codingcontext

package
v0.0.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 17 Imported by: 0

README

codingcontext

Go package for dynamically assembling context for AI coding agents.

Installation

go get github.com/kitproj/coding-context-cli/pkg/codingcontext

Usage

Basic Example
package main

import (
    "context"
    "fmt"
    "log/slog"
    "os"

    "github.com/kitproj/coding-context-cli/pkg/codingcontext"
)

func main() {
    // Create a new context with options
    ctx := codingcontext.New(
        codingcontext.WithSearchPaths("file://.", "file://"+os.Getenv("HOME")),
        codingcontext.WithParams(codingcontext.Params{
            "issue_number": "123",
            "feature":      "authentication",
        }),
        codingcontext.WithLogger(slog.New(slog.NewTextHandler(os.Stderr, nil))),
    )

    // Run a task and get the result
    result, err := ctx.Run(context.Background(), "my-task")
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error: %v\n", err)
        os.Exit(1)
    }

    // Access the assembled context
    for _, rule := range result.Rules {
        fmt.Println(rule.Content)
    }
    fmt.Println(result.Task.Content)
}
}
Advanced Example
package main

import (
    "context"
    "fmt"
    "log/slog"
    "os"

    "github.com/kitproj/coding-context-cli/pkg/codingcontext"
)

func main() {
    // Create selectors for filtering rules
    selectors := make(codingcontext.Selectors)
    selectors.SetValue("language", "go")
    selectors.SetValue("stage", "implementation")

    // Create context with all options
    ctx := codingcontext.New(
        codingcontext.WithSearchPaths(
            "file://.",
            "git::https://github.com/org/repo//path/to/rules",
        ),
        codingcontext.WithParams(codingcontext.Params{
            "issue_number": "123",
        }),
        codingcontext.WithSelectors(selectors),
        codingcontext.WithAgent(codingcontext.AgentCursor),
        codingcontext.WithResume(false),
        codingcontext.WithUserPrompt("Additional context or instructions"),
        codingcontext.WithManifestURL("https://example.com/manifest.txt"),
        codingcontext.WithLogger(slog.New(slog.NewTextHandler(os.Stderr, nil))),
    )

    // Run the task and get the result
    result, err := ctx.Run(context.Background(), "implement-feature")
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error: %v\n", err)
        os.Exit(1)
    }

    // Process the result
    fmt.Printf("Task: %s\n", result.Task.Content)
    fmt.Printf("Rules found: %d\n", len(result.Rules))
    fmt.Printf("Total tokens: %d\n", result.Tokens)
    fmt.Printf("Agent: %s\n", result.Agent)
    
    // Access task metadata using typed fields
    if len(result.Task.FrontMatter.Languages) > 0 {
        fmt.Printf("Languages: %v\n", result.Task.FrontMatter.Languages)
    }
    
    // You can also access any frontmatter field via the Content map
    if customField, ok := result.Task.FrontMatter.Content["custom_field"]; ok {
        fmt.Printf("Custom field: %v\n", customField)
    }
    
    // Access MCP server configurations
    mcpServers := result.MCPServers()
    for name, config := range mcpServers {
        fmt.Printf("MCP Server %s: %s\n", name, config.Command)
    }
}

API Reference

Types
Context

The main type for assembling context.

Result

Result holds the assembled context from running a task:

  • Rules []Markdown[RuleFrontMatter] - List of included rule files
  • Task Markdown[TaskFrontMatter] - Task file with frontmatter and content
  • Tokens int - Total estimated token count
  • Agent Agent - The agent used (from task frontmatter or option)

Methods:

  • MCPServers() MCPServerConfigs - Returns all MCP server configurations from rules and task
Markdown[T]

Represents a markdown file with frontmatter and content (generic type):

  • FrontMatter T - Parsed YAML frontmatter (type depends on usage)
  • Content string - Expanded content of the markdown
  • Tokens int - Estimated token count

Type aliases:

  • TaskMarkdown = Markdown[TaskFrontMatter]
  • RuleMarkdown = Markdown[RuleFrontMatter]
TaskFrontMatter

