@documentation-robotics/cli 0.1.13 → 0.2.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 +38 -0
- package/dist/analyzers/verify-engine.js +22 -19
- package/dist/analyzers/verify-engine.js.map +2 -2
- package/dist/cli.js +101 -27
- 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 +122 -0
- package/dist/coding-agents/default-permissions.js.map +7 -0
- package/dist/commands/add.js +10 -6
- package/dist/commands/add.js.map +2 -2
- package/dist/commands/analyzer.js +18 -10
- 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.js +238 -145
- package/dist/commands/changeset.js.map +2 -2
- package/dist/commands/delete.js +45 -18
- 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 +657 -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 +107 -0
- package/dist/commands/mcp.js.map +7 -0
- package/dist/commands/relationship.js +53 -30
- 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 +19 -6
- package/dist/commands/update.js.map +2 -2
- 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/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/farm-manifest.js +134 -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 +159 -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 +55 -1
- package/dist/core/migration-registry.js.map +2 -2
- package/dist/core/model.js +177 -16
- package/dist/core/model.js.map +3 -3
- package/dist/core/virtual-projection.js +1 -0
- package/dist/core/virtual-projection.js.map +2 -2
- package/dist/generated/node-types.js +1 -1
- package/dist/generated/node-types.js.map +2 -2
- package/dist/generated/relationship-index.js +45 -9
- package/dist/generated/relationship-index.js.map +2 -2
- package/dist/integrations/claude_code/docs/MCP_SERVER.md +55 -0
- package/dist/integrations/claude_code/docs/README.md +4 -0
- package/dist/mcp/api-key-manager.js +98 -0
- package/dist/mcp/api-key-manager.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 +44 -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-list.js +33 -0
- package/dist/mcp/tools/changeset-list.js.map +7 -0
- package/dist/mcp/tools/changeset-show.js +39 -0
- package/dist/mcp/tools/changeset-show.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 +47 -0
- package/dist/mcp/tools/index.js.map +7 -0
- package/dist/mcp/tools/model-add.js +106 -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 +88 -0
- package/dist/mcp/tools/model-search.js.map +7 -0
- package/dist/mcp/tools/model-show.js +41 -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 +55 -0
- package/dist/mcp/tools/model-trace.js.map +7 -0
- package/dist/mcp/tools/model-update.js +105 -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/shared.js +103 -0
- package/dist/mcp/tools/shared.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 +2 -2
- package/dist/schemas/bundled/analyzers/manifest.json +2 -2
- package/dist/schemas/bundled/api.json +1 -1
- package/dist/schemas/bundled/apm.json +1 -1
- package/dist/schemas/bundled/application.json +12 -1
- package/dist/schemas/bundled/base.json +1 -1
- package/dist/schemas/bundled/business.json +1 -1
- package/dist/schemas/bundled/data-model.json +38 -2
- package/dist/schemas/bundled/data-store.json +1 -1
- package/dist/schemas/bundled/manifest.json +4 -4
- package/dist/schemas/bundled/motivation.json +1 -1
- package/dist/schemas/bundled/navigation.json +1 -1
- package/dist/schemas/bundled/product.json +1 -1
- package/dist/schemas/bundled/security.json +1 -1
- package/dist/schemas/bundled/technology.json +1 -1
- package/dist/schemas/bundled/testing.json +1 -1
- package/dist/schemas/bundled/ux.json +1 -1
- package/dist/server/server.js +22 -3
- package/dist/server/server.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 +25 -0
- package/dist/utils/ansi-suppressor.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/errors.js +69 -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 +24 -2
- 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 +5 -0
- 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 +262 -0
- package/dist/validators/composed-reference-validator.js.map +7 -0
- package/dist/validators/reference-validator.js +59 -8
- package/dist/validators/reference-validator.js.map +3 -3
- package/dist/validators/relationship-schema-validator.js +30 -2
- package/dist/validators/relationship-schema-validator.js.map +3 -3
- package/package.json +6 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AnnotationStore } from "../../core/annotation-store.js";
|
|
2
|
+
import { CLIError, ErrorCategory } from "../../utils/errors.js";
|
|
3
|
+
import { annotationIdSchema } from "./annotation-shared.js";
|
|
4
|
+
import { jsonResult, loadModel, rootPathSchema, runTool } from "./shared.js";
|
|
5
|
+
const inputSchema = {
|
|
6
|
+
annotationId: annotationIdSchema,
|
|
7
|
+
rootPath: rootPathSchema
|
|
8
|
+
};
|
|
9
|
+
async function annotationDeleteHandler(args) {
|
|
10
|
+
return runTool(async () => {
|
|
11
|
+
const model = await loadModel(args.rootPath);
|
|
12
|
+
if (!await new AnnotationStore(model.rootPath).delete(args.annotationId))
|
|
13
|
+
throw new CLIError(`Annotation ${args.annotationId} not found`, ErrorCategory.NOT_FOUND, [
|
|
14
|
+
'Use "annotation_list" to find existing annotations'
|
|
15
|
+
]);
|
|
16
|
+
return jsonResult({ status: "deleted", annotationId: args.annotationId });
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const annotationDeleteTool = {
|
|
20
|
+
name: "annotation_delete",
|
|
21
|
+
description: "Delete an annotation and its replies.",
|
|
22
|
+
inputSchema,
|
|
23
|
+
handler: annotationDeleteHandler
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
annotationDeleteHandler,
|
|
27
|
+
annotationDeleteTool
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=annotation-delete.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/annotation-delete.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * annotation_delete \u2014 delete an annotation and its replies. Mirrors\n * `DELETE /api/annotations/:annotationId` on the REST server.\n */\n\nimport type { z } from \"zod\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { AnnotationStore } from \"../../core/annotation-store.js\";\nimport { CLIError, ErrorCategory } from \"../../utils/errors.js\";\nimport { annotationIdSchema } from \"./annotation-shared.js\";\nimport { jsonResult, loadModel, rootPathSchema, runTool, type McpToolDefinition } from \"./shared.js\";\n\nconst inputSchema = {\n annotationId: annotationIdSchema,\n rootPath: rootPathSchema,\n};\n\nexport type AnnotationDeleteArgs = z.infer<z.ZodObject<typeof inputSchema>>;\n\nexport async function annotationDeleteHandler(args: AnnotationDeleteArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const model = await loadModel(args.rootPath);\n const store = new AnnotationStore(model.rootPath);\n const deleted = await store.delete(args.annotationId);\n\n if (!deleted) {\n throw new CLIError(`Annotation ${args.annotationId} not found`, ErrorCategory.NOT_FOUND, [\n 'Use \"annotation_list\" to find existing annotations',\n ]);\n }\n\n return jsonResult({ status: \"deleted\", annotationId: args.annotationId });\n });\n}\n\nexport const annotationDeleteTool: McpToolDefinition<typeof inputSchema> = {\n name: \"annotation_delete\",\n description: \"Delete an annotation and its replies.\",\n inputSchema,\n handler: annotationDeleteHandler,\n};\n"],
|
|
5
|
+
"mappings": "AAOA,SAAS,uBAAuB;AAChC,SAAS,UAAU,qBAAqB;AACxC,SAAS,0BAA0B;AACnC,SAAS,YAAY,WAAW,gBAAgB,eAAuC;AAEvF,MAAM,cAAc;EAClB,cAAc;EACd,UAAU;;AAKZ,eAAsB,wBAAwB,MAA0B;AACtE,SAAO,QAAQ,YAAW;AACxB,UAAM,QAAQ,MAAM,UAAU,KAAK,QAAQ;AAI3C,QAAI,CAFY,MADF,IAAI,gBAAgB,MAAM,QAAQ,EACpB,OAAO,KAAK,YAAY;AAGlD,YAAM,IAAI,SAAS,cAAc,KAAK,YAAY,cAAc,cAAc,WAAW;QACvF;OACD;AAGH,WAAO,WAAW,EAAE,QAAQ,WAAW,cAAc,KAAK,aAAY,CAAE;EAC1E,CAAC;AACH;AAEO,MAAM,uBAA8D;EACzE,MAAM;EACN,aAAa;EACb;EACA,SAAS;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AnnotationStore } from "../../core/annotation-store.js";
|
|
2
|
+
import { CLIError, ErrorCategory } from "../../utils/errors.js";
|
|
3
|
+
import { annotationIdSchema } from "./annotation-shared.js";
|
|
4
|
+
import { jsonResult, loadModel, rootPathSchema, runTool } from "./shared.js";
|
|
5
|
+
const inputSchema = {
|
|
6
|
+
annotationId: annotationIdSchema,
|
|
7
|
+
rootPath: rootPathSchema
|
|
8
|
+
};
|
|
9
|
+
async function annotationGetHandler(args) {
|
|
10
|
+
return runTool(async () => {
|
|
11
|
+
const model = await loadModel(args.rootPath), annotation = await new AnnotationStore(model.rootPath).get(args.annotationId);
|
|
12
|
+
if (!annotation)
|
|
13
|
+
throw new CLIError(`Annotation ${args.annotationId} not found`, ErrorCategory.NOT_FOUND, [
|
|
14
|
+
'Use "annotation_list" to find existing annotations'
|
|
15
|
+
]);
|
|
16
|
+
return jsonResult(annotation);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const annotationGetTool = {
|
|
20
|
+
name: "annotation_get",
|
|
21
|
+
description: "Get a single annotation by ID, including its replies.",
|
|
22
|
+
inputSchema,
|
|
23
|
+
handler: annotationGetHandler
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
annotationGetHandler,
|
|
27
|
+
annotationGetTool
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=annotation-get.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/annotation-get.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * annotation_get \u2014 retrieve a single annotation (with its replies) by ID.\n * Mirrors `GET /api/annotations/:annotationId` on the REST server.\n */\n\nimport type { z } from \"zod\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { AnnotationStore } from \"../../core/annotation-store.js\";\nimport { CLIError, ErrorCategory } from \"../../utils/errors.js\";\nimport { annotationIdSchema } from \"./annotation-shared.js\";\nimport { jsonResult, loadModel, rootPathSchema, runTool, type McpToolDefinition } from \"./shared.js\";\n\nconst inputSchema = {\n annotationId: annotationIdSchema,\n rootPath: rootPathSchema,\n};\n\nexport type AnnotationGetArgs = z.infer<z.ZodObject<typeof inputSchema>>;\n\nexport async function annotationGetHandler(args: AnnotationGetArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const model = await loadModel(args.rootPath);\n const store = new AnnotationStore(model.rootPath);\n const annotation = await store.get(args.annotationId);\n if (!annotation) {\n throw new CLIError(`Annotation ${args.annotationId} not found`, ErrorCategory.NOT_FOUND, [\n 'Use \"annotation_list\" to find existing annotations',\n ]);\n }\n return jsonResult(annotation);\n });\n}\n\nexport const annotationGetTool: McpToolDefinition<typeof inputSchema> = {\n name: \"annotation_get\",\n description: \"Get a single annotation by ID, including its replies.\",\n inputSchema,\n handler: annotationGetHandler,\n};\n"],
|
|
5
|
+
"mappings": "AAOA,SAAS,uBAAuB;AAChC,SAAS,UAAU,qBAAqB;AACxC,SAAS,0BAA0B;AACnC,SAAS,YAAY,WAAW,gBAAgB,eAAuC;AAEvF,MAAM,cAAc;EAClB,cAAc;EACd,UAAU;;AAKZ,eAAsB,qBAAqB,MAAuB;AAChE,SAAO,QAAQ,YAAW;AACxB,UAAM,QAAQ,MAAM,UAAU,KAAK,QAAQ,GAErC,aAAa,MADL,IAAI,gBAAgB,MAAM,QAAQ,EACjB,IAAI,KAAK,YAAY;AACpD,QAAI,CAAC;AACH,YAAM,IAAI,SAAS,cAAc,KAAK,YAAY,cAAc,cAAc,WAAW;QACvF;OACD;AAEH,WAAO,WAAW,UAAU;EAC9B,CAAC;AACH;AAEO,MAAM,oBAA2D;EACtE,MAAM;EACN,aAAa;EACb;EACA,SAAS;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AnnotationStore } from "../../core/annotation-store.js";
|
|
2
|
+
import { elementIdSchema } from "./annotation-shared.js";
|
|
3
|
+
import { jsonResult, loadModel, rootPathSchema, runTool } from "./shared.js";
|
|
4
|
+
const inputSchema = {
|
|
5
|
+
elementId: elementIdSchema.optional().describe("If provided, only return annotations on this element."),
|
|
6
|
+
rootPath: rootPathSchema
|
|
7
|
+
};
|
|
8
|
+
async function annotationListHandler(args) {
|
|
9
|
+
return runTool(async () => {
|
|
10
|
+
const model = await loadModel(args.rootPath), annotations = await new AnnotationStore(model.rootPath).list(args.elementId);
|
|
11
|
+
return jsonResult({ annotations });
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
const annotationListTool = {
|
|
15
|
+
name: "annotation_list",
|
|
16
|
+
description: "List annotations on model elements, optionally filtered to a single element.",
|
|
17
|
+
inputSchema,
|
|
18
|
+
handler: annotationListHandler
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
annotationListHandler,
|
|
22
|
+
annotationListTool
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=annotation-list.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/annotation-list.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * annotation_list \u2014 list annotations, optionally filtered to a single\n * element. Mirrors `GET /api/annotations` on the REST server.\n */\n\nimport type { z } from \"zod\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { AnnotationStore } from \"../../core/annotation-store.js\";\nimport { elementIdSchema } from \"./annotation-shared.js\";\nimport { jsonResult, loadModel, rootPathSchema, runTool, type McpToolDefinition } from \"./shared.js\";\n\nconst inputSchema = {\n elementId: elementIdSchema.optional().describe(\"If provided, only return annotations on this element.\"),\n rootPath: rootPathSchema,\n};\n\nexport type AnnotationListArgs = z.infer<z.ZodObject<typeof inputSchema>>;\n\nexport async function annotationListHandler(args: AnnotationListArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const model = await loadModel(args.rootPath);\n const store = new AnnotationStore(model.rootPath);\n const annotations = await store.list(args.elementId);\n return jsonResult({ annotations });\n });\n}\n\nexport const annotationListTool: McpToolDefinition<typeof inputSchema> = {\n name: \"annotation_list\",\n description: \"List annotations on model elements, optionally filtered to a single element.\",\n inputSchema,\n handler: annotationListHandler,\n};\n"],
|
|
5
|
+
"mappings": "AAOA,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,YAAY,WAAW,gBAAgB,eAAuC;AAEvF,MAAM,cAAc;EAClB,WAAW,gBAAgB,SAAQ,EAAG,SAAS,uDAAuD;EACtG,UAAU;;AAKZ,eAAsB,sBAAsB,MAAwB;AAClE,SAAO,QAAQ,YAAW;AACxB,UAAM,QAAQ,MAAM,UAAU,KAAK,QAAQ,GAErC,cAAc,MADN,IAAI,gBAAgB,MAAM,QAAQ,EAChB,KAAK,KAAK,SAAS;AACnD,WAAO,WAAW,EAAE,YAAW,CAAE;EACnC,CAAC;AACH;AAEO,MAAM,qBAA4D;EACvE,MAAM;EACN,aAAa;EACb;EACA,SAAS;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AnnotationStore } from "../../core/annotation-store.js";
|
|
2
|
+
import { CLIError, ErrorCategory } from "../../utils/errors.js";
|
|
3
|
+
import { annotationAuthorSchema, annotationContentSchema, annotationIdSchema } from "./annotation-shared.js";
|
|
4
|
+
import { jsonResult, loadModel, rootPathSchema, runTool } from "./shared.js";
|
|
5
|
+
const inputSchema = {
|
|
6
|
+
annotationId: annotationIdSchema,
|
|
7
|
+
content: annotationContentSchema,
|
|
8
|
+
author: annotationAuthorSchema,
|
|
9
|
+
rootPath: rootPathSchema
|
|
10
|
+
};
|
|
11
|
+
async function annotationReplyHandler(args) {
|
|
12
|
+
return runTool(async () => {
|
|
13
|
+
const model = await loadModel(args.rootPath), reply = await new AnnotationStore(model.rootPath).addReply(args.annotationId, {
|
|
14
|
+
author: args.author?.trim() || "Anonymous",
|
|
15
|
+
content: args.content
|
|
16
|
+
});
|
|
17
|
+
if (!reply)
|
|
18
|
+
throw new CLIError(`Annotation ${args.annotationId} not found`, ErrorCategory.NOT_FOUND, [
|
|
19
|
+
'Use "annotation_list" to find existing annotations'
|
|
20
|
+
]);
|
|
21
|
+
return jsonResult(reply);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const annotationReplyTool = {
|
|
25
|
+
name: "annotation_reply",
|
|
26
|
+
description: "Add a reply to an existing annotation.",
|
|
27
|
+
inputSchema,
|
|
28
|
+
handler: annotationReplyHandler
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
annotationReplyHandler,
|
|
32
|
+
annotationReplyTool
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=annotation-reply.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/annotation-reply.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * annotation_reply \u2014 add a reply to an annotation. Mirrors\n * `POST /api/annotations/:annotationId/replies` on the REST server.\n */\n\nimport type { z } from \"zod\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { AnnotationStore } from \"../../core/annotation-store.js\";\nimport { CLIError, ErrorCategory } from \"../../utils/errors.js\";\nimport { annotationAuthorSchema, annotationContentSchema, annotationIdSchema } from \"./annotation-shared.js\";\nimport { jsonResult, loadModel, rootPathSchema, runTool, type McpToolDefinition } from \"./shared.js\";\n\nconst inputSchema = {\n annotationId: annotationIdSchema,\n content: annotationContentSchema,\n author: annotationAuthorSchema,\n rootPath: rootPathSchema,\n};\n\nexport type AnnotationReplyArgs = z.infer<z.ZodObject<typeof inputSchema>>;\n\nexport async function annotationReplyHandler(args: AnnotationReplyArgs): Promise<CallToolResult> {\n return runTool(async () => {\n const model = await loadModel(args.rootPath);\n const store = new AnnotationStore(model.rootPath);\n const reply = await store.addReply(args.annotationId, {\n author: args.author?.trim() || \"Anonymous\",\n content: args.content,\n });\n\n if (!reply) {\n throw new CLIError(`Annotation ${args.annotationId} not found`, ErrorCategory.NOT_FOUND, [\n 'Use \"annotation_list\" to find existing annotations',\n ]);\n }\n\n return jsonResult(reply);\n });\n}\n\nexport const annotationReplyTool: McpToolDefinition<typeof inputSchema> = {\n name: \"annotation_reply\",\n description: \"Add a reply to an existing annotation.\",\n inputSchema,\n handler: annotationReplyHandler,\n};\n"],
|
|
5
|
+
"mappings": "AAOA,SAAS,uBAAuB;AAChC,SAAS,UAAU,qBAAqB;AACxC,SAAS,wBAAwB,yBAAyB,0BAA0B;AACpF,SAAS,YAAY,WAAW,gBAAgB,eAAuC;AAEvF,MAAM,cAAc;EAClB,cAAc;EACd,SAAS;EACT,QAAQ;EACR,UAAU;;AAKZ,eAAsB,uBAAuB,MAAyB;AACpE,SAAO,QAAQ,YAAW;AACxB,UAAM,QAAQ,MAAM,UAAU,KAAK,QAAQ,GAErC,QAAQ,MADA,IAAI,gBAAgB,MAAM,QAAQ,EACtB,SAAS,KAAK,cAAc;MACpD,QAAQ,KAAK,QAAQ,KAAI,KAAM;MAC/B,SAAS,KAAK;KACf;AAED,QAAI,CAAC;AACH,YAAM,IAAI,SAAS,cAAc,KAAK,YAAY,cAAc,cAAc,WAAW;QACvF;OACD;AAGH,WAAO,WAAW,KAAK;EACzB,CAAC;AACH;AAEO,MAAM,sBAA6D;EACxE,MAAM;EACN,aAAa;EACb;EACA,SAAS;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const annotationIdSchema = z.string().min(1).describe("Annotation ID (e.g. 'ann-1700000000000-a1b2c3d4')."), elementIdSchema = z.string().min(1).describe("Target element ID (e.g. 'api.operation.create-order')."), annotationContentSchema = z.string().min(1, "Content is required").max(5e3, "Content too long (max 5000 characters)"), annotationAuthorSchema = z.string().max(100, "Author name too long (max 100 characters)").optional().describe("Author name. Defaults to 'Anonymous'."), annotationTagsSchema = z.array(z.string()).optional().describe("Tags to attach to the annotation.");
|
|
3
|
+
export {
|
|
4
|
+
annotationAuthorSchema,
|
|
5
|
+
annotationContentSchema,
|
|
6
|
+
annotationIdSchema,
|
|
7
|
+
annotationTagsSchema,
|
|
8
|
+
elementIdSchema
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=annotation-shared.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/annotation-shared.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Shared input field schemas for the annotation_* MCP tools.\n */\n\nimport { z } from \"zod\";\n\nexport const annotationIdSchema = z.string().min(1).describe(\"Annotation ID (e.g. 'ann-1700000000000-a1b2c3d4').\");\n\nexport const elementIdSchema = z\n .string()\n .min(1)\n .describe(\"Target element ID (e.g. 'api.operation.create-order').\");\n\nexport const annotationContentSchema = z\n .string()\n .min(1, \"Content is required\")\n .max(5000, \"Content too long (max 5000 characters)\");\n\nexport const annotationAuthorSchema = z\n .string()\n .max(100, \"Author name too long (max 100 characters)\")\n .optional()\n .describe(\"Author name. Defaults to 'Anonymous'.\");\n\nexport const annotationTagsSchema = z\n .array(z.string())\n .optional()\n .describe(\"Tags to attach to the annotation.\");\n"],
|
|
5
|
+
"mappings": "AAIA,SAAS,SAAS;AAEX,MAAM,qBAAqB,EAAE,OAAM,EAAG,IAAI,CAAC,EAAE,SAAS,oDAAoD,GAEpG,kBAAkB,EAC5B,OAAM,EACN,IAAI,CAAC,EACL,SAAS,wDAAwD,GAEvD,0BAA0B,EACpC,OAAM,EACN,IAAI,GAAG,qBAAqB,EAC5B,IAAI,KAAM,wCAAwC,GAExC,yBAAyB,EACnC,OAAM,EACN,IAAI,KAAK,2CAA2C,EACpD,SAAQ,EACR,SAAS,uCAAuC,GAEtC,uBAAuB,EACjC,MAAM,EAAE,OAAM,CAAE,EAChB,SAAQ,EACR,SAAS,mCAAmC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AnnotationStore } from "../../core/annotation-store.js";
|
|
3
|
+
import { CLIError, ErrorCategory } from "../../utils/errors.js";
|
|
4
|
+
import { annotationContentSchema, annotationIdSchema, annotationTagsSchema } from "./annotation-shared.js";
|
|
5
|
+
import { jsonResult, loadModel, rootPathSchema, runTool } from "./shared.js";
|
|
6
|
+
const inputSchema = {
|
|
7
|
+
annotationId: annotationIdSchema,
|
|
8
|
+
content: annotationContentSchema.optional(),
|
|
9
|
+
tags: annotationTagsSchema,
|
|
10
|
+
resolved: z.boolean().optional().describe("Mark the annotation resolved or unresolved."),
|
|
11
|
+
rootPath: rootPathSchema
|
|
12
|
+
};
|
|
13
|
+
async function annotationUpdateHandler(args) {
|
|
14
|
+
return runTool(async () => {
|
|
15
|
+
if (args.content === void 0 && args.tags === void 0 && args.resolved === void 0)
|
|
16
|
+
throw new CLIError("At least one of content, tags, or resolved must be provided", ErrorCategory.USER);
|
|
17
|
+
const model = await loadModel(args.rootPath), updated = await new AnnotationStore(model.rootPath).update(args.annotationId, {
|
|
18
|
+
content: args.content,
|
|
19
|
+
tags: args.tags,
|
|
20
|
+
resolved: args.resolved
|
|
21
|
+
});
|
|
22
|
+
if (!updated)
|
|
23
|
+
throw new CLIError(`Annotation ${args.annotationId} not found`, ErrorCategory.NOT_FOUND, [
|
|
24
|
+
'Use "annotation_list" to find existing annotations'
|
|
25
|
+
]);
|
|
26
|
+
return jsonResult(updated);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const annotationUpdateTool = {
|
|
30
|
+
name: "annotation_update",
|
|
31
|
+
description: "Partially update an annotation's content, tags, or resolved state.",
|
|
32
|
+
inputSchema,
|
|
33
|
+
handler: annotationUpdateHandler
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
annotationUpdateHandler,
|
|
37
|
+
annotationUpdateTool
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=annotation-update.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/mcp/tools/annotation-update.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * annotation_update \u2014 partially update an annotation's content, tags, or\n * resolved state. Mirrors `PATCH /api/annotations/:annotationId` (and the\n * REST server's equivalently-partial `PUT`) on the REST server.\n */\n\nimport { z } from \"zod\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { AnnotationStore } from \"../../core/annotation-store.js\";\nimport { CLIError, ErrorCategory } from \"../../utils/errors.js\";\nimport { annotationContentSchema, annotationIdSchema, annotationTagsSchema } from \"./annotation-shared.js\";\nimport { jsonResult, loadModel, rootPathSchema, runTool, type McpToolDefinition } from \"./shared.js\";\n\nconst inputSchema = {\n annotationId: annotationIdSchema,\n content: annotationContentSchema.optional(),\n tags: annotationTagsSchema,\n resolved: z.boolean().optional().describe(\"Mark the annotation resolved or unresolved.\"),\n rootPath: rootPathSchema,\n};\n\nexport type AnnotationUpdateArgs = z.infer<z.ZodObject<typeof inputSchema>>;\n\nexport async function annotationUpdateHandler(args: AnnotationUpdateArgs): Promise<CallToolResult> {\n return runTool(async () => {\n if (args.content === undefined && args.tags === undefined && args.resolved === undefined) {\n throw new CLIError(\"At least one of content, tags, or resolved must be provided\", ErrorCategory.USER);\n }\n\n const model = await loadModel(args.rootPath);\n const store = new AnnotationStore(model.rootPath);\n const updated = await store.update(args.annotationId, {\n content: args.content,\n tags: args.tags,\n resolved: args.resolved,\n });\n\n if (!updated) {\n throw new CLIError(`Annotation ${args.annotationId} not found`, ErrorCategory.NOT_FOUND, [\n 'Use \"annotation_list\" to find existing annotations',\n ]);\n }\n\n return jsonResult(updated);\n });\n}\n\nexport const annotationUpdateTool: McpToolDefinition<typeof inputSchema> = {\n name: \"annotation_update\",\n description: \"Partially update an annotation's content, tags, or resolved state.\",\n inputSchema,\n handler: annotationUpdateHandler,\n};\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,SAAS;AAElB,SAAS,uBAAuB;AAChC,SAAS,UAAU,qBAAqB;AACxC,SAAS,yBAAyB,oBAAoB,4BAA4B;AAClF,SAAS,YAAY,WAAW,gBAAgB,eAAuC;AAEvF,MAAM,cAAc;EAClB,cAAc;EACd,SAAS,wBAAwB,SAAQ;EACzC,MAAM;EACN,UAAU,EAAE,QAAO,EAAG,SAAQ,EAAG,SAAS,6CAA6C;EACvF,UAAU;;AAKZ,eAAsB,wBAAwB,MAA0B;AACtE,SAAO,QAAQ,YAAW;AACxB,QAAI,KAAK,YAAY,UAAa,KAAK,SAAS,UAAa,KAAK,aAAa;AAC7E,YAAM,IAAI,SAAS,+DAA+D,cAAc,IAAI;AAGtG,UAAM,QAAQ,MAAM,UAAU,KAAK,QAAQ,GAErC,UAAU,MADF,IAAI,gBAAgB,MAAM,QAAQ,EACpB,OAAO,KAAK,cAAc;MACpD,SAAS,KAAK;MACd,MAAM,KAAK;MACX,UAAU,KAAK;KAChB;AAED,QAAI,CAAC;AACH,YAAM,IAAI,SAAS,cAAc,KAAK,YAAY,cAAc,cAAc,WAAW;QACvF;OACD;AAGH,WAAO,WAAW,OAAO;EAC3B,CAAC;AACH;AAEO,MAAM,uBAA8D;EACzE,MAAM;EACN,aAAa;EACb;EACA,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,39 @@
|
|
|
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, rootPathSchema, runTool } from "./shared.js";
|
|
5
|
+
const inputSchema = {
|
|
6
|
+
changesetId: z.string().describe("Changeset ID or name."),
|
|
7
|
+
rootPath: rootPathSchema
|
|
8
|
+
};
|
|
9
|
+
async function changesetShowHandler(args) {
|
|
10
|
+
return runTool(async () => {
|
|
11
|
+
const model = await loadModel(args.rootPath), changeset = await new StagingAreaManager(model.rootPath, model).load(args.changesetId);
|
|
12
|
+
if (!changeset)
|
|
13
|
+
throw new CLIError(`Changeset ${args.changesetId} not found`, ErrorCategory.NOT_FOUND, [
|
|
14
|
+
'Use "changeset_list" to see all available changesets'
|
|
15
|
+
]);
|
|
16
|
+
return jsonResult({
|
|
17
|
+
id: changeset.id,
|
|
18
|
+
name: changeset.name,
|
|
19
|
+
description: changeset.description,
|
|
20
|
+
status: changeset.status,
|
|
21
|
+
created: changeset.created,
|
|
22
|
+
modified: changeset.modified,
|
|
23
|
+
baseSnapshot: changeset.baseSnapshot,
|
|
24
|
+
stats: changeset.stats,
|
|
25
|
+
changes: changeset.changes
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const changesetShowTool = {
|
|
30
|
+
name: "changeset_show",
|
|
31
|
+
description: "Show a single changeset's full detail including its description, stats, and list of changes.",
|
|
32
|
+
inputSchema,
|
|
33
|
+
handler: changesetShowHandler
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
changesetShowHandler,
|
|
37
|
+
changesetShowTool
|
|
38
|
+
};
|
|
39
|
+
//# 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 { 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 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 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: \"Show a single changeset's full detail including its description, stats, and list of changes.\",\n inputSchema,\n handler: changesetShowHandler,\n};\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,SAAS;AAElB,SAAS,0BAA0B;AACnC,SAAS,UAAU,qBAAqB;AACxC,SAAS,YAAY,WAAW,gBAAgB,eAAuC;AAEvF,MAAM,cAAc;EAClB,aAAa,EAAE,OAAM,EAAG,SAAS,uBAAuB;EACxD,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,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,aAAa;EACb;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,47 @@
|
|
|
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 { chatStatusTool } from "./chat-status.js";
|
|
22
|
+
import { chatLaunchTool } from "./chat-launch.js";
|
|
23
|
+
export {
|
|
24
|
+
annotationCreateTool,
|
|
25
|
+
annotationDeleteTool,
|
|
26
|
+
annotationGetTool,
|
|
27
|
+
annotationListTool,
|
|
28
|
+
annotationReplyTool,
|
|
29
|
+
annotationUpdateTool,
|
|
30
|
+
changesetListTool,
|
|
31
|
+
changesetShowTool,
|
|
32
|
+
chatLaunchTool,
|
|
33
|
+
chatStatusTool,
|
|
34
|
+
modelAddTool,
|
|
35
|
+
modelDeleteTool,
|
|
36
|
+
modelExportTool,
|
|
37
|
+
modelInfoTool,
|
|
38
|
+
modelListTool,
|
|
39
|
+
modelReloadTool,
|
|
40
|
+
modelSearchTool,
|
|
41
|
+
modelShowTool,
|
|
42
|
+
modelStatsTool,
|
|
43
|
+
modelTraceTool,
|
|
44
|
+
modelUpdateTool,
|
|
45
|
+
modelValidateTool
|
|
46
|
+
};
|
|
47
|
+
//# 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 { chatStatusTool } from \"./chat-status.js\";\nexport { chatLaunchTool } from \"./chat-launch.js\";\nexport type { McpToolDefinition } from \"./shared.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,sBAAsB;AAC/B,SAAS,sBAAsB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Element } from "../../core/element.js";
|
|
3
|
+
import { Layer } from "../../core/layer.js";
|
|
4
|
+
import { MutationHandler } from "../../core/mutation-handler.js";
|
|
5
|
+
import { getAllLayerIds, isValidLayer } from "../../generated/layer-registry.js";
|
|
6
|
+
import { getNodeTypesForLayer, isValidNodeType, normalizeNodeType } from "../../generated/node-types.js";
|
|
7
|
+
import { generateElementId, generateUUID } from "../../utils/id-generator.js";
|
|
8
|
+
import { buildSourceReference, validateSourceReferenceOptions } from "../../utils/source-reference.js";
|
|
9
|
+
import { SchemaValidator } from "../../validators/schema-validator.js";
|
|
10
|
+
import { CLIError, ErrorCategory, findSimilar, formatValidOptions } from "../../utils/errors.js";
|
|
11
|
+
import { jsonResult, loadModel, rootPathSchema, runTool } from "./shared.js";
|
|
12
|
+
const inputSchema = {
|
|
13
|
+
layer: z.string().describe("Canonical layer name (e.g. 'api', 'data-model')."),
|
|
14
|
+
type: z.string().describe("Element type within the layer (e.g. 'operation', 'entity')."),
|
|
15
|
+
name: z.string().describe("Human-readable element name; used to derive the element ID."),
|
|
16
|
+
description: z.string().optional(),
|
|
17
|
+
attributes: z.record(z.string(), z.unknown()).optional().describe("Type-specific attributes, validated against the element's spec schema."),
|
|
18
|
+
sourceFile: z.string().optional().describe("Source file path relative to the repository root."),
|
|
19
|
+
sourceSymbol: z.string().optional(),
|
|
20
|
+
sourceProvenance: z.enum(["extracted", "manual", "inferred", "generated"]).optional(),
|
|
21
|
+
sourceRepoRemote: z.string().optional(),
|
|
22
|
+
sourceRepoCommit: z.string().optional().describe("Full 40-character Git commit SHA."),
|
|
23
|
+
rootPath: rootPathSchema
|
|
24
|
+
};
|
|
25
|
+
async function modelAddHandler(args) {
|
|
26
|
+
return runTool(async () => {
|
|
27
|
+
if (!isValidLayer(args.layer)) {
|
|
28
|
+
const validLayers = getAllLayerIds(), similar = findSimilar(args.layer, validLayers, 3), suggestions = [`Use a valid layer name: ${formatValidOptions(validLayers)}`];
|
|
29
|
+
throw similar.length > 0 && suggestions.unshift(`Did you mean: ${similar.join(" or ")}?`), new CLIError(`Unknown layer "${args.layer}"`, ErrorCategory.USER, suggestions);
|
|
30
|
+
}
|
|
31
|
+
if (!isValidNodeType(args.layer, args.type)) {
|
|
32
|
+
const typeNames = getNodeTypesForLayer(args.layer).map((t) => t.type).sort(), similar = findSimilar(args.type, typeNames, 3), suggestions = [`Valid types for ${args.layer}: ${formatValidOptions(typeNames)}`];
|
|
33
|
+
throw similar.length > 0 && suggestions.unshift(`Did you mean: ${similar.join(" or ")}?`), new CLIError(`Invalid element type "${args.type}" for layer "${args.layer}"`, ErrorCategory.USER, suggestions);
|
|
34
|
+
}
|
|
35
|
+
const resolvedType = normalizeNodeType(args.layer, args.type), elementPath = generateElementId(args.layer, resolvedType, args.name), elementUUID = generateUUID();
|
|
36
|
+
if (!elementPath.split(".")[2])
|
|
37
|
+
throw new CLIError(`Cannot generate a valid element ID from name "${args.name}"`, ErrorCategory.USER, [
|
|
38
|
+
"Element names must contain at least one letter or digit"
|
|
39
|
+
]);
|
|
40
|
+
validateSourceReferenceOptions(args);
|
|
41
|
+
const model = await loadModel(args.rootPath);
|
|
42
|
+
let layerObj = await model.getLayer(args.layer), isNewLayer = !1;
|
|
43
|
+
layerObj || (layerObj = new Layer(args.layer), isNewLayer = !0);
|
|
44
|
+
const now = (/* @__PURE__ */ new Date()).toISOString(), element = new Element({
|
|
45
|
+
id: elementUUID,
|
|
46
|
+
path: elementPath,
|
|
47
|
+
spec_node_id: `${args.layer}.${resolvedType}`,
|
|
48
|
+
layer_id: args.layer,
|
|
49
|
+
type: resolvedType,
|
|
50
|
+
name: args.name,
|
|
51
|
+
description: args.description,
|
|
52
|
+
attributes: args.attributes ?? {},
|
|
53
|
+
metadata: {
|
|
54
|
+
created_at: now,
|
|
55
|
+
updated_at: now,
|
|
56
|
+
version: 1
|
|
57
|
+
},
|
|
58
|
+
layer: args.layer
|
|
59
|
+
}), sourceRef = buildSourceReference(args);
|
|
60
|
+
sourceRef && element.setSourceReference(sourceRef);
|
|
61
|
+
{
|
|
62
|
+
const schemaValidator = new SchemaValidator(), tempLayer = new Layer(args.layer);
|
|
63
|
+
tempLayer.addElement(element);
|
|
64
|
+
const attrValidation = await schemaValidator.validateLayer(tempLayer);
|
|
65
|
+
if (!attrValidation.isValid()) {
|
|
66
|
+
const errorMessages = attrValidation.errors.map((e) => ` ${e.message}`).join(`
|
|
67
|
+
`);
|
|
68
|
+
throw new CLIError(`Element ${elementPath} has invalid attributes:
|
|
69
|
+
${errorMessages}`, ErrorCategory.USER, [
|
|
70
|
+
`Use "model_info" with layer "${args.layer}" and the spec resource for "${args.type}" to see the required attributes`
|
|
71
|
+
]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (layerObj.getElement(elementPath))
|
|
75
|
+
throw new CLIError(`Element ${elementPath} already exists in ${args.layer} layer`, ErrorCategory.USER, [
|
|
76
|
+
'Use "model_show" to view the existing element',
|
|
77
|
+
'Use "model_update" to modify it',
|
|
78
|
+
'Use "model_delete" to remove it first if you want to recreate it'
|
|
79
|
+
]);
|
|
80
|
+
isNewLayer && model.addLayer(layerObj);
|
|
81
|
+
const mutationHandler = new MutationHandler(model, elementPath, args.layer);
|
|
82
|
+
await mutationHandler.executeAdd(element, (elem) => {
|
|
83
|
+
layerObj.addElement(elem);
|
|
84
|
+
});
|
|
85
|
+
const activeChangeset = await mutationHandler.getStagingManager().getActive(), staged = !!(activeChangeset && activeChangeset.status === "staged");
|
|
86
|
+
return jsonResult({
|
|
87
|
+
status: staged ? "staged" : "added",
|
|
88
|
+
changeset: staged ? activeChangeset.name : void 0,
|
|
89
|
+
id: elementPath,
|
|
90
|
+
layer: args.layer,
|
|
91
|
+
type: resolvedType,
|
|
92
|
+
name: args.name
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const modelAddTool = {
|
|
97
|
+
name: "model_add",
|
|
98
|
+
description: "Add a new element to a layer, validated against its spec schema.",
|
|
99
|
+
inputSchema,
|
|
100
|
+
handler: modelAddHandler
|
|
101
|
+
};
|
|
102
|
+
export {
|
|
103
|
+
modelAddHandler,
|
|
104
|
+
modelAddTool
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=model-add.js.map
|