@roarpeng/graphflow 1.0.0 → 1.0.4
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.
- package/CHANGELOG.md +26 -0
- package/README.md +96 -38
- package/dist/agents/insight.d.ts +83 -0
- package/dist/agents/insight.d.ts.map +1 -0
- package/dist/agents/insight.js +381 -0
- package/dist/agents/insight.js.map +1 -0
- package/dist/config/defaults.js +1 -1
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/discover-workspace.d.ts +16 -0
- package/dist/config/discover-workspace.d.ts.map +1 -0
- package/dist/config/discover-workspace.js +112 -0
- package/dist/config/discover-workspace.js.map +1 -0
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resolve.js +22 -8
- package/dist/config/resolve.js.map +1 -1
- package/dist/config/scaffold.d.ts.map +1 -1
- package/dist/config/scaffold.js +2 -1
- package/dist/config/scaffold.js.map +1 -1
- package/dist/config/workspace-root.d.ts +24 -0
- package/dist/config/workspace-root.d.ts.map +1 -0
- package/dist/config/workspace-root.js +59 -0
- package/dist/config/workspace-root.js.map +1 -0
- package/dist/core/orchestrator.js +10 -1
- package/dist/core/orchestrator.js.map +1 -1
- package/dist/core/state-machine.js +1 -1
- package/dist/core/state-machine.js.map +1 -1
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/graph/artifact-manager.d.ts +72 -0
- package/dist/graph/artifact-manager.d.ts.map +1 -0
- package/dist/graph/artifact-manager.js +215 -0
- package/dist/graph/artifact-manager.js.map +1 -0
- package/dist/graph/context-slicer.d.ts.map +1 -1
- package/dist/graph/context-slicer.js +3 -2
- package/dist/graph/context-slicer.js.map +1 -1
- package/dist/graph/file-indexer.d.ts +31 -0
- package/dist/graph/file-indexer.d.ts.map +1 -1
- package/dist/graph/file-indexer.js +332 -3
- package/dist/graph/file-indexer.js.map +1 -1
- package/dist/graph/graph-compression.d.ts.map +1 -1
- package/dist/graph/graph-compression.js +2 -0
- package/dist/graph/graph-compression.js.map +1 -1
- package/dist/graph/graph-utils.d.ts +4 -1
- package/dist/graph/graph-utils.d.ts.map +1 -1
- package/dist/graph/graph-utils.js +62 -0
- package/dist/graph/graph-utils.js.map +1 -1
- package/dist/graph/graphify-file-client.d.ts.map +1 -1
- package/dist/graph/graphify-file-client.js +30 -8
- package/dist/graph/graphify-file-client.js.map +1 -1
- package/dist/graph/language-indexers/c-cpp.d.ts +9 -1
- package/dist/graph/language-indexers/c-cpp.d.ts.map +1 -1
- package/dist/graph/language-indexers/c-cpp.js +328 -103
- package/dist/graph/language-indexers/c-cpp.js.map +1 -1
- package/dist/graph/language-indexers/index.d.ts +20 -0
- package/dist/graph/language-indexers/index.d.ts.map +1 -1
- package/dist/graph/language-indexers/index.js +4 -0
- package/dist/graph/language-indexers/index.js.map +1 -1
- package/dist/graph/language-indexers/java.d.ts +12 -0
- package/dist/graph/language-indexers/java.d.ts.map +1 -0
- package/dist/graph/language-indexers/java.js +273 -0
- package/dist/graph/language-indexers/java.js.map +1 -0
- package/dist/graph/language-indexers/python.d.ts.map +1 -1
- package/dist/graph/language-indexers/python.js +47 -4
- package/dist/graph/language-indexers/python.js.map +1 -1
- package/dist/graph/language-indexers/ruby.d.ts +14 -0
- package/dist/graph/language-indexers/ruby.d.ts.map +1 -0
- package/dist/graph/language-indexers/ruby.js +245 -0
- package/dist/graph/language-indexers/ruby.js.map +1 -0
- package/dist/graph/language-indexers/rust.d.ts +10 -1
- package/dist/graph/language-indexers/rust.d.ts.map +1 -1
- package/dist/graph/language-indexers/rust.js +254 -80
- package/dist/graph/language-indexers/rust.js.map +1 -1
- package/dist/graph/language-indexers/tree-sitter-loader.d.ts +8 -1
- package/dist/graph/language-indexers/tree-sitter-loader.d.ts.map +1 -1
- package/dist/graph/language-indexers/tree-sitter-loader.js +64 -13
- package/dist/graph/language-indexers/tree-sitter-loader.js.map +1 -1
- package/dist/graph/language-indexers/typescript.d.ts.map +1 -1
- package/dist/graph/language-indexers/typescript.js +72 -8
- package/dist/graph/language-indexers/typescript.js.map +1 -1
- package/dist/graph/metrics.d.ts +33 -0
- package/dist/graph/metrics.d.ts.map +1 -0
- package/dist/graph/metrics.js +117 -0
- package/dist/graph/metrics.js.map +1 -0
- package/dist/graph/token-savings.d.ts +52 -0
- package/dist/graph/token-savings.d.ts.map +1 -0
- package/dist/graph/token-savings.js +113 -0
- package/dist/graph/token-savings.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/agent-mcp-installer.d.ts +2 -0
- package/dist/integrations/agent-mcp-installer.d.ts.map +1 -1
- package/dist/integrations/agent-mcp-installer.js +115 -23
- package/dist/integrations/agent-mcp-installer.js.map +1 -1
- package/dist/learning/episodic-memory.d.ts +8 -1
- package/dist/learning/episodic-memory.d.ts.map +1 -1
- package/dist/learning/episodic-memory.js +33 -0
- package/dist/learning/episodic-memory.js.map +1 -1
- package/dist/skills/index.d.ts +157 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +157 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/surfaces/cli/index.js +119 -0
- package/dist/surfaces/cli/index.js.map +1 -1
- package/dist/surfaces/cli/output.d.ts.map +1 -1
- package/dist/surfaces/cli/output.js +7 -0
- package/dist/surfaces/cli/output.js.map +1 -1
- package/dist/surfaces/cli/runtime/graph.d.ts +77 -3
- package/dist/surfaces/cli/runtime/graph.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime/graph.js +140 -9
- package/dist/surfaces/cli/runtime/graph.js.map +1 -1
- package/dist/surfaces/cli/runtime/routing.d.ts +24 -1
- package/dist/surfaces/cli/runtime/routing.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime/routing.js +57 -0
- package/dist/surfaces/cli/runtime/routing.js.map +1 -1
- package/dist/surfaces/cli/runtime/settings.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime/settings.js +4 -1
- package/dist/surfaces/cli/runtime/settings.js.map +1 -1
- package/dist/surfaces/cli/runtime/types.d.ts +16 -0
- package/dist/surfaces/cli/runtime/types.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime.d.ts +2 -2
- package/dist/surfaces/cli/runtime.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime.js +11 -1
- package/dist/surfaces/cli/runtime.js.map +1 -1
- package/dist/surfaces/mcp/server.d.ts.map +1 -1
- package/dist/surfaces/mcp/server.js +143 -2
- package/dist/surfaces/mcp/server.js.map +1 -1
- package/package.json +5 -2
- package/scripts/safe-postinstall.cjs +167 -12
- package/src/surfaces/trae-skill/graphflow/SKILL.md +535 -0
- package/wasm/tree-sitter-c.wasm +0 -0
- package/wasm/tree-sitter-go.wasm +0 -0
- package/wasm/tree-sitter-java.wasm +0 -0
- package/wasm/tree-sitter-python.wasm +0 -0
- package/wasm/tree-sitter-ruby.wasm +0 -0
- package/wasm/tree-sitter-rust.wasm +0 -0
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "graphflow"
|
|
3
|
+
description: "Graph-based code context compression, task planning, and knowledge graph orchestration. Backed by GraphFlow MCP server with 18 tools. Invoke before multi-step edits, large refactors, codebase-wide questions, or when you need to understand project structure efficiently to save tokens."
|
|
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
|
+
│ 18 tools: preview, expand, plan, plan_insight, │
|
|
24
|
+
│ run, report_outcome, index, index_file, rebuild,│
|
|
25
|
+
│ enrich, model_download, inspect, skill_insights,│
|
|
26
|
+
│ diagnose, export_artifact, import_artifact, │
|
|
27
|
+
│ stats, metrics │
|
|
28
|
+
└──────────────────┬──────────────────────────────┘
|
|
29
|
+
│
|
|
30
|
+
▼
|
|
31
|
+
┌─────────────────────────────────────────────────┐
|
|
32
|
+
│ GraphFlow Core Engine │
|
|
33
|
+
│ - Graph index & context compression │
|
|
34
|
+
│ - Task planning & DAG │
|
|
35
|
+
│ - Skill learning flywheel │
|
|
36
|
+
│ - Artifact import/export │
|
|
37
|
+
└─────────────────────────────────────────────────┘
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## When to Use
|
|
41
|
+
|
|
42
|
+
**ALWAYS invoke this skill BEFORE:**
|
|
43
|
+
- Multi-step edits, refactors, or architecture changes
|
|
44
|
+
- Large codebase-wide questions or exploration
|
|
45
|
+
- Debugging across multiple files
|
|
46
|
+
- Any task where you would otherwise read many files
|
|
47
|
+
- Token budget is a concern
|
|
48
|
+
- You need structured task planning
|
|
49
|
+
|
|
50
|
+
**DO NOT:**
|
|
51
|
+
- Scan the whole repository recursively before trying GraphFlow
|
|
52
|
+
- Read large files before checking GraphFlow anchors
|
|
53
|
+
- Skip GraphFlow for complex tasks
|
|
54
|
+
- Use grep for codebase exploration before `graphflow_preview_context`
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Tool Inventory (18 MCP Tools)
|
|
59
|
+
|
|
60
|
+
### Core Context Tools (Highest Frequency)
|
|
61
|
+
|
|
62
|
+
| Tool | Purpose | Call Frequency |
|
|
63
|
+
|------|---------|---------------|
|
|
64
|
+
| `graphflow_preview_context` | Compress task context with token budget | **Highest** - default first step |
|
|
65
|
+
| `graphflow_expand_anchor` | Expand a single anchor to full content | **High** - dive deeper into specific items |
|
|
66
|
+
|
|
67
|
+
### Planning Tools (High Frequency)
|
|
68
|
+
|
|
69
|
+
| Tool | Purpose | Call Frequency |
|
|
70
|
+
|------|---------|---------------|
|
|
71
|
+
| `graphflow_plan` | Multi-step task decomposition & DAG | High - before complex work |
|
|
72
|
+
| `graphflow_plan_insight` | Six Thinking Hats + 5-Why deep analysis | Medium - ambiguous/high-stakes tasks |
|
|
73
|
+
| `graphflow_run` | Plan + context package (bridge mode) | Medium - full task packaging |
|
|
74
|
+
| `graphflow_report_outcome` | Report bridge-mode execution outcome back | Medium - close the learning loop |
|
|
75
|
+
|
|
76
|
+
### Graph Management Tools (Medium Frequency)
|
|
77
|
+
|
|
78
|
+
| Tool | Purpose | Call Frequency |
|
|
79
|
+
|------|---------|---------------|
|
|
80
|
+
| `graphflow_index` | Incremental workspace re-index | Medium - after file changes |
|
|
81
|
+
| `graphflow_index_file` | Single file incremental index | Medium-High - after saving a file |
|
|
82
|
+
| `graphflow_rebuild` | Clear cache + full re-index | Low - when graph is stale/corrupted |
|
|
83
|
+
| `graphflow_inspect_graph` | Graph stats & sample nodes/edges | Low - check graph health |
|
|
84
|
+
| `graphflow_enrich_graph` | Semantic enrichment of symbols | Rare - LLM-powered enrichment |
|
|
85
|
+
| `graphflow_model_download` | Download local compression model | Rare - offline setup |
|
|
86
|
+
|
|
87
|
+
### Collaboration & Insights Tools (Low Frequency)
|
|
88
|
+
|
|
89
|
+
| Tool | Purpose | Call Frequency |
|
|
90
|
+
|------|---------|---------------|
|
|
91
|
+
| `graphflow_export_artifact` | Export graph to portable artifact | Low - team sharing |
|
|
92
|
+
| `graphflow_import_artifact` | Import graph artifact | Low - skip full index on new machine |
|
|
93
|
+
| `graphflow_skill_insights` | Learned skill patterns | Low - leverage prior learning |
|
|
94
|
+
| `graphflow_stats` | Cumulative token savings stats | Low - ROI tracking |
|
|
95
|
+
| `graphflow_metrics` | Prometheus-compatible metrics | Low - observability |
|
|
96
|
+
| `graphflow_diagnose` | Provider health & model routing | Rare - config issues |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Standard Workflows
|
|
101
|
+
|
|
102
|
+
### Workflow 1: Context First (90% of tasks)
|
|
103
|
+
|
|
104
|
+
**Use when:** Answering code questions, exploring codebase, understanding modules
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
Step 1: graphflow_preview_context(query: "<your question>")
|
|
108
|
+
Step 2: Read summary + anchors as primary context
|
|
109
|
+
Step 3: Expand specific anchors with graphflow_expand_anchor when needed
|
|
110
|
+
Step 4: Read full files only when exact edits required
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Input - preview_context:**
|
|
114
|
+
```typescript
|
|
115
|
+
{
|
|
116
|
+
query: string; // Required - your search/understanding query
|
|
117
|
+
configPath?: string; // Optional - path to graphflow.config.json
|
|
118
|
+
rootDir?: string; // Optional - workspace root override
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Input - expand_anchor:**
|
|
123
|
+
```typescript
|
|
124
|
+
{
|
|
125
|
+
anchorId: string; // Required - anchor id from preview_context
|
|
126
|
+
configPath?: string; // Optional - path to graphflow.config.json
|
|
127
|
+
rootDir?: string; // Optional - workspace root override
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Output structure (preview_context):**
|
|
132
|
+
```typescript
|
|
133
|
+
{
|
|
134
|
+
summary: string[]; // Compressed context lines
|
|
135
|
+
anchors: Array<{ // File/symbol anchors you can expand
|
|
136
|
+
id: string;
|
|
137
|
+
type: "Module" | "File" | "Symbol";
|
|
138
|
+
layer: "L1" | "L2" | "L3";
|
|
139
|
+
}>;
|
|
140
|
+
tokenBudget: {
|
|
141
|
+
maxContextTokens: number; // Configured budget
|
|
142
|
+
estimatedRawTokens: number; // What full files would cost
|
|
143
|
+
compressedTokens: number; // What this returns
|
|
144
|
+
estimatedSavingsPercent: number; // 0-100
|
|
145
|
+
budgetUsedPercent: number; // 0-100
|
|
146
|
+
};
|
|
147
|
+
refillPreview: string[]; // Hints for getting more context
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Always report to user:**
|
|
152
|
+
- Token savings percentage
|
|
153
|
+
- Number of anchors found
|
|
154
|
+
- Key findings from summary
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
### Workflow 2: Plan Before Coding (complex tasks)
|
|
159
|
+
|
|
160
|
+
**Use when:** Multi-step changes, refactors, features with unclear scope
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
Step 1: graphflow_preview_context(query: "<task>")
|
|
164
|
+
Step 2: graphflow_plan(task: "<task description>")
|
|
165
|
+
Step 3: Review plan steps and dependencies
|
|
166
|
+
Step 4: Execute step by step, using GraphFlow context for each step
|
|
167
|
+
Step 5: graphflow_index() after major changes
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Input:**
|
|
171
|
+
```typescript
|
|
172
|
+
{
|
|
173
|
+
task: string; // Required - task description to plan
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Output structure:**
|
|
178
|
+
```typescript
|
|
179
|
+
{
|
|
180
|
+
ideas: string[]; // Brainstorming ideas
|
|
181
|
+
plan: {
|
|
182
|
+
steps: Array<{
|
|
183
|
+
id: string;
|
|
184
|
+
title: string;
|
|
185
|
+
description: string;
|
|
186
|
+
dependsOn: string[];
|
|
187
|
+
estimate: string;
|
|
188
|
+
}>;
|
|
189
|
+
dag: object; // Task dependency graph
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
### Workflow 3: Deep Analysis (complex/ambiguous tasks)
|
|
197
|
+
|
|
198
|
+
**Use when:** High-stakes changes, root-cause analysis, ambiguous requirements
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
Step 1: graphflow_preview_context(query: "<task>")
|
|
202
|
+
Step 2: graphflow_plan_insight(task: "<task description>")
|
|
203
|
+
Step 3: Review Six Hats analysis and 5-Why chains
|
|
204
|
+
Step 4: Use insights to inform implementation plan
|
|
205
|
+
Step 5: Execute with regular context previews
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
### Workflow 4: Full Task Packaging (bridge mode)
|
|
211
|
+
|
|
212
|
+
**Use when:** You want a complete execution descriptor with context packaged
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
Step 1: graphflow_run(task: "<full task description>")
|
|
216
|
+
Step 2: Receive executionDescriptor with phases + compressed context
|
|
217
|
+
Step 3: Execute the plan (GraphFlow does NOT execute code)
|
|
218
|
+
Step 4: graphflow_report_outcome(episodeId, success, lessons)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Input:**
|
|
222
|
+
```typescript
|
|
223
|
+
{
|
|
224
|
+
task: string; // Required - full task description
|
|
225
|
+
configPath?: string; // Optional - config path
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**Input - report_outcome:**
|
|
230
|
+
```typescript
|
|
231
|
+
{
|
|
232
|
+
episodeId: string; // Required - from graphflow_run
|
|
233
|
+
success: boolean; // Required - whether task completed
|
|
234
|
+
lessons?: string[]; // Optional - up to 4 lessons learned
|
|
235
|
+
configPath?: string; // Optional - config path
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
### Workflow 5: Graph Maintenance
|
|
242
|
+
|
|
243
|
+
**Use when:** Graph is stale, or after significant project changes
|
|
244
|
+
|
|
245
|
+
#### Incremental Index (fast)
|
|
246
|
+
```
|
|
247
|
+
graphflow_index(rootDir?: string, configPath?: string)
|
|
248
|
+
```
|
|
249
|
+
- Only indexes new/changed files
|
|
250
|
+
- Safe to call frequently
|
|
251
|
+
- Use after saving multiple files
|
|
252
|
+
|
|
253
|
+
#### Single File Index (fastest)
|
|
254
|
+
```
|
|
255
|
+
graphflow_index_file(filePath: string, configPath?: string)
|
|
256
|
+
```
|
|
257
|
+
- Index just one file
|
|
258
|
+
- Perfect for onSave hooks
|
|
259
|
+
- Skips unchanged files automatically
|
|
260
|
+
|
|
261
|
+
#### Full Rebuild (slow but clean)
|
|
262
|
+
```
|
|
263
|
+
graphflow_rebuild(rootDir?: string, configPath?: string)
|
|
264
|
+
```
|
|
265
|
+
- Clears ALL cached data
|
|
266
|
+
- Full re-index from scratch
|
|
267
|
+
- Use only when graph is corrupted or very stale
|
|
268
|
+
|
|
269
|
+
#### Inspect Graph State
|
|
270
|
+
```
|
|
271
|
+
graphflow_inspect_graph(nodeLimit?, edgeLimit?, rootDir?)
|
|
272
|
+
```
|
|
273
|
+
- Check graph size, file count, symbol count
|
|
274
|
+
- Verify indexing worked correctly
|
|
275
|
+
- Sample nodes to verify quality
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
### Workflow 6: Team Collaboration
|
|
280
|
+
|
|
281
|
+
**Use when:** Sharing graph state with teammates
|
|
282
|
+
|
|
283
|
+
#### Export Artifact
|
|
284
|
+
```
|
|
285
|
+
graphflow_export_artifact(outputPath?, compression?)
|
|
286
|
+
```
|
|
287
|
+
- Export graph to portable gzip artifact
|
|
288
|
+
- Share with team to skip full indexing
|
|
289
|
+
- Can be committed to git
|
|
290
|
+
|
|
291
|
+
#### Import Artifact
|
|
292
|
+
```
|
|
293
|
+
graphflow_import_artifact(inputPath?)
|
|
294
|
+
```
|
|
295
|
+
- Import teammate's graph artifact
|
|
296
|
+
- Skip initial full workspace index
|
|
297
|
+
- Great for onboarding new team members
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
### Workflow 7: Advanced Capabilities
|
|
302
|
+
|
|
303
|
+
#### Semantic Enrichment (LLM required)
|
|
304
|
+
```
|
|
305
|
+
graphflow_enrich_graph(batchSize?, sleepMs?, timeoutMs?)
|
|
306
|
+
```
|
|
307
|
+
- Adds semantic descriptions to symbol nodes
|
|
308
|
+
- Improves context quality for complex queries
|
|
309
|
+
- Requires configured LLM provider
|
|
310
|
+
|
|
311
|
+
#### Skill Insights (learning flywheel)
|
|
312
|
+
```
|
|
313
|
+
graphflow_skill_insights(limit?, rootDir?)
|
|
314
|
+
```
|
|
315
|
+
- Returns learned skill patterns from prior runs
|
|
316
|
+
- Can accelerate similar tasks
|
|
317
|
+
- Part of the skill evolution flywheel
|
|
318
|
+
|
|
319
|
+
#### Token Savings Stats
|
|
320
|
+
```
|
|
321
|
+
graphflow_stats(configPath?, rootDir?)
|
|
322
|
+
```
|
|
323
|
+
- Cumulative token savings across all runs
|
|
324
|
+
- ROI tracking
|
|
325
|
+
- See how much GraphFlow has saved
|
|
326
|
+
|
|
327
|
+
#### Prometheus Metrics
|
|
328
|
+
```
|
|
329
|
+
graphflow_metrics(configPath?, rootDir?)
|
|
330
|
+
```
|
|
331
|
+
- Prometheus text exposition format
|
|
332
|
+
- Token savings, graph size, compression ratio
|
|
333
|
+
- For observability dashboards
|
|
334
|
+
|
|
335
|
+
#### Diagnostics
|
|
336
|
+
```
|
|
337
|
+
graphflow_diagnose(configPath?)
|
|
338
|
+
```
|
|
339
|
+
- Check provider health
|
|
340
|
+
- Verify model routing
|
|
341
|
+
- Debug configuration issues
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## Tool Selection Decision Tree
|
|
346
|
+
|
|
347
|
+
```
|
|
348
|
+
Start
|
|
349
|
+
│
|
|
350
|
+
├─ Is this a codebase question/exploration?
|
|
351
|
+
│ └─ YES → graphflow_preview_context ← START HERE
|
|
352
|
+
│ │
|
|
353
|
+
│ └─ Need more detail on specific item?
|
|
354
|
+
│ └─ YES → graphflow_expand_anchor
|
|
355
|
+
│
|
|
356
|
+
├─ Is this a multi-step coding task?
|
|
357
|
+
│ ├─ Simple (2-3 files) → preview_context + implement
|
|
358
|
+
│ ├─ Complex → preview_context → graphflow_plan → implement
|
|
359
|
+
│ └─ Ambiguous/high-stakes → preview_context → graphflow_plan_insight → implement
|
|
360
|
+
│
|
|
361
|
+
├─ Do you need a complete packaged task?
|
|
362
|
+
│ └─ YES → graphflow_run (bridge mode) → execute → report_outcome
|
|
363
|
+
│
|
|
364
|
+
├─ Did you just make file changes?
|
|
365
|
+
│ ├─ Single file → graphflow_index_file
|
|
366
|
+
│ └─ Multiple files → graphflow_index (incremental)
|
|
367
|
+
│
|
|
368
|
+
├─ Is the graph giving bad results?
|
|
369
|
+
│ ├─ First → graphflow_inspect_graph (check state)
|
|
370
|
+
│ ├─ Then → graphflow_index (try incremental)
|
|
371
|
+
│ └─ Last resort → graphflow_rebuild (full rebuild)
|
|
372
|
+
│
|
|
373
|
+
├─ Sharing with teammates?
|
|
374
|
+
│ ├─ Export → graphflow_export_artifact
|
|
375
|
+
│ └─ Import → graphflow_import_artifact
|
|
376
|
+
│
|
|
377
|
+
├─ Do you want to leverage prior learning?
|
|
378
|
+
│ └─ YES → graphflow_skill_insights
|
|
379
|
+
│
|
|
380
|
+
├─ Tracking ROI / observability?
|
|
381
|
+
│ ├─ Quick stats → graphflow_stats
|
|
382
|
+
│ └─ Prometheus → graphflow_metrics
|
|
383
|
+
│
|
|
384
|
+
└─ Is routing/models misbehaving?
|
|
385
|
+
└─ YES → graphflow_diagnose
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## Output Interpretation Guide
|
|
391
|
+
|
|
392
|
+
### Reading Compressed Context
|
|
393
|
+
|
|
394
|
+
The `summary` array contains compressed context lines. Each line is one of:
|
|
395
|
+
|
|
396
|
+
| Prefix | Meaning | Example |
|
|
397
|
+
|--------|---------|---------|
|
|
398
|
+
| `Module:` | Module-level summary | `Module: src/graph/context-slicer` |
|
|
399
|
+
| `File:` | File-level summary | `File: src/graph/context-slicer.ts # exports: buildLayeredContextPackage` |
|
|
400
|
+
| `Symbol:` | Function/class symbol | `Symbol: function buildLayeredContextPackage (exported) @src/graph/context-slicer.ts:42` |
|
|
401
|
+
|
|
402
|
+
**Priority order:** Symbols (L1) > Files (L1) > Modules (L2) > Overview (L3)
|
|
403
|
+
|
|
404
|
+
### Token Budget
|
|
405
|
+
|
|
406
|
+
Always pay attention to `tokenBudget`:
|
|
407
|
+
|
|
408
|
+
| Field | Meaning |
|
|
409
|
+
|-------|---------|
|
|
410
|
+
| `maxContextTokens` | The configured budget (default 1500) |
|
|
411
|
+
| `estimatedRawTokens` | What reading all relevant files raw would cost |
|
|
412
|
+
| `compressedTokens` | What GraphFlow's compressed output uses |
|
|
413
|
+
| `estimatedSavingsPercent` | Percentage saved (typically 70-95%) |
|
|
414
|
+
| `budgetUsedPercent` | How much of the budget is used |
|
|
415
|
+
|
|
416
|
+
**Rule of thumb:** If `budgetUsedPercent < 50%`, you can safely expand more anchors.
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## Best Practices
|
|
421
|
+
|
|
422
|
+
### 1. Context First, Always
|
|
423
|
+
- Start EVERY coding task with `graphflow_preview_context`
|
|
424
|
+
- Only read full files when compressed context is insufficient
|
|
425
|
+
- Never grep the whole repo before trying GraphFlow
|
|
426
|
+
|
|
427
|
+
### 2. Plan Before Complex Work
|
|
428
|
+
- Use `graphflow_plan` for anything beyond 2-3 files
|
|
429
|
+
- Use `graphflow_plan_insight` for ambiguous tasks
|
|
430
|
+
- Follow the DAG order (respect dependencies)
|
|
431
|
+
- Use context from GraphFlow at each step
|
|
432
|
+
|
|
433
|
+
### 3. Keep Graph Fresh
|
|
434
|
+
- Call `graphflow_index_file` after saving individual files
|
|
435
|
+
- Call `graphflow_index` after significant changes
|
|
436
|
+
- Prefer incremental index over full rebuild
|
|
437
|
+
- Check `graphflow_inspect_graph` if results seem off
|
|
438
|
+
|
|
439
|
+
### 4. Close the Learning Loop
|
|
440
|
+
- After bridge-mode runs, call `graphflow_report_outcome`
|
|
441
|
+
- Include lessons learned to improve future planning
|
|
442
|
+
- This feeds the skill evolution flywheel
|
|
443
|
+
|
|
444
|
+
### 5. Report Token Savings
|
|
445
|
+
- Always mention `estimatedSavingsPercent` to the user
|
|
446
|
+
- This demonstrates the value of GraphFlow
|
|
447
|
+
- Include raw vs compressed token counts
|
|
448
|
+
|
|
449
|
+
### 6. Bridge Mode Mindset
|
|
450
|
+
- `graphflow_run` returns plans, it doesn't execute them
|
|
451
|
+
- YOU are the execution agent (bridge mode)
|
|
452
|
+
- Use the packaged context to accelerate your work
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## Troubleshooting
|
|
457
|
+
|
|
458
|
+
### "0 anchors found" or empty results
|
|
459
|
+
1. Check if graph exists: `graphflow_inspect_graph`
|
|
460
|
+
2. If empty: run `graphflow_index`
|
|
461
|
+
3. If still empty: verify `rootDir` points to correct project
|
|
462
|
+
|
|
463
|
+
### Results seem stale
|
|
464
|
+
1. Run `graphflow_index` (incremental, fast)
|
|
465
|
+
2. If still stale: `graphflow_rebuild` (full, slow)
|
|
466
|
+
|
|
467
|
+
### Context quality is poor
|
|
468
|
+
1. Try more specific query terms
|
|
469
|
+
2. Check if symbols are indexed (inspect graph)
|
|
470
|
+
3. Run `graphflow_enrich_graph` for semantic enhancement (LLM required)
|
|
471
|
+
|
|
472
|
+
### Tool errors / configuration issues
|
|
473
|
+
1. Run `graphflow_diagnose` to check provider health
|
|
474
|
+
2. Verify config file exists at specified path
|
|
475
|
+
3. Check workspace root is correct
|
|
476
|
+
|
|
477
|
+
### Want to share graph with teammates
|
|
478
|
+
1. Export: `graphflow_export_artifact`
|
|
479
|
+
2. Send the artifact file
|
|
480
|
+
3. Teammate imports: `graphflow_import_artifact`
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
484
|
+
## Quick Reference Cheat Sheet
|
|
485
|
+
|
|
486
|
+
```typescript
|
|
487
|
+
// 90% of the time - start here
|
|
488
|
+
await graphflow_preview_context({ query: "what you're looking for" });
|
|
489
|
+
|
|
490
|
+
// Need more detail on a specific anchor?
|
|
491
|
+
await graphflow_expand_anchor({ anchorId: "symbol:src/foo.ts:abc123" });
|
|
492
|
+
|
|
493
|
+
// Before complex tasks
|
|
494
|
+
await graphflow_plan({ task: "describe the task" });
|
|
495
|
+
|
|
496
|
+
// Deep analysis with Six Thinking Hats + 5-Why
|
|
497
|
+
await graphflow_plan_insight({ task: "complex ambiguous task" });
|
|
498
|
+
|
|
499
|
+
// Full packaged task (bridge mode)
|
|
500
|
+
const result = await graphflow_run({ task: "full task description" });
|
|
501
|
+
// ... execute the task ...
|
|
502
|
+
await graphflow_report_outcome({
|
|
503
|
+
episodeId: result.episodeId,
|
|
504
|
+
success: true,
|
|
505
|
+
lessons: ["lesson 1", "lesson 2"]
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
// After making changes - single file
|
|
509
|
+
await graphflow_index_file({ filePath: "src/foo.ts" });
|
|
510
|
+
|
|
511
|
+
// After making changes - workspace
|
|
512
|
+
await graphflow_index({ rootDir: "/path/to/project" });
|
|
513
|
+
|
|
514
|
+
// Check graph health
|
|
515
|
+
await graphflow_inspect_graph({ nodeLimit: 20 });
|
|
516
|
+
|
|
517
|
+
// When graph is broken
|
|
518
|
+
await graphflow_rebuild({ rootDir: "/path/to/project" });
|
|
519
|
+
|
|
520
|
+
// Team collaboration
|
|
521
|
+
await graphflow_export_artifact({ outputPath: "graph-artifact.gz" });
|
|
522
|
+
await graphflow_import_artifact({ inputPath: "graph-artifact.gz" });
|
|
523
|
+
|
|
524
|
+
// Leverage prior learning
|
|
525
|
+
await graphflow_skill_insights({ limit: 5 });
|
|
526
|
+
|
|
527
|
+
// Token savings stats
|
|
528
|
+
await graphflow_stats();
|
|
529
|
+
|
|
530
|
+
// Prometheus metrics
|
|
531
|
+
await graphflow_metrics();
|
|
532
|
+
|
|
533
|
+
// Diagnose issues
|
|
534
|
+
await graphflow_diagnose();
|
|
535
|
+
```
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|