Frontmatter structure for task files with fields:

  • Agent string - Default agent if not specified via option
  • Languages []string - Programming languages for filtering rules
  • Model string - AI model identifier (metadata only)
  • SingleShot bool - Whether task runs once or multiple times (metadata only)
  • Timeout string - Task timeout in time.Duration format (metadata only)
  • MCPServers MCPServerConfigs - MCP server configurations (metadata only)
  • Resume bool - Whether this task should be resumed
  • Selectors map[string]any - Additional custom selectors for filtering rules
  • ExpandParams *bool - Controls parameter expansion (defaults to true)
  • Content map[string]any - All frontmatter fields as map (from BaseFrontMatter)
RuleFrontMatter

Frontmatter structure for rule files with fields:

  • TaskNames []string - Which task(s) this rule applies to
  • Languages []string - Which programming language(s) this rule applies to
  • Agent string - Which AI agent this rule is intended for
  • MCPServers MCPServerConfigs - MCP server configurations (metadata only)
  • RuleName string - Optional identifier for the rule file
  • ExpandParams *bool - Controls parameter expansion (defaults to true)
  • Content map[string]any - All frontmatter fields as map (from BaseFrontMatter)
CommandFrontMatter

Frontmatter structure for command files with fields:

  • ExpandParams *bool - Controls parameter expansion (defaults to true)
  • Content map[string]any - All frontmatter fields as map (from BaseFrontMatter)
BaseFrontMatter

Base frontmatter structure that other frontmatter types embed:

  • Content map[string]any - All frontmatter fields as a map for selector matching
Agent

Type representing an AI coding agent (string type).

Constants:

  • AgentCursor - Cursor AI (cursor.sh)
  • AgentOpenCode - OpenCode.ai agent
  • AgentCopilot - GitHub Copilot
  • AgentClaude - Anthropic Claude AI
  • AgentGemini - Google Gemini AI
  • AgentAugment - Augment Code assistant
  • AgentWindsurf - Codeium Windsurf
  • AgentCodex - Codex AI agent

Methods:

  • String() string - Returns string representation
  • PathPatterns() []string - Returns path patterns for this agent
  • MatchesPath(path string) bool - Checks if path matches agent patterns
  • ShouldExcludePath(path string) bool - Returns true if path should be excluded
  • IsSet() bool - Returns true if agent is set (non-empty)
  • UserRulePath() string - Returns user-level rules path for agent
MCPServerConfig

Configuration for MCP (Model Context Protocol) servers:

  • Type TransportType - Connection protocol ("stdio", "sse", "http")
  • Command string - Executable to run (for stdio type)
  • Args []string - Command arguments
  • Env map[string]string - Environment variables
  • URL string - Endpoint URL (for http/sse types)
  • Headers map[string]string - Custom HTTP headers
MCPServerConfigs

Type alias: map[string]MCPServerConfig - Maps server names to configurations

TransportType

Type representing MCP transport protocol (string type):

Constants:

  • TransportTypeStdio - Local process communication
  • TransportTypeSSE - Server-Sent Events (remote)
  • TransportTypeHTTP - Standard HTTP/POST
Params

Map of parameter key-value pairs for template substitution: map[string]string

Methods:

  • String() string - Returns string representation
  • Set(value string) error - Parses and sets key=value pair (implements flag.Value)
Selectors

Map structure for filtering rules based on frontmatter metadata: map[string]map[string]bool

Methods:

  • String() string - Returns string representation
  • Set(value string) error - Parses and sets key=value pair (implements flag.Value)
  • SetValue(key, value string) - Sets a value for a key
  • GetValue(key, value string) bool - Checks if value exists for key
  • MatchesIncludes(frontmatter BaseFrontMatter) bool - Tests if frontmatter matches selectors
Task Parser Types

Types for parsing task content with slash commands:

  • Task - Slice of Block elements representing parsed task content
  • Block - Contains either Text or SlashCommand
  • SlashCommand - Parsed slash command with name and arguments
  • Text - Text content (slice of TextLine)
  • TextLine - Single line of text content
  • Input - Top-level wrapper type for parsing
  • Argument - Slash command argument (can be positional or named key=value)

Methods:

  • (*SlashCommand) Params() map[string]string - Returns parsed parameters as map
  • (*Text) Content() string - Returns text content as string
  • Various String() methods for formatting each type
Constants
FreeTextTaskName

Constant: "free-text" - Task name used for free-text prompts

FreeTextParamName

Constant: "text" - Parameter name for text content in free-text tasks

Functions
New(opts ...Option) *Context

Creates a new Context with the given options.

