@org_pigeon/analyzer
v0.1.0
Published
Static code analysis engine — builds a knowledge graph of any JS/TS project
Maintainers
Readme
@org_pigeon/analyzer
Static code analysis engine — builds a knowledge graph of any JS/TS project.
Part of the Pigeon monorepo.
Install
npm install @org_pigeon/analyzerRequires Node.js ≥ 18.
Usage
import { Analyzer } from "@org_pigeon/analyzer";
const analyzer = new Analyzer({
projectRoot: "/absolute/path/to/project",
detectRoutes: true, // default: true
detectEnvVars: true, // default: true
});
const graph = await analyzer.analyze();
console.log(graph.stats);
// {
// totalNodes: 312,
// totalEdges: 487,
// files: 42,
// byType: { file: 42, function: 180, route: 14, env_var: 8, ... }
// }API
new Analyzer(options)
| Option | Type | Default | Description |
|---|---|---|---|
| projectRoot | string | required | Absolute path to the project root |
| include | string[] | ["**/*.ts","**/*.tsx","**/*.js","**/*.jsx","**/*.mjs","**/*.cjs"] | Glob patterns to include |
| exclude | string[] | node_modules, dist, build, .next, coverage, tests, .d.ts, .min.js | Glob patterns to exclude |
| detectRoutes | boolean | true | Detect Express/Fastify/Koa routes |
| detectEnvVars | boolean | true | Detect process.env / import.meta.env usage |
analyzer.analyze(): Promise<PigeonGraph>
Returns the full knowledge graph.
PigeonGraph
interface PigeonGraph {
version: string;
projectRoot: string;
generatedAt: string;
nodes: Map<string, PigeonNode>; // all detected symbols
edges: PigeonEdge[]; // relationships between nodes
stats: GraphStats;
}Node types
file · function · class · route · env_var · module · db_table · external_api · event
Edge types
imports · defines · calls · uses_env · depends_on · routes_to · queries · emits · listens
License
MIT
