kirograph 0.23.0 → 0.27.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 (64) hide show
  1. package/README.md +19 -5
  2. package/dist/bin/commands/configure-mcp.js +104 -0
  3. package/dist/bin/commands/configure-mcp.js.map +7 -0
  4. package/dist/bin/commands/memory.js +334 -2
  5. package/dist/bin/commands/memory.js.map +2 -2
  6. package/dist/bin/commands/uninit.js +12 -5
  7. package/dist/bin/commands/uninit.js.map +2 -2
  8. package/dist/bin/commands/wiki.js +307 -0
  9. package/dist/bin/commands/wiki.js.map +7 -0
  10. package/dist/bin/installer/common.js +9 -0
  11. package/dist/bin/installer/common.js.map +2 -2
  12. package/dist/bin/installer/config-prompt.js +96 -5
  13. package/dist/bin/installer/config-prompt.js.map +2 -2
  14. package/dist/bin/installer/hooks.js +182 -88
  15. package/dist/bin/installer/hooks.js.map +2 -2
  16. package/dist/bin/installer/index.js +30 -12
  17. package/dist/bin/installer/index.js.map +2 -2
  18. package/dist/bin/installer/instructions.js +27 -1
  19. package/dist/bin/installer/instructions.js.map +2 -2
  20. package/dist/bin/installer/mcp.js +37 -4
  21. package/dist/bin/installer/mcp.js.map +2 -2
  22. package/dist/bin/installer/prompts.js +3 -3
  23. package/dist/bin/installer/prompts.js.map +2 -2
  24. package/dist/bin/installer/steering.js +633 -291
  25. package/dist/bin/installer/steering.js.map +2 -2
  26. package/dist/bin/installer/targets/index.js.map +1 -1
  27. package/dist/bin/installer/targets/kiro.js +7 -6
  28. package/dist/bin/installer/targets/kiro.js.map +2 -2
  29. package/dist/bin/kirograph.js +3 -1
  30. package/dist/bin/kirograph.js.map +3 -3
  31. package/dist/config.js +52 -5
  32. package/dist/config.js.map +2 -2
  33. package/dist/db/database.js +11 -0
  34. package/dist/db/database.js.map +2 -2
  35. package/dist/db/memory-schema.sql +34 -1
  36. package/dist/db/wiki-schema.sql +40 -0
  37. package/dist/mcp/server.js +35 -11
  38. package/dist/mcp/server.js.map +2 -2
  39. package/dist/mcp/tool-names.js +112 -1
  40. package/dist/mcp/tool-names.js.map +2 -2
  41. package/dist/mcp/tools.js +458 -3
  42. package/dist/mcp/tools.js.map +2 -2
  43. package/dist/memory/database.js +131 -7
  44. package/dist/memory/database.js.map +2 -2
  45. package/dist/memory/index.js +130 -4
  46. package/dist/memory/index.js.map +3 -3
  47. package/dist/memory/types.js.map +1 -1
  48. package/dist/watchmen/synthesize.js +2 -0
  49. package/dist/watchmen/synthesize.js.map +2 -2
  50. package/dist/wiki/database.js +143 -0
  51. package/dist/wiki/database.js.map +7 -0
  52. package/dist/wiki/index.js +149 -0
  53. package/dist/wiki/index.js.map +7 -0
  54. package/dist/wiki/ingest.js +259 -0
  55. package/dist/wiki/ingest.js.map +7 -0
  56. package/dist/wiki/lint.js +93 -0
  57. package/dist/wiki/lint.js.map +7 -0
  58. package/dist/wiki/schema.js +148 -0
  59. package/dist/wiki/schema.js.map +7 -0
  60. package/dist/wiki/synthesize.js +104 -0
  61. package/dist/wiki/synthesize.js.map +7 -0
  62. package/dist/wiki/types.js +17 -0
  63. package/dist/wiki/types.js.map +7 -0
  64. package/package.json +6 -4
@@ -34,53 +34,124 @@ module.exports = __toCommonJS(steering_exports);
34
34
  var fs = __toESM(require("fs"));
35
35
  var path = __toESM(require("path"));
36
36
  var import_caveman = require("./caveman");
