Documentation
¶
Index ¶
- Variables
- type Axon
- func (a *Axon) DeleteByPath(ctx context.Context, path string) error
- func (a *Axon) Describe(ctx context.Context, includeFields bool) (*graph.SchemaDescription, error)
- func (a *Axon) Explain(ctx context.Context, q *aql.Query) (*graph.QueryPlan, error)
- func (a *Axon) Find(ctx context.Context, filter graph.NodeFilter, opts graph.QueryOptions) ([]*graph.Node, error)
- func (a *Axon) FindPath(ctx context.Context, fromID, toID string, opts PathOptions) ([]*Path, error)
- func (a *Axon) Flush(ctx context.Context) error
- func (a *Axon) GetNodeByURI(ctx context.Context, uri string) (*graph.Node, error)
- func (a *Axon) Graph() *graph.Graph
- func (a *Axon) Index(ctx context.Context, path string) (*IndexResult, error)
- func (a *Axon) IndexWithOptions(ctx context.Context, opts IndexOptions) (*IndexResult, error)
- func (a *Axon) IndexWithProgress(ctx context.Context, path string, prog chan<- progress.Event) (*IndexResult, error)
- func (a *Axon) Neighbors(ctx context.Context, uri string, opts NeighborsOptions) ([]*NeighborResult, error)
- func (a *Axon) PutNode(ctx context.Context, node *graph.Node) error
- func (a *Axon) Query(ctx context.Context, q *aql.Query) (*graph.QueryResult, error)
- func (a *Axon) QueryString(ctx context.Context, q string) (*graph.QueryResult, error)
- func (a *Axon) RegisterIndexer(idx indexer.Indexer)
- func (a *Axon) Search(ctx context.Context, queries []string, opts SearchOptions) ([]*SemanticSearchResult, error)
- func (a *Axon) SemanticSearch(ctx context.Context, queries []string, limit int, filter *graph.NodeFilter) ([]*SemanticSearchResult, error)
- func (a *Axon) Watch(ctx context.Context, path string, opts WatchOptions) error
- func (a *Axon) WriteNode(ctx context.Context, node *graph.Node) error
- type Config
- type ErrNoIndexer
- type IndexOptions
- type IndexResult
- type NeighborResult
- type NeighborsOptions
- type Path
- type PathOptions
- type PathStep
- type Querier
- type SearchOptions
- type SemanticSearchResult
- type WatchOptions
Constants ¶
This section is empty.
Variables ¶
var DefaultFSIgnore = []string{
".git",
"node_modules",
"__pycache__",
"target",
"vendor",
"venv",
"env",
"dist",
"build",
"site-packages",
".devspace",
".DS_Store",
"*.log",
}
DefaultFSIgnore contains the default patterns to exclude when indexing. Dot-prefixed paths are no longer blanket-excluded; specific entries are listed here so that useful dotfiles (.agents/, .claude/, etc.) remain visible to the graph.
var ErrNoEmbeddingProvider = errors.New("axon: no embedding provider configured; use axon init --embed to generate embeddings")
ErrNoEmbeddingProvider is returned when SemanticSearch is called but no EmbeddingProvider was configured.
Functions ¶
This section is empty.
Types ¶
type Axon ¶
type Axon struct {
// contains filtered or unexported fields
}
Axon is the main entry point for the axon library.
func (*Axon) DeleteByPath ¶ added in v0.6.0
DeleteByPath removes the graph node(s) for the given filesystem path and cleans up orphaned edges. For directory paths it removes all nodes whose URI has the directory URI as a prefix (entire subtree). Returns nil when no node exists for the path (idempotent).
func (*Axon) Describe ¶ added in v0.10.0
Describe returns a schema description of the current graph: every node type with its count, every edge type with its count and the from/to node-type pairs it connects, and (when includeFields is true) the top-level JSON data field names discovered in each node type.
Field discovery samples up to 500 nodes per type so the cost is bounded even on large graphs. Pass includeFields=false when you only need type/count information and want the fastest possible response.
Describe calls Flush before querying so that any buffered writes are visible in the results.
func (*Axon) Explain ¶ added in v0.9.0
Explain returns the execution plan for a pre-built AQL query.
func (*Axon) Find ¶ added in v0.9.0
func (a *Axon) Find(ctx context.Context, filter graph.NodeFilter, opts graph.QueryOptions) ([]*graph.Node, error)
Find returns nodes matching the structural filter.
func (*Axon) FindPath ¶ added in v0.15.0
func (a *Axon) FindPath(ctx context.Context, fromID, toID string, opts PathOptions) ([]*Path, error)
FindPath finds the shortest paths between two nodes in the knowledge graph.
fromID and toID are node IDs (as returned by Find, Search, or GetNodeByURI). Paths are discovered by bidirectional BFS: both outgoing and incoming edges are followed so that structural and semantic relationships are bridged.
The search is bounded by opts.MaxDepth edges (default 6) and returns at most opts.MaxPaths results (default 3), ordered by ascending length.
Returns an empty slice (no error) when no connecting path exists within the depth limit. Returns an error only when the origin node cannot be loaded or the storage layer fails.
func (*Axon) GetNodeByURI ¶ added in v0.9.1
GetNodeByURI returns the node with the given URI, or an error if not found.
func (*Axon) Index ¶
Index indexes the given path and updates the graph. If path is empty, indexes the configured directory.
func (*Axon) IndexWithOptions ¶
func (a *Axon) IndexWithOptions(ctx context.Context, opts IndexOptions) (*IndexResult, error)
IndexWithOptions indexes with the provided options.
The library never writes to stdout or stderr unless opts.ShowProgress is true, in which case compact progress lines are written to stderr. Use opts.Progress for structured event access.
func (*Axon) IndexWithProgress ¶
func (a *Axon) IndexWithProgress(ctx context.Context, path string, prog chan<- progress.Event) (*IndexResult, error)
IndexWithProgress indexes the given path and reports progress on the provided channel. If progress is nil, progress reporting is disabled.
func (*Axon) Neighbors ¶ added in v0.18.0
func (a *Axon) Neighbors(ctx context.Context, uri string, opts NeighborsOptions) ([]*NeighborResult, error)
Neighbors returns the immediate neighbors of the node identified by uri, following edges in the requested direction.
uri is the node URI (e.g. "file:///path/to/file.go" or "go:func:pkg.Func"). Direction defaults to "both" when opts.Direction is empty.
Results are ordered: outgoing edges first, then incoming, as returned by the storage layer (no additional sorting is applied). When opts.Max > 0 the result slice is truncated to that length after filtering.
Returns a non-nil error if the node cannot be found or the storage layer fails. An isolated node (no matching edges) returns an empty slice without an error.
func (*Axon) PutNode ¶ added in v0.9.1
PutNode writes a node to the storage layer without flushing or embedding. Use WriteNode for the full write-flush-embed cycle.
func (*Axon) QueryString ¶ added in v0.9.0
QueryString parses the AQL string and executes it. Convenience wrapper around aql.Parse + Query.
func (*Axon) RegisterIndexer ¶
RegisterIndexer adds a custom indexer.
func (*Axon) Search ¶ added in v0.9.0
func (a *Axon) Search(ctx context.Context, queries []string, opts SearchOptions) ([]*SemanticSearchResult, error)
Search performs semantic vector similarity search with the given options. It wraps SemanticSearch and applies MinScore filtering after the search.
func (*Axon) SemanticSearch ¶ added in v0.6.0
func (a *Axon) SemanticSearch(ctx context.Context, queries []string, limit int, filter *graph.NodeFilter) ([]*SemanticSearchResult, error)
SemanticSearch embeds each query string using the configured EmbeddingProvider and runs vector similarity search for each. Results across all queries are merged and deduplicated — the best score per node wins. Returns up to limit results sorted by score descending.
Returns ErrNoEmbeddingProvider if no provider is set in Config.
func (*Axon) Watch ¶ added in v0.5.0
Watch watches the given path for filesystem changes and re-indexes affected files automatically. It performs an initial full index, then blocks until ctx is cancelled, re-indexing individual changed files/directories on each batch of changes after the debounce window elapses.
func (*Axon) WriteNode ¶ added in v0.9.1
WriteNode writes a node to the graph, flushes it to storage, and automatically generates and stores an embedding if an EmbeddingProvider is configured. This is the preferred way to persist custom nodes programmatically — the node will be immediately findable via Search without requiring a full re-index run.
type Config ¶
type Config struct {
// Dir is the working directory. Defaults to current directory.
Dir string
// Storage is the storage backend. Defaults to in-memory storage.
Storage graph.Storage
// FSExclude contains glob patterns to exclude from indexing.
// When empty, DefaultFSIgnore is used. To clear all defaults, set FSExclude
// to a non-nil empty slice: []string{}.
// Patterns matched against file name and full absolute path.
FSExclude []string
// FSInclude contains glob patterns to include. When non-empty, only files
// matching at least one pattern are indexed (directories always traversed).
FSInclude []string
// FSIgnore is a deprecated alias for FSExclude.
// If both are set they are merged. Prefer FSExclude.
FSIgnore []string
// EmbeddingProvider is an optional embedding provider for semantic search.
// When set, a PostIndexer will generate and store embeddings for Go symbols
// and Markdown sections after each indexing run.
// If nil (default), no embeddings are generated.
EmbeddingProvider embeddings.Provider
// GitConfig holds configuration for the git indexer.
// Controls how many commits are indexed per repository (default: 500).
GitConfig git.Config
}
Config holds configuration for an Axon instance.
type ErrNoIndexer ¶
type ErrNoIndexer struct {
URI string
}
ErrNoIndexer is returned when no indexer can handle a URI.
func (*ErrNoIndexer) Error ¶
func (e *ErrNoIndexer) Error() string
type IndexOptions ¶
type IndexOptions struct {
// Path is the path to index. If empty, uses the configured directory.
Path string
// Progress is an optional channel for reporting indexing progress.
// Events are sent as indexers start, make progress, and complete.
// The caller owns the channel; it is never closed by the library.
// Mutually exclusive with ShowProgress — if both are set, Progress
// takes precedence and ShowProgress is ignored.
Progress chan<- progress.Event
// ShowProgress writes a compact human-readable progress log to
// os.Stderr. Intended for programmatic callers that want feedback
// without wiring up a full progress channel or a bubbletea UI.
//
// Default: false (completely silent).
ShowProgress bool
// SkipGC skips garbage collection (orphaned edge cleanup) after indexing.
// This can speed up indexing when you know cleanup isn't needed,
// or when you plan to run `axon gc` separately.
SkipGC bool
}
IndexOptions configures the indexing behavior.
type IndexResult ¶
type IndexResult struct {
Files int
Directories int
Repos int
StaleRemoved int
RootURI string
Generation string
Errors []error // Errors from individual indexers (non-fatal)
}
IndexResult contains statistics from an indexing operation.
type NeighborResult ¶ added in v0.18.0
type NeighborResult struct {
// Node is the connected graph node.
Node *graph.Node
// EdgeType is the type of the edge connecting origin and Node.
EdgeType string
// Direction is "in" when the edge points from Node toward the origin,
// or "out" when it points from the origin toward Node.
Direction string
// EdgeID is the internal ID of the connecting edge.
EdgeID string
}
NeighborResult is one entry returned by Neighbors: the connected node together with the edge that links it to the origin node.
type NeighborsOptions ¶ added in v0.18.0
type NeighborsOptions struct {
// Direction controls which edges to follow.
// Accepted values: "in", "out", "both". Default (empty string) is "both".
Direction string
// EdgeTypes restricts results to edges whose type matches one of these
// values. When nil or empty, all edge types are included.
EdgeTypes []string
// Max caps the number of results returned. 0 means no limit.
Max int
}
NeighborsOptions configures a call to (*Axon).Neighbors.
type Path ¶ added in v0.15.0
type Path struct {
Steps []PathStep
}
Path is an ordered sequence of PathSteps representing a route through the knowledge graph from one node to another.
type PathOptions ¶ added in v0.15.0
type PathOptions struct {
// MaxDepth caps the BFS search depth in number of edges. Default: 6.
MaxDepth int
// MaxPaths limits the number of distinct paths returned. Default: 3.
MaxPaths int
// EdgeTypes restricts traversal to edges of these types only.
// When nil or empty, all edge types are traversed.
EdgeTypes []string
}
PathOptions configures a call to (*Axon).FindPath.
type PathStep ¶ added in v0.15.0
type PathStep struct {
// Node is the graph node at this position in the path.
Node *graph.Node
// EdgeType is the type of the edge that connects the previous node to this
// one. Empty string for the first step (the origin node).
EdgeType string
// Incoming is true when this step was reached by following an incoming
// edge in reverse (i.e. the underlying edge points FROM this node TOWARD
// the previous node). False for outgoing edges and for the origin step.
Incoming bool
}
PathStep is one node in a path through the knowledge graph, annotated with the edge that was followed to arrive at it.
type Querier ¶ added in v0.9.0
type Querier interface {
// Query executes a pre-built AQL query (from aql.Builder.Build or aql.Parse).
Query(ctx context.Context, q *aql.Query) (*graph.QueryResult, error)
// QueryString parses an AQL string and executes it in one call.
QueryString(ctx context.Context, q string) (*graph.QueryResult, error)
// Explain returns the execution plan for a pre-built AQL query without
// running it. Useful for debugging and performance analysis.
Explain(ctx context.Context, q *aql.Query) (*graph.QueryPlan, error)
// Find returns nodes matching the structural filter.
Find(ctx context.Context, filter graph.NodeFilter, opts graph.QueryOptions) ([]*graph.Node, error)
// Search performs semantic vector similarity search.
// Returns ErrNoEmbeddingProvider if no embedding provider is configured.
Search(ctx context.Context, queries []string, opts SearchOptions) ([]*SemanticSearchResult, error)
// FindPath finds the shortest paths between two nodes identified by their
// node IDs. Returns an empty slice (no error) when no path exists within
// the configured depth limit.
FindPath(ctx context.Context, fromID, toID string, opts PathOptions) ([]*Path, error)
}
Querier is the read-only interface for executing queries against an axon graph. *Axon satisfies it, allowing integrators to depend on the interface for easier testing and decoupling.
type SearchOptions ¶ added in v0.9.1
type SearchOptions struct {
// Limit is the maximum number of results to return. Defaults to 20.
Limit int
// Filter restricts the search to nodes matching the given criteria.
// nil = no filter (search all nodes).
Filter *graph.NodeFilter
// MinScore drops results whose similarity score is below this threshold.
// Range 0.0–1.0. Default 0 = return all results.
MinScore float32
}
SearchOptions configures a call to (*Axon).Search.
type SemanticSearchResult ¶ added in v0.6.0
type SemanticSearchResult struct {
*graph.NodeWithScore
MatchedQuery string
}
SemanticSearchResult is a node with its best-match score and the query that produced it.
type WatchOptions ¶ added in v0.5.0
type WatchOptions struct {
IndexOptions
// Debounce is how long to wait after the last file event before
// triggering a re-index. Default: 150ms.
Debounce time.Duration
// GCInterval is how often the background GC ticker runs DeleteExpired.
// Default: 5 minutes. Set to 0 to disable background expiry GC.
GCInterval time.Duration
// OnReady is called once after the initial full index completes.
// It is NOT called on subsequent change-triggered re-indexes.
// If nil, the initial result is silently discarded.
OnReady func(result *IndexResult, err error)
// OnReindex is called after each change-triggered re-index.
// It is NOT called for the initial index (use OnReady for that).
// If nil, re-index results are silently discarded.
OnReindex func(path string, result *IndexResult, err error)
}
WatchOptions configures the Watch behavior.
Directories
¶
| Path | Synopsis |
|---|---|
|
adapters
|
|
|
Package aql provides a type-safe fluent API and parser for the Axon Query Language (AQL).
|
Package aql provides a type-safe fluent API and parser for the Axon Query Language (AQL). |
|
cmd
|
|
|
axon
command
|
|
|
axonui
command
|
|
|
Package context provides the budget fitting algorithm for the Context Window Optimizer.
|
Package context provides the budget fitting algorithm for the Context Window Optimizer. |
|
Package graph provides the core graph data structures and operations for Axon.
|
Package graph provides the core graph data structures and operations for Axon. |
|
embeddings
Package embeddings provides the Provider interface and built-in implementations for generating vector embeddings from text.
|
Package embeddings provides the Provider interface and built-in implementations for generating vector embeddings from text. |
|
git/commitparser
Package commitparser implements a lenient parser for Conventional Commits (https://www.conventionalcommits.org/).
|
Package commitparser implements a lenient parser for Conventional Commits (https://www.conventionalcommits.org/). |
|
golang
Package golang provides an indexer for Go modules and packages.
|
Package golang provides an indexer for Go modules and packages. |
|
project
Package project provides an indexer for detecting project types from manifest files.
|
Package project provides an indexer for detecting project types from manifest files. |
|
todo
Package todo indexes TODO/FIXME/HACK/XXX/NOTE annotation comments from source files, emitting one code:todo graph node per matched annotation.
|
Package todo indexes TODO/FIXME/HACK/XXX/NOTE annotation comments from source files, emitting one code:todo graph node per matched annotation. |
|
Package progress provides progress reporting for indexing operations.
|
Package progress provides progress reporting for indexing operations. |