@roarpeng/graphflow 1.4.4 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +25 -0
  3. package/CLAUDE.md +1 -1
  4. package/README.md +69 -47
  5. package/dist/agents/atp-schema.d.ts +59 -0
  6. package/dist/agents/atp-schema.d.ts.map +1 -0
  7. package/dist/agents/atp-schema.js +3 -0
  8. package/dist/agents/atp-schema.js.map +1 -0
  9. package/dist/agents/decision-engine.d.ts +55 -0
  10. package/dist/agents/decision-engine.d.ts.map +1 -0
  11. package/dist/agents/decision-engine.js +338 -0
  12. package/dist/agents/decision-engine.js.map +1 -0
  13. package/dist/agents/insight.d.ts +57 -1
  14. package/dist/agents/insight.d.ts.map +1 -1
  15. package/dist/agents/insight.js +365 -2
  16. package/dist/agents/insight.js.map +1 -1
  17. package/dist/config/defaults.d.ts.map +1 -1
  18. package/dist/config/defaults.js +1 -2
  19. package/dist/config/defaults.js.map +1 -1
  20. package/dist/config/discover-workspace.d.ts.map +1 -1
  21. package/dist/config/discover-workspace.js +4 -0
  22. package/dist/config/discover-workspace.js.map +1 -1
  23. package/dist/config/embedding-factory.js +6 -6
  24. package/dist/config/embedding-factory.js.map +1 -1
  25. package/dist/config/loader.d.ts.map +1 -1
  26. package/dist/config/loader.js +1 -2
  27. package/dist/config/loader.js.map +1 -1
  28. package/dist/config/schema.d.ts +1 -2
  29. package/dist/config/schema.d.ts.map +1 -1
  30. package/dist/core/agent-delegation.d.ts +3 -1
  31. package/dist/core/agent-delegation.d.ts.map +1 -1
  32. package/dist/core/agent-delegation.js +121 -0
  33. package/dist/core/agent-delegation.js.map +1 -1
  34. package/dist/core/orchestrator-context.d.ts.map +1 -1
  35. package/dist/core/orchestrator-context.js +25 -3
  36. package/dist/core/orchestrator-context.js.map +1 -1
  37. package/dist/core/types.d.ts +12 -0
  38. package/dist/core/types.d.ts.map +1 -1
  39. package/dist/graph/context-slicer-types.d.ts +0 -4
  40. package/dist/graph/context-slicer-types.d.ts.map +1 -1
  41. package/dist/graph/context-slicer-types.js.map +1 -1
  42. package/dist/graph/context-slicer.d.ts.map +1 -1
  43. package/dist/graph/context-slicer.js +5 -15
  44. package/dist/graph/context-slicer.js.map +1 -1
  45. package/dist/graph/file-indexer-walker.d.ts +3 -0
  46. package/dist/graph/file-indexer-walker.d.ts.map +1 -1
  47. package/dist/graph/file-indexer-walker.js.map +1 -1
  48. package/dist/graph/file-indexer.d.ts +1 -0
  49. package/dist/graph/file-indexer.d.ts.map +1 -1
  50. package/dist/graph/file-indexer.js +14 -18
  51. package/dist/graph/file-indexer.js.map +1 -1
  52. package/dist/learning/embeddings.d.ts +2 -3
  53. package/dist/learning/embeddings.d.ts.map +1 -1
  54. package/dist/learning/embeddings.js +18 -33
  55. package/dist/learning/embeddings.js.map +1 -1
  56. package/dist/learning/hnsw-index.d.ts +9 -35
  57. package/dist/learning/hnsw-index.d.ts.map +1 -1
  58. package/dist/learning/hnsw-index.js +8 -154
  59. package/dist/learning/hnsw-index.js.map +1 -1
  60. package/dist/surfaces/antigravity-rules/graphflow.md +5 -6
  61. package/dist/surfaces/cli/runtime/graph.d.ts.map +1 -1
  62. package/dist/surfaces/cli/runtime/graph.js +0 -1
  63. package/dist/surfaces/cli/runtime/graph.js.map +1 -1
  64. package/dist/surfaces/cli/runtime/settings.d.ts.map +1 -1
  65. package/dist/surfaces/cli/runtime/settings.js +0 -5
  66. package/dist/surfaces/cli/runtime/settings.js.map +1 -1
  67. package/dist/surfaces/cli/runtime/types.d.ts +0 -8
  68. package/dist/surfaces/cli/runtime/types.d.ts.map +1 -1
  69. package/dist/surfaces/copilot-instructions/graphflow.md +3 -4
  70. package/dist/surfaces/cursor-rules/graphflow.mdc +17 -25
  71. package/dist/surfaces/mcp/tool-definitions.d.ts.map +1 -1
  72. package/dist/surfaces/mcp/tool-definitions.js +31 -124
  73. package/dist/surfaces/mcp/tool-definitions.js.map +1 -1
  74. package/dist/surfaces/mcp/tool-handlers.d.ts.map +1 -1
  75. package/dist/surfaces/mcp/tool-handlers.js +78 -42
  76. package/dist/surfaces/mcp/tool-handlers.js.map +1 -1
  77. package/dist/surfaces/trae-rules/graphflow.md +6 -7
  78. package/dist/surfaces/trae-skill/graphflow/SKILL.md +66 -75
  79. package/package.json +2 -2
  80. package/src/surfaces/antigravity-rules/graphflow.md +5 -6
  81. package/src/surfaces/copilot-instructions/graphflow.md +3 -4
  82. package/src/surfaces/cursor-rules/graphflow.mdc +17 -25
  83. package/src/surfaces/trae-rules/graphflow.md +6 -7
  84. package/src/surfaces/trae-skill/graphflow/SKILL.md +66 -75
