tool

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: AGPL-3.0 Imports: 36 Imported by: 0

Documentation

Overview

Package tool defines tool contracts and built-in tool implementations.

Index

Constants

View Source
const (
	ReadToolName     = "read"
	DefaultReadLimit = 1000
)
View Source
const (
	WorkflowReviewOverallCorrectnessCorrect   = "correct"
	WorkflowReviewOverallCorrectnessIncorrect = "incorrect"
)
View Source
const ApplyPatchToolName = "apply_patch"
View Source
const (
	BashToolName = "bash"
)
View Source
const CodeActionToolName = "code_action"
View Source
const DefinitionToolName = "definition"
View Source
const DiagnosticsToolName = "diagnostics"
View Source
const LocateToolName = "locate"
View Source
const MCPToolNamePrefix = "mcp_"
View Source
const MCPToolWildcard = "mcp:*"
View Source
const MemoryContentMaxChars = 2000
View Source
const MemoryToolName = "memory"
View Source
const QuestionToolName = "question"
View Source
const RefsToolName = "refs"
View Source
const RenameSymbolToolName = "rename_symbol"
View Source
const SearchSkillsToolName = "search_skills"
View Source
const SearchToolName = "search"
View Source
const SkillToolName = "skill"
View Source
const SymbolsToolName = "symbols"
View Source
const TaskReviewToolName = "task_review"
View Source
const TaskWorkflowToolName = "task_workflow"
View Source
const TestToolName = "test"
View Source
const TraceToolName = "trace"
View Source
const (
	WebFetchToolName = "web_fetch"
)
View Source
const (
	WebSearchToolName = "web_search"
)
View Source
const WorkflowPhaseOutputToolName = "workflow_phase_output"
View Source
const WorkflowReviewResultToolName = "workflow_review_result"
View Source
const WriteToolName = "write"

Variables

