Documentation
¶
Overview ¶
Package aiusage reports AI usage in source code: it builds each language's call graph with reach, projects it as a graph fragment and matches the AI cards against it. MCP servers come from the MCP client configs in the tree (package mcp).
Index ¶
Constants ¶
const ( ModelLiteral = "literal" ModelConstant = "constant" ModelUnresolved = "unresolved" )
Model resolution values; a rule that reports a model leaves the field to resolveModel.
const DefaultRuleset = "ai@latest"
DefaultRuleset is the ruleset Scan downloads when Options.Ruleset is empty.
const MetadataKey = "ai"
MetadataKey is the rule block AI cards carry their metadata in.
Variables ¶
var ( ErrRulesUnavailable = rulesets.ErrUnavailable // ErrAPIKeyRequired is a scan with neither a rules directory nor an API key to lease rules with. ErrAPIKeyRequired = fmt.Errorf("%w: API key required", ErrRulesUnavailable) // has: their verdicts are unknown, so the scan has no result. ErrVerdictsUnavailable = errors.New("MCP server verdicts unavailable") )
Functions ¶
func CountAtOrAbove ¶
CountAtOrAbove counts the findings whose risk is at least threshold.
func Render ¶
Render writes a report as the ai-usage command does, naming project in the document metadata.
Types ¶
type Options ¶
type Options struct {
// RulesDir holds the card files, one directory per card language (python/, javascript/). When
// set, nothing is downloaded; when empty, the ruleset is leased from the API with API's key.
RulesDir string
// API is the SCANOSS API rulesets are leased from and MCP verdicts are looked up with.
API scanoss.Config
// Ruleset is the ruleset to download, name@version (default DefaultRuleset).
Ruleset string
// CacheDir is where downloaded rulesets are cached (default rulesets.DefaultCacheDir()).
CacheDir string
// NoCache downloads the ruleset again and refreshes the cache.
NoCache bool
// MaxStale is how old a cached ruleset may be when the API is unreachable (default 30 days,
// at most 90).
MaxStale time.Duration
// Strict fails when the API is unreachable instead of using an expired cached ruleset.
Strict bool
// Languages are the languages to scan: python, javascript, typescript, and json for MCP
// client configs. Empty scans every card language the rules hold and the MCP configs.
Languages []string
// IncludeTests also scans test files.
IncludeTests bool
// Reachability decides for each finding whether it runs from an entry point.
Reachability bool
// Vulnerabilities judges the packages MCP servers launch in place of a client built from API.
Vulnerabilities scanoss.VulnerabilityAPI
}
Options select the rules and languages of a scan.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package contracts holds the types of the AI SDK client objects (what a constructor returns, what its attributes hold), which reach needs to type calls such as client.chat.completions.create.
|
Package contracts holds the types of the AI SDK client objects (what a constructor returns, what its attributes hold), which reach needs to type calls such as client.chat.completions.create. |
|
Package mcp finds the MCP servers that MCP client configs in a source tree launch or connect to, and judges each launched package with the SCANOSS vulnerabilities API.
|
Package mcp finds the MCP servers that MCP client configs in a source tree launch or connect to, and judges each launched package with the SCANOSS vulnerabilities API. |