package/AGENTS.md CHANGED
@@ -34,7 +34,7 @@ During repository development you can also point Claude Code at this checkout:
34
34
  ## Usage guidance
35
35
 
36
36
  - Ask GraphFlow to plan before broad changes: `graphflow_plan`.
37
- - Ask GraphFlow to compress and anchor code context: `graphflow_preview_context`.
37
+ - Ask GraphFlow to compress and anchor code context: `graphflow_context`.
38
38
  - Ask GraphFlow to inspect graph state or skill learnings when the repo history matters.
39
39
  - After executing work from a `graphflow_run` `executionDescriptor`, **must** call `graphflow_report_outcome` with the `episodeId` from the run result, a `success` boolean, and optional `lessons` to close the skill flywheel loop.
40
40
  - Fall back to `graphflow ... --json` only if MCP is not available (including `graphflow --json outcome report <episodeId> <success>`).
package/CHANGELOG.md CHANGED
@@ -4,6 +4,31 @@ All notable changes to this project are documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [1.7.0] - 2026-07-11
8
+
9
+ ### Added
10
+
11
+ - **P0 向量召回修正**:引入 `@xenova/transformers` + `all-MiniLM-L6-v2`(384 维,约 22MB),实现真正的本地语义 embedding 召回
12
+ - **P2 ATP 自适应截断**:简单任务(低优先级、无约束、短描述)自动 short-circuit,跳过 First Principles / Decision Matrix / Reflection,节省 4-6 次 LLM 调用
13
+ - **P2 MCP 工具精简**:18 个工具合并为 10 个核心工具,降低 LLM 工具调用认知负荷
14
+
15
+ ### Changed
16
+
17
+ - **embedding provider 默认改为 `transformers`**:替代原有的 FNV-1a hash embedding(伪语义)
18
+ - **MCP 工具合并**:
19
+ - `graphflow_context` = `preview_context` + `expand_anchor`
20
+ - `graphflow_plan` = `plan` + `plan_insight`(mode 参数区分)
21
+ - `graphflow_index` = `index` + `index_file` + `rebuild`
22
+ - `graphflow_insight` = `submit_insight` + `merge_insight`
23
+ - `graphflow_diagnose` = `diagnose` + `inspect_graph` + `stats`
24
+ - `graphflow_artifact` = `export_artifact` + `import_artifact`
25
+
26
+ ### Removed
27
+
28
+ - **P1 移除 `hnswlib-node`**:彻底移除 C++ 编译依赖,向量召回统一使用纯线性扫描
29
+ - 移除 `graphPolicy.enableHnsw` 配置项及相关代码
30
+ - 移除 `hash` embedding provider 及相关函数
31
+
7
32
  ## [1.4.4] - 2026-07-05
8
33
 
9
34
  ### Added
package/CLAUDE.md CHANGED
@@ -34,7 +34,7 @@ During repository development you can also point Claude Code at this checkout:
34
34
  ## Usage guidance
35
35
 
36
36
  - Ask GraphFlow to plan before broad changes: `graphflow_plan`.
37
- - Ask GraphFlow to compress and anchor code context: `graphflow_preview_context`.
37
+ - Ask GraphFlow to compress and anchor code context: `graphflow_context`.
38
38
  - Ask GraphFlow to inspect graph state or skill learnings when the repo history matters.
39
39
  - After executing work from a `graphflow_run` `executionDescriptor`, **must** call `graphflow_report_outcome` with the `episodeId` from the run result, a `success` boolean, and optional `lessons` to close the skill flywheel loop.
40
40
  - Fall back to `graphflow ... --json` only if MCP is not available (including `graphflow --json outcome report <episodeId> <success>`).
package/README.md CHANGED
@@ -31,7 +31,7 @@ npx @roarpeng/graphflow context preview "orchestrator" --json
31
31
  }
