Documentation
¶
Overview ¶
Package cartograph provides the public embedded API for using Cartograph as an in-process Go library.
Index ¶
- Variables
- func DefaultDataDir() string
- type AnalyzeOptions
- type AnalyzeResult
- type CallTreeNode
- type CatFile
- type CatOptions
- type CatResult
- type Client
- func (c *Client) Analyze(ctx context.Context, target string, opts AnalyzeOptions) (result *AnalyzeResult, retErr error)
- func (c *Client) Cat(ctx context.Context, repo string, files []string, opts CatOptions) (*CatResult, error)
- func (c *Client) Close() error
- func (c *Client) Context(ctx context.Context, repo, symbol string, opts ContextOptions) (*ContextResult, error)
- func (c *Client) Cypher(ctx context.Context, repo, cypher string, _ CypherOptions) (*CypherResult, error)
- func (c *Client) Impact(ctx context.Context, repo, symbol string, opts ImpactOptions) (*ImpactResult, error)
- func (c *Client) List(ctx context.Context) (*ListResult, error)
- func (c *Client) Query(ctx context.Context, repo, text string, opts QueryOptions) (*QueryResult, error)
- func (c *Client) RegisterPlugin(ctx context.Context, p pluginsdk.Plugin, opts RegisterPluginOptions) (*PluginDatasetStatus, error)
- func (c *Client) Schema(ctx context.Context, repo string) (*SchemaResult, error)
- func (c *Client) Search(ctx context.Context, repo, pattern string, opts SearchOptions) (*SearchResult, error)
- func (c *Client) Status(ctx context.Context, repo string) (*StatusResult, error)
- func (c *Client) Tree(ctx context.Context, repo string, _ TreeOptions) (*TreeResult, error)
- type Config
- type ContextOptions
- type ContextRelationship
- type ContextResult
- type CypherOptions
- type CypherResult
- type ImpactOptions
- type ImpactResult
- type ListResult
- type NodeLabelSummary
- type PluginDatasetStatus
- type PluginDisplayField
- type PluginQueryMatch
- type ProcessMatch
- type QueryOptions
- type QueryResult
- type RegisterPluginOptions
- type RelTypeSummary
- type RelationshipGroup
- type RelationshipPatternSummary
- type RelationshipStats
- type RepoArtifact
- type RepoInfo
- type SchemaResult
- type SearchMatch
- type SearchOptions
- type SearchResult
- type StatusResult
- type SymbolMatch
- type TreeOptions
- type TreeResult
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDataDirInUse = errors.New("cartograph: data directory in use")
ErrDataDirInUse is returned when a background Cartograph service owns the configured data directory.
Functions ¶
func DefaultDataDir ¶
func DefaultDataDir() string
DefaultDataDir returns the default data directory for Cartograph.
It respects XDG_DATA_HOME when set, otherwise it falls back to ~/.local/share/cartograph.
Types ¶
type AnalyzeOptions ¶
type AnalyzeOptions struct {
Force bool
// Ref selects a remote branch or tag. Local targets reject this option.
Ref string
// CloneDepth controls remote shallow-clone depth. Values <= 0 use depth 1.
CloneDepth int
// AuthToken authenticates HTTPS clones of private repositories.
AuthToken string
OnStep func(step string, current, total int)
OnFileProgress func(done, total int)
}
AnalyzeOptions controls local or remote repository analysis.
type AnalyzeResult ¶
type AnalyzeResult struct {
RepoName string
RepoHash string
IndexedPath string
NodeCount int
EdgeCount int
Duration time.Duration
Skipped bool
Commit string
}
AnalyzeResult summarizes a local or remote repository analysis run.
type CallTreeNode ¶
type CallTreeNode struct {
Symbol SymbolMatch
EdgeType string
Children []CallTreeNode
Pruned int
}
CallTreeNode is a node in a transitive call tree returned by Context.
type CatResult ¶
type CatResult struct {
Files []CatFile
}
CatResult contains file contents returned by Cat.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an in-process Cartograph client.
A Client is safe for concurrent use. Repositories are loaded lazily on first access and remain cached until Close is called.
func Open ¶
Open opens an embedded Cartograph client.
Example ¶
package main
import (
"context"
"github.com/onixhdz/cartograph"
)
func main() {
client, err := cartograph.Open(cartograph.Config{})
if err != nil {
return
}
defer client.Close()
_, _ = client.List(context.Background())
}
Output:
func (*Client) Analyze ¶
func (c *Client) Analyze(ctx context.Context, target string, opts AnalyzeOptions) (result *AnalyzeResult, retErr error)
Analyze analyzes and indexes one local path, Git URL, host-prefixed URL, or owner/repository shorthand target.
Example ¶
package main
import (
"context"
"github.com/onixhdz/cartograph"
)
func main() {
ctx := context.Background()
client, err := cartograph.Open(cartograph.Config{})
if err != nil {
return
}
defer client.Close()
result, err := client.Analyze(ctx, ".", cartograph.AnalyzeOptions{})
if err != nil {
return
}
_, _ = client.Schema(ctx, result.RepoHash)
}
Output:
func (*Client) Cat ¶
func (c *Client) Cat(ctx context.Context, repo string, files []string, opts CatOptions) (*CatResult, error)
Cat returns source contents for files in an indexed repository.
func (*Client) Context ¶
func (c *Client) Context(ctx context.Context, repo, symbol string, opts ContextOptions) (*ContextResult, error)
Context returns symbol context from an indexed repository.
func (*Client) Cypher ¶
func (c *Client) Cypher(ctx context.Context, repo, cypher string, _ CypherOptions) (*CypherResult, error)
Cypher runs a read-only Cypher query against an indexed repository.
func (*Client) Impact ¶
func (c *Client) Impact(ctx context.Context, repo, symbol string, opts ImpactOptions) (*ImpactResult, error)
Impact returns upstream or downstream impact for a symbol.
func (*Client) List ¶
func (c *Client) List(ctx context.Context) (*ListResult, error)
List lists indexed repositories in the configured data directory.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, repo, text string, opts QueryOptions) (*QueryResult, error)
Query runs a graph-aware query against an indexed repository or plugin dataset.
func (*Client) RegisterPlugin ¶
func (c *Client) RegisterPlugin(ctx context.Context, p pluginsdk.Plugin, opts RegisterPluginOptions) (*PluginDatasetStatus, error)
RegisterPlugin registers and ingests a plugin directly in this process.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, repo, pattern string, opts SearchOptions) (*SearchResult, error)
Search searches source text in an indexed repository.
func (*Client) Tree ¶
func (c *Client) Tree(ctx context.Context, repo string, _ TreeOptions) (*TreeResult, error)
Tree returns indexed file paths for a repository.
type Config ¶
type Config struct {
// DataDir is the Cartograph data directory. If empty, DefaultDataDir is used.
DataDir string
}
Config configures an embedded Cartograph client.
type ContextOptions ¶
type ContextOptions struct {
File string
UID string
Content bool
Depth int
IncludeTests bool
IncludeRelationships bool
RelationshipLimit int
}
ContextOptions controls symbol context behavior.
type ContextRelationship ¶
type ContextRelationship struct {
FromID string
From SymbolMatch
ToID string
To SymbolMatch
}
ContextRelationship is a graph edge returned by context relationship mode.
type ContextResult ¶
type ContextResult struct {
Symbol SymbolMatch
Callers []SymbolMatch
Callees []SymbolMatch
CallTree *CallTreeNode
Importers []SymbolMatch
Imports []SymbolMatch
Processes []SymbolMatch
Implementors []SymbolMatch
Extends []SymbolMatch
RelationshipGroups []RelationshipGroup
RelationshipStats *RelationshipStats
}
ContextResult contains a symbol's immediate and optional transitive graph context.
type CypherOptions ¶
type CypherOptions struct{}
CypherOptions is reserved for future read-only Cypher options.
type CypherResult ¶
CypherResult contains read-only Cypher query rows.
type ImpactOptions ¶
type ImpactOptions struct {
File string
Direction string
Depth int
CrossRepo bool
IncludeTests bool
}
ImpactOptions controls impact traversal behavior.
type ImpactResult ¶
type ImpactResult struct {
Target SymbolMatch
Affected []SymbolMatch
Depth int
}
ImpactResult contains affected symbols for a target.
type ListResult ¶
type ListResult struct {
Repos []RepoInfo
}
ListResult lists indexed repositories.
type NodeLabelSummary ¶
NodeLabelSummary describes a node label and its count.
type PluginDatasetStatus ¶
type PluginDatasetStatus struct {
PluginName string
PluginVersion string
ConnectionName string
Repo string
RepoHash string
NodeCount int
EdgeCount int
ResourceCount int
Duration time.Duration
}
PluginDatasetStatus summarizes a registered plugin dataset.
type PluginDisplayField ¶
PluginDisplayField is one displayed plugin result field.
type PluginQueryMatch ¶
type PluginQueryMatch struct {
EntityLabel string
NodeID string
Score float64
Fields []PluginDisplayField
}
PluginQueryMatch represents one plugin dataset query match.
type ProcessMatch ¶
type ProcessMatch struct {
Name string
HeuristicLabel string
StepCount int
CallerCount int
Importance float64
Relevance float64
}
ProcessMatch represents a matched process in query results.
type QueryOptions ¶
QueryOptions controls Query behavior.
type QueryResult ¶
type QueryResult struct {
Processes []ProcessMatch
ProcessSymbols []SymbolMatch
Definitions []SymbolMatch
UsageExamples []SymbolMatch
TestFlows []ProcessMatch
PluginResults []PluginQueryMatch
}
QueryResult contains graph-aware query matches.
type RegisterPluginOptions ¶
type RegisterPluginOptions struct {
ConnectionName string
Config map[string]string
ResourceTypes []string
Concurrency int
Timeout time.Duration
MaxNodes int
MaxEdges int
}
RegisterPluginOptions configures in-process plugin registration.
type RelTypeSummary ¶
RelTypeSummary describes a relationship type and its count.
type RelationshipGroup ¶
type RelationshipGroup struct {
Type string
Relationships []ContextRelationship
}
RelationshipGroup contains context relationships grouped by graph relationship type.
type RelationshipPatternSummary ¶
RelationshipPatternSummary describes an observed edge pattern.
type RelationshipStats ¶
type RelationshipStats struct {
Depth int
ReturnedNodes int
ReturnedRelationships int
Limit int
Truncated bool
}
RelationshipStats describes a bounded graph neighborhood returned with Context.
type RepoArtifact ¶
RepoArtifact describes one on-disk index artifact.
type RepoInfo ¶
type RepoInfo struct {
Name string
Hash string
Type string
IndexedAt string
NodeCount int
EdgeCount int
BuiltWith string
Embedding string
}
RepoInfo describes one indexed repository.
type SchemaResult ¶
type SchemaResult struct {
NodeLabels []NodeLabelSummary
RelTypes []RelTypeSummary
RelationshipPatterns []RelationshipPatternSummary
Properties []string
TotalNodes int
TotalEdges int
}
SchemaResult summarizes the graph schema for writing Cypher queries.
type SearchMatch ¶
type SearchMatch struct {
FilePath string
Line int
Column int
LineText string
Before []string
After []string
Symbol *SymbolMatch
}
SearchMatch is one source search match plus bounded context.
type SearchOptions ¶
type SearchOptions struct {
FixedStrings bool
IgnoreCase bool
Limit int
ContextLines int
Files string
ExcludeTests bool
}
SearchOptions controls source search behavior.
type SearchResult ¶
type SearchResult struct {
Repo string
Pattern string
FixedStrings bool
IndexStatus string
Message string
DurationMS int64
MatchCount int
FileCount int
Truncated bool
Matches []SearchMatch
}
SearchResult contains source search matches.
type StatusResult ¶
type StatusResult struct {
Name string
Hash string
Path string
URL string
Type string
Indexed bool
IndexedAt string
NodeCount int
EdgeCount int
Commit string
Branch string
Languages []string
Duration string
BuiltWith string
EmbeddingStatus string
EmbeddingProgress int
EmbeddingTotal int
EmbeddingModel string
EmbeddingProvider string
EmbeddingDims int
EmbeddingError string
Artifacts []RepoArtifact
}
StatusResult describes one repository's index status.
type SymbolMatch ¶
type SymbolMatch struct {
Name string
FilePath string
StartLine int
EndLine int
Label string
ProcessName string
Content string
Score float64
Repo string
Signature string
}
SymbolMatch represents a matched symbol in query, context, and impact results.
type TreeOptions ¶
type TreeOptions struct{}
TreeOptions configures Tree. There are currently no options.
type TreeResult ¶
TreeResult contains indexed repository file paths.
Directories
¶
| Path | Synopsis |
|---|---|
|
cartograph
command
|
|
|
examples
|
|
|
embedded
command
|
|
|
plugins/mitre-capec
command
|
|
|
plugins/mitre-cwe
command
|
|
|
internal
|
|
|
embedding
Package embedding provides text embedding vectors for semantic search.
|
Package embedding provides text embedding vectors for semantic search. |
|
embedding/local
Package local provides embedding via native CGO-linked inference.
|
Package local provides embedding via native CGO-linked inference. |
|
graph
Package graph defines the node labels, relationship types, and property structs used throughout the Cartograph knowledge graph.
|
Package graph defines the node labels, relationship types, and property structs used throughout the Cartograph knowledge graph. |
|
ingestion
Package ingestion implements the Cartograph ingestion pipeline: filesystem walking, structure building, import/call/heritage resolution, community detection, and process detection.
|
Package ingestion implements the Cartograph ingestion pipeline: filesystem walking, structure building, import/call/heritage resolution, community detection, and process detection. |
|
mcp
Package mcp implements an MCP (Model Context Protocol) server for Cartograph.
|
Package mcp implements an MCP (Model Context Protocol) server for Cartograph. |
|
query
Package query implements the query/context/cypher/impact tool backends that operate on an in-memory lpg.Graph.
|
Package query implements the query/context/cypher/impact tool backends that operate on an in-memory lpg.Graph. |
|
remote
Package remote provides Git remote operations: URL parsing, cloning (in-memory and on-disk), and billy filesystem walkers/readers that integrate with the ingestion pipeline.
|
Package remote provides Git remote operations: URL parsing, cloning (in-memory and on-disk), and billy filesystem walkers/readers that integrate with the ingestion pipeline. |
|
search
Package search implements full-text search (BM25 via Bleve) and hybrid search (RRF merging) for the Cartograph knowledge graph.
|
Package search implements full-text search (BM25 via Bleve) and hybrid search (RRF merging) for the Cartograph knowledge graph. |
|
service
Package service defines the HTTP/JSON API types for the CLI ↔ service IPC.
|
Package service defines the HTTP/JSON API types for the CLI ↔ service IPC. |
|
storage
Package storage defines the GraphStore persistence interface and repository metadata management.
|
Package storage defines the GraphStore persistence interface and repository metadata management. |
|
storage/bbolt
Package bbolt implements the storage.GraphStore interface using bbolt (an embedded key-value store) with msgpack serialization.
|
Package bbolt implements the storage.GraphStore interface using bbolt (an embedded key-value store) with msgpack serialization. |
|
sysutil
Package sysutil provides platform-specific system utilities: available memory, process detachment, signal handling, and PID management for resource-aware tuning and daemon lifecycle control.
|
Package sysutil provides platform-specific system utilities: available memory, process detachment, signal handling, and PID management for resource-aware tuning and daemon lifecycle control. |
|
testutil
Package testutil provides shared test fixtures and helpers for Cartograph unit tests.
|
Package testutil provides shared test fixtures and helpers for Cartograph unit tests. |
|
wiki
Package wiki implements context generation and HTML bundling for agent-driven wiki generation.
|
Package wiki implements context generation and HTML bundling for agent-driven wiki generation. |
|
Package plugin is the SDK for implementing in-process Cartograph plugins.
|
Package plugin is the SDK for implementing in-process Cartograph plugins. |
|
plugintest
Package plugintest provides test utilities for Cartograph plugin authors.
|
Package plugintest provides test utilities for Cartograph plugin authors. |