@vpxa/kb 0.1.24 → 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.
- 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 +1 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={search:{title:`Hybrid Search`,annotations:{readOnlyHint:!0,idempotentHint:!0}},find:{title:`Federated Find`,annotations:{readOnlyHint:!0,idempotentHint:!0}},symbol:{title:`Symbol Resolver`,annotations:{readOnlyHint:!0,idempotentHint:!0}},trace:{title:`Data Flow Tracer`,annotations:{readOnlyHint:!0,idempotentHint:!0}},scope_map:{title:`Task Scope Map`,annotations:{readOnlyHint:!0,idempotentHint:!0}},lookup:{title:`Chunk Lookup`,annotations:{readOnlyHint:!0,idempotentHint:!0}},dead_symbols:{title:`Dead Symbol Finder`,annotations:{readOnlyHint:!0,idempotentHint:!0}},file_summary:{title:`File Summary`,annotations:{readOnlyHint:!0,idempotentHint:!0}},analyze_structure:{title:`Analyze Structure`,annotations:{readOnlyHint:!0,idempotentHint:!0}},analyze_dependencies:{title:`Analyze Dependencies`,annotations:{readOnlyHint:!0,idempotentHint:!0}},analyze_symbols:{title:`Analyze Symbols`,annotations:{readOnlyHint:!0,idempotentHint:!0}},analyze_patterns:{title:`Analyze Patterns`,annotations:{readOnlyHint:!0,idempotentHint:!0}},analyze_entry_points:{title:`Analyze Entry Points`,annotations:{readOnlyHint:!0,idempotentHint:!0}},analyze_diagram:{title:`Analyze Diagram`,annotations:{readOnlyHint:!0,idempotentHint:!0}},blast_radius:{title:`Blast Radius`,annotations:{readOnlyHint:!0,idempotentHint:!0}},remember:{title:`Remember Knowledge`,annotations:{readOnlyHint:!1}},read:{title:`Read Knowledge`,annotations:{readOnlyHint:!0,idempotentHint:!0}},update:{title:`Update Knowledge`,annotations:{readOnlyHint:!1}},forget:{title:`Forget Knowledge`,annotations:{readOnlyHint:!1,destructiveHint:!0}},list:{title:`List Knowledge`,annotations:{readOnlyHint:!0,idempotentHint:!0}},produce_knowledge:{title:`Produce Knowledge`,annotations:{readOnlyHint:!0,idempotentHint:!0}},compact:{title:`Semantic Compactor`,annotations:{readOnlyHint:!0,idempotentHint:!0}},digest:{title:`Multi-Source Digest`,annotations:{readOnlyHint:!0,idempotentHint:!0}},stratum_card:{title:`Stratum Card`,annotations:{readOnlyHint:!0,idempotentHint:!0}},forge_ground:{title:`FORGE Ground`,annotations:{readOnlyHint:!0,idempotentHint:!0}},forge_classify:{title:`FORGE Classify`,annotations:{readOnlyHint:!0,idempotentHint:!0}},evidence_map:{title:`Evidence Map`,annotations:{readOnlyHint:!1}},check:{title:`Typecheck & Lint`,annotations:{readOnlyHint:!0,openWorldHint:!0}},test_run:{title:`Run Tests`,annotations:{readOnlyHint:!0,openWorldHint:!0}},eval:{title:`Evaluate Code`,annotations:{readOnlyHint:!1,openWorldHint:!0}},batch:{title:`Batch Operations`,annotations:{readOnlyHint:!0,idempotentHint:!0}},audit:{title:`Project Audit`,annotations:{readOnlyHint:!0,idempotentHint:!0}},rename:{title:`Rename Symbol`,annotations:{readOnlyHint:!1,destructiveHint:!0}},restore:{title:`Restore`,annotations:{readOnlyHint:!1}},codemod:{title:`Codemod`,annotations:{readOnlyHint:!1,destructiveHint:!0}},data_transform:{title:`Data Transform`,annotations:{readOnlyHint:!0,idempotentHint:!0}},stash:{title:`Stash Values`,annotations:{readOnlyHint:!1}},checkpoint:{title:`Session Checkpoint`,annotations:{readOnlyHint:!1}},workset:{title:`Workset Manager`,annotations:{readOnlyHint:!1}},lane:{title:`Exploration Lane`,annotations:{readOnlyHint:!1}},git_context:{title:`Git Context`,annotations:{readOnlyHint:!0,idempotentHint:!0}},diff_parse:{title:`Diff Parser`,annotations:{readOnlyHint:!0,idempotentHint:!0}},parse_output:{title:`Parse Build Output`,annotations:{readOnlyHint:!0,idempotentHint:!0}},process:{title:`Process Manager`,annotations:{readOnlyHint:!1,openWorldHint:!0}},watch:{title:`File Watcher`,annotations:{readOnlyHint:!1,openWorldHint:!0}},delegate:{title:`Delegate Task`,annotations:{readOnlyHint:!1,openWorldHint:!0}},status:{title:`KB Status`,annotations:{readOnlyHint:!0,idempotentHint:!0}},health:{title:`Health Check`,annotations:{readOnlyHint:!0,idempotentHint:!0}},reindex:{title:`Reindex`,annotations:{readOnlyHint:!1}},onboard:{title:`Onboard Codebase`,annotations:{readOnlyHint:!1}},graph:{title:`Knowledge Graph`,annotations:{readOnlyHint:!1}},guide:{title:`Tool Guide`,annotations:{readOnlyHint:!0,idempotentHint:!0}},replay:{title:`Replay History`,annotations:{readOnlyHint:!0,idempotentHint:!0}},changelog:{title:`Generate Changelog`,annotations:{readOnlyHint:!0,idempotentHint:!0}},regex_test:{title:`Regex Tester`,annotations:{readOnlyHint:!0,idempotentHint:!0}},encode:{title:`Encode / Decode`,annotations:{readOnlyHint:!0,idempotentHint:!0}},measure:{title:`Code Metrics`,annotations:{readOnlyHint:!0,idempotentHint:!0}},schema_validate:{title:`Schema Validator`,annotations:{readOnlyHint:!0,idempotentHint:!0}},snippet:{title:`Code Snippets`,annotations:{readOnlyHint:!1}},env:{title:`Environment Info`,annotations:{readOnlyHint:!0,idempotentHint:!0}},time:{title:`Date & Time`,annotations:{readOnlyHint:!0,idempotentHint:!0}},web_fetch:{title:`Web Fetch`,annotations:{readOnlyHint:!0,openWorldHint:!0}},web_search:{title:`Web Search`,annotations:{readOnlyHint:!0,openWorldHint:!0}},http:{title:`HTTP Request`,annotations:{readOnlyHint:!1,openWorldHint:!0}},queue:{title:`Operation Queue`,annotations:{readOnlyHint:!1}},bridge_push:{title:`Bridge Push`,annotations:{readOnlyHint:!1}},bridge_pull:{title:`Bridge Pull`,annotations:{readOnlyHint:!0,idempotentHint:!0}},bridge_sync:{title:`Bridge Sync Status`,annotations:{readOnlyHint:!0,idempotentHint:!0}},evolution_state:{title:`Evolution State`,annotations:{readOnlyHint:!1}},policy_check:{title:`Policy Check`,annotations:{readOnlyHint:!0,idempotentHint:!0}}};function t(t){return e[t]??{title:t,annotations:{readOnlyHint:!1}}}export{e as TOOL_METADATA,t as getToolMeta};
|
|
1
|
+
const e={search:{title:`Hybrid Search`,annotations:{readOnlyHint:!0,idempotentHint:!0}},find:{title:`Federated Find`,annotations:{readOnlyHint:!0,idempotentHint:!0}},symbol:{title:`Symbol Resolver`,annotations:{readOnlyHint:!0,idempotentHint:!0}},trace:{title:`Data Flow Tracer`,annotations:{readOnlyHint:!0,idempotentHint:!0}},scope_map:{title:`Task Scope Map`,annotations:{readOnlyHint:!0,idempotentHint:!0}},lookup:{title:`Chunk Lookup`,annotations:{readOnlyHint:!0,idempotentHint:!0}},dead_symbols:{title:`Dead Symbol Finder`,annotations:{readOnlyHint:!0,idempotentHint:!0}},file_summary:{title:`File Summary`,annotations:{readOnlyHint:!0,idempotentHint:!0}},analyze_structure:{title:`Analyze Structure`,annotations:{readOnlyHint:!0,idempotentHint:!0}},analyze_dependencies:{title:`Analyze Dependencies`,annotations:{readOnlyHint:!0,idempotentHint:!0}},analyze_symbols:{title:`Analyze Symbols`,annotations:{readOnlyHint:!0,idempotentHint:!0}},analyze_patterns:{title:`Analyze Patterns`,annotations:{readOnlyHint:!0,idempotentHint:!0}},analyze_entry_points:{title:`Analyze Entry Points`,annotations:{readOnlyHint:!0,idempotentHint:!0}},analyze_diagram:{title:`Analyze Diagram`,annotations:{readOnlyHint:!0,idempotentHint:!0}},blast_radius:{title:`Blast Radius`,annotations:{readOnlyHint:!0,idempotentHint:!0}},brainstorm:{title:`Brainstorm Session`,annotations:{readOnlyHint:!0,idempotentHint:!0}},remember:{title:`Remember Knowledge`,annotations:{readOnlyHint:!1}},read:{title:`Read Knowledge`,annotations:{readOnlyHint:!0,idempotentHint:!0}},update:{title:`Update Knowledge`,annotations:{readOnlyHint:!1}},forget:{title:`Forget Knowledge`,annotations:{readOnlyHint:!1,destructiveHint:!0}},list:{title:`List Knowledge`,annotations:{readOnlyHint:!0,idempotentHint:!0}},produce_knowledge:{title:`Produce Knowledge`,annotations:{readOnlyHint:!0,idempotentHint:!0}},compact:{title:`Semantic Compactor`,annotations:{readOnlyHint:!0,idempotentHint:!0}},digest:{title:`Multi-Source Digest`,annotations:{readOnlyHint:!0,idempotentHint:!0}},stratum_card:{title:`Stratum Card`,annotations:{readOnlyHint:!0,idempotentHint:!0}},forge_ground:{title:`FORGE Ground`,annotations:{readOnlyHint:!0,idempotentHint:!0}},forge_classify:{title:`FORGE Classify`,annotations:{readOnlyHint:!0,idempotentHint:!0}},evidence_map:{title:`Evidence Map`,annotations:{readOnlyHint:!1}},present:{title:`Rich Content Presenter`,annotations:{readOnlyHint:!0,idempotentHint:!0}},check:{title:`Typecheck & Lint`,annotations:{readOnlyHint:!0,openWorldHint:!0}},test_run:{title:`Run Tests`,annotations:{readOnlyHint:!0,openWorldHint:!0}},eval:{title:`Evaluate Code`,annotations:{readOnlyHint:!1,openWorldHint:!0}},batch:{title:`Batch Operations`,annotations:{readOnlyHint:!0,idempotentHint:!0}},audit:{title:`Project Audit`,annotations:{readOnlyHint:!0,idempotentHint:!0}},rename:{title:`Rename Symbol`,annotations:{readOnlyHint:!1,destructiveHint:!0}},restore:{title:`Restore`,annotations:{readOnlyHint:!1}},codemod:{title:`Codemod`,annotations:{readOnlyHint:!1,destructiveHint:!0}},data_transform:{title:`Data Transform`,annotations:{readOnlyHint:!0,idempotentHint:!0}},stash:{title:`Stash Values`,annotations:{readOnlyHint:!1}},checkpoint:{title:`Session Checkpoint`,annotations:{readOnlyHint:!1}},workset:{title:`Workset Manager`,annotations:{readOnlyHint:!1}},lane:{title:`Exploration Lane`,annotations:{readOnlyHint:!1}},git_context:{title:`Git Context`,annotations:{readOnlyHint:!0,idempotentHint:!0}},diff_parse:{title:`Diff Parser`,annotations:{readOnlyHint:!0,idempotentHint:!0}},parse_output:{title:`Parse Build Output`,annotations:{readOnlyHint:!0,idempotentHint:!0}},process:{title:`Process Manager`,annotations:{readOnlyHint:!1,openWorldHint:!0}},watch:{title:`File Watcher`,annotations:{readOnlyHint:!1,openWorldHint:!0}},delegate:{title:`Delegate Task`,annotations:{readOnlyHint:!1,openWorldHint:!0}},status:{title:`KB Status`,annotations:{readOnlyHint:!0,idempotentHint:!0}},health:{title:`Health Check`,annotations:{readOnlyHint:!0,idempotentHint:!0}},reindex:{title:`Reindex`,annotations:{readOnlyHint:!1}},onboard:{title:`Onboard Codebase`,annotations:{readOnlyHint:!1}},graph:{title:`Knowledge Graph`,annotations:{readOnlyHint:!1}},guide:{title:`Tool Guide`,annotations:{readOnlyHint:!0,idempotentHint:!0}},replay:{title:`Replay History`,annotations:{readOnlyHint:!0,idempotentHint:!0}},changelog:{title:`Generate Changelog`,annotations:{readOnlyHint:!0,idempotentHint:!0}},regex_test:{title:`Regex Tester`,annotations:{readOnlyHint:!0,idempotentHint:!0}},encode:{title:`Encode / Decode`,annotations:{readOnlyHint:!0,idempotentHint:!0}},measure:{title:`Code Metrics`,annotations:{readOnlyHint:!0,idempotentHint:!0}},schema_validate:{title:`Schema Validator`,annotations:{readOnlyHint:!0,idempotentHint:!0}},snippet:{title:`Code Snippets`,annotations:{readOnlyHint:!1}},env:{title:`Environment Info`,annotations:{readOnlyHint:!0,idempotentHint:!0}},time:{title:`Date & Time`,annotations:{readOnlyHint:!0,idempotentHint:!0}},web_fetch:{title:`Web Fetch`,annotations:{readOnlyHint:!0,openWorldHint:!0}},web_search:{title:`Web Search`,annotations:{readOnlyHint:!0,openWorldHint:!0}},http:{title:`HTTP Request`,annotations:{readOnlyHint:!1,openWorldHint:!0}},queue:{title:`Operation Queue`,annotations:{readOnlyHint:!1}},bridge_push:{title:`Bridge Push`,annotations:{readOnlyHint:!1}},bridge_pull:{title:`Bridge Pull`,annotations:{readOnlyHint:!0,idempotentHint:!0}},bridge_sync:{title:`Bridge Sync Status`,annotations:{readOnlyHint:!0,idempotentHint:!0}},evolution_state:{title:`Evolution State`,annotations:{readOnlyHint:!1}},policy_check:{title:`Policy Check`,annotations:{readOnlyHint:!0,idempotentHint:!0}}};function t(t){return e[t]??{title:t,annotations:{readOnlyHint:!1}}}export{e as TOOL_METADATA,t as getToolMeta};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
|
|
3
|
+
//#region packages/server/src/tool-prefix.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Install a tool-name prefix interceptor on the given McpServer.
|
|
6
|
+
*
|
|
7
|
+
* @param server The MCP server whose `registerTool` method will be wrapped.
|
|
8
|
+
* @param prefix A string prepended to every tool name. Empty string = no-op.
|
|
9
|
+
*/
|
|
10
|
+
declare function installToolPrefix(server: McpServer, prefix: string): void;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { installToolPrefix };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t){if(!t)return;let n=e.registerTool.bind(e);e.registerTool=(e,r,i)=>{let a=`${t}${e}`;return i===void 0?n(a,r):n(a,r,i)}}export{e as installToolPrefix};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{getToolMeta as e}from"../tool-metadata.js";import{
|
|
1
|
+
import{getToolMeta as e}from"../tool-metadata.js";import{AnalyzeStructureOutputSchema as t,BlastRadiusOutputSchema as n}from"../output-schemas.js";import{createHash as r}from"node:crypto";import{z as i}from"zod";import{createLogger as a,serializeError as o}from"../../../core/dist/index.js";import{BlastRadiusAnalyzer as s,DependencyAnalyzer as c,DiagramGenerator as l,EntryPointAnalyzer as u,PatternAnalyzer as d,StructureAnalyzer as f,SymbolAnalyzer as p}from"../../../analyzers/dist/index.js";import{WasmRuntime as m}from"../../../chunker/dist/index.js";import{gitContext as h,truncateToTokenBudget as g}from"../../../tools/dist/index.js";const _=a(`tools`),v=i.number().min(100).max(5e4).optional().describe(`Maximum token budget for the response. When set, output is truncated to fit.`);function y(e,t){return t?g(e,t):e}function b(){let e=[];return m.get()||e.push(`Tree-sitter unavailable — using regex fallback, symbol/pattern confidence reduced`),e.length===0?``:`\n\n> **⚠ Caveats:** ${e.join(`; `)}`}function x(e){return(e??[]).map(e=>{if(typeof e==`string`)return e;if(e&&typeof e==`object`&&`path`in e)return typeof e.path==`string`?e.path:void 0}).filter(e=>!!e)}function S(e){let t=[],n=e.filter(e=>/\.(ts|tsx|js|jsx)$/.test(e)&&/(service|store|model|schema|migration)/i.test(e)),r=e.filter(e=>/\.(ts|tsx|js|jsx)$/.test(e)&&!n.includes(e)),i=e.filter(e=>!/\.(ts|tsx|js|jsx)$/.test(e));return(n.length>0||r.length>0||i.length>0)&&(t.push(`
|
|
2
2
|
|
|
3
3
|
### Risk Assessment`),n.length>0&&t.push(`- 🔴 **High risk** (${n.length}): ${n.slice(0,5).map(e=>`\`${e}\``).join(`, `)}`),r.length>0&&t.push(`- 🟡 **Medium risk** (${r.length}): source files`),i.length>0&&t.push(`- 🟢 **Low risk** (${i.length}): non-source files`)),t.join(`
|
|
4
|
-
`)}function
|
|
4
|
+
`)}function C(e){let t=e.replace(/\\/g,`/`);return/(^|\/)__tests__\/|\.(test|spec)\.[jt]sx?$/i.test(t)?`Tests`:/(controller|route|handler|api)/i.test(t)?`API`:/(service|store|model|schema|migration|repo|repository|db|database)/i.test(t)?`Core/Data`:/\.(ts|tsx|js|jsx)$/.test(t)?`Source`:`Config/Docs`}function w(e){if(e.length===0)return``;let t=[`Core/Data`,`API`,`Source`,`Tests`,`Config/Docs`],n=new Map;for(let t of e){let e=C(t),r=n.get(e)??[];r.push(t),n.set(e,r)}let r=[`
|
|
5
5
|
|
|
6
6
|
### Layer Classification`];for(let e of t){let t=n.get(e);if(!t?.length)continue;let i=t.slice(0,5).map(e=>`\`${e}\``).join(`, `),a=t.length>5?`, ... and ${t.length-5} more`:``;r.push(`- **${e}** (${t.length}): ${i}${a}`)}return r.join(`
|
|
7
|
-
`)}async function
|
|
8
|
-
`),e.size>20&&(d+=`\n- ... and ${e.size-20} more`))}catch{}let f=
|
|
7
|
+
`)}async function T(e,t,n,i,a){try{let o=`produced/analysis/${n}/${r(`sha256`).update(i).digest(`hex`).slice(0,12)}.md`,s=r(`sha256`).update(a).digest(`hex`).slice(0,16),c=new Date().toISOString(),l=a.length>2e3?a.split(/(?=^## )/m).filter(e=>e.trim().length>0):[a],u=l.map((e,t)=>({id:r(`sha256`).update(`${o}::${t}`).digest(`hex`).slice(0,16),content:e.trim(),sourcePath:o,contentType:`produced-knowledge`,chunkIndex:t,totalChunks:l.length,startLine:0,endLine:0,fileHash:s,indexedAt:c,origin:`produced`,tags:[`analysis`,n],category:`analysis`,version:1})),d=await t.embedBatch(u.map(e=>e.content));await e.upsert(u,d),_.info(`Auto-persisted analysis`,{analyzerName:n,chunkCount:u.length})}catch(e){_.warn(`Auto-persist analysis failed`,{analyzerName:n,...o(e)})}}function E(n,r,a){let s=new f,c=e(`analyze_structure`);n.registerTool(`analyze_structure`,{title:c.title,description:`Analyze the file/directory structure of a codebase. Returns an annotated tree with language stats.`,outputSchema:t,inputSchema:{path:i.string().describe(`Root path to analyze`),max_depth:i.number().min(1).max(10).default(6).describe(`Maximum directory depth`),format:i.enum([`json`,`markdown`]).default(`markdown`).describe(`Output format`),max_tokens:v},annotations:c.annotations},async({path:e,max_depth:t,format:n,max_tokens:i})=>{try{let o=await s.analyze(e,{format:n,maxDepth:t,maxTokens:i});T(r,a,`structure`,e,o.output);let c=o.data;return{content:[{type:`text`,text:y(o.output+"\n\n---\n_Analysis auto-saved to KB. Next: Use `analyze_dependencies` for import graphs, or `analyze_patterns` to detect architecture patterns._",i)}],structuredContent:{files:c.fileCount??o.meta.fileCount,packages:c.packageCount??0,languages:c.languages??{},tree:o.output.slice(0,2e3)}}}catch(e){return _.error(`Analysis failed`,o(e)),{content:[{type:`text`,text:`Analysis failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function D(t,n,r){let a=new c,s=e(`analyze_dependencies`);t.registerTool(`analyze_dependencies`,{title:s.title,description:`Analyze import/require dependencies across a codebase. Shows external packages and internal module graph.`,inputSchema:{path:i.string().describe(`Root path to analyze`),format:i.enum([`json`,`markdown`,`mermaid`]).default(`markdown`).describe(`Output format`),max_tokens:v},annotations:s.annotations},async({path:e,format:t,max_tokens:i})=>{try{let o=await a.analyze(e,{format:t});return T(n,r,`dependencies`,e,o.output),{content:[{type:`text`,text:y(o.output+"\n\n---\n_Analysis auto-saved to KB. Next: Use `analyze_symbols` to explore exported symbols, or `analyze_diagram` for visual representation._",i)}]}}catch(e){return _.error(`Analysis failed`,o(e)),{content:[{type:`text`,text:`Analysis failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function O(t,n,r){let a=new p,s=e(`analyze_symbols`);t.registerTool(`analyze_symbols`,{title:s.title,description:`Extract exported and local symbols (functions, classes, interfaces, types, constants) from a codebase.`,inputSchema:{path:i.string().describe(`Root path to analyze`),filter:i.string().optional().describe(`Filter symbols by name substring`),format:i.enum([`json`,`markdown`]).default(`markdown`).describe(`Output format`)},annotations:s.annotations},async({path:e,filter:t,format:i})=>{try{let o=await a.analyze(e,{format:i,filter:t});return T(n,r,`symbols`,e,o.output),{content:[{type:`text`,text:o.output+b()+"\n\n---\n_Analysis auto-saved to KB. Next: Use `analyze_dependencies` to see import relationships, or `search` to find usage patterns._"}]}}catch(e){return _.error(`Analysis failed`,o(e)),{content:[{type:`text`,text:`Analysis failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function k(t,n,r){let a=new d,s=e(`analyze_patterns`);t.registerTool(`analyze_patterns`,{title:s.title,description:`Detect architectural patterns, frameworks, and conventions in a codebase using directory structure and code heuristics.`,inputSchema:{path:i.string().describe(`Root path to analyze`)},annotations:s.annotations},async({path:e})=>{try{let t=await a.analyze(e);return T(n,r,`patterns`,e,t.output),{content:[{type:`text`,text:t.output+b()+"\n\n---\n_Analysis auto-saved to KB. Next: Use `analyze_entry_points` to find Lambda handlers and main exports, or `produce_knowledge` for full analysis._"}]}}catch(e){return _.error(`Analysis failed`,o(e)),{content:[{type:`text`,text:`Analysis failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function A(t,n,r){let a=new u,s=e(`analyze_entry_points`);t.registerTool(`analyze_entry_points`,{title:s.title,description:`Find entry points: Lambda handlers, main exports, CLI bins, and server start scripts.`,inputSchema:{path:i.string().describe(`Root path to analyze`)},annotations:s.annotations},async({path:e})=>{try{let t=await a.analyze(e);return T(n,r,`entry-points`,e,t.output),{content:[{type:`text`,text:t.output+b()+"\n\n---\n_Analysis auto-saved to KB. Next: Use `analyze_dependencies` to see what each entry point imports, or `produce_knowledge` for comprehensive analysis._"}]}}catch(e){return _.error(`Analysis failed`,o(e)),{content:[{type:`text`,text:`Analysis failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function j(t,n,r){let a=new l,s=e(`analyze_diagram`);t.registerTool(`analyze_diagram`,{title:s.title,description:`Generate a Mermaid diagram of the codebase architecture or dependency graph. Returns Mermaid flowchart syntax — paste into any Markdown renderer or Mermaid editor to visualize.`,inputSchema:{path:i.string().describe(`Root path to analyze`),diagram_type:i.enum([`architecture`,`dependencies`]).default(`architecture`).describe(`Type of diagram`)},annotations:s.annotations},async({path:e,diagram_type:t})=>{try{let i=await a.analyze(e,{diagramType:t});return T(n,r,`diagram`,e,i.output),{content:[{type:`text`,text:i.output+"\n\n---\n_Analysis auto-saved to KB. Next: Use `analyze_structure` for detailed file tree, or `produce_knowledge` for comprehensive analysis._"}]}}catch(e){return _.error(`Diagram generation failed`,o(e)),{content:[{type:`text`,text:`Diagram generation failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function M(t,r,a,c){let l=new s,u=e(`blast_radius`);t.registerTool(`blast_radius`,{title:u.title,description:`Given a list of changed files, trace the dependency graph to find all affected files (direct + transitive importers) and their tests. Useful for scoping code reviews and impact analysis.`,outputSchema:n,inputSchema:{path:i.string().describe(`Root path of the codebase`),files:i.array(i.string()).optional().describe(`Changed file paths (relative to root). If omitted, auto-detects from git status.`),max_depth:i.number().min(1).max(20).default(5).describe(`Maximum transitive dependency depth`),format:i.enum([`json`,`markdown`]).default(`markdown`).describe(`Output format`),max_tokens:v},annotations:u.annotations},async({path:e,files:t,max_depth:n,format:i,max_tokens:s})=>{try{let o=t??[];if(o.length===0)try{let t=await h({cwd:e,includeDiff:!1});if(o=Array.from(new Set([...x(t.status?.staged),...x(t.status?.modified),...x(t.status?.untracked)])),o.length===0)return{content:[{type:`text`,text:"No changed files detected from git status. Provide `files` explicitly or make changes first."}]}}catch{return{content:[{type:`text`,text:"Could not detect changed files from git. Provide `files` explicitly."}],isError:!0}}let u=await l.analyze(e,{files:o,maxDepth:n,format:i}),d=``;if(c)try{let e=new Set;for(let t of o){let n=await c.findNodes({sourcePath:t,limit:10});for(let t of n){let n=await c.getNeighbors(t.id,{direction:`incoming`,edgeType:`imports`});for(let t of n.nodes){let n=t.sourcePath??t.name;o.includes(n)||e.add(n)}}}e.size>0&&(d=`\n\n### Graph-discovered importers (${e.size})\n`+[...e].slice(0,20).map(e=>`- \`${e}\``).join(`
|
|
8
|
+
`),e.size>20&&(d+=`\n- ... and ${e.size-20} more`))}catch{}let f=w(o),p=S(o),m=u.output+d+f+p+b()+"\n\n---\n_Analysis auto-saved to KB. Next: Use `analyze_dependencies` to see the full import graph, or `analyze_symbols` to inspect affected exports._";T(r,a,`blast-radius`,e,m);let g=new Set;if(c)for(let e of o)try{let t=await c.findNodes({sourcePath:e,limit:10});for(let e of t){let t=await c.getNeighbors(e.id,{direction:`incoming`,edgeType:`imports`});for(let e of t.nodes){let t=e.sourcePath??e.name;o.includes(t)||g.add(t)}}}catch{}let _=[...g].map(e=>({path:e,impact:`transitive`,reason:`imports changed file`})),v=o.length>10?`high`:o.length>3?`medium`:`low`;return{content:[{type:`text`,text:y(m,s)}],structuredContent:{changedFiles:o,affectedFiles:_,totalAffected:_.length,riskLevel:v}}}catch(e){return _.error(`Blast radius analysis failed`,o(e)),{content:[{type:`text`,text:`Blast radius analysis failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}export{D as registerAnalyzeDependenciesTool,j as registerAnalyzeDiagramTool,A as registerAnalyzeEntryPointsTool,k as registerAnalyzePatternsTool,E as registerAnalyzeStructureTool,O as registerAnalyzeSymbolsTool,M as registerBlastRadiusTool};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getToolMeta as e}from"../tool-metadata.js";import{
|
|
1
|
+
import{getToolMeta as e}from"../tool-metadata.js";import{AuditOutputSchema as t}from"../output-schemas.js";import{createTaskRunner as n}from"../task-manager.js";import{z as r}from"zod";import{createLogger as i,serializeError as a}from"../../../core/dist/index.js";import{audit as o}from"../../../tools/dist/index.js";const s=i(`tools`);function c(i,c,l){let u=e(`audit`);i.registerTool(`audit`,{title:u.title,description:`Run a unified audit: structure, dependencies, patterns, health, dead_symbols, check, entry_points. Returns synthesized report with score, recommendations, and next steps. 6 round-trips → 1.`,outputSchema:t,inputSchema:{path:r.string().default(`.`).describe(`Root path to audit`),checks:r.array(r.enum([`structure`,`dependencies`,`patterns`,`health`,`dead_symbols`,`check`,`entry_points`])).optional().describe(`Which checks to run (default: all)`),detail:r.enum([`summary`,`full`]).default(`summary`).describe(`'summary' for overview (~500 tokens), 'full' includes pattern table`)},annotations:u.annotations},async({path:e,checks:t,detail:r},i)=>{try{let a=await o(c,l,{path:e,checks:t,detail:r});return n(i).createTask(`Audit`,1).complete(`Audit complete: ${a.data?.recommendations?.length??0} recommendations`),{content:[{type:`text`,text:a.ok?`${a.summary}\n\n---\n_Audit score: ${a.data?.score}/100 | ${a.meta.durationMs}ms${a.next&&a.next.length>0?` | Next: ${a.next.map(e=>`\`${e.tool}\` (${e.reason})`).join(`, `)}`:``}_`:a.error?.message??`Audit failed`}],isError:!a.ok,...a.ok&&a.data?{structuredContent:{passed:a.ok,score:a.data.score??0,checks:(a.data.recommendations??[]).map(e=>({name:e.area,passed:e.priority!==`high`,message:e.message,severity:e.priority})),summary:a.summary??``}}:{}}}catch(e){return s.error(`Audit failed`,a(e)),{content:[{type:`text`,text:`Audit failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}export{c as registerAuditTool};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { Elicitor } from "@kb/elicitation";
|
|
3
|
+
|
|
4
|
+
//#region packages/server/src/tools/brainstorm.tool.d.ts
|
|
5
|
+
declare function registerBrainstormTool(server: McpServer, elicitor: Elicitor): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { registerBrainstormTool };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{getToolMeta as e}from"../tool-metadata.js";import{z as t}from"zod";import{createLogger as n}from"../../../core/dist/index.js";const r=n(`tools`);function i(n,i){let s=e(`brainstorm`);n.registerTool(`brainstorm`,{title:s.title,description:`Interactive brainstorming tool for exploring ideas, making design decisions, and gathering requirements. Supports multiple actions: ask_choice (single selection), ask_multi (multiple selections), ask_freeform (text input), ask_confirm (yes/no), present_design (show summary and confirm). Falls back to text-only mode when elicitation is unavailable.`,inputSchema:{action:t.enum([`ask_choice`,`ask_multi`,`ask_freeform`,`ask_confirm`,`present_design`]).describe(`The type of brainstorm interaction`),message:t.string().describe(`The question or prompt to present`),options:t.array(t.string()).optional().describe(`Options for ask_choice/ask_multi actions`),context:t.string().optional().describe(`Additional context to include in the prompt`)},annotations:s.annotations},async({action:e,message:t,options:n,context:s})=>{let c=s?`${s}\n\n${t}`:t;if(!i.available)return o(e,c,n);try{switch(e){case`ask_choice`:{if(!n?.length)return a(`Error: ask_choice requires options array`);let e=await i.selectOne(c,n);return a(e===null?`No selection made (declined or cancelled).`:`Selected: **${e}**`)}case`ask_multi`:{if(!n?.length)return a(`Error: ask_multi requires options array`);let e=await i.selectMany(c,n);return e.length===0?a(`No selections made (declined or cancelled).`):a(`Selected:\n${e.map(e=>`- ${e}`).join(`
|
|
2
|
+
`)}`)}case`ask_freeform`:{let e=await i.promptText(c);return a(e===null?`No input provided (declined or cancelled).`:`Response:\n\n${e}`)}case`ask_confirm`:return a(await i.confirm(c)?`Confirmed: **Yes**`:`Confirmed: **No**`);case`present_design`:return a(await i.confirm(`## Design Summary\n\n${c}\n\nDo you approve this design?`)?`## Design Approved ✓
|
|
3
|
+
|
|
4
|
+
Proceeding with the design as described.`:`## Design Not Approved
|
|
5
|
+
|
|
6
|
+
Please provide feedback for revisions.`);default:return a(`Unknown action: ${e}`)}}catch(t){return r.warn(`Brainstorm elicitation failed, falling back to text`,{action:e,error:String(t)}),o(e,c,n)}})}function a(e){return{content:[{type:`text`,text:e}]}}function o(e,t,n){let r=`## Brainstorm: ${e}\n\n${t}`;return n?.length&&(r+=`\n\n**Options:**\n${n.map((e,t)=>`${t+1}. ${e}`).join(`
|
|
7
|
+
`)}`),r+=`
|
|
8
|
+
|
|
9
|
+
> *Elicitation unavailable — please respond with your choice in the next message.*`,{content:[{type:`text`,text:r}]}}export{i as registerBrainstormTool};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{getToolMeta as e}from"../tool-metadata.js";import{
|
|
2
|
-
`)}]}}catch(e){return
|
|
3
|
-
`)+"\n\n---\n_Next: Use `search` to dive into specific files, or `compact` to compress file contents for context._";return{content:[{type:`text`,text:a?
|
|
4
|
-
`),
|
|
5
|
-
`)}]}}catch(e){return
|
|
6
|
-
`)}]}}catch(e){return
|
|
7
|
-
`)}]}}catch(e){return
|
|
8
|
-
`)}function
|
|
9
|
-
`)}function
|
|
1
|
+
import{getToolMeta as e}from"../tool-metadata.js";import{CompactOutputSchema as t,DeadSymbolsOutputSchema as n,FileSummaryOutputSchema as r,FindOutputSchema as i,ScopeMapOutputSchema as a,SymbolOutputSchema as o}from"../output-schemas.js";import{fanOutSearch as s,openWorkspaceStores as c,resolveWorkspaces as l}from"../cross-workspace.js";import{z as u}from"zod";import{CONTENT_TYPES as d,computePartitionKey as f,createLogger as p,serializeError as m}from"../../../core/dist/index.js";import{compact as h,fileSummary as g,find as _,findDeadSymbols as v,findExamples as y,scopeMap as b,symbol as x,trace as S,truncateToTokenBudget as C}from"../../../tools/dist/index.js";const w=p(`tools:context`);function T(n,r,i){let a=e(`compact`);n.registerTool(`compact`,{title:a.title,description:"Compress text to relevant sections using embedding similarity (no LLM). Provide either `text` or `path` (server reads the file — saves a round-trip). Segments by paragraph/sentence/line.",outputSchema:t,inputSchema:{text:u.string().optional().describe(`The text to compress (provide this OR path, not both)`),path:u.string().optional().describe(`File path to read server-side — avoids read_file round-trip + token doubling (provide this OR text)`),query:u.string().describe(`Focus query — what are you trying to understand?`),max_chars:u.number().min(100).max(5e4).default(3e3).describe(`Target output size in characters`),segmentation:u.enum([`paragraph`,`sentence`,`line`]).default(`paragraph`).describe(`How to split the text for scoring`)},annotations:a.annotations},async({text:e,path:t,query:n,max_chars:a,segmentation:o})=>{try{if(!e&&!t)return{content:[{type:`text`,text:`Error: Either "text" or "path" must be provided.`}],isError:!0};let s=await h(r,{text:e,path:t,query:n,maxChars:a,segmentation:o,cache:i});return{content:[{type:`text`,text:[`Compressed ${s.originalChars} → ${s.compressedChars} chars (${(s.ratio*100).toFixed(0)}%)`,`Kept ${s.segmentsKept}/${s.segmentsTotal} segments`,``,s.text].join(`
|
|
2
|
+
`)}],structuredContent:{originalChars:s.originalChars,compressedChars:s.compressedChars,ratio:s.ratio,segmentsKept:s.segmentsKept,segmentsTotal:s.segmentsTotal}}}catch(e){return w.error(`Compact failed`,m(e)),{content:[{type:`text`,text:`Compact failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function E(t,n,r){let i=e(`scope_map`);t.registerTool(`scope_map`,{title:i.title,description:`Generate a task-scoped reading plan. Given a task description, identifies which files and sections are relevant, with estimated token counts and suggested reading order.`,outputSchema:a,inputSchema:{task:u.string().describe(`Description of the task to scope`),max_files:u.number().min(1).max(50).default(15).describe(`Maximum files to include`),content_type:u.enum(d).optional().describe(`Filter by content type`),max_tokens:u.number().min(100).max(5e4).optional().describe(`Maximum token budget for the response. When set, output is truncated to fit.`)},annotations:i.annotations},async({task:e,max_files:t,content_type:i,max_tokens:a})=>{try{let o=await b(n,r,{task:e,maxFiles:t,contentType:i}),s=[`## Scope Map: ${e}`,`Total estimated tokens: ~${o.totalEstimatedTokens}`,``,`### Files (by relevance)`,...o.files.map((e,t)=>`${t+1}. **${e.path}** (~${e.estimatedTokens} tokens, ${(e.relevance*100).toFixed(0)}% relevant)\n ${e.reason}\n Focus: ${e.focusRanges.map(e=>`L${e.start}-${e.end}`).join(`, `)}`),``,`### Suggested Reading Order`,...o.readingOrder.map((e,t)=>`${t+1}. ${e}`),``,`### Suggested Compact Calls`,`_Estimated compressed total: ~${Math.ceil(o.totalEstimatedTokens/5)} tokens_`,...o.compactCommands.map((e,t)=>`${t+1}. ${e}`)].join(`
|
|
3
|
+
`)+"\n\n---\n_Next: Use `search` to dive into specific files, or `compact` to compress file contents for context._";return{content:[{type:`text`,text:a?C(s,a):s}],structuredContent:{files:o.files.map(e=>({path:e.path,relevance:e.relevance,estimatedTokens:e.estimatedTokens,...e.focusRanges.length>0?{focusLines:e.focusRanges.map(e=>`L${e.start}-${e.end}`)}:{}})),totalFiles:o.files.length,totalEstimatedTokens:o.totalEstimatedTokens,task:e}}}catch(e){return w.error(`Scope map failed`,m(e)),{content:[{type:`text`,text:`Scope map failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function D(t,n,r){let a=e(`find`);t.registerTool(`find`,{title:a.title,description:`Multi-strategy search combining vector, FTS, glob, and regex. Use for precise queries needing multiple strategies. mode=examples finds real usage of a symbol. For general discovery use search instead.`,outputSchema:i,inputSchema:{query:u.string().optional().describe(`Semantic/keyword search query (required for mode "examples")`),glob:u.string().optional().describe(`File glob pattern (search mode only)`),pattern:u.string().optional().describe(`Regex pattern to match in content (search mode only)`),limit:u.number().min(1).max(50).default(10).describe(`Max results`),content_type:u.enum(d).optional().describe(`Filter by content type`),mode:u.enum([`search`,`examples`]).default(`search`).describe(`Mode: "search" (default) for federated search, "examples" to find usage examples of a symbol/pattern`),max_tokens:u.number().min(100).max(5e4).optional().describe(`Maximum token budget for the response. When set, output is truncated to fit.`),workspaces:u.array(u.string()).optional().describe(`Cross-workspace search: partition names or folder basenames to include. Use ["*"] for all. User-level mode only.`)},annotations:a.annotations},async({query:e,glob:t,pattern:i,limit:a,content_type:o,mode:u,max_tokens:d,workspaces:p})=>{try{if(u===`examples`){if(!e)return{content:[{type:`text`,text:`Error: "query" is required for mode "examples".`}],isError:!0};let t=await y(n,r,{query:e,limit:a,contentType:o}),i=JSON.stringify(t);return{content:[{type:`text`,text:d?C(i,d):i}]}}let m=await _(n,r,{query:e,glob:t,pattern:i,limit:a,contentType:o}),h=``;if(p&&p.length>0&&e){let t=l(p,f(process.cwd()));if(t.length>0){let{stores:r,closeAll:i}=await c(t);try{let i=await s(r,await n.embedQuery(e),{limit:a,contentType:o});for(let e of i)m.results.push({path:`[${e.workspace}] ${e.record.sourcePath}`,score:e.score,source:`cross-workspace`,lineRange:e.record.startLine?{start:e.record.startLine,end:e.record.endLine}:void 0,preview:e.record.content.slice(0,200)});m.results.sort((e,t)=>t.score-e.score),m.results=m.results.slice(0,a),m.totalFound=m.results.length,h=` + ${t.length} workspace(s)`}finally{await i()}}}if(m.results.length===0)return{content:[{type:`text`,text:`No results found.`}],structuredContent:{matches:[],totalMatches:0,pattern:e??t??i??``,truncated:!1}};let g=[`Found ${m.totalFound} results via ${m.strategies.join(` + `)}${h}`,``,...m.results.map(e=>{let t=e.lineRange?`:${e.lineRange.start}-${e.lineRange.end}`:``,n=e.preview?`\n ${e.preview.slice(0,100)}...`:``;return`- [${e.source}] ${e.path}${t} (${(e.score*100).toFixed(0)}%)${n}`})];return{content:[{type:`text`,text:d?C(g.join(`
|
|
4
|
+
`),d):g.join(`
|
|
5
|
+
`)}],structuredContent:{matches:m.results.map(e=>({path:e.path,...e.lineRange?{line:e.lineRange.start}:{},matchType:e.source,preview:e.preview?.slice(0,200)??``})),totalMatches:m.totalFound,pattern:e??t??i??``,truncated:m.results.length<m.totalFound}}}catch(e){return w.error(`Find failed`,m(e)),{content:[{type:`text`,text:`Find failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function O(t,n,r,i){let a=e(`symbol`);t.registerTool(`symbol`,{title:a.title,description:`Find definition, imports, and references of a named symbol (function, class, type). For tracing data flow across call sites use trace instead.`,inputSchema:{name:u.string().describe(`Symbol name to look up (function, class, type, etc.)`),limit:u.number().min(1).max(50).default(20).describe(`Max results per category`),workspaces:u.array(u.string()).optional().describe(`Cross-workspace search: partition names or folder basenames to include. Use ["*"] for all. User-level mode only.`)},outputSchema:o,annotations:a.annotations},async({name:e,limit:t,workspaces:a})=>{try{let o=await x(n,r,{name:e,limit:t,graphStore:i});if(a&&a.length>0){let r=l(a,f(process.cwd()));if(r.length>0){let{stores:i,closeAll:a}=await c(r);try{for(let[r,a]of i){let i=await x(n,a,{name:e,limit:t});i.definedIn&&!o.definedIn&&(o.definedIn={...i.definedIn,path:`[${r}] ${i.definedIn.path}`});for(let e of i.referencedIn)o.referencedIn.push({...e,path:`[${r}] ${e.path}`});if(i.importedBy){o.importedBy=o.importedBy??[];for(let e of i.importedBy)o.importedBy.push({...e,path:`[${r}] ${e.path}`})}}}finally{await a()}}}let s={name:o.name,definedIn:o.definedIn??null,importedBy:o.importedBy??[],referencedIn:o.referencedIn??[],graphContext:o.graphContext??null};return{content:[{type:`text`,text:M(o)}],structuredContent:s}}catch(e){return w.error(`Symbol lookup failed`,m(e)),{content:[{type:`text`,text:`Symbol lookup failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function k(t,n){let i=e(`file_summary`);t.registerTool(`file_summary`,{title:i.title,description:`Create a concise structural summary of a source file: imports, exports, functions, classes, interfaces, and types.`,outputSchema:r,inputSchema:{path:u.string().describe(`Absolute path to the file to summarize`)},annotations:i.annotations},async({path:e})=>{try{let t=await g({path:e,content:(await n.get(e)).content});return{content:[{type:`text`,text:N(t)}],structuredContent:{path:t.path,language:t.language,lines:t.lines,imports:t.imports?.length??0,exports:t.exports?.length??0,functions:t.functions?.length??0,classes:t.classes?.length??0}}}catch(e){return w.error(`File summary failed`,m(e)),{content:[{type:`text`,text:`File summary failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function A(t,n,r){let i=e(`trace`);t.registerTool(`trace`,{title:i.title,description:`Follow data flow forward/backward across imports and call sites from a starting symbol or file:line. For finding a single symbol definition use symbol instead.`,inputSchema:{start:u.string().describe(`Starting point — symbol name or file:line reference`),direction:u.enum([`forward`,`backward`,`both`]).describe(`Which direction to trace relationships`),max_depth:u.number().min(1).max(10).default(3).optional().describe(`Maximum trace depth`)},annotations:i.annotations},async({start:e,direction:t,max_depth:i})=>{try{let a=await S(n,r,{start:e,direction:t,maxDepth:i}),o=[`## Trace: ${a.start}`,`Direction: ${a.direction} | Depth: ${a.depth}`,``];if(a.nodes.length===0)o.push(`No connections found.`);else{let e=a.nodes.filter(e=>e.relationship===`calls`),t=a.nodes.filter(e=>e.relationship===`called-by`),n=a.nodes.filter(e=>e.relationship===`imports`),r=a.nodes.filter(e=>e.relationship===`imported-by`),i=a.nodes.filter(e=>e.relationship===`references`);if(e.length>0){o.push(`### Calls (${e.length})`);for(let t of e){let e=t.scope?` (from ${t.scope}())`:``;o.push(`- ${t.symbol}() — ${t.path}:${t.line}${e}`)}o.push(``)}if(t.length>0){o.push(`### Called by (${t.length})`);for(let e of t){let t=e.scope?` in ${e.scope}()`:``;o.push(`- ${e.symbol}()${t} — ${e.path}:${e.line}`)}o.push(``)}if(n.length>0){o.push(`### Imports (${n.length})`);for(let e of n)o.push(`- ${e.symbol} — ${e.path}:${e.line}`);o.push(``)}if(r.length>0){o.push(`### Imported by (${r.length})`);for(let e of r)o.push(`- ${e.path}:${e.line}`);o.push(``)}if(i.length>0){o.push(`### References (${i.length})`);for(let e of i)o.push(`- ${e.path}:${e.line}`);o.push(``)}}return o.push(`---`,"_Next: `symbol` for definition details | `compact` to read a referenced file | `blast_radius` for impact analysis_"),{content:[{type:`text`,text:o.join(`
|
|
6
|
+
`)}]}}catch(e){return w.error(`Trace failed`,m(e)),{content:[{type:`text`,text:`Trace failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function j(t,r,i){let a=e(`dead_symbols`);t.registerTool(`dead_symbols`,{title:a.title,description:`Find exported symbols that appear to be unused because they are never imported or re-exported.`,outputSchema:n,inputSchema:{path:u.string().optional().describe(`Root path to scope the search (default: cwd)`),limit:u.number().min(1).max(500).default(100).optional().describe(`Maximum exported symbols to scan`)},annotations:a.annotations},async({path:e,limit:t})=>{try{let n=await v(r,i,{rootPath:e,limit:t}),a=[`## Dead Symbol Analysis`,``,`**Exports scanned:** ${n.totalExports}`,`**Dead in source:** ${n.totalDeadSource} (actionable)`,`**Dead in docs:** ${n.totalDeadDocs} (informational — code samples in .md files)`,``];if(n.deadInSource.length>0){a.push(`### Dead in Source (actionable)`);for(let e of n.deadInSource)a.push(`- \`${e.name}\` (${e.kind}) — ${e.path}:${e.line}`);a.push(``)}if(n.deadInDocs.length>0){a.push(`### Dead in Docs (informational)`),a.push(`_${n.totalDeadDocs} symbol(s) found only in documentation code samples — not actionable dead code._`);for(let e of n.deadInDocs.slice(0,5))a.push(`- \`${e.name}\` — ${e.path}:${e.line}`);n.deadInDocs.length>5&&a.push(`- _... ${n.deadInDocs.length-5} more omitted_`)}return n.totalDeadSource>0?a.push(``,`---`,`_Next: \`codemod\` to remove ${n.totalDeadSource} unused exports | \`symbol\` to verify usage before removing_`):a.push(``,`---`,"_Next: `check` — no dead symbols found, validate types and lint_"),{content:[{type:`text`,text:a.join(`
|
|
7
|
+
`)}],structuredContent:{symbols:[...n.deadInSource,...n.deadInDocs].map(e=>({name:e.name,path:e.path,...e.line===void 0?{}:{line:e.line},kind:e.kind})),totalDead:n.totalDeadSource+n.totalDeadDocs}}}catch(e){return w.error(`Dead symbol scan failed`,m(e)),{content:[{type:`text`,text:`Dead symbol scan failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function M(e){let t=[`Symbol: ${e.name}`];if(e.definedIn){let n=`Defined in: ${e.definedIn.path}:${e.definedIn.line} (${e.definedIn.kind})`;e.definedIn.signature&&(n+=`\nSignature: ${e.definedIn.signature}`),t.push(n)}else t.push(`Defined in: not found`);if(t.push(``,`Imported by:`),e.importedBy.length===0)t.push(` none`);else for(let n of e.importedBy)t.push(` - ${n.path}:${n.line} ${n.importStatement}`);if(t.push(``,`Referenced in:`),e.referencedIn.length===0)t.push(` none`);else for(let n of e.referencedIn){let e=`scope`in n&&n.scope?` in ${n.scope}()`:``;t.push(` - ${n.path}:${n.line}${e} ${n.context}`)}if(e.graphContext){let n=e.graphContext;t.push(``,`Graph context:`),n.definingModule&&t.push(` Module: ${n.definingModule}`),n.importedByModules.length>0&&t.push(` Imported by modules: ${n.importedByModules.join(`, `)}`),n.siblingSymbols.length>0&&t.push(` Sibling symbols: ${n.siblingSymbols.join(`, `)}`)}return t.join(`
|
|
8
|
+
`)}function N(e){let t=[e.path,`Language: ${e.language}`,`Lines: ${e.lines}`,`Estimated tokens: ~${e.estimatedTokens}`,``,`Imports (${e.imports.length}):`,...P(e.imports),``,`Exports (${e.exports.length}):`,...P(e.exports),``,`Functions (${e.functions.length}):`,...P(e.functions.map(e=>`${e.name} @ line ${e.line}${e.exported?` [exported]`:``}${`signature`in e&&e.signature?` — ${e.signature}`:``}`)),``,`Classes (${e.classes.length}):`,...P(e.classes.map(e=>`${e.name} @ line ${e.line}${e.exported?` [exported]`:``}${e.signature?` — ${e.signature}`:``}`)),``,`Interfaces (${e.interfaces.length}):`,...P(e.interfaces.map(e=>`${e.name} @ line ${e.line}${`exported`in e&&e.exported?` [exported]`:``}`)),``,`Types (${e.types.length}):`,...P(e.types.map(e=>`${e.name} @ line ${e.line}${`exported`in e&&e.exported?` [exported]`:``}`))];if(`importDetails`in e&&e.importDetails&&e.importDetails.length>0){let n=e.importDetails.filter(e=>e.isExternal).length,r=e.importDetails.length-n;t.push(``,`Import breakdown: ${n} external, ${r} internal`)}if(`callEdges`in e&&e.callEdges&&e.callEdges.length>0){t.push(``,`Call edges (${e.callEdges.length} intra-file):`);for(let n of e.callEdges.slice(0,30))t.push(` - ${n.caller}() → ${n.callee}() @ line ${n.line}`);e.callEdges.length>30&&t.push(` - ... ${e.callEdges.length-30} more`)}return t.join(`
|
|
9
|
+
`)}function P(e){return e.length===0?[` none`]:e.map(e=>` - ${e}`)}export{T as registerCompactTool,j as registerDeadSymbolsTool,k as registerFileSummaryTool,D as registerFindTool,E as registerScopeMapTool,O as registerSymbolTool,A as registerTraceTool};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ISamplingClient } from "../sampling.js";
|
|
1
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
3
|
import { IEmbedder } from "@kb/embeddings";
|
|
3
4
|
import { IKnowledgeStore } from "@kb/store";
|
|
@@ -8,6 +9,6 @@ declare function registerBatchTool(server: McpServer, embedder: IEmbedder, store
|
|
|
8
9
|
declare function registerEvalTool(server: McpServer): void;
|
|
9
10
|
declare function registerTestRunTool(server: McpServer): void;
|
|
10
11
|
declare function registerParseOutputTool(server: McpServer): void;
|
|
11
|
-
declare function registerDelegateTool(server: McpServer): void;
|
|
12
|
+
declare function registerDelegateTool(server: McpServer, samplingClient?: ISamplingClient): void;
|
|
12
13
|
//#endregion
|
|
13
14
|
export { registerBatchTool, registerCheckTool, registerDelegateTool, registerEvalTool, registerParseOutputTool, registerTestRunTool };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{getToolMeta as e}from"../tool-metadata.js";import{CheckOutputSchema as t}from"../output-schemas.js";import{
|
|
2
|
-
`)}],structuredContent:{...e}}}return{content:[{type:`text`,text:JSON.stringify(
|
|
3
|
-
`).replace(/\\t/g,` `),t);return{content:[{type:`text`,text:JSON.stringify(n)}]}}catch(e){return
|
|
4
|
-
`)}export{
|
|
1
|
+
import{getToolMeta as e}from"../tool-metadata.js";import{CheckOutputSchema as t}from"../output-schemas.js";import{createTaskRunner as n}from"../task-manager.js";import{z as r}from"zod";import{CONTENT_TYPES as i,createLogger as a,serializeError as o}from"../../../core/dist/index.js";import{batch as s,check as c,delegate as l,delegateListModels as u,evaluate as d,find as f,parseOutput as p,summarizeCheckResult as m,testRun as h}from"../../../tools/dist/index.js";const g=a(`tools:execution`);function _(i){let a=e(`check`);i.registerTool(`check`,{title:a.title,description:`Run incremental typecheck (tsc) and lint (biome) on the project or specific files. Returns structured error and warning lists. Default detail level is "summary" (~300 tokens).`,inputSchema:{files:r.array(r.string()).optional().describe(`Specific files to check (if omitted, checks all)`),cwd:r.string().optional().describe(`Working directory`),skip_types:r.boolean().default(!1).describe(`Skip TypeScript typecheck`),skip_lint:r.boolean().default(!1).describe(`Skip Biome lint`),detail:r.enum([`summary`,`errors`,`full`]).default(`summary`).describe(`Output detail level: summary (default, ~300 tokens — pass/fail + counts + top errors), errors (parsed error objects), full (includes raw terminal output)`)},outputSchema:t,annotations:a.annotations},async({files:e,cwd:t,skip_types:r,skip_lint:i,detail:a},s)=>{try{let o=await c({files:e,cwd:t,skipTypes:r,skipLint:i,detail:a===`summary`?`errors`:a}),l=n(s).createTask(`Check`,2);if(l.progress(0,`tsc: ${o.tsc.errors.length} errors`),l.progress(1,`biome: ${o.biome.errors.length} errors`),l.complete(`Check ${o.passed?`passed`:`failed`}`),a===`summary`){let e=m(o),t=[];if(o.passed)t.push({tool:`test_run`,reason:`Types and lint clean — run tests next`});else{let e=o.tsc.errors[0]?.file??o.biome.errors[0]?.file;e&&t.push({tool:`symbol`,reason:`Resolve failing symbol in ${e}`,suggested_args:{name:e}}),t.push({tool:`check`,reason:`Re-check after fixing errors`,suggested_args:{detail:`errors`}})}let n=[`## Check ${e.passed?`✅ PASS`:`❌ FAIL`}`,``,`**tsc**: ${e.tsc.passed?`✅`:`❌`} ${e.tsc.errorCount} errors, ${e.tsc.warningCount} warnings`];if(e.tsc.topErrors.length>0)for(let t of e.tsc.topErrors)n.push(` - ${t}`);if(n.push(`**biome**: ${e.biome.passed?`✅`:`❌`} ${e.biome.errorCount} errors, ${e.biome.warningCount} warnings`),e.biome.topErrors.length>0)for(let t of e.biome.topErrors)n.push(` - ${t}`);if(t.length>0){n.push(``,`**Next steps:**`);for(let e of t)n.push(`- \`${e.tool}\`: ${e.reason}`)}return{content:[{type:`text`,text:n.join(`
|
|
2
|
+
`)}],structuredContent:{...e}}}return{content:[{type:`text`,text:JSON.stringify(o)}]}}catch(e){return g.error(`Check failed`,o(e)),{content:[{type:`text`,text:`Check failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function v(t,i,a){let c=e(`batch`);t.registerTool(`batch`,{title:c.title,description:`Execute multiple built-in operations in parallel with concurrency control. Supported operation types: search, find, and check.`,inputSchema:{operations:r.array(r.object({id:r.string().describe(`Unique ID for this operation`),type:r.enum([`search`,`find`,`check`]).describe(`Built-in operation type`),args:r.record(r.string(),r.unknown()).describe(`Arguments for the operation`)})).min(1).max(100).describe(`Operations to execute`),concurrency:r.number().min(1).max(20).default(4).describe(`Max concurrent operations`)},annotations:c.annotations},async({operations:e,concurrency:t},r)=>{try{let o=await s(e,async e=>E(e,i,a),{concurrency:t}),c=n(r).createTask(`Batch`,e.length);for(let e=0;e<o.length;e++)c.progress(e,`${o[e].id}: ${o[e].status}`);return c.complete(`Batch complete: ${o.length} operations`),{content:[{type:`text`,text:JSON.stringify(o)}]}}catch(e){return g.error(`Batch failed`,o(e)),{content:[{type:`text`,text:`Batch failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function y(t){let n=e(`eval`);t.registerTool(`eval`,{title:n.title,description:`Execute a JavaScript or TypeScript snippet in a constrained VM sandbox with a timeout. Captures console output and returned values.`,inputSchema:{code:r.string().max(1e5).describe(`Code snippet to execute`),lang:r.enum([`js`,`ts`]).default(`js`).optional().describe(`Language mode: js executes directly, ts strips common type syntax first`),timeout:r.number().min(1).max(6e4).default(5e3).optional().describe(`Execution timeout in milliseconds`)},annotations:n.annotations},async({code:e,lang:t,timeout:n})=>{try{let r=d({code:e,lang:t,timeout:n});return r.success?{content:[{type:`text`,text:`Eval succeeded in ${r.durationMs}ms\n\n${r.output}`}]}:{content:[{type:`text`,text:`Eval failed in ${r.durationMs}ms: ${r.error??`Unknown error`}`}],isError:!0}}catch(e){return g.error(`Eval failed`,o(e)),{content:[{type:`text`,text:`Eval failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function b(t){let i=e(`test_run`);t.registerTool(`test_run`,{title:i.title,description:`Run Vitest for the current project or a subset of files, then return a structured summary of passing and failing tests.`,inputSchema:{files:r.array(r.string()).optional().describe(`Specific test files or patterns to run`),grep:r.string().optional().describe(`Only run tests whose names match this pattern`),cwd:r.string().optional().describe(`Working directory for the test run`)},annotations:i.annotations},async({files:e,grep:t,cwd:r},i)=>{try{let a=await h({files:e,grep:t,cwd:r}),o=n(i).createTask(`Test Run`,1),s=a.summary.passed+a.summary.failed+a.summary.skipped;return o.complete(`Tests: ${a.passed?`passed`:`failed`} (${s} tests)`),{content:[{type:`text`,text:k(a)}],isError:!a.passed}}catch(e){return g.error(`Test run failed`,o(e)),{content:[{type:`text`,text:`Test run failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function x(t){let n=e(`parse_output`);t.registerTool(`parse_output`,{title:n.title,description:`Parse structured data from build tool output. Supports tsc, vitest, biome, and git status. Auto-detects the tool or specify explicitly.`,inputSchema:{output:r.string().max(5e5).describe(`Raw output text from a build tool`),tool:r.enum([`tsc`,`vitest`,`biome`,`git-status`]).optional().describe(`Tool to parse as (auto-detects if omitted)`)},annotations:n.annotations},async({output:e,tool:t})=>{try{let n=p(e.replace(/\\n/g,`
|
|
3
|
+
`).replace(/\\t/g,` `),t);return{content:[{type:`text`,text:JSON.stringify(n)}]}}catch(e){return g.error(`Parse failed`,o(e)),{content:[{type:`text`,text:`Parse failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function S(t,n){let i=e(`delegate`);t.registerTool(`delegate`,{title:i.title,description:`Delegate a subtask to a local Ollama model. Use for summarization, classification, naming, or any task that can offload work from the host agent. Fails fast if Ollama is not running.`,inputSchema:{prompt:r.string().max(2e5).describe(`The task or question to send to the local model`),model:r.string().optional().describe(`Ollama model name (default: first available model)`),system:r.string().optional().describe(`System prompt for the model`),context:r.string().max(5e5).optional().describe(`Context text to include before the prompt (e.g. file contents)`),temperature:r.number().min(0).max(2).default(.3).optional().describe(`Sampling temperature (0=deterministic, default 0.3)`),timeout:r.number().min(1e3).max(6e5).default(12e4).optional().describe(`Timeout in milliseconds (default 120000)`),action:r.enum([`generate`,`list_models`]).default(`generate`).optional().describe(`Action: generate a response or list available models`)},annotations:i.annotations},async({prompt:e,model:t,system:r,context:i,temperature:a,timeout:s,action:c})=>{try{if(c===`list_models`){let e=await u();return{content:[{type:`text`,text:JSON.stringify({models:e,count:e.length,_Next:`Use delegate with a model name`},null,2)}]}}if(n?.available)try{let t=await n.createMessage({prompt:e,systemPrompt:r,context:i,maxTokens:4e3,modelPreferences:{intelligencePriority:.8,speedPriority:.5,costPriority:.3}});return{content:[{type:`text`,text:JSON.stringify({model:t.model??`sampling`,response:t.text,provider:`mcp-sampling`,_Next:`Use the response in your workflow. stash to save it.`},null,2)}]}}catch{g.debug(`Sampling failed, falling back to Ollama`)}let o=await l({prompt:e,model:t,system:r,context:i,temperature:a,timeout:s});return o.error?{content:[{type:`text`,text:JSON.stringify({error:o.error,model:o.model,durationMs:o.durationMs},null,2)}],isError:!0}:{content:[{type:`text`,text:JSON.stringify({model:o.model,response:o.response,durationMs:o.durationMs,tokenCount:o.tokenCount,_Next:`Use the response in your workflow. stash to save it.`},null,2)}]}}catch(e){return g.error(`Delegate failed`,o(e)),{content:[{type:`text`,text:`Delegate failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}const C=r.object({query:r.string(),limit:r.number().min(1).max(20).default(5).optional(),search_mode:r.enum([`hybrid`,`semantic`,`keyword`]).default(`hybrid`).optional(),content_type:r.enum(i).optional(),origin:r.enum([`indexed`,`curated`,`produced`]).optional(),category:r.string().optional(),tags:r.array(r.string()).optional(),min_score:r.number().min(0).max(1).default(.25).optional()}),w=r.object({query:r.string().optional(),glob:r.string().optional(),pattern:r.string().optional(),limit:r.number().min(1).max(50).default(10).optional(),content_type:r.enum(i).optional(),cwd:r.string().optional()}),T=r.object({files:r.array(r.string()).optional(),cwd:r.string().optional(),skip_types:r.boolean().optional(),skip_lint:r.boolean().optional()});async function E(e,t,n){switch(e.type){case`search`:return D(t,n,C.parse(e.args));case`find`:{let r=w.parse(e.args);if(!r.query&&!r.glob&&!r.pattern)throw Error(`find operation requires query, glob, or pattern`);return f(t,n,{query:r.query,glob:r.glob,pattern:r.pattern,limit:r.limit,contentType:r.content_type,cwd:r.cwd})}case`check`:{let t=T.parse(e.args);return c({files:t.files,cwd:t.cwd,skipTypes:t.skip_types,skipLint:t.skip_lint})}default:throw Error(`Unsupported batch operation type: ${e.type}`)}}async function D(e,t,n){let r=n.limit??5,i={limit:r,minScore:n.min_score??.25,contentType:n.content_type,origin:n.origin,category:n.category,tags:n.tags},a=e.embedQuery?.bind(e)??e.embed.bind(e);if(n.search_mode===`keyword`)return(await t.ftsSearch(n.query,i)).slice(0,r);let o=await a(n.query);if(n.search_mode===`semantic`)return t.search(o,i);let[s,c]=await Promise.all([t.search(o,{...i,limit:r*2}),t.ftsSearch(n.query,{...i,limit:r*2})]);return O(s,c).slice(0,r)}function O(e,t,n=60){let r=new Map;for(let t=0;t<e.length;t++){let i=e[t];r.set(i.record.id,{record:i.record,score:1/(n+t+1)})}for(let e=0;e<t.length;e++){let i=t[e],a=r.get(i.record.id);if(a){a.score+=1/(n+e+1);continue}r.set(i.record.id,{record:i.record,score:1/(n+e+1)})}return[...r.values()].sort((e,t)=>t.score-e.score)}function k(e){let t=[`Vitest run: ${e.passed?`passed`:`failed`}`,`Duration: ${e.durationMs}ms`,`Passed: ${e.summary.passed}`,`Failed: ${e.summary.failed}`,`Skipped: ${e.summary.skipped}`];e.summary.suites!==void 0&&t.push(`Suites: ${e.summary.suites}`);let n=e.summary.tests.filter(e=>e.status===`fail`);if(n.length>0){t.push(``,`Failed tests:`);for(let e of n)t.push(`- ${e.name}${e.file?` (${e.file})`:``}`),e.error&&t.push(` ${e.error}`)}return t.join(`
|
|
4
|
+
`)}export{v as registerBatchTool,_ as registerCheckTool,S as registerDelegateTool,y as registerEvalTool,x as registerParseOutputTool,b as registerTestRunTool};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{getToolMeta as e}from"../tool-metadata.js";import{
|
|
2
|
-
`)}]}}case`update`:{if(!t)throw Error(`task_id required for update`);if(c===void 0)throw Error(`id required for update`);if(!
|
|
3
|
-
`)}]}}case`get`:{if(!t)throw Error(`task_id required for get`);let e=
|
|
4
|
-
`)}]}:{content:[{type:`text`,text:`Evidence map "${t}" not found.`}]}}case`gate`:{if(!t)throw Error(`task_id required for gate`);let e=
|
|
5
|
-
`)}]}}case`list`:{let e=
|
|
6
|
-
`)}]}}case`delete`:if(!t)throw Error(`task_id required for delete`);return{content:[{type:`text`,text:
|
|
7
|
-
`)}]}}catch(e){return
|
|
8
|
-
`)}]}}catch(e){return
|
|
9
|
-
`)}]}}catch(e){return
|
|
10
|
-
`)}]}}catch(e){return
|
|
1
|
+
import{getToolMeta as e}from"../tool-metadata.js";import{createTaskRunner as t}from"../task-manager.js";import{z as n}from"zod";import{createLogger as r,serializeError as i}from"../../../core/dist/index.js";import{digest as a,evidenceMap as o,forgeClassify as s,forgeGround as c,stratumCard as l}from"../../../tools/dist/index.js";const u=r(`tools`);function d(t){let r=e(`evidence_map`);t.registerTool(`evidence_map`,{title:r.title,description:`Track verified/assumed/unresolved claims for complex tasks. Gate readiness: YIELD (proceed), HOLD (unknowns), HARD_BLOCK (critical gaps). Persists across calls.`,inputSchema:{action:n.enum([`create`,`add`,`update`,`get`,`gate`,`list`,`delete`]).describe(`Operation to perform`),task_id:n.string().optional().describe(`Task identifier (required for all except list)`),tier:n.enum([`floor`,`standard`,`critical`]).optional().describe(`FORGE tier (required for create)`),claim:n.string().optional().describe(`Critical-path claim text (for add)`),status:n.enum([`V`,`A`,`U`]).optional().describe(`Evidence status: V=Verified, A=Assumed, U=Unresolved`),receipt:n.string().optional().describe(`Evidence receipt: tool→ref for V, reasoning for A, attempts for U`),id:n.number().optional().describe(`Entry ID (for update)`),critical_path:n.boolean().default(!0).describe(`Whether this claim is on the critical path`),unknown_type:n.enum([`contract`,`convention`,`freshness`,`runtime`,`data-flow`,`impact`]).optional().describe(`Typed unknown classification`),safety_gate:n.enum([`provenance`,`commitment`,`coverage`]).optional().describe(`Safety gate tag: provenance (claim→evidence), commitment (user-approved), coverage (nothing dropped)`),retry_count:n.number().default(0).describe(`Retry count for gate evaluation (0 = first attempt)`),cwd:n.string().optional().describe(`Working directory for evidence map storage (default: server cwd). Use root_path from forge_ground to match.`)},annotations:r.annotations},async({action:e,task_id:t,tier:n,claim:r,status:a,receipt:s,id:c,critical_path:l,unknown_type:d,safety_gate:f,retry_count:p,cwd:m})=>{try{switch(e){case`create`:if(!t)throw Error(`task_id required for create`);if(!n)throw Error(`tier required for create`);return o({action:`create`,taskId:t,tier:n},m),{content:[{type:`text`,text:`Created evidence map "${t}" (tier: ${n}).\n\n---\n_Next: Use \`evidence_map\` with action "add" to record critical-path claims._`}]};case`add`:{if(!t)throw Error(`task_id required for add`);if(!r)throw Error(`claim required for add`);if(!a)throw Error(`status required for add`);let e=o({action:`add`,taskId:t,claim:r,status:a,receipt:s??``,criticalPath:l,unknownType:d,safetyGate:f},m),n=[`Added entry #${e.entry?.id} to "${t}": [${a}] ${r}`];return e.formattedMap&&n.push(``,e.formattedMap),{content:[{type:`text`,text:n.join(`
|
|
2
|
+
`)}]}}case`update`:{if(!t)throw Error(`task_id required for update`);if(c===void 0)throw Error(`id required for update`);if(!a)throw Error(`status required for update`);let e=o({action:`update`,taskId:t,id:c,status:a,receipt:s??``},m),n=[`Updated entry #${c} in "${t}" → ${a}`];return e.formattedMap&&n.push(``,e.formattedMap),{content:[{type:`text`,text:n.join(`
|
|
3
|
+
`)}]}}case`get`:{if(!t)throw Error(`task_id required for get`);let e=o({action:`get`,taskId:t},m);return e.state?{content:[{type:`text`,text:[`## Evidence Map: ${t} (${e.state.tier})`,``,e.formattedMap??`No entries.`,``,`_${e.state.entries.length} entries — created ${e.state.createdAt}_`].join(`
|
|
4
|
+
`)}]}:{content:[{type:`text`,text:`Evidence map "${t}" not found.`}]}}case`gate`:{if(!t)throw Error(`task_id required for gate`);let e=o({action:`gate`,taskId:t,retryCount:p},m);if(!e.gate)return{content:[{type:`text`,text:`Evidence map "${t}" not found.`}]};let n=e.gate,r=[`## FORGE Gate: **${n.decision}**`,``,`**Reason:** ${n.reason}`,``,`**Stats:** ${n.stats.verified}V / ${n.stats.assumed}A / ${n.stats.unresolved}U (${n.stats.total} total)`];return n.warnings.length>0&&r.push(``,`**Warnings:**`,...n.warnings.map(e=>`- ⚠️ ${e}`)),n.unresolvedCritical.length>0&&r.push(``,`**Blocking entries:**`,...n.unresolvedCritical.map(e=>`- #${e.id}: ${e.claim} [${e.unknownType??`untyped`}]`)),n.safetyGates&&(r.push(``,`**Safety Gates:**`,`- Provenance: ${n.safetyGates.provenance}`,`- Commitment: ${n.safetyGates.commitment}`,`- Coverage: ${n.safetyGates.coverage}`),n.safetyGates.failures.length>0&&r.push(``,`**Safety failures:**`,...n.safetyGates.failures.map(e=>`- \u{1F6D1} ${e}`))),n.annotation&&r.push(``,`**Annotation:**`,n.annotation),e.formattedMap&&r.push(``,`---`,``,e.formattedMap),r.push(``,`---`,`_Next: ${n.decision===`YIELD`?`Proceed to implementation.`:n.decision===`HOLD`?`Resolve blocking entries, then re-run gate.`:n.decision===`HARD_BLOCK`?`Contract unknowns MUST be resolved. Use search or schema_validate.`:`Proceed with annotation — document unresolved items in delivery.`}_`),{content:[{type:`text`,text:r.join(`
|
|
5
|
+
`)}]}}case`list`:{let e=o({action:`list`},m);return!e.states||e.states.length===0?{content:[{type:`text`,text:`No evidence maps found.`}]}:{content:[{type:`text`,text:e.states.map(e=>`- **${e.taskId}** (${e.tier}) — ${e.entries.length} entries — ${e.updatedAt}`).join(`
|
|
6
|
+
`)}]}}case`delete`:if(!t)throw Error(`task_id required for delete`);return{content:[{type:`text`,text:o({action:`delete`,taskId:t},m).deleted?`Deleted evidence map "${t}".`:`Evidence map "${t}" not found.`}]}}}catch(e){return u.error(`Evidence map error`,i(e)),{content:[{type:`text`,text:`Evidence map error: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function f(t,r){let o=e(`digest`);t.registerTool(`digest`,{title:o.title,description:`Compress multiple text sources (handoffs, debates, phase summaries) into a token-budgeted digest. Jointly ranks across all sources, pins structured fields (status, files, decisions, blockers), and allocates budget by priority weight.`,inputSchema:{sources:n.array(n.object({id:n.string().describe(`Source identifier (e.g., "phase-2-handoff")`),text:n.string().max(5e5).describe(`Source text to compress`),weight:n.number().min(0).default(1).describe(`Priority weight (higher = more budget)`)})).min(1).max(20).describe(`Text sources to compress`),query:n.string().describe(`Focus query — what matters for the next step?`),max_chars:n.number().min(100).max(5e4).default(4e3).describe(`Target budget in characters`),pin_fields:n.array(n.string()).optional().describe(`Key fields to always extract (default: status, files, decisions, blockers, next)`),segmentation:n.enum([`paragraph`,`sentence`,`line`]).default(`paragraph`).describe(`How to split text for scoring`)},annotations:o.annotations},async({sources:e,query:t,max_chars:n,pin_fields:o,segmentation:s})=>{try{let i=await a(r,{sources:e,query:t,maxChars:n,pinFields:o,segmentation:s}),c=[`## Digest (${i.totalOriginalChars} → ${i.totalCompressedChars} chars, ${(i.ratio*100).toFixed(0)}%)`,``],l=Object.keys(i.fields);if(l.length>0){c.push(`### Extracted Fields`);for(let e of l){let t=i.fields[e];c.push(`**${e}:**`);for(let e of t)c.push(` - [${e.sourceId}] ${e.value}`)}c.push(``)}c.push(`### Compressed Content`,``,i.text),c.push(``,`### Source Stats`);for(let e of i.sourceStats)c.push(`- **${e.id}**: ${e.originalChars} → ${e.keptChars} chars (${e.segmentsKept}/${e.segmentsTotal} segments)`);return c.push(``,`---`,"_Next: Use the digest as compressed context for the next phase. Use `stash` to persist it if needed._"),{content:[{type:`text`,text:c.join(`
|
|
7
|
+
`)}]}}catch(e){return u.error(`Digest failed`,i(e)),{content:[{type:`text`,text:`Digest failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function p(t){let r=e(`forge_classify`);t.registerTool(`forge_classify`,{title:r.title,description:`Classify FORGE tier (Floor/Standard/Critical) from target files and task description. Checks blast radius, cross-package boundaries, schema/contract patterns, and security signals. Returns tier, triggers, typed unknown seeds, and ceremony guidance.`,inputSchema:{files:n.array(n.string()).min(1).max(100).describe(`Files being modified (paths)`),task:n.string().describe(`Task description`),root_path:n.string().describe(`Root path of the codebase`)},annotations:r.annotations},async({files:e,task:t,root_path:n})=>{try{let r=await s({files:e,task:t,rootPath:n}),i=[`## FORGE Classification: **${r.tier.toUpperCase()}**`,``];if(r.triggers.length>0){i.push(`### Triggers`);for(let e of r.triggers)i.push(`- **${e.rule}** (${e.source}): ${e.detail}`);i.push(``)}if(r.packagesCrossed.length>0&&i.push(`**Packages crossed:** ${r.packagesCrossed.join(`, `)}`),r.typedUnknownSeeds.length>0){i.push(``,`### Typed Unknown Seeds`);for(let e of r.typedUnknownSeeds)i.push(`- [${e.type}] ${e.description} → use \`${e.suggestedTool}\``)}i.push(``,`### Ceremony`);let a=r.ceremony;return i.push(`- **Ground:** ${a.ground}`,`- **Build:** ${a.build}`,`- **Break:** ${a.break}`,`- **Evidence Map:** ${a.evidenceMap}`,`- **Gate:** ${a.gate}`),i.push(``,`---`,`_Next: ${r.tier===`floor`?`Proceed directly to implementation.`:"Run `forge_ground` to execute the full Ground phase."}_`),{content:[{type:`text`,text:i.join(`
|
|
8
|
+
`)}]}}catch(e){return u.error(`FORGE classify failed`,i(e)),{content:[{type:`text`,text:`FORGE classify failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function m(t,r,a){let o=e(`stratum_card`);t.registerTool(`stratum_card`,{title:o.title,description:`Generate context cards from files — a compressed alternative to reading full files (10-100x token reduction). Tier 1 (T1): structure only (~100 tokens/file — imports, exports, functions). Tier 2 (T2): structure + query-relevant content (~300 tokens/file).`,inputSchema:{files:n.array(n.string()).min(1).max(50).describe(`Absolute file paths to generate cards for`),query:n.string().describe(`Current task query — guides relevance scoring`),tier:n.enum([`T1`,`T2`]).default(`T1`).describe(`Card tier: T1 = structural only, T2 = T1 + compressed content`),max_content_chars:n.number().min(100).max(5e3).default(800).describe(`For T2: max chars for compressed content section`)},annotations:o.annotations},async({files:e,query:t,tier:n,max_content_chars:o})=>{try{let i=await l(r,{files:e,query:t,tier:n,maxContentChars:o,cache:a}),s=[`## STRATUM Cards (${n}) — ${i.cards.length} files`,`Total: ~${i.totalTokenEstimate} tokens (was ~${i.totalOriginalTokenEstimate}, ${(i.compressionRatio*100).toFixed(0)}% of original)`,``];for(let e of i.cards)s.push(e.card,``);return s.push(`---`,"_Next: Use these cards as context instead of reading full files. Use `compact` for deeper content extraction on specific files._"),{content:[{type:`text`,text:s.join(`
|
|
9
|
+
`)}]}}catch(e){return u.error(`STRATUM cards failed`,i(e)),{content:[{type:`text`,text:`STRATUM cards failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function h(r,a,o){let s=e(`forge_ground`);r.registerTool(`forge_ground`,{title:s.title,description:`Execute the complete FORGE Ground phase in a single call. Chains: tier classification → scope map → typed unknown seeds → constraint loading → file summaries → evidence map creation. Replaces 5-15 manual tool calls.`,inputSchema:{task:n.string().describe(`Task description`),files:n.array(n.string()).min(1).max(100).describe(`Target files being modified (absolute paths)`),root_path:n.string().describe(`Root path of the codebase`),max_constraints:n.number().min(0).max(10).default(3).describe(`Max constraint entries to load from KB`),force_tier:n.enum([`floor`,`standard`,`critical`]).optional().describe(`Force a specific tier (skips auto-classification)`),task_id:n.string().optional().describe(`Custom task ID for evidence map (auto-generated if omitted)`)},annotations:s.annotations},async({task:e,files:n,root_path:r,max_constraints:s,force_tier:l,task_id:d},f)=>{try{let i=await c(a,o,{task:e,files:n,rootPath:r,maxConstraints:s,forceTier:l,taskId:d}),u=t(f).createTask(`FORGE Ground`,3);u.progress(0,`Classification: ${i.tier}`),u.progress(1,`Files analyzed: ${i.fileSummaries.length}`),u.progress(2,`Unknowns: ${i.typedUnknownSeeds.length}`),u.complete(`FORGE Ground complete: tier=${i.tier}`);let p=[`## FORGE Ground: **${i.tier.toUpperCase()}**`,`Estimated output: ~${i.estimatedTokens} tokens`,``];if(i.classifyTriggers.length>0){p.push(`### Classification Triggers`);for(let e of i.classifyTriggers)p.push(`- **${e.rule}** (${e.source}): ${e.detail}`);p.push(``)}if(i.fileSummaries.length>0){p.push(`### Target Files`);for(let e of i.fileSummaries)p.push(`- **${e.path}** (${e.lines} lines) — exports: ${e.exports.join(`, `)||`none`} — functions: ${e.functions.join(`, `)||`none`}`);p.push(``)}if(i.typedUnknownSeeds.length>0){p.push(`### Typed Unknown Seeds`);for(let e of i.typedUnknownSeeds)p.push(`- [${e.type}] ${e.description} → \`${e.suggestedTool}\``);p.push(``)}if(i.constraints.length>0){p.push(`### Constraint Seed`);for(let e of i.constraints)p.push(`- **${e.source}** (${(e.relevance*100).toFixed(0)}%): ${e.snippet}`);p.push(``)}if(i.scopeMap){p.push(`### Scope Map: ${i.scopeMap.files.length} files (~${i.scopeMap.totalEstimatedTokens} tokens)`);for(let e of i.scopeMap.files.slice(0,5))p.push(`- ${e.path} (${(e.relevance*100).toFixed(0)}%) — ${e.reason}`);i.scopeMap.files.length>5&&p.push(`- _...and ${i.scopeMap.files.length-5} more_`),p.push(``)}i.evidenceMapTaskId&&(p.push(`**Evidence Map:** \`${i.evidenceMapTaskId}\` (initialized)`),p.push(``)),p.push(`### Ceremony Guidance`);let m=i.ceremony;return p.push(`- **Ground:** ${m.ground}`,`- **Build:** ${m.build}`,`- **Break:** ${m.break}`,`- **Evidence Map:** ${m.evidenceMap}`,`- **Gate:** ${m.gate}`),p.push(``,`---`,`_Next: ${i.tier===`floor`?`Proceed to Build phase.`:"Use `evidence_map` to track claims during Build, then `evidence_map` gate after Break."}_`),{content:[{type:`text`,text:p.join(`
|
|
10
|
+
`)}]}}catch(e){return u.error(`FORGE Ground failed`,i(e)),{content:[{type:`text`,text:`FORGE Ground failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}export{f as registerDigestTool,d as registerEvidenceMapTool,p as registerForgeClassifyTool,h as registerForgeGroundTool,m as registerStratumCardTool};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CuratedKnowledgeManager } from "../curated-manager.js";
|
|
2
|
+
import { ResourceNotifier } from "../resources/resource-notifier.js";
|
|
2
3
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
4
|
|
|
4
5
|
//#region packages/server/src/tools/forget.tool.d.ts
|
|
5
|
-
declare function registerForgetTool(server: McpServer, curated: CuratedKnowledgeManager): void;
|
|
6
|
+
declare function registerForgetTool(server: McpServer, curated: CuratedKnowledgeManager, resourceNotifier?: ResourceNotifier): void;
|
|
6
7
|
//#endregion
|
|
7
8
|
export { registerForgetTool };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getToolMeta as e}from"../tool-metadata.js";import{existsSync as t,readFileSync as n}from"node:fs";import{resolve as r}from"node:path";import{z as i}from"zod";import{KB_PATHS as a,createLogger as o,serializeError as s}from"../../../core/dist/index.js";import{createRestorePoint as c}from"../../../tools/dist/index.js";const l=o(`tools`);function u(o,u){let
|
|
1
|
+
import{getToolMeta as e}from"../tool-metadata.js";import{existsSync as t,readFileSync as n}from"node:fs";import{resolve as r}from"node:path";import{z as i}from"zod";import{KB_PATHS as a,createLogger as o,serializeError as s}from"../../../core/dist/index.js";import{createRestorePoint as c}from"../../../tools/dist/index.js";const l=o(`tools`);function u(o,u,d){let f=e(`forget`);o.registerTool(`forget`,{title:f.title,description:`Remove a curated knowledge entry. Deletes the file and removes it from the vector store.`,inputSchema:{path:i.string().describe(`Relative path within .ai/curated/ (e.g., "decisions/deprecated-approach.md")`),reason:i.string().min(3).describe(`Why this entry is being removed`)},annotations:f.annotations},async({path:e,reason:i})=>{try{let o=r(process.cwd(),a.aiCurated,e);if(t(o))try{c(`forget`,[{path:o,content:n(o,`utf-8`)}],`forget: ${e}`)}catch{}let s=await u.forget(e,i);return l.info(`Forgot entry`,{path:s.path,reason:i}),d&&(d.notifyAfterCuratedWrite().catch(()=>{}),d.notifyResourceListChanged().catch(()=>{})),{content:[{type:`text`,text:`Forgotten: \`.ai/curated/${s.path}\`\n\nRemoved from disk and vector store.\nReason: ${i}\n\n---\n_Next: Use \`list\` to verify removal, or \`search\` to confirm the entry is no longer returned._`}]}}catch(e){return l.error(`Forget failed`,s(e)),{content:[{type:`text`,text:`Forget failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}export{u as registerForgetTool};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{getToolMeta as e}from"../tool-metadata.js";import{
|
|
1
|
+
import{getToolMeta as e}from"../tool-metadata.js";import{GraphOutputSchema as t}from"../output-schemas.js";import{z as n}from"zod";import{createLogger as r,serializeError as i}from"../../../core/dist/index.js";import{graphQuery as a}from"../../../tools/dist/index.js";const o=r(`tools`),s=n.object({id:n.string().optional().describe(`Node ID (auto-generated if omitted)`),type:n.string().describe(`Node type (entity, service, api, concept, decision)`),name:n.string().describe(`Display name`),properties:n.record(n.string(),n.unknown()).optional().describe(`Arbitrary properties`),sourceRecordId:n.string().optional().describe(`Back-link to knowledge record ID`),sourcePath:n.string().optional().describe(`Source file path`)}),c=n.object({id:n.string().optional().describe(`Edge ID (auto-generated if omitted)`),fromId:n.string().describe(`Source node ID`),toId:n.string().describe(`Target node ID`),type:n.string().describe(`Relationship type (depends-on, implements, calls, affects)`),weight:n.number().min(0).max(1).optional().describe(`Relationship weight`),properties:n.record(n.string(),n.unknown()).optional().describe(`Arbitrary properties`)});function l(r,l){let u=e(`graph`);r.registerTool(`graph`,{title:u.title,description:`Query and manage the knowledge graph. Find nodes/edges, traverse connections, add entities and relationships. The graph captures structural relationships between concepts discovered in the codebase.`,outputSchema:t,inputSchema:{action:n.enum([`find_nodes`,`find_edges`,`neighbors`,`traverse`,`stats`,`validate`,`add`,`delete`,`clear`]).describe(`Action: find_nodes (search nodes), find_edges (search edges), neighbors (direct connections), traverse (multi-hop), stats (graph overview), validate (check graph integrity), add (insert nodes/edges), delete (remove nodes), clear (remove all)`),node_type:n.string().optional().describe(`Node type filter (for find_nodes)`),name_pattern:n.string().optional().describe(`Name substring match (for find_nodes)`),source_path:n.string().optional().describe(`Source path filter`),node_id:n.string().optional().describe(`Node ID (for neighbors, traverse, delete)`),edge_type:n.string().optional().describe(`Edge type filter`),from_id:n.string().optional().describe(`Source node ID (for find_edges)`),to_id:n.string().optional().describe(`Target node ID (for find_edges)`),direction:n.enum([`outgoing`,`incoming`,`both`]).default(`both`).describe(`Traversal direction`),max_depth:n.number().min(1).max(5).default(2).describe(`Max traversal depth`),limit:n.number().min(1).max(100).default(50).describe(`Max results`),nodes:n.array(s).max(500).optional().describe(`Nodes to add (for action=add)`),edges:n.array(c).max(500).optional().describe(`Edges to add (for action=add)`)},annotations:u.annotations},async e=>{try{let t=await a(l,{action:e.action,nodeType:e.node_type,namePattern:e.name_pattern,sourcePath:e.source_path,nodeId:e.node_id,edgeType:e.edge_type,fromId:e.from_id,toId:e.to_id,direction:e.direction,maxDepth:e.max_depth,limit:e.limit,nodes:e.nodes,edges:e.edges}),n=[t.summary];if(t.nodes&&t.nodes.length>0){n.push(`
|
|
2
2
|
### Nodes`);for(let e of t.nodes){let t=Object.keys(e.properties).length>0?` — ${JSON.stringify(e.properties)}`:``;n.push(`- **${e.name}** (${e.type}, id: \`${e.id}\`)${t}`)}}if(t.edges&&t.edges.length>0){n.push(`
|
|
3
3
|
### Edges`);for(let e of t.edges)n.push(`- \`${e.fromId}\` —[${e.type}]→ \`${e.toId}\`${e.weight===1?``:` (weight: ${e.weight})`}`)}if(t.stats&&(n.push(`\nNode types: ${JSON.stringify(t.stats.nodeTypes)}`),n.push(`Edge types: ${JSON.stringify(t.stats.edgeTypes)}`)),t.validation){if(n.push(`
|
|
4
4
|
### Validation`),n.push(`- **Valid**: ${t.validation.valid?`yes`:`no`}`),t.validation.danglingEdges.length>0){n.push(`- **Dangling edges**:`);for(let e of t.validation.danglingEdges)n.push(` - \`${e.edgeId}\` references missing node \`${e.missingNodeId}\``)}t.validation.orphanNodes.length>0&&n.push(`- **Orphan nodes**: ${t.validation.orphanNodes.map(e=>`\`${e}\``).join(`, `)}`)}return n.push("\n---\n_Next: Use `graph(traverse)` to explore connections, `graph(add)` to insert entities, or `search` with graph-augmented results._"),{content:[{type:`text`,text:n.join(`
|
|
5
|
-
`)}]}}catch(e){return
|
|
5
|
+
`)}],structuredContent:{nodes:(t.nodes??[]).map(e=>({id:e.id,name:e.name,type:e.type,...e.sourcePath?{sourcePath:e.sourcePath}:{}})),edges:(t.edges??[]).map(e=>({fromId:e.fromId,toId:e.toId,type:e.type})),totalNodes:t.stats?.nodeCount??t.nodes?.length??0,totalEdges:t.stats?.edgeCount??t.edges?.length??0,query:e.action}}}catch(e){return o.error(`Graph query failed`,i(e)),{content:[{type:`text`,text:`Graph query failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}export{l as registerGraphTool};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{getToolMeta as e}from"../tool-metadata.js";import{
|
|
2
|
-
`).replace(/\\t/g,` `)}))}]}}catch(e){return
|
|
3
|
-
`)}function
|
|
4
|
-
`)}export{
|
|
1
|
+
import{getToolMeta as e}from"../tool-metadata.js";import{GitContextOutputSchema as t}from"../output-schemas.js";import{z as n}from"zod";import{createLogger as r,serializeError as i}from"../../../core/dist/index.js";import{codemod as a,dataTransform as o,diffParse as s,gitContext as c,rename as l}from"../../../tools/dist/index.js";const u=r(`tools:manipulation`);function d(r){let a=e(`git_context`);r.registerTool(`git_context`,{title:a.title,description:`Summarize the current Git branch, working tree state, recent commits, and optional diff statistics for the repository.`,inputSchema:{cwd:n.string().optional().describe(`Repository root or working directory`),commit_count:n.number().min(1).max(50).default(5).optional().describe(`How many recent commits to include`),include_diff:n.boolean().default(!1).optional().describe(`Include diff stat for working tree changes`)},annotations:a.annotations,outputSchema:t},async({cwd:e,commit_count:t,include_diff:n})=>{try{let r=await c({cwd:e,commitCount:t,includeDiff:n});return{content:[{type:`text`,text:g(r)}],structuredContent:{gitRoot:r.gitRoot,branch:r.branch,commitCount:r.recentCommits.length,hasUncommitted:r.status.staged.length>0||r.status.modified.length>0||r.status.untracked.length>0,recentCommits:r.recentCommits.map(e=>({hash:e.hash,message:e.message,author:e.author,date:e.date}))}}}catch(e){return u.error(`Git context failed`,i(e)),{content:[{type:`text`,text:`Git context failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function f(t){let r=e(`diff_parse`);t.registerTool(`diff_parse`,{title:r.title,description:`Parse raw unified diff text into file-level and hunk-level structural changes.`,inputSchema:{diff:n.string().max(1e6).describe(`Raw unified diff text`)},annotations:r.annotations},async({diff:e})=>{try{return{content:[{type:`text`,text:_(s({diff:e.replace(/\\n/g,`
|
|
2
|
+
`).replace(/\\t/g,` `)}))}]}}catch(e){return u.error(`Diff parse failed`,i(e)),{content:[{type:`text`,text:`Diff parse failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function p(t){let r=e(`rename`);t.registerTool(`rename`,{title:r.title,description:`Rename a symbol across files using whole-word regex matching for exports, imports, and general usage references.`,inputSchema:{old_name:n.string().describe(`Existing symbol name to replace`),new_name:n.string().describe(`New symbol name to use`),root_path:n.string().describe(`Root directory to search within`),extensions:n.array(n.string()).optional().describe(`Optional file extensions to include, such as .ts,.tsx,.js,.jsx`),dry_run:n.boolean().default(!0).describe(`Preview changes without writing files`)},annotations:r.annotations},async({old_name:e,new_name:t,root_path:n,extensions:r,dry_run:a})=>{try{let i=await l({oldName:e,newName:t,rootPath:n,extensions:r,dryRun:a});return{content:[{type:`text`,text:JSON.stringify(i)}]}}catch(e){return u.error(`Rename failed`,i(e)),{content:[{type:`text`,text:`Rename failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function m(t){let r=e(`codemod`);t.registerTool(`codemod`,{title:r.title,description:`Apply regex-based codemod rules across files and return structured before/after changes for each affected line.`,inputSchema:{root_path:n.string().describe(`Root directory to transform within`),rules:n.array(n.object({description:n.string().describe(`What the codemod rule does`),pattern:n.string().describe(`Regex pattern in string form`),replacement:n.string().describe(`Replacement string with optional capture groups`)})).min(1).describe(`Codemod rules to apply`),dry_run:n.boolean().default(!0).describe(`Preview changes without writing files`)},annotations:r.annotations},async({root_path:e,rules:t,dry_run:n})=>{try{let r=await a({rootPath:e,rules:t,dryRun:n});return{content:[{type:`text`,text:JSON.stringify(r)}]}}catch(e){return u.error(`Codemod failed`,i(e)),{content:[{type:`text`,text:`Codemod failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function h(t){let r=e(`data_transform`);t.registerTool(`data_transform`,{title:r.title,description:`Apply small jq-like transforms to JSON input for filtering, projection, grouping, and path extraction.`,inputSchema:{input:n.string().max(5e5).describe(`Input JSON string`),expression:n.string().max(1e4).describe(`Transform expression to apply`)},annotations:r.annotations},async({input:e,expression:t})=>{try{return{content:[{type:`text`,text:o({input:e,expression:t}).outputString}]}}catch(e){return u.error(`Data transform failed`,i(e)),{content:[{type:`text`,text:`Data transform failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}})}function g(e){let t=[`Git root: ${e.gitRoot}`,`Branch: ${e.branch}`,`Staged: ${e.status.staged.length}`,...e.status.staged.map(e=>` - ${e}`),`Modified: ${e.status.modified.length}`,...e.status.modified.map(e=>` - ${e}`),`Untracked: ${e.status.untracked.length}`,...e.status.untracked.map(e=>` - ${e}`),``,`Recent commits:`];if(e.recentCommits.length===0)t.push(` none`);else for(let n of e.recentCommits)t.push(` - ${n.hash} ${n.message}`),t.push(` ${n.author} @ ${n.date}`);return e.diff&&t.push(``,`Diff stat:`,e.diff),t.join(`
|
|
3
|
+
`)}function _(e){if(e.length===0)return`No diff files found.`;let t=[];for(let n of e){let e=n.oldPath?` (from ${n.oldPath})`:``;t.push(`${n.path}${e} [${n.status}] +${n.additions} -${n.deletions} (${n.hunks.length} hunks)`);for(let e of n.hunks){let n=e.header?` ${e.header}`:``;t.push(` @@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@${n}`)}}return t.join(`
|
|
4
|
+
`)}export{m as registerCodemodTool,h as registerDataTransformTool,f as registerDiffParseTool,d as registerGitContextTool,p as registerRenameTool};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getToolMeta as e}from"../tool-metadata.js";import{
|
|
2
|
-
`)}]}}catch(e){return
|
|
1
|
+
import{getToolMeta as e}from"../tool-metadata.js";import{createTaskRunner as t}from"../task-manager.js";import{createHash as n}from"node:crypto";import{z as r}from"zod";import{createLogger as i,serializeError as a}from"../../../core/dist/index.js";import{onboard as o}from"../../../tools/dist/index.js";const s=i(`tools`);let c=!1;async function l(e,t,r){for(let i of r.steps)if(!(i.status!==`success`||!i.output))try{let a=n(`sha256`).update(r.path).digest(`hex`).slice(0,12),o=`produced/onboard/${i.name}/${a}.md`,s=n(`sha256`).update(i.output).digest(`hex`).slice(0,16),c=new Date().toISOString(),l=i.output.length>2e3?i.output.split(/(?=^## )/m).filter(e=>e.trim().length>0):[i.output],u=l.map((e,t)=>({id:n(`sha256`).update(`${o}::${t}`).digest(`hex`).slice(0,16),content:e.trim(),sourcePath:o,contentType:`produced-knowledge`,chunkIndex:t,totalChunks:l.length,startLine:0,endLine:0,fileHash:s,indexedAt:c,origin:`produced`,tags:[`onboard`,i.name],category:`analysis`,version:1})),d=await t.embedBatch(u.map(e=>e.content));await e.upsert(u,d)}catch(e){s.warn(`Auto-persist onboard step failed`,{stepName:i.name,...a(e)})}}function u(n,i,u){let d=e(`onboard`);n.registerTool(`onboard`,{title:d.title,description:`First-time codebase onboarding: runs all analysis tools (structure, dependencies, entry-points, symbols, patterns, diagram) in one command. Results are auto-persisted to KB. Use mode=generate to also write structured output to .ai/kb/ directory.`,inputSchema:{path:r.string().describe(`Root path of the codebase to onboard`),mode:r.enum([`memory`,`generate`]).default(`memory`).describe(`Output mode: memory = KB vector store only; generate = also write to .ai/kb/ directory`),out_dir:r.string().optional().describe(`Custom output directory for generate mode (default: <path>/.ai/kb)`)},annotations:d.annotations},async({path:e,mode:n,out_dir:r},d)=>{try{if(c)return{content:[{type:`text`,text:`Onboard is already running. Please wait for it to complete before starting another.`}]};c=!0,s.info(`Starting onboard`,{path:e,mode:n});let a=await o({path:e,mode:n,outDir:r}),f=t(d).createTask(`Onboard`,a.steps.length);for(let e=0;e<a.steps.length;e++){let t=a.steps[e];f.progress(e,`${t.name}: ${t.status}`)}f.complete(`Onboard complete: ${a.steps.filter(e=>e.status===`success`).length}/${a.steps.length} steps succeeded`),l(i,u,a);let p=[`## Onboard Complete`,``,`**Path:** \`${a.path}\``,`**Mode:** ${a.mode}`,`**Duration:** ${a.totalDurationMs}ms`,``];a.outDir&&(p.push(`**Output directory:** \`${a.outDir}\``),p.push(``)),p.push(`### Analysis Results`,``);let m=[],h=[];for(let e of a.steps)e.status===`success`?m.push(`- ✓ **${e.name}** (${e.durationMs}ms) — ${e.output.length} chars`):h.push(`- ✗ **${e.name}** — ${e.error}`);p.push(...m),h.length>0&&p.push(``,`### Failed`,``,...h),p.push(``,`---`,``);for(let e of a.steps)e.status===`success`&&p.push(`### ${e.name}`,``,e.output,``,`---`,``);return p.push(`_All results auto-saved to KB.`,a.mode===`generate`?` Files written to \`${a.outDir}\`.`:``," Next: Use `search` to query the knowledge, or `remember` to add custom insights._"),{content:[{type:`text`,text:p.join(`
|
|
2
|
+
`)}]}}catch(e){return s.error(`Onboard failed`,a(e)),{content:[{type:`text`,text:`Onboard failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}finally{c=!1}})}export{u as registerOnboardTool};
|