Documentation
¶
Index ¶
- func FormatFileContent(content string, offset, limit int) string
- func FormatFileResults(results []index.FileSearchResult, nameOnly bool) string
- func FormatSearchResults(results []index.ContentSearchResult, totalMatches int, truncated bool, ...) string
- type DiskFallbackFunc
- type DiskFallbackStatus
- type FilesArgs
- type FilesHandler
- type ReadArgs
- type ReadHandler
- type ReindexArgs
- type ReindexFunc
- type ReindexHandler
- type SearchArgs
- type SearchHandler
- type StatusArgs
- type StatusHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatFileContent ¶
FormatFileContent formats a file's content with line numbers for AI consumption. offset: 1-based starting line (0 = from beginning). limit: max lines (0 = all). Line numbers in the output reflect actual file positions, not local indices.
func FormatFileResults ¶
func FormatFileResults(results []index.FileSearchResult, nameOnly bool) string
FormatFileResults formats file search results for AI consumption.
func FormatSearchResults ¶
func FormatSearchResults(results []index.ContentSearchResult, totalMatches int, truncated bool, outputMode string) string
FormatSearchResults formats content search results for AI consumption. outputMode: "content" renders hunks with line numbers ("N:" = match, "N-" = context), "files" renders file paths only, "count" renders "path: matchCount" lines.
Types ¶
type DiskFallbackFunc ¶ added in v0.7.0
type DiskFallbackFunc func(relativePath string) (content string, status DiskFallbackStatus)
DiskFallbackFunc reads a file that is missing from the index directly from disk and, when the file is eligible, adds it to the index. It is provided by main.go so this package stays free of filesystem and ignore-rule logic.
type DiskFallbackStatus ¶ added in v0.7.0
type DiskFallbackStatus int
DiskFallbackStatus is the outcome of a last-resort filesystem read for a file that is missing from the in-memory index.
const ( // DiskFallbackMissing: the file is not on disk either (likely a hallucinated path). DiskFallbackMissing DiskFallbackStatus = iota // DiskFallbackIndexed: the file was read from disk and added to the index (a genuine index gap). DiskFallbackIndexed // DiskFallbackServedRaw: the file was read from disk but deliberately not indexed (ignored or too large). DiskFallbackServedRaw // DiskFallbackBinary: the file exists on disk but is binary and was not served. DiskFallbackBinary )
type FilesArgs ¶
type FilesArgs struct {
Pattern string `json:"pattern" jsonschema:"Glob pattern to match files (e.g. **/*.ts or src/**/*.go)"`
NameOnly bool `json:"nameOnly,omitempty" jsonschema:"If true return only file paths without metadata"`
MaxResults int `json:"maxResults,omitempty" jsonschema:"Maximum number of results to return (default 50)"`
}
FilesArgs defines the input parameters for the codeindex_files tool.
type FilesHandler ¶
FilesHandler holds the dependencies for the files tool.
func (*FilesHandler) Handle ¶
func (h *FilesHandler) Handle(ctx context.Context, req *mcp.CallToolRequest, args FilesArgs) (*mcp.CallToolResult, any, error)
Handle processes a codeindex_files request.
type ReadArgs ¶
type ReadArgs struct {
FilePath string `json:"filePath" jsonschema:"Relative file path to read from the index (e.g. src/main.go)"`
Offset int `` /* 135-byte string literal not displayed */
Limit int `json:"limit,omitempty" jsonschema:"Number of lines to read. Only provide if the file is too large to read at once"`
}
ReadArgs defines the input parameters for the codeindex_read tool.
type ReadHandler ¶
type ReadHandler struct {
ContentIndex *index.ContentIndex
Logger *slog.Logger
// DiskFallback is the last-resort filesystem read used when a file is not in
// the index. Optional; if nil the handler returns a plain "not found" error.
DiskFallback DiskFallbackFunc
// TriggerSync kicks off a non-blocking background index reconciliation. It is
// called after a genuine index gap is recovered, since sibling files may also
// be missing. Optional.
TriggerSync func()
}
ReadHandler holds the dependencies for the read tool.
func (*ReadHandler) Handle ¶
func (h *ReadHandler) Handle(ctx context.Context, req *mcp.CallToolRequest, args ReadArgs) (*mcp.CallToolResult, any, error)
Handle processes a codeindex_read request.
type ReindexArgs ¶
type ReindexArgs struct{}
ReindexArgs defines the input parameters for the codeindex_reindex tool.
type ReindexFunc ¶
ReindexFunc is the function signature for the reindex operation. It is provided by main.go to avoid circular dependencies.
type ReindexHandler ¶
type ReindexHandler struct {
DoReindex ReindexFunc
Logger *slog.Logger
}
ReindexHandler holds the dependencies for the reindex tool.
func (*ReindexHandler) Handle ¶
func (h *ReindexHandler) Handle(ctx context.Context, req *mcp.CallToolRequest, args ReindexArgs) (*mcp.CallToolResult, any, error)
Handle processes a codeindex_reindex request.
type SearchArgs ¶
type SearchArgs struct {
Query string `` /* 164-byte string literal not displayed */
FilePath string `` /* 147-byte string literal not displayed */
FileGlob string `json:"fileGlob,omitempty" jsonschema:"Optional glob pattern to filter files (e.g. **/*.go)"`
MaxResults int `json:"maxResults,omitempty" jsonschema:"Maximum number of file results to return (default 50)"`
ContextLines *int `json:"contextLines,omitempty" jsonschema:"Context lines before and after each match (default 2, 0 = matching lines only)"`
MaxMatchesPerFile int `json:"maxMatchesPerFile,omitempty" jsonschema:"Maximum matches shown per file (default 10)"`
OutputMode string `` /* 151-byte string literal not displayed */
CaseSensitive bool `json:"caseSensitive,omitempty" jsonschema:"Case-sensitive matching for plain text and regex queries (default false)"`
}
SearchArgs defines the input parameters for the codeindex_search tool.
type SearchHandler ¶
type SearchHandler struct {
ContentIndex *index.ContentIndex
Logger *slog.Logger
}
SearchHandler holds the dependencies for the search tool.
func (*SearchHandler) Handle ¶
func (h *SearchHandler) Handle(ctx context.Context, req *mcp.CallToolRequest, args SearchArgs) (*mcp.CallToolResult, any, error)
Handle processes a codeindex_search request.
type StatusArgs ¶
type StatusArgs struct{}
StatusArgs defines the input parameters for the codeindex_status tool (none required).
type StatusHandler ¶
type StatusHandler struct {
FileIndex *index.FileIndex
ContentIndex *index.ContentIndex
StartTime time.Time
RootDir string
Version string
// WatchedDirs reports how many directories the file watcher covers; nil when the watcher failed to start.
WatchedDirs func() int
SyncIntervalSeconds int
Logger *slog.Logger
}
StatusHandler holds the dependencies for the status tool.
func (*StatusHandler) Handle ¶
func (h *StatusHandler) Handle(ctx context.Context, req *mcp.CallToolRequest, args StatusArgs) (*mcp.CallToolResult, any, error)
Handle processes a codeindex_status request.