@vpxa/kb 0.1.24 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/package.json +9 -2
- package/packages/analyzers/dist/symbol-analyzer.js +5 -5
- package/packages/cli/dist/commands/init/adapters.js +1 -1
- package/packages/cli/dist/commands/init/constants.d.ts +4 -1
- package/packages/cli/dist/commands/init/constants.js +1 -1
- package/packages/cli/dist/commands/init/frontmatter.d.ts +54 -0
- package/packages/cli/dist/commands/init/frontmatter.js +2 -0
- package/packages/cli/dist/commands/init/index.js +4 -4
- package/packages/cli/dist/commands/init/manifest.d.ts +71 -0
- package/packages/cli/dist/commands/init/manifest.js +1 -0
- package/packages/cli/dist/commands/init/scaffold.d.ts +28 -5
- package/packages/cli/dist/commands/init/scaffold.js +1 -1
- package/packages/cli/dist/commands/init/templates.js +38 -9
- package/packages/cli/dist/commands/init/user.d.ts +3 -3
- package/packages/cli/dist/commands/init/user.js +4 -4
- package/packages/cli/dist/commands/system.js +2 -2
- package/packages/cli/dist/kb-init.js +1 -1
- package/packages/core/dist/errors.d.ts +2 -2
- package/packages/core/dist/errors.js +1 -1
- package/packages/core/dist/logger.d.ts +2 -1
- package/packages/core/dist/logger.js +1 -1
- package/packages/core/dist/types.d.ts +6 -0
- package/packages/dashboard/dist/assets/index-9ysCkze9.js +21 -0
- package/packages/dashboard/dist/assets/index-9ysCkze9.js.map +1 -0
- package/packages/dashboard/dist/assets/index-CHpVij2M.css +1 -0
- package/packages/dashboard/dist/index.html +18 -0
- package/packages/elicitation/dist/__tests__/build.test.d.ts +1 -0
- package/packages/elicitation/dist/__tests__/build.test.js +35 -0
- package/packages/elicitation/dist/__tests__/fields.test.d.ts +1 -0
- package/packages/elicitation/dist/__tests__/fields.test.js +81 -0
- package/packages/elicitation/dist/__tests__/normalize.test.d.ts +1 -0
- package/packages/elicitation/dist/__tests__/normalize.test.js +60 -0
- package/packages/elicitation/dist/build.d.ts +13 -0
- package/packages/elicitation/dist/build.js +23 -0
- package/packages/elicitation/dist/fields.d.ts +41 -0
- package/packages/elicitation/dist/fields.js +62 -0
- package/packages/elicitation/dist/index.d.ts +10 -0
- package/packages/elicitation/dist/index.js +12 -0
- package/packages/elicitation/dist/normalize.d.ts +15 -0
- package/packages/elicitation/dist/normalize.js +31 -0
- package/packages/elicitation/dist/types.d.ts +85 -0
- package/packages/elicitation/dist/types.js +8 -0
- package/packages/kb-client/dist/direct-client.d.ts +37 -0
- package/packages/kb-client/dist/direct-client.js +1 -0
- package/packages/kb-client/dist/index.d.ts +5 -0
- package/packages/kb-client/dist/index.js +1 -0
- package/packages/kb-client/dist/mcp-client.d.ts +19 -0
- package/packages/kb-client/dist/mcp-client.js +4 -0
- package/packages/kb-client/dist/parsers.d.ts +35 -0
- package/packages/kb-client/dist/parsers.js +2 -0
- package/packages/kb-client/dist/types.d.ts +62 -0
- package/packages/kb-client/dist/types.js +1 -0
- package/packages/present/dist/index.html +384 -0
- package/packages/server/dist/completions.d.ts +14 -0
- package/packages/server/dist/completions.js +1 -0
- package/packages/server/dist/dashboard-static.d.ts +27 -0
- package/packages/server/dist/dashboard-static.js +1 -0
- package/packages/server/dist/elicitor.d.ts +18 -0
- package/packages/server/dist/elicitor.js +1 -0
- package/packages/server/dist/index.js +1 -1
- package/packages/server/dist/mcp-logging.js +1 -1
- package/packages/server/dist/output-schemas.d.ts +118 -1
- package/packages/server/dist/output-schemas.js +1 -1
- package/packages/server/dist/prompts.d.ts +9 -2
- package/packages/server/dist/prompts.js +13 -7
- package/packages/server/dist/resources/curated-resources.js +1 -1
- package/packages/server/dist/resources/resource-notifier.d.ts +45 -0
- package/packages/server/dist/resources/resource-notifier.js +1 -0
- package/packages/server/dist/sampling.d.ts +41 -0
- package/packages/server/dist/sampling.js +2 -0
- package/packages/server/dist/server.d.ts +5 -2
- package/packages/server/dist/server.js +2 -2
- package/packages/server/dist/task-manager.d.ts +40 -0
- package/packages/server/dist/task-manager.js +1 -0
- package/packages/server/dist/tool-metadata.js +1 -1
- package/packages/server/dist/tool-prefix.d.ts +12 -0
- package/packages/server/dist/tool-prefix.js +1 -0
- package/packages/server/dist/tools/analyze.tools.js +4 -4
- package/packages/server/dist/tools/audit.tool.js +1 -1
- package/packages/server/dist/tools/brainstorm.tool.d.ts +7 -0
- package/packages/server/dist/tools/brainstorm.tool.js +9 -0
- package/packages/server/dist/tools/context.tools.js +9 -9
- package/packages/server/dist/tools/execution.tools.d.ts +2 -1
- package/packages/server/dist/tools/execution.tools.js +4 -4
- package/packages/server/dist/tools/forge.tools.js +10 -10
- package/packages/server/dist/tools/forget.tool.d.ts +2 -1
- package/packages/server/dist/tools/forget.tool.js +1 -1
- package/packages/server/dist/tools/graph.tool.js +2 -2
- package/packages/server/dist/tools/manipulation.tools.js +4 -4
- package/packages/server/dist/tools/onboard.tool.js +2 -2
- package/packages/server/dist/tools/present-blocks.d.ts +46 -0
- package/packages/server/dist/tools/present-blocks.js +27 -0
- package/packages/server/dist/tools/present-charts.d.ts +31 -0
- package/packages/server/dist/tools/present-charts.js +34 -0
- package/packages/server/dist/tools/present-theme.d.ts +14 -0
- package/packages/server/dist/tools/present-theme.js +395 -0
- package/packages/server/dist/tools/present-utils.d.ts +11 -0
- package/packages/server/dist/tools/present-utils.js +1 -0
- package/packages/server/dist/tools/present.tool.d.ts +7 -0
- package/packages/server/dist/tools/present.tool.js +113 -0
- package/packages/server/dist/tools/produce.tool.js +2 -2
- package/packages/server/dist/tools/reindex.tool.d.ts +2 -1
- package/packages/server/dist/tools/reindex.tool.js +2 -2
- package/packages/server/dist/tools/remember.tool.d.ts +2 -1
- package/packages/server/dist/tools/remember.tool.js +2 -2
- package/packages/server/dist/tools/replay.tool.js +1 -1
- package/packages/server/dist/tools/search.tool.d.ts +2 -1
- package/packages/server/dist/tools/search.tool.js +5 -4
- package/packages/server/dist/tools/status.tool.js +2 -2
- package/packages/server/dist/tools/update.tool.d.ts +2 -1
- package/packages/server/dist/tools/update.tool.js +1 -1
- package/packages/server/dist/tools/utility.tools.js +1 -1
- package/packages/tools/dist/batch.js +1 -1
- package/packages/tools/dist/checkpoint.js +1 -1
- package/packages/tools/dist/config-extractor.d.ts +9 -0
- package/packages/tools/dist/config-extractor.js +7 -0
- package/packages/tools/dist/dead-symbols.js +2 -2
- package/packages/tools/dist/diagram-builder.d.ts +9 -0
- package/packages/tools/dist/diagram-builder.js +9 -0
- package/packages/tools/dist/evidence-map.d.ts +12 -1
- package/packages/tools/dist/evidence-map.js +2 -2
- package/packages/tools/dist/find-examples.js +2 -2
- package/packages/tools/dist/forge-classify.d.ts +4 -0
- package/packages/tools/dist/forge-classify.js +1 -1
- package/packages/tools/dist/git-context.d.ts +1 -0
- package/packages/tools/dist/git-context.js +3 -3
- package/packages/tools/dist/index.d.ts +3 -2
- package/packages/tools/dist/index.js +1 -1
- package/packages/tools/dist/onboard-utils.d.ts +12 -0
- package/packages/tools/dist/onboard-utils.js +1 -0
- package/packages/tools/dist/onboard.js +2 -21
- package/packages/tools/dist/regex-utils.d.ts +8 -0
- package/packages/tools/dist/regex-utils.js +1 -0
- package/packages/tools/dist/rename.js +2 -2
- package/packages/tools/dist/replay.d.ts +2 -1
- package/packages/tools/dist/replay.js +4 -4
- package/packages/tools/dist/symbol.js +3 -3
- package/packages/tools/dist/synthesis-engine.d.ts +13 -0
- package/packages/tools/dist/synthesis-engine.js +6 -0
- package/packages/tools/dist/trace.js +2 -2
- package/packages/tui/dist/App-DXY0-tlW.js +2 -0
- package/packages/tui/dist/App.d.ts +3 -3
- package/packages/tui/dist/App.js +1 -1
- package/packages/tui/dist/CuratedPanel-BIamXLNy.js +2 -0
- package/packages/tui/dist/LogPanel-D6u6o84n.js +3 -0
- package/packages/tui/dist/SearchPanel-CpJGczAc.js +2 -0
- package/packages/tui/dist/StatusPanel-BAbUxyqQ.js +2 -0
- package/packages/tui/dist/hooks/useKBClient.d.ts +9 -0
- package/packages/tui/dist/hooks/useKBClient.js +2 -0
- package/packages/tui/dist/hooks/usePolling.d.ts +8 -0
- package/packages/tui/dist/hooks/usePolling.js +2 -0
- package/packages/tui/dist/index.d.ts +6 -2
- package/packages/tui/dist/index.js +1 -1
- package/packages/tui/dist/jsx-runtime-y6Gdq5PZ.js +294 -0
- package/packages/tui/dist/panels/CuratedPanel.d.ts +1 -7
- package/packages/tui/dist/panels/CuratedPanel.js +1 -1
- package/packages/tui/dist/panels/LogPanel.js +1 -1
- package/packages/tui/dist/panels/SearchPanel.d.ts +1 -10
- package/packages/tui/dist/panels/SearchPanel.js +1 -1
- package/packages/tui/dist/panels/StatusPanel.d.ts +1 -7
- package/packages/tui/dist/panels/StatusPanel.js +1 -1
- package/packages/tui/dist/react-D__J1GQe.js +24 -0
- package/packages/tui/dist/types-VcTHNV6s.d.ts +64 -0
- package/packages/tui/dist/useKBClient-C35iA4uG.js +2 -0
- package/packages/tui/dist/usePolling-BbjnRWgx.js +2 -0
- package/scaffold/adapters/copilot.mjs +9 -81
- package/scaffold/definitions/agents.mjs +12 -0
- package/scaffold/definitions/bodies.mjs +39 -14
- package/scaffold/definitions/protocols.mjs +149 -0
- package/scaffold/definitions/tools.mjs +40 -5
- package/scaffold/general/agents/Architect-Reviewer-Alpha.agent.md +1 -1
- package/scaffold/general/agents/Architect-Reviewer-Beta.agent.md +1 -1
- package/scaffold/general/agents/Code-Reviewer-Alpha.agent.md +1 -1
- package/scaffold/general/agents/Code-Reviewer-Beta.agent.md +1 -1
- package/scaffold/general/agents/Debugger.agent.md +2 -2
- package/scaffold/general/agents/Documenter.agent.md +2 -2
- package/scaffold/general/agents/Explorer.agent.md +4 -3
- package/scaffold/general/agents/Frontend.agent.md +1 -1
- package/scaffold/general/agents/Implementer.agent.md +1 -1
- package/scaffold/general/agents/Orchestrator.agent.md +16 -1
- package/scaffold/general/agents/Planner.agent.md +11 -4
- package/scaffold/general/agents/Refactor.agent.md +1 -1
- package/scaffold/general/agents/Researcher-Alpha.agent.md +1 -1
- package/scaffold/general/agents/Researcher-Beta.agent.md +1 -1
- package/scaffold/general/agents/Researcher-Delta.agent.md +1 -1
- package/scaffold/general/agents/Researcher-Gamma.agent.md +1 -1
- package/scaffold/general/agents/Security.agent.md +10 -8
- package/scaffold/general/agents/_shared/architect-reviewer-base.md +1 -0
- package/scaffold/general/agents/_shared/code-agent-base.md +28 -0
- package/scaffold/general/agents/_shared/code-reviewer-base.md +1 -0
- package/scaffold/general/agents/_shared/forge-protocol.md +44 -0
- package/scaffold/general/agents/_shared/researcher-base.md +14 -0
- package/scaffold/general/agents/templates/adr-template.md +1 -0
- package/scaffold/general/agents/templates/execution-state.md +1 -0
- package/skills/knowledge-base/SKILL.md +19 -6
- package/skills/present/SKILL.md +153 -0
- package/packages/server/dist/tools/toolkit.tools.d.ts +0 -36
- package/packages/server/dist/tools/toolkit.tools.js +0 -20
- package/packages/tui/dist/App-DE_tdOhs.js +0 -2
- package/packages/tui/dist/CuratedPanel-sYdZAICX.js +0 -2
- package/packages/tui/dist/LogPanel-Ce3jMQbH.js +0 -3
- package/packages/tui/dist/SearchPanel-DREo6zgt.js +0 -2
- package/packages/tui/dist/StatusPanel-2ex8fLOO.js +0 -2
- package/packages/tui/dist/embedder.interface-IFCBpOlX.d.ts +0 -28
- package/packages/tui/dist/index-C8NmOF18.d.ts +0 -13
- package/packages/tui/dist/jsx-runtime-Cof-kwFn.js +0 -316
- package/packages/tui/dist/store.interface-CnY6SPOH.d.ts +0 -150
- /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
|
-
- **
|
|
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
|
|
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/ —
|
|
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.
|
|
3
|
+
"version": "0.1.26",
|
|
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": ">=
|
|
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
|
|
2
|
-
`),a=new Set,o=
|
|
3
|
-
`).length,l=s===`function`||s===`method`?
|
|
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`?
|
|
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{
|
|
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
|
|
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{
|
|
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`),
|
|
3
|
-
Note: User-level KB is also installed. This workspace uses its own local data store.`)}async function
|
|
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
|
|
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{
|
|
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
|
|
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
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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};
|
|
@@ -18,7 +18,7 @@ interface UserLevelIdePath {
|
|
|
18
18
|
globalScaffoldRoot: string | null;
|
|
19
19
|
/**
|
|
20
20
|
* User-level instruction file root (may differ from scaffold root).
|
|
21
|
-
* VS Code uses ~/.
|
|
21
|
+
* VS Code uses ~/.copilot/instructions/ for .instructions.md files.
|
|
22
22
|
* When null, falls back to globalScaffoldRoot.
|
|
23
23
|
*/
|
|
24
24
|
instructionsRoot: string | null;
|
|
@@ -42,7 +42,7 @@ declare function writeVscodeSettings(idePath: UserLevelIdePath, force?: boolean)
|
|
|
42
42
|
* global scaffold root.
|
|
43
43
|
*
|
|
44
44
|
* Each IDE has its own global discovery path:
|
|
45
|
-
* - VS Code / VSCodium: ~/.copilot/ (agents/, prompts/, skills
|
|
45
|
+
* - VS Code / VSCodium: ~/.copilot/ (agents/, prompts/, skills/, instructions/)
|
|
46
46
|
* - Claude Code: ~/.claude/ (CLAUDE.md, agents/)
|
|
47
47
|
* - Cursor: ~/.cursor/ (rules/kb.mdc, agents/, prompts/, skills/)
|
|
48
48
|
* - Windsurf: ~/.windsurf/ (rules/kb.md, agents/, prompts/, skills/)
|
|
@@ -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{
|
|
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)
|
|
3
|
-
Installing scaffold files:`),
|
|
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(r,`instructions`),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,`kb.instructions.md`);h.has(r)||(u(r,`---\napplyTo: "**"\n---\n\n${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{
|
|
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};
|