Documentation
¶
Index ¶
- Constants
- type Backend
- type CallHierarchyArgs
- type CodeActionsArgs
- type FileArgs
- type InlayHintsArgs
- type Multiplexer
- type PositionArgs
- type ReferencesArgs
- type RenameArgs
- type Tool
- func (t *Tool) HandlesFile(path string) bool
- func (t *Tool) Instructions() string
- func (t *Tool) Kind() string
- func (t *Tool) Name() string
- func (t *Tool) Restart(ctx context.Context) error
- func (t *Tool) SetFileTypes(fileTypes []string)
- func (t *Tool) SetToolsChangedHandler(handler func())
- func (t *Tool) Start(ctx context.Context) error
- func (t *Tool) State() lifecycle.StateInfo
- func (t *Tool) Stop(ctx context.Context) error
- func (t *Tool) Tools(context.Context) ([]tools.Tool, error)
- func (t *Tool) WorkingDir() string
- type TypeHierarchyArgs
- type WorkspaceArgs
- type WorkspaceSymbolsArgs
Constants ¶
const ( ToolNameLSPWorkspace = "lsp_workspace" ToolNameLSPHover = "lsp_hover" ToolNameLSPDefinition = "lsp_definition" ToolNameLSPReferences = "lsp_references" ToolNameLSPDocumentSymbols = "lsp_document_symbols" ToolNameLSPWorkspaceSymbols = "lsp_workspace_symbols" ToolNameLSPDiagnostics = "lsp_diagnostics" ToolNameLSPRename = "lsp_rename" ToolNameLSPCodeActions = "lsp_code_actions" ToolNameLSPFormat = "lsp_format" ToolNameLSPCallHierarchy = "lsp_call_hierarchy" ToolNameLSPTypeHierarchy = "lsp_type_hierarchy" ToolNameLSPImplementations = "lsp_implementations" ToolNameLSPSignatureHelp = "lsp_signature_help" ToolNameLSPInlayHints = "lsp_inlay_hints" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
Backend pairs a raw Tool (used for file-type routing) with an optionally-wrapped ToolSet (used for tool enumeration, so that per-toolset config like tool filters, instructions, or toon wrappers are respected).
type CallHierarchyArgs ¶
type CallHierarchyArgs struct {
PositionArgs
Direction string `json:"direction" jsonschema:"Direction: 'incoming' (who calls this) or 'outgoing' (what this calls)"`
}
CallHierarchyArgs for getting call hierarchy.
type CodeActionsArgs ¶
type CodeActionsArgs struct {
File string `json:"file" jsonschema:"Absolute path to the source file"`
StartLine int `json:"start_line" jsonschema:"Start line of the range (1-based)"`
EndLine int `json:"end_line,omitempty" jsonschema:"End line of the range (1-based, defaults to start_line)"`
}
CodeActionsArgs for getting available code actions.
type FileArgs ¶
type FileArgs struct {
File string `json:"file" jsonschema:"Absolute path to the source file"`
}
FileArgs is for tools that only need a file path.
type InlayHintsArgs ¶
type InlayHintsArgs struct {
File string `json:"file" jsonschema:"Absolute path to the source file"`
StartLine int `json:"start_line,omitempty" jsonschema:"Start line of range (1-based, default: 1)"`
EndLine int `json:"end_line,omitempty" jsonschema:"End line of range (1-based, default: end of file)"`
}
InlayHintsArgs for getting inlay hints.
type Multiplexer ¶
type Multiplexer struct {
// contains filtered or unexported fields
}
Multiplexer combines multiple LSP backends into a single toolset. It presents one set of lsp_* tools and routes each call to the appropriate backend based on the file extension in the tool arguments.
func NewLSPMultiplexer ¶
func NewLSPMultiplexer(backends []Backend) *Multiplexer
NewLSPMultiplexer creates a multiplexer that routes LSP tool calls to the appropriate backend based on file type.
func (*Multiplexer) Instructions ¶
func (m *Multiplexer) Instructions() string
func (*Multiplexer) Kind ¶
func (m *Multiplexer) Kind() string
Kind returns the user-facing classification of this toolset.
func (*Multiplexer) Name ¶
func (m *Multiplexer) Name() string
Name returns a comma-separated list of backend command basenames (e.g. "gopls,rust-analyzer"). The multiplexer wraps multiple LSP toolsets behind a single ToolSet entry, so the /tools dialog needs one label that covers them all instead of one row per backend.
type PositionArgs ¶
type PositionArgs struct {
File string `json:"file" jsonschema:"Absolute path to the source file"`
Line int `json:"line" jsonschema:"Line number (1-based)"`
Character int `json:"character" jsonschema:"Character position on the line (1-based)"`
}
PositionArgs is the base for all position-based tool arguments.
type ReferencesArgs ¶
type ReferencesArgs struct {
PositionArgs
IncludeDeclaration *bool `json:"include_declaration,omitempty" jsonschema:"Include the declaration in results (default: true)"`
}
ReferencesArgs extends PositionArgs with an include_declaration option.
type RenameArgs ¶
type RenameArgs struct {
PositionArgs
NewName string `json:"new_name" jsonschema:"The new name for the symbol"`
}
RenameArgs extends PositionArgs with the new name.
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
Tool implements tools.ToolSet for connecting to any LSP server. It provides stateless code intelligence tools that automatically manage the LSP server lifecycle and document state.
func NewLSPTool ¶
func NewLSPTool(command string, args, env []string, workingDir string, policy ...lifecycle.Policy) *Tool
NewLSPTool creates a new LSP tool that connects to an LSP server.
The optional policy lets callers tune restart/backoff behaviour. When the zero value is passed the supervisor uses its built-in defaults (RestartOnFailure, 5 attempts, 1s..32s backoff). Internal callbacks (OnDisconnect, Logger) are always set by the constructor.
func (*Tool) HandlesFile ¶
HandlesFile checks if this LSP handles the given file based on its extension.
func (*Tool) Instructions ¶
func (*Tool) Kind ¶
Kind returns the user-facing classification of this toolset. Used by status surfaces such as the /tools dialog so they can label the toolset without leaking Go type names.
func (*Tool) Name ¶
Name returns the basename of the configured command ("gopls", "rust-analyzer", …). It's the most useful identifier in the absence of a YAML name: field on LSP toolsets, and lets the /tools dialog distinguish multiple language servers in the same agent.
func (*Tool) Restart ¶
Restart brings the LSP server back up regardless of state. Failed or Stopped supervisors are recovered via Start; otherwise the current session is dropped and we wait for the supervisor to reconnect. Blocks up to 35s (matching the MCP toolset).
func (*Tool) SetFileTypes ¶
SetFileTypes sets the file types (extensions) that this LSP server handles.
func (*Tool) SetToolsChangedHandler ¶
func (t *Tool) SetToolsChangedHandler(handler func())
SetToolsChangedHandler registers a callback that is invoked after the supervisor reaches Ready and the server's capability matrix becomes available. The runtime uses this to re-query Tools() and pick up the capability-filtered list.
func (*Tool) State ¶
State returns a snapshot of the underlying supervisor's lifecycle state, suitable for the /tools dialog and lifecycle log messages.
func (*Tool) WorkingDir ¶
WorkingDir returns the working directory of the LSP server process. This is intended for testing only.
type TypeHierarchyArgs ¶
type TypeHierarchyArgs struct {
PositionArgs
Direction string `json:"direction" jsonschema:"Direction: 'supertypes' (parent types) or 'subtypes' (child types)"`
}
TypeHierarchyArgs for getting type hierarchy.
type WorkspaceArgs ¶
type WorkspaceArgs struct{}
WorkspaceArgs is empty - the workspace tool takes no arguments.
type WorkspaceSymbolsArgs ¶
type WorkspaceSymbolsArgs struct {
Query string `json:"query" jsonschema:"Search query to filter symbols (supports fuzzy matching)"`
}
WorkspaceSymbolsArgs for searching symbols across the workspace.