View Source
var (
	ErrApplyPatchNoFilesModified = errors.New("patch produced the same file content; nothing changed")
	ErrApplyPatchHunkNoMatch     = errors.New("hunk did not match")
	ErrApplyPatchHunkAmbiguous   = errors.New("hunk matched multiple locations")
)
View Source
var (
	ErrApplyPatchEmpty            = errors.New("patch is empty")
	ErrApplyPatchMissingBegin     = errors.New("patch is missing first line: *** Begin Patch")
	ErrApplyPatchMissingEnd       = errors.New("patch is missing final line: *** End Patch")
	ErrApplyPatchNoOperations     = errors.New("patch must contain at least one file operation")
	ErrApplyPatchEmptyPath        = errors.New("file path is required")
	ErrApplyPatchAbsolutePath     = errors.New("absolute paths are not allowed")
	ErrApplyPatchParentPath       = errors.New("paths must stay inside the workspace")
	ErrApplyPatchUnknownHeader    = errors.New("unknown patch header")
	ErrApplyPatchEmptyAdd         = errors.New("add file operation must include at least one added line")
	ErrApplyPatchEmptyUpdate      = errors.New("update file operation must include a move or at least one changed line")
	ErrApplyPatchMalformedLine    = errors.New("invalid patch syntax")
	ErrApplyPatchReadLinePrefixes = errors.New("patch lines must not include read output line number prefixes")
)
View Source
var (
	ErrCodeActionPathRequired          = errors.New("path is required")
	ErrCodeActionStartLineInvalid      = errors.New("start_line must be at least 1")
	ErrCodeActionEndLineInvalid        = errors.New("end_line must be at least 1")
	ErrCodeActionStartCharacterInvalid = errors.New("start_character must be at least 0")
	ErrCodeActionEndCharacterInvalid   = errors.New("end_character must be at least 0")
	ErrCodeActionRangeInvalid          = errors.New("end position must not be before the start position")
)
View Source
var (
	ErrRuntimeOwnedExecution    = errors.New("generic execution is runtime-owned and must be executed by the runtime service")
	ErrCommandRequired          = errors.New("command is required")
	ErrCommandWorkingDirMissing = errors.New("working_directory must exist")
	ErrCommandWorkingDirNotDir  = errors.New("working_directory must be a directory")
	ErrShellCommandRequired     = errors.New("command is required")
)
View Source
var (
	ErrDefinitionPathRequired      = errors.New("path is required")
	ErrDefinitionLineRequired      = errors.New("line must be >= 1")
	ErrDefinitionCharacterInvalid  = errors.New("provide character >= 0 or symbol")
	ErrSymbolsQueryRequired        = errors.New("query is required")
	ErrTraceModeRequired           = errors.New("mode must be callers, callees, or graph")
	ErrTraceDepthInvalid           = errors.New("depth must be between 1 and 4")
	ErrTraceMaxNodesInvalid        = errors.New("max_nodes must be between 1 and 500")
	ErrRefsModeInvalid             = errors.New("mode must be all, readers, or writers")
	ErrRefsMaxResultsInvalid       = errors.New("max_results must be between 1 and 500")
	ErrDiagnosticsPathsRequired    = errors.New("paths must contain at least one file")
	ErrDiagnosticsPathBlank        = errors.New("paths must not contain blank entries")
	ErrDiagnosticsPathLimitInvalid = errors.New("paths must contain at most 32 files")
)
View Source
var (
	ErrLocatePathRequired      = errors.New("path is required")
	ErrLocatePathNotFolder     = errors.New("path must be a directory")
	ErrLocateMaxMatchesInvalid = fmt.Errorf("max_matches must be between 1 and %d", searchMaxMatchesLimit)
)
View Source
var (
	ErrMemoryActionInvalid   = errors.New("action must be save, list, or delete")
	ErrMemoryContentRequired = errors.New("content is required for save")
	ErrMemoryIDRequired      = errors.New("id is required for delete")
)
View Source
var (
	ErrMkdirPathRequired   = errors.New("path is required")
	ErrMkdirPathExistsFile = errors.New("path exists and is not a directory")
)
View Source
var (
	ErrQuestionRequired      = errors.New("question is required")
	ErrQuestionOptionsEmpty  = errors.New("options is required")
	ErrQuestionOptionInvalid = errors.New("options must not contain empty values")
)
View Source
var (
	ErrReadPathsRequired = errors.New("path or paths is required")
	ErrReadPathRequired  = ErrReadPathsRequired
	ErrReadPathConflict  = errors.New("use either path or paths, not both")
	ErrReadEmptyPath     = errors.New("paths must not contain empty values")
	ErrReadOffsetInvalid = errors.New("offset must be at least 0")
	ErrReadLimitInvalid  = errors.New("limit must be at least 1")
)
View Source
var (
	ErrRenameSymbolPathRequired     = errors.New("path is required")
	ErrRenameSymbolLineInvalid      = errors.New("line must be at least 1")
	ErrRenameSymbolCharacterInvalid = errors.New("character must be at least 0")
	ErrRenameSymbolNewNameRequired  = errors.New("new_name is required")
)
View Source
var (
	ErrSearchQueryRequired     = errors.New("query is required")
	ErrSearchPathRequired      = errors.New("path is required")
	ErrSearchModeInvalid       = errors.New("mode must be lexical or hybrid")
	ErrSearchMaxMatchesInvalid = fmt.Errorf("max_matches must be between 1 and %d", searchMaxMatchesLimit)
)
View Source
var (
	ErrTaskActionRequired           = errors.New("action is required")
	ErrTaskInputIDRequired          = errors.New("task_id is required")
	ErrTaskParentInputInvalid       = errors.New("parent_task_id must reference another task")
	ErrTaskInputTitleRequired       = errors.New("title is required")
	ErrTaskInputUpdateRequired      = errors.New("status, progress, or notes is required")
	ErrTaskStatusInvalid            = errors.New("status must be pending or in_progress when set")
	ErrTaskCompleteActionOnly       = errors.New("use action complete to mark a task done; status only accepts pending or in_progress")
	ErrTaskSummaryRequired          = errors.New("summary is required")
	ErrTaskBlockReasonRequired      = errors.New("block_reason is required")
	ErrTaskReviewStatusInvalid      = errors.New("review_status must be pass, concern, fail, or accepted")
	ErrTaskReviewSummaryNeeded      = errors.New("review_summary is required")
	ErrTaskWorkflowFieldUnsupported = errors.New("field is not supported for this task_workflow action")
	ErrTaskReviewFieldUnsupported   = errors.New("field is not supported for this task_review action")
)
View Source
var (
	ErrTestPathRequired          = errors.New("path must not be empty")
	ErrTestTimeoutInvalid        = fmt.Errorf("timeout must be between %d and %d milliseconds; timeout uses milliseconds, so 90000 means 90 seconds and 600 means 0.6 seconds", testMinTimeoutMS, testMaxTimeoutMS)
	ErrTestFilterUnsupported     = errors.New("filter is not supported for the selected test framework")
	ErrTestPathTargetUnsupported = errors.New("path targeting is not supported for the selected test framework")
	ErrTestWatchModeUnsupported  = errors.New("test only supports one-shot commands, not watcher or server modes")
)
View Source
var (
	ErrWebFetchURLRequired    = errors.New("url is required")
	ErrWebFetchURLInvalid     = errors.New("url must be a valid http or https URL")
	ErrWebFetchURLSearch      = errors.New("url must be a direct page URL, not a search engine")
	ErrWebFetchMethodInvalid  = errors.New(`method must be one of "GET", "POST", "PUT", "PATCH", "DELETE", or "HEAD"`)
	ErrWebFetchFormatInvalid  = errors.New(`format must be one of "auto", "markdown", "text", "json", or "raw"`)
	ErrWebFetchBodyMethod     = errors.New("body is only supported for POST, PUT, PATCH, or DELETE")
	ErrWebFetchBinaryResponse = errors.New("response content type is not supported for web_fetch")
	ErrWebFetchBodyTooLarge   = errors.New("response body exceeds the maximum size")
	ErrWebFetchCrossHostRedir = errors.New("redirect to a different host is not allowed")
)
View Source
var (
	ErrWebSearchQueryRequired        = errors.New("query is required")
	ErrWebSearchLimitInvalid         = fmt.Errorf("limit must be between 1 and %d", webSearchMaxLimit)
	ErrWebSearchFreshnessDaysInvalid = errors.New("freshness_days must be greater than zero")
	ErrWebSearchServiceRequired      = errors.New("web search service is required")
	ErrWebSearchProviderRequired     = errors.New("web search provider is required")
	ErrWebSearchProviderInvalid      = errors.New("provider must not be blank")
)
View Source
var (
	ErrWorkflowReviewPassRequired               = errors.New("review_pass is required")
	ErrWorkflowReviewOverallCorrectnessInvalid  = errors.New("overall_correctness must be correct or incorrect")
	ErrWorkflowReviewOverallSummaryRequired     = errors.New("overall_summary is required")
	ErrWorkflowReviewFindingSeverityInvalid     = errors.New("finding severity must be P0, P1, P2, or P3")
	ErrWorkflowReviewFindingPathRequired        = errors.New("finding path is required")
	ErrWorkflowReviewFindingLineInvalid         = errors.New("finding line must be > 0")
	ErrWorkflowReviewFindingTitleRequired       = errors.New("finding title is required")
	ErrWorkflowReviewFindingExplanationRequired = errors.New("finding explanation is required")
)
View Source
var (
	ErrWritePathRequired    = errors.New("path is required")
	ErrWriteContentRequired = errors.New("content is required")
)
View Source
var (
	ErrBashCommandRequired = errors.New("cmd is required")
)
View Source
var ErrCodeIntelRequired = errors.New("code intel is required")
View Source
var ErrGitDiffStagedRequired = errors.New("staged is required")
View Source
var ErrGitRepositoryRequired = errors.New("workspace directory is not inside a git repository")
View Source
var ErrGitShowRevisionRequired = errors.New("rev is required")
View Source
var ErrGitStatusNoArguments = errors.New("git_status takes no fields")
View Source
var ErrInvalidArguments = errors.New("tool arguments are invalid")
View Source
var ErrMemoryManagerRequired = errors.New("memory manager is required")
View Source
var ErrQuestionAskerRequired = errors.New("question asker is required")
View Source
var ErrSkillCatalogRequired = errors.New("skill catalog is required")
View Source
var ErrStructuredResultInvalid = errors.New("structured result must be valid JSON")
View Source
var ErrTaskManagerRequired = errors.New("task manager is required")
View Source
var ErrTaskReviewActionInvalid = errors.New("action must be list or review")
View Source
var ErrTaskWorkflowActionInvalid = errors.New("action must be list, create, update, block, or complete")
View Source
var ErrTestFrameworkNotDetected = errors.New("could not detect a supported test framework from the selected path")
View Source
var ErrWorkflowPhaseOutputFieldsRequired = errors.New("fields must include at least one non-empty value")
View Source
var ErrWorkflowPhaseOutputManagerRequired = errors.New("workflow phase output manager is required")
View Source
var ErrWorkflowReviewResultManagerRequired = errors.New("workflow review result manager is required")
View Source
var ErrWorkspaceRequired = errors.New("workspace scope is required")

