@vpxa/kb 0.1.23 → 0.1.25

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 (227) hide show
  1. package/README.md +3 -3
  2. package/package.json +9 -2
  3. package/packages/analyzers/dist/symbol-analyzer.js +5 -5
  4. package/packages/cli/dist/commands/init/adapters.js +1 -1
  5. package/packages/cli/dist/commands/init/constants.d.ts +4 -1
  6. package/packages/cli/dist/commands/init/constants.js +1 -1
  7. package/packages/cli/dist/commands/init/frontmatter.d.ts +54 -0
  8. package/packages/cli/dist/commands/init/frontmatter.js +2 -0
  9. package/packages/cli/dist/commands/init/index.js +4 -4
  10. package/packages/cli/dist/commands/init/manifest.d.ts +71 -0
  11. package/packages/cli/dist/commands/init/manifest.js +1 -0
  12. package/packages/cli/dist/commands/init/scaffold.d.ts +28 -5
  13. package/packages/cli/dist/commands/init/scaffold.js +1 -1
  14. package/packages/cli/dist/commands/init/templates.js +38 -9
  15. package/packages/cli/dist/commands/init/user.d.ts +1 -1
  16. package/packages/cli/dist/commands/init/user.js +4 -4
  17. package/packages/cli/dist/commands/system.js +2 -2
  18. package/packages/cli/dist/kb-init.js +1 -1
  19. package/packages/core/dist/errors.d.ts +2 -2
  20. package/packages/core/dist/errors.js +1 -1
  21. package/packages/core/dist/logger.d.ts +2 -1
  22. package/packages/core/dist/logger.js +1 -1
  23. package/packages/core/dist/types.d.ts +6 -0
  24. package/packages/dashboard/dist/assets/index-9ysCkze9.js +21 -0
  25. package/packages/dashboard/dist/assets/index-9ysCkze9.js.map +1 -0
  26. package/packages/dashboard/dist/assets/index-CHpVij2M.css +1 -0
  27. package/packages/dashboard/dist/index.html +18 -0
  28. package/packages/elicitation/dist/__tests__/build.test.d.ts +1 -0
  29. package/packages/elicitation/dist/__tests__/build.test.js +35 -0
  30. package/packages/elicitation/dist/__tests__/fields.test.d.ts +1 -0
  31. package/packages/elicitation/dist/__tests__/fields.test.js +81 -0
  32. package/packages/elicitation/dist/__tests__/normalize.test.d.ts +1 -0
  33. package/packages/elicitation/dist/__tests__/normalize.test.js +60 -0
  34. package/packages/elicitation/dist/build.d.ts +13 -0
  35. package/packages/elicitation/dist/build.js +23 -0
  36. package/packages/elicitation/dist/fields.d.ts +41 -0
  37. package/packages/elicitation/dist/fields.js +62 -0
  38. package/packages/elicitation/dist/index.d.ts +10 -0
  39. package/packages/elicitation/dist/index.js +12 -0
  40. package/packages/elicitation/dist/normalize.d.ts +15 -0
  41. package/packages/elicitation/dist/normalize.js +31 -0
  42. package/packages/elicitation/dist/types.d.ts +85 -0
  43. package/packages/elicitation/dist/types.js +8 -0
  44. package/packages/kb-client/dist/direct-client.d.ts +37 -0
  45. package/packages/kb-client/dist/direct-client.js +1 -0
  46. package/packages/kb-client/dist/index.d.ts +5 -0
  47. package/packages/kb-client/dist/index.js +1 -0
  48. package/packages/kb-client/dist/mcp-client.d.ts +19 -0
  49. package/packages/kb-client/dist/mcp-client.js +4 -0
  50. package/packages/kb-client/dist/parsers.d.ts +35 -0
  51. package/packages/kb-client/dist/parsers.js +2 -0
  52. package/packages/kb-client/dist/types.d.ts +62 -0
  53. package/packages/kb-client/dist/types.js +1 -0
  54. package/packages/present/dist/index.html +384 -0
  55. package/packages/server/dist/completions.d.ts +14 -0
  56. package/packages/server/dist/completions.js +1 -0
  57. package/packages/server/dist/config.js +1 -1
  58. package/packages/server/dist/dashboard-static.d.ts +27 -0
  59. package/packages/server/dist/dashboard-static.js +1 -0
  60. package/packages/server/dist/elicitor.d.ts +18 -0
  61. package/packages/server/dist/elicitor.js +1 -0
  62. package/packages/server/dist/index.js +1 -1
  63. package/packages/server/dist/mcp-logging.js +1 -1
  64. package/packages/server/dist/output-schemas.d.ts +118 -1
  65. package/packages/server/dist/output-schemas.js +1 -1
  66. package/packages/server/dist/prompts.d.ts +9 -2
  67. package/packages/server/dist/prompts.js +13 -6
  68. package/packages/server/dist/resources/curated-resources.js +1 -1
  69. package/packages/server/dist/resources/resource-notifier.d.ts +45 -0
  70. package/packages/server/dist/resources/resource-notifier.js +1 -0
  71. package/packages/server/dist/sampling.d.ts +41 -0
  72. package/packages/server/dist/sampling.js +2 -0
  73. package/packages/server/dist/server.d.ts +5 -2
  74. package/packages/server/dist/server.js +3 -1
  75. package/packages/server/dist/task-manager.d.ts +40 -0
  76. package/packages/server/dist/task-manager.js +1 -0
  77. package/packages/server/dist/tool-metadata.js +1 -1
  78. package/packages/server/dist/tool-prefix.d.ts +12 -0
  79. package/packages/server/dist/tool-prefix.js +1 -0
  80. package/packages/server/dist/tools/analyze.tools.js +4 -4
  81. package/packages/server/dist/tools/audit.tool.js +1 -1
  82. package/packages/server/dist/tools/brainstorm.tool.d.ts +7 -0
  83. package/packages/server/dist/tools/brainstorm.tool.js +9 -0
  84. package/packages/server/dist/tools/bridge.tools.js +1 -1
  85. package/packages/server/dist/tools/context.tools.js +9 -9
  86. package/packages/server/dist/tools/execution.tools.d.ts +2 -1
  87. package/packages/server/dist/tools/execution.tools.js +4 -3
  88. package/packages/server/dist/tools/forge.tools.js +10 -10
  89. package/packages/server/dist/tools/forget.tool.d.ts +2 -1
  90. package/packages/server/dist/tools/forget.tool.js +1 -1
  91. package/packages/server/dist/tools/graph.tool.js +2 -2
  92. package/packages/server/dist/tools/infra.tools.js +2 -2
  93. package/packages/server/dist/tools/list.tool.js +2 -2
  94. package/packages/server/dist/tools/lookup.tool.js +1 -1
  95. package/packages/server/dist/tools/manipulation.tools.js +4 -4
  96. package/packages/server/dist/tools/onboard.tool.js +2 -2
  97. package/packages/server/dist/tools/persistence.tools.js +4 -4
  98. package/packages/server/dist/tools/policy.tools.js +3 -2
  99. package/packages/server/dist/tools/present-blocks.d.ts +46 -0
  100. package/packages/server/dist/tools/present-blocks.js +27 -0
  101. package/packages/server/dist/tools/present-charts.d.ts +31 -0
  102. package/packages/server/dist/tools/present-charts.js +34 -0
  103. package/packages/server/dist/tools/present-theme.d.ts +14 -0
  104. package/packages/server/dist/tools/present-theme.js +395 -0
  105. package/packages/server/dist/tools/present-utils.d.ts +11 -0
  106. package/packages/server/dist/tools/present-utils.js +1 -0
  107. package/packages/server/dist/tools/present.tool.d.ts +7 -0
  108. package/packages/server/dist/tools/present.tool.js +113 -0
  109. package/packages/server/dist/tools/produce.tool.js +2 -2
  110. package/packages/server/dist/tools/read.tool.js +1 -1
  111. package/packages/server/dist/tools/reindex.tool.d.ts +2 -1
  112. package/packages/server/dist/tools/reindex.tool.js +2 -2
  113. package/packages/server/dist/tools/remember.tool.d.ts +2 -1
  114. package/packages/server/dist/tools/remember.tool.js +2 -2
  115. package/packages/server/dist/tools/replay.tool.js +2 -2
  116. package/packages/server/dist/tools/search.tool.d.ts +2 -1
  117. package/packages/server/dist/tools/search.tool.js +5 -4
  118. package/packages/server/dist/tools/status.tool.js +2 -2
  119. package/packages/server/dist/tools/update.tool.d.ts +2 -1
  120. package/packages/server/dist/tools/update.tool.js +1 -1
  121. package/packages/server/dist/tools/utility.tools.js +8 -8
  122. package/packages/store/dist/lance-store.d.ts +1 -0
  123. package/packages/store/dist/lance-store.js +1 -1
  124. package/packages/tools/dist/audit.js +1 -1
  125. package/packages/tools/dist/batch.js +1 -1
  126. package/packages/tools/dist/check.js +1 -1
  127. package/packages/tools/dist/checkpoint.js +1 -1
  128. package/packages/tools/dist/compact.js +2 -2
  129. package/packages/tools/dist/config-extractor.d.ts +9 -0
  130. package/packages/tools/dist/config-extractor.js +7 -0
  131. package/packages/tools/dist/dead-symbols.js +2 -2
  132. package/packages/tools/dist/diagram-builder.d.ts +9 -0
  133. package/packages/tools/dist/diagram-builder.js +9 -0
  134. package/packages/tools/dist/eval.js +2 -2
  135. package/packages/tools/dist/evidence-map.d.ts +12 -1
  136. package/packages/tools/dist/evidence-map.js +2 -2
  137. package/packages/tools/dist/file-summary.js +2 -2
  138. package/packages/tools/dist/find-examples.js +2 -2
  139. package/packages/tools/dist/forge-classify.d.ts +4 -0
  140. package/packages/tools/dist/forge-classify.js +1 -1
  141. package/packages/tools/dist/git-context.d.ts +1 -0
  142. package/packages/tools/dist/git-context.js +3 -3
  143. package/packages/tools/dist/index.d.ts +3 -2
  144. package/packages/tools/dist/index.js +1 -1
  145. package/packages/tools/dist/onboard-utils.d.ts +12 -0
  146. package/packages/tools/dist/onboard-utils.js +1 -0
  147. package/packages/tools/dist/onboard.js +2 -21
  148. package/packages/tools/dist/queue.js +1 -1
  149. package/packages/tools/dist/regex-utils.d.ts +8 -0
  150. package/packages/tools/dist/regex-utils.js +1 -0
  151. package/packages/tools/dist/rename.js +2 -2
  152. package/packages/tools/dist/replay.d.ts +2 -1
  153. package/packages/tools/dist/replay.js +4 -4
  154. package/packages/tools/dist/symbol.js +3 -3
  155. package/packages/tools/dist/synthesis-engine.d.ts +13 -0
  156. package/packages/tools/dist/synthesis-engine.js +6 -0
  157. package/packages/tools/dist/test-run.d.ts +3 -1
  158. package/packages/tools/dist/test-run.js +1 -1
  159. package/packages/tools/dist/trace.js +2 -2
  160. package/packages/tui/dist/App-DXY0-tlW.js +2 -0
  161. package/packages/tui/dist/App.d.ts +3 -3
  162. package/packages/tui/dist/App.js +1 -1
  163. package/packages/tui/dist/CuratedPanel-BIamXLNy.js +2 -0
  164. package/packages/tui/dist/LogPanel-D6u6o84n.js +3 -0
  165. package/packages/tui/dist/SearchPanel-CpJGczAc.js +2 -0
  166. package/packages/tui/dist/StatusPanel-BAbUxyqQ.js +2 -0
  167. package/packages/tui/dist/hooks/useKBClient.d.ts +9 -0
  168. package/packages/tui/dist/hooks/useKBClient.js +2 -0
  169. package/packages/tui/dist/hooks/usePolling.d.ts +8 -0
  170. package/packages/tui/dist/hooks/usePolling.js +2 -0
  171. package/packages/tui/dist/index.d.ts +6 -2
  172. package/packages/tui/dist/index.js +1 -1
  173. package/packages/tui/dist/jsx-runtime-y6Gdq5PZ.js +294 -0
  174. package/packages/tui/dist/panels/CuratedPanel.d.ts +1 -7
  175. package/packages/tui/dist/panels/CuratedPanel.js +1 -1
  176. package/packages/tui/dist/panels/LogPanel.js +1 -1
  177. package/packages/tui/dist/panels/SearchPanel.d.ts +1 -10
  178. package/packages/tui/dist/panels/SearchPanel.js +1 -1
  179. package/packages/tui/dist/panels/StatusPanel.d.ts +1 -7
  180. package/packages/tui/dist/panels/StatusPanel.js +1 -1
  181. package/packages/tui/dist/react-D__J1GQe.js +24 -0
  182. package/packages/tui/dist/types-VcTHNV6s.d.ts +64 -0
  183. package/packages/tui/dist/useKBClient-C35iA4uG.js +2 -0
  184. package/packages/tui/dist/usePolling-BbjnRWgx.js +2 -0
  185. package/scaffold/adapters/copilot.mjs +9 -81
  186. package/scaffold/definitions/agents.mjs +12 -0
  187. package/scaffold/definitions/bodies.mjs +39 -14
  188. package/scaffold/definitions/protocols.mjs +149 -0
  189. package/scaffold/definitions/tools.mjs +40 -5
  190. package/scaffold/general/agents/Architect-Reviewer-Alpha.agent.md +1 -1
  191. package/scaffold/general/agents/Architect-Reviewer-Beta.agent.md +1 -1
  192. package/scaffold/general/agents/Code-Reviewer-Alpha.agent.md +1 -1
  193. package/scaffold/general/agents/Code-Reviewer-Beta.agent.md +1 -1
  194. package/scaffold/general/agents/Debugger.agent.md +2 -2
  195. package/scaffold/general/agents/Documenter.agent.md +2 -2
  196. package/scaffold/general/agents/Explorer.agent.md +4 -3
  197. package/scaffold/general/agents/Frontend.agent.md +1 -1
  198. package/scaffold/general/agents/Implementer.agent.md +1 -1
  199. package/scaffold/general/agents/Orchestrator.agent.md +16 -1
  200. package/scaffold/general/agents/Planner.agent.md +11 -4
  201. package/scaffold/general/agents/Refactor.agent.md +1 -1
  202. package/scaffold/general/agents/Researcher-Alpha.agent.md +1 -1
  203. package/scaffold/general/agents/Researcher-Beta.agent.md +1 -1
  204. package/scaffold/general/agents/Researcher-Delta.agent.md +1 -1
  205. package/scaffold/general/agents/Researcher-Gamma.agent.md +1 -1
  206. package/scaffold/general/agents/Security.agent.md +10 -8
  207. package/scaffold/general/agents/_shared/architect-reviewer-base.md +1 -0
  208. package/scaffold/general/agents/_shared/code-agent-base.md +28 -0
  209. package/scaffold/general/agents/_shared/code-reviewer-base.md +1 -0
  210. package/scaffold/general/agents/_shared/forge-protocol.md +44 -0
  211. package/scaffold/general/agents/_shared/researcher-base.md +14 -0
  212. package/scaffold/general/agents/templates/adr-template.md +1 -0
  213. package/scaffold/general/agents/templates/execution-state.md +1 -0
  214. package/skills/knowledge-base/SKILL.md +19 -6
  215. package/skills/present/SKILL.md +153 -0
  216. package/packages/server/dist/tools/toolkit.tools.d.ts +0 -36
  217. package/packages/server/dist/tools/toolkit.tools.js +0 -20
  218. package/packages/tui/dist/App-DE_tdOhs.js +0 -2
  219. package/packages/tui/dist/CuratedPanel-sYdZAICX.js +0 -2
  220. package/packages/tui/dist/LogPanel-Ce3jMQbH.js +0 -3
  221. package/packages/tui/dist/SearchPanel-DREo6zgt.js +0 -2
  222. package/packages/tui/dist/StatusPanel-2ex8fLOO.js +0 -2
  223. package/packages/tui/dist/embedder.interface-IFCBpOlX.d.ts +0 -28
  224. package/packages/tui/dist/index-C8NmOF18.d.ts +0 -13
  225. package/packages/tui/dist/jsx-runtime-Cof-kwFn.js +0 -316
  226. package/packages/tui/dist/store.interface-CnY6SPOH.d.ts +0 -150
  227. /package/packages/tui/dist/{devtools-DUyj952l.js → devtools-DMOZMn70.js} +0 -0
