@documentation-robotics/cli 0.1.13 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -2
- package/dist/analysis/relationship-classifier.js +2 -9
- package/dist/analysis/relationship-classifier.js.map +2 -2
- package/dist/analyzers/call-graph-utils.js +2 -2
- package/dist/analyzers/call-graph-utils.js.map +2 -2
- package/dist/analyzers/cards/build.js +171 -0
- package/dist/analyzers/cards/build.js.map +7 -0
- package/dist/analyzers/cards/classify.js +42 -0
- package/dist/analyzers/cards/classify.js.map +7 -0
- package/dist/analyzers/cards/edge-index.js +44 -0
- package/dist/analyzers/cards/edge-index.js.map +7 -0
- package/dist/analyzers/cards/facts.js +46 -0
- package/dist/analyzers/cards/facts.js.map +7 -0
- package/dist/analyzers/cards/graph.js +42 -0
- package/dist/analyzers/cards/graph.js.map +7 -0
- package/dist/analyzers/cards/index.js +8 -0
- package/dist/analyzers/cards/index.js.map +7 -0
- package/dist/analyzers/cards/tier0.js +18 -0
- package/dist/analyzers/cards/tier0.js.map +7 -0
- package/dist/analyzers/cards/types.js +1 -0
- package/dist/analyzers/cards/types.js.map +7 -0
- package/dist/analyzers/cbm-analyzer.js +195 -171
- package/dist/analyzers/cbm-analyzer.js.map +2 -2
- package/dist/analyzers/cbm-responses.js +336 -0
- package/dist/analyzers/cbm-responses.js.map +7 -0
- package/dist/analyzers/edge-relationships.js +45 -0
- package/dist/analyzers/edge-relationships.js.map +7 -0
- package/dist/analyzers/mapping-loader.js +9 -0
- package/dist/analyzers/mapping-loader.js.map +2 -2
- package/dist/analyzers/tier0-rules.js +153 -0
- package/dist/analyzers/tier0-rules.js.map +7 -0
- package/dist/analyzers/types.js.map +1 -1
- package/dist/analyzers/verify-engine.js +22 -19
- package/dist/analyzers/verify-engine.js.map +2 -2
- package/dist/audit/relationships/ai/prompts.js +10 -10
- package/dist/audit/relationships/ai/prompts.js.map +2 -2
- package/dist/audit/relationships/analysis/layer-templates.js +52 -52
- package/dist/audit/relationships/analysis/layer-templates.js.map +1 -1
- package/dist/cli.js +112 -28
- package/dist/cli.js.map +3 -3
- package/dist/coding-agents/agents/claude-code.js +3 -1
- package/dist/coding-agents/agents/claude-code.js.map +2 -2
- package/dist/coding-agents/claude-code-client.js +2 -1
- package/dist/coding-agents/claude-code-client.js.map +2 -2
- package/dist/coding-agents/copilot-client.js +17 -12
- package/dist/coding-agents/copilot-client.js.map +2 -2
- package/dist/coding-agents/default-permissions.js +152 -0
- package/dist/coding-agents/default-permissions.js.map +7 -0
- package/dist/coding-agents/drbot-mcp.js +167 -0
- package/dist/coding-agents/drbot-mcp.js.map +7 -0
- package/dist/commands/add.js +12 -7
- package/dist/commands/add.js.map +2 -2
- package/dist/commands/analyzer.js +134 -23
- package/dist/commands/analyzer.js.map +2 -2
- package/dist/commands/audit.js +6 -6
- package/dist/commands/audit.js.map +2 -2
- package/dist/commands/changeset-verify.js +55 -0
- package/dist/commands/changeset-verify.js.map +7 -0
- package/dist/commands/changeset.js +261 -147
- package/dist/commands/changeset.js.map +2 -2
- package/dist/commands/delete.js +52 -19
- package/dist/commands/delete.js.map +3 -3
- package/dist/commands/element.js +3 -2
- package/dist/commands/element.js.map +2 -2
- package/dist/commands/farm.js +773 -0
- package/dist/commands/farm.js.map +7 -0
- package/dist/commands/init.js +11 -1
- package/dist/commands/init.js.map +2 -2
- package/dist/commands/mcp.js +122 -0
- package/dist/commands/mcp.js.map +7 -0
- package/dist/commands/relationship.js +251 -47
- package/dist/commands/relationship.js.map +2 -2
- package/dist/commands/reports.js +1 -1
- package/dist/commands/reports.js.map +2 -2
- package/dist/commands/update.js +56 -24
- package/dist/commands/update.js.map +2 -2
- package/dist/commands/upgrade.js +99 -11
- package/dist/commands/upgrade.js.map +3 -3
- package/dist/commands/validate.js +41 -3
- package/dist/commands/validate.js.map +2 -2
- package/dist/commands/version.js +2 -2
- package/dist/commands/version.js.map +2 -2
- package/dist/commands/visualize.js +4 -3
- package/dist/commands/visualize.js.map +2 -2
- package/dist/config.js +83 -0
- package/dist/config.js.map +7 -0
- package/dist/core/annotation-store.js +138 -0
- package/dist/core/annotation-store.js.map +7 -0
- package/dist/core/catalog-migration.js +33 -0
- package/dist/core/catalog-migration.js.map +7 -0
- package/dist/core/changeset-analysis.js +421 -0
- package/dist/core/changeset-analysis.js.map +7 -0
- package/dist/core/changeset-base-index.js +153 -0
- package/dist/core/changeset-base-index.js.map +7 -0
- package/dist/core/changeset-brief-delta.js +102 -0
- package/dist/core/changeset-brief-delta.js.map +7 -0
- package/dist/core/changeset-graph.js +281 -0
- package/dist/core/changeset-graph.js.map +7 -0
- package/dist/core/changeset-only-guard.js +32 -0
- package/dist/core/changeset-only-guard.js.map +7 -0
- package/dist/core/changeset-summary.js +68 -0
- package/dist/core/changeset-summary.js.map +7 -0
- package/dist/core/changeset-validator.js +66 -20
- package/dist/core/changeset-validator.js.map +2 -2
- package/dist/core/changeset-verify.js +518 -0
- package/dist/core/changeset-verify.js.map +7 -0
- package/dist/core/changeset.js +56 -9
- package/dist/core/changeset.js.map +2 -2
- package/dist/core/element-type-migration.js +145 -0
- package/dist/core/element-type-migration.js.map +7 -0
- package/dist/core/farm-manifest.js +140 -0
- package/dist/core/farm-manifest.js.map +7 -0
- package/dist/core/farm-sync-engine.js +346 -0
- package/dist/core/farm-sync-engine.js.map +7 -0
- package/dist/core/farm-sync-state.js +167 -0
- package/dist/core/farm-sync-state.js.map +7 -0
- package/dist/core/manifest.js +6 -3
- package/dist/core/manifest.js.map +2 -2
- package/dist/core/migration-registry.js +84 -1
- package/dist/core/migration-registry.js.map +2 -2
- package/dist/core/model-upgrade.js +102 -0
- package/dist/core/model-upgrade.js.map +7 -0
- package/dist/core/model.js +257 -44
- package/dist/core/model.js.map +3 -3
- package/dist/core/mutation-handler.js +71 -6
- package/dist/core/mutation-handler.js.map +2 -2
- package/dist/core/relationship-migration-table.js +6639 -0
- package/dist/core/relationship-migration-table.js.map +7 -0
- package/dist/core/relationship-migration.js +272 -0
- package/dist/core/relationship-migration.js.map +7 -0
- package/dist/core/relationship-prune.js +49 -0
- package/dist/core/relationship-prune.js.map +7 -0
- package/dist/core/relationship-staging.js +68 -0
- package/dist/core/relationship-staging.js.map +7 -0
- package/dist/core/relationships.js +26 -4
- package/dist/core/relationships.js.map +2 -2
- package/dist/core/report-data-model.js +7 -13
- package/dist/core/report-data-model.js.map +2 -2
- package/dist/core/staged-changeset-storage.js +64 -17
- package/dist/core/staged-changeset-storage.js.map +2 -2
- package/dist/core/staged-source-reference.js +28 -0
- package/dist/core/staged-source-reference.js.map +7 -0
- package/dist/core/staging-area.js +83 -18
- package/dist/core/staging-area.js.map +2 -2
- package/dist/core/virtual-projection.js +14 -5
- package/dist/core/virtual-projection.js.map +2 -2
- package/dist/export/archimate-exporter.js +1 -0
- package/dist/export/archimate-exporter.js.map +2 -2
- package/dist/generated/compiled-validators.js +2 -2
- package/dist/generated/compiled-validators.js.map +2 -2
- package/dist/generated/layer-registry.js +16 -16
- package/dist/generated/layer-registry.js.map +2 -2
- package/dist/generated/node-types.js +186 -168
- package/dist/generated/node-types.js.map +2 -2
- package/dist/generated/relationship-index.js +2209 -7727
- package/dist/generated/relationship-index.js.map +2 -2
- package/dist/integrations/claude_code/agents/dr-architect.md +16 -3
- package/dist/integrations/claude_code/agents/dr-extractor.md +1 -1
- package/dist/integrations/claude_code/commands/dr-analyzer.md +565 -0
- package/dist/integrations/claude_code/commands/dr-map.md +13 -0
- package/dist/integrations/claude_code/commands/dr-plan.md +40 -0
- package/dist/integrations/claude_code/commands/dr-relate.md +106 -96
- package/dist/integrations/claude_code/commands/dr-verify.md +45 -2
- package/dist/integrations/claude_code/docs/END_TO_END_WALKTHROUGH.md +14 -0
- package/dist/integrations/claude_code/docs/MCP_SERVER.md +79 -0
- package/dist/integrations/claude_code/docs/QUICK_START.md +37 -8
- package/dist/integrations/claude_code/docs/README.md +52 -1
- package/dist/integrations/claude_code/skills/dr_01_motivation_layer/SKILL.md +93 -72
- package/dist/integrations/claude_code/skills/dr_02_business_layer/SKILL.md +163 -126
- package/dist/integrations/claude_code/skills/dr_03_product_layer/SKILL.md +161 -126
- package/dist/integrations/claude_code/skills/dr_04_security_layer/SKILL.md +153 -133
- package/dist/integrations/claude_code/skills/dr_05_application_layer/SKILL.md +129 -100
- package/dist/integrations/claude_code/skills/dr_06_technology_layer/SKILL.md +111 -94
- package/dist/integrations/claude_code/skills/dr_07_api_layer/SKILL.md +143 -157
- package/dist/integrations/claude_code/skills/dr_08_data_model_layer/SKILL.md +117 -33
- package/dist/integrations/claude_code/skills/dr_09_dataset_layer/SKILL.md +74 -25
- package/dist/integrations/claude_code/skills/dr_10_ux_layer/SKILL.md +88 -12
- package/dist/integrations/claude_code/skills/dr_11_navigation_layer/SKILL.md +83 -24
- package/dist/integrations/claude_code/skills/dr_12_apm_layer/SKILL.md +57 -12
- package/dist/integrations/claude_code/skills/dr_13_testing_layer/SKILL.md +92 -15
- package/dist/integrations/claude_code/skills/dr_change_planning/SKILL.md +119 -0
- package/dist/integrations/claude_code/skills/dr_changeset_reviewer/SKILL.md +3 -0
- package/dist/integrations/claude_code/skills/dr_engineering_guide/SKILL.md +1 -1
- package/dist/integrations/github_copilot/agents/dr-architect.md +1 -1
- package/dist/integrations/github_copilot/skills/dr_01_motivation_layer/SKILL.md +182 -102
- package/dist/integrations/github_copilot/skills/dr_02_business_layer/SKILL.md +266 -148
- package/dist/integrations/github_copilot/skills/dr_03_product_layer/SKILL.md +547 -86
- package/dist/integrations/github_copilot/skills/dr_04_security_layer/SKILL.md +164 -169
- package/dist/integrations/github_copilot/skills/dr_05_application_layer/SKILL.md +420 -150
- package/dist/integrations/github_copilot/skills/dr_06_technology_layer/SKILL.md +331 -138
- package/dist/integrations/github_copilot/skills/dr_07_api_layer/SKILL.md +265 -201
- package/dist/integrations/github_copilot/skills/dr_08_data_model_layer/SKILL.md +181 -58
- package/dist/integrations/github_copilot/skills/dr_09_dataset_layer/SKILL.md +209 -57
- package/dist/integrations/github_copilot/skills/dr_10_ux_layer/SKILL.md +277 -112
- package/dist/integrations/github_copilot/skills/dr_11_navigation_layer/SKILL.md +219 -70
- package/dist/integrations/github_copilot/skills/dr_12_apm_layer/SKILL.md +189 -105
- package/dist/integrations/github_copilot/skills/dr_13_testing_layer/SKILL.md +222 -102
- package/dist/integrations/github_copilot/skills/dr_change_planning/SKILL.md +119 -0
- package/dist/integrations/github_copilot/skills/dr_changeset_reviewer/SKILL.md +3 -0
- package/dist/integrations/hash-utils.js.map +2 -2
- package/dist/mcp/api-key-manager.js +111 -0
- package/dist/mcp/api-key-manager.js.map +7 -0
- package/dist/mcp/changeset-only.js +34 -0
- package/dist/mcp/changeset-only.js.map +7 -0
- package/dist/mcp/http-transport.js +176 -0
- package/dist/mcp/http-transport.js.map +7 -0
- package/dist/mcp/resource-registry.js +97 -0
- package/dist/mcp/resource-registry.js.map +7 -0
- package/dist/mcp/tool-registry.js +60 -0
- package/dist/mcp/tool-registry.js.map +7 -0
- package/dist/mcp/tools/annotation-create.js +39 -0
- package/dist/mcp/tools/annotation-create.js.map +7 -0
- package/dist/mcp/tools/annotation-delete.js +29 -0
- package/dist/mcp/tools/annotation-delete.js.map +7 -0
- package/dist/mcp/tools/annotation-get.js +29 -0
- package/dist/mcp/tools/annotation-get.js.map +7 -0
- package/dist/mcp/tools/annotation-list.js +24 -0
- package/dist/mcp/tools/annotation-list.js.map +7 -0
- package/dist/mcp/tools/annotation-reply.js +34 -0
- package/dist/mcp/tools/annotation-reply.js.map +7 -0
- package/dist/mcp/tools/annotation-shared.js +10 -0
- package/dist/mcp/tools/annotation-shared.js.map +7 -0
- package/dist/mcp/tools/annotation-update.js +39 -0
- package/dist/mcp/tools/annotation-update.js.map +7 -0
- package/dist/mcp/tools/changeset-analysis-tools.js +78 -0
- package/dist/mcp/tools/changeset-analysis-tools.js.map +7 -0
- package/dist/mcp/tools/changeset-editing.js +184 -0
- package/dist/mcp/tools/changeset-editing.js.map +7 -0
- package/dist/mcp/tools/changeset-lifecycle.js +83 -0
- package/dist/mcp/tools/changeset-lifecycle.js.map +7 -0
- package/dist/mcp/tools/changeset-list.js +33 -0
- package/dist/mcp/tools/changeset-list.js.map +7 -0
- package/dist/mcp/tools/changeset-shared.js +31 -0
- package/dist/mcp/tools/changeset-shared.js.map +7 -0
- package/dist/mcp/tools/changeset-show.js +55 -0
- package/dist/mcp/tools/changeset-show.js.map +7 -0
- package/dist/mcp/tools/changeset-verify.js +43 -0
- package/dist/mcp/tools/changeset-verify.js.map +7 -0
- package/dist/mcp/tools/chat-launch.js +50 -0
- package/dist/mcp/tools/chat-launch.js.map +7 -0
- package/dist/mcp/tools/chat-status.js +26 -0
- package/dist/mcp/tools/chat-status.js.map +7 -0
- package/dist/mcp/tools/index.js +65 -0
- package/dist/mcp/tools/index.js.map +7 -0
- package/dist/mcp/tools/model-add.js +107 -0
- package/dist/mcp/tools/model-add.js.map +7 -0
- package/dist/mcp/tools/model-delete.js +99 -0
- package/dist/mcp/tools/model-delete.js.map +7 -0
- package/dist/mcp/tools/model-export.js +72 -0
- package/dist/mcp/tools/model-export.js.map +7 -0
- package/dist/mcp/tools/model-info.js +51 -0
- package/dist/mcp/tools/model-info.js.map +7 -0
- package/dist/mcp/tools/model-list.js +53 -0
- package/dist/mcp/tools/model-list.js.map +7 -0
- package/dist/mcp/tools/model-reload.js +34 -0
- package/dist/mcp/tools/model-reload.js.map +7 -0
- package/dist/mcp/tools/model-search.js +102 -0
- package/dist/mcp/tools/model-search.js.map +7 -0
- package/dist/mcp/tools/model-show.js +68 -0
- package/dist/mcp/tools/model-show.js.map +7 -0
- package/dist/mcp/tools/model-stats.js +22 -0
- package/dist/mcp/tools/model-stats.js.map +7 -0
- package/dist/mcp/tools/model-trace.js +118 -0
- package/dist/mcp/tools/model-trace.js.map +7 -0
- package/dist/mcp/tools/model-update.js +121 -0
- package/dist/mcp/tools/model-update.js.map +7 -0
- package/dist/mcp/tools/model-validate.js +78 -0
- package/dist/mcp/tools/model-validate.js.map +7 -0
- package/dist/mcp/tools/relationship-tools.js +98 -0
- package/dist/mcp/tools/relationship-tools.js.map +7 -0
- package/dist/mcp/tools/shared.js +126 -0
- package/dist/mcp/tools/shared.js.map +7 -0
- package/dist/mcp/tools/spec-type.js +90 -0
- package/dist/mcp/tools/spec-type.js.map +7 -0
- package/dist/reports/model-layer-report-generator.js +5 -3
- package/dist/reports/model-layer-report-generator.js.map +2 -2
- package/dist/reports/model-readme-generator.js +116 -0
- package/dist/reports/model-readme-generator.js.map +7 -0
- package/dist/reports/model-report-data.js +37 -1
- package/dist/reports/model-report-data.js.map +2 -2
- package/dist/reports/model-report-orchestrator.js +29 -6
- package/dist/reports/model-report-orchestrator.js.map +2 -2
- package/dist/reports/model-report-utils.js +9 -0
- package/dist/reports/model-report-utils.js.map +7 -0
- package/dist/schemas/bundled/analyzers/cbm.json +1186 -68
- package/dist/schemas/bundled/analyzers/manifest.json +2 -2
- package/dist/schemas/bundled/api.json +1029 -1658
- package/dist/schemas/bundled/apm.json +499 -734
- package/dist/schemas/bundled/application.json +745 -370
- package/dist/schemas/bundled/base.json +3 -220
- package/dist/schemas/bundled/business.json +452 -366
- package/dist/schemas/bundled/data-model.json +403 -383
- package/dist/schemas/bundled/data-store.json +334 -558
- package/dist/schemas/bundled/manifest.json +18 -18
- package/dist/schemas/bundled/motivation.json +349 -368
- package/dist/schemas/bundled/navigation.json +415 -731
- package/dist/schemas/bundled/product.json +325 -159
- package/dist/schemas/bundled/security.json +864 -1232
- package/dist/schemas/bundled/technology.json +574 -703
- package/dist/schemas/bundled/testing.json +718 -1643
- package/dist/schemas/bundled/ux.json +739 -1352
- package/dist/server/schemas.js +8 -0
- package/dist/server/schemas.js.map +2 -2
- package/dist/server/server.js +234 -31
- package/dist/server/server.js.map +2 -2
- package/dist/server-entry.js +2 -1
- package/dist/server-entry.js.map +2 -2
- package/dist/telemetry/config.js +2 -40
- package/dist/telemetry/config.js.map +2 -2
- package/dist/telemetry/index.js +1 -1
- package/dist/types/index.js.map +2 -2
- package/dist/utils/ansi-suppressor.js +23 -0
- package/dist/utils/ansi-suppressor.js.map +7 -0
- package/dist/utils/attribute-patch.js +41 -0
- package/dist/utils/attribute-patch.js.map +7 -0
- package/dist/utils/color-utils.js +34 -0
- package/dist/utils/color-utils.js.map +7 -0
- package/dist/utils/element-reference-shape.js +15 -1
- package/dist/utils/element-reference-shape.js.map +3 -3
- package/dist/utils/error-hints.js +29 -0
- package/dist/utils/error-hints.js.map +7 -0
- package/dist/utils/errors.js +75 -10
- package/dist/utils/errors.js.map +2 -2
- package/dist/utils/globals.js +17 -1
- package/dist/utils/globals.js.map +2 -2
- package/dist/utils/project-paths.js +50 -3
- package/dist/utils/project-paths.js.map +2 -2
- package/dist/utils/reference-path-parser.js +49 -0
- package/dist/utils/reference-path-parser.js.map +7 -0
- package/dist/utils/source-reference.js +17 -10
- package/dist/utils/source-reference.js.map +2 -2
- package/dist/utils/spec-version.js +10 -2
- package/dist/utils/spec-version.js.map +2 -2
- package/dist/validators/composed-reference-validator.js +240 -0
- package/dist/validators/composed-reference-validator.js.map +7 -0
- package/dist/validators/reference-validator.js +57 -13
- package/dist/validators/reference-validator.js.map +3 -3
- package/dist/validators/relationship-schema-validator.js +33 -5
- package/dist/validators/relationship-schema-validator.js.map +3 -3
- package/dist/validators/schema-validator.js +27 -9
- package/dist/validators/schema-validator.js.map +2 -2
- package/dist/validators/types.js.map +1 -1
- package/dist/viewer/README.md +6 -6
- package/dist/viewer/assets/main-CxzcuU_o.js +84 -0
- package/dist/viewer/assets/main-j-7ULYpm.css +1 -0
- package/dist/viewer/index.html +2 -2
- package/dist/viewer/manifest.json +10 -10
- package/dist/viewer/version.json +1 -1
- package/package.json +7 -3
- package/dist/viewer/assets/main-B7AOQXXX.js +0 -81
- package/dist/viewer/assets/main-vdrFrG7q.css +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/changeset-editing.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * changeset_update, changeset_unstage, changeset_discard \u2014 revise a staged changeset while\n * planning a change. Mirror `dr changeset unstage|discard` and add the rename / re-describe step\n * the CLI has no command for, all through StagingAreaManager.\n *\n * Every mutation reloads the cached model afterwards, like changeset-lifecycle.ts: the model\n * projects the active changeset's elements at load time, and the projection cache is keyed by\n * what is staged.\n *\n * Commit and apply stay off the MCP surface (landing a change is the human's step). Discard is\n * exposed because an agent must be able to abandon its own plan, but it clears the staged changes\n * for good, so it needs `confirm: true`. See docs/CHANGE_MODELING.md.\n */\n\nimport { z } from \"zod\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { ChangesetGraph } from \"../../core/changeset-graph.js\";\nimport type { Changeset, StagedChange } from \"../../core/changeset.js\";\nimport { StagingAreaManager } from \"../../core/staging-area.js\";\nimport { stagedRelationshipChangesAtEnds, stagedRelationshipTriple } from \"../../core/relationship-staging.js\";\nimport { CLIError, ErrorCategory, getErrorMessage } from \"../../utils/errors.js\";\nimport { jsonResult, loadModel, reloadModel, rootPathSchema, runTool, type McpToolDefinition } from \"./shared.js\";\nimport { resolveChangeset } from \"./changeset-shared.js\";\n\nconst changesetIdSchema = z\n .string()\n .optional()\n .describe(\"Changeset ID or name. Defaults to the active changeset.\");\n\nfunction requireStaged(changeset: Changeset, action: string): void {\n if (changeset.status !== \"staged\") {\n throw new CLIError(`Changeset '${changeset.name}' is ${changeset.status}; cannot ${action}`, ErrorCategory.USER, [\n 'Use \"changeset_list\" to find a staged changeset, or \"changeset_create\" to start a new one',\n ]);\n }\n}\n\n/** Wraps a StagingAreaManager error (plain Error) as a user error the agent can act on. */\nasync function asUserError<T>(fn: () => Promise<T>, suggestions: string[]): Promise<T> {\n try {\n return await fn();\n } catch (error) {\n if (error instanceof CLIError) throw error;\n throw new CLIError(getErrorMessage(error), ErrorCategory.USER, suggestions);\n }\n}\n\nfunction summarize(change: StagedChange): Record<string, unknown> {\n const triple = change.type.startsWith(\"relationship-\") ? stagedRelationshipTriple(change) : null;\n return {\n type: change.type,\n elementId: change.elementId,\n layer: change.layerName,\n ...(triple ? { relationship: triple } : {}),\n };\n}\n\n// ---------------------------------------------------------------------------\n// changeset_update\n// ---------------------------------------------------------------------------\n\nconst updateInputSchema = {\n changesetId: changesetIdSchema,\n name: z.string().min(1).optional().describe(\"New name. Must not be another changeset's name.\"),\n description: z\n .string()\n .optional()\n .describe(\"New description: the change's intent and what done looks like. An empty string clears it.\"),\n rootPath: rootPathSchema,\n};\n\nexport type ChangesetUpdateArgs = z.infer<z.ZodObject<typeof updateInputSchema>>;\n\nexport async function changesetUpdateHandler(args: ChangesetUpdateArgs): Promise<CallToolResult> {\n return runTool(async () => {\n if (args.name === undefined && args.description === undefined) {\n throw new CLIError(\"Nothing to update\", ErrorCategory.USER, ['Pass \"name\" and/or \"description\"']);\n }\n const model = await loadModel(args.rootPath);\n const manager = new StagingAreaManager(model.rootPath, model);\n const changeset = await resolveChangeset(manager, args.changesetId);\n\n const updated = await asUserError(\n () => manager.update(changeset.id!, { name: args.name, description: args.description }),\n ['Use \"changeset_list\" to see the names already taken']\n );\n await reloadModel(args.rootPath);\n\n return jsonResult({\n id: updated.id,\n name: updated.name,\n ...(changeset.name !== updated.name ? { previousName: changeset.name } : {}),\n description: updated.description ?? null,\n status: updated.status,\n changes: updated.changes.length,\n });\n });\n}\n\nexport const changesetUpdateTool: McpToolDefinition<typeof updateInputSchema> = {\n name: \"changeset_update\",\n description:\n \"Rename a changeset or change its description (the change's intent). Staged changes are untouched. \" +\n \"Defaults to the active changeset.\",\n inputSchema: updateInputSchema,\n handler: changesetUpdateHandler,\n};\n\n// ---------------------------------------------------------------------------\n// changeset_unstage\n// ---------------------------------------------------------------------------\n\nconst unstageInputSchema = {\n changesetId: changesetIdSchema,\n elementId: z\n .string()\n .optional()\n .describe(\"Drop every staged change to this element (its add, updates or delete). ID or path.\"),\n source: z\n .string()\n .optional()\n .describe(\n \"Drop staged relationship changes (adds and deletes) from this element: to target when given, otherwise to \" +\n \"any element. The element's own changes are not touched.\"\n ),\n target: z\n .string()\n .optional()\n .describe(\n \"Drop staged relationship changes (adds and deletes) to this element: from source when given, otherwise from \" +\n \"any element. The element's own changes are not touched.\"\n ),\n predicate: z.string().optional().describe(\"Only relationship changes with this predicate. Omit for any.\"),\n keepRelationships: z\n .boolean()\n .optional()\n .describe(\n \"With elementId: keep the staged relationship changes that depend on the element's change. By default, \" +\n \"unstaging an element's add also drops staged relationships to it (they would dangle), and unstaging its \" +\n \"delete also drops the relationship removals its cascade staged (removals staged before the delete are kept).\"\n ),\n rootPath: rootPathSchema,\n};\n\nexport type ChangesetUnstageArgs = z.infer<z.ZodObject<typeof unstageInputSchema>>;\n\nfunction describeEnds(args: { source?: string; target?: string }): string {\n if (args.source && args.target) return `from ${args.source} to ${args.target}`;\n return args.source ? `from ${args.source}` : `to ${args.target}`;\n}\n\nexport async function changesetUnstageHandler(args: ChangesetUnstageArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const byElement = args.elementId !== undefined;\n const byRelationship = args.source !== undefined || args.target !== undefined;\n if (byElement === byRelationship) {\n throw new CLIError(\"Name either an element or a relationship to unstage\", ErrorCategory.USER, [\n 'Pass \"elementId\" to drop an element\\'s staged changes',\n 'Or pass \"source\" and/or \"target\" (and optionally \"predicate\") to drop staged relationship changes',\n ]);\n }\n if (byRelationship && !args.source && !args.target) {\n throw new CLIError('\"source\" or \"target\" must not be empty', ErrorCategory.USER);\n }\n\n const model = await loadModel(args.rootPath);\n const manager = new StagingAreaManager(model.rootPath, model);\n const changeset = await resolveChangeset(manager, args.changesetId);\n requireStaged(changeset, \"unstage changes\");\n const graph = await ChangesetGraph.build(model, changeset);\n const changes = changeset.changes as StagedChange[];\n\n const keys = new Set<string>();\n const notes: string[] = [];\n\n if (byElement) {\n const element = graph.getElement(args.elementId!);\n const ids = new Set([args.elementId!, ...(element ? [element.id, element.uuid ?? element.id] : [])]);\n const own = changes.filter((c) => !c.type.startsWith(\"relationship-\") && ids.has(c.elementId));\n for (const change of own) keys.add(change.elementId);\n\n // Relationship changes that only make sense with the element's change.\n const dependentType = own.some((c) => c.type === \"add\")\n ? \"relationship-add\"\n : own.some((c) => c.type === \"delete\")\n ? \"relationship-delete\"\n : null;\n const touching = dependentType\n ? changes.filter((c) => {\n if (c.type !== dependentType) return false;\n const triple = stagedRelationshipTriple(c);\n return (\n !!triple &&\n (ids.has(triple.source) ||\n ids.has(triple.target) ||\n (element && (graph.resolve(triple.source) === element.id || graph.resolve(triple.target) === element.id)))\n );\n })\n : [];\n // A delete cascades into relationship removals staged right after it. Removals staged before the\n // delete were the agent's own decisions, not the cascade's, so they stay.\n const seq = (c: StagedChange): number => c.sequenceNumber ?? changes.indexOf(c);\n const deleteSeqs = own.filter((c) => c.type === \"delete\").map(seq);\n const firstDelete = deleteSeqs.length > 0 ? Math.min(...deleteSeqs) : -1;\n const dependent =\n dependentType === \"relationship-delete\" ? touching.filter((c) => seq(c) > firstDelete) : touching;\n const deliberate = touching.filter((c) => !dependent.includes(c));\n if (deliberate.length > 0) {\n notes.push(\n `${deliberate.length} relationship removal(s) on ${args.elementId} staged before its delete were kept ` +\n `(${deliberate.map((c) => c.elementId).join(\", \")}); unstage them by source and target if they should go too`\n );\n }\n if (dependent.length > 0) {\n if (args.keepRelationships) {\n notes.push(\n `${dependent.length} staged relationship change(s) on ${args.elementId} were kept (keepRelationships)` +\n (dependentType === \"relationship-add\" ? \"; they will dangle unless the element is staged again\" : \"\")\n );\n } else {\n for (const change of dependent) keys.add(change.elementId);\n }\n }\n } else {\n const matched = stagedRelationshipChangesAtEnds(graph, changeset, {\n source: args.source || undefined,\n target: args.target || undefined,\n predicate: args.predicate,\n });\n // A relationship removal staged after the delete of one of its ends is that delete's cascade:\n // without it the deleted element's relationship dangles and the changeset no longer commits.\n const seq = (c: StagedChange): number => c.sequenceNumber ?? changes.indexOf(c);\n const deleteSeq = new Map<string, number>();\n for (const change of changes) {\n if (change.type !== \"delete\") continue;\n const id = graph.resolve(change.elementId);\n deleteSeq.set(id, Math.min(deleteSeq.get(id) ?? Infinity, seq(change)));\n }\n const deletedEndOf = (change: StagedChange): string | undefined => {\n if (change.type !== \"relationship-delete\") return undefined;\n const triple = stagedRelationshipTriple(change);\n if (!triple) return undefined;\n return [graph.resolve(triple.source), graph.resolve(triple.target)].find(\n (end) => deleteSeq.has(end) && deleteSeq.get(end)! < seq(change)\n );\n };\n const cascaded = matched.filter((c) => deletedEndOf(c) !== undefined);\n const deletedEnds = [...new Set(cascaded.map((c) => deletedEndOf(c)!))].join(\", \");\n const cascadeList = cascaded.map((c) => c.elementId).join(\", \");\n // One end sweeps every relationship there, so it leaves a delete's cascade alone. Naming both\n // ends asks for those relationships specifically, so they go, with a warning.\n const bothEnds = !!args.source && !!args.target;\n for (const change of matched) {\n if (!bothEnds && cascaded.includes(change)) continue;\n keys.add(change.elementId);\n }\n if (cascaded.length > 0 && bothEnds) {\n notes.push(\n `Unstaged ${cascaded.length} relationship removal(s) cascaded from the staged delete of ${deletedEnds} ` +\n `(${cascadeList}): those relationships now dangle, so the changeset will not commit until they are ` +\n `removed again or the delete is unstaged (\"changeset_unstage\" with elementId)`\n );\n } else if (cascaded.length > 0) {\n notes.push(\n `Kept ${cascaded.length} relationship removal(s) cascaded from the staged delete of ${deletedEnds} ` +\n `(${cascadeList}): dropping them would leave those relationships dangling. Unstage the delete ` +\n `(\"changeset_unstage\" with elementId) to restore them, or name both source and target to drop one anyway`\n );\n }\n }\n\n const removed = changes.filter((c) => keys.has(c.elementId));\n if (removed.length === 0) {\n return jsonResult({\n status: \"not-staged\",\n changeset: changeset.name,\n message: byElement\n ? `No staged change to ${args.elementId} in '${changeset.name}'`\n : `No staged relationship change ${describeEnds(args)}` +\n `${args.predicate ? ` (${args.predicate})` : \"\"} in '${changeset.name}'`,\n suggestions: ['Use \"changeset_show\" to list the staged changes'],\n ...(notes.length > 0 ? { notes } : {}),\n });\n }\n\n for (const key of keys) {\n await manager.unstage(changeset.id!, key);\n }\n await reloadModel(args.rootPath);\n\n return jsonResult({\n status: \"unstaged\",\n changeset: changeset.name,\n unstaged: removed.map(summarize),\n remainingChanges: changes.length - removed.length,\n ...(notes.length > 0 ? { notes } : {}),\n });\n });\n}\n\nexport const changesetUnstageTool: McpToolDefinition<typeof unstageInputSchema> = {\n name: \"changeset_unstage\",\n description:\n \"Undo part of a staged changeset: drop the staged changes to one element (elementId), or the staged \" +\n \"relationship adds/deletes between source and target, or every one from source alone or to target alone \" +\n \"(optionally one predicate). The base model is not touched. \" +\n \"Defaults to the active changeset. Use changeset_show to see what is staged.\",\n inputSchema: unstageInputSchema,\n handler: changesetUnstageHandler,\n};\n\n// ---------------------------------------------------------------------------\n// changeset_discard\n// ---------------------------------------------------------------------------\n\nconst discardInputSchema = {\n changesetId: z.string().describe(\"Changeset ID or name to discard. Required: discard is never implied.\"),\n confirm: z\n .boolean()\n .describe(\n \"Must be true. Discarding deletes the changeset's staged changes permanently (only its name, description and \" +\n \"a 'discarded' status remain), so confirm only when the plan is to be abandoned.\"\n ),\n rootPath: rootPathSchema,\n};\n\nexport type ChangesetDiscardArgs = z.infer<z.ZodObject<typeof discardInputSchema>>;\n\nexport async function changesetDiscardHandler(args: ChangesetDiscardArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const model = await loadModel(args.rootPath);\n const manager = new StagingAreaManager(model.rootPath, model);\n const changeset = await resolveChangeset(manager, args.changesetId);\n requireStaged(changeset, \"discard it\");\n\n if (args.confirm !== true) {\n throw new CLIError(\n `Discarding '${changeset.name}' deletes its ${changeset.changes.length} staged change(s) permanently`,\n ErrorCategory.USER,\n [\n 'Pass \"confirm\": true to discard it',\n 'Use \"changeset_unstage\" to drop individual changes instead',\n 'Use \"changeset_deactivate\" to stop staging into it and keep its changes',\n ]\n );\n }\n\n const wasActive = (await manager.getActiveId()) === changeset.id;\n const discardedChanges = changeset.changes.length;\n await manager.discard(changeset.id!);\n if (wasActive) {\n await manager.clearActive();\n }\n await reloadModel(args.rootPath);\n\n return jsonResult({\n id: changeset.id,\n name: changeset.name,\n status: \"discarded\",\n discardedChanges,\n deactivated: wasActive,\n });\n });\n}\n\nexport const changesetDiscardTool: McpToolDefinition<typeof discardInputSchema> = {\n name: \"changeset_discard\",\n description:\n \"Abandon a staged changeset: PERMANENTLY deletes its staged changes and marks it discarded (deactivating it if \" +\n \"active). Not recoverable, so it requires confirm: true. The base model is not touched. To undo part of a \" +\n \"plan use changeset_unstage; to pause it use changeset_deactivate.\",\n inputSchema: discardInputSchema,\n handler: changesetDiscardHandler,\n};\n"],
|
|
5
|
+
"mappings": "AAcA,SAAS,SAAS;AAElB,SAAS,sBAAsB;AAE/B,SAAS,0BAA0B;AACnC,SAAS,iCAAiC,gCAAgC;AAC1E,SAAS,UAAU,eAAe,uBAAuB;AACzD,SAAS,YAAY,WAAW,aAAa,gBAAgB,eAAuC;AACpG,SAAS,wBAAwB;AAEjC,MAAM,oBAAoB,EACvB,OAAM,EACN,SAAQ,EACR,SAAS,yDAAyD;AAErE,SAAS,cAAc,WAAsB,QAAc;AACzD,MAAI,UAAU,WAAW;AACvB,UAAM,IAAI,SAAS,cAAc,UAAU,IAAI,QAAQ,UAAU,MAAM,YAAY,MAAM,IAAI,cAAc,MAAM;MAC/G;KACD;AAEL;AAGA,eAAe,YAAe,IAAsB,aAAqB;AACvE,MAAI;AACF,WAAO,MAAM,GAAE;EACjB,SAAS,OAAO;AACd,UAAI,iBAAiB,WAAgB,QAC/B,IAAI,SAAS,gBAAgB,KAAK,GAAG,cAAc,MAAM,WAAW;EAC5E;AACF;AAEA,SAAS,UAAU,QAAoB;AACrC,QAAM,SAAS,OAAO,KAAK,WAAW,eAAe,IAAI,yBAAyB,MAAM,IAAI;AAC5F,SAAO;IACL,MAAM,OAAO;IACb,WAAW,OAAO;IAClB,OAAO,OAAO;IACd,GAAI,SAAS,EAAE,cAAc,OAAM,IAAK,CAAA;;AAE5C;AAMA,MAAM,oBAAoB;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ChB,QAAQ;MACR;MACA,aAAa;KACd;EACH,CAAC;AACH;AAEO,MAAM,uBAAqE;EAChF,MAAM;EACN,aACE;EAGF,aAAa;EACb,SAAS;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { StagingAreaManager } from "../../core/staging-area.js";
|
|
3
|
+
import { CLIError, ErrorCategory } from "../../utils/errors.js";
|
|
4
|
+
import { jsonResult, loadModel, reloadModel, rootPathSchema, runTool } from "./shared.js";
|
|
5
|
+
import { resolveChangeset } from "./changeset-shared.js";
|
|
6
|
+
const createInputSchema = {
|
|
7
|
+
name: z.string().min(1).describe("Short name for the change, e.g. 'add-order-export'."),
|
|
8
|
+
description: z.string().optional().describe("The change's intent: what it is for and what done looks like. Shown to the human reviewing it."),
|
|
9
|
+
activate: z.boolean().optional().describe("Make it the active changeset so mutations stage into it (default true)."),
|
|
10
|
+
rootPath: rootPathSchema
|
|
11
|
+
};
|
|
12
|
+
async function changesetCreateHandler(args) {
|
|
13
|
+
return runTool(async () => {
|
|
14
|
+
const model = await loadModel(args.rootPath), manager = new StagingAreaManager(model.rootPath, model);
|
|
15
|
+
if (await manager.load(args.name))
|
|
16
|
+
throw new CLIError(`Changeset '${args.name}' already exists`, ErrorCategory.USER, [
|
|
17
|
+
`Use "changeset_activate" with "${args.name}" to continue it`,
|
|
18
|
+
"Or choose another name"
|
|
19
|
+
]);
|
|
20
|
+
const changeset = await manager.create(args.name, args.description), activate = args.activate ?? !0, previouslyActive = activate ? await manager.getActiveId() : null;
|
|
21
|
+
return activate && (await manager.setActive(changeset.id), await reloadModel(args.rootPath)), jsonResult({
|
|
22
|
+
id: changeset.id,
|
|
23
|
+
name: changeset.name,
|
|
24
|
+
...changeset.description ? { description: changeset.description } : {},
|
|
25
|
+
status: changeset.status,
|
|
26
|
+
active: activate,
|
|
27
|
+
...previouslyActive && previouslyActive !== changeset.id ? { deactivated: previouslyActive } : {}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const changesetCreateTool = {
|
|
32
|
+
name: "changeset_create",
|
|
33
|
+
description: "Start planning a change: create a changeset carrying the change's intent and (by default) activate it, so model_add / model_update / model_delete / relationship_add / relationship_delete stage into it instead of writing the model. The human commits it later; it is never committed over MCP.",
|
|
34
|
+
inputSchema: createInputSchema,
|
|
35
|
+
handler: changesetCreateHandler
|
|
36
|
+
}, activateInputSchema = {
|
|
37
|
+
changesetId: z.string().describe("Changeset ID or name."),
|
|
38
|
+
rootPath: rootPathSchema
|
|
39
|
+
};
|
|
40
|
+
async function changesetActivateHandler(args) {
|
|
41
|
+
return runTool(async () => {
|
|
42
|
+
const model = await loadModel(args.rootPath), manager = new StagingAreaManager(model.rootPath, model), changeset = await resolveChangeset(manager, args.changesetId);
|
|
43
|
+
if (changeset.status !== "staged")
|
|
44
|
+
throw new CLIError(`Changeset '${changeset.name}' is ${changeset.status} and cannot accept changes`, ErrorCategory.USER, ['Use "changeset_create" to start a new one']);
|
|
45
|
+
const previouslyActive = await manager.getActiveId();
|
|
46
|
+
return await manager.setActive(changeset.id), await reloadModel(args.rootPath), jsonResult({
|
|
47
|
+
id: changeset.id,
|
|
48
|
+
name: changeset.name,
|
|
49
|
+
active: !0,
|
|
50
|
+
changes: changeset.changes.length,
|
|
51
|
+
...previouslyActive && previouslyActive !== changeset.id ? { deactivated: previouslyActive } : {}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const changesetActivateTool = {
|
|
56
|
+
name: "changeset_activate",
|
|
57
|
+
description: "Make an existing staged changeset the active one, so mutations stage into it.",
|
|
58
|
+
inputSchema: activateInputSchema,
|
|
59
|
+
handler: changesetActivateHandler
|
|
60
|
+
}, deactivateInputSchema = {
|
|
61
|
+
rootPath: rootPathSchema
|
|
62
|
+
};
|
|
63
|
+
async function changesetDeactivateHandler(args) {
|
|
64
|
+
return runTool(async () => {
|
|
65
|
+
const model = await loadModel(args.rootPath), manager = new StagingAreaManager(model.rootPath, model), activeId = await manager.getActiveId();
|
|
66
|
+
return activeId && (await manager.clearActive(), await reloadModel(args.rootPath)), jsonResult({ deactivated: activeId ?? null });
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const changesetDeactivateTool = {
|
|
70
|
+
name: "changeset_deactivate",
|
|
71
|
+
description: "Deactivate the active changeset. Its changes stay staged; afterwards mutations write the base model directly.",
|
|
72
|
+
inputSchema: deactivateInputSchema,
|
|
73
|
+
handler: changesetDeactivateHandler
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
changesetActivateHandler,
|
|
77
|
+
changesetActivateTool,
|
|
78
|
+
changesetCreateHandler,
|
|
79
|
+
changesetCreateTool,
|
|
80
|
+
changesetDeactivateHandler,
|
|
81
|
+
changesetDeactivateTool
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=changeset-lifecycle.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/changeset-lifecycle.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * changeset_create, changeset_activate, changeset_deactivate \u2014 open and switch the changeset\n * that model and relationship mutations stage into. Mirrors `dr changeset create|activate|deactivate`.\n *\n * Every one of these reloads the cached model afterwards: the model decides at load time whether\n * its layers are projected through an active changeset.\n *\n * Commit, apply and delete are deliberately not exposed over MCP: landing a change is the\n * human's step (viewer or CLI). Rename, unstage and (confirmed) discard are in\n * changeset-editing.ts. See docs/CHANGE_MODELING.md.\n */\n\nimport { z } from \"zod\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { StagingAreaManager } from \"../../core/staging-area.js\";\nimport { CLIError, ErrorCategory } from \"../../utils/errors.js\";\nimport { jsonResult, loadModel, reloadModel, rootPathSchema, runTool, type McpToolDefinition } from \"./shared.js\";\nimport { resolveChangeset } from \"./changeset-shared.js\";\n\n// ---------------------------------------------------------------------------\n// changeset_create\n// ---------------------------------------------------------------------------\n\nconst createInputSchema = {\n name: z.string().min(1).describe(\"Short name for the change, e.g. 'add-order-export'.\"),\n description: z\n .string()\n .optional()\n .describe(\"The change's intent: what it is for and what done looks like. Shown to the human reviewing it.\"),\n activate: z\n .boolean()\n .optional()\n .describe(\"Make it the active changeset so mutations stage into it (default true).\"),\n rootPath: rootPathSchema,\n};\n\nexport type ChangesetCreateArgs = z.infer<z.ZodObject<typeof createInputSchema>>;\n\nexport async function changesetCreateHandler(args: ChangesetCreateArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const model = await loadModel(args.rootPath);\n const manager = new StagingAreaManager(model.rootPath, model);\n\n if (await manager.load(args.name)) {\n throw new CLIError(`Changeset '${args.name}' already exists`, ErrorCategory.USER, [\n `Use \"changeset_activate\" with \"${args.name}\" to continue it`,\n \"Or choose another name\",\n ]);\n }\n\n const changeset = await manager.create(args.name, args.description);\n const activate = args.activate ?? true;\n const previouslyActive = activate ? await manager.getActiveId() : null;\n if (activate) {\n await manager.setActive(changeset.id);\n await reloadModel(args.rootPath);\n }\n\n return jsonResult({\n id: changeset.id,\n name: changeset.name,\n ...(changeset.description ? { description: changeset.description } : {}),\n status: changeset.status,\n active: activate,\n ...(previouslyActive && previouslyActive !== changeset.id ? { deactivated: previouslyActive } : {}),\n });\n });\n}\n\nexport const changesetCreateTool: McpToolDefinition<typeof createInputSchema> = {\n name: \"changeset_create\",\n description:\n \"Start planning a change: create a changeset carrying the change's intent and (by default) activate it, \" +\n \"so model_add / model_update / model_delete / relationship_add / relationship_delete stage into it instead \" +\n \"of writing the model. The human commits it later; it is never committed over MCP.\",\n inputSchema: createInputSchema,\n handler: changesetCreateHandler,\n};\n\n// ---------------------------------------------------------------------------\n// changeset_activate\n// ---------------------------------------------------------------------------\n\nconst activateInputSchema = {\n changesetId: z.string().describe(\"Changeset ID or name.\"),\n rootPath: rootPathSchema,\n};\n\nexport type ChangesetActivateArgs = z.infer<z.ZodObject<typeof activateInputSchema>>;\n\nexport async function changesetActivateHandler(args: ChangesetActivateArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const model = await loadModel(args.rootPath);\n const manager = new StagingAreaManager(model.rootPath, model);\n const changeset = await resolveChangeset(manager, args.changesetId);\n\n if (changeset.status !== \"staged\") {\n throw new CLIError(\n `Changeset '${changeset.name}' is ${changeset.status} and cannot accept changes`,\n ErrorCategory.USER,\n ['Use \"changeset_create\" to start a new one']\n );\n }\n\n const previouslyActive = await manager.getActiveId();\n await manager.setActive(changeset.id);\n await reloadModel(args.rootPath);\n\n return jsonResult({\n id: changeset.id,\n name: changeset.name,\n active: true,\n changes: changeset.changes.length,\n ...(previouslyActive && previouslyActive !== changeset.id ? { deactivated: previouslyActive } : {}),\n });\n });\n}\n\nexport const changesetActivateTool: McpToolDefinition<typeof activateInputSchema> = {\n name: \"changeset_activate\",\n description: \"Make an existing staged changeset the active one, so mutations stage into it.\",\n inputSchema: activateInputSchema,\n handler: changesetActivateHandler,\n};\n\n// ---------------------------------------------------------------------------\n// changeset_deactivate\n// ---------------------------------------------------------------------------\n\nconst deactivateInputSchema = {\n rootPath: rootPathSchema,\n};\n\nexport type ChangesetDeactivateArgs = z.infer<z.ZodObject<typeof deactivateInputSchema>>;\n\nexport async function changesetDeactivateHandler(args: ChangesetDeactivateArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const model = await loadModel(args.rootPath);\n const manager = new StagingAreaManager(model.rootPath, model);\n const activeId = await manager.getActiveId();\n if (activeId) {\n await manager.clearActive();\n await reloadModel(args.rootPath);\n }\n return jsonResult({ deactivated: activeId ?? null });\n });\n}\n\nexport const changesetDeactivateTool: McpToolDefinition<typeof deactivateInputSchema> = {\n name: \"changeset_deactivate\",\n description:\n \"Deactivate the active changeset. Its changes stay staged; afterwards mutations write the base model directly.\",\n inputSchema: deactivateInputSchema,\n handler: changesetDeactivateHandler,\n};\n"],
|
|
5
|
+
"mappings": "AAYA,SAAS,SAAS;AAElB,S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,QAAQ,YAAW;AACxB,UAAM,QAAQ,MAAM,UAAU,KAAK,QAAQ,GACrC,UAAU,IAAI,mBAAmB,MAAM,UAAU,KAAK,GACtD,YAAY,MAAM,iBAAiB,SAAS,KAAK,WAAW;AAElE,QAAI,UAAU,WAAW;AACvB,YAAM,IAAI,SACR,cAAc,UAAU,IAAI,QAAQ,UAAU,MAAM,8BACpD,cAAc,MACd,CAAC,2CAA2C,CAAC;AAIjD,UAAM,mBAAmB,MAAM,QAAQ,YAAW;AAClD,iBAAM,QAAQ,UAAU,UAAU,EAAE,GACpC,MAAM,YAAY,KAAK,QAAQ,GAExB,WAAW;MAChB,IAAI,UAAU;MACd,MAAM,UAAU;MAChB,QAAQ;MACR,SAAS,UAAU,QAAQ;MAC3B,GAAI,oBAAoB,qBAAqB,UAAU,KAAK,EAAE,aAAa,iBAAgB,IAAK,CAAA;KACjG;EACH,CAAC;AACH;AAEO,MAAM,wBAAuE;EAClF,MAAM;EACN,aAAa;EACb,aAAa;EACb,SAAS;GAOL,wBAAwB;EAC5B,UAAU;;AAKZ,eAAsB,2BAA2B,MAA6B;AAC5E,SAAO,QAAQ,YAAW;AACxB,UAAM,QAAQ,MAAM,UAAU,KAAK,QAAQ,GACrC,UAAU,IAAI,mBAAmB,MAAM,UAAU,KAAK,GACtD,WAAW,MAAM,QAAQ,YAAW;AAC1C,WAAI,aACF,MAAM,QAAQ,YAAW,GACzB,MAAM,YAAY,KAAK,QAAQ,IAE1B,WAAW,EAAE,aAAa,YAAY,KAAI,CAAE;EACrD,CAAC;AACH;AAEO,MAAM,0BAA2E;EACtF,MAAM;EACN,aACE;EACF,aAAa;EACb,SAAS;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { StagingAreaManager } from "../../core/staging-area.js";
|
|
2
|
+
import { jsonResult, loadModel, rootPathSchema, runTool } from "./shared.js";
|
|
3
|
+
const inputSchema = {
|
|
4
|
+
rootPath: rootPathSchema
|
|
5
|
+
};
|
|
6
|
+
async function changesetListHandler(args) {
|
|
7
|
+
return runTool(async () => {
|
|
8
|
+
const model = await loadModel(args.rootPath), manager = new StagingAreaManager(model.rootPath, model), changesets = await manager.list(), activeChangesetId = await manager.getActiveId(), changesetsById = {};
|
|
9
|
+
for (const changeset of changesets)
|
|
10
|
+
changesetsById[changeset.id] = {
|
|
11
|
+
name: changeset.name,
|
|
12
|
+
status: changeset.status,
|
|
13
|
+
created: changeset.created,
|
|
14
|
+
changes_count: changeset.changes.length
|
|
15
|
+
};
|
|
16
|
+
return jsonResult({
|
|
17
|
+
version: "1.0.0",
|
|
18
|
+
changesets: changesetsById,
|
|
19
|
+
activeChangesetId
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const changesetListTool = {
|
|
24
|
+
name: "changeset_list",
|
|
25
|
+
description: "List all staged changesets, mirroring the REST GET /api/changesets endpoint.",
|
|
26
|
+
inputSchema,
|
|
27
|
+
handler: changesetListHandler
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
changesetListHandler,
|
|
31
|
+
changesetListTool
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=changeset-list.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/changeset-list.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * changeset_list \u2014 list all staged changesets. Mirrors the REST\n * `GET /api/changesets` endpoint (see `ChangesetsListSchema` in\n * `cli/src/server/schemas.ts`).\n */\n\nimport type { z } from \"zod\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { StagingAreaManager } from \"../../core/staging-area.js\";\nimport { jsonResult, loadModel, rootPathSchema, runTool, type McpToolDefinition } from \"./shared.js\";\n\nconst inputSchema = {\n rootPath: rootPathSchema,\n};\n\nexport type ChangesetListArgs = z.infer<z.ZodObject<typeof inputSchema>>;\n\nexport async function changesetListHandler(args: ChangesetListArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const model = await loadModel(args.rootPath);\n const manager = new StagingAreaManager(model.rootPath, model);\n const changesets = await manager.list();\n const activeChangesetId = await manager.getActiveId();\n\n const changesetsById: Record<\n string,\n { name: string; status: string; created: string; changes_count: number }\n > = {};\n for (const changeset of changesets) {\n changesetsById[changeset.id] = {\n name: changeset.name,\n status: changeset.status,\n created: changeset.created,\n changes_count: changeset.changes.length,\n };\n }\n\n return jsonResult({\n version: \"1.0.0\",\n changesets: changesetsById,\n activeChangesetId,\n });\n });\n}\n\nexport const changesetListTool: McpToolDefinition<typeof inputSchema> = {\n name: \"changeset_list\",\n description: \"List all staged changesets, mirroring the REST GET /api/changesets endpoint.\",\n inputSchema,\n handler: changesetListHandler,\n};\n"],
|
|
5
|
+
"mappings": "AAQA,SAAS,0BAA0B;AACnC,SAAS,YAAY,WAAW,gBAAgB,eAAuC;AAEvF,MAAM,cAAc;EAClB,UAAU;;AAKZ,eAAsB,qBAAqB,MAAuB;AAChE,SAAO,QAAQ,YAAW;AACxB,UAAM,QAAQ,MAAM,UAAU,KAAK,QAAQ,GACrC,UAAU,IAAI,mBAAmB,MAAM,UAAU,KAAK,GACtD,aAAa,MAAM,QAAQ,KAAI,GAC/B,oBAAoB,MAAM,QAAQ,YAAW,GAE7C,iBAGF,CAAA;AACJ,eAAW,aAAa;AACtB,qBAAe,UAAU,EAAE,IAAI;QAC7B,MAAM,UAAU;QAChB,QAAQ,UAAU;QAClB,SAAS,UAAU;QACnB,eAAe,UAAU,QAAQ;;AAIrC,WAAO,WAAW;MAChB,SAAS;MACT,YAAY;MACZ;KACD;EACH,CAAC;AACH;AAEO,MAAM,oBAA2D;EACtE,MAAM;EACN,aAAa;EACb;EACA,SAAS;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ChangesetGraph } from "../../core/changeset-graph.js";
|
|
2
|
+
import { StagingAreaManager } from "../../core/staging-area.js";
|
|
3
|
+
import { CLIError, ErrorCategory } from "../../utils/errors.js";
|
|
4
|
+
async function resolveChangeset(manager, changesetId, parameter = "changesetId") {
|
|
5
|
+
const id = changesetId ?? await manager.getActiveId();
|
|
6
|
+
if (!id)
|
|
7
|
+
throw new CLIError("No changeset named and none is active", ErrorCategory.USER, [
|
|
8
|
+
`Pass "${parameter}", or use "changeset_create" / "changeset_activate" first`,
|
|
9
|
+
'Use "changeset_list" to see existing changesets'
|
|
10
|
+
]);
|
|
11
|
+
const changeset = await manager.load(id);
|
|
12
|
+
if (!changeset)
|
|
13
|
+
throw new CLIError(`Changeset ${id} not found`, ErrorCategory.NOT_FOUND, [
|
|
14
|
+
'Use "changeset_list" to see all available changesets'
|
|
15
|
+
]);
|
|
16
|
+
return changeset;
|
|
17
|
+
}
|
|
18
|
+
async function activeStagedChangeset(manager) {
|
|
19
|
+
const active = await manager.getActive();
|
|
20
|
+
return active && active.status === "staged" ? active : null;
|
|
21
|
+
}
|
|
22
|
+
async function loadChangesetGraph(model, changesetId) {
|
|
23
|
+
const manager = new StagingAreaManager(model.rootPath, model), changeset = await resolveChangeset(manager, changesetId), graph = await ChangesetGraph.build(model, changeset);
|
|
24
|
+
return { manager, changeset, graph };
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
activeStagedChangeset,
|
|
28
|
+
loadChangesetGraph,
|
|
29
|
+
resolveChangeset
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=changeset-shared.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/changeset-shared.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Helpers shared by the changeset-planning MCP tools.\n */\n\nimport type { Changeset } from \"../../core/changeset.js\";\nimport { ChangesetGraph } from \"../../core/changeset-graph.js\";\nimport type { Model } from \"../../core/model.js\";\nimport { StagingAreaManager } from \"../../core/staging-area.js\";\nimport { CLIError, ErrorCategory } from \"../../utils/errors.js\";\n\n/** Loads a changeset by id or name, or the active one when none is named. */\nexport async function resolveChangeset(\n manager: StagingAreaManager,\n changesetId?: string,\n /** The tool parameter that names the changeset, for the hint when none is named or active. */\n parameter = \"changesetId\"\n): Promise<Changeset> {\n const id = changesetId ?? (await manager.getActiveId());\n if (!id) {\n throw new CLIError(\"No changeset named and none is active\", ErrorCategory.USER, [\n `Pass \"${parameter}\", or use \"changeset_create\" / \"changeset_activate\" first`,\n 'Use \"changeset_list\" to see existing changesets',\n ]);\n }\n const changeset = await manager.load(id);\n if (!changeset) {\n throw new CLIError(`Changeset ${id} not found`, ErrorCategory.NOT_FOUND, [\n 'Use \"changeset_list\" to see all available changesets',\n ]);\n }\n return changeset;\n}\n\n/** The active changeset when it can still accept changes, else null. */\nexport async function activeStagedChangeset(manager: StagingAreaManager): Promise<Changeset | null> {\n const active = await manager.getActive();\n return active && active.status === \"staged\" ? active : null;\n}\n\n/** Builds the projected graph for a changeset (by id/name, or the active one). */\nexport async function loadChangesetGraph(\n model: Model,\n changesetId?: string\n): Promise<{ manager: StagingAreaManager; changeset: Changeset; graph: ChangesetGraph }> {\n const manager = new StagingAreaManager(model.rootPath, model);\n const changeset = await resolveChangeset(manager, changesetId);\n const graph = await ChangesetGraph.build(model, changeset);\n return { manager, changeset, graph };\n}\n"],
|
|
5
|
+
"mappings": "AAKA,SAAS,sBAAsB;AAE/B,SAAS,0BAA0B;AACnC,SAAS,UAAU,qBAAqB;AAGxC,eAAsB,iBACpB,SACA,aAEA,YAAY,eAAa;AAEzB,QAAM,KAAK,eAAgB,MAAM,QAAQ,YAAW;AACpD,MAAI,CAAC;AACH,UAAM,IAAI,SAAS,yCAAyC,cAAc,MAAM;MAC9E,SAAS,SAAS;MAClB;KACD;AAEH,QAAM,YAAY,MAAM,QAAQ,KAAK,EAAE;AACvC,MAAI,CAAC;AACH,UAAM,IAAI,SAAS,aAAa,EAAE,cAAc,cAAc,WAAW;MACvE;KACD;AAEH,SAAO;AACT;AAGA,eAAsB,sBAAsB,SAA2B;AACrE,QAAM,SAAS,MAAM,QAAQ,UAAS;AACtC,SAAO,UAAU,OAAO,WAAW,WAAW,SAAS;AACzD;AAGA,eAAsB,mBACpB,OACA,aAAoB;AAEpB,QAAM,UAAU,IAAI,mBAAmB,MAAM,UAAU,KAAK,GACtD,YAAY,MAAM,iBAAiB,SAAS,WAAW,GACvD,QAAQ,MAAM,eAAe,MAAM,OAAO,SAAS;AACzD,SAAO,EAAE,SAAS,WAAW,MAAK;AACpC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { StagingAreaManager } from "../../core/staging-area.js";
|
|
3
|
+
import { summarizeChangeset } from "../../core/changeset-summary.js";
|
|
4
|
+
import { CLIError, ErrorCategory } from "../../utils/errors.js";
|
|
5
|
+
import { jsonResult, loadModel, rootPathSchema, runTool } from "./shared.js";
|
|
6
|
+
const inputSchema = {
|
|
7
|
+
changesetId: z.string().describe("Changeset ID or name."),
|
|
8
|
+
detail: z.enum(["full", "summary"]).optional().describe('"full" (default): every change with its before/after snapshots. "summary": one entry per change (sequence, operation, element id and type or relationship source/predicate/target, and for updates the changed field names such as attributes.summary), plus totals per operation, without snapshots.'),
|
|
9
|
+
rootPath: rootPathSchema
|
|
10
|
+
};
|
|
11
|
+
async function changesetShowHandler(args) {
|
|
12
|
+
return runTool(async () => {
|
|
13
|
+
const model = await loadModel(args.rootPath), changeset = await new StagingAreaManager(model.rootPath, model).load(args.changesetId);
|
|
14
|
+
if (!changeset)
|
|
15
|
+
throw new CLIError(`Changeset ${args.changesetId} not found`, ErrorCategory.NOT_FOUND, [
|
|
16
|
+
'Use "changeset_list" to see all available changesets'
|
|
17
|
+
]);
|
|
18
|
+
if (args.detail === "summary") {
|
|
19
|
+
const summary = summarizeChangeset(changeset.changes);
|
|
20
|
+
return jsonResult({
|
|
21
|
+
id: changeset.id,
|
|
22
|
+
name: changeset.name,
|
|
23
|
+
description: changeset.description,
|
|
24
|
+
status: changeset.status,
|
|
25
|
+
created: changeset.created,
|
|
26
|
+
modified: changeset.modified,
|
|
27
|
+
detail: "summary",
|
|
28
|
+
totals: summary.totals,
|
|
29
|
+
changes: summary.changes
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return jsonResult({
|
|
33
|
+
id: changeset.id,
|
|
34
|
+
name: changeset.name,
|
|
35
|
+
description: changeset.description,
|
|
36
|
+
status: changeset.status,
|
|
37
|
+
created: changeset.created,
|
|
38
|
+
modified: changeset.modified,
|
|
39
|
+
baseSnapshot: changeset.baseSnapshot,
|
|
40
|
+
stats: changeset.stats,
|
|
41
|
+
changes: changeset.changes
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const changesetShowTool = {
|
|
46
|
+
name: "changeset_show",
|
|
47
|
+
description: `Show a single changeset's detail including its description, stats, and list of changes. Pass detail: "summary" for one compact line per change (operation, element or relationship, changed fields) and totals per operation, without the before/after snapshots.`,
|
|
48
|
+
inputSchema,
|
|
49
|
+
handler: changesetShowHandler
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
changesetShowHandler,
|
|
53
|
+
changesetShowTool
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=changeset-show.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/changeset-show.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * changeset_show \u2014 show a single changeset's full detail, including its list\n * of changes. Mirrors the REST `GET /api/changesets/:changesetId` endpoint\n * (see `ChangesetDetailSchema` in `cli/src/server/schemas.ts`).\n */\n\nimport { z } from \"zod\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { StagingAreaManager } from \"../../core/staging-area.js\";\nimport { summarizeChangeset } from \"../../core/changeset-summary.js\";\nimport { CLIError, ErrorCategory } from \"../../utils/errors.js\";\nimport { jsonResult, loadModel, rootPathSchema, runTool, type McpToolDefinition } from \"./shared.js\";\n\nconst inputSchema = {\n changesetId: z.string().describe(\"Changeset ID or name.\"),\n detail: z\n .enum([\"full\", \"summary\"])\n .optional()\n .describe(\n '\"full\" (default): every change with its before/after snapshots. \"summary\": one entry per change ' +\n \"(sequence, operation, element id and type or relationship source/predicate/target, and for updates the \" +\n \"changed field names such as attributes.summary), plus totals per operation, without snapshots.\"\n ),\n rootPath: rootPathSchema,\n};\n\nexport type ChangesetShowArgs = z.infer<z.ZodObject<typeof inputSchema>>;\n\nexport async function changesetShowHandler(args: ChangesetShowArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const model = await loadModel(args.rootPath);\n const manager = new StagingAreaManager(model.rootPath, model);\n const changeset = await manager.load(args.changesetId);\n\n if (!changeset) {\n throw new CLIError(`Changeset ${args.changesetId} not found`, ErrorCategory.NOT_FOUND, [\n 'Use \"changeset_list\" to see all available changesets',\n ]);\n }\n\n if (args.detail === \"summary\") {\n const summary = summarizeChangeset(changeset.changes);\n return jsonResult({\n id: changeset.id,\n name: changeset.name,\n description: changeset.description,\n status: changeset.status,\n created: changeset.created,\n modified: changeset.modified,\n detail: \"summary\",\n totals: summary.totals,\n changes: summary.changes,\n });\n }\n\n return jsonResult({\n id: changeset.id,\n name: changeset.name,\n description: changeset.description,\n status: changeset.status,\n created: changeset.created,\n modified: changeset.modified,\n baseSnapshot: changeset.baseSnapshot,\n stats: changeset.stats,\n changes: changeset.changes,\n });\n });\n}\n\nexport const changesetShowTool: McpToolDefinition<typeof inputSchema> = {\n name: \"changeset_show\",\n description:\n \"Show a single changeset's detail including its description, stats, and list of changes. Pass \" +\n 'detail: \"summary\" for one compact line per change (operation, element or relationship, changed fields) ' +\n \"and totals per operation, without the before/after snapshots.\",\n inputSchema,\n handler: changesetShowHandler,\n};\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,SAAS;AAElB,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,UAAU,qBAAqB;AACxC,SAAS,YAAY,WAAW,gBAAgB,eAAuC;AAEvF,MAAM,cAAc;EAClB,aAAa,EAAE,OAAM,EAAG,SAAS,uBAAuB;EACxD,QAAQ,EACL,KAAK,CAAC,QAAQ,SAAS,CAAC,EACxB,SAAQ,EACR,SACC,uSAEkG;EAEtG,UAAU;;AAKZ,eAAsB,qBAAqB,MAAuB;AAChE,SAAO,QAAQ,YAAW;AACxB,UAAM,QAAQ,MAAM,UAAU,KAAK,QAAQ,GAErC,YAAY,MADF,IAAI,mBAAmB,MAAM,UAAU,KAAK,EAC5B,KAAK,KAAK,WAAW;AAErD,QAAI,CAAC;AACH,YAAM,IAAI,SAAS,aAAa,KAAK,WAAW,cAAc,cAAc,WAAW;QACrF;OACD;AAGH,QAAI,KAAK,WAAW,WAAW;AAC7B,YAAM,UAAU,mBAAmB,UAAU,OAAO;AACpD,aAAO,WAAW;QAChB,IAAI,UAAU;QACd,MAAM,UAAU;QAChB,aAAa,UAAU;QACvB,QAAQ,UAAU;QAClB,SAAS,UAAU;QACnB,UAAU,UAAU;QACpB,QAAQ;QACR,QAAQ,QAAQ;QAChB,SAAS,QAAQ;OAClB;IACH;AAEA,WAAO,WAAW;MAChB,IAAI,UAAU;MACd,MAAM,UAAU;MAChB,aAAa,UAAU;MACvB,QAAQ,UAAU;MAClB,SAAS,UAAU;MACnB,UAAU,UAAU;MACpB,cAAc,UAAU;MACxB,OAAO,UAAU;MACjB,SAAS,UAAU;KACpB;EACH,CAAC;AACH;AAEO,MAAM,oBAA2D;EACtE,MAAM;EACN,aACE;EAGF;EACA,SAAS;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { verifyChangesetInModel } from "../../core/changeset-verify.js";
|
|
3
|
+
import { StagingAreaManager } from "../../core/staging-area.js";
|
|
4
|
+
import { CLIError, ErrorCategory } from "../../utils/errors.js";
|
|
5
|
+
import { jsonResult, reloadModel, rootPathSchema, runTool } from "./shared.js";
|
|
6
|
+
import { resolveChangeset } from "./changeset-shared.js";
|
|
7
|
+
const inputSchema = {
|
|
8
|
+
planned: z.string().optional().describe("The planned changeset, by ID or name. Defaults to the active changeset."),
|
|
9
|
+
against: z.object({
|
|
10
|
+
changesetId: z.string().optional().describe("An as-built changeset (by ID or name), e.g. one written by extraction or by hand."),
|
|
11
|
+
base: z.boolean().optional().describe("Compare with the base model, e.g. after the as-built changeset was committed on the branch.")
|
|
12
|
+
}).describe('What was built: {"changesetId": "..."} or {"base": true}.'),
|
|
13
|
+
matchBySource: z.boolean().optional().describe("Also match elements of the same layer and type that share a source file (default true)."),
|
|
14
|
+
rootPath: rootPathSchema
|
|
15
|
+
};
|
|
16
|
+
async function changesetVerifyHandler(args) {
|
|
17
|
+
return runTool(async () => {
|
|
18
|
+
if (args.against?.changesetId && args.against.base)
|
|
19
|
+
throw new CLIError('Pass either "against.changesetId" or "against.base", not both', ErrorCategory.USER);
|
|
20
|
+
if (!args.against?.changesetId && !args.against?.base)
|
|
21
|
+
throw new CLIError("Nothing to verify against", ErrorCategory.USER, [
|
|
22
|
+
'Pass "against": {"changesetId": "<as-built changeset>"} to compare with another changeset',
|
|
23
|
+
'Pass "against": {"base": true} to compare with the base model'
|
|
24
|
+
]);
|
|
25
|
+
const model = await reloadModel(args.rootPath), manager = new StagingAreaManager(model.rootPath, model), planned = await resolveChangeset(manager, args.planned, "planned"), asBuilt = args.against?.changesetId ? await resolveChangeset(manager, args.against.changesetId) : void 0;
|
|
26
|
+
return jsonResult(await verifyChangesetInModel(model, {
|
|
27
|
+
planned,
|
|
28
|
+
against: asBuilt ? { changeset: asBuilt } : { base: !0 },
|
|
29
|
+
matchBySource: args.matchBySource
|
|
30
|
+
}));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const changesetVerifyTool = {
|
|
34
|
+
name: "changeset_verify",
|
|
35
|
+
description: "Compare a planned changeset with what was built: another (as-built) changeset, or the base model. Elements match by id, then by layer + type + name ignoring case and separators, then by source file; relationships match through those element matches. Reports matched, missing (planned, not built), unplanned (built, not planned), divergent (matched but type, description or attributes differ, with the fields), and planned deletions that still exist, with a verdict. Fuzzy matches are marked probable with their reason; confirm them. Reads the model fresh from disk, so a commit made outside MCP is seen. Read-only.",
|
|
36
|
+
inputSchema,
|
|
37
|
+
handler: changesetVerifyHandler
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
changesetVerifyHandler,
|
|
41
|
+
changesetVerifyTool
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=changeset-verify.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/changeset-verify.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * changeset_verify \u2014 compare a planned changeset with what was built.\n * See `cli/src/core/changeset-verify.ts` and docs/CHANGE_MODELING.md.\n */\n\nimport { z } from \"zod\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { verifyChangesetInModel } from \"../../core/changeset-verify.js\";\nimport { StagingAreaManager } from \"../../core/staging-area.js\";\nimport { CLIError, ErrorCategory } from \"../../utils/errors.js\";\nimport { jsonResult, reloadModel, rootPathSchema, runTool, type McpToolDefinition } from \"./shared.js\";\nimport { resolveChangeset } from \"./changeset-shared.js\";\n\nconst inputSchema = {\n planned: z\n .string()\n .optional()\n .describe(\"The planned changeset, by ID or name. Defaults to the active changeset.\"),\n against: z\n .object({\n changesetId: z\n .string()\n .optional()\n .describe(\"An as-built changeset (by ID or name), e.g. one written by extraction or by hand.\"),\n base: z\n .boolean()\n .optional()\n .describe(\"Compare with the base model, e.g. after the as-built changeset was committed on the branch.\"),\n })\n .describe('What was built: {\"changesetId\": \"...\"} or {\"base\": true}.'),\n matchBySource: z\n .boolean()\n .optional()\n .describe(\"Also match elements of the same layer and type that share a source file (default true).\"),\n rootPath: rootPathSchema,\n};\n\nexport type ChangesetVerifyArgs = z.infer<z.ZodObject<typeof inputSchema>>;\n\nexport async function changesetVerifyHandler(args: ChangesetVerifyArgs): Promise<CallToolResult> {\n return runTool(async () => {\n if (args.against?.changesetId && args.against.base) {\n throw new CLIError('Pass either \"against.changesetId\" or \"against.base\", not both', ErrorCategory.USER);\n }\n if (!args.against?.changesetId && !args.against?.base) {\n throw new CLIError(\"Nothing to verify against\", ErrorCategory.USER, [\n 'Pass \"against\": {\"changesetId\": \"<as-built changeset>\"} to compare with another changeset',\n 'Pass \"against\": {\"base\": true} to compare with the base model',\n ]);\n }\n // Always read the model fresh: the build is often committed outside MCP (`dr changeset commit` is\n // not exposed here), and a cached model would compare against the base as it was when the server\n // started. Verify is read-only and infrequent, so the reload is cheap insurance.\n const model = await reloadModel(args.rootPath);\n const manager = new StagingAreaManager(model.rootPath, model);\n const planned = await resolveChangeset(manager, args.planned, \"planned\");\n const asBuilt = args.against?.changesetId ? await resolveChangeset(manager, args.against.changesetId) : undefined;\n return jsonResult(\n await verifyChangesetInModel(model, {\n planned,\n against: asBuilt ? { changeset: asBuilt } : { base: true },\n matchBySource: args.matchBySource,\n })\n );\n });\n}\n\nexport const changesetVerifyTool: McpToolDefinition<typeof inputSchema> = {\n name: \"changeset_verify\",\n description:\n \"Compare a planned changeset with what was built: another (as-built) changeset, or the base model. Elements \" +\n \"match by id, then by layer + type + name ignoring case and separators, then by source file; relationships \" +\n \"match through those element matches. Reports matched, missing (planned, not built), unplanned (built, not \" +\n \"planned), divergent (matched but type, description or attributes differ, with the fields), and planned \" +\n \"deletions that still exist, with a verdict. Fuzzy matches are marked probable with their reason; confirm \" +\n \"them. Reads the model fresh from disk, so a commit made outside MCP is seen. Read-only.\",\n inputSchema,\n handler: changesetVerifyHandler,\n};\n"],
|
|
5
|
+
"mappings": "AAKA,SAAS,SAAS;AAElB,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,SAAS,UAAU,qBAAqB;AACxC,SAAS,YAAY,aAAa,gBAAgB,eAAuC;AACzF,SAAS,wBAAwB;AAEjC,MAAM,cAAc;EAClB,SAAS,EACN,OAAM,EACN,SAAQ,EACR,SAAS,yEAAyE;EACrF,SAAS,EACN,OAAO;IACN,aAAa,EACV,OAAM,EACN,SAAQ,EACR,SAAS,mFAAmF;IAC/F,MAAM,EACH,QAAO,EACP,SAAQ,EACR,SAAS,6FAA6F;GAC1G,EACA,SAAS,2DAA2D;EACvE,eAAe,EACZ,QAAO,EACP,SAAQ,EACR,SAAS,yFAAyF;EACrG,UAAU;;AAKZ,eAAsB,uBAAuB,MAAyB;AACpE,SAAO,QAAQ,YAAW;AACxB,QAAI,KAAK,SAAS,eAAe,KAAK,QAAQ;AAC5C,YAAM,IAAI,SAAS,iEAAiE,cAAc,IAAI;AAExG,QAAI,CAAC,KAAK,SAAS,eAAe,CAAC,KAAK,SAAS;AAC/C,YAAM,IAAI,SAAS,6BAA6B,cAAc,MAAM;QAClE;QACA;OACD;AAKH,UAAM,QAAQ,MAAM,YAAY,KAAK,QAAQ,GACvC,UAAU,IAAI,mBAAmB,MAAM,UAAU,KAAK,GACtD,UAAU,MAAM,iBAAiB,SAAS,KAAK,SAAS,SAAS,GACjE,UAAU,KAAK,SAAS,cAAc,MAAM,iBAAiB,SAAS,KAAK,QAAQ,WAAW,IAAI;AACxG,WAAO,WACL,MAAM,uBAAuB,OAAO;MAClC;MACA,SAAS,UAAU,EAAE,WAAW,QAAO,IAAK,EAAE,MAAM,GAAI;MACxD,eAAe,KAAK;KACrB,CAAC;EAEN,CAAC;AACH;AAEO,MAAM,sBAA6D;EACxE,MAAM;EACN,aACE;EAMF;EACA,SAAS;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { detectAvailableClients } from "../../coding-agents/chat-utils.js";
|
|
3
|
+
import { jsonResult, loadModel, rootPathSchema, runTool } from "./shared.js";
|
|
4
|
+
const inputSchema = {
|
|
5
|
+
prompt: z.string().min(1).describe("The message to send to the AI coding agent."),
|
|
6
|
+
client: z.string().optional().describe('Exact client name to use ("Claude Code" or "GitHub Copilot"). Defaults to the first available client.'),
|
|
7
|
+
agent: z.string().optional().describe('Optional agent/skill name to invoke. Defaults to "dr-architect".'),
|
|
8
|
+
rootPath: rootPathSchema
|
|
9
|
+
};
|
|
10
|
+
async function chatLaunchHandler(args) {
|
|
11
|
+
return runTool(async () => {
|
|
12
|
+
const model = await loadModel(args.rootPath), availableClients = await detectAvailableClients();
|
|
13
|
+
if (availableClients.length === 0)
|
|
14
|
+
return jsonResult({
|
|
15
|
+
status: "unavailable",
|
|
16
|
+
message: "No AI coding agent is installed. Install Claude Code or GitHub Copilot."
|
|
17
|
+
}, { isError: !0 });
|
|
18
|
+
let selected = availableClients[0];
|
|
19
|
+
if (args.client) {
|
|
20
|
+
const match = availableClients.find((client) => client.getClientName() === args.client);
|
|
21
|
+
if (!match)
|
|
22
|
+
return jsonResult({
|
|
23
|
+
status: "unavailable",
|
|
24
|
+
message: `"${args.client}" is not installed or not available. Available: ${availableClients.map((client) => client.getClientName()).join(", ")}`
|
|
25
|
+
}, { isError: !0 });
|
|
26
|
+
selected = match;
|
|
27
|
+
}
|
|
28
|
+
const response = await selected.sendMessage(args.prompt, {
|
|
29
|
+
workingDirectory: model.rootPath,
|
|
30
|
+
agent: args.agent ?? "dr-architect",
|
|
31
|
+
outputStream: null
|
|
32
|
+
});
|
|
33
|
+
return jsonResult({
|
|
34
|
+
status: "ok",
|
|
35
|
+
client: selected.getClientName(),
|
|
36
|
+
response
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const chatLaunchTool = {
|
|
41
|
+
name: "chat_launch",
|
|
42
|
+
description: "Send a single prompt to an installed AI coding agent (Claude Code or GitHub Copilot) in run-to-completion mode and return its full response.",
|
|
43
|
+
inputSchema,
|
|
44
|
+
handler: chatLaunchHandler
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
chatLaunchHandler,
|
|
48
|
+
chatLaunchTool
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=chat-launch.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/chat-launch.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * chat_launch \u2014 send a single prompt to an installed AI coding agent (Claude\n * Code or GitHub Copilot) in run-to-completion (`--print`) mode and return its\n * full response. Reuses `BaseChatClient.sendMessage()`, the same call `dr\n * chat` makes per turn, but as a single request/response instead of an\n * interactive REPL \u2014 there is no multi-turn session across separate\n * `chat_launch` calls.\n */\n\nimport { z } from \"zod\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { detectAvailableClients } from \"../../coding-agents/chat-utils.js\";\nimport { jsonResult, loadModel, rootPathSchema, runTool, type McpToolDefinition } from \"./shared.js\";\n\nconst inputSchema = {\n prompt: z.string().min(1).describe(\"The message to send to the AI coding agent.\"),\n client: z\n .string()\n .optional()\n .describe(\n 'Exact client name to use (\"Claude Code\" or \"GitHub Copilot\"). Defaults to the first available client.'\n ),\n agent: z\n .string()\n .optional()\n .describe('Optional agent/skill name to invoke. Defaults to \"dr-architect\".'),\n rootPath: rootPathSchema,\n};\n\nexport type ChatLaunchArgs = z.infer<z.ZodObject<typeof inputSchema>>;\n\nexport async function chatLaunchHandler(args: ChatLaunchArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const model = await loadModel(args.rootPath);\n const availableClients = await detectAvailableClients();\n\n if (availableClients.length === 0) {\n return jsonResult(\n {\n status: \"unavailable\",\n message: \"No AI coding agent is installed. Install Claude Code or GitHub Copilot.\",\n },\n { isError: true }\n );\n }\n\n let selected = availableClients[0];\n if (args.client) {\n const match = availableClients.find((client) => client.getClientName() === args.client);\n if (!match) {\n return jsonResult(\n {\n status: \"unavailable\",\n message: `\"${args.client}\" is not installed or not available. Available: ${availableClients\n .map((client) => client.getClientName())\n .join(\", \")}`,\n },\n { isError: true }\n );\n }\n selected = match;\n }\n\n const response = await selected.sendMessage(args.prompt, {\n workingDirectory: model.rootPath,\n agent: args.agent ?? \"dr-architect\",\n outputStream: null,\n });\n\n return jsonResult({\n status: \"ok\",\n client: selected.getClientName(),\n response,\n });\n });\n}\n\nexport const chatLaunchTool: McpToolDefinition<typeof inputSchema> = {\n name: \"chat_launch\",\n description:\n \"Send a single prompt to an installed AI coding agent (Claude Code or GitHub Copilot) in run-to-completion mode and return its full response.\",\n inputSchema,\n handler: chatLaunchHandler,\n};\n"],
|
|
5
|
+
"mappings": "AASA,SAAS,SAAS;AAElB,SAAS,8BAA8B;AACvC,SAAS,YAAY,WAAW,gBAAgB,eAAuC;AAEvF,MAAM,cAAc;EAClB,QAAQ,EAAE,OAAM,EAAG,IAAI,CAAC,EAAE,SAAS,6CAA6C;EAChF,QAAQ,EACL,OAAM,EACN,SAAQ,EACR,SACC,uGAAuG;EAE3G,OAAO,EACJ,OAAM,EACN,SAAQ,EACR,SAAS,kEAAkE;EAC9E,UAAU;;AAKZ,eAAsB,kBAAkB,MAAoB;AAC1D,SAAO,QAAQ,YAAW;AACxB,UAAM,QAAQ,MAAM,UAAU,KAAK,QAAQ,GACrC,mBAAmB,MAAM,uBAAsB;AAErD,QAAI,iBAAiB,WAAW;AAC9B,aAAO,WACL;QACE,QAAQ;QACR,SAAS;SAEX,EAAE,SAAS,GAAI,CAAE;AAIrB,QAAI,WAAW,iBAAiB,CAAC;AACjC,QAAI,KAAK,QAAQ;AACf,YAAM,QAAQ,iBAAiB,KAAK,CAAC,WAAW,OAAO,cAAa,MAAO,KAAK,MAAM;AACtF,UAAI,CAAC;AACH,eAAO,WACL;UACE,QAAQ;UACR,SAAS,IAAI,KAAK,MAAM,mDAAmD,iBACxE,IAAI,CAAC,WAAW,OAAO,cAAa,CAAE,EACtC,KAAK,IAAI,CAAC;WAEf,EAAE,SAAS,GAAI,CAAE;AAGrB,iBAAW;IACb;AAEA,UAAM,WAAW,MAAM,SAAS,YAAY,KAAK,QAAQ;MACvD,kBAAkB,MAAM;MACxB,OAAO,KAAK,SAAS;MACrB,cAAc;KACf;AAED,WAAO,WAAW;MAChB,QAAQ;MACR,QAAQ,SAAS,cAAa;MAC9B;KACD;EACH,CAAC;AACH;AAEO,MAAM,iBAAwD;EACnE,MAAM;EACN,aACE;EACF;EACA,SAAS;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { detectAvailableClients, selectChatClient } from "../../coding-agents/chat-utils.js";
|
|
2
|
+
import { jsonResult, runTool } from "./shared.js";
|
|
3
|
+
const inputSchema = {};
|
|
4
|
+
async function chatStatusHandler(_args) {
|
|
5
|
+
return runTool(async () => {
|
|
6
|
+
const availableClients = await detectAvailableClients(), selected = selectChatClient(availableClients);
|
|
7
|
+
return jsonResult({
|
|
8
|
+
available: availableClients.map((client) => client.getClientName()),
|
|
9
|
+
selected: selected ? selected.getClientName() : null,
|
|
10
|
+
sdk_available: availableClients.length > 0,
|
|
11
|
+
sdk_version: selected ? selected.getClientName() : null,
|
|
12
|
+
error_message: availableClients.length === 0 ? "No chat client available. Install Claude Code or GitHub Copilot." : null
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const chatStatusTool = {
|
|
17
|
+
name: "chat_status",
|
|
18
|
+
description: "Report which AI coding agents (Claude Code, GitHub Copilot) are installed and available.",
|
|
19
|
+
inputSchema,
|
|
20
|
+
handler: chatStatusHandler
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
chatStatusHandler,
|
|
24
|
+
chatStatusTool
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=chat-status.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/chat-status.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * chat_status \u2014 report which AI coding agents (Claude Code, GitHub Copilot)\n * are installed and available. Mirrors the REST/WebSocket `chat.status`\n * JSON-RPC method (`cli/src/server/server.ts`).\n */\n\nimport type { z } from \"zod\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { detectAvailableClients, selectChatClient } from \"../../coding-agents/chat-utils.js\";\nimport { jsonResult, runTool, type McpToolDefinition } from \"./shared.js\";\n\nconst inputSchema = {};\n\nexport type ChatStatusArgs = z.infer<z.ZodObject<typeof inputSchema>>;\n\nexport async function chatStatusHandler(_args: ChatStatusArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const availableClients = await detectAvailableClients();\n const selected = selectChatClient(availableClients);\n\n return jsonResult({\n available: availableClients.map((client) => client.getClientName()),\n selected: selected ? selected.getClientName() : null,\n sdk_available: availableClients.length > 0,\n sdk_version: selected ? selected.getClientName() : null,\n error_message:\n availableClients.length === 0\n ? \"No chat client available. Install Claude Code or GitHub Copilot.\"\n : null,\n });\n });\n}\n\nexport const chatStatusTool: McpToolDefinition<typeof inputSchema> = {\n name: \"chat_status\",\n description: \"Report which AI coding agents (Claude Code, GitHub Copilot) are installed and available.\",\n inputSchema,\n handler: chatStatusHandler,\n};\n"],
|
|
5
|
+
"mappings": "AAQA,SAAS,wBAAwB,wBAAwB;AACzD,SAAS,YAAY,eAAuC;AAE5D,MAAM,cAAc,CAAA;AAIpB,eAAsB,kBAAkB,OAAqB;AAC3D,SAAO,QAAQ,YAAW;AACxB,UAAM,mBAAmB,MAAM,uBAAsB,GAC/C,WAAW,iBAAiB,gBAAgB;AAElD,WAAO,WAAW;MAChB,WAAW,iBAAiB,IAAI,CAAC,WAAW,OAAO,cAAa,CAAE;MAClE,UAAU,WAAW,SAAS,cAAa,IAAK;MAChD,eAAe,iBAAiB,SAAS;MACzC,aAAa,WAAW,SAAS,cAAa,IAAK;MACnD,eACE,iBAAiB,WAAW,IACxB,qEACA;KACP;EACH,CAAC;AACH;AAEO,MAAM,iBAAwD;EACnE,MAAM;EACN,aAAa;EACb;EACA,SAAS;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { annotationListTool } from "./annotation-list.js";
|
|
2
|
+
import { annotationGetTool } from "./annotation-get.js";
|
|
3
|
+
import { annotationCreateTool } from "./annotation-create.js";
|
|
4
|
+
import { annotationUpdateTool } from "./annotation-update.js";
|
|
5
|
+
import { annotationDeleteTool } from "./annotation-delete.js";
|
|
6
|
+
import { annotationReplyTool } from "./annotation-reply.js";
|
|
7
|
+
import { modelListTool } from "./model-list.js";
|
|
8
|
+
import { modelShowTool } from "./model-show.js";
|
|
9
|
+
import { modelSearchTool } from "./model-search.js";
|
|
10
|
+
import { modelStatsTool } from "./model-stats.js";
|
|
11
|
+
import { modelInfoTool } from "./model-info.js";
|
|
12
|
+
import { modelTraceTool } from "./model-trace.js";
|
|
13
|
+
import { modelAddTool } from "./model-add.js";
|
|
14
|
+
import { modelUpdateTool } from "./model-update.js";
|
|
15
|
+
import { modelDeleteTool } from "./model-delete.js";
|
|
16
|
+
import { modelValidateTool } from "./model-validate.js";
|
|
17
|
+
import { modelExportTool } from "./model-export.js";
|
|
18
|
+
import { modelReloadTool } from "./model-reload.js";
|
|
19
|
+
import { changesetListTool } from "./changeset-list.js";
|
|
20
|
+
import { changesetShowTool } from "./changeset-show.js";
|
|
21
|
+
import { changesetCreateTool, changesetActivateTool, changesetDeactivateTool } from "./changeset-lifecycle.js";
|
|
22
|
+
import { changesetImpactTool, changesetBriefTool } from "./changeset-analysis-tools.js";
|
|
23
|
+
import { relationshipAddTool, relationshipDeleteTool } from "./relationship-tools.js";
|
|
24
|
+
import { specTypeTool } from "./spec-type.js";
|
|
25
|
+
import { chatStatusTool } from "./chat-status.js";
|
|
26
|
+
import { chatLaunchTool } from "./chat-launch.js";
|
|
27
|
+
import { changesetVerifyTool } from "./changeset-verify.js";
|
|
28
|
+
import { changesetUpdateTool, changesetUnstageTool, changesetDiscardTool } from "./changeset-editing.js";
|
|
29
|
+
export {
|
|
30
|
+
annotationCreateTool,
|
|
31
|
+
annotationDeleteTool,
|
|
32
|
+
annotationGetTool,
|
|
33
|
+
annotationListTool,
|
|
34
|
+
annotationReplyTool,
|
|
35
|
+
annotationUpdateTool,
|
|
36
|
+
changesetActivateTool,
|
|
37
|
+
changesetBriefTool,
|
|
38
|
+
changesetCreateTool,
|
|
39
|
+
changesetDeactivateTool,
|
|
40
|
+
changesetDiscardTool,
|
|
41
|
+
changesetImpactTool,
|
|
42
|
+
changesetListTool,
|
|
43
|
+
changesetShowTool,
|
|
44
|
+
changesetUnstageTool,
|
|
45
|
+
changesetUpdateTool,
|
|
46
|
+
changesetVerifyTool,
|
|
47
|
+
chatLaunchTool,
|
|
48
|
+
chatStatusTool,
|
|
49
|
+
modelAddTool,
|
|
50
|
+
modelDeleteTool,
|
|
51
|
+
modelExportTool,
|
|
52
|
+
modelInfoTool,
|
|
53
|
+
modelListTool,
|
|
54
|
+
modelReloadTool,
|
|
55
|
+
modelSearchTool,
|
|
56
|
+
modelShowTool,
|
|
57
|
+
modelStatsTool,
|
|
58
|
+
modelTraceTool,
|
|
59
|
+
modelUpdateTool,
|
|
60
|
+
modelValidateTool,
|
|
61
|
+
relationshipAddTool,
|
|
62
|
+
relationshipDeleteTool,
|
|
63
|
+
specTypeTool
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { annotationListTool } from \"./annotation-list.js\";\nexport { annotationGetTool } from \"./annotation-get.js\";\nexport { annotationCreateTool } from \"./annotation-create.js\";\nexport { annotationUpdateTool } from \"./annotation-update.js\";\nexport { annotationDeleteTool } from \"./annotation-delete.js\";\nexport { annotationReplyTool } from \"./annotation-reply.js\";\nexport { modelListTool } from \"./model-list.js\";\nexport { modelShowTool } from \"./model-show.js\";\nexport { modelSearchTool } from \"./model-search.js\";\nexport { modelStatsTool } from \"./model-stats.js\";\nexport { modelInfoTool } from \"./model-info.js\";\nexport { modelTraceTool } from \"./model-trace.js\";\nexport { modelAddTool } from \"./model-add.js\";\nexport { modelUpdateTool } from \"./model-update.js\";\nexport { modelDeleteTool } from \"./model-delete.js\";\nexport { modelValidateTool } from \"./model-validate.js\";\nexport { modelExportTool } from \"./model-export.js\";\nexport { modelReloadTool } from \"./model-reload.js\";\nexport { changesetListTool } from \"./changeset-list.js\";\nexport { changesetShowTool } from \"./changeset-show.js\";\nexport { changesetCreateTool, changesetActivateTool, changesetDeactivateTool } from \"./changeset-lifecycle.js\";\nexport { changesetImpactTool, changesetBriefTool } from \"./changeset-analysis-tools.js\";\nexport { relationshipAddTool, relationshipDeleteTool } from \"./relationship-tools.js\";\nexport { specTypeTool } from \"./spec-type.js\";\nexport { chatStatusTool } from \"./chat-status.js\";\nexport { chatLaunchTool } from \"./chat-launch.js\";\nexport { changesetVerifyTool } from \"./changeset-verify.js\";\nexport type { McpToolDefinition } from \"./shared.js\";\nexport { changesetUpdateTool, changesetUnstageTool, changesetDiscardTool } from \"./changeset-editing.js\";\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,qBAAqB,uBAAuB,+BAA+B;AACpF,SAAS,qBAAqB,0BAA0B;AACxD,SAAS,qBAAqB,8BAA8B;AAC5D,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AAEpC,SAAS,qBAAqB,sBAAsB,4BAA4B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|