Functions

func AppendUniqueRange

func AppendUniqueRange(dst []lsp.Range, value lsp.Range) []lsp.Range

func BestEffortCodeActionRanges

func BestEffortCodeActionRanges(filePath string, startLine, startCharacter, endLine, endCharacter int) []lsp.Range

func BestEffortPositionCandidates

func BestEffortPositionCandidates(filePath string, line, character int) []int

func CommandScopedNetworkTarget

func CommandScopedNetworkTarget(command string, prefixRule []string) string

func CurrentObservedResourceState

func CurrentObservedResourceState(kind ObservedResourceKind, path string) (string, bool, error)

func CurrentObservedResourceVersion

func CurrentObservedResourceVersion(kind ObservedResourceKind, path string) (string, bool, error)

func DecodeArgs

func DecodeArgs(toolName string, args json.RawMessage, dst any) error

func DecodeArgsStrict

func DecodeArgsStrict(toolName string, args json.RawMessage, dst any, allowedFields ...string) error

func DefaultErrorText

func DefaultErrorText(toolName string, err error) string

func FormatDiagnostics

func FormatDiagnostics(files []CodeIntelFileDiagnostics) string

func InvalidArguments

func InvalidArguments(toolName string, cause error) error

func IsMCPToolName

func IsMCPToolName(name string) bool

func MCPToolName

func MCPToolName(serverName, remoteToolName string) string

func MCPToolNameComponent

func MCPToolNameComponent(value string) string

func MarshalStructuredResult

func MarshalStructuredResult(value any) (json.RawMessage, error)

func NewCodeIntelNoticeError

func NewCodeIntelNoticeError(kind CodeIntelNoticeKind, message string) error

func NormalizeArgumentError

func NormalizeArgumentError(toolName string, err error) error

func NormalizeSearchArguments

func NormalizeSearchArguments(args json.RawMessage, service *searchsvc.Service) (json.RawMessage, error)

func NormalizeWebSearchArguments

func NormalizeWebSearchArguments(args json.RawMessage, service *websearchsvc.Service) (json.RawMessage, error)

func ParseMCPToolName

func ParseMCPToolName(name string) (string, string, bool)

func PolicyListContainsTool

func PolicyListContainsTool(list []string, name string) bool

func ReadObservedVersion

func ReadObservedVersion(path string) (string, error)

ReadObservedVersion returns the same full-file content token that the read tool records in Result.ObservedResources for successful text-file reads.

func ToolPatternMatches

func ToolPatternMatches(pattern, name string) bool

func WithFileMutationLock

func WithFileMutationLock(path string, fn func() error) error

func WorkspaceEditHasChanges

func WorkspaceEditHasChanges(edit *lsp.WorkspaceEdit) bool

func WriteFileAtomically

func WriteFileAtomically(path string, content []byte, mode os.FileMode) error

Types

type ApplyPatch

type ApplyPatch struct {
	Operations []ApplyPatchOperation
}

func ParseApplyPatch

func ParseApplyPatch(patch string) (ApplyPatch, error)

type ApplyPatchChangedFile

type ApplyPatchChangedFile struct {
	Path     string `json:"path"`
	MovePath string `json:"move_path,omitempty"`
	Kind     string `json:"kind"`
}

type ApplyPatchOperation

type ApplyPatchOperation struct {
	Kind     ApplyPatchOperationKind
	Path     string
	MovePath string
	Lines    []string
	Hunks    []ApplyPatchUpdateHunk
}

type ApplyPatchOperationKind

type ApplyPatchOperationKind string
const (
	ApplyPatchOperationAdd    ApplyPatchOperationKind = "add"
	ApplyPatchOperationDelete ApplyPatchOperationKind = "delete"
	ApplyPatchOperationUpdate ApplyPatchOperationKind = "update"
)

type ApplyPatchStructuredResult

type ApplyPatchStructuredResult struct {
	ChangedFiles []ApplyPatchChangedFile `json:"changed_files"`
}

type ApplyPatchTool

type ApplyPatchTool struct{}

func NewApplyPatchTool

func NewApplyPatchTool() ApplyPatchTool

func (ApplyPatchTool) Definition

func (ApplyPatchTool) Definition() Definition

func (ApplyPatchTool) Execute

func (ApplyPatchTool) PathRequests

func (ApplyPatchTool) PathRequests(args json.RawMessage) ([]PathRequest, error)

type ApplyPatchUpdateHunk

type ApplyPatchUpdateHunk struct {
	Context     string
	OldLines    []string
	NewLines    []string
	EndOfFile   bool
	StartLineNo int
}

type BashTool

type BashTool struct{}

func NewBashTool

func NewBashTool() BashTool

func (BashTool) Definition

func (BashTool) Definition() Definition

func (BashTool) Execute

func (BashTool) ExecutionRequest

func (BashTool) ExecutionRequest(workspaceRoot string, args json.RawMessage) (ExecutionRequest, bool, error)

type BeforeFileMutation

type BeforeFileMutation func(resolvedPath string) error

type CodeActionTool

type CodeActionTool struct{}

func NewCodeActionTool

func NewCodeActionTool() CodeActionTool

func (CodeActionTool) Definition

func (CodeActionTool) Definition() Definition

func (CodeActionTool) Execute

func (CodeActionTool) PathRequests

func (CodeActionTool) PathRequests(args json.RawMessage) ([]PathRequest, error)

type CodeIntel

type CodeIntel interface {
	Definition(ctx context.Context, filePath string, line, character int) ([]CodeIntelLocation, error)
	Diagnostics(ctx context.Context, filePaths []string) ([]CodeIntelFileDiagnostics, error)
	Symbols(ctx context.Context, query string) (CodeIntelSymbolsResult, error)
	Trace(ctx context.Context, request CodeIntelTraceRequest) (CodeIntelTraceResult, error)
	Refs(ctx context.Context, request CodeIntelRefsRequest) (CodeIntelRefsResult, error)
	RenameSymbol(ctx context.Context, request CodeIntelRenameRequest) (CodeIntelMutationSummary, error)
	ApplyCodeAction(ctx context.Context, request CodeIntelCodeActionRequest) (CodeIntelCodeActionResult, error)
}

type CodeIntelCodeActionRequest

type CodeIntelCodeActionRequest struct {
	Path           string
	StartLine      int
	StartCharacter int
	EndLine        int
	EndCharacter   int
	Title          string
	Kind           string
	OnlyPreferred  bool
}

type CodeIntelCodeActionResult

type CodeIntelCodeActionResult struct {
	Title   string                   `json:"title,omitempty"`
	Summary CodeIntelMutationSummary `json:"summary,omitempty"`
}

type CodeIntelDiagnostic

type CodeIntelDiagnostic struct {
	Line      int    `json:"line"`
	Character int    `json:"character"`
	Severity  string `json:"severity,omitempty"`
	Message   string `json:"message,omitempty"`
	Source    string `json:"source,omitempty"`
}

type CodeIntelFileDiagnostics

type CodeIntelFileDiagnostics struct {
	Path        string                `json:"path"`
	Error       string                `json:"error,omitempty"`
	Diagnostics []CodeIntelDiagnostic `json:"diagnostics,omitempty"`
}

type CodeIntelLocation

type CodeIntelLocation struct {
	Path      string `json:"path"`
	Line      int    `json:"line"`
	Character int    `json:"character"`
	EndLine   int    `json:"end_line,omitempty"`
	EndChar   int    `json:"end_char,omitempty"`
}

type CodeIntelMutationSummary

type CodeIntelMutationSummary struct {
	Paths     []string `json:"paths,omitempty"`
	TextEdits int      `json:"text_edits,omitempty"`
	Created   int      `json:"created,omitempty"`
	Renamed   int      `json:"renamed,omitempty"`
	Deleted   int      `json:"deleted,omitempty"`
}

type CodeIntelNotice

type CodeIntelNotice struct {
	Kind    CodeIntelNoticeKind `json:"kind,omitempty"`
	Message string              `json:"message,omitempty"`
}

func AsCodeIntelNotice

func AsCodeIntelNotice(err error) (*CodeIntelNotice, bool)

type CodeIntelNoticeError

type CodeIntelNoticeError struct {
	Notice CodeIntelNotice
}

func (*CodeIntelNoticeError) Error

func (e *CodeIntelNoticeError) Error() string

type CodeIntelNoticeKind

type CodeIntelNoticeKind string
const (
	CodeIntelNoticeKindUnavailable CodeIntelNoticeKind = "unavailable"
	CodeIntelNoticeKindUnsupported CodeIntelNoticeKind = "unsupported"
)

type CodeIntelReference

type CodeIntelReference struct {
	Kind      CodeIntelReferenceKind `json:"kind,omitempty"`
	Path      string                 `json:"path,omitempty"`
	Line      int                    `json:"line,omitempty"`
	Character int                    `json:"character,omitempty"`
	Snippet   string                 `json:"snippet,omitempty"`
}

type CodeIntelReferenceKind

type CodeIntelReferenceKind string
const (
	CodeIntelReferenceKindRead      CodeIntelReferenceKind = "read"
	CodeIntelReferenceKindWrite     CodeIntelReferenceKind = "write"
	CodeIntelReferenceKindReference CodeIntelReferenceKind = "reference"
)

type CodeIntelRefsMode

type CodeIntelRefsMode string
const (
	CodeIntelRefsModeAll     CodeIntelRefsMode = "all"
	CodeIntelRefsModeReaders CodeIntelRefsMode = "readers"
	CodeIntelRefsModeWriters CodeIntelRefsMode = "writers"
)

type CodeIntelRefsRequest

type CodeIntelRefsRequest struct {
	Path               string
	Line               int
	Character          int
	Mode               CodeIntelRefsMode
	MaxResults         int
	IncludeDeclaration bool
}

type CodeIntelRefsResult

type CodeIntelRefsResult struct {
	Supported                bool                 `json:"supported"`
	Found                    bool                 `json:"found"`
	Notice                   *CodeIntelNotice     `json:"notice,omitempty"`
	Target                   CodeIntelTraceNode   `json:"target,omitempty"`
	References               []CodeIntelReference `json:"references,omitempty"`
	Truncated                bool                 `json:"truncated,omitempty"`
	ClassificationSupported  bool                 `json:"classification_supported,omitempty"`
	ClassificationIncomplete bool                 `json:"classification_incomplete,omitempty"`
}

type CodeIntelRenameRequest

type CodeIntelRenameRequest struct {
	Path      string
	Line      int
	Character int
	NewName   string
}

type CodeIntelSymbol

type CodeIntelSymbol struct {
	Name string `json:"name"`
	Kind string `json:"kind,omitempty"`
	Path string `json:"path,omitempty"`
	Line int    `json:"line,omitempty"`
}

type CodeIntelSymbolsResult

type CodeIntelSymbolsResult struct {
	Symbols []CodeIntelSymbol `json:"symbols,omitempty"`
	Notice  *CodeIntelNotice  `json:"notice,omitempty"`
}

type CodeIntelTraceEdge

type CodeIntelTraceEdge struct {
	FromID string `json:"from_id,omitempty"`
	ToID   string `json:"to_id,omitempty"`
}

type CodeIntelTraceMode