package/README.md CHANGED
@@ -4,7 +4,7 @@ Local-first AI developer toolkit — knowledge base, code analysis, context mana
4
4
 
5
5
  ## Features
6
6
 
7
- - **64 MCP tools** for AI agents to search, analyze, and manipulate codebases
7
+ - **67 MCP tools** for AI agents to search, analyze, and manipulate codebases
8
8
  - **47 CLI commands** for shell-based interaction
9
9
  - **Local-first** — ONNX embeddings, LanceDB vector store, no cloud dependencies
10
10
  - **Three interfaces**: MCP (for agent IDEs), CLI (for terminal agents), and programmatic API
@@ -23,7 +23,7 @@ This is an **MCP (Model Context Protocol) server** that gives AI agents:
23
23
  8. **Graph auto-population** — during indexing, a lightweight regex extractor builds the knowledge graph automatically from TS/JS source files (functions, classes, interfaces, types, imports)
24
24
  9. **Optimized reindex** — full reindex skips redundant hash checks, batches graph writes (flush every 50 files), and skips per-file graph deletes when bulk-cleared
25
25
 
26
- The KB auto-indexes configured source directories on startup, stores embeddings in a local LanceDB vector store, and exposes everything through 64 MCP tools, 45 CLI commands, and 2 resources.
26
+ The KB auto-indexes configured source directories on startup, stores embeddings in a local LanceDB vector store, and exposes everything through 67 MCP tools, 45 CLI commands, and 2 resources.
27
27
 
28
28
  ---
29
29
 
@@ -348,7 +348,7 @@ kb init [--user|--workspace] [--force] [--guide]
348
348
  │ ├── chunker/ — tree-sitter + regex code chunking
349
349
  │ ├── indexer/ — incremental file indexer
350
350
  │ ├── analyzers/ — blast-radius, deps, symbols, patterns, diagrams
351
- │ ├── tools/ — 52 tool modules (64 MCP tools)
351
+ │ ├── tools/ — 55 tool modules (67 MCP tools)
352
352
  │ ├── server/ — MCP protocol server
353
353
  │ └── cli/ — command-line interface
354
354
  ├── bin/kb.mjs — CLI entry point
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpxa/kb",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "type": "module",
5
5
  "description": "Local-first AI developer toolkit — knowledge base, code analysis, context management, and developer tools for LLM agents",
6
6
  "license": "MIT",
@@ -23,6 +23,8 @@
23
23
  "bin/",
24
24
  "packages/*/dist/**/*.js",
25
25
  "packages/*/dist/**/*.d.ts",
26
+ "packages/dashboard/dist/**",
27
+ "packages/present/dist/**",
26
28
  "packages/chunker/wasm/*.wasm",
27
29
  "packages/chunker/src/queries/**/*.scm",
28
30
  "scaffold/",
@@ -44,6 +46,8 @@
44
46
  "dependencies": {
45
47
  "@huggingface/transformers": "^3.x",
46
48
  "@lancedb/lancedb": "^0.x",
49
+ "@mcp-ui/server": "^6.x",
50
+ "@modelcontextprotocol/ext-apps": "^1.x",
47
51
  "@modelcontextprotocol/sdk": "^1.x",
48
52
  "express": "^5.x",
49
53
  "linkedom": "^0.x",
@@ -56,16 +60,19 @@
56
60
  },
57
61
  "devDependencies": {
58
62
  "@biomejs/biome": "^2.x",
63
+ "@types/express": "^5.x",
59
64
  "@types/node": "^24.x",
60
65
  "rimraf": "^6.x",
61
66
  "tsdown": "^0.x",
62
67
  "turbo": "^2.x",
63
68
  "typescript": "^6.x",
69
+ "vite": "^8.x",
70
+ "vite-plugin-singlefile": "^2.x",
64
71
  "vitest": "^4.x",
65
72
  "ws": "^8.x"
66
73
  },
67
74
  "engines": {
68
- "node": ">=24"
75
+ "node": ">=18"
69
76
  },
