analyzer

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigNode

type ConfigNode struct {
	Path       string
	Content    []byte
	Parsed     *parser.ParsedFile
	References []Reference
	Children   []*ConfigNode
	Parent     *ConfigNode
	Depth      int
}

ConfigNode represents a node in the configuration tree

type ContextScope

type ContextScope struct {
	// Type indicates whether this is a main or subagent scope
	Type ScopeType

	// Name identifies the scope ("main" or the subagent name)
	Name string

	// Entrypoint is the root file path for this scope
	Entrypoint string

	// Nodes contains all ConfigNodes that belong to this scope
	Nodes []*ConfigNode

	// FilePaths is a convenience list of all file paths in this scope
	FilePaths []string

	// Children contains nested scopes (commands/skills for main, skills for subagents)
	Children []*ContextScope

	// DeclaredSkills contains skill names declared in frontmatter
	DeclaredSkills []string

	// DeclaredTools contains tool names declared in frontmatter
	DeclaredTools []string
}

ContextScope represents an isolated scope for analysis. Each scope contains a subset of files that form a coherent context, either the main agent configuration or a subagent's configuration.

type Location

type Location struct {
	File   string
	Line   int
	Column int
}

Location represents a position in a file

func (Location) String

func (l Location) String() string

type Metrics

type Metrics struct {
	TotalFiles       int
	TotalReferences  int
	EstimatedTokens  int
	TotalBytes       int
	ReferencesByType map[string]int
	FilesByType      map[string]int
	MaxDepth         int
	UnresolvedRefs   int
}

Metrics contains computed metrics about the configuration

func ComputeMetrics

func ComputeMetrics(tree *Tree) *Metrics

ComputeMetrics computes metrics for a configuration tree

type RefType

type RefType int

RefType represents the type of reference

const (
	RefTypeFile RefType = iota
	RefTypeURL
	RefTypeTool
	RefTypeSubagent
	RefTypeSkill
	RefTypeMCPServer
	RefTypeUnknown
)

func ParseRefType

func ParseRefType(s string) RefType

ParseRefType converts a string to RefType

func (RefType) String

func (rt RefType) String() string

type Reference

type Reference struct {
	Type     RefType
	Value    string
	Source   Location
	Priority int    // Based on surrounding markers
	Context  string // Surrounding text for context
	Resolved bool   // Whether the reference was resolved
	Target   string // Resolved path/URL
}

Reference represents a reference found in a configuration file

type ScopeType

type ScopeType int

ScopeType represents the type of context scope

const (
	// ScopeTypeMain represents the main agent context
	ScopeTypeMain ScopeType = iota
	// ScopeTypeSubagent represents a subagent context
	ScopeTypeSubagent
	// ScopeTypeCommand represents a slash command context
	ScopeTypeCommand
	// ScopeTypeSkill represents a skill context
	ScopeTypeSkill
)

func (ScopeType) String

func (st ScopeType) String() string

type Tree

type Tree struct {
	Root     *ConfigNode
	RootPath string                 // Absolute path to project root
	Nodes    map[string]*ConfigNode // Path -> Node
}

Tree represents the complete configuration tree

func BuildTree

func BuildTree(rootPath string, agentConfig *agent.Config) (*Tree, error)

BuildTree builds a reference tree starting from the given path

func (*Tree) AllPaths

func (t *Tree) AllPaths() []string

AllPaths returns all file paths in the tree

func (*Tree) AllReferences

func (t *Tree) AllReferences() []Reference

AllReferences returns all references from all nodes

func (*Tree) DiscoverCommands

func (t *Tree) DiscoverCommands(agentConfig *agent.Config, rootPath string) ([]*ContextScope, error)

DiscoverCommands finds all slash commands in .claude/commands/ and builds scopes for them. Each command file becomes its own context scope that can be analyzed independently.

func (*Tree) DiscoverScopes

func (t *Tree) DiscoverScopes(agentConfig *agent.Config, rootPath string) ([]*ContextScope, error)

DiscoverScopes finds all context scopes in the tree. It identifies the main scope and any subagent scopes from: 1. RefTypeSubagent references in parsed files 2. Files in well-known paths like .claude/agents/

func (*Tree) DiscoverSkills

func (t *Tree) DiscoverSkills(agentConfig *agent.Config, rootPath string) ([]*ContextScope, error)

DiscoverSkills finds all skills in .claude/skills/ and builds scopes for them. Each skill directory becomes its own context scope that can be analyzed independently.

func (*Tree) NodeCount

func (t *Tree) NodeCount() int

NodeCount returns the total number of nodes in the tree

func (*Tree) PrintTree

func (t *Tree) PrintTree()

PrintTree prints the tree structure

Jump to

Keyboard shortcuts

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