Options:

  • WithSearchPaths(paths ...string) - Add search paths (supports go-getter URLs)
  • WithParams(params Params) - Set parameters for substitution
  • WithSelectors(selectors Selectors) - Set selectors for filtering rules
  • WithAgent(agent Agent) - Set target agent (excludes that agent's own rules)
  • WithResume(resume bool) - Enable resume mode (skips rules)
  • WithUserPrompt(userPrompt string) - Set user prompt to append to task
  • WithManifestURL(manifestURL string) - Set manifest URL for additional search paths
  • WithLogger(logger *slog.Logger) - Set logger
(*Context) Run(ctx context.Context, taskName string) (*Result, error)

Executes the context assembly for the given task name and returns the assembled result structure with rule and task markdown files (including frontmatter and content).

ParseMarkdownFile[T any](path string, frontmatter *T) (Markdown[T], error)

Parses a markdown file into frontmatter and content. Generic function that works with any frontmatter type.

ParseTask(text string) (Task, error)

Parses task text content into blocks of text and slash commands.

ParseParams(s string) (Params, error)

Parses a string containing key=value pairs with quoted values.

Examples:

// Parse quoted key-value pairs
params, _ := ParseParams(`key1="value1" key2="value2"`)
// Result: map[string]string{"key1": "value1", "key2": "value2"}

// Parse with spaces in values
params, _ := ParseParams(`key1="value with spaces" key2="value2"`)
// Result: map[string]string{"key1": "value with spaces", "key2": "value2"}

// Parse with escaped quotes
params, _ := ParseParams(`key1="value with \"escaped\" quotes"`)
// Result: map[string]string{"key1": "value with \"escaped\" quotes"}
ParseAgent(s string) (Agent, error)

Parses a string into an Agent type. Returns error if agent is not supported.

See Also

Documentation

Index

Constants

View Source
const FreeTextParamName = "text"

FreeTextParamName is the parameter name used for the text content in free-text tasks

View Source
const FreeTextTaskName = "free-text"

FreeTextTaskName is the task name used for free-text prompts

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent added in v0.0.17

type Agent string

Agent represents an AI coding agent

const (
	AgentCursor   Agent = "cursor"
	AgentOpenCode Agent = "opencode"
	AgentCopilot  Agent = "copilot"
	AgentClaude   Agent = "claude"
	AgentGemini   Agent = "gemini"
	AgentAugment  Agent = "augment"
	AgentWindsurf Agent = "windsurf"
	AgentCodex    Agent = "codex"
)

Supported agents

func ParseAgent added in v0.0.17

func ParseAgent(s string) (Agent, error)

ParseAgent parses a string into an Agent type

func (Agent) IsSet added in v0.0.18

func (a Agent) IsSet() bool

IsSet returns true if an agent has been specified (non-empty)

func (Agent) MatchesPath added in v0.0.17

func (a Agent) MatchesPath(path string) bool

MatchesPath returns true if the given path matches any of the agent's patterns

func (Agent) PathPatterns added in v0.0.17

func (a Agent) PathPatterns() []string

PathPatterns returns the path patterns associated with this agent

func (*Agent) Set added in v0.0.18

func (a *Agent) Set(value string) error

Set implements the flag.Value interface for Agent

func (Agent) ShouldExcludePath added in v0.0.18

func (a Agent) ShouldExcludePath(path string) bool

ShouldExcludePath returns true if the given path should be excluded based on this agent Empty agent means no exclusion

func (Agent) String added in v0.0.17

func (a Agent) String() string

String returns the string representation of the agent

func (Agent) UserRulePath added in v0.0.24

func (a Agent) UserRulePath() string

UserRulePath returns the primary user-level rules path for this agent relative to home directory. Returns an empty string if the agent is not set. The path is relative and should be joined with the home directory.

type Argument added in v0.0.22

type Argument struct {
	Key   string `parser:"(@Term Assign)?"`
	Value string `parser:"(@String | @Term)"`
}

Argument represents either a named (key=value) or positional argument

func (Argument) String added in v0.0.22

func (a Argument) String() string

String returns the original text representation of an argument

type BaseFrontMatter added in v0.0.18

type BaseFrontMatter struct {
	Content map[string]any `json:"-" yaml:",inline"`
}

BaseFrontMatter represents parsed YAML frontmatter from markdown files

type Block added in v0.0.22

type Block struct {
	SlashCommand *SlashCommand `parser:"@@"`
	Text         *Text         `parser:"| @@"`
}

Block represents either a slash command or text content

func (Block) String added in v0.0.22

func (b Block) String() string

String returns the original text representation of a block

type CommandFrontMatter added in v0.0.22

type CommandFrontMatter struct {
	BaseFrontMatter `yaml:",inline"`

	// ExpandParams controls whether parameter expansion should occur
	// Defaults to true if not specified
	ExpandParams *bool `yaml:"expand,omitempty" json:"expand,omitempty"`
}

CommandFrontMatter represents the frontmatter fields for command files. Previously this was an empty placeholder struct, but now supports the expand field to control parameter expansion behavior in command content.

func (*CommandFrontMatter) UnmarshalJSON added in v0.0.23

func (c *CommandFrontMatter) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaler that populates both typed fields and Content map

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context holds the configuration and state for assembling coding context

func New

func New(opts ...Option) *Context

New creates a new Context with the given options

func (*Context) Run

func (cc *Context) Run(ctx context.Context, taskName string) (*Result, error)

Run executes the context assembly for the given taskName and returns the assembled result. The taskName is looked up in task search paths and its content is parsed into blocks. If the taskName cannot be found as a task file, an error is returned.

type Input added in v0.0.22

type Input struct {
	Blocks []Block `parser:"@@*"`
}

Input is the top-level wrapper for parsing

type MCPServerConfig added in v0.0.18

type MCPServerConfig struct {
	// Type specifies the connection protocol.
	// Values: "stdio", "sse", "http".
	Type TransportType `json:"type,omitempty" yaml:"type,omitempty"`

	// Command is the executable to run (e.g. "npx", "docker").
	// Required for "stdio" type.
	Command string `json:"command,omitempty" yaml:"command,omitempty"`

	// Args is an array of arguments for the command.
	Args []string `json:"args,omitempty" yaml:"args,omitempty"`

	// Env defines environment variables for the server process.
	Env map[string]string `json:"env,omitempty" yaml:"env,omitempty"`

	// URL is the endpoint for "http" or "sse" types.
	// Required for remote connections.
	URL string `json:"url,omitempty" yaml:"url,omitempty"`

	// Headers contains custom HTTP headers (e.g. {"Authorization": "Bearer ..."}).
	// Used for "http" and "sse" types.
	Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`

	// Content holds arbitrary additional fields from YAML/JSON that aren't in the struct
	Content map[string]any `json:"-" yaml:",inline"`
}

MCPServerConfig defines the common configuration fields supported by both platforms. It also supports arbitrary additional fields via the Content map.

func (*MCPServerConfig) UnmarshalJSON added in v0.0.25

func (m *MCPServerConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaler that populates both typed fields and Content map

type MCPServerConfigs added in v0.0.21

type MCPServerConfigs map[string]MCPServerConfig

MCPServerConfigs maps server names to their configurations.

type Markdown

type Markdown[T any] struct {
	FrontMatter T      // Parsed YAML frontmatter
	Content     string // Expanded content of the markdown
	Tokens      int    // Estimated token count
}

Markdown represents a markdown file with frontmatter and content

func ParseMarkdownFile

func ParseMarkdownFile[T any](path string, frontMatter *T) (Markdown[T], error)

ParseMarkdownFile parses a markdown file into frontmatter and content

type Option

type Option func(*Context)

Option is a functional option for configuring a Context

func WithAgent added in v0.0.17

func WithAgent(agent Agent) Option

WithAgent sets the target agent, which excludes that agent's own rules

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets the logger

func WithManifestURL added in v0.0.20

func WithManifestURL(manifestURL string) Option

WithManifestURL sets the manifest URL

func WithParams

func WithParams(params Params) Option

WithParams sets the parameters

func WithResume

func WithResume(resume bool) Option

WithResume enables resume mode, which skips rule discovery and bootstrap scripts

func WithSearchPaths added in v0.0.20

func WithSearchPaths(paths ...string) Option

WithSearchPaths adds one or more search paths

func WithSelectors

func WithSelectors(selectors Selectors) Option

WithSelectors sets the selectors

func WithUserPrompt added in v0.0.24

func WithUserPrompt(userPrompt string) Option

WithUserPrompt sets the user prompt to append to the task

type Params

type Params map[string]string

Params is a map of parameter key-value pairs for template substitution

func ParseParams added in v0.0.19

func ParseParams(s string) (Params, error)

ParseParams parses a string containing key=value pairs separated by spaces. Values must be quoted with double quotes, and quotes can be escaped. Unquoted values are treated as an error. Examples:

  • `key1="value1" key2="value2"`
  • `key1="value with spaces" key2="value2"`
  • `key1="value with \"escaped\" quotes"`

func (*Params) Set

func (p *Params) Set(value string) error

Set implements the flag.Value interface for Params

func (*Params) String

func (p *Params) String() string

String implements the fmt.Stringer interface for Params

type Result

type Result struct {
	Rules  []Markdown[RuleFrontMatter] // List of included rule files
	Task   Markdown[TaskFrontMatter]   // Task file with frontmatter and content
	Tokens int                         // Total token count
	Agent  Agent                       // The agent used (from task or -a flag)
}

Result holds the assembled context from running a task

func (*Result) MCPServers added in v0.0.18

func (r *Result) MCPServers() MCPServerConfigs

MCPServers returns all MCP servers from both rules and the task. Servers from the task take precedence over servers from rules. If multiple rules define the same server name, the behavior is non-deterministic.

type RuleFrontMatter added in v0.0.18

type RuleFrontMatter struct {
	BaseFrontMatter `yaml:",inline"`

	// TaskNames specifies which task(s) this rule applies to
	// Array of task names for OR logic
	TaskNames []string `yaml:"task_names,omitempty" json:"task_names,omitempty"`

	// Languages specifies which programming language(s) this rule applies to
	// Array of languages for OR logic (e.g., ["go", "python"])
	Languages []string `yaml:"languages,omitempty" json:"languages,omitempty"`

	// Agent specifies which AI agent this rule is intended for
	Agent string `yaml:"agent,omitempty" json:"agent,omitempty"`

	// MCPServers maps server names to their configurations
	// Metadata only, does not filter
	MCPServers MCPServerConfigs `yaml:"mcp_servers,omitempty" json:"mcp_servers,omitempty"`

	// RuleName is an optional identifier for the rule file
	RuleName string `yaml:"rule_name,omitempty" json:"rule_name,omitempty"`

	// ExpandParams controls whether parameter expansion should occur
	// Defaults to true if not specified
	ExpandParams *bool `yaml:"expand,omitempty" json:"expand,omitempty"`
}

RuleFrontMatter represents the standard frontmatter fields for rule files

func (*RuleFrontMatter) UnmarshalJSON added in v0.0.18

func (r *RuleFrontMatter) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaler that populates both typed fields and Content map

type RuleMarkdown added in v0.0.18

type RuleMarkdown = Markdown[RuleFrontMatter]

RuleMarkdown is a Markdown with RuleFrontMatter

type Selectors

type Selectors map[string]map[string]bool

Selectors stores selector key-value pairs where values are stored in inner maps Multiple values for the same key use OR logic (match any value in the inner map) Each value can be represented exactly once per key

func (*Selectors) GetValue

func (s *Selectors) GetValue(key, value string) bool

GetValue returns true if the given value exists in the inner map for the given key. Returns false if the key doesn't exist or the value is not present.

func (*Selectors) MatchesIncludes

func (includes *Selectors) MatchesIncludes(frontmatter BaseFrontMatter) bool

MatchesIncludes returns true if the frontmatter matches all include selectors. If a key doesn't exist in frontmatter, it's allowed. Multiple values for the same key use OR logic (matches if frontmatter value is in the inner map). This enables combining CLI selectors (-s flag) with task frontmatter selectors: both are added to the same Selectors map, creating an OR condition for rules to match.

func (*Selectors) Set

func (s *Selectors) Set(value string) error

Set implements the flag.Value interface for Selectors

func (*Selectors) SetValue

func (s *Selectors) SetValue(key, value string)

SetValue sets a value in the inner map for the given key. If the key doesn't exist, it creates a new inner map. Each value can be represented exactly once per key.

func (*Selectors) String

func (s *Selectors) String() string

String implements the fmt.Stringer interface for Selectors

type SlashCommand added in v0.0.22

type SlashCommand struct {
	Name      string     `parser:"Slash @Term"`
	Arguments []Argument `parser:"(Whitespace @@)* Whitespace? Newline?"`
}

SlashCommand represents a command starting with "/" that ends with a newline or EOF The newline is optional to handle EOF, but when present, prevents matching inline slashes

func (*SlashCommand) Params added in v0.0.22

func (s *SlashCommand) Params() map[string]string

Params converts the slash command's arguments into a parameter map Returns a map with: - "ARGUMENTS": space-separated string of all arguments - "1", "2", etc.: positional parameters (1-indexed) - named parameters: key-value pairs from key="value" arguments

func (SlashCommand) String added in v0.0.22

func (s SlashCommand) String() string

String returns the original text representation of a slash command

type Task added in v0.0.22

type Task []Block

Task represents a parsed task, which is a sequence of blocks

func ParseTask added in v0.0.22

func ParseTask(text string) (Task, error)

ParseTask parses a task string into a Task structure

func (Task) String added in v0.0.22

func (t Task) String() string

String returns the original text representation of a task

type TaskFrontMatter added in v0.0.18

type TaskFrontMatter struct {
	BaseFrontMatter `yaml:",inline"`

	// Agent specifies the default agent if not specified via -a flag
	// This is not used for selecting tasks or rules, only as a default
	Agent string `yaml:"agent,omitempty" json:"agent,omitempty"`

	// Languages specifies the programming language(s) for filtering rules
	// Array of languages for OR logic (e.g., ["go", "python"])
	Languages []string `yaml:"languages,omitempty" json:"languages,omitempty"`

	// Model specifies the AI model identifier
	// Does not filter rules, metadata only
	Model string `yaml:"model,omitempty" json:"model,omitempty"`

	// SingleShot indicates whether the task runs once or multiple times
	// Does not filter rules, metadata only
	SingleShot bool `yaml:"single_shot,omitempty" json:"single_shot,omitempty"`

	// Timeout specifies the task timeout in time.Duration format (e.g., "10m", "1h")
	// Does not filter rules, metadata only
	Timeout string `yaml:"timeout,omitempty" json:"timeout,omitempty"`

	// MCPServers maps server names to their configurations
	// Does not filter rules, metadata only
	MCPServers MCPServerConfigs `yaml:"mcp_servers,omitempty" json:"mcp_servers,omitempty"`

	// Resume indicates if this task should be resumed
	Resume bool `yaml:"resume,omitempty" json:"resume,omitempty"`

	// Selectors contains additional custom selectors for filtering rules
	Selectors map[string]any `yaml:"selectors,omitempty" json:"selectors,omitempty"`

	// ExpandParams controls whether parameter expansion should occur
	// Defaults to true if not specified
	ExpandParams *bool `yaml:"expand,omitempty" json:"expand,omitempty"`
}

TaskFrontMatter represents the standard frontmatter fields for task files

func (*TaskFrontMatter) UnmarshalJSON added in v0.0.18

func (t *TaskFrontMatter) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaler that populates both typed fields and Content map

type TaskMarkdown added in v0.0.18

type TaskMarkdown = Markdown[TaskFrontMatter]

TaskMarkdown is a Markdown with TaskFrontMatter

type Text added in v0.0.22

type Text struct {
	Lines []TextLine `parser:"@@+"`
}

Text represents a block of text It can span multiple lines, consuming line content and newlines But it will stop before a newline that's followed by a slash (potential command)

func (*Text) Content added in v0.0.22

func (t *Text) Content() string

Content returns the text content with all lines concatenated

func (Text) String added in v0.0.22

func (t Text) String() string

String returns the original text representation of text

type TextLine added in v0.0.22

type TextLine struct {
	NonSlashStart []string `parser:"(@Term | @String | @Assign | @Whitespace)"`           // First token can't be Slash
	RestOfLine    []string `parser:"(@Term | @String | @Slash | @Assign | @Whitespace)*"` // Rest can include Slash
	NewlineOpt    string   `parser:"@Newline?"`
}

TextLine is a single line of text content (not starting with a slash) It matches tokens until the end of the line

type TransportType added in v0.0.18

type TransportType string

TransportType defines the communication protocol used by the server. Supported by both Claude and Cursor.

const (
	// TransportTypeStdio is for local processes (executables).
	TransportTypeStdio TransportType = "stdio"

	// TransportTypeSSE is for Server-Sent Events (Remote).
	// Note: Claude Code prefers HTTP over SSE, but supports it.
	TransportTypeSSE TransportType = "sse"

	// TransportTypeHTTP is for standard HTTP/POST interactions.
	TransportTypeHTTP TransportType = "http"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL