@roarpeng/graphflow 1.9.6 → 1.9.12

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 (214) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/README.md +190 -113
  3. package/dist/agents/atp-example-producer.d.ts +33 -0
  4. package/dist/agents/atp-example-producer.d.ts.map +1 -0
  5. package/dist/agents/atp-example-producer.js +154 -0
  6. package/dist/agents/atp-example-producer.js.map +1 -0
  7. package/dist/agents/planner.d.ts.map +1 -1
  8. package/dist/agents/planner.js +14 -8
  9. package/dist/agents/planner.js.map +1 -1
  10. package/dist/config/defaults.d.ts.map +1 -1
  11. package/dist/config/defaults.js +5 -3
  12. package/dist/config/defaults.js.map +1 -1
  13. package/dist/config/include-extensions.d.ts +3 -1
  14. package/dist/config/include-extensions.d.ts.map +1 -1
  15. package/dist/config/include-extensions.js +6 -3
  16. package/dist/config/include-extensions.js.map +1 -1
  17. package/dist/config/loader.js +1 -1
  18. package/dist/config/loader.js.map +1 -1
  19. package/dist/core/agent-delegation.d.ts +16 -2
  20. package/dist/core/agent-delegation.d.ts.map +1 -1
  21. package/dist/core/agent-delegation.js +48 -5
  22. package/dist/core/agent-delegation.js.map +1 -1
  23. package/dist/core/merge-agent-insight.d.ts.map +1 -1
  24. package/dist/core/merge-agent-insight.js +10 -0
  25. package/dist/core/merge-agent-insight.js.map +1 -1
  26. package/dist/core/orchestrator-episode.js +1 -1
  27. package/dist/core/orchestrator.js +52 -1
  28. package/dist/core/orchestrator.js.map +1 -1
  29. package/dist/core/submit-agent-insight.d.ts +17 -0
  30. package/dist/core/submit-agent-insight.d.ts.map +1 -1
  31. package/dist/core/submit-agent-insight.js +28 -0
  32. package/dist/core/submit-agent-insight.js.map +1 -1
  33. package/dist/core/types.d.ts +35 -2
  34. package/dist/core/types.d.ts.map +1 -1
  35. package/dist/graph/context-slicer-types.d.ts +4 -0
  36. package/dist/graph/context-slicer-types.d.ts.map +1 -1
  37. package/dist/graph/context-slicer-types.js +3 -0
  38. package/dist/graph/context-slicer-types.js.map +1 -1
  39. package/dist/graph/context-slicer.d.ts.map +1 -1
  40. package/dist/graph/context-slicer.js +154 -6
  41. package/dist/graph/context-slicer.js.map +1 -1
  42. package/dist/graph/document-convert.d.ts +33 -0
  43. package/dist/graph/document-convert.d.ts.map +1 -0
  44. package/dist/graph/document-convert.js +137 -0
  45. package/dist/graph/document-convert.js.map +1 -0
  46. package/dist/graph/document-semantic-bridge.d.ts +23 -0
  47. package/dist/graph/document-semantic-bridge.d.ts.map +1 -0
  48. package/dist/graph/document-semantic-bridge.js +61 -0
  49. package/dist/graph/document-semantic-bridge.js.map +1 -0
  50. package/dist/graph/document-semantic-ingest.d.ts +48 -0
  51. package/dist/graph/document-semantic-ingest.d.ts.map +1 -0
  52. package/dist/graph/document-semantic-ingest.js +229 -0
  53. package/dist/graph/document-semantic-ingest.js.map +1 -0
  54. package/dist/graph/episode-engineering-links.d.ts +29 -0
  55. package/dist/graph/episode-engineering-links.d.ts.map +1 -0
  56. package/dist/graph/episode-engineering-links.js +63 -0
  57. package/dist/graph/episode-engineering-links.js.map +1 -0
  58. package/dist/graph/file-indexer-edges.d.ts +15 -0
  59. package/dist/graph/file-indexer-edges.d.ts.map +1 -1
  60. package/dist/graph/file-indexer-edges.js +60 -5
  61. package/dist/graph/file-indexer-edges.js.map +1 -1
  62. package/dist/graph/file-indexer-walker.d.ts +2 -1
  63. package/dist/graph/file-indexer-walker.d.ts.map +1 -1
  64. package/dist/graph/file-indexer-walker.js +29 -16
  65. package/dist/graph/file-indexer-walker.js.map +1 -1
  66. package/dist/graph/file-indexer.d.ts +5 -0
  67. package/dist/graph/file-indexer.d.ts.map +1 -1
  68. package/dist/graph/file-indexer.js +121 -17
  69. package/dist/graph/file-indexer.js.map +1 -1
  70. package/dist/graph/graph-compression.d.ts.map +1 -1
  71. package/dist/graph/graph-compression.js +17 -2
  72. package/dist/graph/graph-compression.js.map +1 -1
  73. package/dist/graph/language-indexers/c-cpp.d.ts.map +1 -1
  74. package/dist/graph/language-indexers/c-cpp.js +19 -13
  75. package/dist/graph/language-indexers/c-cpp.js.map +1 -1
  76. package/dist/graph/language-indexers/dart.d.ts.map +1 -1
  77. package/dist/graph/language-indexers/dart.js +2 -6
  78. package/dist/graph/language-indexers/dart.js.map +1 -1
  79. package/dist/graph/language-indexers/go.d.ts.map +1 -1
  80. package/dist/graph/language-indexers/go.js +3 -6
  81. package/dist/graph/language-indexers/go.js.map +1 -1
  82. package/dist/graph/language-indexers/java.d.ts.map +1 -1
  83. package/dist/graph/language-indexers/java.js +2 -6
  84. package/dist/graph/language-indexers/java.js.map +1 -1
  85. package/dist/graph/language-indexers/kotlin.d.ts.map +1 -1
  86. package/dist/graph/language-indexers/kotlin.js +2 -6
  87. package/dist/graph/language-indexers/kotlin.js.map +1 -1
  88. package/dist/graph/language-indexers/python.d.ts.map +1 -1
  89. package/dist/graph/language-indexers/python.js +4 -6
  90. package/dist/graph/language-indexers/python.js.map +1 -1
  91. package/dist/graph/language-indexers/ruby.d.ts.map +1 -1
  92. package/dist/graph/language-indexers/ruby.js +2 -6
  93. package/dist/graph/language-indexers/ruby.js.map +1 -1
  94. package/dist/graph/language-indexers/rust.d.ts.map +1 -1
  95. package/dist/graph/language-indexers/rust.js +3 -6
  96. package/dist/graph/language-indexers/rust.js.map +1 -1
  97. package/dist/graph/language-indexers/swift.d.ts.map +1 -1
  98. package/dist/graph/language-indexers/swift.js +2 -6
  99. package/dist/graph/language-indexers/swift.js.map +1 -1
  100. package/dist/graph/language-indexers/tree-sitter-loader.d.ts +20 -0
  101. package/dist/graph/language-indexers/tree-sitter-loader.d.ts.map +1 -1
  102. package/dist/graph/language-indexers/tree-sitter-loader.js +42 -0
  103. package/dist/graph/language-indexers/tree-sitter-loader.js.map +1 -1
  104. package/dist/graph/memory-pack.d.ts +46 -0
  105. package/dist/graph/memory-pack.d.ts.map +1 -0
  106. package/dist/graph/memory-pack.js +204 -0
  107. package/dist/graph/memory-pack.js.map +1 -0
  108. package/dist/graph/snapshot-view.d.ts.map +1 -1
  109. package/dist/graph/snapshot-view.js +26 -1
  110. package/dist/graph/snapshot-view.js.map +1 -1
  111. package/dist/graph/symbol-extract.d.ts +39 -0
  112. package/dist/graph/symbol-extract.d.ts.map +1 -0
  113. package/dist/graph/symbol-extract.js +187 -0
  114. package/dist/graph/symbol-extract.js.map +1 -0
  115. package/dist/hooks/auto-capture.d.ts +3 -2
  116. package/dist/hooks/auto-capture.d.ts.map +1 -1
  117. package/dist/hooks/auto-capture.js +5 -3
  118. package/dist/hooks/auto-capture.js.map +1 -1
  119. package/dist/index.d.ts +7 -2
  120. package/dist/index.d.ts.map +1 -1
  121. package/dist/index.js +21 -2
  122. package/dist/index.js.map +1 -1
  123. package/dist/integrations/agent-mcp-installer.d.ts +87 -5
  124. package/dist/integrations/agent-mcp-installer.d.ts.map +1 -1
  125. package/dist/integrations/agent-mcp-installer.js +418 -60
  126. package/dist/integrations/agent-mcp-installer.js.map +1 -1
  127. package/dist/integrations/agent-profiles/profiles/qoder.d.ts.map +1 -1
  128. package/dist/integrations/agent-profiles/profiles/qoder.js +14 -2
  129. package/dist/integrations/agent-profiles/profiles/qoder.js.map +1 -1
  130. package/dist/integrations/agent-profiles/skills/qoder.js +6 -0
  131. package/dist/integrations/agent-profiles/skills/qoder.js.map +1 -1
  132. package/dist/integrations/claude-code-hooks.d.ts +33 -1
  133. package/dist/integrations/claude-code-hooks.d.ts.map +1 -1
  134. package/dist/integrations/claude-code-hooks.js +99 -13
  135. package/dist/integrations/claude-code-hooks.js.map +1 -1
  136. package/dist/integrations/ensure-anydoc.d.ts +41 -0
  137. package/dist/integrations/ensure-anydoc.d.ts.map +1 -0
  138. package/dist/integrations/ensure-anydoc.js +221 -0
  139. package/dist/integrations/ensure-anydoc.js.map +1 -0
  140. package/dist/integrations/skill-installer.d.ts +26 -3
  141. package/dist/integrations/skill-installer.d.ts.map +1 -1
  142. package/dist/integrations/skill-installer.js +147 -5
  143. package/dist/integrations/skill-installer.js.map +1 -1
  144. package/dist/learning/canary-gate.d.ts +39 -0
  145. package/dist/learning/canary-gate.d.ts.map +1 -0
  146. package/dist/learning/canary-gate.js +57 -0
  147. package/dist/learning/canary-gate.js.map +1 -0
  148. package/dist/learning/skill-consolidate.d.ts +84 -0
  149. package/dist/learning/skill-consolidate.d.ts.map +1 -0
  150. package/dist/learning/skill-consolidate.js +353 -0
  151. package/dist/learning/skill-consolidate.js.map +1 -0
  152. package/dist/learning/skill-flywheel.d.ts +26 -0
  153. package/dist/learning/skill-flywheel.d.ts.map +1 -1
  154. package/dist/learning/skill-flywheel.js +192 -29
  155. package/dist/learning/skill-flywheel.js.map +1 -1
  156. package/dist/learning/skill-opt-lite.d.ts +46 -0
  157. package/dist/learning/skill-opt-lite.d.ts.map +1 -0
  158. package/dist/learning/skill-opt-lite.js +270 -0
  159. package/dist/learning/skill-opt-lite.js.map +1 -0
  160. package/dist/learning/skill-package.d.ts.map +1 -1
  161. package/dist/learning/skill-package.js +80 -6
  162. package/dist/learning/skill-package.js.map +1 -1
  163. package/dist/learning/skill-store.d.ts.map +1 -1
  164. package/dist/learning/skill-store.js +13 -0
  165. package/dist/learning/skill-store.js.map +1 -1
  166. package/dist/learning/skill-types.d.ts +32 -0
  167. package/dist/learning/skill-types.d.ts.map +1 -1
  168. package/dist/learning/skill-types.js +17 -0
  169. package/dist/learning/skill-types.js.map +1 -1
  170. package/dist/skills/index.js +1 -1
  171. package/dist/skills/index.js.map +1 -1
  172. package/dist/surfaces/cli/index.js +46 -5
  173. package/dist/surfaces/cli/index.js.map +1 -1
  174. package/dist/surfaces/cli/init.d.ts +17 -4
  175. package/dist/surfaces/cli/init.d.ts.map +1 -1
  176. package/dist/surfaces/cli/init.js +71 -8
  177. package/dist/surfaces/cli/init.js.map +1 -1
  178. package/dist/surfaces/cli/output.d.ts.map +1 -1
  179. package/dist/surfaces/cli/output.js +4 -2
  180. package/dist/surfaces/cli/output.js.map +1 -1
  181. package/dist/surfaces/cli/runtime/facade.d.ts +2 -1
  182. package/dist/surfaces/cli/runtime/facade.d.ts.map +1 -1
  183. package/dist/surfaces/cli/runtime/facade.js +1 -0
  184. package/dist/surfaces/cli/runtime/facade.js.map +1 -1
  185. package/dist/surfaces/cli/runtime/graph.d.ts +53 -0
  186. package/dist/surfaces/cli/runtime/graph.d.ts.map +1 -1
  187. package/dist/surfaces/cli/runtime/graph.js +116 -5
  188. package/dist/surfaces/cli/runtime/graph.js.map +1 -1
  189. package/dist/surfaces/cli/runtime/learning.d.ts +19 -0
  190. package/dist/surfaces/cli/runtime/learning.d.ts.map +1 -1
  191. package/dist/surfaces/cli/runtime/learning.js +46 -0
  192. package/dist/surfaces/cli/runtime/learning.js.map +1 -1
  193. package/dist/surfaces/cli/runtime/routing.d.ts +6 -3
  194. package/dist/surfaces/cli/runtime/routing.d.ts.map +1 -1
  195. package/dist/surfaces/cli/runtime/routing.js +70 -7
  196. package/dist/surfaces/cli/runtime/routing.js.map +1 -1
  197. package/dist/surfaces/cli/runtime/types.d.ts +54 -0
  198. package/dist/surfaces/cli/runtime/types.d.ts.map +1 -1
  199. package/dist/surfaces/cli/runtime.d.ts +3 -3
  200. package/dist/surfaces/cli/runtime.d.ts.map +1 -1
  201. package/dist/surfaces/cli/runtime.js +6 -2
  202. package/dist/surfaces/cli/runtime.js.map +1 -1
  203. package/dist/surfaces/mcp/server.js +1 -1
  204. package/dist/surfaces/mcp/tool-definitions.d.ts.map +1 -1
  205. package/dist/surfaces/mcp/tool-definitions.js +15 -0
  206. package/dist/surfaces/mcp/tool-definitions.js.map +1 -1
  207. package/dist/surfaces/mcp/tool-handlers.d.ts.map +1 -1
  208. package/dist/surfaces/mcp/tool-handlers.js +24 -3
  209. package/dist/surfaces/mcp/tool-handlers.js.map +1 -1
  210. package/mcp.json +14 -0
  211. package/package.json +19 -1
  212. package/plugin.json +21 -0
  213. package/scripts/safe-postinstall.cjs +36 -1
  214. package/skills/graphflow/SKILL.md +565 -0
@@ -0,0 +1,565 @@
1
+ ---
2
+ name: "graphflow"
3
+ description: "Graph-based code context compression, task planning, and knowledge graph orchestration (10 MCP tools). Invoke before ANY code question, bug fix, debugging, file reading, Chinese/CJK query, refactor, or multi-step edit — ALWAYS call graphflow_context MCP first when GraphFlow is connected."
4
+ ---
5
+
6
+ # GraphFlow Skill
7
+
8
+ GraphFlow is a graph-based context and planning service backed by a persistent MCP server. It turns codebases into queryable knowledge graphs, delivering token-efficient compressed context, task planning, and orchestration.
9
+
10
+ ## Architecture
11
+
12
+ ```
13
+ ┌─────────────────────────────────────────────────┐
14
+ │ GraphFlow Skill (this file) │
15
+ │ - Quick entry points & workflows │
16
+ │ - Tool selection logic │
17
+ │ - Output interpretation guides │
18
+ └──────────────────┬──────────────────────────────┘
19
+
20
+
21
+ ┌─────────────────────────────────────────────────┐
22
+ │ GraphFlow MCP Server (persistent backend) │
23
+ │ 10 tools: context, plan, index, insight, run, │
24
+ │ report_outcome, skill_insights, diagnose, │
25
+ │ artifact, skill_guide │
26
+ └──────────────────┬──────────────────────────────┘
27
+
28
+
29
+ ┌─────────────────────────────────────────────────┐
30
+ │ GraphFlow Core Engine │
31
+ │ - Graph index & context compression │
32
+ │ - Task planning & DAG │
33
+ │ - Skill learning flywheel │
34
+ │ - Artifact import/export │
35
+ └─────────────────────────────────────────────────┘
36
+ ```
37
+
38
+ ## When to Use
39
+
40
+ **ALWAYS invoke this skill BEFORE:**
41
+ - Multi-step edits, refactors, or architecture changes
42
+ - Large codebase-wide questions or exploration
43
+ - Debugging across multiple files
44
+ - Any task where you would otherwise read many files
45
+ - Token budget is a concern
46
+ - You need structured task planning
47
+
48
+ **DO NOT:**
49
+ - Scan the whole repository recursively before trying GraphFlow
50
+ - Read large files before checking GraphFlow anchors
51
+ - Skip GraphFlow for complex tasks
52
+ - Use grep for codebase exploration before `graphflow_context`
53
+
54
+ ### Trae / Trae CN setup (Rules + Skill + MCP)
55
+
56
+ Trae loads **Rules every turn** and **Skills on demand**. GraphFlow `install` writes:
57
+
58
+ | Path | Role |
59
+ |------|------|
60
+ | `.trae/rules/graphflow.md` | `alwaysApply: true` — **must** call `graphflow_context` first |
61
+ | `.trae/skills/graphflow/SKILL.md` | Full workflows; trigger with `#graphflow` |
62
+ | `User/mcp.json` | GraphFlow MCP server |
63
+
64
+ If Rules are missing, type `#graphflow` at the start of a chat. Pass `rootDir` = current project absolute path on every context call.
65
+
66
+ ### Antigravity IDE setup (Rules + Skill + MCP)
67
+
68
+ | Path | Role |
69
+ |------|------|
70
+ | `~/.gemini/antigravity/mcp_config.json` | Global MCP (`mcpServers.graphflow`) |
71
+ | `~/.gemini/antigravity/skills/graphflow/SKILL.md` | Global Skill |
72
+ | `.agent/rules/graphflow.md` | Project rules (always loaded in workspace) |
73
+ | `.agent/skills/graphflow/SKILL.md` | Project Skill |
74
+ | `GEMINI.md` (project root) | Managed token-first block |
75
+
76
+ Run `npx @roarpeng/graphflow install` from the project root. Do **not** hardcode `GRAPHFLOW_WORKSPACE_ROOT` in MCP env.
77
+
78
+ ### Gemini CLI setup
79
+
80
+ | Path | Role |
81
+ |------|------|
82
+ | `~/.gemini/settings.json` | MCP (`mcpServers.graphflow`) |
83
+ | `~/.gemini/GEMINI.md` | Global managed instruction block |
84
+ | `GEMINI.md` (project root) | Project managed block (with `install --scope all`) |
85
+
86
+ ### GitHub Copilot (VS Code) setup
87
+
88
+ | Path | Role |
89
+ |------|------|
90
+ | `~/.config/Code/User/mcp.json` | User MCP (`servers.graphflow`) |
91
+ | `.vscode/mcp.json` | Project MCP (optional, team-shared) |
92
+ | `.github/copilot-instructions.md` | Repo-level Copilot instructions |
93
+
94
+ ---
95
+
96
+ ## Tool Inventory (10 MCP Tools)
97
+
98
+ ### Core Context Tools (Highest Frequency)
99
+
100
+ | Tool | Purpose | Call Frequency |
101
+ |------|---------|---------------|
102
+ | `graphflow_context` | Preview compressed context (query) or expand anchor (anchorId) | **Highest** - default first step |
103
+
104
+ ### Planning Tools (High Frequency)
105
+
106
+ | Tool | Purpose | Call Frequency |
107
+ |------|---------|---------------|
108
+ | `graphflow_plan` | Multi-step task decomposition & DAG (mode='simple' or 'insight') | High - before complex work |
109
+ | `graphflow_run` | Plan + context package (bridge mode) | Medium - full task packaging |
110
+ | `graphflow_report_outcome` | Report bridge-mode execution outcome back | Medium - close the learning loop |
111
+ | `graphflow_insight` | Submit or merge agent insights | Medium - no external LLM API |
112
+
113
+ ### Graph Management Tools (Medium Frequency)
114
+
115
+ | Tool | Purpose | Call Frequency |
116
+ |------|---------|---------------|
117
+ | `graphflow_index` | Incremental workspace re-index, single-file, or full rebuild | Medium - after file changes |
118
+
119
+ ### Collaboration & Insights Tools (Low Frequency)
120
+
121
+ | Tool | Purpose | Call Frequency |
122
+ |------|---------|---------------|
123
+ | `graphflow_artifact` | Export or import graph artifact | Low - team sharing |
124
+ | `graphflow_skill_insights` | Learned skill patterns | Low - leverage prior learning |
125
+ | `graphflow_skill_guide` | Skill usage guide for connected agents | Low - onboarding |
126
+ | `graphflow_diagnose` | Provider health, graph stats, and token savings | Low - ROI tracking / config issues |
127
+
128
+ ---
129
+
130
+ ## Standard Workflows
131
+
132
+ ### Workflow 1: Context First (90% of tasks)
133
+
134
+ **Use when:** Answering code questions, exploring codebase, understanding modules
135
+
136
+ ```
137
+ Step 1: graphflow_context(query: "<your question>")
138
+ Step 2: Read summary + anchors as primary context
139
+ Step 3: Expand specific anchors with graphflow_context(anchorId: "...") when needed
140
+ Step 4: Read full files only when exact edits required
141
+ ```
142
+
143
+ **Input - context (preview):**
144
+ ```typescript
145
+ {
146
+ query: string; // Required for preview - user question (Chinese OK)
147
+ englishQuery?: string; // Agent-translated English code search terms (recommended for CJK)
148
+ configPath?: string;
149
+ rootDir?: string;
150
+ }
151
+ ```
152
+
153
+ **Input - context (expand):**
154
+ ```typescript
155
+ {
156
+ anchorId: string; // Required for expand - anchor id from preview
157
+ configPath?: string;
158
+ rootDir?: string;
159
+ }
160
+ ```
161
+
162
+ **Output structure (preview):**
163
+ ```typescript
164
+ {
165
+ summary: string[];
166
+ anchors: Array<{ id: string; type: string; layer: "L1" | "L2" | "L3" }>;
167
+ tokenBudget: {
168
+ maxContextTokens: number;
169
+ estimatedRawTokens: number;
170
+ compressedTokens: number;
171
+ estimatedSavingsPercent: number;
172
+ budgetUsedPercent: number;
173
+ };
174
+ agentWorkItems?: Array<{ id: string; kind: string; prompt: string }>; // CJK low-match delegation
175
+ englishQuery?: string;
176
+ }
177
+ ```
178
+
179
+ **Always report to user:** token savings %, anchor count, key summary findings
180
+
181
+ ### Workflow 1b: Chinese / CJK queries (agent translates → English search)
182
+
183
+ **Use when:** User asks in Chinese but the codebase uses English symbols
184
+
185
+ GraphFlow tokenizes CJK and expands workspace path hints. When that is not enough, **YOU must translate** to English code keywords.
186
+
187
+ **Preferred (proactive):**
188
+ ```
189
+ Step 1: Translate user intent to English file/symbol terms with YOUR model
190
+ Step 2: graphflow_context({ query: "<Chinese>", englishQuery: "PoseDetectionPage avatarMode BattlePage shieldEffect", rootDir })
191
+ Step 3: Use summary + anchors
192
+ ```
193
+
194
+ Use **exact file/class/component names** (PascalCase stems). Avoid generic words like `exercise` when the user means camera/pose UI — that word often hits data/types layers instead of pages.
195
+
196
+ For **module families** (Zustand store + `slices/`): put file stems in `englishQuery` (`useGameStore companionSlice dailySlice inventorySlice`), not bare domain words like `monster` (often ranks `data/monsters` over `monsterSlice`).
197
+
198
+ **Fallback:** If `anchorCount < 3` and `agentWorkItems` includes `query-translate-en`, answer JSON prompt and retry with `englishQuery`.
199
+
200
+ ---
201
+
202
+ ### Workflow 2: Plan Before Coding (complex tasks)
203
+
204
+ **Use when:** Multi-step changes, refactors, features with unclear scope
205
+
206
+ ```
207
+ Step 1: graphflow_context(query: "<task>")
208
+ Step 2: graphflow_plan(task: "<task description>")
209
+ - Without GraphFlow LLM: returns mode=agent-delegated + agentWorkItems
210
+ (simple-plan-intent, simple-plan-decomposition) and optional suggestedNodes.
211
+ MUST submit/merge via graphflow_insight before treating the DAG as final.
212
+ - Local suggestedNodes are heuristic hints only.
213
+ Step 3: Review plan steps and dependencies
214
+ Step 4: Execute step by step, using GraphFlow context for each step
215
+ Step 5: graphflow_index() after major changes
216
+ ```
217
+
218
+ **Input:**
219
+ ```typescript
220
+ {
221
+ task: string; // Required - task description to plan
222
+ mode?: "simple" | "insight"; // 'simple' (default) for quick planning, 'insight' for Six Hats + 5-Why
223
+ configPath?: string;
224
+ }
225
+ ```
226
+
227
+ **Output structure:**
228
+ ```typescript
229
+ {
230
+ ideas: string[]; // Brainstorming ideas
231
+ plan: {
232
+ steps: Array<{
233
+ id: string;
234
+ title: string;
235
+ description: string;
236
+ dependsOn: string[];
237
+ estimate: string;
238
+ }>;
239
+ dag: object; // Task dependency graph
240
+ };
241
+ }
242
+ ```
243
+
244
+ ---
245
+
246
+ ### Workflow 3: Deep Analysis (complex/ambiguous tasks)
247
+
248
+ **Use when:** High-stakes changes, root-cause analysis, ambiguous requirements
249
+
250
+ ```
251
+ Step 1: graphflow_context(query: "<task>")
252
+ Step 2: graphflow_plan(task: "<task description>", mode: "insight")
253
+ Step 3: Review Six Hats analysis and 5-Why chains
254
+ Step 4: Use insights to inform implementation plan
255
+ Step 5: Execute with regular context previews
256
+ ```
257
+
258
+ ---
259
+
260
+ ### Workflow 4: Full Task Packaging (bridge mode)
261
+
262
+ **Use when:** You want a complete execution descriptor with context packaged
263
+
264
+ ```
265
+ Step 1: graphflow_run(task: "<full task description>")
266
+ Step 2: Receive executionDescriptor with phases + compressed context
267
+ Step 3: Execute the plan (GraphFlow does NOT execute code)
268
+ Step 4: graphflow_report_outcome(episodeId, success, lessons)
269
+ ```
270
+
271
+ **Input:**
272
+ ```typescript
273
+ {
274
+ task: string; // Required - full task description
275
+ configPath?: string; // Optional - config path
276
+ }
277
+ ```
278
+
279
+ **Input - report_outcome:**
280
+ ```typescript
281
+ {
282
+ episodeId: string; // Required - from graphflow_run
283
+ success: boolean; // Required - whether task completed
284
+ lessons?: string[]; // Optional - up to 4 lessons learned
285
+ configPath?: string; // Optional - config path
286
+ }
287
+ ```
288
+
289
+ ---
290
+
291
+ ### Workflow 5: Graph Maintenance
292
+
293
+ **Use when:** Graph is stale, or after significant project changes
294
+
295
+ #### Incremental Index (fast)
296
+ ```
297
+ graphflow_index(rootDir?: string, configPath?: string)
298
+ ```
299
+ - Only indexes new/changed files
300
+ - Safe to call frequently
301
+ - Use after saving multiple files
302
+
303
+ #### Single File Index (fastest)
304
+ ```
305
+ graphflow_index(filePath: string, configPath?: string)
306
+ ```
307
+ - Index just one file
308
+ - Perfect for onSave hooks
309
+ - Skips unchanged files automatically
310
+
311
+ #### Full Rebuild (slow but clean)
312
+ ```
313
+ graphflow_index(mode: "full", rootDir?: string, configPath?: string)
314
+ ```
315
+ - Clears ALL cached data
316
+ - Full re-index from scratch
317
+ - Use only when graph is corrupted or very stale
318
+
319
+ #### Inspect Graph State
320
+ ```
321
+ graphflow_diagnose(nodeLimit?, edgeLimit?, rootDir?)
322
+ ```
323
+ - Check graph size, file count, symbol count
324
+ - Verify indexing worked correctly
325
+ - Sample nodes to verify quality
326
+ - Also shows provider health and token savings
327
+
328
+ ---
329
+
330
+ ### Workflow 6: Team Collaboration
331
+
332
+ **Use when:** Sharing graph state with teammates
333
+
334
+ #### Export Artifact
335
+ ```
336
+ graphflow_artifact(mode: "export", outputPath?, compression?)
337
+ ```
338
+ - Export graph to portable gzip artifact
339
+ - Share with team to skip full indexing
340
+ - Can be committed to git
341
+
342
+ #### Import Artifact
343
+ ```
344
+ graphflow_artifact(mode: "import", inputPath?)
345
+ ```
346
+ - Import teammate's graph artifact
347
+ - Skip initial full workspace index
348
+ - Great for onboarding new team members
349
+
350
+ ---
351
+
352
+ ### Workflow 7: Advanced Capabilities
353
+
354
+ #### Skill Insights (learning flywheel)
355
+ ```
356
+ graphflow_skill_insights(limit?, rootDir?)
357
+ ```
358
+ - Returns learned skill patterns from prior runs
359
+ - Can accelerate similar tasks
360
+ - Part of the skill evolution flywheel
361
+
362
+ #### Token Savings Stats
363
+ ```
364
+ graphflow_diagnose(configPath?, rootDir?)
365
+ ```
366
+ - Check the `stats` field for cumulative token savings across all runs
367
+ - ROI tracking
368
+ - See how much GraphFlow has saved
369
+
370
+ #### Diagnostics
371
+ ```
372
+ graphflow_diagnose(configPath?)
373
+ ```
374
+ - Check provider health
375
+ - Verify model routing
376
+ - Debug configuration issues
377
+ - Also returns graph stats and token savings
378
+
379
+ ---
380
+
381
+ ## Tool Selection Decision Tree
382
+
383
+ ```
384
+ Start
385
+
386
+ ├─ Is this a codebase question/exploration?
387
+ │ └─ YES → graphflow_context ← START HERE
388
+ │ │
389
+ │ └─ Need more detail on specific item?
390
+ │ └─ YES → graphflow_context(anchorId)
391
+
392
+ ├─ Is this a multi-step coding task?
393
+ │ ├─ Simple (2-3 files) → context + implement
394
+ │ ├─ Complex → context → graphflow_plan → implement
395
+ │ └─ Ambiguous/high-stakes → context → graphflow_plan(mode="insight") → implement
396
+
397
+ ├─ Do you need a complete packaged task?
398
+ │ └─ YES → graphflow_run (bridge mode) → execute → report_outcome
399
+
400
+ ├─ Did you just make file changes?
401
+ │ ├─ Single file → graphflow_index(filePath)
402
+ │ └─ Multiple files → graphflow_index (incremental)
403
+
404
+ ├─ Is the graph giving bad results?
405
+ │ ├─ First → graphflow_diagnose (check state)
406
+ │ ├─ Then → graphflow_index (try incremental)
407
+ │ └─ Last resort → graphflow_index(mode="full") (full rebuild)
408
+
409
+ ├─ Sharing with teammates?
410
+ │ ├─ Export → graphflow_artifact(mode="export")
411
+ │ └─ Import → graphflow_artifact(mode="import")
412
+
413
+ ├─ Do you want to leverage prior learning?
414
+ │ └─ YES → graphflow_skill_insights
415
+
416
+ ├─ Tracking ROI?
417
+ │ └─ graphflow_diagnose (check stats field)
418
+
419
+ └─ Is routing/models misbehaving?
420
+ └─ YES → graphflow_diagnose
421
+ ```
422
+
423
+ ---
424
+
425
+ ## Output Interpretation Guide
426
+
427
+ ### Reading Compressed Context
428
+
429
+ The `summary` array contains compressed context lines. Each line is one of:
430
+
431
+ | Prefix | Meaning | Example |
432
+ |--------|---------|---------|
433
+ | `Module:` | Module-level summary | `Module: src/graph/context-slicer` |
434
+ | `File:` | File-level summary | `File: src/graph/context-slicer.ts # exports: buildLayeredContextPackage` |
435
+ | `Symbol:` | Function/class symbol | `Symbol: function buildLayeredContextPackage (exported) @src/graph/context-slicer.ts:42` |
436
+
437
+ **Priority order:** Symbols (L1) > Files (L1) > Modules (L2) > Overview (L3)
438
+
439
+ ### Token Budget
440
+
441
+ Always pay attention to `tokenBudget`:
442
+
443
+ | Field | Meaning |
444
+ |-------|---------|
445
+ | `maxContextTokens` | The configured budget (default 1500) |
446
+ | `estimatedRawTokens` | What reading all relevant files raw would cost |
447
+ | `compressedTokens` | What GraphFlow's compressed output uses |
448
+ | `estimatedSavingsPercent` | Percentage saved (typically 70-95%) |
449
+ | `budgetUsedPercent` | How much of the budget is used |
450
+
451
+ **Rule of thumb:** If `budgetUsedPercent < 50%`, you can safely expand more anchors.
452
+
453
+ ---
454
+
455
+ ## Best Practices
456
+
457
+ ### 1. Context First, Always
458
+ - Start EVERY coding task with `graphflow_context`
459
+ - Only read full files when compressed context is insufficient
460
+ - Never grep the whole repo before trying GraphFlow
461
+
462
+ ### 2. Plan Before Complex Work
463
+ - Use `graphflow_plan` for anything beyond 2-3 files
464
+ - Use `graphflow_plan(mode="insight")` for ambiguous tasks
465
+ - Follow the DAG order (respect dependencies)
466
+ - Use context from GraphFlow at each step
467
+
468
+ ### 3. Keep Graph Fresh
469
+ - Call `graphflow_index(filePath)` after saving individual files
470
+ - Call `graphflow_index` after significant changes
471
+ - Prefer incremental index over full rebuild
472
+ - Check `graphflow_diagnose` if results seem off
473
+
474
+ ### 4. Close the Learning Loop
475
+ - After bridge-mode runs, call `graphflow_report_outcome`
476
+ - Include lessons learned to improve future planning
477
+ - This feeds the skill evolution flywheel
478
+
479
+ ### 5. Report Token Savings
480
+ - Always mention `estimatedSavingsPercent` to the user
481
+ - This demonstrates the value of GraphFlow
482
+ - Include raw vs compressed token counts
483
+
484
+ ### 6. Bridge Mode Mindset
485
+ - `graphflow_run` returns plans, it doesn't execute them
486
+ - YOU are the execution agent (bridge mode)
487
+ - Use the packaged context to accelerate your work
488
+
489
+ ---
490
+
491
+ ## Troubleshooting
492
+
493
+ ### "0 anchors found" or empty results
494
+ 1. **Chinese/CJK:** translate to English keywords; pass `englishQuery` or answer `agentWorkItems` id `query-translate-en`
495
+ 2. Check if graph exists: `graphflow_diagnose`
496
+ 3. If empty: run `graphflow_index`
497
+ 4. If still empty: verify `rootDir` points to correct project
498
+
499
+ ### Results seem stale
500
+ 1. Run `graphflow_index` (incremental, fast)
501
+ 2. If still stale: `graphflow_index(mode="full")` (full, slow)
502
+
503
+ ### Context quality is poor
504
+ 1. Try more specific query terms
505
+ 2. Check if symbols are indexed (diagnose)
506
+ 3. Run `graphflow_index(mode="full")` if the graph may be stale
507
+
508
+ ### Tool errors / configuration issues
509
+ 1. Run `graphflow_diagnose` to check provider health
510
+ 2. Verify config file exists at specified path
511
+ 3. Check workspace root is correct
512
+
513
+ ### Want to share graph with teammates
514
+ 1. Export: `graphflow_artifact(mode="export")`
515
+ 2. Send the artifact file
516
+ 3. Teammate imports: `graphflow_artifact(mode="import")`
517
+
518
+ ---
519
+
520
+ ## Quick Reference Cheat Sheet
521
+
522
+ ```typescript
523
+ // 90% of the time - start here
524
+ await graphflow_context({ query: "what you're looking for" });
525
+
526
+ // Need more detail on a specific anchor?
527
+ await graphflow_context({ anchorId: "symbol:src/foo.ts:abc123" });
528
+
529
+ // Before complex tasks
530
+ await graphflow_plan({ task: "describe the task" });
531
+
532
+ // Deep analysis with Six Thinking Hats + 5-Why
533
+ await graphflow_plan({ task: "complex ambiguous task", mode: "insight" });
534
+
535
+ // Full packaged task (bridge mode)
536
+ const result = await graphflow_run({ task: "full task description" });
537
+ // ... execute the task ...
538
+ await graphflow_report_outcome({
539
+ episodeId: result.episodeId,
540
+ success: true,
541
+ lessons: ["lesson 1", "lesson 2"]
542
+ });
543
+
544
+ // After making changes - single file
545
+ await graphflow_index({ filePath: "src/foo.ts" });
546
+
547
+ // After making changes - workspace
548
+ await graphflow_index({ rootDir: "/path/to/project" });
549
+
550
+ // Check graph health + stats + savings
551
+ await graphflow_diagnose({ nodeLimit: 20 });
552
+
553
+ // When graph is broken
554
+ await graphflow_index({ mode: "full", rootDir: "/path/to/project" });
555
+
556
+ // Team collaboration
557
+ await graphflow_artifact({ mode: "export", outputPath: "graph-artifact.gz" });
558
+ await graphflow_artifact({ mode: "import", inputPath: "graph-artifact.gz" });
559
+
560
+ // Leverage prior learning
561
+ await graphflow_skill_insights({ limit: 5 });
562
+
563
+ // Diagnose issues
564
+ await graphflow_diagnose();
565
+ ```