32
32
  ```
33
33
 
34
- 接好后让 agent 优先调用 `graphflow_preview_context` 取压缩上下文;多步任务用 `graphflow_plan`。配置 provider API key 是**可选**的——只在需要 LLM 规划增强时才用。
34
+ 接好后让 agent 优先调用 `graphflow_context` 取压缩上下文;多步任务用 `graphflow_plan`。配置 provider API key 是**可选**的——只在需要 LLM 规划增强时才用。
35
35
 
36
36
  ## 为什么选 GraphFlow(与同类对比)
37
37
 
@@ -48,27 +48,62 @@ npx @roarpeng/graphflow context preview "orchestrator" --json
48
48
 
49
49
  > 实话实说:论纯图谱的成熟度与社区规模,CodeGraph 更领先;论 LSP 符号编辑标准,Serena 更专精;论整库打包,Repomix 更简单。GraphFlow 的价值在于把"图谱 + 压缩 + 规划 + 学习记忆"合到一处,让 agent 不仅省 token,还能跨会话复用项目经验。
50
50
 
51
- ## 当前能力总览(v1.4.0+)
51
+ ## 当前能力总览(v1.7.0+)
52
52
 
53
53
  | 能力域 | 说明 |
54
54
  | --- | --- |
55
- | **任务规划与移交** | 按任务复杂度分流 simple / complex / insight;DAG 规划;`graphflow_plan_insight` 六顶思考帽 + 5-Why 深度分析;默认 **bridge 模式**输出结构化任务描述符交给外部 coding agent 执行 |
55
+ | **任务规划与移交** | 按任务复杂度分流 simple / complex / insight;DAG 规划;**ATP v1.0 Agent Thinking Protocol**:Intent → Requirement → Six Hats → 5-Why First Principles → Decision Matrix → Planning → Reflection(`planInsight(task, opts, true)` 开启完整 8 阶段分析,简单任务自动 short-circuit);Agent 委托模式生成 work items;默认 **bridge 模式**输出结构化任务描述符交给外部 coding agent 执行 |
56
+
56
57
  | **模型路由** | Smart / Economy 双 tier;多 provider 健康探测与 fallback(OpenAI、Anthropic、百炼、豆包) |
57
58
  | **知识图谱** | 工作区 AST 索引(TS/JS/Python/Rust/Go/C/C++/Java/Ruby/Kotlin/Swift);File / Module / Symbol 节点 + 依赖/引用/定义/调用/继承边;图谱 artifact 导入/导出 |
58
- | **上下文压缩** | L1/L2/L3 分层锚点;近无损打包;图结构压缩(边权重+PageRank,零成本默认开启);向量召回 + RRF + HNSW ANN;RepoMap 概览;自适应预算 |
59
- | **持续建图** | 默认 `autoIndexOnSave`;MCP 启动时自动启动 FileWatcher;preview / run 前按需增量索引;MCP `graphflow_index_file` 单文件增量 |
59
+ | **上下文压缩** | L1/L2/L3 分层锚点;近无损打包;图结构压缩(边权重+PageRank,零成本默认开启);向量召回 + RRF 融合;RepoMap 概览;自适应预算 |
60
+ | **持续建图** | 默认 `autoIndexOnSave`;MCP 启动时自动启动 FileWatcher;preview / run 前按需增量索引;MCP `graphflow_index` 单文件增量 |
60
61
  | **学习飞轮** | Episodic Memory(Jaccard + embedding RRF 语义检索)、Reflection(聚类 + Lesson 提取)、Skill 节点(score ±1,bounded [-20,20])、nightly 学习、技能提示注入规划 |
61
- | **可观测性** | `graphflow_stats` 累计 token 节省;VS Code 知识图谱 Snapshot |
62
- | **Agent 接入** | CLI `--json`;MCP stdio(**18 工具**);自动安装 MCP 到 15+ Agent(Cursor / Claude Code / Windsurf / Cline / Codex / Gemini 等) |
62
+ | **可观测性** | `graphflow_diagnose` 累计 token 节省;VS Code 知识图谱 Snapshot |
63
+ | **Agent 接入** | CLI `--json`;MCP stdio(**10 工具**);自动安装 MCP 到 15+ Agent(Cursor / Claude Code / Windsurf / Cline / Codex / Gemini 等) |
63
64
  | **VS Code 扩展** | Settings、建图、路由测试、Context Preview、**知识图谱可视化**、Skill Insights、Chat Agent、一键安装 MCP |
64
65
  | **存储后端** | `file`(JSON)/ `memory` / `sqlite`(FTS5)/ `mcp-http`(Graphify) |
65
66
  | **多项目隔离** | 全局配置共享 LLM/路由;**图谱路径按当前工作区解析**,不再串读其它项目的 `graphflow-out` |
66
- | **工程质量** | TypeScript strict;**56 测试文件 / 249+ tests**;`npm run ci` 含扩展 esbuild 打包与 bundled runtime smoke |
67
+ | **工程质量** | TypeScript strict;**59 测试文件 / 280+ tests**;`npm run ci` 含扩展 esbuild 打包与 bundled runtime smoke |
67
68
 
68
69
  ### 一句话总结
69
70
 
70
71
  > 从 task 描述出发,自动规划 → 路由模型 → 压缩图谱上下文(含向量召回)→ **输出结构化执行描述符交给外部 coding agent**,并把经验沉淀回知识图谱;定位为 **上下文与规划服务(context service)**,而非独立执行器。
71
72
 
73
+ ### v1.7.0 核心(2026-07)
74
+
75
+ **P0 向量召回修正**:废弃 FNV-1a hash embedding,引入 `@xenova/transformers` + `all-MiniLM-L6-v2`(384 维,约 22MB,纯 JS 推理),实现真正的本地语义召回。
76
+
77
+ **P1 移除 hnswlib-node**:彻底移除 C++ 编译依赖,向量召回统一使用纯线性扫描(典型仓库 <10K 节点性能完全够用)。
78
+
79
+ **P2 MCP 工具精简**:18 个工具合并为 10 个核心工具(context、plan、index、insight、diagnose、artifact 等合并),降低 LLM 工具调用认知负荷。
80
+
81
+ **P2 ATP 自适应截断**:简单任务(低优先级、无约束、短描述)自动 short-circuit,跳过 First Principles / Decision Matrix / Reflection,节省 4-6 次 LLM 调用。
82
+
83
+ ---
84
+
85
+ ### v1.5.0 核心(2026-07)
86
+
87
+ **ATP v1.0 Agent Thinking Protocol**:以文档驱动的全链路思考协议增强深度分析流程。
88
+
89
+ **新增 5 个分析阶段**(在 Six Hats + 5-Why 基础上补齐):
90
+
91
+ 1. **Intent Analysis** — 区分显式/隐式意图、核心问题、非目标、成功标准
92
+ 2. **Requirement Analysis** — 结构化功能/非功能需求、优先级、范围(included/excluded)
93
+ 3. **First Principles** — 拆解到不可再分事实、挑战假设
94
+ 4. **Decision Matrix** — 多方案按 5 维度打分(complexity/cost/risk/maintainability/impact)比较后推荐
95
+ 5. **Plan Reflection** — 规划阶段自评置信度、不确定性、缺失信息、改进方向
96
+
97
+ **ATP 类型 IR**:`atp-schema.ts` 导出 `AgentThinkingProtocol` 完整接口,作为 Multi-Agent 共享中间表示。
98
+
99
+ **TaskNode 丰富**:新增 `priority`、`complexity`、`verification`、`inputs`、`outputs`、`risks` 6 个可选字段。
100
+
101
+ **Agent 委托扩展**:work items 扩展(+intent +requirement +first-principles +decision-matrix +reflection),submit/merge 闭环不变。
102
+
103
+ **向后兼容**:`planInsight(task, options)` 不传第三参数时行为不变;`runFullAtp=true` 启用完整 ATP 8 阶段。
104
+
105
+ **P0 残留清理**:移除 VS Code 扩展中对已删除 runtime 方法的调用(`enrichGraph`/`downloadModel`/`showSetupGuide` 命令 + `/enrich` 聊天命令);清理 87 处 OpenBMB/enrichment 残留代码;移除 `canaryAllowed`/`canaryReason` 和 5 个 enrichment 类型字段。
106
+
72
107
  ### v1.4.0 核心(2026-07)
73
108
 
74
109
  **奥卡姆剃刀精简**:移除 OpenBMB 本地部署、语义压缩模型、语义增强器、技能进化、金丝雀门控、本地嵌入模型、向量存储等未产生真实价值的模块。留下的是三条经过验证的闭环链路。
@@ -76,10 +111,9 @@ npx @roarpeng/graphflow context preview "orchestrator" --json
76
111
  **三大核心功能验证修复**:
77
112
 
78
113
  1. **HNSW 向量召回完全打通**(P0 修复)
79
- - `file-indexer` 现在为所有 File/Symbol/Module 节点附加 hash embedding(零成本 FNV-1a,256 维)
114
+ - `file-indexer` 现在为所有 File/Symbol/Module 节点附加真正的语义 embedding(`@xenova/transformers` + `all-MiniLM-L6-v2`,384 维)
80
115
  - `orchestrator-context` 现在传递 `embeddingProvider` + `enableVectorRecall` 到压缩管道
81
- - HNSW 索引持久化路径接通(`vectorStorePath` → `.hnsw` 文件)
82
- - 大仓库(≥200 节点)自动使用 HNSW ANN(10-100x 提速),小仓库线性扫描
116
+ - 向量召回统一使用纯线性扫描,无需 C++ 编译依赖
83
117
 
84
118
  2. **FileWatcher 接入 MCP 启动**(P0 修复)
85
119
  - `startFileWatcherIfEnabled` 此前是死代码,现已接入 MCP 服务器启动路径
@@ -97,7 +131,7 @@ npx @roarpeng/graphflow context preview "orchestrator" --json
97
131
 
98
132
  ### 发布信息
99
133
 
100
- - 最新版本:**v1.4.4**(root + vscode-extension);npm:`@roarpeng/graphflow@1.4.4`
134
+ - 最新版本:**v1.7.0**(root + vscode-extension);npm:`@roarpeng/graphflow@1.7.0`
101
135
  - **GitHub Release**:push 到 `main` 后 CI 在 `windows-2022` 上自动构建 VSIX 并发布到 [GitHub Releases](https://github.com/Roarpeng/GraphFlow/releases)
102
136
  - **npm 发布**:push tag `v*`(如 `v1.4.1`)触发 [Publish npm](https://github.com/Roarpeng/GraphFlow/actions/workflows/publish-npm.yml) 工作流
103
137
  - 变更日志:`CHANGELOG.md`
@@ -107,9 +141,7 @@ npx @roarpeng/graphflow context preview "orchestrator" --json
107
141
  1. Node.js >= 20
108
142
  2. npm >= 10
109
143
  3. Windows / macOS / Linux 均可
110
- 4. **npm 安装 `@roarpeng/graphflow` 时**:`hnswlib-node` 为**强制依赖**(HNSW 向量召回),首次安装会编译原生模块
111
- - **Linux / macOS**:通常自带 C++ 工具链即可
112
- - **Windows**:需安装 [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) 并勾选 **「使用 C++ 的桌面开发」**;或使用 WSL / Linux 环境安装
144
+ 4. **npm 安装 `@roarpeng/graphflow` 时**:纯 JS/TS 依赖,无原生模块编译
113
145
 
114
146
  ## 5 分钟本地试跑
115
147
 
@@ -118,7 +150,7 @@ npm install
118
150
  npm run ci
119
151
  ```
120
152
 
121
- 预期:`lint` 无错误、`build` 成功、**249+ tests** 通过、扩展 bundle 与 runtime smoke 通过。
153
+ 预期:`lint` 无错误、`build` 成功、**280+ tests** 通过、扩展 bundle 与 runtime smoke 通过。
122
154
 
123
155
  ## Agent 工具接入
124
156
 
@@ -133,27 +165,19 @@ GraphFlow 支持两种对外接入方式:
133
165
  npm run start:mcp
134
166
  ```
135
167
 
136
- ### MCP 工具一览(18 个)
168
+ ### MCP 工具一览(10 个)
137
169
 
138
170
  | 工具 | 用途 |
139
171
  | --- | --- |
140
- | `graphflow_preview_context` | 压缩任务相关上下文(**优先调用**) |
141
- | `graphflow_plan` | 多步任务分解与 DAG 规划 |
142
- | `graphflow_plan_insight` | 六顶思考帽 + 5-Why 深度分析后规划(复杂任务) |
172
+ | `graphflow_context` | 预览压缩上下文(query)或扩展锚点(anchorId)(**优先调用**) |
173
+ | `graphflow_plan` | 多步任务分解与 DAG 规划(mode='simple' 或 'insight') |
143
174
  | `graphflow_run` | 规划 + 压缩上下文,输出 bridge 执行描述符 |
144
175
  | `graphflow_report_outcome` | 向 GraphFlow 汇报任务执行结果,用于学习飞轮 |
145
- | `graphflow_submit_insight` | 回传 `agentWorkItems` 中每条 prompt 的外部 agent 分析结果 |
146
- | `graphflow_merge_insight` | 合并已提交的 agent 分析为完整 Six Hats insight + DAG plan |
147
- | `graphflow_expand_anchor` | 扩展指定锚点的上下文详情 |
148
- | `graphflow_index` | 全工作区增量建图 |
149
- | `graphflow_index_file` | 单文件增量建图(适合 onSave / watcher) |
150
- | `graphflow_rebuild` | 清空缓存后全量重建 |
151
- | `graphflow_inspect_graph` | 图谱快照统计与样本节点 |
176
+ | `graphflow_insight` | 提交或合并 agent 分析结果(Six Hats / plan prompts) |
177
+ | `graphflow_index` | 全工作区增量建图、单文件建图或全量重建 |
152
178
  | `graphflow_skill_insights` | 技能学习洞察 |
153
- | `graphflow_diagnose` | 路由与模型健康诊断 |
154
- | `graphflow_export_artifact` | 导出压缩图谱 artifact |
155
- | `graphflow_import_artifact` | 导入图谱 artifact |
156
- | `graphflow_stats` | 累计 token 节省 ROI 统计 |
179
+ | `graphflow_diagnose` | 路由健康、图谱统计与 token 节省 |
180
+ | `graphflow_artifact` | 导出或导入压缩图谱 artifact |
157
181
  | `graphflow_skill_guide` | 获取 GraphFlow Skill 使用指南 |
158
182
 
159
183
  **MCP 建图提示**:用户级 MCP 进程的 `cwd` 不一定是当前项目。请任选其一:
@@ -215,16 +239,15 @@ GraphFlow 的压缩采用「两层渐进」策略,先用零成本图结构压
215
239
  | 层 | 机制 | 成本 | 默认 |
216
240
  | --- | --- | --- | --- |
217
241
  | 图结构压缩 | 边权重连通子图 + PageRank 中心性重排 | 零 LLM | **开启** |
218
- | 向量召回 | hash embedding + RRF 融合;候选 ≥200 自动用 HNSW ANN | LLM | **开启** |
242
+ | 向量召回 | transformers.js embedding + 线性扫描 + RRF 融合 | 本地模型 | **开启** |
219
243
  | RepoMap 概览 | 预算紧张时返回模块级地图 | 零 LLM | opt-in |
220
244
  | 自适应预算 | 按任务复杂度动态调整 token 预算 | 零 LLM | opt-in |
221
245
 
222
246
  **向量召回设计**:
223
247
 
224
- - 索引时:`file-indexer` 为每个节点生成 256 hash embedding(FNV-1a,零成本,无模型推理)
248
+ - 索引时:`file-indexer` 为每个节点生成 384 维语义 embedding(`@xenova/transformers` + `all-MiniLM-L6-v2`,约 22MB,纯 JS 推理)
225
249
  - 查询时:对 query 生成同样维度的 embedding,与图中节点做 cosine similarity
226
- - 大仓库(≥200 候选节点)自动启用 HNSW ANN(hnswlib-node),10-100x 提速
227
- - 小仓库使用线性扫描,避免 HNSW 构建开销
250
+ - 统一使用线性扫描(典型仓库 <10K 节点性能完全够用,无需 HNSW ANN
228
251
  - 关键词检索 + 向量召回结果通过 RRF(Reciprocal Rank Fusion, k=60)融合
229
252
 
230
253
  配置示例:
@@ -232,7 +255,6 @@ GraphFlow 的压缩采用「两层渐进」策略,先用零成本图结构压
232
255
  ```json
233
256
  {
234
257
  "graphPolicy": {
235
- "enableHnsw": true,
236
258
  "compression": {
237
259
  "enableGraphCompression": true,
238
260
  "enableAdaptiveBudget": true
@@ -240,7 +262,7 @@ GraphFlow 的压缩采用「两层渐进」策略,先用零成本图结构压
240
262
  },
241
263
  "embeddingPolicy": {
242
264
  "enabled": true,
243
- "provider": "hash",
265
+ "provider": "transformers",
244
266
  "topK": 8,
245
267
  "minSimilarity": 0.05
246
268
  }
@@ -324,8 +346,8 @@ Trae 区分 **Rules**(每轮自动加载)与 **Skill**(按需匹配)。
324
346
 
325
347
  | 路径 | 作用 |
326
348
  |------|------|
327
- | `.trae/rules/graphflow.md` | `alwaysApply: true` — 每轮强制先调 `graphflow_preview_context` |
328
- | `.trae/skills/graphflow/SKILL.md` | 详细 18 工具工作流;可用 `#graphflow` 手动触发 |
349
+ | `.trae/rules/graphflow.md` | `alwaysApply: true` — 每轮强制先调 `graphflow_context` |
350
+ | `.trae/skills/graphflow/SKILL.md` | 详细 10 工具工作流;可用 `#graphflow` 手动触发 |
329
351
  | `~/.config/Trae CN/User/skills/graphflow/SKILL.md` | 用户级 Skill(跨项目) |
330
352
  | `User/mcp.json` | GraphFlow MCP 服务器 |
331
353
 
@@ -335,7 +357,7 @@ npx @roarpeng/graphflow install
335
357
  npx @roarpeng/graphflow doctor # 检查 Trae CN rules/skill/MCP 是否就绪
336
358
  ```
337
359
 
338
- **注意**:MCP 配置中不要硬编码 `GRAPHFLOW_WORKSPACE_ROOT` 到其他项目;在 Trae 打开哪个仓库,就让 Agent 在 `graphflow_preview_context` 里传该仓库的 `rootDir`。
360
+ **注意**:MCP 配置中不要硬编码 `GRAPHFLOW_WORKSPACE_ROOT` 到其他项目;在 Trae 打开哪个仓库,就让 Agent 在 `graphflow_context` 里传该仓库的 `rootDir`。
339
361
 
340
362
  ### Antigravity IDE 推荐配置
341
363
 
@@ -402,11 +424,11 @@ cp graphflow.config.example.json graphflow.config.json
402
424
  | `graphPolicy.autoIndexOnSave` | 保存后增量索引(默认 **true**) |
403
425
  | `graphPolicy.autoIndexOnPreview` / `autoIndexOnRun` | preview / run 前自动索引 |
404
426
  | `graphPolicy.enableNearLosslessMode` | 近无损上下文打包 |
405
- | `graphPolicy.enableHnsw` | HNSW ANN 加速(默认 **true**) |
427
+
406
428
  | `graphPolicy.layerQuota` | L1/L2/L3 锚点配额 |
407
429
  | `routingPolicy.enableDynamicRouting` | provider 健康路由 |
408
430
  | `skillPolicy.enableSkillFlywheel` | 技能飞轮 |
409
- | `embeddingPolicy.provider` | embedding 提供者(`hash` 零成本 / `openai`) |
431
+ | `embeddingPolicy.provider` | embedding 提供者(`transformers` 本地 / `openai`) |
410
432
 
411
433
  ## VS Code / Cursor 扩展
412
434
 
@@ -423,9 +445,9 @@ cp graphflow.config.example.json graphflow.config.json
423
445
  CLI 安装(若已安装 `code` / `cursor` 命令):
424
446
 
425
447
  ```bash
426
- code --install-extension graphflow-vscode-1.4.4.vsix
448
+ code --install-extension graphflow-vscode-1.7.0.vsix
427
449
  # 或
428
- cursor --install-extension graphflow-vscode-1.4.4.vsix
450
+ cursor --install-extension graphflow-vscode-1.7.0.vsix
429
451
  ```
430
452
 
431
453
  ### 命令面板
@@ -505,7 +527,7 @@ npm run package:extension
505
527
 
506
528
  **无 LLM 时能用吗**
507
529
 
508
- - 可以:结构索引、图谱可视化、context preview(基于结构图谱 + hash embedding 向量召回)、MCP `graphflow_inspect_graph` 均不强制 LLM
530
+ - 可以:结构索引、图谱可视化、context preview(基于结构图谱 + transformers.js 语义向量召回)、MCP `graphflow_diagnose` 均不强制 LLM
509
531
  - 只有 Six Hats 深度规划和 LLM 语义压缩需要配置 provider
510
532
 
511
533
  ## 项目结构
@@ -519,8 +541,8 @@ GraphFlow/
519
541
  │ ├── learning/ # embeddings, episode, skill-flywheel, reflector, hnsw
520
542
  │ └── surfaces/
521
543
  │ ├── cli/ # CLI + runtime 子模块
522
- │ └── mcp/ # MCP server (18 tools)
523
- ├── tests/ # 56 文件 / 249+ tests
544
+ │ └── mcp/ # MCP server (10 tools)
545
+ ├── tests/ # 59 文件 / 280+ tests
524
546
  ├── vscode-extension/ # VS Code 面板与命令
525
547
  ├── docs/
526
548
  └── CHANGELOG.md
@@ -0,0 +1,59 @@
1
+ export interface IntentAnalysis {
2
+ explicitIntent: string;
3
+ implicitIntent: string;
4
+ coreProblem: string;
5
+ nonGoals: string[];
6
+ successDefinition: string;
7
+ complexity?: "simple" | "moderate" | "complex";
8
+ }
9
+ export interface RequirementAnalysis {
10
+ functional: string[];
11
+ nonFunctional: string[];
12
+ constraints: string[];
13
+ priority: "Low" | "Medium" | "High" | "Critical";
14
+ scope: {
15
+ included: string[];
16
+ excluded: string[];
17
+ };
18
+ }
19
+ export interface FirstPrinciplesAnalysis {
20
+ assumptions: string[];
21
+ facts: string[];
22
+ deconstructedTo: string[];
23
+ challenges: string[];
24
+ }
25
+ export interface DecisionMatrixOption {
26
+ name: string;
27
+ description: string;
28
+ scores: {
29
+ complexity: number;
30
+ cost: number;
31
+ risk: number;
32
+ maintainability: number;
33
+ impact: number;
34
+ };
35
+ pros: string[];
36
+ cons: string[];
37
+ }
38
+ export interface DecisionMatrixResult {
39
+ options: DecisionMatrixOption[];
40
+ recommendedOption: string;
41
+ rationale: string;
42
+ }
43
+ export interface PlanReflection {
44
+ confidence: number;
45
+ uncertainties: string[];
46
+ missingInformation: string[];
47
+ improvementDirections: string[];
48
+ }
49
+ export interface AgentThinkingProtocol {
50
+ task: string;
51
+ intent: IntentAnalysis;
52
+ requirements: RequirementAnalysis;
53
+ sixHatsInsight: import("./insight").SixHatsInsight;
54
+ firstPrinciples: FirstPrinciplesAnalysis;
55
+ decisionMatrix: DecisionMatrixResult;
56
+ plan: import("../core/types").TaskNode[];
57
+ reflection: PlanReflection;
58
+ }
59
+ //# sourceMappingURL=atp-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atp-schema.d.ts","sourceRoot":"","sources":["../../src/agents/atp-schema.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;CAChD;AAGD,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACjD,KAAK,EAAE;QACL,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH;AAGD,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAGD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE;QACN,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,MAAM,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,qBAAqB,EAAE,MAAM,EAAE,CAAC;CACjC;AAGD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,cAAc,CAAC;IACvB,YAAY,EAAE,mBAAmB,CAAC;IAClC,cAAc,EAAE,OAAO,WAAW,EAAE,cAAc,CAAC;IACnD,eAAe,EAAE,uBAAuB,CAAC;IACzC,cAAc,EAAE,oBAAoB,CAAC;IACrC,IAAI,EAAE,OAAO,eAAe,EAAE,QAAQ,EAAE,CAAC;IACzC,UAAU,EAAE,cAAc,CAAC;CAC5B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=atp-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atp-schema.js","sourceRoot":"","sources":["../../src/agents/atp-schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Decision Engine — First Principles Analysis + Decision Matrix.
3
+ *
4
+ * These two modules form the core of ATP v1.0's analytical depth:
5
+ * - First Principles: strip away assumptions, decompose to fundamental
6
+ * truths, and challenge every belief about the problem.
7
+ * - Decision Matrix: generate viable options, score them across
8
+ * multiple dimensions, and recommend the best path forward.
9
+ *
10
+ * Each module has an LLM-powered version (calls executeRolePrompt) and
11
+ * a heuristic fallback (rule-based, no LLM dependency). The LLM version
12
+ * always falls back to the heuristic when the call fails or the JSON
13
+ * response is unparseable.
14
+ */
15
+ import type { SixHatsInsight, PlanInsightOptions } from "./insight";
16
+ import type { FirstPrinciplesAnalysis, DecisionMatrixResult } from "./atp-schema";
17
+ /** === First Principles Analysis === */
18
+ /**
19
+ * Apply first principles thinking to the task using LLM.
20
+ *
21
+ * Asks the LLM to:
22
+ * 1. List current assumptions (assumptions)
23
+ * 2. Decompose to irreducible facts (facts)
24
+ * 3. Identify fundamental elements (deconstructedTo)
25
+ * 4. Challenge each assumption (challenges)
26
+ *
27
+ * Falls back to heuristic on LLM failure or unparseable response.
28
+ */
29
+ export declare function applyFirstPrinciples(task: string, insight: SixHatsInsight, options: PlanInsightOptions): Promise<FirstPrinciplesAnalysis>;
30
+ /**
31
+ * Heuristic first principles analysis — no LLM calls.
32
+ * Derives assumptions, facts, decomposition, and challenges from
33
+ * the Six Hats insight using rule-based logic.
34
+ */
35
+ export declare function applyFirstPrinciplesHeuristic(task: string, insight: SixHatsInsight): FirstPrinciplesAnalysis;
36
+ /** === Decision Matrix Evaluation === */
37
+ /**
38
+ * Evaluate solution options using a decision matrix with LLM.
39
+ *
40
+ * Asks the LLM to:
41
+ * 1. Generate 2-3 viable options based on first principles analysis
42
+ * 2. Score each option on complexity, cost, risk, maintainability, impact (1-10)
43
+ * 3. List pros and cons for each option
44
+ * 4. Recommend one option with rationale
45
+ *
46
+ * Falls back to heuristic on LLM failure or unparseable response.
47
+ */
48
+ export declare function evaluateOptions(task: string, insight: SixHatsInsight, firstPrinciples: FirstPrinciplesAnalysis, options: PlanInsightOptions): Promise<DecisionMatrixResult>;
49
+ /**
50
+ * Heuristic decision matrix evaluation — no LLM calls.
51
+ * Generates two standard options (Incremental vs Comprehensive)
52
+ * and recommends based on risk count.
53
+ */
54
+ export declare function evaluateOptionsHeuristic(_task: string, insight: SixHatsInsight): DecisionMatrixResult;
55
+ //# sourceMappingURL=decision-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-engine.d.ts","sourceRoot":"","sources":["../../src/agents/decision-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EAErB,MAAM,cAAc,CAAC;AAItB,wCAAwC;AAExC;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,uBAAuB,CAAC,CA4ClC;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,GACtB,uBAAuB,CAoBzB;AAED,yCAAyC;AAEzC;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,EACvB,eAAe,EAAE,uBAAuB,EACxC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CAiE/B;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,cAAc,GACtB,oBAAoB,CAwBtB"}