type CodeIntelTraceMode string
const (
	CodeIntelTraceModeCallers CodeIntelTraceMode = "callers"
	CodeIntelTraceModeCallees CodeIntelTraceMode = "callees"
	CodeIntelTraceModeGraph   CodeIntelTraceMode = "graph"
)

type CodeIntelTraceNode

type CodeIntelTraceNode struct {
	ID        string `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
	Kind      string `json:"kind,omitempty"`
	Path      string `json:"path,omitempty"`
	Line      int    `json:"line,omitempty"`
	Character int    `json:"character,omitempty"`
}

type CodeIntelTraceRequest

type CodeIntelTraceRequest struct {
	Path      string
	Line      int
	Character int
	Mode      CodeIntelTraceMode
	Depth     int
	MaxNodes  int
}

type CodeIntelTraceResult

type CodeIntelTraceResult struct {
	Supported bool                 `json:"supported"`
	Found     bool                 `json:"found"`
	Notice    *CodeIntelNotice     `json:"notice,omitempty"`
	RootID    string               `json:"root_id,omitempty"`
	Nodes     []CodeIntelTraceNode `json:"nodes,omitempty"`
	Edges     []CodeIntelTraceEdge `json:"edges,omitempty"`
	Truncated bool                 `json:"truncated,omitempty"`
}

type Definition

type Definition struct {
	Name                string
	Description         string
	ProviderDescription string
	InputKind           InputKind
	InputSchema         json.RawMessage
	InputFormat         *InputFormat
	ProviderInputSchema json.RawMessage
	ArgumentExamples    []string
	RequiresWorkspace   bool
	// ProviderRichGuidance keeps schema descriptions and a compact example in the
	// provider-facing tool surface for tools where precise usage materially
	// reduces bad calls.
	ProviderRichGuidance bool
	// ParallelSafe means Execute is read-only, does not use direct permission,
	// network, or execution append paths, and may run concurrently while the
	// runtime commits durable tool events later in provider order.
	ParallelSafe bool
}

func (Definition) InputKindOrDefault

func (d Definition) InputKindOrDefault() InputKind

func (Definition) ProviderDescriptionText

func (d Definition) ProviderDescriptionText() string

type DefinitionTool

type DefinitionTool struct{}

func NewDefinitionTool

func NewDefinitionTool() DefinitionTool

func (DefinitionTool) Definition

func (DefinitionTool) Definition() Definition

func (DefinitionTool) Execute

func (DefinitionTool) PathRequests

func (DefinitionTool) PathRequests(args json.RawMessage) ([]PathRequest, error)

type DiagnosticsTool

type DiagnosticsTool struct{}

func NewDiagnosticsTool

func NewDiagnosticsTool() DiagnosticsTool

func (DiagnosticsTool) Definition

func (DiagnosticsTool) Definition() Definition

func (DiagnosticsTool) Execute

func (DiagnosticsTool) PathRequests

func (DiagnosticsTool) PathRequests(args json.RawMessage) ([]PathRequest, error)

type ExecutionContext

type ExecutionContext struct {
	SessionID      string
	Workspace      *workspace.Scope
	Search         *searchsvc.Service
	WebSearch      *websearchsvc.Service
	OutputEmitter  OutputEmitter
	BeforeMutation BeforeFileMutation
	QuestionAsker  QuestionAsker
	TaskManager    TaskManager
	CodeIntelAPI   CodeIntel
	MemoryManager  MemoryManager
	SkillCatalog   SkillCatalog
	WorkflowOutput WorkflowPhaseOutputManager
	WorkflowReview WorkflowReviewResultManager
}

func (ExecutionContext) AskQuestion

func (e ExecutionContext) AskQuestion(request QuestionRequest) (QuestionResponse, error)

func (ExecutionContext) CodeIntel

func (e ExecutionContext) CodeIntel() (CodeIntel, error)

func (ExecutionContext) EmitToolOutput

func (e ExecutionContext) EmitToolOutput(stream, chunk string) error

func (ExecutionContext) Memories

func (e ExecutionContext) Memories() (MemoryManager, error)

func (ExecutionContext) ResolvePath

func (e ExecutionContext) ResolvePath(access workspace.Access, path string) (workspace.Decision, error)

func (ExecutionContext) Skills

func (e ExecutionContext) Skills() (SkillCatalog, error)

func (ExecutionContext) Tasks

func (e ExecutionContext) Tasks() (TaskManager, error)

func (ExecutionContext) WorkflowPhaseOutput added in v0.5.0

func (e ExecutionContext) WorkflowPhaseOutput() (WorkflowPhaseOutputManager, error)

func (ExecutionContext) WorkflowReviewResult added in v0.5.0

func (e ExecutionContext) WorkflowReviewResult() (WorkflowReviewResultManager, error)

type ExecutionEffect

type ExecutionEffect string
const (
	ExecutionEffectUnknown ExecutionEffect = "unknown"
	ExecutionEffectRead    ExecutionEffect = "read"
	ExecutionEffectWrite   ExecutionEffect = "write"
	ExecutionEffectNetwork ExecutionEffect = "network"
	ExecutionEffectProcess ExecutionEffect = "process"
)

func BashArgumentsExecutionEffect

func BashArgumentsExecutionEffect(args json.RawMessage) (ExecutionEffect, error)

type ExecutionIntent

type ExecutionIntent string
const (
	ExecutionIntentUnknown ExecutionIntent = "unknown"
	ExecutionIntentOneShot ExecutionIntent = "one_shot"
	ExecutionIntentWatcher ExecutionIntent = "watcher"
	ExecutionIntentServer  ExecutionIntent = "server"
)

type ExecutionRequest

type ExecutionRequest struct {
	Kind             string
	Preview          string
	WorkingDirectory string
	Command          []string
	ShellCommand     string
	PathRequests     []PathRequest
	OpaquePathReason string
	NetworkTargets   []string
	Intent           ExecutionIntent
	IntentCommand    string
	Effect           ExecutionEffect
	ReadyPatterns    []string
	TimeoutMS        int
	LoginShell       bool
	ShellProgram     string
	TTY              bool
	YieldTimeMS      int
	MaxOutputTokens  int
	PrefixRule       []string
}

type ExecutionRequestIntrospector

type ExecutionRequestIntrospector interface {
	ExecutionRequest(workspaceRoot string, args json.RawMessage) (ExecutionRequest, bool, error)
}

type ExecutionRuntime

type ExecutionRuntime struct {
	Backend    string
	ExitCode   *int
	DurationMS int64
}

type GitDiffTool

type GitDiffTool struct{}

func NewGitDiffTool

func NewGitDiffTool() GitDiffTool

func (GitDiffTool) Definition

func (GitDiffTool) Definition() Definition

func (GitDiffTool) Execute

func (GitDiffTool) Execute(ctx context.Context, ectx ExecutionContext, args json.RawMessage) (Result, error)

type GitShowTool

type GitShowTool struct{}

func NewGitShowTool

func NewGitShowTool() GitShowTool

func (GitShowTool) Definition

func (GitShowTool) Definition() Definition

func (GitShowTool) Execute

func (GitShowTool) Execute(ctx context.Context, ectx ExecutionContext, args json.RawMessage) (Result, error)

type GitStatusTool

type GitStatusTool struct{}

func NewGitStatusTool

func NewGitStatusTool() GitStatusTool

func (GitStatusTool) Definition

func (GitStatusTool) Definition() Definition

func (GitStatusTool) Execute

type InputFormat

type InputFormat struct {
	Type       string
	Syntax     string
	Definition string
}

type InputKind

type InputKind string
const (
	InputKindFunction InputKind = "function"
	InputKindCustom   InputKind = "custom"
)

type InvalidArgumentsError

type InvalidArgumentsError struct {
	ToolName string
	Message  string
	Cause    error
}

func (*InvalidArgumentsError) Error

func (e *InvalidArgumentsError) Error() string

func (*InvalidArgumentsError) Is

func (e *InvalidArgumentsError) Is(target error) bool

func (*InvalidArgumentsError) Unwrap

func (e *InvalidArgumentsError) Unwrap() error

type LocateTool

type LocateTool struct{}

func NewLocateTool

func NewLocateTool() LocateTool

func (LocateTool) Definition

func (LocateTool) Definition() Definition

func (LocateTool) Execute

func (LocateTool) NormalizedInputKey

func (LocateTool) NormalizedInputKey(args json.RawMessage) (string, error)

func (LocateTool) PathRequests

func (LocateTool) PathRequests(args json.RawMessage) ([]PathRequest, error)

type MemoryDeleteRequest

type MemoryDeleteRequest struct {
	ID string
}

type MemoryManager

type MemoryManager interface {
	SaveMemory(MemorySaveRequest) (MemoryRecord, error)
	ListMemories() ([]MemoryRecord, error)
	DeleteMemory(MemoryDeleteRequest) error
}

type MemoryRecord

type MemoryRecord struct {
	ID        string `json:"id,omitempty"`
	Path      string `json:"path,omitempty"`
	Content   string `json:"content,omitempty"`
	UpdatedAt string `json:"updated_at,omitempty"`
}

type MemorySaveRequest

type MemorySaveRequest struct {
	Content string
}

type MemoryTool

type MemoryTool struct{}

func NewMemoryTool

func NewMemoryTool() MemoryTool

func (MemoryTool) Definition

func (MemoryTool) Definition() Definition

func (MemoryTool) Execute

type MkdirTool

type MkdirTool struct{}

func NewMkdirTool

func NewMkdirTool() MkdirTool

func (MkdirTool) Definition

func (MkdirTool) Definition() Definition

func (MkdirTool) Execute

func (MkdirTool) PathRequests

func (MkdirTool) PathRequests(args json.RawMessage) ([]PathRequest, error)

type MutationRange

type MutationRange struct {
	OldStartLine int
	NewStartLine int
}

type NetworkIntrospector

type NetworkIntrospector interface {
	NetworkRequests(json.RawMessage) ([]NetworkRequest, error)
}

type NetworkRequest

type NetworkRequest struct {
	Target  string
	URL     string
	Command string
	Reason  string
}

type NormalizedInputKeyProvider

type NormalizedInputKeyProvider interface {
	NormalizedInputKey(json.RawMessage) (string, error)
}

type ObservedResource

type ObservedResource struct {
	Kind       ObservedResourceKind
	Path       string
	Version    string
	State      string
	Complete   bool
	StartLine  int
	EndLine    int
	TotalLines int
}

func ObserveDirEntriesResource

func ObserveDirEntriesResource(path string) (ObservedResource, bool)

func ReadDirWithObservedResource

func ReadDirWithObservedResource(path string) ([]os.DirEntry, *ObservedResource, error)

type ObservedResourceKind

type ObservedResourceKind string
const (
	ObservedResourceFileContent ObservedResourceKind = "file_content"
	ObservedResourceDirEntries  ObservedResourceKind = "dir_entries"
)

type OutputChunk

type OutputChunk struct {
	Stream string
	Chunk  string
}

type OutputEmitter

type OutputEmitter func(OutputChunk) error

type PathIntrospector

type PathIntrospector interface {
	PathRequests(json.RawMessage) ([]PathRequest, error)
}

type PathRequest

type PathRequest struct {
	Access workspace.Access
	Path   string
	Reason string
}

type QuestionAsker

type QuestionAsker func(QuestionRequest) (QuestionResponse, error)

type QuestionRequest

type QuestionRequest struct {
	Question string
	Options  []string
	Multiple bool
	Purpose  string
}

type QuestionResponse

type QuestionResponse struct {
	RequestID string
	Answer    string
	Answered  bool
}

type QuestionTool

type QuestionTool struct{}

func NewQuestionTool

func NewQuestionTool() QuestionTool

func (QuestionTool) Definition

func (QuestionTool) Definition() Definition

func (QuestionTool) Execute

func (QuestionTool) NormalizedInputKey

func (QuestionTool) NormalizedInputKey(args json.RawMessage) (string, error)

type ReadTool

type ReadTool struct{}

func NewReadTool

func NewReadTool() ReadTool

func (ReadTool) Definition

func (ReadTool) Definition() Definition

func (ReadTool) Execute

func (ReadTool) Execute(_ context.Context, ectx ExecutionContext, args json.RawMessage) (Result, error)

func (ReadTool) NormalizedInputKey

func (ReadTool) NormalizedInputKey(args json.RawMessage) (string, error)

func (ReadTool) PathRequests

func (ReadTool) PathRequests(args json.RawMessage) ([]PathRequest, error)

type RefsTool

type RefsTool struct{}

func NewRefsTool

func NewRefsTool() RefsTool

func (RefsTool) Definition

func (RefsTool) Definition() Definition

func (RefsTool) Execute

func (RefsTool) Execute(ctx context.Context, ectx ExecutionContext, args json.RawMessage) (Result, error)

func (RefsTool) PathRequests

func (RefsTool) PathRequests(args json.RawMessage) ([]PathRequest, error)

type RenameSymbolTool

type RenameSymbolTool struct{}

func NewRenameSymbolTool

func NewRenameSymbolTool() RenameSymbolTool

func (RenameSymbolTool) Definition

func (RenameSymbolTool) Definition() Definition

func (RenameSymbolTool) Execute

func (RenameSymbolTool) PathRequests

func (RenameSymbolTool) PathRequests(args json.RawMessage) ([]PathRequest, error)

type Result

type Result struct {
	Output            string
	Error             string
	StructuredResult  json.RawMessage
	Execution         *ExecutionRuntime
	PendingQuestionID string
	MutationRanges    []MutationRange
	TextMutations     []TextMutation
	ObservedResources []ObservedResource
}

type SearchSkillsTool

type SearchSkillsTool struct{}

func NewSearchSkillsTool

func NewSearchSkillsTool() SearchSkillsTool

func (SearchSkillsTool) Definition

func (SearchSkillsTool) Definition() Definition

func (SearchSkillsTool) Execute

type SearchTool

type SearchTool struct{}

func NewSearchTool

func NewSearchTool() SearchTool

func (SearchTool) Definition

func (SearchTool) Definition() Definition

func (SearchTool) Execute

func (SearchTool) Execute(ctx context.Context, ectx ExecutionContext, args json.RawMessage) (Result, error)

func (SearchTool) NormalizedInputKey

func (SearchTool) NormalizedInputKey(args json.RawMessage) (string, error)

func (SearchTool) PathRequests

func (SearchTool) PathRequests(args json.RawMessage) ([]PathRequest, error)

type SkillCatalog

type SkillCatalog interface {
	SearchSkills(query string, limit int) ([]SkillMatch, error)
	LoadSkill(id string) (SkillDocument, error)
}

type SkillDocument

type SkillDocument struct {
	ID          string         `json:"id"`
	Description string         `json:"description,omitempty"`
	WhenToUse   string         `json:"when_to_use,omitempty"`
	Arguments   []string       `json:"arguments,omitempty"`
	Source      string         `json:"source,omitempty"`
	Path        string         `json:"path,omitempty"`
	Content     string         `json:"content,omitempty"`
	Sections    []SkillSection `json:"sections,omitempty"`
}

type SkillMatch

type SkillMatch struct {
	ID          string   `json:"id"`
	Description string   `json:"description,omitempty"`
	WhenToUse   string   `json:"when_to_use,omitempty"`
	Arguments   []string `json:"arguments,omitempty"`
	Source      string   `json:"source,omitempty"`
	Path        string   `json:"path,omitempty"`
	Reasons     []string `json:"reasons,omitempty"`
}

type SkillSection

type SkillSection struct {
	ID    string `json:"id"`
	Title string `json:"title"`
}

type SkillTool

type SkillTool struct{}

func NewSkillTool

func NewSkillTool() SkillTool

func (SkillTool) Definition

func (SkillTool) Definition() Definition

func (SkillTool) Execute

type SymbolsTool

type SymbolsTool struct{}

func NewSymbolsTool

func NewSymbolsTool() SymbolsTool

func (SymbolsTool) Definition

func (SymbolsTool) Definition() Definition

func (SymbolsTool) Execute

func (SymbolsTool) Execute(ctx context.Context, ectx ExecutionContext, args json.RawMessage) (Result, error)

type TaskBlockRequest

type TaskBlockRequest struct {
	TaskID      string
	BlockReason string
	Notes       string
}

type TaskCompleteRequest

type TaskCompleteRequest struct {
	TaskID  string
	Summary string
}

type TaskCreateRequest

type TaskCreateRequest struct {
	TaskID       string
	ParentTaskID string
	Title        string
	Kind         string
	Status       string
	Notes        string
}

type TaskCreateResult

type TaskCreateResult struct {
	Task       TaskRecord  `json:"task"`
	ParentTask *TaskRecord `json:"parent_task,omitempty"`
	Message    string      `json:"message,omitempty"`
}

type TaskManager

type TaskManager interface {
	ListTasks() ([]TaskRecord, error)
	CreateTask(TaskCreateRequest) (TaskCreateResult, error)
	UpdateTaskProgress(TaskProgressUpdateRequest) (TaskRecord, error)
	BlockTask(TaskBlockRequest) (TaskRecord, error)
	CompleteTask(TaskCompleteRequest) (TaskRecord, error)
	ReviewTask(TaskReviewRequest) (TaskRecord, error)
}

type TaskProgressUpdateRequest

type TaskProgressUpdateRequest struct {
	TaskID   string
	Status   string
	Progress string
	Notes    string
}

type TaskRecord

type TaskRecord struct {
	TaskID          string `json:"task_id"`
	ParentTaskID    string `json:"parent_task_id,omitempty"`
	WorkflowID      string `json:"workflow_id,omitempty"`
	WorkflowPhaseID string `json:"workflow_phase_id,omitempty"`
	Title           string `json:"title"`
	Kind            string `json:"kind,omitempty"`
	Status          string `json:"status"`
	Notes           string `json:"notes,omitempty"`
	Progress        string `json:"progress,omitempty"`
	BlockReason     string `json:"block_reason,omitempty"`
	ReviewStatus    string `json:"review_status,omitempty"`
	ReviewSummary   string `json:"review_summary,omitempty"`
}

type TaskReviewRequest

type TaskReviewRequest struct {
	TaskID        string
	ReviewStatus  string
	ReviewSummary string
}

type TaskReviewTool

type TaskReviewTool struct{}

func NewTaskReviewTool

func NewTaskReviewTool() TaskReviewTool

func (TaskReviewTool) Definition

func (TaskReviewTool) Definition() Definition

func (TaskReviewTool) Execute

func (TaskReviewTool) NormalizedInputKey

func (TaskReviewTool) NormalizedInputKey(args json.RawMessage) (string, error)

type TaskWorkflowTool

type TaskWorkflowTool struct{}

func NewTaskWorkflowTool

func NewTaskWorkflowTool() TaskWorkflowTool

func (TaskWorkflowTool) Definition

func (TaskWorkflowTool) Definition() Definition

func (TaskWorkflowTool) Execute

func (TaskWorkflowTool) NormalizedInputKey

func (TaskWorkflowTool) NormalizedInputKey(args json.RawMessage) (string, error)

type TestTool

type TestTool struct{}

func NewTestTool

func NewTestTool() TestTool

func (TestTool) Definition

func (TestTool) Definition() Definition

func (TestTool) Execute

func (TestTool) ExecutionRequest

func (TestTool) ExecutionRequest(workspaceRoot string, args json.RawMessage) (ExecutionRequest, bool, error)

type TextMutation

type TextMutation struct {
	Path    string
	Before  string
	After   string
	Existed bool
	Mode    uint32
}

type Tool

type Tool interface {
	Definition() Definition
	Execute(context.Context, ExecutionContext, json.RawMessage) (Result, error)
}

func AllBuiltInTools

func AllBuiltInTools() []Tool

AllBuiltInTools returns the full built-in tool catalog, including config-gated tools that are not always registered in the runtime surface. Use this for schema and argument-metadata lookups, not runtime registration.

func DefaultRuntimeTools

func DefaultRuntimeTools() []Tool

DefaultRuntimeTools is the baseline production tool surface exposed by kodacode before any config-gated runtime tools are appended.

type TraceTool

type TraceTool struct{}

func NewTraceTool

func NewTraceTool() TraceTool

func (TraceTool) Definition

func (TraceTool) Definition() Definition

func (TraceTool) Execute

func (TraceTool) Execute(ctx context.Context, ectx ExecutionContext, args json.RawMessage) (Result, error)

func (TraceTool) PathRequests

func (TraceTool) PathRequests(args json.RawMessage) ([]PathRequest, error)

type WebFetchTool

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

func NewWebFetchTool

func NewWebFetchTool() WebFetchTool

func (WebFetchTool) Definition

func (WebFetchTool) Definition() Definition

func (WebFetchTool) Execute

func (WebFetchTool) NetworkRequests

func (WebFetchTool) NetworkRequests(args json.RawMessage) ([]NetworkRequest, error)

func (WebFetchTool) NormalizedInputKey

func (WebFetchTool) NormalizedInputKey(args json.RawMessage) (string, error)

type WebSearchTool

type WebSearchTool struct{}

func NewWebSearchTool

func NewWebSearchTool() WebSearchTool

func (WebSearchTool) Definition

func (WebSearchTool) Definition() Definition

func (WebSearchTool) Execute

func (WebSearchTool) NormalizedInputKey

func (WebSearchTool) NormalizedInputKey(args json.RawMessage) (string, error)

type WorkflowPhaseOutputManager added in v0.5.0

type WorkflowPhaseOutputManager interface {
	RecordWorkflowPhaseOutput(WorkflowPhaseOutputRequest) (WorkflowPhaseOutputRecord, error)
}

type WorkflowPhaseOutputRecord added in v0.5.0

type WorkflowPhaseOutputRecord struct {
	RecordedKeys []string `json:"recorded_keys"`
	Message      string   `json:"message"`
}

type WorkflowPhaseOutputRequest added in v0.5.0

type WorkflowPhaseOutputRequest struct {
	Fields map[string]string
}

type WorkflowPhaseOutputTool added in v0.5.0

type WorkflowPhaseOutputTool struct{}

func NewWorkflowPhaseOutputTool added in v0.5.0

func NewWorkflowPhaseOutputTool() WorkflowPhaseOutputTool

func (WorkflowPhaseOutputTool) Definition added in v0.5.0

func (WorkflowPhaseOutputTool) Definition() Definition

func (WorkflowPhaseOutputTool) Execute added in v0.5.0

type WorkflowReviewFinding added in v0.5.0

type WorkflowReviewFinding struct {
	Severity    string `json:"severity"`
	Path        string `json:"path"`
	Line        int    `json:"line"`
	Title       string `json:"title"`
	Explanation string `json:"explanation"`
}

type WorkflowReviewResultManager added in v0.5.0

type WorkflowReviewResultManager interface {
	RecordWorkflowReviewResult(WorkflowReviewResultRequest) (WorkflowReviewResultRecord, error)
}

type WorkflowReviewResultRecord added in v0.5.0

type WorkflowReviewResultRecord struct {
	ReviewID   string `json:"review_id"`
	ReviewPass string `json:"review_pass"`
	Status     string `json:"status"`
	Message    string `json:"message"`
}

type WorkflowReviewResultRequest added in v0.5.0

type WorkflowReviewResultRequest struct {
	ReviewPass         string
	Findings           []WorkflowReviewFinding
	OverallCorrectness string
	OverallSummary     string
}

type WorkflowReviewResultTool added in v0.5.0

type WorkflowReviewResultTool struct{}

func NewWorkflowReviewResultTool added in v0.5.0

func NewWorkflowReviewResultTool() WorkflowReviewResultTool

func (WorkflowReviewResultTool) Definition added in v0.5.0

func (WorkflowReviewResultTool) Definition() Definition

func (WorkflowReviewResultTool) Execute added in v0.5.0

type WriteTool

type WriteTool struct{}

func NewWriteTool

func NewWriteTool() WriteTool

func (WriteTool) Definition

func (WriteTool) Definition() Definition

func (WriteTool) Execute

func (WriteTool) PathRequests

func (WriteTool) PathRequests(args json.RawMessage) ([]PathRequest, error)

Jump to

Keyboard shortcuts

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