70
77
  "scripts": {
71
78
  "build": "node scripts/build.mjs",
@@ -1,9 +1,9 @@
1
- import{readFile as e,readdir as t}from"node:fs/promises";import{extname as n,join as r,relative as i}from"node:path";import{SUPPORTED_EXTENSIONS as a,WasmRuntime as o,extractCalls as s,extractSymbols as c}from"../../chunker/dist/index.js";const l=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.java`,`.py`,`.go`,`.cs`,`.rb`,`.kt`,`.scala`,`.rs`,`.php`,`.swift`]),u=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,`__pycache__`,`.venv`,`target`,`bin`,`obj`,`.gradle`,`venv`,`env`]),d={exported:[{pattern:/^export\s+(?:async\s+)?function\s+(\w+)/gm,kind:`function`},{pattern:/^export\s+(?:default\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^export\s+interface\s+(\w+)/gm,kind:`interface`},{pattern:/^export\s+type\s+(\w+)/gm,kind:`type`},{pattern:/^export\s+(?:const|let)\s+(\w+)/gm,kind:`const`},{pattern:/^export\s+enum\s+(\w+)/gm,kind:`enum`}],local:[{pattern:/^(?:async\s+)?function\s+(\w+)/gm,kind:`function`},{pattern:/^class\s+(\w+)/gm,kind:`class`},{pattern:/^interface\s+(\w+)/gm,kind:`interface`},{pattern:/^type\s+(\w+)/gm,kind:`type`},{pattern:/^(?:const|let)\s+(\w+)\s*=/gm,kind:`const`},{pattern:/^enum\s+(\w+)/gm,kind:`enum`}]},f={exported:[{pattern:/^[ \t]*public\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*public\s+(?:static\s+)?interface\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*public\s+(?:static\s+)?enum\s+(\w+)/gm,kind:`enum`},{pattern:/^[ \t]*public\s+(?:static\s+)?(?:synchronized\s+)?(?:final\s+)?(?:abstract\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])*)\s+(\w+)\s*\(/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:synchronized\s+)?(?:final\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])*)\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:final\s+)?(?:\w+(?:<[^>]*>)?)\s+(\w+)\s*[;=]/gm,kind:`variable`}],skipIndentFilter:!0},p={exported:[{pattern:/^def\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^async\s+def\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^class\s+(\w+)/gm,kind:`class`}],local:[{pattern:/^[ \t]+def\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^[ \t]+async\s+def\s+(\w+)\s*\(/gm,kind:`function`}],skipIndentFilter:!0},m={exported:[{pattern:/^func\s+([A-Z]\w*)\s*\(/gm,kind:`function`},{pattern:/^func\s+\([^)]+\)\s+([A-Z]\w*)\s*\(/gm,kind:`function`},{pattern:/^type\s+([A-Z]\w*)\s+struct\b/gm,kind:`class`},{pattern:/^type\s+([A-Z]\w*)\s+interface\b/gm,kind:`interface`},{pattern:/^type\s+([A-Z]\w*)\s+/gm,kind:`type`}],local:[{pattern:/^func\s+([a-z]\w*)\s*\(/gm,kind:`function`},{pattern:/^func\s+\([^)]+\)\s+([a-z]\w*)\s*\(/gm,kind:`function`},{pattern:/^type\s+([a-z]\w*)\s+struct\b/gm,kind:`class`},{pattern:/^type\s+([a-z]\w*)\s+/gm,kind:`type`}],skipIndentFilter:!0},h={exported:[{pattern:/^[ \t]*public\s+(?:static\s+)?(?:partial\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*public\s+(?:static\s+)?interface\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*public\s+(?:static\s+)?enum\s+(\w+)/gm,kind:`enum`},{pattern:/^[ \t]*public\s+(?:static\s+)?(?:virtual\s+)?(?:override\s+)?(?:async\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])?)\s+(\w+)\s*\(/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|protected|internal)\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:private|protected|internal)\s+(?:static\s+)?(?:async\s+)?(?:\w+(?:<[^>]*>)?)\s+(\w+)\s*\(/gm,kind:`function`}],skipIndentFilter:!0},g={exported:[{pattern:/^(?:open\s+|data\s+|sealed\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^(?:fun|suspend\s+fun)\s+(\w+)\s*[(<]/gm,kind:`function`},{pattern:/^interface\s+(\w+)/gm,kind:`interface`},{pattern:/^object\s+(\w+)/gm,kind:`class`},{pattern:/^enum\s+class\s+(\w+)/gm,kind:`enum`}],local:[{pattern:/^[ \t]+(?:private|internal)\s+(?:fun|suspend\s+fun)\s+(\w+)/gm,kind:`function`},{pattern:/^[ \t]+(?:private|internal)\s+(?:val|var)\s+(\w+)/gm,kind:`variable`}],skipIndentFilter:!0},_={exported:[{pattern:/^class\s+(\w+)/gm,kind:`class`},{pattern:/^module\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]+def\s+self\.(\w+)/gm,kind:`function`}],local:[{pattern:/^[ \t]+def\s+(\w+)/gm,kind:`function`}],skipIndentFilter:!0},v={exported:[{pattern:/^pub\s+(?:async\s+)?fn\s+(\w+)/gm,kind:`function`},{pattern:/^pub\s+struct\s+(\w+)/gm,kind:`class`},{pattern:/^pub\s+trait\s+(\w+)/gm,kind:`interface`},{pattern:/^pub\s+enum\s+(\w+)/gm,kind:`enum`},{pattern:/^pub\s+type\s+(\w+)/gm,kind:`type`}],local:[{pattern:/^(?:async\s+)?fn\s+(\w+)/gm,kind:`function`},{pattern:/^struct\s+(\w+)/gm,kind:`class`},{pattern:/^trait\s+(\w+)/gm,kind:`interface`},{pattern:/^enum\s+(\w+)/gm,kind:`enum`}],skipIndentFilter:!0},y={exported:[{pattern:/^[ \t]*(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*interface\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*public\s+(?:static\s+)?function\s+(\w+)/gm,kind:`function`},{pattern:/^function\s+(\w+)\s*\(/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?function\s+(\w+)/gm,kind:`function`}],skipIndentFilter:!0},b={exported:[{pattern:/^[ \t]*(?:open|public)\s+class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:open|public)\s+struct\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:open|public)\s+protocol\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*(?:open|public)\s+enum\s+(\w+)/gm,kind:`enum`},{pattern:/^[ \t]*(?:open|public)\s+func\s+(\w+)/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|fileprivate|internal)\s+func\s+(\w+)/gm,kind:`function`},{pattern:/^[ \t]*(?:private|fileprivate|internal)\s+class\s+(\w+)/gm,kind:`class`}],skipIndentFilter:!0},x={exported:[{pattern:/^[ \t]*(?:case\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*object\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*trait\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*def\s+(\w+)/gm,kind:`function`}],local:[],skipIndentFilter:!0};function S(e){switch(e){case`.ts`:case`.tsx`:case`.js`:case`.jsx`:return d;case`.java`:return f;case`.py`:return p;case`.go`:return m;case`.cs`:return h;case`.kt`:return g;case`.rb`:return _;case`.rs`:return v;case`.php`:return y;case`.swift`:return b;case`.scala`:return x;default:return d}}function C(e,t){let n=``,r=0,i=!1;for(let a=t;a<Math.min(t+5,e.length);a++){let t=e[a].trim();n+=(n?` `:``)+t;for(let e of t)e===`(`&&(r++,i=!0),e===`)`&&r--;if(i&&r<=0)return n.replace(/\s*\{.*$/,``).replace(/\s*:\s*$/,``).trim()}return n.trim()||void 0}var w=class{name=`symbols`;async analyze(t,r={}){let{format:l=`markdown`,filter:u}=r,d=Date.now(),f=await this.collectFiles(t),p=[],m=[],h=!1;try{await o.ensure(),h=!0}catch{}for(let r of f){let o=await e(r,`utf-8`),l=i(t,r).replace(/\\/g,`/`),u=n(r);if(h&&a.has(u)){let e=await c(o,u,l);if(e.length>0){p.push(...e);let t=await s(o,u,l);m.push(...t)}else{let e=this.extractSymbolsRegex(o,l);p.push(...e)}}else{let e=this.extractSymbolsRegex(o,l);p.push(...e)}}if(u){let e=u.toLowerCase();p=p.filter(t=>t.name.toLowerCase().includes(e))}return{output:l===`json`?JSON.stringify(p,null,2):this.formatMarkdown(p,t,m),data:{symbols:p,byKind:this.groupByKind(p),exportedCount:p.filter(e=>e.exported).length,totalCount:p.length,callEdges:m},meta:{analyzedAt:new Date().toISOString(),scope:t,fileCount:f.length,durationMs:Date.now()-d}}}async collectFiles(e){let i=[],a=async e=>{let o=await t(e,{withFileTypes:!0});for(let t of o){if(u.has(t.name)||t.name.startsWith(`.`))continue;let o=r(e,t.name);t.isDirectory()?await a(o):l.has(n(t.name))&&i.push(o)}};return await a(e),i}extractSymbolsRegex(e,t){let r=[],i=e.split(`
2
- `),a=new Set,o=S(n(t));for(let{pattern:n,kind:s}of o.exported){let o=new RegExp(n.source,n.flags),c;for(;(c=o.exec(e))!==null;){let n=c[1];a.add(n);let o=e.slice(0,c.index).split(`
3
- `).length,l=s===`function`||s===`method`?C(i,o-1):void 0;r.push({name:n,kind:s,exported:!0,filePath:t,line:o,signature:l})}}for(let{pattern:n,kind:s}of o.local){let c=new RegExp(n.source,n.flags),l;for(;(l=c.exec(e))!==null;){let n=l[1];if(a.has(n))continue;if(!o.skipIndentFilter){let t=i[e.slice(0,l.index).split(`
1
+ import{readFile as e,readdir as t,stat as n}from"node:fs/promises";import{dirname as r,extname as i,join as a,relative as o}from"node:path";import{SUPPORTED_EXTENSIONS as s,WasmRuntime as c,extractCalls as l,extractSymbols as u}from"../../chunker/dist/index.js";const d=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.java`,`.py`,`.go`,`.cs`,`.rb`,`.kt`,`.scala`,`.rs`,`.php`,`.swift`]),f=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,`__pycache__`,`.venv`,`target`,`bin`,`obj`,`.gradle`,`venv`,`env`]),p={exported:[{pattern:/^export\s+(?:async\s+)?function\s+(\w+)/gm,kind:`function`},{pattern:/^export\s+(?:default\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^export\s+interface\s+(\w+)/gm,kind:`interface`},{pattern:/^export\s+type\s+(\w+)/gm,kind:`type`},{pattern:/^export\s+(?:const|let)\s+(\w+)/gm,kind:`const`},{pattern:/^export\s+enum\s+(\w+)/gm,kind:`enum`}],local:[{pattern:/^(?:async\s+)?function\s+(\w+)/gm,kind:`function`},{pattern:/^class\s+(\w+)/gm,kind:`class`},{pattern:/^interface\s+(\w+)/gm,kind:`interface`},{pattern:/^type\s+(\w+)/gm,kind:`type`},{pattern:/^(?:const|let)\s+(\w+)\s*=/gm,kind:`const`},{pattern:/^enum\s+(\w+)/gm,kind:`enum`}]},m={exported:[{pattern:/^[ \t]*public\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*public\s+(?:static\s+)?interface\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*public\s+(?:static\s+)?enum\s+(\w+)/gm,kind:`enum`},{pattern:/^[ \t]*public\s+(?:static\s+)?(?:synchronized\s+)?(?:final\s+)?(?:abstract\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])*)\s+(\w+)\s*\(/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:synchronized\s+)?(?:final\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])*)\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?(?:final\s+)?(?:\w+(?:<[^>]*>)?)\s+(\w+)\s*[;=]/gm,kind:`variable`}],skipIndentFilter:!0},h={exported:[{pattern:/^def\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^async\s+def\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^class\s+(\w+)/gm,kind:`class`}],local:[{pattern:/^[ \t]+def\s+(\w+)\s*\(/gm,kind:`function`},{pattern:/^[ \t]+async\s+def\s+(\w+)\s*\(/gm,kind:`function`}],skipIndentFilter:!0},g={exported:[{pattern:/^func\s+([A-Z]\w*)\s*\(/gm,kind:`function`},{pattern:/^func\s+\([^)]+\)\s+([A-Z]\w*)\s*\(/gm,kind:`function`},{pattern:/^type\s+([A-Z]\w*)\s+struct\b/gm,kind:`class`},{pattern:/^type\s+([A-Z]\w*)\s+interface\b/gm,kind:`interface`},{pattern:/^type\s+([A-Z]\w*)\s+/gm,kind:`type`}],local:[{pattern:/^func\s+([a-z]\w*)\s*\(/gm,kind:`function`},{pattern:/^func\s+\([^)]+\)\s+([a-z]\w*)\s*\(/gm,kind:`function`},{pattern:/^type\s+([a-z]\w*)\s+struct\b/gm,kind:`class`},{pattern:/^type\s+([a-z]\w*)\s+/gm,kind:`type`}],skipIndentFilter:!0},_={exported:[{pattern:/^[ \t]*public\s+(?:static\s+)?(?:partial\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*public\s+(?:static\s+)?interface\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*public\s+(?:static\s+)?enum\s+(\w+)/gm,kind:`enum`},{pattern:/^[ \t]*public\s+(?:static\s+)?(?:virtual\s+)?(?:override\s+)?(?:async\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])?)\s+(\w+)\s*\(/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|protected|internal)\s+(?:static\s+)?(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:private|protected|internal)\s+(?:static\s+)?(?:async\s+)?(?:\w+(?:<[^>]*>)?)\s+(\w+)\s*\(/gm,kind:`function`}],skipIndentFilter:!0},v={exported:[{pattern:/^(?:open\s+|data\s+|sealed\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^(?:fun|suspend\s+fun)\s+(\w+)\s*[(<]/gm,kind:`function`},{pattern:/^interface\s+(\w+)/gm,kind:`interface`},{pattern:/^object\s+(\w+)/gm,kind:`class`},{pattern:/^enum\s+class\s+(\w+)/gm,kind:`enum`}],local:[{pattern:/^[ \t]+(?:private|internal)\s+(?:fun|suspend\s+fun)\s+(\w+)/gm,kind:`function`},{pattern:/^[ \t]+(?:private|internal)\s+(?:val|var)\s+(\w+)/gm,kind:`variable`}],skipIndentFilter:!0},y={exported:[{pattern:/^class\s+(\w+)/gm,kind:`class`},{pattern:/^module\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]+def\s+self\.(\w+)/gm,kind:`function`}],local:[{pattern:/^[ \t]+def\s+(\w+)/gm,kind:`function`}],skipIndentFilter:!0},b={exported:[{pattern:/^pub\s+(?:async\s+)?fn\s+(\w+)/gm,kind:`function`},{pattern:/^pub\s+struct\s+(\w+)/gm,kind:`class`},{pattern:/^pub\s+trait\s+(\w+)/gm,kind:`interface`},{pattern:/^pub\s+enum\s+(\w+)/gm,kind:`enum`},{pattern:/^pub\s+type\s+(\w+)/gm,kind:`type`}],local:[{pattern:/^(?:async\s+)?fn\s+(\w+)/gm,kind:`function`},{pattern:/^struct\s+(\w+)/gm,kind:`class`},{pattern:/^trait\s+(\w+)/gm,kind:`interface`},{pattern:/^enum\s+(\w+)/gm,kind:`enum`}],skipIndentFilter:!0},x={exported:[{pattern:/^[ \t]*(?:abstract\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*interface\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*public\s+(?:static\s+)?function\s+(\w+)/gm,kind:`function`},{pattern:/^function\s+(\w+)\s*\(/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|protected)\s+(?:static\s+)?function\s+(\w+)/gm,kind:`function`}],skipIndentFilter:!0},S={exported:[{pattern:/^[ \t]*(?:open|public)\s+class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:open|public)\s+struct\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*(?:open|public)\s+protocol\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*(?:open|public)\s+enum\s+(\w+)/gm,kind:`enum`},{pattern:/^[ \t]*(?:open|public)\s+func\s+(\w+)/gm,kind:`function`}],local:[{pattern:/^[ \t]*(?:private|fileprivate|internal)\s+func\s+(\w+)/gm,kind:`function`},{pattern:/^[ \t]*(?:private|fileprivate|internal)\s+class\s+(\w+)/gm,kind:`class`}],skipIndentFilter:!0},C={exported:[{pattern:/^[ \t]*(?:case\s+)?class\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*object\s+(\w+)/gm,kind:`class`},{pattern:/^[ \t]*trait\s+(\w+)/gm,kind:`interface`},{pattern:/^[ \t]*def\s+(\w+)/gm,kind:`function`}],local:[],skipIndentFilter:!0};function w(e){switch(e){case`.ts`:case`.tsx`:case`.js`:case`.jsx`:return p;case`.java`:return m;case`.py`:return h;case`.go`:return g;case`.cs`:return _;case`.kt`:return v;case`.rb`:return y;case`.rs`:return b;case`.php`:return x;case`.swift`:return S;case`.scala`:return C;default:return p}}function T(e,t){let n=``,r=0,i=!1;for(let a=t;a<Math.min(t+5,e.length);a++){let t=e[a].trim();n+=(n?` `:``)+t;for(let e of t)e===`(`&&(r++,i=!0),e===`)`&&r--;if(i&&r<=0)return n.replace(/\s*\{.*$/,``).replace(/\s*:\s*$/,``).trim()}return n.trim()||void 0}var E=class{name=`symbols`;async analyze(t,n={}){let{format:a=`markdown`,filter:d}=n,f=Date.now(),p=await this.collectFiles(t),m=p.length===1&&p[0]===t?r(t):t,h=[],g=[],_=!1;try{await c.ensure(),_=!0}catch{}for(let t of p){let n=await e(t,`utf-8`),r=o(m,t).replace(/\\/g,`/`),a=i(t);if(_&&s.has(a)){let e=await u(n,a,r);if(e.length>0){h.push(...e);let t=await l(n,a,r);g.push(...t)}else{let e=this.extractSymbolsRegex(n,r);h.push(...e)}}else{let e=this.extractSymbolsRegex(n,r);h.push(...e)}}if(d){let e=d.toLowerCase();h=h.filter(t=>t.name.toLowerCase().includes(e))}return{output:a===`json`?JSON.stringify(h,null,2):this.formatMarkdown(h,m,g),data:{symbols:h,byKind:this.groupByKind(h),exportedCount:h.filter(e=>e.exported).length,totalCount:h.length,callEdges:g},meta:{analyzedAt:new Date().toISOString(),scope:t,fileCount:p.length,durationMs:Date.now()-f}}}async collectFiles(e){let r=[],o;try{o=await n(e)}catch{throw Error(`Path does not exist: ${e}`)}if(o.isFile()){if(d.has(i(e)))return[e];throw Error(`Not a recognized source file: ${e}`)}if(!o.isDirectory())throw Error(`Not a file or directory: ${e}`);let s=async e=>{let n=await t(e,{withFileTypes:!0});for(let t of n){if(f.has(t.name)||t.name.startsWith(`.`))continue;let n=a(e,t.name);t.isDirectory()?await s(n):d.has(i(t.name))&&r.push(n)}};return await s(e),r}extractSymbolsRegex(e,t){let n=[],r=e.split(`
2
+ `),a=new Set,o=w(i(t));for(let{pattern:i,kind:s}of o.exported){let o=new RegExp(i.source,i.flags),c;for(;(c=o.exec(e))!==null;){let i=c[1];a.add(i);let o=e.slice(0,c.index).split(`
3
+ `).length,l=s===`function`||s===`method`?T(r,o-1):void 0;n.push({name:i,kind:s,exported:!0,filePath:t,line:o,signature:l})}}for(let{pattern:i,kind:s}of o.local){let c=new RegExp(i.source,i.flags),l;for(;(l=c.exec(e))!==null;){let i=l[1];if(a.has(i))continue;if(!o.skipIndentFilter){let t=r[e.slice(0,l.index).split(`
4
4
  `).length-1]??``;if(t.startsWith(` `)||t.startsWith(` `))continue}let c=e.slice(0,l.index).split(`
5
- `).length,u=s===`function`||s===`method`?C(i,c-1):void 0;r.push({name:n,kind:s,exported:!1,filePath:t,line:c,signature:u})}}return r}groupByKind(e){let t={};for(let n of e)t[n.kind]=(t[n.kind]??0)+1;return t}formatMarkdown(e,t,n=[]){let r=[],i=e.filter(e=>e.exported).length;r.push(`## Symbols: ${t}\n`),r.push(`**${e.length} symbols** (${i} exported)\n`);let a={};for(let t of e)a[t.kind]=(a[t.kind]??0)+1;let o=Object.entries(a).sort((e,t)=>t[1]-e[1]).map(([e,t])=>`${t} ${e===`class`?`classes`:`${e}s`}`).join(`, `);r.push(`**Breakdown**: ${o}\n`);let s={};for(let t of e)s[t.filePath]||(s[t.filePath]=[]),s[t.filePath].push(t);r.push(`**${Object.keys(s).length} files** with symbols\n`);let c=0,l=Object.entries(s).sort((e,t)=>{let n=e[1].filter(e=>e.exported).length;return t[1].filter(e=>e.exported).length-n});for(let[e,t]of l){let n=t.filter(e=>e.exported);if(n.length===0)continue;let i=[`### ${e}\n`];for(let e of n){let t=e.signature?` — \`${e.signature}\``:``;i.push(`- 📤 \`${e.kind}\` **${e.name}** (line ${e.line})${t}`)}let a=t.length-n.length;a>0&&i.push(`- _${a} internal ${a===1?`symbol`:`symbols`}_`),i.push(``);let o=i.join(`
5
+ `).length,u=s===`function`||s===`method`?T(r,c-1):void 0;n.push({name:i,kind:s,exported:!1,filePath:t,line:c,signature:u})}}return n}groupByKind(e){let t={};for(let n of e)t[n.kind]=(t[n.kind]??0)+1;return t}formatMarkdown(e,t,n=[]){let r=[],i=e.filter(e=>e.exported).length;r.push(`## Symbols: ${t}\n`),r.push(`**${e.length} symbols** (${i} exported)\n`);let a={};for(let t of e)a[t.kind]=(a[t.kind]??0)+1;let o=Object.entries(a).sort((e,t)=>t[1]-e[1]).map(([e,t])=>`${t} ${e===`class`?`classes`:`${e}s`}`).join(`, `);r.push(`**Breakdown**: ${o}\n`);let s={};for(let t of e)s[t.filePath]||(s[t.filePath]=[]),s[t.filePath].push(t);r.push(`**${Object.keys(s).length} files** with symbols\n`);let c=0,l=Object.entries(s).sort((e,t)=>{let n=e[1].filter(e=>e.exported).length;return t[1].filter(e=>e.exported).length-n});for(let[e,t]of l){let n=t.filter(e=>e.exported);if(n.length===0)continue;let i=[`### ${e}\n`];for(let e of n){let t=e.signature?` — \`${e.signature}\``:``;i.push(`- 📤 \`${e.kind}\` **${e.name}** (line ${e.line})${t}`)}let a=t.length-n.length;a>0&&i.push(`- _${a} internal ${a===1?`symbol`:`symbols`}_`),i.push(``);let o=i.join(`
6
6
  `);if(c+=o.length,c>81920){r.push(`\n_Output truncated at 80KB. ${Object.keys(s).length-r.filter(e=>e.startsWith(`### `)).length} files omitted._`);break}r.push(o)}return n.length>0&&r.push(this.formatCallGraph(n)),r.join(`
7
7
  `)}formatCallGraph(e){let t=new Map;for(let n of e){if(n.callerName===`<module>`)continue;let e=`${n.callerFile}:${n.callerName}->${n.calleeName}`,r=t.get(e);r?r.count++:t.set(e,{callerFile:n.callerFile,callerName:n.callerName,calleeName:n.calleeName,count:1})}if(t.size===0)return``;let n=[];n.push(`### Call Graph Summary
8
8
  `),n.push(`**${e.length} call edges** across analyzed files\n`);let r=new Map;for(let e of t.values()){let t=`${e.callerFile}#${e.callerName}`;r.has(t)||r.set(t,[]),r.get(t)?.push(e.calleeName)}let i=[...r.entries()].sort((e,t)=>t[1].length-e[1].length).slice(0,30);for(let[e,t]of i){let[r,i]=e.split(`#`);n.push(`- **${i}** (${r}) → ${t.join(`, `)}`)}return n.push(``),n.join(`
9
- `)}};export{w as SymbolAnalyzer};
9
+ `)}};export{E as SymbolAnalyzer};
@@ -1 +1 @@
1
- import{MCP_SERVER_ENTRY as e}from"./constants.js";import{buildAgentsMd as t,buildCopilotInstructions as n}from"./templates.js";import{existsSync as r,mkdirSync as i,writeFileSync as a}from"node:fs";import{basename as o,resolve as s}from"node:path";function c(e){return r(s(e,`.cursor`))?`cursor`:r(s(e,`.claude`))?`claude-code`:r(s(e,`.windsurf`))?`windsurf`:`copilot`}function l(t){return{servers:{[t]:{...e}}}}function u(t){let{type:n,...r}=e;return{mcpServers:{[t]:r}}}const d={scaffoldDir:`general`,writeMcpConfig(e,t){let n=s(e,`.vscode`),o=s(n,`mcp.json`);r(o)||(i(n,{recursive:!0}),a(o,`${JSON.stringify(l(t),null,2)}\n`,`utf-8`),console.log(` Created .vscode/mcp.json`))},writeInstructions(e,t){let c=s(e,`.github`),l=s(c,`copilot-instructions.md`);r(l)||(i(c,{recursive:!0}),a(l,n(o(e),t),`utf-8`),console.log(` Created .github/copilot-instructions.md`))},writeAgentsMd(e,n){let i=s(e,`AGENTS.md`);r(i)||(a(i,t(o(e),n),`utf-8`),console.log(` Created AGENTS.md`))}},f={scaffoldDir:`general`,writeMcpConfig(e,t){let n=s(e,`.mcp.json`);r(n)||(a(n,`${JSON.stringify(u(t),null,2)}\n`,`utf-8`),console.log(` Created .mcp.json`))},writeInstructions(e,i){let c=s(e,`CLAUDE.md`);if(!r(c)){let r=o(e);a(c,`${n(r,i)}\n---\n\n${t(r,i)}`,`utf-8`),console.log(` Created CLAUDE.md`)}},writeAgentsMd(e,t){}},p={scaffoldDir:`general`,writeMcpConfig(e,t){let n=s(e,`.cursor`),o=s(n,`mcp.json`);r(o)||(i(n,{recursive:!0}),a(o,`${JSON.stringify(u(t),null,2)}\n`,`utf-8`),console.log(` Created .cursor/mcp.json`))},writeInstructions(e,c){let l=s(e,`.cursor`,`rules`),u=s(l,`kb.mdc`);if(!r(u)){i(l,{recursive:!0});let r=o(e);a(u,`${n(r,c)}\n---\n\n${t(r,c)}`,`utf-8`),console.log(` Created .cursor/rules/kb.mdc`)}},writeAgentsMd(e,t){}},m={scaffoldDir:`general`,writeMcpConfig(e,t){let n=s(e,`.vscode`),o=s(n,`mcp.json`);r(o)||(i(n,{recursive:!0}),a(o,`${JSON.stringify(l(t),null,2)}\n`,`utf-8`),console.log(` Created .vscode/mcp.json (Windsurf-compatible)`))},writeInstructions(e,i){let c=s(e,`.windsurfrules`);if(!r(c)){let r=o(e);a(c,`${n(r,i)}\n---\n\n${t(r,i)}`,`utf-8`),console.log(` Created .windsurfrules`)}},writeAgentsMd(e,t){}};function h(e){switch(e){case`copilot`:return d;case`claude-code`:return f;case`cursor`:return p;case`windsurf`:return m}}export{f as claudeCodeAdapter,d as copilotAdapter,p as cursorAdapter,c as detectIde,h as getAdapter,m as windsurfAdapter};
1
+ import{MCP_SERVER_ENTRY as e}from"./constants.js";import{buildAgentsMd as t,buildCopilotInstructions as n}from"./templates.js";import{existsSync as r,mkdirSync as i,writeFileSync as a}from"node:fs";import{basename as o,resolve as s}from"node:path";function c(e){return r(s(e,`.cursor`))?`cursor`:r(s(e,`.claude`))?`claude-code`:r(s(e,`.windsurf`))?`windsurf`:`copilot`}function l(t){return{servers:{[t]:{...e}}}}function u(t){let{type:n,...r}=e;return{mcpServers:{[t]:r}}}const d={scaffoldDir:`general`,writeMcpConfig(e,t){let n=s(e,`.vscode`),o=s(n,`mcp.json`);r(o)||(i(n,{recursive:!0}),a(o,`${JSON.stringify(l(t),null,2)}\n`,`utf-8`),console.log(` Created .vscode/mcp.json`))},writeInstructions(e,t){let r=s(e,`.github`),c=s(r,`copilot-instructions.md`);i(r,{recursive:!0}),a(c,n(o(e),t),`utf-8`),console.log(` Updated .github/copilot-instructions.md`)},writeAgentsMd(e,n){a(s(e,`AGENTS.md`),t(o(e),n),`utf-8`),console.log(` Updated AGENTS.md`)}},f={scaffoldDir:`general`,writeMcpConfig(e,t){let n=s(e,`.mcp.json`);r(n)||(a(n,`${JSON.stringify(u(t),null,2)}\n`,`utf-8`),console.log(` Created .mcp.json`))},writeInstructions(e,r){let i=s(e,`CLAUDE.md`),c=o(e);a(i,`${n(c,r)}\n---\n\n${t(c,r)}`,`utf-8`),console.log(` Updated CLAUDE.md`)},writeAgentsMd(e,t){}},p={scaffoldDir:`general`,writeMcpConfig(e,t){let n=s(e,`.cursor`),o=s(n,`mcp.json`);r(o)||(i(n,{recursive:!0}),a(o,`${JSON.stringify(u(t),null,2)}\n`,`utf-8`),console.log(` Created .cursor/mcp.json`))},writeInstructions(e,r){let c=s(e,`.cursor`,`rules`),l=s(c,`kb.mdc`);i(c,{recursive:!0});let u=o(e);a(l,`${n(u,r)}\n---\n\n${t(u,r)}`,`utf-8`),console.log(` Updated .cursor/rules/kb.mdc`)},writeAgentsMd(e,t){}},m={scaffoldDir:`general`,writeMcpConfig(e,t){let n=s(e,`.vscode`),o=s(n,`mcp.json`);r(o)||(i(n,{recursive:!0}),a(o,`${JSON.stringify(l(t),null,2)}\n`,`utf-8`),console.log(` Created .vscode/mcp.json (Windsurf-compatible)`))},writeInstructions(e,r){let i=s(e,`.windsurfrules`),c=o(e);a(i,`${n(c,r)}\n---\n\n${t(c,r)}`,`utf-8`),console.log(` Updated .windsurfrules`)},writeAgentsMd(e,t){}};function h(e){switch(e){case`copilot`:return d;case`claude-code`:return f;case`cursor`:return p;case`windsurf`:return m}}export{f as claudeCodeAdapter,d as copilotAdapter,p as cursorAdapter,c as detectIde,h as getAdapter,m as windsurfAdapter};
@@ -13,7 +13,7 @@ declare const MCP_SERVER_ENTRY: {
13
13
  readonly args: readonly ["-y", "@vpxa/kb", "serve"];
14
14
  };
