命令参考
所有命令在 context-chain 项目根目录运行。
基础设施
docker compose up -d
启动 Memgraph 和 Memgraph Lab。
| 服务 | 端口 | 地址 |
|---|---|---|
| Memgraph (bolt) | 7687 | bolt://localhost:7687 |
| Memgraph Lab | 3000 | http://localhost:3000 |
npm run db:schema
初始化 Memgraph 的索引和约束。
npm run db:reset
DANGER
清空图谱所有数据,不可恢复。
分析
npm run analyze
主要分析命令。使用 analyze_function 模块逐函数提取决策。
bash
npm run analyze -- --repo my-repo # 全量扫描
npm run analyze -- --repo my-repo --continue # 恢复中断的扫描
npm run analyze -- --function createOrder --file store/orderStore.js --repo my-repo # 单个函数
npm run analyze -- --repo my-repo --template deep-analysis # 指定模板
npm run analyze -- --list-templates # 查看可用模板模板控制:上下文深度(调用者/被调用者的跳数)、代码粒度(完整/截断/签名)、发现类型、每函数最大决策数、prompt 用词。
npm run ingest:cpg
从 Joern 生成的 JSON 导入代码结构。
bash
npm run ingest:cpg -- --file data/output.jsonnpm run ingest:sessions:v2
从 Claude Code 对话记录提取决策。详见 Session 摄入。
bash
npm run ingest:sessions:v2 # 所有新 session
npm run ingest:sessions:v2 -- --project my-project # 指定项目
npm run ingest:sessions:v2 -- --auto-approve # 跳过交互确认
npm run ingest:sessions:v2 -- --dry-run # 仅预览npm run connect
处理待比较的决策——建立关系边(CAUSED_BY、DEPENDS_ON、CONFLICTS_WITH 等)。
bash
npm run connect在 analyze 或 ingest:sessions:v2 之后运行。
npm run refine
运行夜间精炼管线。
bash
npm run refine # 所有任务
npm run refine -- --only staleness # 单项任务任务包括:过期检测、锚点精度提升、关键词归一化、决策边补全、覆盖空白检测。
MCP Server
npm run mcp
启动 MCP server。通常由 Claude Code 通过 .mcp.json 自动管理。
Dashboard
npm run dashboard
启动 Dashboard,访问 http://localhost:3001。支持中英文。