source

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package source builds a repository graph and discovers MCP registrations. Build walks, parses, resolves symbols, and finds MCP registrations. It is the independent entry point for every graph-consuming analyzer, so none depends on analyzer execution order.

Index

Constants

View Source
const ArtifactKey = "source.graph"

ArtifactKey is where the built graph is published on ac.Artifacts

View Source
const SynthesizeCoverageKey = "source.synthesize_coverage"

SynthesizeCoverageKey lets snapshot consumers include unresolved source declarations in their coverage. The caller publishes the value.

View Source
const WalkCoverageKey = "source.walk_coverage"

WalkCoverageKey stores coverage from the walk that produced ArtifactKey. Consumers that reuse the graph must also reuse its blind spots instead of claiming a fresh, complete walk.

Variables

This section is empty.

Functions

func Build

func Build(ctx context.Context, root string) (*graph.Graph, model.Coverage, error)

Build walks root, parses every file discovered, resolves the call graph and discovers MCP registrations. It always returns a graph, even an empty one, because the caller still needs the coverage counters to report a gap honestly rather than silently.

func DisplayName added in v1.2.0

func DisplayName(c graph.Capability) string

DisplayName is the name to show for a capability in findings and snapshots: the resolved name, a handler named by identifier, or an "<unresolved at file:line>" marker - never handler code

func FoldWalkCoverage

func FoldWalkCoverage(a *analyzer.Artifacts, cov model.Coverage) model.Coverage

FoldWalkCoverage merges file counters, skips, and limits into a graph consumer's coverage without overwriting analyzer-specific symbol or capability counts. Missing shared coverage leaves cov unchanged, which lets callers report that absence according to the target type rather than fabricating counters.

func LoadGraph

func LoadGraph(ctx context.Context, ac *analyzer.AnalysisContext, root string) (g *graph.Graph, cov model.Coverage, walkCoverageMissing bool, err error)

LoadGraph reuses a published graph or builds one independently. A reused graph without walk coverage is accepted but reported as PARTIAL, so missing metadata cannot resemble an empty tree.

func Publish

func Publish(a *analyzer.Artifacts, g *graph.Graph, cov model.Coverage)

Publish shares a built graph and the coverage of the walk that produced it.

The two go together: a consumer that reuses the graph has to reuse its blind spots too, or it reports a complete walk it never performed. Coverage is stored first on purpose. Artifacts is mutex-guarded, so a consumer that sees the graph is guaranteed to see the coverage stored before it - publishing them the other way round leaves a window where the graph looks like the product of a walk that found nothing.

func ResolveRoot

func ResolveRoot(targetPath, acRoot string) (string, error)

ResolveRoot picks the scan root, preferring ac.Root over target.Path: a caller that set Root has already fixed the filesystem boundary, so target.Path cannot override it. If Root is unset, target.Path is used as-is. When both are present, symlinks are resolved and target.Path must remain beneath the established root.

func Synthesize

func Synthesize(g *graph.Graph) (*model.Snapshot, model.Coverage)

Synthesize builds a Snapshot from discovered capabilities so analyzers that read declared text can run against a source tree. The returned coverage records unresolved names or descriptions as reasoned skips; prompt defense later converts unresolved fields into an analyzed-count gap.

func UnresolvedDescriptions

func UnresolvedDescriptions(g *graph.Graph) map[string]bool

UnresolvedDescriptions returns tools whose descriptions could not be resolved, using the names assigned by Synthesize. Their empty snapshot fields indicate coverage gaps, not known empty descriptions.

Types

type Analyzer

type Analyzer struct{}

Analyzer walks a source tree, builds the symbol/call graph and discovers MCP registrations. Its own findings are limited to what the discovery pass itself can say about a capability's declared metadata; dataflow and behavioral comparison are separate analyzers that consume the same graph.

func (*Analyzer) Analyze

func (*Analyzer) AppliesTo

func (*Analyzer) AppliesTo(kind model.TargetKind) bool

func (*Analyzer) Describe

func (*Analyzer) Describe() analyzer.Description

func (*Analyzer) Name

func (*Analyzer) Name() string

Directories

Path Synopsis
Package bundle reads a JavaScript bundle in esbuild's output shape - tsup and other tools built on esbuild write the same - where every bundled module opens with a comment line holding the path the bundler resolved it from:
Package bundle reads a JavaScript bundle in esbuild's output shape - tsup and other tools built on esbuild write the same - where every bundled module opens with a comment line holding the path the bundler resolved it from:
Package graph is the exported source-code model shared between the discovery pass and every analyzer that reasons about dataflow: symbols, imports, the call graph and the MCP capabilities found in it
Package graph is the exported source-code model shared between the discovery pass and every analyzer that reasons about dataflow: symbols, imports, the call graph and the MCP capabilities found in it
Package inventory walks regular source files within a hard root boundary and records reported skips.
Package inventory walks regular source files within a hard root boundary and records reported skips.
Package language adapts each supported source language to a common shape: its file extensions, its tree-sitter grammar, and the small set of node kinds the parser and taint walker need to recognize (a function, a call, an assignment, a string literal)
Package language adapts each supported source language to a common shape: its file extensions, its tree-sitter grammar, and the small set of node kinds the parser and taint walker need to recognize (a function, a call, an assignment, a string literal)
Package parser turns one source file into symbols, imports and calls using the language's tree-sitter grammar and queries.
Package parser turns one source file into symbols, imports and calls using the language's tree-sitter grammar and queries.
Package queries embeds the tree-sitter query files for every supported language, so parsing never depends on a query file being present on disk at runtime
Package queries embeds the tree-sitter query files for every supported language, so parsing never depends on a query file being present on disk at runtime
Package registration finds where MCP tools, prompts and resources are registered, across direct SDK calls, decorators/annotations/attributes, a wrapper function that forwards into the SDK, and registration inside a loop - working entirely off the graph the parser already built, so it never re-reads source.
Package registration finds where MCP tools, prompts and resources are registered, across direct SDK calls, decorators/annotations/attributes, a wrapper function that forwards into the SDK, and registration inside a loop - working entirely off the graph the parser already built, so it never re-reads source.
Package targetfs reads the files of a scanned tree after the inventory walk.
Package targetfs reads the files of a scanned tree after the inventory walk.

Jump to

Keyboard shortcuts

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