37
- const STEERING_CONTENT = `---
38
- inclusion: always
37
+ const LEVEL_DESCRIPTIONS = {
38
+ normal: "Balanced: removes noise, keeps structure.",
39
+ aggressive: "Compact: groups by category, limits output.",
40
+ ultra: "Maximum compression: counts and summaries only."
41
+ };
42
+ const LEVEL_EXAMPLES = {
43
+ normal: `\\\`\\\`\\\`
44
+ kirograph_exec(command: "git status")
45
+ kirograph_exec(command: "npm test")
46
+ kirograph_exec(command: "cargo build")
47
+ kirograph_exec(command: "ls -la src/")
48
+ \\\`\\\`\\\``,
49
+ aggressive: `\\\`\\\`\\\`
50
+ kirograph_exec(command: "git status", level: "aggressive")
51
+ kirograph_exec(command: "npm test", level: "aggressive")
52
+ kirograph_exec(command: "eslint .", level: "aggressive")
53
+ kirograph_exec(command: "find . -name '*.ts'", level: "aggressive")
54
+ \\\`\\\`\\\``,
55
+ ultra: `\\\`\\\`\\\`
56
+ kirograph_exec(command: "git status", level: "ultra")
57
+ kirograph_exec(command: "npm test", level: "ultra")
58
+ kirograph_exec(command: "docker ps", level: "ultra")
59
+ kirograph_exec(command: "ls -la src/", level: "ultra")
60
+ \\\`\\\`\\\``
61
+ };
62
+ function buildCompressionSection(level) {
63
+ return `
39
64
  ---
40
65
 
41
- # KiroGraph
66
+ ## Shell Compression (\\\`kirograph_exec\\\`)
42
67
 
43
- KiroGraph builds a semantic knowledge graph of your codebase. Use its MCP tools instead of grep/glob/file reads whenever \`.kirograph/\` exists in the project.
68
+ When running shell commands, prefer \\\`kirograph_exec\\\` over raw shell execution for:
69
+ - **git** operations (status, log, diff, push, pull, commit, add, fetch, branch)
70
+ - **GitHub CLI** (gh pr list/view, gh issue list, gh run list)
71
+ - **test runners** (jest, vitest, pytest, cargo test, go test, rspec, minitest, playwright)
72
+ - **linters/build** (eslint, tsc, ruff, clippy, cargo build, prettier, biome, golangci-lint, rubocop, next build)
73
+ - **file listings** (ls, find, tree)
74
+ - **search** (grep, rg/ripgrep: grouped by file)
75
+ - **diff** (diff file1 file2: condensed context)
76
+ - **docker/k8s** (docker ps, images, logs, compose ps, kubectl pods, logs, services)
77
+ - **package managers** (npm/pnpm install/list, pip list/install, bundle install, prisma generate)
78
+ - **AWS CLI** (sts, ec2, lambda, logs, cloudformation, dynamodb, iam, s3, ecs, sqs, sns)
79
+ - **network** (curl, wget: strip progress bars and headers)
44
80
 
45
- ## Quick decision guide
81
+ This saves 60-90% of tokens compared to raw output.
46
82
 
47
- | Question | Tool |
48
- |----------|------|
49
- | Where do I start on this task? | \`kirograph_context\` |
50
- | What is this symbol / show me its code | \`kirograph_node\` with \`includeCode: true\` |
51
- | Find a symbol by name | \`kirograph_search\` |
52
- | Who calls function X? | \`kirograph_callers\` |
53
- | What does function X call? | \`kirograph_callees\` |
54
- | What breaks if I change X? | \`kirograph_impact\` |
55
- | How are X and Y connected? | \`kirograph_path\` |
56
- | What extends / implements this type? | \`kirograph_type_hierarchy\` |
57
- | Which code is never called? | \`kirograph_dead_code\` |
58
- | Are there import cycles? | \`kirograph_circular_deps\` |
59
- | What files are indexed? | \`kirograph_files\` |
60
- | Is the index healthy? | \`kirograph_status\` |
61
- | What are the most critical symbols? | \`kirograph_hotspots\` |
62
- | Any unexpected cross-module coupling? | \`kirograph_surprising\` |
63
- | What changed since the last snapshot? | \`kirograph_diff\` |
64
- | What packages/layers exist? | \`kirograph_architecture\` |
65
- | How coupled is package X? | \`kirograph_coupling\` |
66
- | What does package X depend on? | \`kirograph_package\` |
67
- | Run a command with token savings | \`kirograph_exec\` |
68
- | Check token savings stats | \`kirograph_gain\` |
69
- | What data files are indexed? | \`kirograph_data_list\` |
70
- | What columns does this dataset have? | \`kirograph_data_describe\` |
71
- | Query rows with filters | \`kirograph_data_query\` |
72
- | Aggregate data (sum, avg, count) | \`kirograph_data_aggregate\` |
73
- | Are there vulnerable dependencies? | \`kirograph_security\` |
74
- | Which CVEs affect my project? | \`kirograph_vulns\` |
75
- | Is this vulnerability reachable? | \`kirograph_reachability\` |
76
- | What licenses do my dependencies use? | \`kirograph_licenses\` |
77
- | Are dependencies outdated? | \`kirograph_staleness\` |
78
- | Generate SBOM/VEX | \`kirograph_sbom\` / \`kirograph_vex\` |
79
- | Add a private CVE | \`kirograph_vuln_add\` |
80
- | Find structural code patterns? | \`kirograph_live_search\` |
83
+ Compression level: **${level}**: ${LEVEL_DESCRIPTIONS[level]}
81
84
 
82
- ---
85
+ ${LEVEL_EXAMPLES[level]}
83
86
 
87
+ **Important:** Error details are always preserved. Failed commands show full diagnostic output regardless of level.
88
+
89
+ **Do NOT re-run commands:** When \\\`kirograph_exec\\\` returns a result, treat it as the final answer. Never re-run the same command with raw shell execution to "get more details." The compressed output preserves all essential information. If you genuinely need something missing from the output, explain what's missing before making a second call.
90
+
91
+ Use \\\`kirograph_gain\\\` to check token savings statistics.`;
92
+ }
93
+ function buildSteeringContent(opts) {
94
+ const cavemanMode = opts?.cavemanMode;
95
+ const enableCompression = opts?.enableCompression !== false && opts?.shellCompressionLevel !== "off";
96
+ const shellCompressionLevel = opts?.shellCompressionLevel ?? "normal";
97
+ const enableArchitecture = opts?.enableArchitecture ?? false;
98
+ const enableMemory = opts?.enableMemory ?? false;
99
+ const enableDocs = opts?.enableDocs ?? false;
100
+ const enableData = opts?.enableData ?? false;
101
+ const enableSecurity = opts?.enableSecurity ?? false;
102
+ const enablePatterns = opts?.enablePatterns ?? false;
103
+ const enableWiki = opts?.enableWiki ?? false;
104
+ const enableCodeHealth = opts?.enableCodeHealth ?? false;
105
+ const enableAdvancedAnalysis = opts?.enableAdvancedAnalysis ?? false;
106
+ const enableAgentUtils = opts?.enableAgentUtils ?? false;
107
+ const trackCallSites = opts?.trackCallSites ?? false;
108
+ const guideRows = [
109
+ "| Where do I start on this task? | `kirograph_context` |",
110
+ "| What is this symbol / show me its code | `kirograph_node` with `includeCode: true` |",
111
+ "| Find a symbol by name | `kirograph_search` |",
112
+ ...trackCallSites ? [
113
+ "| Who calls function X? | `kirograph_callers` |",
114
+ "| What does function X call? | `kirograph_callees` |"
115
+ ] : [],
116
+ "| What breaks if I change X? | `kirograph_impact` |",
117
+ "| How are X and Y connected? | `kirograph_path` |",
118
+ ...enableAdvancedAnalysis ? ["| What extends / implements this type? | `kirograph_type_hierarchy` |"] : [],
119
+ ...enableCodeHealth ? [
120
+ "| Which code is never called? | `kirograph_dead_code` |",
121
+ "| Are there import cycles? | `kirograph_circular_deps` |"
122
+ ] : [],
123
+ "| What files are indexed? | `kirograph_files` |",
124
+ "| Is the index healthy? | `kirograph_status` |",
125
+ ...enableCodeHealth ? [
126
+ "| What are the most critical symbols? | `kirograph_hotspots` |",
127
+ "| Any unexpected cross-module coupling? | `kirograph_surprising` |",
128
+ "| What changed since the last snapshot? | `kirograph_diff` |"
129
+ ] : [],
130
+ ...enableArchitecture ? [
131
+ "| What packages/layers exist? | `kirograph_architecture` |",
132
+ "| How coupled is package X? | `kirograph_coupling` |",
133
+ "| What does package X depend on? | `kirograph_package` |"
134
+ ] : [],
135
+ ...enableCompression ? ["| Run a command with token savings | `kirograph_exec` |"] : [],
136
+ ...enableAgentUtils ? ["| Check token savings stats | `kirograph_gain` |"] : [],
137
+ ...enableData ? [
138
+ "| What data files are indexed? | `kirograph_data_list` |",
139
+ "| What columns does this dataset have? | `kirograph_data_describe` |",
140
+ "| Query rows with filters | `kirograph_data_query` |",
141
+ "| Aggregate data (sum, avg, count) | `kirograph_data_aggregate` |"
142
+ ] : [],
143
+ ...enableSecurity ? [
144
+ "| Are there vulnerable dependencies? | `kirograph_security` |",
145
+ "| Which CVEs affect my project? | `kirograph_vulns` |",
146
+ "| Is this vulnerability reachable? | `kirograph_reachability` |",
147
+ "| What licenses do my dependencies use? | `kirograph_licenses` |",
148
+ "| Are dependencies outdated? | `kirograph_staleness` |",
149
+ "| Generate SBOM/VEX | `kirograph_sbom` / `kirograph_vex` |",
150
+ "| Add a private CVE | `kirograph_vuln_add` |"
151
+ ] : [],
152
+ ...enablePatterns ? ["| Find structural code patterns? | `kirograph_live_search` |"] : []
153
+ ];
154
+ let toolRef = `
84
155
  ## Tool reference
85
156
 
86
157
  ### \`kirograph_context\`: **start here for any code task**
@@ -112,7 +183,9 @@ Returns kind, file, signature, docstring. Add \`includeCode: true\` to get the f
112
183
  \`\`\`
113
184
  kirograph_node(symbol: "validateToken")
114
185
  kirograph_node(symbol: "AuthService", includeCode: true)
115
- \`\`\`
186
+ \`\`\``;
187
+ if (trackCallSites) {
188
+ toolRef += `
116
189
 
117
190
  ### \`kirograph_callers\`: who calls this?
118
191
 
@@ -128,7 +201,9 @@ BFS over outgoing \`calls\` edges (depth 1).
128
201
 
129
202
  \`\`\`
130
203
  kirograph_callees(symbol: "handleRequest")
131
- \`\`\`
204
+ \`\`\``;
205
+ }
206
+ toolRef += `
132
207
 
133
208
  ### \`kirograph_impact\`: blast radius before a change
134
209
 
@@ -144,7 +219,9 @@ BFS shortest path across all edge types.
144
219
 
145
220
  \`\`\`
146
221
  kirograph_path(from: "LoginController", to: "DatabasePool")
147
- \`\`\`
222
+ \`\`\``;
223
+ if (enableAdvancedAnalysis) {
224
+ toolRef += `
148
225
 
149
226
  ### \`kirograph_type_hierarchy\`: class/interface inheritance
150
227
 
@@ -152,7 +229,10 @@ kirograph_path(from: "LoginController", to: "DatabasePool")
152
229
  kirograph_type_hierarchy(symbol: "BaseRepository", direction: "down") // derived types
153
230
  kirograph_type_hierarchy(symbol: "PaymentService", direction: "up") // base types
154
231
  kirograph_type_hierarchy(symbol: "IUserStore", direction: "both") // all
155
- \`\`\`
232
+ \`\`\``;
233
+ }
234
+ if (enableCodeHealth) {
235
+ toolRef += `
156
236
 
157
237
  ### \`kirograph_dead_code\`: unreferenced symbols
158
238
 
@@ -168,7 +248,9 @@ Runs Tarjan's SCC over import edges. No parameters needed.
168
248
 
169
249
  \`\`\`
170
250
  kirograph_circular_deps()
171
- \`\`\`
251
+ \`\`\``;
252
+ }
253
+ toolRef += `
172
254
 
173
255
  ### \`kirograph_files\`: indexed file structure
174
256
 
@@ -182,7 +264,9 @@ kirograph_files(pattern: "**/*.test.ts")
182
264
 
183
265
  ### \`kirograph_status\`: index health
184
266
 
185
- Returns file count, symbol count, edge count, embedding coverage, DB size. Call when something feels off.
267
+ Returns file count, symbol count, edge count, embedding coverage, DB size. Call when something feels off.`;
268
+ if (enableCodeHealth) {
269
+ toolRef += `
186
270
 
187
271
  ### \`kirograph_hotspots\`: most-connected symbols
188
272
 
@@ -207,7 +291,10 @@ Compares the current graph against a saved snapshot. Shows added/removed symbols
207
291
  \`\`\`
208
292
  kirograph_diff() // vs latest snapshot
209
293
  kirograph_diff(snapshot: "pre-refactor") // vs named snapshot
210
- \`\`\`
294
+ \`\`\``;
295
+ }
296
+ if (enableArchitecture) {
297
+ toolRef += `
211
298
 
212
299
  ---
213
300
 
@@ -243,34 +330,63 @@ Returns metadata, coupling metrics, outgoing deps, incoming dependents, and file
243
330
  \`\`\`
244
331
  kirograph_package(package: "auth")
245
332
  kirograph_package(package: "src/services", includeFiles: false)
246
- \`\`\`
333
+ \`\`\``;
334
+ }
335
+ let bugFixWorkflow = `**Bug fix or feature:**
336
+ 1. \`kirograph_context\`: orient, find entry points.
337
+ 2. \`kirograph_node\` with \`includeCode: true\`: read the relevant symbol.`;
338
+ if (trackCallSites) {
339
+ bugFixWorkflow += `
340
+ 3. \`kirograph_callers\` / \`kirograph_callees\`: trace the call flow.
341
+ 4. \`kirograph_impact\`: check blast radius before editing.`;
342
+ } else {
343
+ bugFixWorkflow += `
344
+ 3. \`kirograph_impact\`: check blast radius before editing.`;
345
+ }
346
+ let workflows = `
247
347
 
248
348
  ---
249
349
 
250
350
  ## Workflows
251
351
 
252
- **Bug fix or feature:**
253
- 1. \`kirograph_context\`: orient, find entry points.
254
- 2. \`kirograph_node\` with \`includeCode: true\`: read the relevant symbol.
255
- 3. \`kirograph_callers\` / \`kirograph_callees\`: trace the call flow.
256
- 4. \`kirograph_impact\`: check blast radius before editing.
352
+ ${bugFixWorkflow}`;
353
+ if (enableCodeHealth) {
354
+ workflows += `
257
355
 
258
356
  **Refactor planning:**
259
357
  1. \`kirograph_hotspots\`: identify the most-connected symbols; changing these is risky.
260
358
  2. \`kirograph_surprising\`: surface hidden coupling that will break.
261
359
  3. \`kirograph_impact\` on specific targets: confirm blast radius.
262
- 4. \`kirograph_diff\` after the refactor: verify the structural change matches intent.
360
+ 4. \`kirograph_diff\` after the refactor: verify the structural change matches intent.`;
361
+ }
362
+ if (enableArchitecture) {
363
+ workflows += `
263
364
 
264
365
  **Architectural review:**
265
366
  1. \`kirograph_architecture\`: get the package and layer map.
266
367
  2. \`kirograph_coupling\`: find the most stable (high Ca) and most volatile (high instability) packages.
267
368
  3. \`kirograph_package\`: drill into any package of interest.
268
- 4. \`kirograph_circular_deps\`: check for import cycles.
369
+ 4. \`kirograph_circular_deps\`: check for import cycles.`;
370
+ }
371
+ if (enableCodeHealth) {
372
+ workflows += `
269
373
 
270
374
  **Code cleanup:**
271
375
  1. \`kirograph_dead_code\`: find unreferenced unexported symbols.
272
376
  2. \`kirograph_circular_deps\`: find import cycles to untangle.
273
- 3. \`kirograph_surprising\`: find unexpected coupling to decouple.
377
+ 3. \`kirograph_surprising\`: find unexpected coupling to decouple.`;
378
+ }
379
+ const workflowRows = [
380
+ ...enableSecurity ? ["| security audit, check vulnerabilities, CVE review | `.kiro/steering/kirograph-security.md` |"] : [],
381
+ "| code review, review this PR | `.kiro/steering/kirograph-review.md` |",
382
+ "| debug, trace this bug, root cause | `.kiro/steering/kirograph-debug.md` |",
383
+ ...enableArchitecture ? ["| architecture, understand structure, package map | `.kiro/steering/kirograph-architecture.md` |"] : [],
384
+ "| onboard, understand this codebase | `.kiro/steering/kirograph-onboard.md` |",
385
+ "| refactor, rename, safe refactoring | `.kiro/steering/kirograph-refactor.md` |",
386
+ ...enableMemory ? ["| memory, recall decisions, conflict detection | `.kiro/steering/kirograph-mem-workflow.md` |"] : [],
387
+ ...enableWiki ? ["| wiki, update knowledge base, ingest docs | `.kiro/steering/kirograph-wiki-workflow.md` |"] : []
388
+ ];
389
+ const workflowSection = `
274
390
 
275
391
  ---
276
392
 
@@ -289,12 +405,7 @@ Read file: .kiro/steering/kirograph-review.md
289
405
 
290
406
  | User intent | File to load |
291
407
  |-------------|-------------|
292
- | security audit, check vulnerabilities, CVE review | \`.kiro/steering/kirograph-security.md\` *(requires enableSecurity)* |
293
- | code review, review this PR | \`.kiro/steering/kirograph-review.md\` |
294
- | debug, trace this bug, root cause | \`.kiro/steering/kirograph-debug.md\` |
295
- | architecture, understand structure, package map | \`.kiro/steering/kirograph-architecture.md\` *(requires enableArchitecture)* |
296
- | onboard, understand this codebase | \`.kiro/steering/kirograph-onboard.md\` |
297
- | refactor, rename, safe refactoring | \`.kiro/steering/kirograph-refactor.md\` |
408
+ ${workflowRows.join("\n")}
298
409
 
299
410
  Each file contains numbered steps, exact tool calls, and an interpretation reference. Follow the steps in order.
300
411
 
@@ -302,69 +413,26 @@ Each file contains numbered steps, exact tool calls, and an interpretation refer
302
413
 
303
414
  ## If \`.kirograph/\` does NOT exist
304
415
 
305
- Ask the user: "This project doesn't have KiroGraph initialized. Run \`kirograph init -i\` to build a code knowledge graph for faster exploration?"
306
- `;
307
- const LEVEL_DESCRIPTIONS = {
308
- normal: "Balanced: removes noise, keeps structure.",
309
- aggressive: "Compact: groups by category, limits output.",
310
- ultra: "Maximum compression: counts and summaries only."
311
- };
312
- const LEVEL_EXAMPLES = {
313
- normal: `\\\`\\\`\\\`
314
- kirograph_exec(command: "git status")
315
- kirograph_exec(command: "npm test")
316
- kirograph_exec(command: "cargo build")
317
- kirograph_exec(command: "ls -la src/")
318
- \\\`\\\`\\\``,
319
- aggressive: `\\\`\\\`\\\`
320
- kirograph_exec(command: "git status", level: "aggressive")
321
- kirograph_exec(command: "npm test", level: "aggressive")
322
- kirograph_exec(command: "eslint .", level: "aggressive")
323
- kirograph_exec(command: "find . -name '*.ts'", level: "aggressive")
324
- \\\`\\\`\\\``,
325
- ultra: `\\\`\\\`\\\`
326
- kirograph_exec(command: "git status", level: "ultra")
327
- kirograph_exec(command: "npm test", level: "ultra")
328
- kirograph_exec(command: "docker ps", level: "ultra")
329
- kirograph_exec(command: "ls -la src/", level: "ultra")
330
- \\\`\\\`\\\``
331
- };
332
- function buildCompressionSection(level) {
333
- return `
416
+ Ask the user: "This project doesn't have KiroGraph initialized. Run \`kirograph init -i\` to build a code knowledge graph for faster exploration?"`;
417
+ let content = `---
418
+ inclusion: always
334
419
  ---
335
420
 
336
- ## Shell Compression (\\\`kirograph_exec\\\`)
337
-
338
- When running shell commands, prefer \\\`kirograph_exec\\\` over raw shell execution for:
339
- - **git** operations (status, log, diff, push, pull, commit, add, fetch, branch)
340
- - **GitHub CLI** (gh pr list/view, gh issue list, gh run list)
341
- - **test runners** (jest, vitest, pytest, cargo test, go test, rspec, minitest, playwright)
342
- - **linters/build** (eslint, tsc, ruff, clippy, cargo build, prettier, biome, golangci-lint, rubocop, next build)
343
- - **file listings** (ls, find, tree)
344
- - **search** (grep, rg/ripgrep: grouped by file)
345
- - **diff** (diff file1 file2: condensed context)
346
- - **docker/k8s** (docker ps, images, logs, compose ps, kubectl pods, logs, services)
347
- - **package managers** (npm/pnpm install/list, pip list/install, bundle install, prisma generate)
348
- - **AWS CLI** (sts, ec2, lambda, logs, cloudformation, dynamodb, iam, s3, ecs, sqs, sns)
349
- - **network** (curl, wget: strip progress bars and headers)
350
-
351
- This saves 60-90% of tokens compared to raw output.
352
-
353
- Compression level: **${level}**: ${LEVEL_DESCRIPTIONS[level]}
421
+ # KiroGraph
354
422
 
355
- ${LEVEL_EXAMPLES[level]}
423
+ KiroGraph builds a semantic knowledge graph of your codebase. Use its MCP tools instead of grep/glob/file reads whenever \`.kirograph/\` exists in the project.
356
424
 
357
- **Important:** Error details are always preserved. Failed commands show full diagnostic output regardless of level.
425
+ ## Quick decision guide
358
426
 
359
- **Do NOT re-run commands:** When \\\`kirograph_exec\\\` returns a result, treat it as the final answer. Never re-run the same command with raw shell execution to "get more details." The compressed output preserves all essential information. If you genuinely need something missing from the output, explain what's missing before making a second call.
427
+ | Question | Tool |
428
+ |----------|------|
429
+ ${guideRows.join("\n")}
360
430
 
361
- Use \\\`kirograph_gain\\\` to check token savings statistics.`;
362
- }
363
- function buildSteeringContent(opts) {
364
- const cavemanMode = opts?.cavemanMode;
365
- const enableCompression = opts?.enableCompression !== false && opts?.shellCompressionLevel !== "off";
366
- const shellCompressionLevel = opts?.shellCompressionLevel ?? "normal";
367
- let content = STEERING_CONTENT;
431
+ ---
432
+ ${toolRef}
433
+ ${workflows}
434
+ ${workflowSection}
435
+ `;
368
436
  if (enableCompression && shellCompressionLevel !== "off") {
369
437
  const section = buildCompressionSection(shellCompressionLevel);
370
438
  content = content.replace(
@@ -372,46 +440,44 @@ function buildSteeringContent(opts) {
372
440
  section.trim() + "\n\n---\n\n## If `.kirograph/` does NOT exist"
373
441
  );
374
442
  }
375
- if (!enableCompression) {
376
- content = content.replace("| Run a command with token savings | `kirograph_exec` |\n", "");
377
- content = content.replace("| Check token savings stats | `kirograph_gain` |\n", "");
378
- }
379
- if (!opts?.enableSecurity) {
380
- content = content.replace("| Are there vulnerable dependencies? | `kirograph_security` |\n", "");
381
- content = content.replace("| Which CVEs affect my project? | `kirograph_vulns` |\n", "");
382
- content = content.replace("| Is this vulnerability reachable? | `kirograph_reachability` |\n", "");
383
- content = content.replace("| What licenses do my dependencies use? | `kirograph_licenses` |\n", "");
384
- content = content.replace("| Are dependencies outdated? | `kirograph_staleness` |\n", "");
385
- content = content.replace("| Generate SBOM/VEX | `kirograph_sbom` / `kirograph_vex` |\n", "");
386
- content = content.replace("| Add a private CVE | `kirograph_vuln_add` |\n", "");
387
- }
388
- if (!opts?.enablePatterns) {
389
- content = content.replace("| Find structural code patterns? | `kirograph_live_search` |\n", "");
390
- }
391
443
  const caveman = cavemanMode && cavemanMode !== "off" ? import_caveman.CAVEMAN_RULES[cavemanMode] : null;
392
444
  if (caveman) {
393
445
  content = content.trimEnd() + "\n\n" + caveman + "\n";
394
446
  }
395
- if (opts?.enableMemory) {
447
+ if (enableMemory) {
396
448
  const memorySection = `
397
449
  ## Memory
398
450
 
399
- KiroGraph has persistent memory. Use \`kirograph_mem_search\` to recall past decisions,
400
- errors, and patterns before making changes. Use \`kirograph_mem_store\` to save important
401
- observations (architecture decisions, bug root causes, patterns discovered).
451
+ KiroGraph has persistent memory. Use it to recall past decisions and store new ones.
452
+
453
+ | Question | Tool |
454
+ |----------|------|
455
+ | What did we decide about X? | \`kirograph_mem_search\` |
456
+ | Store a decision / bug fix / pattern | \`kirograph_mem_store\` |
457
+ | Does this contradict something stored? | \`kirograph_mem_conflicts_scan\` |
458
+ | Two observations conflict \u2014 which wins? | \`kirograph_mem_compare\` \u2192 \`kirograph_mem_judge\` |
459
+ | Extract observations from structured text | \`kirograph_mem_capture\` |
460
+ | Which observations need re-evaluation? | \`kirograph_mem_review\` |
461
+ | Mark an observation as still valid | \`kirograph_mem_mark_reviewed\` |
402
462
 
403
- Memory is searchable via hybrid FTS + vector search. Observations are automatically
404
- linked to code symbols in the graph and surface in \`kirograph_context\` and
405
- \`kirograph_impact\` results when relevant.
463
+ Memory is searchable via hybrid FTS + vector search. Observations surface automatically in
464
+ \`kirograph_context\` and \`kirograph_impact\` results when linked to relevant code symbols.
406
465
 
407
466
  **When to store:** After fixing a bug, making an architecture decision, discovering a pattern,
408
- encountering a non-obvious error, or learning something about the codebase that future sessions
409
- should know. Keep observations concise \u2014 one fact per store call. A hook will also remind you
467
+ or learning something future sessions should know. One fact per store call. A hook reminds you
410
468
  at session end.
469
+
470
+ **topicKey:** Use a stable semantic key (e.g. \`"architecture/auth-model"\`) when storing a
471
+ decision that may be superseded or revisited. Lets you address the same concept across sessions.
472
+
473
+ **reviewAfter:** Pass an epoch-ms timestamp when an observation should expire or be re-evaluated
474
+ (e.g. after a planned migration, a library upgrade, or a time-boxed experiment).
475
+
476
+ For the full conflict-detection workflow, load: \`.kiro/steering/kirograph-mem-workflow.md\`
411
477
  `;
412
478
  content = content.trimEnd() + "\n\n" + memorySection.trim() + "\n";
413
479
  }
414
- if (opts?.enableDocs) {
480
+ if (enableDocs) {
415
481
  const docsSection = `
416
482
  ## Documentation
417
483
 
@@ -432,7 +498,7 @@ and gives you structured navigation instead of raw file content.
432
498
  `;
433
499
  content = content.trimEnd() + "\n\n" + docsSection.trim() + "\n";
434
500
  }
435
- if (opts?.enableData) {
501
+ if (enableData) {
436
502
  const dataSection = `
437
503
  ## Data
438
504
 
@@ -461,7 +527,7 @@ kirograph_data_aggregate(dataset: "data-orders", groupBy: ["region"], metrics: [
461
527
  `;
462
528
  content = content.trimEnd() + "\n\n" + dataSection.trim() + "\n";
463
529
  }
464
- if (opts?.enablePatterns) {
530
+ if (enablePatterns) {
465
531
  const patternsSection = `
466
532
  ## Pattern Matching
467
533
 
@@ -479,7 +545,39 @@ KiroGraph can search for structural code patterns using @ast-grep/napi.
479
545
  `;
480
546
  content = content.trimEnd() + "\n\n" + patternsSection.trim() + "\n";
481
547
  }
482
- if (opts?.enableSecurity) {
548
+ if (enableWiki) {
549
+ const wikiSection = `
550
+ ## Wiki
551
+
552
+ KiroGraph maintains a structured LLM wiki \u2014 a set of markdown pages that compound knowledge
553
+ across sessions. Use it to look up project decisions, architecture facts, and domain knowledge
554
+ before starting work. Use it to save knowledge that should survive context resets.
555
+
556
+ **Available tools:**
557
+ - \`kirograph_wiki_ingest\` \u2014 build an ingest prompt for a source text; pass the result to yourself to generate a WIKI_DIFF
558
+ - \`kirograph_wiki_apply_diff\` \u2014 apply a WIKI_DIFF to create or update wiki pages
559
+ - \`kirograph_wiki_search\` \u2014 full-text search over wiki pages
560
+ - \`kirograph_wiki_page\` \u2014 retrieve the full content of a page by slug
561
+ - \`kirograph_wiki_list\` \u2014 list all pages with metadata
562
+ - \`kirograph_wiki_lint\` \u2014 health check: broken links, orphan pages, contradictions
563
+
564
+ **When to consult the wiki:**
565
+ - Before starting a complex feature or bug fix: \`kirograph_wiki_search(query: "<topic>")\`
566
+ - When the user references a concept you don't recognize from the code graph alone
567
+ - After \`kirograph_context\` returns wiki enrichments (pages above threshold score)
568
+
569
+ **When to update the wiki:**
570
+ - End of a session that produced durable knowledge (architecture decision, API contract, process)
571
+ - The ingest hook will remind you at agentStop if \`enableWiki: true\` is set
572
+
573
+ **Quick workflow:**
574
+ 1. \`kirograph_wiki_ingest\` \u2014 get the prompt with SCHEMA + MANIFEST + your source text
575
+ 2. Generate a \`WIKI_DIFF\` block (create/upsert/append per page)
576
+ 3. \`kirograph_wiki_apply_diff\` \u2014 apply it; review any pending conflicts in the response
577
+ `;
578
+ content = content.trimEnd() + "\n\n" + wikiSection.trim() + "\n";
579
+ }
580
+ if (enableSecurity) {
483
581
  const securitySection = `
484
582
  ## Security
485
583
 
@@ -539,132 +637,139 @@ function writeSteering(kiroDir, opts) {
539
637
  writeWorkflowSteering(steeringDir, resolvedOpts);
540
638
  }
541
639
  function writeWorkflowSteering(steeringDir, opts) {
542
- const workflows = {
543
- "kirograph-review.md": `---
544
- inclusion: manual
545
- ---
546
-
547
- # KiroGraph: Code Review Workflow
548
-
549
- Follow these steps for a structured, risk-aware code review using the knowledge graph.
550
-
551
- ## Steps
552
-
553
- 1. **Understand the change scope**
640
+ const trackCallSites = opts?.trackCallSites ?? false;
641
+ const enableCodeHealth = opts?.enableCodeHealth ?? false;
642
+ const enableArchitecture = opts?.enableArchitecture ?? false;
643
+ const enableAdvancedAnalysis = opts?.enableAdvancedAnalysis ?? false;
644
+ const reviewSteps = [
645
+ `1. **Understand the change scope**
554
646
  \`\`\`
555
647
  kirograph_context(task: "<describe what changed>")
556
- \`\`\`
557
-
558
- 2. **Analyze blast radius**
648
+ \`\`\``,
649
+ `2. **Analyze blast radius**
559
650
  For each key symbol that was modified:
560
651
  \`\`\`
561
652
  kirograph_impact(symbol: "<changed symbol>", depth: 2)
562
- \`\`\`
563
-
564
- 3. **Check test coverage**
653
+ \`\`\``
654
+ ];
655
+ if (trackCallSites) {
656
+ reviewSteps.push(`3. **Check test coverage**
565
657
  \`\`\`
566
658
  kirograph_callers(symbol: "<changed symbol>")
567
659
  \`\`\`
568
- Look for test files among the callers. Flag untested changes.
569
-
570
- 4. **Look for surprising coupling**
660
+ Look for test files among the callers. Flag untested changes.`);
661
+ }
662
+ if (enableCodeHealth) {
663
+ const n = reviewSteps.length + 1;
664
+ reviewSteps.push(`${n}. **Look for surprising coupling**
571
665
  \`\`\`
572
666
  kirograph_surprising(limit: 10)
573
- \`\`\`
574
-
575
- 5. **Produce findings** grouped by risk level (high/medium/low) with:
667
+ \`\`\``);
668
+ }
669
+ const findingsN = reviewSteps.length + 1;
670
+ reviewSteps.push(`${findingsN}. **Produce findings** grouped by risk level (high/medium/low) with:
576
671
  - What changed and why it matters
577
672
  - Test coverage status
578
673
  - Suggested improvements
579
- - Overall merge recommendation
580
- `,
581
- "kirograph-debug.md": `---
674
+ - Overall merge recommendation`);
675
+ fs.writeFileSync(path.join(steeringDir, "kirograph-review.md"), `---
582
676
  inclusion: manual
583
677
  ---
584
678
 
585
- # KiroGraph: Debug Workflow
679
+ # KiroGraph: Code Review Workflow
586
680
 
587
- Follow these steps to systematically trace and debug issues using the knowledge graph.
681
+ Follow these steps for a structured, risk-aware code review using the knowledge graph.
588
682
 
589
683
  ## Steps
590
684
 
591
- 1. **Find related code**
685
+ ${reviewSteps.join("\n\n")}
686
+ `);
687
+ const debugSteps = [
688
+ `1. **Find related code**
592
689
  \`\`\`
593
690
  kirograph_search(query: "<error message or symptom keywords>")
594
- \`\`\`
595
-
596
- 2. **Get full context**
691
+ \`\`\``,
692
+ `2. **Get full context**
597
693
  \`\`\`
598
694
  kirograph_context(task: "<describe the bug>")
599
- \`\`\`
600
-
601
- 3. **Trace the call chain**
695
+ \`\`\``
696
+ ];
697
+ if (trackCallSites) {
698
+ debugSteps.push(`3. **Trace the call chain**
602
699
  \`\`\`
603
700
  kirograph_callers(symbol: "<suspected function>")
604
701
  kirograph_callees(symbol: "<suspected function>")
605
- \`\`\`
606
-
607
- 4. **Check what changed recently**
702
+ \`\`\``);
703
+ }
704
+ if (enableCodeHealth) {
705
+ const n = debugSteps.length + 1;
706
+ debugSteps.push(`${n}. **Check what changed recently**
608
707
  \`\`\`
609
708
  kirograph_diff()
610
- \`\`\`
611
-
612
- 5. **Understand blast radius**
709
+ \`\`\``);
710
+ }
711
+ const blastN = debugSteps.length + 1;
712
+ debugSteps.push(`${blastN}. **Understand blast radius**
613
713
  \`\`\`
614
714
  kirograph_impact(symbol: "<root cause symbol>", depth: 3)
615
- \`\`\`
616
-
617
- ## Tips
618
- - Check both callers and callees to understand the full context
619
- - Recent changes (via diff) are the most common source of new issues
620
- - Use \`kirograph_path\` to trace how two symbols are connected
621
- `,
622
- "kirograph-architecture.md": `---
715
+ \`\`\``);
716
+ const debugTips = [];
717
+ if (trackCallSites) debugTips.push("- Check both callers and callees to understand the full context");
718
+ if (enableCodeHealth) debugTips.push("- Recent changes (via diff) are the most common source of new issues");
719
+ debugTips.push("- Use `kirograph_path` to trace how two symbols are connected");
720
+ fs.writeFileSync(path.join(steeringDir, "kirograph-debug.md"), `---
623
721
  inclusion: manual
624
722
  ---
625
723
 
626
- # KiroGraph: Architecture Exploration Workflow
724
+ # KiroGraph: Debug Workflow
627
725
 
628
- Follow these steps to understand the high-level structure of the codebase.
726
+ Follow these steps to systematically trace and debug issues using the knowledge graph.
629
727
 
630
728
  ## Steps
631
729
 
632
- 1. **Get project overview**
633
- \`\`\`
634
- kirograph_status()
635
- \`\`\`
636
-
637
- 2. **View architecture**
638
- \`\`\`
639
- kirograph_architecture()
640
- \`\`\`
730
+ ${debugSteps.join("\n\n")}
641
731
 
642
- 3. **Check coupling health**
643
- \`\`\`
644
- kirograph_coupling(sortBy: "instability")
645
- \`\`\`
646
-
647
- 4. **Find core abstractions**
732
+ ## Tips
733
+ ${debugTips.join("\n")}
734
+ `);
735
+ const onboardSteps = [
736
+ `1. **Project overview**
648
737
  \`\`\`
649
- kirograph_hotspots(limit: 20)
738
+ kirograph_status()
739
+ \`\`\``,
740
+ `2. **File structure**
650
741
  \`\`\`
651
-
652
- 5. **Detect hidden dependencies**
742
+ kirograph_files(format: "tree", maxDepth: 2)
743
+ \`\`\``
744
+ ];
745
+ if (enableCodeHealth) {
746
+ onboardSteps.push(`3. **Key entry points**
653
747
  \`\`\`
654
- kirograph_surprising(limit: 15)
748
+ kirograph_hotspots(limit: 15)
749
+ \`\`\``);
750
+ }
751
+ if (enableArchitecture) {
752
+ const n = onboardSteps.length + 1;
753
+ onboardSteps.push(`${n}. **Architecture layers**
655
754
  \`\`\`
656
-
657
- 6. **Check for cycles**
755
+ kirograph_architecture()
756
+ \`\`\``);
757
+ }
758
+ const exploreN = onboardSteps.length + 1;
759
+ onboardSteps.push(`${exploreN}. **Explore a specific area**
658
760
  \`\`\`
659
- kirograph_circular_deps()
761
+ kirograph_context(task: "<area you want to understand>")
762
+ \`\`\``);
763
+ const symbolN = onboardSteps.length + 1;
764
+ onboardSteps.push(`${symbolN}. **Understand a key symbol**
660
765
  \`\`\`
661
-
662
- ## Interpretation
663
- - High Ca (afferent) = load-bearing, risky to change interface
664
- - High Ce (efferent) = depends on many things, safe to refactor internals
665
- - Surprising edges = hidden coupling that may break during refactoring
666
- `,
667
- "kirograph-onboard.md": `---
766
+ kirograph_node(symbol: "<symbol name>", includeCode: true)
767
+ \`\`\``);
768
+ const onboardTips = ["- Start broad (status, files) then narrow down"];
769
+ if (enableCodeHealth) onboardTips[0] = "- Start broad (status, files, hotspots) then narrow down";
770
+ if (enableAdvancedAnalysis) onboardTips.push("- Use `kirograph_type_hierarchy` to understand inheritance patterns");
771
+ if (trackCallSites) onboardTips.push("- Use `kirograph_callees` on entry points to trace execution flow");
772
+ fs.writeFileSync(path.join(steeringDir, "kirograph-onboard.md"), `---
668
773
  inclusion: manual
669
774
  ---
670
775
 
@@ -674,42 +779,49 @@ Follow these steps to quickly understand a new codebase.
674
779
 
675
780
  ## Steps
676
781
 
677
- 1. **Project overview**
678
- \`\`\`
679
- kirograph_status()
680
- \`\`\`
681
-
682
- 2. **File structure**
683
- \`\`\`
684
- kirograph_files(format: "tree", maxDepth: 2)
685
- \`\`\`
782
+ ${onboardSteps.join("\n\n")}
686
783
 
687
- 3. **Key entry points**
688
- \`\`\`
689
- kirograph_hotspots(limit: 15)
690
- \`\`\`
691
-
692
- 4. **Architecture layers**
784
+ ## Tips
785
+ ${onboardTips.join("\n")}
786
+ `);
787
+ const refactorSteps = [
788
+ `1. **Understand what you're changing**
693
789
  \`\`\`
694
- kirograph_architecture()
790
+ kirograph_node(symbol: "<target symbol>", includeCode: true)
791
+ \`\`\``,
792
+ `2. **Check blast radius**
695
793
  \`\`\`
696
-
697
- 5. **Explore a specific area**
794
+ kirograph_impact(symbol: "<target symbol>", depth: 3)
795
+ \`\`\``
796
+ ];
797
+ if (trackCallSites) {
798
+ refactorSteps.push(`3. **Find all callers (rename preview)**
698
799
  \`\`\`
699
- kirograph_context(task: "<area you want to understand>")
800
+ kirograph_callers(symbol: "<target symbol>", limit: 50)
801
+ \`\`\``);
802
+ }
803
+ if (enableCodeHealth) {
804
+ let n = refactorSteps.length + 1;
805
+ refactorSteps.push(`${n}. **Check for cycles that might complicate the refactor**
700
806
  \`\`\`
701
-
702
- 6. **Understand a key symbol**
807
+ kirograph_circular_deps()
808
+ \`\`\``);
809
+ n++;
810
+ refactorSteps.push(`${n}. **Find dead code to clean up**
703
811
  \`\`\`
704
- kirograph_node(symbol: "<symbol name>", includeCode: true)
812
+ kirograph_dead_code(limit: 30)
813
+ \`\`\``);
814
+ n++;
815
+ refactorSteps.push(`${n}. **Verify after changes**
816
+ Run \`kirograph sync\` then:
705
817
  \`\`\`
706
-
707
- ## Tips
708
- - Start broad (status, files, hotspots) then narrow down
709
- - Use \`kirograph_type_hierarchy\` to understand inheritance patterns
710
- - Use \`kirograph_callees\` on entry points to trace execution flow
711
- `,
712
- "kirograph-refactor.md": `---
818
+ kirograph_diff()
819
+ \`\`\``);
820
+ }
821
+ const refactorChecks = ["- Always check `kirograph_impact` before major refactors"];
822
+ if (trackCallSites) refactorChecks.push("- Use `kirograph_callers` as a rename preview (all locations that reference the symbol)");
823
+ if (enableCodeHealth) refactorChecks.push("- After changes, use `kirograph_diff` to verify only intended symbols changed");
824
+ fs.writeFileSync(path.join(steeringDir, "kirograph-refactor.md"), `---
713
825
  inclusion: manual
714
826
  ---
715
827
 
@@ -719,49 +831,59 @@ Follow these steps to plan and execute safe refactoring.
719
831
 
720
832
  ## Steps
721
833
 
722
- 1. **Understand what you're changing**
723
- \`\`\`
724
- kirograph_node(symbol: "<target symbol>", includeCode: true)
725
- \`\`\`
834
+ ${refactorSteps.join("\n\n")}
726
835
 
727
- 2. **Check blast radius**
836
+ ## Safety Checks
837
+ ${refactorChecks.join("\n")}
838
+ `);
839
+ if (enableArchitecture) {
840
+ const archSteps = [
841
+ `1. **Get project overview**
728
842
  \`\`\`
729
- kirograph_impact(symbol: "<target symbol>", depth: 3)
843
+ kirograph_status()
844
+ \`\`\``,
845
+ `2. **View architecture**
730
846
  \`\`\`
731
-
732
- 3. **Find all callers (rename preview)**
847
+ kirograph_architecture()
848
+ \`\`\``,
849
+ `3. **Check coupling health**
733
850
  \`\`\`
734
- kirograph_callers(symbol: "<target symbol>", limit: 50)
851
+ kirograph_coupling(sortBy: "instability")
852
+ \`\`\``
853
+ ];
854
+ if (enableCodeHealth) {
855
+ let n = archSteps.length + 1;
856
+ archSteps.push(`${n}. **Find core abstractions**
735
857
  \`\`\`
736
-
737
- 4. **Check for cycles that might complicate the refactor**
858
+ kirograph_hotspots(limit: 20)
859
+ \`\`\``);
860
+ n++;
861
+ archSteps.push(`${n}. **Detect hidden dependencies**
738
862
  \`\`\`
739
- kirograph_circular_deps()
863
+ kirograph_surprising(limit: 15)
864
+ \`\`\``);
865
+ n++;
866
+ archSteps.push(`${n}. **Check for cycles**
740
867
  \`\`\`
868
+ kirograph_circular_deps()
869
+ \`\`\``);
870
+ }
871
+ fs.writeFileSync(path.join(steeringDir, "kirograph-architecture.md"), `---
872
+ inclusion: manual
873
+ ---
741
874
 
742
- 5. **Find dead code to clean up**
743
- \`\`\`
744
- kirograph_dead_code(limit: 30)
745
- \`\`\`
875
+ # KiroGraph: Architecture Exploration Workflow
746
876
 
747
- 6. **Verify after changes**
748
- Run \`kirograph sync\` then:
749
- \`\`\`
750
- kirograph_diff()
751
- \`\`\`
877
+ Follow these steps to understand the high-level structure of the codebase.
752
878
 
753
- ## Safety Checks
754
- - Always check \`kirograph_impact\` before major refactors
755
- - Use \`kirograph_callers\` as a rename preview (all locations that reference the symbol)
756
- - After changes, use \`kirograph_diff\` to verify only intended symbols changed
757
- `
758
- };
759
- if (opts?.enableArchitecture) {
760
- fs.writeFileSync(path.join(steeringDir, "kirograph-architecture.md"), workflows["kirograph-architecture.md"]);
761
- }
762
- for (const [filename, content] of Object.entries(workflows)) {
763
- if (filename === "kirograph-architecture.md") continue;
764
- fs.writeFileSync(path.join(steeringDir, filename), content);
879
+ ## Steps
880
+
881
+ ${archSteps.join("\n\n")}
882
+
883
+ ## Interpretation
884
+ - High Ca (afferent) = load-bearing, risky to change interface
885
+ - High Ce (efferent) = depends on many things, safe to refactor internals
886
+ ${enableCodeHealth ? "- Surprising edges = hidden coupling that may break during refactoring\n" : ""}`);
765
887
  }
766
888
  if (opts?.enableSecurity) {
767
889
  fs.writeFileSync(path.join(steeringDir, "kirograph-security.md"), `---
@@ -907,10 +1029,230 @@ rule:
907
1029
  `);
908
1030
  console.log(` \u2713 Patterns workflow steering file written`);
909
1031
  }
1032
+ if (opts?.enableWiki) {
1033
+ fs.writeFileSync(path.join(steeringDir, "kirograph-wiki-workflow.md"), `---
1034
+ inclusion: manual
1035
+ ---
1036
+
1037
+ # KiroGraph: Wiki Workflow
1038
+
1039
+ Use this workflow when you need to consult or update the project wiki.
1040
+ Activate with \`/kirograph-wiki-workflow\` in Kiro IDE or read the file directly.
1041
+
1042
+ ## When to use
1043
+
1044
+ - Before a complex task: look up relevant wiki pages
1045
+ - After a session with durable knowledge: ingest it into the wiki
1046
+ - After a source file is added: run ingest to capture its content
1047
+ - Periodically: run lint to catch broken links or contradictions
1048
+
1049
+ ## Steps
1050
+
1051
+ ### 1. Look up existing knowledge before starting work
1052
+
1053
+ \`\`\`
1054
+ kirograph_wiki_search(query: "<topic or keyword>")
1055
+ \`\`\`
1056
+
1057
+ Read any relevant pages:
1058
+
1059
+ \`\`\`
1060
+ kirograph_wiki_page(slug: "<slug from search results>")
1061
+ \`\`\`
1062
+
1063
+ ### 2. Ingest new knowledge (two-tool flow)
1064
+
1065
+ **a. Get the ingest prompt:**
1066
+
1067
+ \`\`\`
1068
+ kirograph_wiki_ingest(source: "<text, notes, or paste from docs>", sourceName: "<descriptive name>")
1069
+ \`\`\`
1070
+
1071
+ The tool returns a structured prompt containing the wiki SCHEMA, the current MANIFEST, and your source text.
1072
+
1073
+ **b. Generate the WIKI_DIFF:**
1074
+
1075
+ Pass the returned prompt to yourself. Produce a \`WIKI_DIFF_START ... WIKI_DIFF_END\` block following the schema. Each entry should have a JSON header with \`action\`, \`slug\`, \`title\`, and \`section\` (optional), followed by markdown content.
1076
+
1077
+ **c. Apply the diff:**
1078
+
1079
+ \`\`\`
1080
+ kirograph_wiki_apply_diff(diff: "<the WIKI_DIFF block you generated>")
1081
+ \`\`\`
1082
+
1083
+ Review the response for any pending conflicts and resolve them.
1084
+
1085
+ ### 3. List all pages
1086
+
1087
+ \`\`\`
1088
+ kirograph_wiki_list()
1089
+ \`\`\`
1090
+
1091
+ ### 4. Health check (periodic)
1092
+
1093
+ \`\`\`
1094
+ kirograph_wiki_lint()
1095
+ \`\`\`
1096
+
1097
+ Issues to look for:
1098
+ - \`broken_link\`: a \`[[slug]]\` reference that points to a non-existent page \u2192 fix the slug or create the page
1099
+ - \`orphan\`: a page with no Related section and no incoming links \u2192 add Related or merge into another page
1100
+ - \`stale_source\`: a source with no date metadata \u2192 add a date to the source header
1101
+ - \`contradiction\`: two pages make semantically opposite claims \u2192 resolve via ingest or manual edit
1102
+
1103
+ ## WIKI_DIFF format reference
1104
+
1105
+ \`\`\`
1106
+ WIKI_DIFF_START
1107
+ {"action": "create", "slug": "auth-flow", "title": "Authentication Flow"}
1108
+ # Authentication Flow
1109
+
1110
+ The login flow validates credentials via JWT...
1111
+
1112
+ ## Related
1113
+ - [[user-model]]
1114
+ WIKI_DIFF_END
1115
+ \`\`\`
1116
+
1117
+ Supported actions: \`create\`, \`upsert\` (merge into existing), \`append\` (add to specific section).
1118
+
1119
+ For append, include \`"section": "Known Issues"\` in the header.
1120
+
1121
+ ## Conflict handling
1122
+
1123
+ If a diff contradicts an existing page, the tool reports it as a conflict:
1124
+ - With \`wikiAutoResolveConflicts: true\`: the newer source wins automatically
1125
+ - Without: the conflict is listed in the response \u2014 read both sides and ingest a resolution
1126
+
1127
+ ## CLI commands
1128
+
1129
+ \`\`\`bash
1130
+ kirograph wiki search "<query>"
1131
+ kirograph wiki page <slug>
1132
+ kirograph wiki list
1133
+ kirograph wiki lint
1134
+ kirograph wiki status
1135
+ kirograph wiki reindex
1136
+ \`\`\`
1137
+ `);
1138
+ console.log(` \u2713 Wiki workflow steering file written`);
1139
+ }
1140
+ if (opts?.enableMemory) {
1141
+ fs.writeFileSync(path.join(steeringDir, "kirograph-mem-workflow.md"), `---
1142
+ inclusion: manual
1143
+ ---
1144
+
1145
+ # KiroGraph: Memory Workflow
1146
+
1147
+ Use this workflow to recall past knowledge, store new observations, and keep the memory base
1148
+ consistent by detecting and resolving conflicts.
1149
+
1150
+ ## 1. Recall before acting
1151
+
1152
+ Before making an architecture decision or fixing a bug, search what's already known:
1153
+
1154
+ \`\`\`
1155
+ kirograph_mem_search(query: "<topic or keywords>", kind: "decision")
1156
+ kirograph_mem_search(query: "<error symptom>", kind: "error")
1157
+ \`\`\`
1158
+
1159
+ Results include inline conflict annotations (\u26A1) \u2014 review them before proceeding.
1160
+
1161
+ ## 2. Store a new observation
1162
+
1163
+ After a decision, bug fix, or discovery:
1164
+
1165
+ \`\`\`
1166
+ kirograph_mem_store(
1167
+ content: "<one concise fact>",
1168
+ kind: "decision" | "error" | "pattern" | "architecture" | "note",
1169
+ topicKey: "<category/slug>", // optional: stable semantic key for revisitable decisions
1170
+ reviewAfter: <epoch-ms> // optional: schedule re-evaluation after a migration/upgrade
1171
+ )
1172
+ \`\`\`
1173
+
1174
+ **topicKey examples:** \`"architecture/auth-model"\`, \`"infra/db-choice"\`, \`"pattern/error-handling"\`
1175
+
1176
+ ## 3. Capture observations from structured text
1177
+
1178
+ If you have a markdown block with bullet points under headings like \`## Key Learnings\` or
1179
+ \`## Decisions\`, extract them all at once:
1180
+
1181
+ \`\`\`
1182
+ kirograph_mem_capture(content: "<markdown text>", kind: "decision")
1183
+ \`\`\`
1184
+
1185
+ ## 4. Detect conflicts
1186
+
1187
+ After storing related observations, scan for potential contradictions:
1188
+
1189
+ \`\`\`
1190
+ kirograph_mem_conflicts_scan(limit: 20)
1191
+ \`\`\`
1192
+
1193
+ Returns candidate pairs ranked by similarity. Review each one.
1194
+
1195
+ ## 5. Compare two observations
1196
+
1197
+ To understand if two observations conflict, are compatible, or one supersedes the other:
1198
+
1199
+ \`\`\`
1200
+ kirograph_mem_compare(observationA: "<id or topicKey>", observationB: "<id or topicKey>")
1201
+ \`\`\`
1202
+
1203
+ Returns both observations side by side. Read them, then judge.
1204
+
1205
+ ## 6. Judge a relation
1206
+
1207
+ \`\`\`
1208
+ kirograph_mem_judge(
1209
+ relationId: "<id>",
1210
+ relation: "supersedes" | "conflicts_with" | "compatible" | "scoped" | "related" | "not_conflict",
1211
+ confidence: 0.0\u20131.0,
1212
+ reason: "<why>"
1213
+ )
1214
+ \`\`\`
1215
+
1216
+ Use \`supersedes\` when a newer decision replaces an older one. Use \`not_conflict\` to dismiss
1217
+ false positives so they don't reappear in scans.
1218
+
1219
+ ## 7. Review stale observations
1220
+
1221
+ Find observations scheduled for re-evaluation:
1222
+
1223
+ \`\`\`
1224
+ kirograph_mem_review(limit: 20)
1225
+ \`\`\`
1226
+
1227
+ For each: verify it's still accurate. If valid, mark it reviewed:
1228
+
1229
+ \`\`\`
1230
+ kirograph_mem_mark_reviewed(id: "<observation-id>")
1231
+ \`\`\`
1232
+
1233
+ If outdated, store a new observation with the correct information and judge the old one as
1234
+ superseded via \`kirograph_mem_judge\`.
1235
+
1236
+ ## Quick reference
1237
+
1238
+ | Situation | Action |
1239
+ |-----------|--------|
1240
+ | About to make a decision | \`mem_search\` first |
1241
+ | Made a decision | \`mem_store\` with \`kind: "decision"\` and \`topicKey\` |
1242
+ | Fixed a non-obvious bug | \`mem_store\` with \`kind: "error"\` |
1243
+ | Two things seem to contradict | \`mem_compare\` \u2192 \`mem_judge\` |
1244
+ | Knowledge base getting stale | \`mem_review\` \u2192 \`mem_mark_reviewed\` |
1245
+ | Structured notes to extract | \`mem_capture\` |
1246
+ | Regular conflict hygiene | \`mem_conflicts_scan\` |
1247
+ `);
1248
+ console.log(` \u2713 Memory workflow steering file written`);
1249
+ }
910
1250
  const written = ["review", "debug", "onboard", "refactor"];
911
1251
  if (opts?.enableArchitecture) written.push("architecture");
912
1252
  if (opts?.enableSecurity) written.push("security");
913
1253
  if (opts?.enablePatterns) written.push("patterns");
1254
+ if (opts?.enableMemory) written.push("memory");
1255
+ if (opts?.enableWiki) written.push("wiki");
914
1256
  console.log(` \u2713 Workflow steering files written (${written.join(", ")})`);
915
1257
  }
916
1258
  // Annotate the CommonJS export names for ESM import in node: