code-kg
v0.1.17
Published
Local code knowledge graph CLI with interactive visualization and deterministic analysis APIs
Maintainers
Readme
code-kg
Local code knowledge graph CLI for TypeScript/JavaScript projects.
- Builds a local graph in SQLite
- Serves an interactive full 3D graph UI with Rust+WASM layout acceleration
- Exposes deterministic JSON APIs for graph exploration and insights
Privacy
code-kg runs locally and does not send code to external services by default.
Quick Start (npx)
npx code-kgThis will:
- Index the current directory
- Start the local server on port
4783 - Print the local UI URL
Explicit Commands
# index project
npx code-kg init --path .
# re-index project
npx code-kg reindex --path .
# serve graph UI/API
npx code-kg serve --path . --port 4783
# one command flow
npx code-kg run --path . --port 4783 --openDev Dependency Workflow
npm i -D code-kgExample package.json scripts:
{
"scripts": {
"codekg": "codekg",
"codekg:run": "codekg run --path . --port 4783",
"codekg:insights": "codekg insights --path . --format json --output .codekg/insights.json"
}
}CLI JSON Outputs
# ranked insights
npx code-kg insights --path . --limit 10 --format json
# filtered graph
npx code-kg graph \
--path . \
--view symbolGraph \
--node-types Function,Class \
--edge-types CALLS,REFERENCES \
--format json
# shortest directed path
npx code-kg path \
--path . \
--from file:src/index.ts \
--to file:src/server/app.ts \
--max-depth 12 \
--format jsonAPI Endpoints
GET /api/metaGET /api/search?q=...GET /api/node/:idGET /api/graph?view=fileDeps|moduleGraph|symbolGraph|all&nodeTypes=...&edgeTypes=...&q=...&limit=...(includes optionalmetawith query timing and recommended renderer quality mode)GET /api/subgraph?seed=<nodeId>&depth=2&direction=bothGET /api/path?from=<nodeId>&to=<nodeId>&maxDepth=12&edgeTypes=...GET /api/routesGET /api/cyclesPOST /api/queryPOST /api/llm/query(optional stub)
Development
npm install
npm run wasm:build
npm run build
npm test
npm run test:perf