Documentation
¶
Index ¶
- Constants
- func FormatSigil(result *FileResult) string
- func FormatSigilResponse(response *SkimResponse) string
- func GetBodyNodeTypes(lang Language) []string
- func GetTreeSitterLanguage(lang Language) *sitter.Language
- func GetTreeSitterLanguageForTSX() *sitter.Language
- func ResolveFiles(source any) ([]string, error)
- type ClassInfo
- type CodeSkimTool
- type FileGraph
- type FileResult
- type FunctionInfo
- type GraphNodeTypes
- type Language
- type NodeTypes
- type SkimRequest
- type SkimResponse
- type TransformResult
- func Transform(ctx context.Context, source string, lang Language, isTSX bool) (*TransformResult, error)
- func TransformWithFilter(ctx context.Context, source string, lang Language, isTSX bool, ...) (*TransformResult, error)
- func TransformWithGraph(ctx context.Context, source string, lang Language, isTSX bool, ...) (*TransformResult, error)
- func TransformWithOptions(ctx context.Context, source string, lang Language, isTSX bool, ...) (*TransformResult, error)
Constants ¶
const ( // MaxASTDepth prevents stack overflow from deeply nested code MaxASTDepth = 500 // MaxASTNodes prevents memory exhaustion from large ASTs MaxASTNodes = 100000 )
Variables ¶
This section is empty.
Functions ¶
func FormatSigil ¶ added in v0.57.0
func FormatSigil(result *FileResult) string
FormatSigil converts a FileResult to compressed sigil notation optimised for LLMs Sigil meanings:
- ! import/module
- $ class/type
- # function/method
- < extends
- & implements
- -> calls (outgoing)
- ★n connectivity rating
func FormatSigilResponse ¶ added in v0.57.0
func FormatSigilResponse(response *SkimResponse) string
FormatSigilResponse formats an entire SkimResponse in sigil notation
func GetBodyNodeTypes ¶
GetBodyNodeTypes returns the node types that represent function/method bodies
func GetTreeSitterLanguage ¶
GetTreeSitterLanguage returns the tree-sitter language for a given language
func GetTreeSitterLanguageForTSX ¶
GetTreeSitterLanguageForTSX returns the TSX-specific tree-sitter language
func ResolveFiles ¶
ResolveFiles resolves the source parameter to a list of files to process Handles: - Single file path - Directory path (recursively finds all supported files) - Glob pattern - Array of any combination of the above
Types ¶
type ClassInfo ¶ added in v0.57.0
type ClassInfo struct {
Name string `json:"name"`
Extends string `json:"extends,omitempty"`
Implements []string `json:"implements,omitempty"`
Methods []string `json:"methods,omitempty"`
}
ClassInfo contains class details with inheritance relationships
type CodeSkimTool ¶
type CodeSkimTool struct{}
CodeSkimTool implements the tools.Tool interface for code transformation
func (*CodeSkimTool) Definition ¶
func (t *CodeSkimTool) Definition() mcp.Tool
Definition returns the tool's definition for MCP registration
func (*CodeSkimTool) Execute ¶
func (t *CodeSkimTool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]any) (*mcp.CallToolResult, error)
Execute executes the code skim tool
func (*CodeSkimTool) ProvideExtendedInfo ¶
func (t *CodeSkimTool) ProvideExtendedInfo() *tools.ExtendedHelp
ProvideExtendedInfo implements the ExtendedHelpProvider interface
type FileGraph ¶ added in v0.57.0
type FileGraph struct {
Imports []string `json:"imports,omitempty"`
Functions []FunctionInfo `json:"functions,omitempty"`
Classes []ClassInfo `json:"classes,omitempty"`
}
FileGraph contains extracted relationships for a file
type FileResult ¶
type FileResult struct {
Path string `json:"path"`
Transformed string `json:"transformed"`
Language Language `json:"language"`
FromCache bool `json:"from_cache"`
Truncated bool `json:"truncated,omitempty"`
TotalLines *int `json:"total_lines,omitempty"`
ReturnedLines *int `json:"returned_lines,omitempty"`
NextStartingLine *int `json:"next_starting_line,omitempty"`
ReductionPercentage *int `json:"reduction_percentage,omitempty"`
MatchedItems *int `json:"matched_items,omitempty"`
TotalItems *int `json:"total_items,omitempty"`
FilteredItems *int `json:"filtered_items,omitempty"`
Graph *FileGraph `json:"graph,omitempty"`
Error string `json:"error,omitempty"`
}
FileResult represents the result for a single file
type FunctionInfo ¶ added in v0.57.0
type FunctionInfo struct {
Name string `json:"name"`
Signature string `json:"signature,omitempty"` // Full signature for semantic search
Line int `json:"line,omitempty"` // Line number (1-based)
Calls []string `json:"calls,omitempty"`
Connectivity int `json:"connectivity,omitempty"` // Total relationships (★ rating)
}
FunctionInfo contains function details with call relationships
type GraphNodeTypes ¶ added in v0.57.0
type GraphNodeTypes struct {
ImportTypes []string // Node types for import statements
CallTypes []string // Node types for function calls
InheritanceTypes []string // Node types for inheritance (extends/implements)
}
GraphNodeTypes contains language-specific node types for graph extraction
type Language ¶
type Language string
Language represents supported programming languages
const ( LanguagePython Language = "python" LanguageGo Language = "go" LanguageJavaScript Language = "javascript" LanguageTypeScript Language = "typescript" LanguageRust Language = "rust" LanguageC Language = "c" LanguageCPP Language = "cpp" LanguageBash Language = "bash" LanguageHTML Language = "html" LanguageCSS Language = "css" LanguageSwift Language = "swift" LanguageJava Language = "java" LanguageYAML Language = "yaml" LanguageHCL Language = "hcl" )
func DetectLanguage ¶
DetectLanguage detects the programming language from a file path
func ValidateLanguage ¶
ValidateLanguage checks if a language string is valid
type NodeTypes ¶
NodeTypes represents language-specific AST node type names
func GetNodeTypes ¶
GetNodeTypes returns the language-specific node types for AST traversal
type SkimRequest ¶
type SkimRequest struct {
Source any `json:"source"` // String or array of strings: file path(s), directory path(s), or glob pattern(s)
ClearCache bool `json:"clear_cache,omitempty"`
StartingLine int `json:"starting_line,omitempty"` // Line number to start from (1-based)
Filter any `json:"filter,omitempty"` // String or array of strings: glob pattern(s) to filter function/method/class names (prefix with ! for inverse)
ExtractGraph bool `json:"extract_graph,omitempty"` // Extract relationship graph (imports, calls, inheritance)
OutputFormat string `json:"output_format,omitempty"` // Output format: "json" (default) or "sigil" (compressed for LLMs)
}
SkimRequest represents a request to transform code
type SkimResponse ¶
type SkimResponse struct {
Files []FileResult `json:"files"`
TotalFiles int `json:"total_files"`
ProcessedFiles int `json:"processed_files"`
FailedFiles int `json:"failed_files"`
ProcessingTimeMs *int64 `json:"processing_time_ms,omitempty"`
}
SkimResponse represents the response from a code transformation
type TransformResult ¶
type TransformResult struct {
Transformed string
MatchedItems int
TotalItems int
FilteredItems int
Graph *FileGraph // Optional graph extraction result
}
TransformResult contains transformation output and metadata
func Transform ¶
func Transform(ctx context.Context, source string, lang Language, isTSX bool) (*TransformResult, error)
Transform transforms source code by removing implementation details
func TransformWithFilter ¶
func TransformWithFilter(ctx context.Context, source string, lang Language, isTSX bool, filterPatterns []string) (*TransformResult, error)
TransformWithFilter transforms source code and optionally filters by name pattern(s) filterPatterns is an array of glob patterns (e.g., ["handle_*", "!temp_*"]) Pass nil or empty slice for no filtering
func TransformWithGraph ¶ added in v0.57.0
func TransformWithGraph(ctx context.Context, source string, lang Language, isTSX bool, extractGraph bool) (*TransformResult, error)
TransformWithGraph transforms source code and optionally extracts the graph
func TransformWithOptions ¶ added in v0.57.0
func TransformWithOptions(ctx context.Context, source string, lang Language, isTSX bool, filterPatterns []string, extractGraph bool) (*TransformResult, error)
TransformWithOptions transforms source code with optional filtering and graph extraction filterPatterns is an array of glob patterns (e.g., ["handle_*", "!temp_*"]) extractGraph controls whether to extract the relationship graph