15
15
  /** Skills shipped with the KB package and installed during init. */
16
- declare const SKILL_NAMES: readonly ["knowledge-base", "brainstorming", "session-handoff", "requirements-clarity", "lesson-learned", "c4-architecture", "adr-skill"];
16
+ declare const SKILL_NAMES: readonly ["knowledge-base", "brainstorming", "session-handoff", "requirements-clarity", "lesson-learned", "c4-architecture", "adr-skill", "present"];
17
17
  /**
18
18
  * VS Code settings merged into each VS Code-family IDE's settings.json.
19
19
  *
@@ -30,6 +30,9 @@ declare const SKILL_NAMES: readonly ["knowledge-base", "brainstorming", "session
30
30
  * session-handoff, etc.) — without this, skills never activate.
31
31
  * - switchAgent: Orchestrator uses the switchAgent tool to hand off to Plan —
32
32
  * without this, agent switching is unavailable.
33
+ * - enableChatTools: Enables integrated-browser tools (openBrowserPage,
34
+ * readPage, screenshotPage, etc.) so agents can open and interact with
35
+ * web pages inside VS Code's built-in browser.
33
36
  */
34
37
  declare const VSCODE_SETTINGS: Record<string, unknown>;
35
38
  //#endregion
@@ -1 +1 @@
1
- const e=`knowledge-base`,t={type:`stdio`,command:`npx`,args:[`-y`,`@vpxa/kb`,`serve`]},n=[`knowledge-base`,`brainstorming`,`session-handoff`,`requirements-clarity`,`lesson-learned`,`c4-architecture`,`adr-skill`],r={"chat.agentFilesLocations":{"~/.claude/agents":!1},"github.copilot.chat.copilotMemory.enabled":!0,"chat.customAgentInSubagent.enabled":!0,"chat.useNestedAgentsMdFiles":!0,"chat.useAgentSkills":!0,"github.copilot.chat.switchAgent.enabled":!0};export{t as MCP_SERVER_ENTRY,e as SERVER_NAME,n as SKILL_NAMES,r as VSCODE_SETTINGS};
1
+ const e=`knowledge-base`,t={type:`stdio`,command:`npx`,args:[`-y`,`@vpxa/kb`,`serve`]},n=[`knowledge-base`,`brainstorming`,`session-handoff`,`requirements-clarity`,`lesson-learned`,`c4-architecture`,`adr-skill`,`present`],r={"chat.agentFilesLocations":{"~/.claude/agents":!1},"github.copilot.chat.copilotMemory.enabled":!0,"chat.customAgentInSubagent.enabled":!0,"chat.useNestedAgentsMdFiles":!0,"chat.useAgentSkills":!0,"github.copilot.chat.switchAgent.enabled":!0,"workbench.browser.enableChatTools":!0};export{t as MCP_SERVER_ENTRY,e as SERVER_NAME,n as SKILL_NAMES,r as VSCODE_SETTINGS};
@@ -0,0 +1,54 @@
1
+ //#region packages/cli/src/commands/init/frontmatter.d.ts
2
+ /**
3
+ * Init module — YAML frontmatter parsing and merging for agent files.
4
+ *
5
+ * Agent `.agent.md` files use YAML frontmatter with fields like `tools`, `model`,
6
+ * `description`, and `argument-hint`. When updating these files, we need to
7
+ * merge new tools while preserving user customizations (model choice, extra tools).
8
+ *
9
+ * This is a lightweight parser — no full YAML dependency. It handles the specific
10
+ * frontmatter format used by Copilot agent files.
11
+ */
12
+ interface ParsedFrontmatter {
13
+ /** Raw key-value pairs from YAML frontmatter. */
14
+ fields: Record<string, string>;
15
+ /** Parsed tools array (from YAML inline array syntax). */
16
+ tools: string[];
17
+ /** Body content after the closing `---`. */
18
+ body: string;
19
+ }
20
+ /**
21
+ * Parse a markdown file with YAML frontmatter.
22
+ *
23
+ * Expects format:
24
+ * ```
25
+ * ---
26
+ * key: value
27
+ * tools: [tool1, tool2]
28
+ * ---
29
+ * body content
30
+ * ```
31
+ */
32
+ declare function parseFrontmatter(content: string): ParsedFrontmatter;
33
+ /**
34
+ * Parse a YAML inline array: `[tool1, tool2, tool3]` → string[]
35
+ */
36
+ declare function parseToolsArray(value: string): string[];
37
+ /**
38
+ * Serialize tools array back to YAML inline syntax.
39
+ */
40
+ declare function serializeToolsArray(tools: string[]): string;
41
+ /**
42
+ * Merge two parsed frontmatter files (source = new upstream, deployed = user's current).
43
+ *
44
+ * Merge rules:
45
+ * - `tools`: UNION of both arrays (add new, keep user-added). Order: source first, then user extras.
46
+ * - `model`: KEEP deployed (user's choice).
47
+ * - `description`, `argument-hint`: TAKE from source (upstream updates).
48
+ * - Body: TAKE from source (structural changes come from upstream).
49
+ *
50
+ * Returns the merged file content as a string.
51
+ */
52
+ declare function mergeFrontmatter(sourceContent: string, deployedContent: string): string;
53
+ //#endregion
54
+ export { ParsedFrontmatter, mergeFrontmatter, parseFrontmatter, parseToolsArray, serializeToolsArray };
@@ -0,0 +1,2 @@
1
+ function e(e){let n={},r=[],i=e,a=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!a)return{fields:n,tools:r,body:i};let o=a[1];i=a[2];for(let e of o.split(/\r?\n/)){let i=e.match(/^(\S+?):\s*(.*)$/);if(!i)continue;let[,a,o]=i;n[a]=o,a===`tools`&&(r=t(o))}return{fields:n,tools:r,body:i}}function t(e){let t=e.trim();if(!t.startsWith(`[`)||!t.endsWith(`]`))return[];let n=t.slice(1,-1).trim();return n?n.split(`,`).map(e=>e.trim()).filter(Boolean):[]}function n(e){return`[${e.join(`, `)}]`}function r(t,r){let i=e(t),a=e(r),o={...i.fields};a.fields.model&&(o.model=a.fields.model);let s=new Set(i.tools),c=a.tools.filter(e=>!s.has(e));o.tools=n([...i.tools,...c]);let l=[`---`],u=[`description`,`argument-hint`,`tools`,`model`],d=new Set;for(let e of u)e in o&&(l.push(`${e}: ${o[e]}`),d.add(e));for(let[e,t]of Object.entries(o))d.has(e)||l.push(`${e}: ${t}`);return l.push(`---`),`${l.join(`
2
+ `)}\n${i.body}`}export{r as mergeFrontmatter,e as parseFrontmatter,t as parseToolsArray,n as serializeToolsArray};
@@ -1,5 +1,5 @@
1
- import{SKILL_NAMES as e}from"./constants.js";import{detectIde as t,getAdapter as n}from"./adapters.js";import{ensureGitignore as r,getServerName as i,writeKbConfig as a}from"./config.js";import{createCuratedDirs as o}from"./curated.js";import{copyScaffold as s,copySkills as c,guideScaffold as l,guideSkills as u}from"./scaffold.js";import{dirname as d,resolve as f}from"node:path";import{fileURLToPath as p}from"node:url";import{isUserInstalled as m}from"../../../../core/dist/index.js";async function h(l){let u=process.cwd();if(!a(u,l.force))return;r(u);let h=i(),g=n(t(u));g.writeMcpConfig(u,h),g.writeInstructions(u,h),g.writeAgentsMd(u,h);let _=f(d(p(import.meta.url)),`..`,`..`,`..`,`..`,`..`);c(u,_,[...e],l.force),s(u,_,g.scaffoldDir,l.force),o(u),console.log(`
2
- Knowledge base initialized! Next steps:`),console.log(` kb reindex Index your codebase`),console.log(` kb search Search indexed content`),console.log(` kb serve Start MCP server for IDE integration`),m()&&console.log(`
3
- Note: User-level KB is also installed. This workspace uses its own local data store.`)}async function g(e){m()?await _(e):await h(e)}async function _(e){let a=process.cwd(),c=i(),l=n(t(a));l.writeInstructions(a,c),l.writeAgentsMd(a,c),s(a,f(d(p(import.meta.url)),`..`,`..`,`..`,`..`,`..`),l.scaffoldDir,e.force),o(a),r(a),console.log(`
1
+ import{SKILL_NAMES as e}from"./constants.js";import{detectIde as t,getAdapter as n}from"./adapters.js";import{ensureGitignore as r,getServerName as i,writeKbConfig as a}from"./config.js";import{createCuratedDirs as o}from"./curated.js";import{guideScaffold as s,guideSkills as c,smartCopyScaffold as l,smartCopySkills as u}from"./scaffold.js";import{readFileSync as d}from"node:fs";import{dirname as f,resolve as p}from"node:path";import{fileURLToPath as m}from"node:url";import{isUserInstalled as h}from"../../../../core/dist/index.js";async function g(s){let c=process.cwd();if(!a(c,s.force))return;r(c);let g=i(),_=n(t(c));_.writeMcpConfig(c,g),_.writeInstructions(c,g),_.writeAgentsMd(c,g);let v=p(f(m(import.meta.url)),`..`,`..`,`..`,`..`,`..`),y=JSON.parse(d(p(v,`package.json`),`utf-8`)).version;u(c,v,[...e],y,s.force),l(c,v,_.scaffoldDir,y,s.force),o(c),console.log(`
2
+ Knowledge base initialized! Next steps:`),console.log(` kb reindex Index your codebase`),console.log(` kb search Search indexed content`),console.log(` kb serve Start MCP server for IDE integration`),h()&&console.log(`
3
+ Note: User-level KB is also installed. This workspace uses its own local data store.`)}async function _(e){h()?await v(e):await g(e)}async function v(e){let a=process.cwd(),s=i(),c=n(t(a));c.writeInstructions(a,s),c.writeAgentsMd(a,s);let u=p(f(m(import.meta.url)),`..`,`..`,`..`,`..`,`..`),h=JSON.parse(d(p(u,`package.json`),`utf-8`)).version;l(a,u,c.scaffoldDir,h,e.force),o(a),r(a),console.log(`
4
4
  Workspace scaffolded for user-level KB! Files added:`),console.log(` Instruction files (AGENTS.md, copilot-instructions.md, etc.)`),console.log(` .ai/curated/ directories`),console.log(` .github/agents/ & .github/prompts/`),console.log(`
5
- The user-level KB server will auto-index this workspace when opened in your IDE.`)}async function v(){let r=process.cwd(),i=n(t(r)),a=f(d(p(import.meta.url)),`..`,`..`,`..`,`..`,`..`),o=[...u(r,a,[...e]),...l(r,a,i.scaffoldDir)],s={summary:{total:o.length,new:o.filter(e=>e.status===`new`).length,outdated:o.filter(e=>e.status===`outdated`).length,current:o.filter(e=>e.status===`current`).length},files:o};console.log(JSON.stringify(s,null,2))}export{v as guideProject,h as initProject,g as initSmart};
5
+ The user-level KB server will auto-index this workspace when opened in your IDE.`)}async function y(){let r=process.cwd(),i=n(t(r)),a=p(f(m(import.meta.url)),`..`,`..`,`..`,`..`,`..`),o=[...c(r,a,[...e]),...s(r,a,i.scaffoldDir)],l={summary:{total:o.length,new:o.filter(e=>e.status===`new`).length,outdated:o.filter(e=>e.status===`outdated`).length,current:o.filter(e=>e.status===`current`).length},files:o};console.log(JSON.stringify(l,null,2))}export{y as guideProject,g as initProject,_ as initSmart};
@@ -0,0 +1,71 @@
1
+ //#region packages/cli/src/commands/init/manifest.d.ts
2
+ /**
3
+ * Init module — scaffold manifest for smart updates.
4
+ *
5
+ * Tracks which scaffold files have been deployed and their source hashes,
6
+ * enabling incremental updates that preserve user customizations while
7
+ * applying new features from upstream.
8
+ *
9
+ * Manifest file: `.kb-scaffold.json` stored alongside the scaffold root
10
+ * (e.g. `~/.copilot/.kb-scaffold.json` for user-level, `.github/.kb-scaffold.json` for workspace).
11
+ */
12
+ /**
13
+ * How a file should be updated when the source changes:
14
+ *
15
+ * - `overwrite`: Replace entirely (shared protocols, templates, skills).
16
+ * - `merge-frontmatter`: Merge YAML frontmatter tools (union), keep user model,
17
+ * replace body. Used for agent .md files that users may customize.
18
+ * - `regenerate`: Re-run the template generator (copilot-instructions.md, CLAUDE.md).
19
+ */
20
+ type UpdateStrategy = 'overwrite' | 'merge-frontmatter' | 'regenerate';
21
+ interface ManifestEntry {
22
+ /** SHA-256 hash (16-char hex) of the source content when deployed. */
23
+ sourceHash: string;
24
+ /** Update strategy for this file. */
25
+ strategy: UpdateStrategy;
26
+ /** ISO timestamp of last deployment. */
27
+ updatedAt: string;
28
+ }
29
+ interface ScaffoldManifest {
30
+ /** Package version that generated this manifest. */
31
+ version: string;
32
+ /** ISO timestamp of manifest creation/update. */
33
+ generatedAt: string;
34
+ /** File entries keyed by relative path from scaffold root. */
35
+ files: Record<string, ManifestEntry>;
36
+ }
37
+ /** Compute a 16-char hex SHA-256 hash of content (consistent with file-hasher). */
38
+ declare function hashContent(content: string): string;
39
+ /** Read and parse a manifest file; returns null if missing or invalid. */
40
+ declare function readManifest(manifestPath: string): ScaffoldManifest | null;
41
+ /** Write a manifest to disk. */
42
+ declare function writeManifest(manifestPath: string, manifest: ScaffoldManifest): void;
43
+ /**
44
+ * Determine the update strategy for a file based on its relative path.
45
+ *
46
+ * Strategy rules:
47
+ * - `*.agent.md` (not under `_shared/`) → merge-frontmatter
48
+ * - `_shared/*.md`, `templates/*.md` → overwrite
49
+ * - `*.prompt.md`, `SKILL.md`, `README.md` → overwrite
50
+ * - Everything else → overwrite
51
+ */
52
+ declare function getUpdateStrategy(relativePath: string): UpdateStrategy;
53
+ /**
54
+ * Check whether a deployed file needs updating.
55
+ *
56
+ * Returns:
57
+ * - `'new'`: File not in manifest (first deployment).
58
+ * - `'outdated'`: Source hash changed since last deployment.
59
+ * - `'current'`: Source hash matches — no update needed.
60
+ */
61
+ declare function getFileStatus(manifest: ScaffoldManifest | null, relativePath: string, sourceContent: string): 'new' | 'outdated' | 'current';
62
+ /**
63
+ * Record a file deployment in the manifest.
64
+ */
65
+ declare function recordDeployment(manifest: ScaffoldManifest, relativePath: string, sourceContent: string, strategy?: UpdateStrategy): void;
66
+ /**
67
+ * Create a fresh manifest for a new deployment.
68
+ */
69
+ declare function createManifest(version: string): ScaffoldManifest;
70
+ //#endregion
71
+ export { ManifestEntry, ScaffoldManifest, UpdateStrategy, createManifest, getFileStatus, getUpdateStrategy, hashContent, readManifest, recordDeployment, writeManifest };
@@ -0,0 +1 @@
1
+ import{existsSync as e,readFileSync as t,writeFileSync as n}from"node:fs";import{createHash as r}from"node:crypto";function i(e){return r(`sha256`).update(e).digest(`hex`).slice(0,16)}function a(n){if(!e(n))return null;try{let e=t(n,`utf-8`),r=JSON.parse(e);return!r.version||!r.files?null:r}catch{return null}}function o(e,t){n(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function s(e){return e.endsWith(`.agent.md`)&&!e.startsWith(`_shared/`)&&!e.startsWith(`agents/_shared/`)&&!e.startsWith(`templates/`)?`merge-frontmatter`:`overwrite`}function c(e,t,n){if(!e)return`new`;let r=e.files[t];return r?r.sourceHash===i(n)?`current`:`outdated`:`new`}function l(e,t,n,r){e.files[t]={sourceHash:i(n),strategy:r??s(t),updatedAt:new Date().toISOString()}}function u(e){return{version:e,generatedAt:new Date().toISOString(),files:{}}}export{u as createManifest,c as getFileStatus,s as getUpdateStrategy,i as hashContent,a as readManifest,l as recordDeployment,o as writeManifest};
@@ -1,8 +1,6 @@
1
+ import { ScaffoldManifest } from "./manifest.js";
2
+
1
3
  //#region packages/cli/src/commands/init/scaffold.d.ts
2
- /**
3
- * Init module — scaffold file copying.
4
- * Copies agent, prompt, and skill files from the package scaffold into the workspace.
5
- */
6
4
  interface GuideFileEntry {
7
5
  status: 'new' | 'outdated' | 'current';
8
6
  relativePath: string;
@@ -11,6 +9,31 @@ interface GuideFileEntry {
11
9
  }
12
10
  /** Recursively copy a directory. When force=false, skip files that already exist. */
13
11
  declare function copyDirectoryRecursive(srcDir: string, destDir: string, logPrefix?: string, force?: boolean): void;
12
+ /**
13
+ * Manifest-aware recursive copy with per-file merge strategies.
14
+ *
15
+ * For each file:
16
+ * - `new`: Deploy and record in manifest.
17
+ * - `outdated` + `overwrite` strategy: Replace entirely.
18
+ * - `outdated` + `merge-frontmatter`: Merge tools (union), keep user model, update body.
19
+ * - `current`: Skip (source unchanged).
20
+ * - `force=true`: Always overwrite (resets manifest entry).
21
+ */
22
+ declare function smartCopyDirectory(srcDir: string, destDir: string, manifest: ScaffoldManifest, logPrefix?: string, force?: boolean): void;
23
+ /**
24
+ * Smart-copy scaffold files with manifest tracking.
25
+ * Reads/creates manifest at `<destRoot>/.kb-scaffold.json`.
26
+ */
27
+ declare function smartCopyScaffold(cwd: string, pkgRoot: string, ide: string, version: string, force?: boolean): void;
28
+ /**
29
+ * Smart-copy skill files with manifest tracking.
30
+ */
31
+ declare function smartCopySkills(cwd: string, pkgRoot: string, skillNames: string[], version: string, force?: boolean): void;
32
+ /**
33
+ * Smart-copy a directory with a standalone manifest (for user-level scaffold).
34
+ * Manifest stored at `<destRoot>/.kb-scaffold.json`.
35
+ */
36
+ declare function smartCopySubdir(srcDir: string, destRoot: string, subdir: string, version: string, force?: boolean): void;
14
37
  /** Copy scaffold files for a given IDE into the workspace .github/ directory. */
15
38
  declare function copyScaffold(cwd: string, pkgRoot: string, ide: string, force?: boolean): void;
16
39
  /** Copy skill directories from the package into .github/skills/. */
@@ -20,4 +43,4 @@ declare function guideScaffold(cwd: string, pkgRoot: string, ide: string): Guide
20
43
  /** Generate guide report for skill files — compare source vs destination. */
21
44
  declare function guideSkills(cwd: string, pkgRoot: string, skillNames: string[]): GuideFileEntry[];
22
45
  //#endregion
23
- export { GuideFileEntry, copyDirectoryRecursive, copyScaffold, copySkills, guideScaffold, guideSkills };
46
+ export { GuideFileEntry, copyDirectoryRecursive, copyScaffold, copySkills, guideScaffold, guideSkills, smartCopyDirectory, smartCopyScaffold, smartCopySkills, smartCopySubdir };
@@ -1 +1 @@
1
- import{copyFileSync as e,existsSync as t,mkdirSync as n,readFileSync as r,readdirSync as i,statSync as a}from"node:fs";import{resolve as o}from"node:path";function s(r,c,l=``,u=!1){n(c,{recursive:!0});for(let n of i(r)){let i=o(r,n),d=o(c,n),f=l?`${l}/${n}`:n;a(i).isDirectory()?s(i,d,f,u):(u||!t(d))&&e(i,d)}}function c(e,n,s,l){if(t(e))for(let u of i(e)){let i=o(e,u),d=s?`${s}/${u}`:u;if(a(i).isDirectory())c(i,o(n,u),d,l);else{let e=o(n,u),a=r(i,`utf-8`);t(e)?a===r(e,`utf-8`)?l.push({status:`current`,relativePath:d,sourcePath:i}):l.push({status:`outdated`,relativePath:d,sourcePath:i,content:a}):l.push({status:`new`,relativePath:d,sourcePath:i,content:a})}}}function l(e,n,r,i=!1){let a=o(n,`scaffold`,r);for(let n of[`agents`,`prompts`]){let r=o(a,n),c=o(e,`.github`,n);t(r)&&s(r,c,``,i)}}function u(e,n,r,i=!1){for(let a of r){let r=o(n,`skills`,a);t(r)&&s(r,o(e,`.github`,`skills`,a),`skills/${a}`,i)}}function d(e,t,n){let r=[],i=o(t,`scaffold`,n);for(let t of[`agents`,`prompts`])c(o(i,t),o(e,`.github`,t),t,r);return r}function f(e,n,r){let i=[];for(let a of r){let r=o(n,`skills`,a);t(r)&&c(r,o(e,`.github`,`skills`,a),`skills/${a}`,i)}return i}export{s as copyDirectoryRecursive,l as copyScaffold,u as copySkills,d as guideScaffold,f as guideSkills};
1
+ import{mergeFrontmatter as e}from"./frontmatter.js";import{createManifest as t,getFileStatus as n,getUpdateStrategy as r,readManifest as i,recordDeployment as a,writeManifest as o}from"./manifest.js";import{copyFileSync as s,existsSync as c,mkdirSync as l,readFileSync as u,readdirSync as d,statSync as f,writeFileSync as p}from"node:fs";import{dirname as m,resolve as h}from"node:path";function g(e,t,n=``,r=!1){l(t,{recursive:!0});for(let i of d(e)){let a=h(e,i),o=h(t,i),l=n?`${n}/${i}`:i;f(a).isDirectory()?g(a,o,l,r):(r||!c(o))&&s(a,o)}}function _(t,i,o,s=``,g=!1){if(c(t)){l(i,{recursive:!0});for(let v of d(t)){let d=h(t,v),y=h(i,v),b=s?`${s}/${v}`:v;if(f(d).isDirectory()){_(d,y,o,b,g);continue}let x=u(d,`utf-8`);if(g){l(m(y),{recursive:!0}),p(y,x,`utf-8`),a(o,b,x);continue}let S=n(o,b,x);if(S!==`current`){if(S===`new`&&!c(y)){l(m(y),{recursive:!0}),p(y,x,`utf-8`),a(o,b,x);continue}if(S===`new`&&c(y)){a(o,b,x);continue}r(b)===`merge-frontmatter`&&c(y)?p(y,e(x,u(y,`utf-8`)),`utf-8`):(l(m(y),{recursive:!0}),p(y,x,`utf-8`)),a(o,b,x)}}}}function v(e,n,r,a,s=!1){let l=h(n,`scaffold`,r),u=h(e,`.github`),d=h(u,`.kb-scaffold.json`),f=i(d)??t(a);f.version=a;for(let e of[`agents`,`prompts`]){let t=h(l,e);c(t)&&_(t,h(u,e),f,e,s)}o(d,f)}function y(e,n,r,a,s=!1){let l=h(e,`.github`),u=h(l,`.kb-scaffold.json`),d=i(u)??t(a);d.version=a;for(let e of r){let t=h(n,`skills`,e);c(t)&&_(t,h(l,`skills`,e),d,`skills/${e}`,s)}o(u,d)}function b(e,n,r,a,s=!1){let l=h(e,r);if(!c(l))return;let u=h(n,r),d=h(n,`.kb-scaffold.json`),f=i(d)??t(a);f.version=a,_(l,u,f,r,s),o(d,f)}function x(e,t,n,r){if(c(e))for(let i of d(e)){let a=h(e,i),o=n?`${n}/${i}`:i;if(f(a).isDirectory())x(a,h(t,i),o,r);else{let e=h(t,i),n=u(a,`utf-8`);c(e)?n===u(e,`utf-8`)?r.push({status:`current`,relativePath:o,sourcePath:a}):r.push({status:`outdated`,relativePath:o,sourcePath:a,content:n}):r.push({status:`new`,relativePath:o,sourcePath:a,content:n})}}}function S(e,t,n,r=!1){let i=h(t,`scaffold`,n);for(let t of[`agents`,`prompts`]){let n=h(i,t),a=h(e,`.github`,t);c(n)&&g(n,a,``,r)}}function C(e,t,n,r=!1){for(let i of n){let n=h(t,`skills`,i);c(n)&&g(n,h(e,`.github`,`skills`,i),`skills/${i}`,r)}}function w(e,t,n){let r=[],i=h(t,`scaffold`,n);for(let t of[`agents`,`prompts`])x(h(i,t),h(e,`.github`,t),t,r);return r}function T(e,t,n){let r=[];for(let i of n){let n=h(t,`skills`,i);c(n)&&x(n,h(e,`.github`,`skills`,i),`skills/${i}`,r)}return r}export{g as copyDirectoryRecursive,S as copyScaffold,C as copySkills,w as guideScaffold,T as guideSkills,_ as smartCopyDirectory,v as smartCopyScaffold,y as smartCopySkills,b as smartCopySubdir};
@@ -1,6 +1,6 @@
1
1
  function e(e,t){return`# ${e} — Copilot Instructions
2
2
 
3
- This project has an MCP server (\`${t}\`) providing 64 tools for search, analysis, memory, and validation.
3
+ This project has an MCP server (\`${t}\`) providing 67 tools for search, analysis, memory, and validation.
4
4
  **These tools REPLACE most native IDE tools.** You MUST use them.
5
5
 
6
6
  ## Step 0: Load KB Tools
@@ -8,7 +8,7 @@ This project has an MCP server (\`${t}\`) providing 64 tools for search, analysi
8
8
  Before doing ANYTHING else, load the KB MCP tools. They are deferred — you must load them first.
9
9
  Search for tools matching the server name (e.g. \`knowledge-bas\`):
10
10
  \`\`\`
11
- tool_search_tool_regex({ pattern: "knowledge-bas" }) // loads all 64 KB tools
11
+ tool_search_tool_regex({ pattern: "knowledge-bas" }) // loads all 67 KB tools
12
12
  \`\`\`
13
13
  Once loaded, KB tools appear as \`mcp_<server>_<tool>\` (e.g. \`mcp_knowledge-bas_search\`).
14
14
 
@@ -26,6 +26,8 @@ Once loaded, KB tools appear as \`mcp_<server>_<tool>\` (e.g. \`mcp_knowledge-ba
26
26
  | \`run_in_terminal\` for test | \`test_run({})\` | Run tests with structured output |
27
27
  | Manual code tracing | \`trace({ symbol, direction })\` | AST call-graph traversal |
28
28
  | Line counting / wc | \`measure({ path })\` | Lines, functions, cognitive complexity |
29
+ | \`fetch_webpage\` | \`web_fetch({ url })\` | Readability extract + token budget — richer output |
30
+ | Web research / browsing | \`web_search({ query })\` | Structured web results without browser — unique to KB |
29
31
 
30
32
  **\`read_file\` is ONLY acceptable when you need exact line content FOR EDITING (before \`replace_string_in_file\`).**
31
33
  Even then, use \`file_summary\` first to identify which lines to read.
@@ -38,20 +40,42 @@ Even then, use \`file_summary\` first to identify which lines to read.
38
40
  4. **Validate** — \`check({})\` + \`test_run({})\` before presenting changes. \`blast_radius({ changed_files })\` for impact.
39
41
  5. **Lifecycle** — Check \`status({})\` first. If onboard not run, run \`onboard({ path: "." })\`. After implementation, \`reindex({})\` + \`produce_knowledge({})\`. At session end, \`remember()\` checkpoint.
40
42
 
43
+ ## User Interaction Rules
44
+
45
+ When you need to explain something or ask for user input:
46
+
47
+ | Situation | Method | Details |
48
+ |-----------|--------|---------|
49
+ | Simple explanation + question | **Elicitation** | Text-only context is sufficient; ask via elicitation fields |
50
+ | Rich content + question | **\`present\` (html)** + **Elicitation** | Use \`present({ format: "html" })\` for visual explanation, then elicitation for user input |
51
+ | Complex visual + interaction | **\`present\` (browser)** | Use \`present({ format: "browser" })\` for full HTML dashboard; confirmations/selections can use browser actions, other input uses elicitation |
52
+
53
+ **Rules:**
54
+ - Never dump long tables or complex visuals as plain text — use \`present\` to render them
55
+ - Confirmation selections (yes/no, pick from list) can be handled inside browser mode via actions
56
+ - Free-form text input always goes through elicitation, even when using \`present\` for the explanation
57
+ - Prefer the simplest method that adequately conveys the information
58
+
41
59
  ## Custom Agents
42
60
 
43
61
  This project has specialized agents in \`.github/agents/\`. Use them instead of built-in modes:
44
- - **Planner** — for planning and research before implementation
45
- - **Implementer** for coding tasks following TDD practices
46
- - **Researcher** — for deep investigation and context gathering
47
- - **Explorer** for rapid codebase navigation
62
+
63
+ | Category | Agents | Purpose |
64
+ |----------|--------|---------|
65
+ | Orchestration | **Orchestrator**, **Planner** | Lifecycle conductor, TDD implementation plans |
66
+ | Implementation | **Implementer**, **Frontend**, **Refactor** | Code writing, UI/UX, cleanup |
67
+ | Diagnostics | **Debugger**, **Security** | Issue tracing, vulnerability analysis |
68
+ | Research | **Researcher-Alpha/Beta/Gamma/Delta** | Multi-model deep investigation |
69
+ | Review | **Code-Reviewer-Alpha/Beta**, **Architect-Reviewer-Alpha/Beta** | Dual-perspective code and architecture review |
70
+ | Exploration | **Explorer** | Rapid codebase navigation |
71
+ | Documentation | **Documenter** | Comprehensive project docs |
48
72
 
49
73
  Check \`.github/agents/\` for the full list of available agents.
50
74
  `}function t(e,t){return`# ${e} — Agent Instructions
51
75
 
52
76
  ## KB MCP Server (\`${t}\`)
53
77
 
54
- 64 tools for search, code analysis, persistent memory, validation, and context compression.
78
+ 67 tools for search, code analysis, persistent memory, validation, and context compression.
55
79
  Load them: \`tool_search_tool_regex({ pattern: "knowledge-bas" })\`
56
80
 
57
81
  ### Skills Reference
@@ -65,6 +89,7 @@ Load them: \`tool_search_tool_regex({ pattern: "knowledge-bas" })\`
65
89
  | Engineering lessons | \`lesson-learned\` | After completing work — extract principles from git diffs. |
66
90
  | Architecture diagrams | \`c4-architecture\` | When documenting or reviewing architecture — C4 Mermaid diagrams. |
67
91
  | Architecture decisions | \`adr-skill\` | When making non-trivial technical decisions — executable ADRs. |
92
+ | Rich presentation | \`present\` | When presenting dashboards, charts, tables, or complex visual content to users. |
68
93
 
69
94
  ### Tool Categories
70
95
 
@@ -74,13 +99,15 @@ Load them: \`tool_search_tool_regex({ pattern: "knowledge-bas" })\`
74
99
  | Code Analysis | \`analyze_structure\`, \`analyze_dependencies\`, \`analyze_symbols\`, \`analyze_patterns\`, \`analyze_entry_points\`, \`analyze_diagram\`, \`blast_radius\` | Structure, deps, patterns, impact |
75
100
  | Knowledge | \`remember\`, \`read\`, \`update\`, \`forget\`, \`list\`, \`produce_knowledge\` | Persistent cross-session memory |
76
101
  | Execution | \`check\`, \`test_run\`, \`eval\`, \`batch\`, \`audit\` | Typecheck, lint, test, run code |
77
- | Context Compression | \`compact\`, \`digest\`, \`stratum_card\`, \`workset\`, \`stash\`, \`checkpoint\` | Reduce tokens, manage working sets |
102
+ | Context Compression | \`compact\`, \`digest\`, \`stratum_card\`, \`workset\`, \`stash\`, \`checkpoint\`, \`restore\` | Reduce tokens, manage working sets |
78
103
  | FORGE | \`forge_ground\`, \`forge_classify\`, \`evidence_map\` | Quality gates for complex tasks |
79
104
  | Code Manipulation | \`rename\`, \`codemod\`, \`diff_parse\`, \`data_transform\` | Safe renames, transforms |
80
105
  | Web & API | \`web_fetch\`, \`web_search\`, \`http\` | Fetch pages, search web |
81
106
  | Lanes | \`lane\` | Isolated file copies for parallel exploration |
82
107
  | Git & Environment | \`git_context\`, \`process\`, \`watch\`, \`delegate\` | Git info, process management |
83
- | Utilities | \`regex_test\`, \`encode\`, \`measure\`, \`changelog\`, \`schema_validate\`, \`snippet\`, \`env\`, \`time\` | Regex, encoding, metrics |
108
+ | Utilities | \`regex_test\`, \`encode\`, \`measure\`, \`changelog\`, \`schema_validate\`, \`snippet\`, \`parse_output\`, \`env\`, \`time\` | Regex, encoding, metrics, output parsing |
109
+ | Presentation | \`present\` | Rich dashboards, charts, tables, timelines |
110
+ | Brainstorming | \`brainstorm\` | Interactive ideation sessions with structured output |
84
111
  | System | \`status\`, \`reindex\`, \`health\`, \`guide\`, \`onboard\`, \`graph\`, \`queue\`, \`replay\` | Index management, knowledge graph |
85
112
 
86
113
  ---
@@ -162,4 +189,6 @@ For long sessions or context approaching capacity, use the \`session-handoff\` s
162
189
  **After implementation:** \`check\` → \`test_run\` → \`blast_radius\` → \`reindex\` → \`produce_knowledge\` → \`remember\`
163
190
 
164
191
  **Complex tasks (FORGE):** \`forge_classify({ task })\` → \`forge_ground({ task })\` → \`evidence_map({ claims })\`
192
+
193
+ **Quality iteration:** \`check\` → \`test_run\` → \`evidence_map({ action: "gate" })\` → fix → re-gate (max 3 rounds)
165
194
  `}export{t as buildAgentsMd,e as buildCopilotInstructions};
@@ -50,7 +50,7 @@ declare function writeVscodeSettings(idePath: UserLevelIdePath, force?: boolean)
50
50
  * Multiple IDEs may share the same root (e.g. VS Code + VSCodium both use ~/.copilot/).
51
51
  * We deduplicate scaffold files but generate IDE-specific instruction files.
52
52
  */
53
- declare function installGlobalScaffold(pkgRoot: string, ides: UserLevelIdePath[], serverName: string, force?: boolean): void;
53
+ declare function installGlobalScaffold(pkgRoot: string, ides: UserLevelIdePath[], serverName: string, version: string, force?: boolean): void;
54
54
  /**
55
55
  * Main orchestrator for `kb init --user`.
56
56
  */
@@ -1,5 +1,5 @@
1
- import{MCP_SERVER_ENTRY as e,SERVER_NAME as t,SKILL_NAMES as n,VSCODE_SETTINGS as r}from"./constants.js";import{buildAgentsMd as i,buildCopilotInstructions as a}from"./templates.js";import{copyDirectoryRecursive as o}from"./scaffold.js";import{copyFileSync as s,existsSync as c,mkdirSync as l,readFileSync as u,readdirSync as d,statSync as f,writeFileSync as p}from"node:fs";import{dirname as m,resolve as h}from"node:path";import{fileURLToPath as g}from"node:url";import{getGlobalDataDir as _,saveRegistry as v}from"../../../../core/dist/index.js";import{homedir as y}from"node:os";function b(){let e=y(),t=process.platform,n=[],r=h(e,`.copilot`),i=h(e,`.github`),a=h(e,`.claude`),o=h(e,`.cursor`),s=h(e,`.windsurf`);if(t===`win32`){let t=process.env.APPDATA??h(e,`AppData`,`Roaming`);n.push({ide:`VS Code`,configDir:h(t,`Code`,`User`),mcpConfigPath:h(t,`Code`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`VS Code Insiders`,configDir:h(t,`Code - Insiders`,`User`),mcpConfigPath:h(t,`Code - Insiders`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`VSCodium`,configDir:h(t,`VSCodium`,`User`),mcpConfigPath:h(t,`VSCodium`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`Cursor`,configDir:h(t,`Cursor`,`User`),mcpConfigPath:h(t,`Cursor`,`User`,`mcp.json`),globalScaffoldRoot:o,instructionsRoot:null},{ide:`Cursor Nightly`,configDir:h(t,`Cursor Nightly`,`User`),mcpConfigPath:h(t,`Cursor Nightly`,`User`,`mcp.json`),globalScaffoldRoot:o,instructionsRoot:null},{ide:`Windsurf`,configDir:h(t,`Windsurf`,`User`),mcpConfigPath:h(t,`Windsurf`,`User`,`mcp.json`),globalScaffoldRoot:s,instructionsRoot:null})}else if(t===`darwin`){let t=h(e,`Library`,`Application Support`);n.push({ide:`VS Code`,configDir:h(t,`Code`,`User`),mcpConfigPath:h(t,`Code`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`VS Code Insiders`,configDir:h(t,`Code - Insiders`,`User`),mcpConfigPath:h(t,`Code - Insiders`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`VSCodium`,configDir:h(t,`VSCodium`,`User`),mcpConfigPath:h(t,`VSCodium`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`Cursor`,configDir:h(t,`Cursor`,`User`),mcpConfigPath:h(t,`Cursor`,`User`,`mcp.json`),globalScaffoldRoot:o,instructionsRoot:null},{ide:`Cursor Nightly`,configDir:h(t,`Cursor Nightly`,`User`),mcpConfigPath:h(t,`Cursor Nightly`,`User`,`mcp.json`),globalScaffoldRoot:o,instructionsRoot:null},{ide:`Windsurf`,configDir:h(t,`Windsurf`,`User`),mcpConfigPath:h(t,`Windsurf`,`User`,`mcp.json`),globalScaffoldRoot:s,instructionsRoot:null})}else{let t=process.env.XDG_CONFIG_HOME??h(e,`.config`);n.push({ide:`VS Code`,configDir:h(t,`Code`,`User`),mcpConfigPath:h(t,`Code`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`VS Code Insiders`,configDir:h(t,`Code - Insiders`,`User`),mcpConfigPath:h(t,`Code - Insiders`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`VSCodium`,configDir:h(t,`VSCodium`,`User`),mcpConfigPath:h(t,`VSCodium`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`Cursor`,configDir:h(t,`Cursor`,`User`),mcpConfigPath:h(t,`Cursor`,`User`,`mcp.json`),globalScaffoldRoot:o,instructionsRoot:null},{ide:`Cursor Nightly`,configDir:h(t,`Cursor Nightly`,`User`),mcpConfigPath:h(t,`Cursor Nightly`,`User`,`mcp.json`),globalScaffoldRoot:o,instructionsRoot:null},{ide:`Windsurf`,configDir:h(t,`Windsurf`,`User`),mcpConfigPath:h(t,`Windsurf`,`User`,`mcp.json`),globalScaffoldRoot:s,instructionsRoot:null})}return n.push({ide:`Claude Code`,configDir:h(e,`.claude`),mcpConfigPath:h(e,`.claude`,`mcp.json`),globalScaffoldRoot:a,instructionsRoot:null}),n.filter(e=>c(e.configDir))}function x(t,n,r=!1){let{mcpConfigPath:i,configDir:a}=t,o={...e},s={};if(c(i)){try{let e=u(i,`utf-8`);s=JSON.parse(e)}catch{let e=`${i}.bak`;p(e,u(i,`utf-8`),`utf-8`),console.log(` Backed up invalid ${i} to ${e}`),s={}}if((s.servers??s.mcpServers??{})[n]&&!r){console.log(` ${t.ide}: ${n} already configured (use --force to update)`);return}}let d=new Set([`VS Code`,`VS Code Insiders`,`VSCodium`,`Windsurf`]).has(t.ide)?`servers`:`mcpServers`,f=s[d]??{};f[n]=o,s[d]=f,l(a,{recursive:!0}),p(i,`${JSON.stringify(s,null,2)}\n`,`utf-8`),console.log(` ${t.ide}: configured ${n} in ${i}`)}const S=new Set([`VS Code`,`VS Code Insiders`,`VSCodium`]);function C(e,t=!1){if(!S.has(e.ide))return;let n=h(e.configDir,`settings.json`),i={};if(c(n))try{let e=u(n,`utf-8`);i=JSON.parse(e)}catch{console.log(` ${e.ide}: skipped settings.json (invalid JSON)`);return}let a=!1;for(let[e,n]of Object.entries(r))if(typeof n==`object`&&n){let t=typeof i[e]==`object`&&i[e]!==null?i[e]:{},r={...t,...n};JSON.stringify(r)!==JSON.stringify(t)&&(i[e]=r,a=!0)}else (t||!(e in i))&&(i[e]=n,a=!0);a&&(p(n,`${JSON.stringify(i,null,2)}\n`,`utf-8`),console.log(` ${e.ide}: updated settings.json`))}function w(e,t,n,r){let i=h(t,n);l(i,{recursive:!0});let a=h(e,`scaffold`,`general`,n);if(!c(a))return 0;let u=0;for(let e of d(a)){let t=h(a,e),l=h(i,e);f(t).isDirectory()?o(t,l,`${n}/${e}`,r):(r||!c(l))&&(s(t,l),u++)}return u}function T(e,t,r,s=!1){let u=new Set;for(let e of t)e.globalScaffoldRoot&&u.add(e.globalScaffoldRoot);if(u.size===0){console.log(` No IDEs with global scaffold support detected.`);return}for(let t of u){let r=w(e,t,`agents`,s),i=w(e,t,`prompts`,s),a=h(t,`skills`),l=0;for(let t of n){let n=h(e,`skills`,t);c(n)&&(o(n,h(a,t),`skills/${t}`,s),l++)}console.log(` ${t}: ${r} agents, ${i} prompts, ${l} skills`)}let d=new Set,f=a(`kb`,r),m=i(`kb`,r);for(let e of t){if(!e.globalScaffoldRoot)continue;let t=e.globalScaffoldRoot;if(e.ide===`Claude Code`){let e=h(t,`CLAUDE.md`);(s||!c(e))&&(p(e,`${f}\n---\n\n${m}`,`utf-8`),d.add(e))}else if(e.ide===`VS Code`||e.ide===`VS Code Insiders`||e.ide===`VSCodium`){let n=e.instructionsRoot??t;l(n,{recursive:!0});let r=h(n,`copilot-instructions.md`);d.has(r)||(s||!c(r))&&(p(r,`${f}\n---\n\n${m}`,`utf-8`),d.add(r))}else if(e.ide===`Cursor`||e.ide===`Cursor Nightly`){let e=h(t,`rules`);l(e,{recursive:!0});let n=h(e,`kb.mdc`);d.has(n)||(s||!c(n))&&(p(n,`${f}\n---\n\n${m}`,`utf-8`),d.add(n))}else if(e.ide===`Windsurf`){let e=h(t,`rules`);l(e,{recursive:!0});let n=h(e,`kb.md`);d.has(n)||(s||!c(n))&&(p(n,`${f}\n---\n\n${m}`,`utf-8`),d.add(n))}}d.size>0&&console.log(` Instruction files: ${[...d].join(`, `)}`)}async function E(e){let n=t,r=h(m(g(import.meta.url)),`..`,`..`,`..`,`..`,`..`,`package.json`),i=JSON.parse(u(r,`utf-8`)).version;console.log(`Initializing @vpxa/kb v${i}...\n`);let a=_();l(a,{recursive:!0}),console.log(` Global data store: ${a}`),v({version:1,workspaces:{}}),console.log(` Created registry.json`);let o=b();if(o.length===0)console.log(`
2
- No supported IDEs detected. You can manually add the MCP server config.`);else{console.log(`\n Detected ${o.length} IDE(s):`);for(let t of o)x(t,n,e.force),C(t,e.force)}let s=h(m(g(import.meta.url)),`..`,`..`,`..`,`..`,`..`);console.log(`
3
- Installing scaffold files:`),T(s,o,n,e.force),console.log(`
1
+ import{MCP_SERVER_ENTRY as e,SERVER_NAME as t,SKILL_NAMES as n,VSCODE_SETTINGS as r}from"./constants.js";import{buildAgentsMd as i,buildCopilotInstructions as a}from"./templates.js";import{smartCopySubdir as o}from"./scaffold.js";import{existsSync as s,mkdirSync as c,readFileSync as l,writeFileSync as u}from"node:fs";import{dirname as d,resolve as f}from"node:path";import{fileURLToPath as p}from"node:url";import{getGlobalDataDir as m,saveRegistry as h}from"../../../../core/dist/index.js";import{homedir as g}from"node:os";function _(){let e=g(),t=process.platform,n=[],r=f(e,`.copilot`),i=f(e,`.github`),a=f(e,`.claude`),o=f(e,`.cursor`),c=f(e,`.windsurf`);if(t===`win32`){let t=process.env.APPDATA??f(e,`AppData`,`Roaming`);n.push({ide:`VS Code`,configDir:f(t,`Code`,`User`),mcpConfigPath:f(t,`Code`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`VS Code Insiders`,configDir:f(t,`Code - Insiders`,`User`),mcpConfigPath:f(t,`Code - Insiders`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`VSCodium`,configDir:f(t,`VSCodium`,`User`),mcpConfigPath:f(t,`VSCodium`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`Cursor`,configDir:f(t,`Cursor`,`User`),mcpConfigPath:f(t,`Cursor`,`User`,`mcp.json`),globalScaffoldRoot:o,instructionsRoot:null},{ide:`Cursor Nightly`,configDir:f(t,`Cursor Nightly`,`User`),mcpConfigPath:f(t,`Cursor Nightly`,`User`,`mcp.json`),globalScaffoldRoot:o,instructionsRoot:null},{ide:`Windsurf`,configDir:f(t,`Windsurf`,`User`),mcpConfigPath:f(t,`Windsurf`,`User`,`mcp.json`),globalScaffoldRoot:c,instructionsRoot:null})}else if(t===`darwin`){let t=f(e,`Library`,`Application Support`);n.push({ide:`VS Code`,configDir:f(t,`Code`,`User`),mcpConfigPath:f(t,`Code`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`VS Code Insiders`,configDir:f(t,`Code - Insiders`,`User`),mcpConfigPath:f(t,`Code - Insiders`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`VSCodium`,configDir:f(t,`VSCodium`,`User`),mcpConfigPath:f(t,`VSCodium`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`Cursor`,configDir:f(t,`Cursor`,`User`),mcpConfigPath:f(t,`Cursor`,`User`,`mcp.json`),globalScaffoldRoot:o,instructionsRoot:null},{ide:`Cursor Nightly`,configDir:f(t,`Cursor Nightly`,`User`),mcpConfigPath:f(t,`Cursor Nightly`,`User`,`mcp.json`),globalScaffoldRoot:o,instructionsRoot:null},{ide:`Windsurf`,configDir:f(t,`Windsurf`,`User`),mcpConfigPath:f(t,`Windsurf`,`User`,`mcp.json`),globalScaffoldRoot:c,instructionsRoot:null})}else{let t=process.env.XDG_CONFIG_HOME??f(e,`.config`);n.push({ide:`VS Code`,configDir:f(t,`Code`,`User`),mcpConfigPath:f(t,`Code`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`VS Code Insiders`,configDir:f(t,`Code - Insiders`,`User`),mcpConfigPath:f(t,`Code - Insiders`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`VSCodium`,configDir:f(t,`VSCodium`,`User`),mcpConfigPath:f(t,`VSCodium`,`User`,`mcp.json`),globalScaffoldRoot:r,instructionsRoot:i},{ide:`Cursor`,configDir:f(t,`Cursor`,`User`),mcpConfigPath:f(t,`Cursor`,`User`,`mcp.json`),globalScaffoldRoot:o,instructionsRoot:null},{ide:`Cursor Nightly`,configDir:f(t,`Cursor Nightly`,`User`),mcpConfigPath:f(t,`Cursor Nightly`,`User`,`mcp.json`),globalScaffoldRoot:o,instructionsRoot:null},{ide:`Windsurf`,configDir:f(t,`Windsurf`,`User`),mcpConfigPath:f(t,`Windsurf`,`User`,`mcp.json`),globalScaffoldRoot:c,instructionsRoot:null})}return n.push({ide:`Claude Code`,configDir:f(e,`.claude`),mcpConfigPath:f(e,`.claude`,`mcp.json`),globalScaffoldRoot:a,instructionsRoot:null}),n.filter(e=>s(e.configDir))}function v(t,n,r=!1){let{mcpConfigPath:i,configDir:a}=t,o={...e},d={};if(s(i)){try{let e=l(i,`utf-8`);d=JSON.parse(e)}catch{let e=`${i}.bak`;u(e,l(i,`utf-8`),`utf-8`),console.log(` Backed up invalid ${i} to ${e}`),d={}}if((d.servers??d.mcpServers??{})[n]&&!r){console.log(` ${t.ide}: ${n} already configured (use --force to update)`);return}}let f=new Set([`VS Code`,`VS Code Insiders`,`VSCodium`,`Windsurf`]).has(t.ide)?`servers`:`mcpServers`,p=d[f]??{};p[n]=o,d[f]=p,c(a,{recursive:!0}),u(i,`${JSON.stringify(d,null,2)}\n`,`utf-8`),console.log(` ${t.ide}: configured ${n} in ${i}`)}const y=new Set([`VS Code`,`VS Code Insiders`,`VSCodium`]);function b(e,t=!1){if(!y.has(e.ide))return;let n=f(e.configDir,`settings.json`),i={};if(s(n))try{let e=l(n,`utf-8`);i=JSON.parse(e)}catch{console.log(` ${e.ide}: skipped settings.json (invalid JSON)`);return}let a=!1;for(let[e,n]of Object.entries(r))if(typeof n==`object`&&n){let t=typeof i[e]==`object`&&i[e]!==null?i[e]:{},r={...t,...n};JSON.stringify(r)!==JSON.stringify(t)&&(i[e]=r,a=!0)}else (t||!(e in i))&&(i[e]=n,a=!0);a&&(u(n,`${JSON.stringify(i,null,2)}\n`,`utf-8`),console.log(` ${e.ide}: updated settings.json`))}function x(e,t,r,l,d=!1){let p=new Set;for(let e of t)e.globalScaffoldRoot&&p.add(e.globalScaffoldRoot);if(p.size===0){console.log(` No IDEs with global scaffold support detected.`);return}let m=f(e,`scaffold`,`general`);for(let t of p){o(m,t,`agents`,l,d),o(m,t,`prompts`,l,d);let r=0;for(let i of n)s(f(e,`skills`,i))&&(o(e,t,`skills/${i}`,l,d),r++);console.log(` ${t}: scaffold updated (${r} skills)`)}let h=new Set,g=a(`kb`,r),_=i(`kb`,r);for(let e of t){if(!e.globalScaffoldRoot)continue;let t=e.globalScaffoldRoot;if(e.ide===`Claude Code`){let e=f(t,`CLAUDE.md`);u(e,`${g}\n---\n\n${_}`,`utf-8`),h.add(e)}else if(e.ide===`VS Code`||e.ide===`VS Code Insiders`||e.ide===`VSCodium`){let n=e.instructionsRoot??t;c(n,{recursive:!0});let r=f(n,`copilot-instructions.md`);h.has(r)||(u(r,`${g}\n---\n\n${_}`,`utf-8`),h.add(r))}else if(e.ide===`Cursor`||e.ide===`Cursor Nightly`){let e=f(t,`rules`);c(e,{recursive:!0});let n=f(e,`kb.mdc`);h.has(n)||(u(n,`${g}\n---\n\n${_}`,`utf-8`),h.add(n))}else if(e.ide===`Windsurf`){let e=f(t,`rules`);c(e,{recursive:!0});let n=f(e,`kb.md`);h.has(n)||(u(n,`${g}\n---\n\n${_}`,`utf-8`),h.add(n))}}h.size>0&&console.log(` Instruction files: ${[...h].join(`, `)}`)}async function S(e){let n=t,r=f(d(p(import.meta.url)),`..`,`..`,`..`,`..`,`..`,`package.json`),i=JSON.parse(l(r,`utf-8`)).version;console.log(`Initializing @vpxa/kb v${i}...\n`);let a=m();c(a,{recursive:!0}),console.log(` Global data store: ${a}`),h({version:1,workspaces:{}}),console.log(` Created registry.json`);let o=_();if(o.length===0)console.log(`
2
+ No supported IDEs detected. You can manually add the MCP server config.`);else{console.log(`\n Detected ${o.length} IDE(s):`);for(let t of o)v(t,n,e.force),b(t,e.force)}let s=f(d(p(import.meta.url)),`..`,`..`,`..`,`..`,`..`);console.log(`
3
+ Installing scaffold files:`),x(s,o,n,i,e.force),console.log(`
4
4
  User-level KB installation complete!`),console.log(`
5
- Next steps:`),console.log(` 1. Open any workspace in your IDE`),console.log(` 2. The KB server will auto-start and index the workspace`),console.log(` 3. Agents, prompts, skills & instructions are available globally`),console.log(` 4. No per-workspace init needed — just open a project and start coding`)}export{b as detectInstalledIdes,E as initUser,T as installGlobalScaffold,x as writeUserLevelMcpConfig,C as writeVscodeSettings};
5
+ Next steps:`),console.log(` 1. Open any workspace in your IDE`),console.log(` 2. The KB server will auto-start and index the workspace`),console.log(` 3. Agents, prompts, skills & instructions are available globally`),console.log(` 4. No per-workspace init needed — just open a project and start coding`)}export{_ as detectInstalledIdes,S as initUser,x as installGlobalScaffold,v as writeUserLevelMcpConfig,b as writeVscodeSettings};
@@ -1,4 +1,4 @@
1
1
  import{ctx as e}from"../context.js";import{executeCliBatchOperation as t,extractStrFlag as n,parseBatchPayload as r,printCheckResult as i,readInput as a}from"../helpers.js";import{dirname as o,resolve as s}from"node:path";import{fileURLToPath as c}from"node:url";import{audit as l,batch as u,check as d,guide as f,health as p,replayClear as m,replayList as h,replayTrim as g}from"../../../tools/dist/index.js";import{fork as _}from"node:child_process";const v=o(c(import.meta.url)),y=[{name:`status`,description:`Show knowledge base index status and statistics`,run:async()=>{let{isUserInstalled:t,getGlobalDataDir:n,computePartitionKey:r,listWorkspaces:i}=await import(`../../../core/dist/index.js`),{existsSync:a}=await import(`node:fs`),o=process.cwd(),c=t(),l=a(s(o,`.vscode`,`mcp.json`)),u,d;if(c&&l)u=`workspace (overrides user-level for this workspace)`,d=s(o,`.kb-data`);else if(c){let e=r(o);u=a(s(o,`AGENTS.md`))?`user (workspace scaffolded)`:`user (workspace not scaffolded)`,d=s(n(),e)}else u=`workspace`,d=s(o,`.kb-data`);if(console.log(`Knowledge Base Status`),console.log(`─`.repeat(40)),console.log(` Mode: ${u}`),console.log(` Data: ${d}`),c&&!l){let e=i();console.log(` Registry: ${e.length} workspace(s) enrolled`)}try{let{store:t}=await e(),n=await t.getStats(),r=await t.listSourcePaths();console.log(` Records: ${n.totalRecords}`),console.log(` Files: ${n.totalFiles}`),console.log(` Indexed: ${n.lastIndexedAt??`Never`}`),console.log(` Backend: ${n.storeBackend}`),console.log(` Model: ${n.embeddingModel}`),console.log(``),console.log(`Content Types:`);for(let[e,t]of Object.entries(n.contentTypeBreakdown))console.log(` ${e}: ${t}`);if(r.length>0){console.log(``),console.log(`Files (${r.length} total):`);for(let e of r.slice(0,20))console.log(` ${e}`);r.length>20&&console.log(` ... and ${r.length-20} more`)}}catch{console.log(``),console.log(" Index not available — run `kb reindex` to index this workspace.")}c&&!l&&!a(s(o,`AGENTS.md`))&&(console.log(``),console.log(" Action: Run `npx @vpxa/kb init` to add AGENTS.md and copilot-instructions.md"))}},{name:`reindex`,description:`Re-index the knowledge base from configured sources`,usage:`kb reindex [--full]`,run:async t=>{let n=t.includes(`--full`),{store:r,indexer:i,curated:a,config:o}=await e();console.log(`Indexing sources...`);let s=e=>{e.phase===`chunking`&&e.currentFile&&process.stdout.write(`\r [${e.filesProcessed+1}/${e.filesTotal}] ${e.currentFile}`),e.phase===`done`&&process.stdout.write(`
2
2
  `)},c;n?(console.log(`Dropping existing index for full reindex...`),c=await i.reindexAll(o,s)):c=await i.index(o,s),console.log(`Done: ${c.filesProcessed} files, ${c.chunksCreated} chunks in ${(c.durationMs/1e3).toFixed(1)}s`),console.log(`Building FTS index...`),await r.createFtsIndex(),console.log(`Re-indexing curated entries...`);let l=await a.reindexAll();console.log(`Curated: ${l.indexed} entries restored`)}},{name:`serve`,description:`Start the MCP server (stdio or HTTP)`,usage:`kb serve [--transport stdio|http] [--port N]`,run:async e=>{let t=s(v,`..`,`..`,`..`,`server`,`dist`,`index.js`),r=n(e,`--transport`,`stdio`),i=n(e,`--port`,`3210`),a=_(t,[],{stdio:r===`stdio`?[`pipe`,`pipe`,`inherit`,`ipc`]:`inherit`,env:{...process.env,KB_TRANSPORT:r,KB_PORT:i}});r===`stdio`&&a.stdin&&a.stdout&&(process.stdin.pipe(a.stdin),a.stdout.pipe(process.stdout)),a.on(`exit`,e=>process.exit(e??0)),process.on(`SIGINT`,()=>a.kill(`SIGINT`)),process.on(`SIGTERM`,()=>a.kill(`SIGTERM`)),await new Promise(()=>{})}},{name:`init`,description:`Initialize a knowledge base in the current directory`,usage:`kb init [--user|--workspace] [--force] [--guide]`,run:async e=>{let t=e.includes(`--user`),n=e.includes(`--workspace`),r=e.includes(`--guide`),i=e.includes(`--force`);if(t&&n&&(console.error(`Cannot use --user and --workspace together.`),process.exit(1)),r){let{guideProject:e}=await import(`./init/index.js`);await e();return}if(t){let{initUser:e}=await import(`./init/user.js`);await e({force:i})}else if(n){let{initProject:e}=await import(`./init/index.js`);await e({force:i})}else{let{initSmart:e}=await import(`./init/index.js`);await e({force:i})}}},{name:`check`,description:`Run incremental typecheck and lint`,usage:`kb check [--cwd <dir>] [--files f1,f2] [--skip-types] [--skip-lint] [--detail summary|errors|full]`,run:async e=>{let t=n(e,`--cwd`,``).trim()||void 0,r=n(e,`--files`,``),a=n(e,`--detail`,`full`)||`full`,o=r.split(`,`).map(e=>e.trim()).filter(Boolean),s=!1;e.includes(`--skip-types`)&&(e.splice(e.indexOf(`--skip-types`),1),s=!0);let c=!1;e.includes(`--skip-lint`)&&(e.splice(e.indexOf(`--skip-lint`),1),c=!0);let l=await d({cwd:t,files:o.length>0?o:void 0,skipTypes:s,skipLint:c,detail:a});i(l),l.passed||(process.exitCode=1)}},{name:`batch`,description:`Execute built-in operations from JSON input`,usage:`kb batch [--file path] [--concurrency N]`,run:async i=>{let o=n(i,`--file`,``).trim()||void 0,s=(()=>{let e=i.indexOf(`--concurrency`);if(e===-1||e+1>=i.length)return 0;let t=Number.parseInt(i.splice(e,2)[1],10);return Number.isNaN(t)?0:t})(),c=await a(o);c.trim()||(console.error(`Usage: kb batch [--file path] [--concurrency N]`),process.exit(1));let l=r(c),d=s>0?s:l.concurrency,f=l.operations.some(e=>e.type!==`check`)?await e():null,p=await u(l.operations,async e=>t(e,f),{concurrency:d});console.log(JSON.stringify(p,null,2)),p.some(e=>e.status===`error`)&&(process.exitCode=1)}},{name:`health`,description:`Run project health checks on the current directory`,usage:`kb health [path]`,run:async e=>{let t=p(e.shift());console.log(`Project Health: ${t.path}`),console.log(`─`.repeat(50));for(let e of t.checks){let t=e.status===`pass`?`+`:e.status===`warn`?`~`:`X`;console.log(` [${t}] ${e.name}: ${e.message}`)}console.log(`─`.repeat(50)),console.log(`Score: ${t.score}% — ${t.summary}`)}},{name:`audit`,description:`Run a unified project audit (structure, deps, patterns, health, dead symbols, check)`,usage:`kb audit [path] [--checks structure,dependencies,patterns,health,dead_symbols,check,entry_points] [--detail summary|full]`,run:async t=>{let{store:r,embedder:i}=await e(),a=n(t,`--detail`,`summary`)||`summary`,o=n(t,`--checks`,``),s=o?o.split(`,`).map(e=>e.trim()):void 0,c=await l(r,i,{path:t.shift()||`.`,checks:s,detail:a});if(c.ok){if(console.log(c.summary),c.next&&c.next.length>0){console.log(`
3
- Suggested next steps:`);for(let e of c.next)console.log(` → ${e.tool}: ${e.reason}`)}}else console.error(c.error?.message??`Audit failed`),process.exitCode=1}},{name:`guide`,description:`Tool discovery — recommend KB tools for a given goal`,usage:`kb guide <goal> [--max N]`,run:async e=>{let t=e.indexOf(`--max`),n=5;t!==-1&&t+1<e.length&&(n=Number.parseInt(e.splice(t,2)[1],10)||5);let r=e.join(` `).trim();r||(console.error(`Usage: kb guide <goal> [--max N]`),console.error(`Example: kb guide "audit this project"`),process.exit(1));let i=f(r,n);console.log(`Workflow: ${i.workflow}`),console.log(` ${i.description}\n`),console.log(`Recommended tools:`);for(let e of i.tools){let t=e.suggestedArgs?` ${JSON.stringify(e.suggestedArgs)}`:``;console.log(` ${e.order}. ${e.tool} — ${e.reason}${t}`)}i.alternativeWorkflows.length>0&&console.log(`\nAlternatives: ${i.alternativeWorkflows.join(`, `)}`)}},{name:`replay`,description:`Show recent tool invocation audit trail`,usage:`kb replay [--last N] [--tool <name>] [--source mcp|cli]`,run:async e=>{let t=h({last:Number.parseInt(e[e.indexOf(`--last`)+1],10)||20,tool:e.includes(`--tool`)?e[e.indexOf(`--tool`)+1]:void 0,source:e.includes(`--source`)?e[e.indexOf(`--source`)+1]:void 0});if(t.length===0){console.log(`No replay entries. Activity is logged when tools are invoked.`);return}console.log(`Replay Log (${t.length} entries)\n`);for(let e of t){let t=e.ts.split(`T`)[1]?.split(`.`)[0]??e.ts,n=e.status===`ok`?`✓`:`✗`;console.log(`${t} ${n} ${e.tool} (${e.durationMs}ms) [${e.source}]`),console.log(` in: ${e.input}`),console.log(` out: ${e.output}`)}g()}},{name:`replay-clear`,description:`Clear the replay audit trail`,run:async()=>{m(),console.log(`Replay log cleared.`)}},{name:`tui`,description:`Launch interactive terminal dashboard (human monitoring)`,run:async()=>{try{let{launch:t}=await import(`../../../tui/dist/index.js`),{store:n,embedder:r,config:i}=await e();t({store:n,embedder:r,config:i})}catch(e){throw e.code===`ERR_MODULE_NOT_FOUND`&&(console.error(`TUI requires ink and react. Install them with:
4
- pnpm add -D ink react @types/react`),process.exit(1)),e}}}];export{y as systemCommands};
3
+ Suggested next steps:`);for(let e of c.next)console.log(` → ${e.tool}: ${e.reason}`)}}else console.error(c.error?.message??`Audit failed`),process.exitCode=1}},{name:`guide`,description:`Tool discovery — recommend KB tools for a given goal`,usage:`kb guide <goal> [--max N]`,run:async e=>{let t=e.indexOf(`--max`),n=5;t!==-1&&t+1<e.length&&(n=Number.parseInt(e.splice(t,2)[1],10)||5);let r=e.join(` `).trim();r||(console.error(`Usage: kb guide <goal> [--max N]`),console.error(`Example: kb guide "audit this project"`),process.exit(1));let i=f(r,n);console.log(`Workflow: ${i.workflow}`),console.log(` ${i.description}\n`),console.log(`Recommended tools:`);for(let e of i.tools){let t=e.suggestedArgs?` ${JSON.stringify(e.suggestedArgs)}`:``;console.log(` ${e.order}. ${e.tool} — ${e.reason}${t}`)}i.alternativeWorkflows.length>0&&console.log(`\nAlternatives: ${i.alternativeWorkflows.join(`, `)}`)}},{name:`replay`,description:`Show recent tool invocation audit trail`,usage:`kb replay [--last N] [--tool <name>] [--source mcp|cli]`,run:async e=>{let t=h({last:Number.parseInt(e[e.indexOf(`--last`)+1],10)||20,tool:e.includes(`--tool`)?e[e.indexOf(`--tool`)+1]:void 0,source:e.includes(`--source`)?e[e.indexOf(`--source`)+1]:void 0});if(t.length===0){console.log(`No replay entries. Activity is logged when tools are invoked.`);return}console.log(`Replay Log (${t.length} entries)\n`);for(let e of t){let t=e.ts.split(`T`)[1]?.split(`.`)[0]??e.ts,n=e.status===`ok`?`✓`:`✗`;console.log(`${t} ${n} ${e.tool} (${e.durationMs}ms) [${e.source}]`),console.log(` in: ${e.input}`),console.log(` out: ${e.output}`)}g().catch(()=>{})}},{name:`replay-clear`,description:`Clear the replay audit trail`,run:async()=>{m(),console.log(`Replay log cleared.`)}},{name:`tui`,description:`Launch interactive terminal dashboard (human monitoring)`,run:async()=>{try{let{launch:t}=await import(`../../../tui/dist/index.js`),{DirectKBClient:n}=await import(`../../../kb-client/dist/index.js`),{store:r,embedder:i,graphStore:a,curated:o}=await e();t(new n({store:r,embedder:i,graphStore:a,listCurated:async()=>(await o.list()).map(e=>({...e,content:e.contentPreview})),readCurated:e=>o.read(e)}))}catch(e){throw e.code===`ERR_MODULE_NOT_FOUND`&&(console.error(`TUI requires ink and react. Install them with:
4
+ pnpm add -D ink react @types/react`),process.exit(1)),e}}},{name:`dashboard`,description:`Launch web dashboard for knowledge graph visualization`,usage:`kb dashboard [--port <port>] [--no-open]`,run:async e=>{let t=e.indexOf(`--port`),n=t!==-1&&e[t+1]?Number.parseInt(e[t+1],10):3210,r=Number.isFinite(n)?n:3210,i=e.includes(`--no-open`);console.log(`Starting KB server on port ${r}...`);let{spawn:a}=await import(`node:child_process`),{platform:o}=await import(`node:os`),c=s(v,`..`,`..`,`..`,`server`,`dist`,`index.js`),l=a(process.execPath,[c,`--transport`,`http`,`--port`,String(r)],{stdio:[`ignore`,`pipe`,`pipe`],env:{...process.env,KB_TRANSPORT:`http`,KB_PORT:String(r)}}),u=`http://localhost:${r}/_dashboard/`,d=`http://localhost:${r}/health`,f=!1;for(let e=0;e<30;e+=1){try{if((await fetch(d)).ok){f=!0;break}}catch{}await new Promise(e=>setTimeout(e,1e3))}if(f||(console.error(`Server failed to start within 30 seconds.`),l.kill(),process.exit(1)),console.log(`KB Dashboard: ${u}`),console.log(`Press Ctrl+C to stop.`),!i){let e=o();e===`win32`?a(`cmd`,[`/c`,`start`,``,u],{stdio:`ignore`,detached:!0}).unref():a(e===`darwin`?`open`:`xdg-open`,[u],{stdio:`ignore`,detached:!0}).unref()}let p=()=>{l.kill(),process.exit(0)};process.on(`SIGINT`,p),process.on(`SIGTERM`,p),await new Promise(e=>{l.on(`exit`,()=>e())})}}];export{y as systemCommands};