@lssm/bundle.contractspec-workspace 0.0.0-canary-20251217063201 → 0.0.0-canary-20251217073102
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/dist/_virtual/rolldown_runtime.js +22 -1
- package/dist/adapters/ai.js +82 -1
- package/dist/adapters/factory.js +36 -1
- package/dist/adapters/fs.js +118 -1
- package/dist/adapters/git.js +54 -1
- package/dist/adapters/index.js +7 -1
- package/dist/adapters/logger.js +80 -1
- package/dist/adapters/watcher.js +69 -1
- package/dist/adapters/workspace.js +190 -2
- package/dist/ai/agents/claude-code-agent.js +146 -9
- package/dist/ai/agents/cursor-agent.js +286 -17
- package/dist/ai/agents/index.js +5 -1
- package/dist/ai/agents/openai-codex-agent.js +140 -8
- package/dist/ai/agents/orchestrator.js +142 -1
- package/dist/ai/agents/simple-agent.js +80 -4
- package/dist/ai/client.js +162 -1
- package/dist/ai/index.js +27 -1
- package/dist/ai/prompts/code-generation.js +55 -13
- package/dist/ai/prompts/index.js +12 -1
- package/dist/ai/prompts/spec-creation.js +61 -20
- package/dist/ai/providers.js +40 -1
- package/dist/formatters/index.js +18 -1
- package/dist/formatters/json.js +71 -1
- package/dist/formatters/sarif.js +163 -1
- package/dist/formatters/text.js +208 -2
- package/dist/index.js +81 -1
- package/dist/libs/ai-providers/dist/factory.js +154 -1
- package/dist/libs/ai-providers/dist/index.js +4 -1
- package/dist/libs/ai-providers/dist/legacy.js +72 -1
- package/dist/libs/ai-providers/dist/models.js +287 -1
- package/dist/libs/ai-providers/dist/validation.js +1 -1
- package/dist/libs/contracts/dist/capabilities/openbanking.js +88 -1
- package/dist/libs/contracts/dist/client/index.js +5 -1
- package/dist/libs/contracts/dist/client/react/feature-render.js +2 -1
- package/dist/libs/contracts/dist/client/react/form-render.js +4 -1
- package/dist/libs/contracts/dist/client/react/index.js +4 -1
- package/dist/libs/contracts/dist/contract-registry/index.js +1 -1
- package/dist/libs/contracts/dist/contract-registry/schemas.js +60 -1
- package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +16 -76
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +16 -350
- package/dist/libs/contracts/dist/docs/index.js +29 -1
- package/dist/libs/contracts/dist/docs/presentations.js +71 -1
- package/dist/libs/contracts/dist/docs/registry.js +44 -1
- package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +16 -383
- package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +16 -68
- package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +16 -140
- package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +16 -86
- package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +16 -1
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +24 -2
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +21 -2
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +16 -213
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +73 -5
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +37 -1
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +16 -1
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +20 -262
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +48 -1
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +24 -2
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +23 -2
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +25 -16
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +67 -1
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +22 -2
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +40 -36
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +47 -1
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +23 -2
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +36 -3
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +20 -1
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +36 -3
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +20 -1
- package/dist/libs/contracts/dist/events.js +8 -1
- package/dist/libs/contracts/dist/experiments/evaluator.js +1 -1
- package/dist/libs/contracts/dist/index.js +72 -1
- package/dist/libs/contracts/dist/install.js +2 -1
- package/dist/libs/contracts/dist/integrations/contracts.js +377 -1
- package/dist/libs/contracts/dist/integrations/index.js +18 -1
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +228 -1
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +159 -1
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +3 -1
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +210 -1
- package/dist/libs/contracts/dist/integrations/openbanking/models.js +242 -1
- package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +13 -1
- package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +52 -1
- package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +75 -1
- package/dist/libs/contracts/dist/integrations/providers/gmail.js +87 -1
- package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +66 -1
- package/dist/libs/contracts/dist/integrations/providers/index.js +11 -1
- package/dist/libs/contracts/dist/integrations/providers/mistral.js +68 -1
- package/dist/libs/contracts/dist/integrations/providers/postmark.js +68 -1
- package/dist/libs/contracts/dist/integrations/providers/powens.js +116 -1
- package/dist/libs/contracts/dist/integrations/providers/qdrant.js +73 -1
- package/dist/libs/contracts/dist/integrations/providers/registry.js +10 -1
- package/dist/libs/contracts/dist/integrations/providers/stripe.js +83 -1
- package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +61 -1
- package/dist/libs/contracts/dist/jsonschema.js +24 -1
- package/dist/libs/contracts/dist/knowledge/contracts.js +306 -1
- package/dist/libs/contracts/dist/knowledge/index.js +7 -1
- package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +34 -1
- package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +34 -1
- package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +38 -1
- package/dist/libs/contracts/dist/knowledge/spaces/index.js +6 -1
- package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +34 -1
- package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +37 -1
- package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +34 -1
- package/dist/libs/contracts/dist/llm/exporters.js +352 -4
- package/dist/libs/contracts/dist/llm/index.js +2 -1
- package/dist/libs/contracts/dist/llm/prompts.js +143 -7
- package/dist/libs/contracts/dist/onboarding-base.js +196 -1
- package/dist/libs/contracts/dist/openapi.js +75 -1
- package/dist/libs/contracts/dist/ownership.js +21 -1
- package/dist/libs/contracts/dist/presentations.js +1 -1
- package/dist/libs/contracts/dist/presentations.v2.js +11 -1
- package/dist/libs/contracts/dist/prompt.js +1 -1
- package/dist/libs/contracts/dist/promptRegistry.js +1 -1
- package/dist/libs/contracts/dist/regenerator/index.js +2 -1
- package/dist/libs/contracts/dist/regenerator/service.js +92 -1
- package/dist/libs/contracts/dist/regenerator/utils.js +51 -1
- package/dist/libs/contracts/dist/registry.js +208 -1
- package/dist/libs/contracts/dist/resources.js +1 -1
- package/dist/libs/contracts/dist/schema/dist/EnumType.js +2 -1
- package/dist/libs/contracts/dist/schema/dist/FieldType.js +49 -1
- package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +236 -1
- package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +34 -1
- package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +1 -1
- package/dist/libs/contracts/dist/schema/dist/entity/index.js +2 -1
- package/dist/libs/contracts/dist/schema/dist/entity/types.js +1 -1
- package/dist/libs/contracts/dist/schema/dist/index.js +6 -1
- package/dist/libs/contracts/dist/server/graphql-pothos.js +6 -1
- package/dist/libs/contracts/dist/server/index.js +8 -1
- package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +4 -1
- package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +2 -1
- package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +1 -1
- package/dist/libs/contracts/dist/server/mcp/registerResources.js +2 -1
- package/dist/libs/contracts/dist/server/mcp/registerTools.js +1 -1
- package/dist/libs/contracts/dist/server/provider-mcp.js +1 -1
- package/dist/libs/contracts/dist/server/rest-elysia.js +1 -1
- package/dist/libs/contracts/dist/server/rest-express.js +1 -1
- package/dist/libs/contracts/dist/server/rest-generic.js +1 -1
- package/dist/libs/contracts/dist/server/rest-next-app.js +1 -1
- package/dist/libs/contracts/dist/server/rest-next-pages.js +1 -1
- package/dist/libs/contracts/dist/spec.js +35 -1
- package/dist/libs/contracts/dist/telemetry/index.js +1 -1
- package/dist/libs/contracts/dist/telemetry/tracker.js +1 -1
- package/dist/libs/contracts/dist/tests/index.js +1 -1
- package/dist/libs/contracts/dist/tests/runner.js +150 -1
- package/dist/libs/contracts/dist/workflow/index.js +1 -1
- package/dist/libs/contracts/dist/workflow/runner.js +1 -1
- package/dist/libs/contracts-transformers/dist/common/utils.js +47 -1
- package/dist/libs/contracts-transformers/dist/openapi/exporter.js +1 -1
- package/dist/libs/contracts-transformers/dist/openapi/importer.js +255 -2
- package/dist/libs/contracts-transformers/dist/openapi/index.js +4 -1
- package/dist/libs/contracts-transformers/dist/openapi/parser.js +231 -1
- package/dist/libs/contracts-transformers/dist/openapi/schema-converter.js +201 -4
- package/dist/modules/contractspec-workspace/dist/ai/code-generation.js +50 -13
- package/dist/modules/contractspec-workspace/dist/ai/spec-creation.js +50 -18
- package/dist/modules/contractspec-workspace/dist/analysis/deps/graph.js +84 -2
- package/dist/modules/contractspec-workspace/dist/analysis/deps/parse-imports.js +30 -1
- package/dist/modules/contractspec-workspace/dist/analysis/diff/semantic.js +96 -1
- package/dist/modules/contractspec-workspace/dist/analysis/feature-scan.js +151 -1
- package/dist/modules/contractspec-workspace/dist/analysis/spec-scan.js +344 -1
- package/dist/modules/contractspec-workspace/dist/analysis/validate/spec-structure.js +122 -1
- package/dist/modules/contractspec-workspace/dist/templates/app-config.js +100 -28
- package/dist/modules/contractspec-workspace/dist/templates/data-view.js +41 -27
- package/dist/modules/contractspec-workspace/dist/templates/event.js +28 -14
- package/dist/modules/contractspec-workspace/dist/templates/experiment.js +76 -51
- package/dist/modules/contractspec-workspace/dist/templates/handler.js +49 -17
- package/dist/modules/contractspec-workspace/dist/templates/integration-utils.js +97 -26
- package/dist/modules/contractspec-workspace/dist/templates/integration.js +46 -23
- package/dist/modules/contractspec-workspace/dist/templates/knowledge.js +59 -19
- package/dist/modules/contractspec-workspace/dist/templates/migration.js +49 -26
- package/dist/modules/contractspec-workspace/dist/templates/operation.js +40 -28
- package/dist/modules/contractspec-workspace/dist/templates/presentation.js +45 -20
- package/dist/modules/contractspec-workspace/dist/templates/telemetry.js +73 -53
- package/dist/modules/contractspec-workspace/dist/templates/utils.js +38 -1
- package/dist/modules/contractspec-workspace/dist/templates/workflow-runner.js +12 -6
- package/dist/modules/contractspec-workspace/dist/templates/workflow.js +50 -24
- package/dist/modules/contractspec-workspace/dist/types/generation-types.js +20 -1
- package/dist/services/agent-guide/adapters/claude-code.js +144 -3
- package/dist/services/agent-guide/adapters/cursor-cli.js +135 -3
- package/dist/services/agent-guide/adapters/generic-mcp.js +159 -3
- package/dist/services/agent-guide/adapters/index.js +30 -1
- package/dist/services/agent-guide/agent-guide-service.js +148 -1
- package/dist/services/agent-guide/index.js +5 -1
- package/dist/services/build.js +140 -1
- package/dist/services/ci-check/ci-check-service.js +393 -1
- package/dist/services/ci-check/index.js +2 -1
- package/dist/services/ci-check/types.js +28 -1
- package/dist/services/clean.js +71 -1
- package/dist/services/config.js +76 -1
- package/dist/services/deps.js +62 -1
- package/dist/services/diff.js +33 -1
- package/dist/services/doctor/checks/ai.js +118 -2
- package/dist/services/doctor/checks/cli.js +146 -1
- package/dist/services/doctor/checks/config.js +170 -1
- package/dist/services/doctor/checks/deps.js +180 -1
- package/dist/services/doctor/checks/index.js +6 -1
- package/dist/services/doctor/checks/mcp.js +144 -1
- package/dist/services/doctor/checks/workspace.js +243 -1
- package/dist/services/doctor/doctor-service.js +115 -2
- package/dist/services/doctor/index.js +2 -1
- package/dist/services/doctor/types.js +26 -1
- package/dist/services/implementation/discovery.js +143 -2
- package/dist/services/implementation/index.js +2 -1
- package/dist/services/implementation/resolver.js +223 -1
- package/dist/services/index.js +53 -1
- package/dist/services/integrity-diagram.js +274 -6
- package/dist/services/integrity.js +272 -1
- package/dist/services/list.js +35 -1
- package/dist/services/openapi/export-service.js +51 -2
- package/dist/services/openapi/import-service.js +75 -1
- package/dist/services/openapi/index.js +4 -1
- package/dist/services/openapi/sync-service.js +121 -1
- package/dist/services/openapi/validate-service.js +130 -1
- package/dist/services/regenerator.js +23 -1
- package/dist/services/registry.js +73 -1
- package/dist/services/setup/config-generators.js +113 -26
- package/dist/services/setup/file-merger.js +60 -2
- package/dist/services/setup/index.js +4 -1
- package/dist/services/setup/setup-service.js +95 -1
- package/dist/services/setup/targets/agents-md.js +46 -1
- package/dist/services/setup/targets/cli-config.js +59 -1
- package/dist/services/setup/targets/cursor-rules.js +47 -1
- package/dist/services/setup/targets/mcp-claude.js +59 -1
- package/dist/services/setup/targets/mcp-cursor.js +58 -1
- package/dist/services/setup/targets/vscode-settings.js +62 -1
- package/dist/services/setup/types.js +26 -1
- package/dist/services/sync.js +62 -1
- package/dist/services/test.js +30 -1
- package/dist/services/validate-implementation.js +69 -1
- package/dist/services/validate.js +47 -1
- package/dist/services/verification-cache/adapters/filesystem.js +121 -1
- package/dist/services/verification-cache/adapters/in-memory.js +45 -1
- package/dist/services/verification-cache/adapters/index.js +3 -1
- package/dist/services/verification-cache/adapters/workspace-state.js +90 -1
- package/dist/services/verification-cache/cache-service.js +255 -1
- package/dist/services/verification-cache/index.js +6 -1
- package/dist/services/verification-cache/types.js +15 -1
- package/dist/services/verify/ai-verifier.js +336 -9
- package/dist/services/verify/behavior-verifier.js +185 -1
- package/dist/services/verify/index.js +4 -1
- package/dist/services/verify/structure-verifier.js +195 -2
- package/dist/services/verify/verify-service.js +203 -3
- package/dist/services/watch.js +31 -1
- package/dist/services/workspace-info.js +102 -2
- package/dist/templates/app-config.template.js +101 -28
- package/dist/templates/data-view.template.js +42 -27
- package/dist/templates/event.template.js +29 -14
- package/dist/templates/experiment.template.js +77 -51
- package/dist/templates/handler.template.js +53 -17
- package/dist/templates/index.js +36 -1
- package/dist/templates/integration.template.js +134 -50
- package/dist/templates/knowledge.template.js +62 -21
- package/dist/templates/migration.template.js +50 -26
- package/dist/templates/operation.template.js +44 -28
- package/dist/templates/presentation.template.js +46 -20
- package/dist/templates/telemetry.template.js +74 -53
- package/dist/templates/workflow-runner.template.js +12 -6
- package/dist/templates/workflow.template.js +51 -24
- package/package.json +13 -9
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { escapeString, toPascalCase } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../modules/contractspec-workspace/dist/templates/workflow.js
|
|
4
|
+
/**
|
|
5
|
+
* Generate workflow spec TypeScript code.
|
|
6
|
+
*/
|
|
7
|
+
function generateWorkflowSpec(data) {
|
|
8
|
+
const specVarName = toPascalCase(data.name.split(".").pop() ?? "Workflow") + "Workflow";
|
|
9
|
+
const stepsCode = data.steps.map((step) => formatStep(step)).join(",\n");
|
|
10
|
+
const transitionsCode = data.transitions.map((transition) => ` {
|
|
11
|
+
from: '${transition.from}',
|
|
12
|
+
to: '${transition.to}',
|
|
13
|
+
${transition.condition ? ` condition: '${escapeString(transition.condition)}',` : ""}
|
|
14
|
+
}`).join(",\n");
|
|
15
|
+
return `import type { WorkflowSpec } from '@lssm/lib.contracts/workflow';
|
|
8
16
|
|
|
9
17
|
/**
|
|
10
18
|
* Workflow generated via contractspec CLI.
|
|
@@ -14,28 +22,46 @@ ${t.condition?` condition: '${e(t.condition)}',`:``}
|
|
|
14
22
|
* - Provide form renderers for human steps.
|
|
15
23
|
* - Add guards/conditions as needed.
|
|
16
24
|
*/
|
|
17
|
-
export const ${
|
|
25
|
+
export const ${specVarName}: WorkflowSpec = {
|
|
18
26
|
meta: {
|
|
19
|
-
name: '${
|
|
20
|
-
version: ${
|
|
21
|
-
title: '${
|
|
22
|
-
description: '${
|
|
23
|
-
domain: '${
|
|
24
|
-
stability: '${
|
|
25
|
-
owners: [${
|
|
26
|
-
tags: [${
|
|
27
|
+
name: '${data.name}',
|
|
28
|
+
version: ${data.version},
|
|
29
|
+
title: '${escapeString(data.title)}',
|
|
30
|
+
description: '${escapeString(data.description)}',
|
|
31
|
+
domain: '${escapeString(data.domain)}',
|
|
32
|
+
stability: '${data.stability}',
|
|
33
|
+
owners: [${data.owners.map((owner) => `'${owner}'`).join(", ")}],
|
|
34
|
+
tags: [${data.tags.map((tag) => `'${tag}'`).join(", ")}],
|
|
27
35
|
},
|
|
28
36
|
definition: {
|
|
29
|
-
${
|
|
30
|
-
${
|
|
37
|
+
${data.entryStepId ? ` entryStepId: '${data.entryStepId}',\n` : ""} steps: [
|
|
38
|
+
${stepsCode}
|
|
31
39
|
],
|
|
32
40
|
transitions: [
|
|
33
|
-
${
|
|
41
|
+
${transitionsCode}
|
|
34
42
|
],
|
|
35
43
|
},
|
|
36
|
-
${
|
|
37
|
-
flags: [${
|
|
38
|
-
}
|
|
44
|
+
${data.policyFlags.length > 0 ? `policy: {
|
|
45
|
+
flags: [${data.policyFlags.map((flag) => `'${flag}'`).join(", ")}],
|
|
46
|
+
},` : "// policy: { flags: [] },"}
|
|
39
47
|
};
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
function formatStep(step) {
|
|
51
|
+
const lines = [
|
|
52
|
+
` {`,
|
|
53
|
+
` id: '${step.id}',`,
|
|
54
|
+
` type: '${step.type}',`,
|
|
55
|
+
` label: '${escapeString(step.label)}',`
|
|
56
|
+
];
|
|
57
|
+
if (step.description) lines.push(` description: '${escapeString(step.description)}',`);
|
|
58
|
+
const actionLines = [];
|
|
59
|
+
if (step.operation) actionLines.push(`operation: { name: '${step.operation.name}', version: ${step.operation.version} }`);
|
|
60
|
+
if (step.form) actionLines.push(`form: { key: '${step.form.key}', version: ${step.form.version} }`);
|
|
61
|
+
if (actionLines.length) lines.push(` action: { ${actionLines.join(", ")} },`);
|
|
62
|
+
lines.push(` }`);
|
|
63
|
+
return lines.join("\n");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { generateWorkflowSpec };
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
//#region ../../modules/contractspec-workspace/dist/types/generation-types.js
|
|
2
|
+
/**
|
|
3
|
+
* Default workspace configuration.
|
|
4
|
+
*/
|
|
5
|
+
const DEFAULT_WORKSPACE_CONFIG = {
|
|
6
|
+
aiProvider: "claude",
|
|
7
|
+
agentMode: "simple",
|
|
8
|
+
outputDir: "./src",
|
|
9
|
+
conventions: {
|
|
10
|
+
operations: "interactions/commands|queries",
|
|
11
|
+
events: "events",
|
|
12
|
+
presentations: "presentations",
|
|
13
|
+
forms: "forms"
|
|
14
|
+
},
|
|
15
|
+
defaultOwners: [],
|
|
16
|
+
defaultTags: []
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { DEFAULT_WORKSPACE_CONFIG };
|
|
@@ -1,3 +1,144 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { AGENT_SYSTEM_PROMPTS } from "../../../libs/contracts/dist/llm/prompts.js";
|
|
2
|
+
import "../../../libs/contracts/dist/llm/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/services/agent-guide/adapters/claude-code.ts
|
|
5
|
+
/**
|
|
6
|
+
* Claude Code adapter implementation.
|
|
7
|
+
* Optimized for Claude's extended thinking and code generation capabilities.
|
|
8
|
+
*/
|
|
9
|
+
var ClaudeCodeAdapter = class {
|
|
10
|
+
agentType = "claude-code";
|
|
11
|
+
/**
|
|
12
|
+
* Format an implementation plan for Claude Code.
|
|
13
|
+
* Uses structured markdown with clear sections and checklists.
|
|
14
|
+
*/
|
|
15
|
+
formatPlan(plan) {
|
|
16
|
+
const lines = [];
|
|
17
|
+
lines.push(`# Implement: ${plan.target.name}.v${plan.target.version}`);
|
|
18
|
+
lines.push("");
|
|
19
|
+
lines.push("## Context");
|
|
20
|
+
lines.push("");
|
|
21
|
+
lines.push(`**Goal:** ${plan.context.goal}`);
|
|
22
|
+
lines.push("");
|
|
23
|
+
lines.push(`**Description:** ${plan.context.description}`);
|
|
24
|
+
lines.push("");
|
|
25
|
+
if (plan.context.background) {
|
|
26
|
+
lines.push(`**Background:**`);
|
|
27
|
+
lines.push(plan.context.background);
|
|
28
|
+
lines.push("");
|
|
29
|
+
}
|
|
30
|
+
lines.push("## Specification");
|
|
31
|
+
lines.push("");
|
|
32
|
+
lines.push(plan.specMarkdown);
|
|
33
|
+
lines.push("");
|
|
34
|
+
if (plan.fileStructure.length > 0) {
|
|
35
|
+
lines.push("## Files to Create/Modify");
|
|
36
|
+
lines.push("");
|
|
37
|
+
for (const file of plan.fileStructure) {
|
|
38
|
+
const icon = file.type === "create" ? "📝" : "✏️";
|
|
39
|
+
lines.push(`${icon} \`${file.path}\``);
|
|
40
|
+
lines.push(` ${file.purpose}`);
|
|
41
|
+
lines.push("");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
lines.push("## Implementation Steps");
|
|
45
|
+
lines.push("");
|
|
46
|
+
for (const step of plan.steps) {
|
|
47
|
+
lines.push(`### ${step.order}. ${step.title}`);
|
|
48
|
+
lines.push("");
|
|
49
|
+
lines.push(step.description);
|
|
50
|
+
lines.push("");
|
|
51
|
+
lines.push("**Acceptance Criteria:**");
|
|
52
|
+
for (const criteria of step.acceptanceCriteria) lines.push(`- [ ] ${criteria}`);
|
|
53
|
+
lines.push("");
|
|
54
|
+
}
|
|
55
|
+
if (plan.constraints.policy.length > 0 || plan.constraints.security.length > 0 || plan.constraints.pii.length > 0) {
|
|
56
|
+
lines.push("## Constraints");
|
|
57
|
+
lines.push("");
|
|
58
|
+
if (plan.constraints.policy.length > 0) {
|
|
59
|
+
lines.push("### Policy");
|
|
60
|
+
for (const p of plan.constraints.policy) lines.push(`- ${p}`);
|
|
61
|
+
lines.push("");
|
|
62
|
+
}
|
|
63
|
+
if (plan.constraints.security.length > 0) {
|
|
64
|
+
lines.push("### Security");
|
|
65
|
+
for (const s of plan.constraints.security) lines.push(`- ⚠️ ${s}`);
|
|
66
|
+
lines.push("");
|
|
67
|
+
}
|
|
68
|
+
if (plan.constraints.pii.length > 0) {
|
|
69
|
+
lines.push("### PII Handling");
|
|
70
|
+
lines.push("The following fields contain personally identifiable information:");
|
|
71
|
+
for (const pii of plan.constraints.pii) lines.push(`- \`${pii}\``);
|
|
72
|
+
lines.push("");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
lines.push("## Verification Checklist");
|
|
76
|
+
lines.push("");
|
|
77
|
+
lines.push("Before submitting, verify:");
|
|
78
|
+
for (const check of plan.verificationChecklist) lines.push(`- [ ] ${check}`);
|
|
79
|
+
lines.push("");
|
|
80
|
+
lines.push("## Instructions");
|
|
81
|
+
lines.push("");
|
|
82
|
+
lines.push("1. Implement each step in order");
|
|
83
|
+
lines.push("2. Use TypeScript with strict typing (no `any`)");
|
|
84
|
+
lines.push("3. Include JSDoc comments for public APIs");
|
|
85
|
+
lines.push("4. Handle all error cases defined in the spec");
|
|
86
|
+
lines.push("5. Emit events as specified");
|
|
87
|
+
lines.push("6. Mark checklist items as you complete them");
|
|
88
|
+
lines.push("");
|
|
89
|
+
return {
|
|
90
|
+
agent: "claude-code",
|
|
91
|
+
systemPrompt: AGENT_SYSTEM_PROMPTS["claude-code"],
|
|
92
|
+
taskPrompt: lines.join("\n")
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Generate agent-specific configuration.
|
|
97
|
+
* For Claude Code, this generates a prompt that can be used as context.
|
|
98
|
+
*/
|
|
99
|
+
generateConfig(spec) {
|
|
100
|
+
const lines = [];
|
|
101
|
+
lines.push("# ContractSpec Implementation Context");
|
|
102
|
+
lines.push("");
|
|
103
|
+
lines.push("This codebase uses ContractSpec for spec-first development.");
|
|
104
|
+
lines.push("");
|
|
105
|
+
lines.push("## Spec Details");
|
|
106
|
+
lines.push("");
|
|
107
|
+
lines.push(`- **Name:** ${spec.meta.name}`);
|
|
108
|
+
lines.push(`- **Version:** ${spec.meta.version}`);
|
|
109
|
+
lines.push(`- **Kind:** ${spec.meta.kind}`);
|
|
110
|
+
lines.push(`- **Stability:** ${spec.meta.stability}`);
|
|
111
|
+
lines.push("");
|
|
112
|
+
lines.push("## Implementation Requirements");
|
|
113
|
+
lines.push("");
|
|
114
|
+
lines.push("1. Match input/output types exactly");
|
|
115
|
+
lines.push("2. Handle all defined error cases");
|
|
116
|
+
lines.push("3. Emit events as specified");
|
|
117
|
+
lines.push("4. Respect policy constraints");
|
|
118
|
+
lines.push("");
|
|
119
|
+
return lines.join("\n");
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Parse Claude Code output to extract generated code.
|
|
123
|
+
*/
|
|
124
|
+
parseOutput(output) {
|
|
125
|
+
const codeBlockMatch = output.match(/```(?:typescript|ts|tsx)?\n([\s\S]*?)\n```/);
|
|
126
|
+
if (codeBlockMatch?.[1]) return { code: codeBlockMatch[1] };
|
|
127
|
+
const errors = [];
|
|
128
|
+
for (const pattern of [
|
|
129
|
+
/error:\s*(.+)/gi,
|
|
130
|
+
/failed:\s*(.+)/gi,
|
|
131
|
+
/cannot\s+(.+)/gi
|
|
132
|
+
]) {
|
|
133
|
+
const matches = output.matchAll(pattern);
|
|
134
|
+
for (const match of matches) if (match[1]) errors.push(match[1]);
|
|
135
|
+
}
|
|
136
|
+
if (errors.length > 0) return { errors };
|
|
137
|
+
return { code: output };
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
/** Singleton instance */
|
|
141
|
+
const claudeCodeAdapter = new ClaudeCodeAdapter();
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
export { ClaudeCodeAdapter, claudeCodeAdapter };
|
|
@@ -1,3 +1,135 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { AGENT_SYSTEM_PROMPTS } from "../../../libs/contracts/dist/llm/prompts.js";
|
|
2
|
+
import "../../../libs/contracts/dist/llm/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/services/agent-guide/adapters/cursor-cli.ts
|
|
5
|
+
/**
|
|
6
|
+
* Cursor CLI adapter implementation.
|
|
7
|
+
* Optimized for Cursor's background/composer mode.
|
|
8
|
+
*/
|
|
9
|
+
var CursorCLIAdapter = class {
|
|
10
|
+
agentType = "cursor-cli";
|
|
11
|
+
/**
|
|
12
|
+
* Format an implementation plan for Cursor CLI.
|
|
13
|
+
* Uses concise format optimized for Cursor's context window.
|
|
14
|
+
*/
|
|
15
|
+
formatPlan(plan) {
|
|
16
|
+
const lines = [];
|
|
17
|
+
lines.push(`# ${plan.target.name}.v${plan.target.version}`);
|
|
18
|
+
lines.push("");
|
|
19
|
+
lines.push(`> ${plan.context.goal}`);
|
|
20
|
+
lines.push("");
|
|
21
|
+
if (plan.fileStructure.length > 0) {
|
|
22
|
+
lines.push("## Files");
|
|
23
|
+
lines.push("");
|
|
24
|
+
for (const file of plan.fileStructure) lines.push(`- ${file.type}: \`${file.path}\` - ${file.purpose}`);
|
|
25
|
+
lines.push("");
|
|
26
|
+
}
|
|
27
|
+
lines.push("## Spec");
|
|
28
|
+
lines.push("");
|
|
29
|
+
lines.push(plan.specMarkdown);
|
|
30
|
+
lines.push("");
|
|
31
|
+
lines.push("## Steps");
|
|
32
|
+
lines.push("");
|
|
33
|
+
for (const step of plan.steps) lines.push(`${step.order}. **${step.title}**: ${step.description}`);
|
|
34
|
+
lines.push("");
|
|
35
|
+
const constraints = [...plan.constraints.policy, ...plan.constraints.security.map((s) => `⚠️ ${s}`)];
|
|
36
|
+
if (constraints.length > 0) {
|
|
37
|
+
lines.push("## Constraints");
|
|
38
|
+
lines.push("");
|
|
39
|
+
for (const c of constraints) lines.push(`- ${c}`);
|
|
40
|
+
lines.push("");
|
|
41
|
+
}
|
|
42
|
+
if (plan.constraints.pii.length > 0) {
|
|
43
|
+
lines.push("## PII Fields");
|
|
44
|
+
lines.push("");
|
|
45
|
+
lines.push(`Handle carefully: ${plan.constraints.pii.map((p) => `\`${p}\``).join(", ")}`);
|
|
46
|
+
lines.push("");
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
agent: "cursor-cli",
|
|
50
|
+
systemPrompt: AGENT_SYSTEM_PROMPTS["cursor-cli"],
|
|
51
|
+
taskPrompt: lines.join("\n")
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Generate Cursor rules (.mdc format) for a spec.
|
|
56
|
+
* Can be saved to .cursor/rules/ to provide persistent context.
|
|
57
|
+
*/
|
|
58
|
+
generateConfig(spec) {
|
|
59
|
+
const m = spec.meta;
|
|
60
|
+
const lines = [];
|
|
61
|
+
lines.push("---");
|
|
62
|
+
lines.push(`description: Implementation rules for ${m.name}.v${m.version}`);
|
|
63
|
+
lines.push(`globs: ["**/${m.name.replace(/\./g, "/")}/**"]`);
|
|
64
|
+
lines.push("alwaysApply: false");
|
|
65
|
+
lines.push("---");
|
|
66
|
+
lines.push("");
|
|
67
|
+
lines.push(`# ${m.name} Implementation Rules`);
|
|
68
|
+
lines.push("");
|
|
69
|
+
lines.push(`This ${m.kind} operation must follow the ContractSpec specification.`);
|
|
70
|
+
lines.push("");
|
|
71
|
+
lines.push("## Goal");
|
|
72
|
+
lines.push("");
|
|
73
|
+
lines.push(m.goal);
|
|
74
|
+
lines.push("");
|
|
75
|
+
lines.push("## Requirements");
|
|
76
|
+
lines.push("");
|
|
77
|
+
lines.push("1. Input/output types MUST match the spec schema exactly");
|
|
78
|
+
lines.push("2. All error cases MUST be handled");
|
|
79
|
+
if (spec.sideEffects?.emits?.length) lines.push("3. Events MUST be emitted as specified");
|
|
80
|
+
lines.push(`4. Auth level: ${spec.policy.auth}`);
|
|
81
|
+
if (spec.policy.idempotent !== void 0) lines.push(`5. Idempotency: ${spec.policy.idempotent}`);
|
|
82
|
+
lines.push("");
|
|
83
|
+
if (spec.io.errors && Object.keys(spec.io.errors).length > 0) {
|
|
84
|
+
lines.push("## Error Cases");
|
|
85
|
+
lines.push("");
|
|
86
|
+
for (const [code, err] of Object.entries(spec.io.errors)) lines.push(`- \`${code}\` (HTTP ${err.http ?? 400}): ${err.when}`);
|
|
87
|
+
lines.push("");
|
|
88
|
+
}
|
|
89
|
+
if (spec.sideEffects?.emits?.length) {
|
|
90
|
+
lines.push("## Events to Emit");
|
|
91
|
+
lines.push("");
|
|
92
|
+
for (const e of spec.sideEffects.emits) if ("ref" in e) lines.push(`- \`${e.ref.name}.v${e.ref.version}\`: ${e.when}`);
|
|
93
|
+
else lines.push(`- \`${e.name}.v${e.version}\`: ${e.when}`);
|
|
94
|
+
lines.push("");
|
|
95
|
+
}
|
|
96
|
+
if (spec.policy.pii?.length) {
|
|
97
|
+
lines.push("## PII Handling");
|
|
98
|
+
lines.push("");
|
|
99
|
+
lines.push("These fields contain PII and must be handled with care:");
|
|
100
|
+
for (const field of spec.policy.pii) lines.push(`- \`${field}\``);
|
|
101
|
+
lines.push("");
|
|
102
|
+
}
|
|
103
|
+
if (spec.acceptance?.scenarios?.length) {
|
|
104
|
+
lines.push("## Acceptance Scenarios");
|
|
105
|
+
lines.push("");
|
|
106
|
+
for (const s of spec.acceptance.scenarios) {
|
|
107
|
+
lines.push(`### ${s.name}`);
|
|
108
|
+
lines.push(`- Given: ${s.given.join("; ")}`);
|
|
109
|
+
lines.push(`- When: ${s.when.join("; ")}`);
|
|
110
|
+
lines.push(`- Then: ${s.then.join("; ")}`);
|
|
111
|
+
lines.push("");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return lines.join("\n");
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Generate a cursor rules file path for a spec.
|
|
118
|
+
*/
|
|
119
|
+
getCursorRulesPath(spec) {
|
|
120
|
+
return `.cursor/rules/${spec.meta.name.replace(/\./g, "-")}.mdc`;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Parse Cursor output to extract generated code.
|
|
124
|
+
*/
|
|
125
|
+
parseOutput(output) {
|
|
126
|
+
const codeBlockMatch = output.match(/```(?:typescript|ts|tsx|javascript|js)?\n([\s\S]*?)\n```/);
|
|
127
|
+
if (codeBlockMatch?.[1]) return { code: codeBlockMatch[1] };
|
|
128
|
+
return { code: output };
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
/** Singleton instance */
|
|
132
|
+
const cursorCLIAdapter = new CursorCLIAdapter();
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
export { CursorCLIAdapter, cursorCLIAdapter };
|
|
@@ -1,3 +1,159 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { AGENT_SYSTEM_PROMPTS } from "../../../libs/contracts/dist/llm/prompts.js";
|
|
2
|
+
import "../../../libs/contracts/dist/llm/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/services/agent-guide/adapters/generic-mcp.ts
|
|
5
|
+
/**
|
|
6
|
+
* Generic MCP adapter implementation.
|
|
7
|
+
* Works with any MCP-compatible agent (Cline, Aider, etc.).
|
|
8
|
+
*/
|
|
9
|
+
var GenericMCPAdapter = class {
|
|
10
|
+
agentType = "generic-mcp";
|
|
11
|
+
/**
|
|
12
|
+
* Format an implementation plan for generic MCP agents.
|
|
13
|
+
* Uses a standard markdown format that works across different agents.
|
|
14
|
+
*/
|
|
15
|
+
formatPlan(plan) {
|
|
16
|
+
const lines = [];
|
|
17
|
+
lines.push(`# Implementation Task: ${plan.target.name}.v${plan.target.version}`);
|
|
18
|
+
lines.push("");
|
|
19
|
+
lines.push("## Task");
|
|
20
|
+
lines.push("");
|
|
21
|
+
lines.push(`Implement the ${plan.target.type} \`${plan.target.name}\` version ${plan.target.version}.`);
|
|
22
|
+
lines.push("");
|
|
23
|
+
lines.push("## Context");
|
|
24
|
+
lines.push("");
|
|
25
|
+
lines.push(`**Goal:** ${plan.context.goal}`);
|
|
26
|
+
lines.push("");
|
|
27
|
+
lines.push(`**Description:** ${plan.context.description}`);
|
|
28
|
+
lines.push("");
|
|
29
|
+
if (plan.context.background) {
|
|
30
|
+
lines.push("**Background:**");
|
|
31
|
+
lines.push("");
|
|
32
|
+
lines.push(plan.context.background);
|
|
33
|
+
lines.push("");
|
|
34
|
+
}
|
|
35
|
+
lines.push("## Specification");
|
|
36
|
+
lines.push("");
|
|
37
|
+
lines.push(plan.specMarkdown);
|
|
38
|
+
lines.push("");
|
|
39
|
+
if (plan.fileStructure.length > 0) {
|
|
40
|
+
lines.push("## Files");
|
|
41
|
+
lines.push("");
|
|
42
|
+
lines.push("| Path | Action | Purpose |");
|
|
43
|
+
lines.push("|------|--------|---------|");
|
|
44
|
+
for (const file of plan.fileStructure) lines.push(`| \`${file.path}\` | ${file.type} | ${file.purpose} |`);
|
|
45
|
+
lines.push("");
|
|
46
|
+
}
|
|
47
|
+
lines.push("## Implementation Steps");
|
|
48
|
+
lines.push("");
|
|
49
|
+
for (const step of plan.steps) {
|
|
50
|
+
lines.push(`### Step ${step.order}: ${step.title}`);
|
|
51
|
+
lines.push("");
|
|
52
|
+
lines.push(step.description);
|
|
53
|
+
lines.push("");
|
|
54
|
+
if (step.acceptanceCriteria.length > 0) {
|
|
55
|
+
lines.push("**Acceptance Criteria:**");
|
|
56
|
+
lines.push("");
|
|
57
|
+
for (const criteria of step.acceptanceCriteria) lines.push(`- ${criteria}`);
|
|
58
|
+
lines.push("");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
lines.push("## Constraints");
|
|
62
|
+
lines.push("");
|
|
63
|
+
if (plan.constraints.policy.length > 0) {
|
|
64
|
+
lines.push("**Policy:**");
|
|
65
|
+
for (const p of plan.constraints.policy) lines.push(`- ${p}`);
|
|
66
|
+
lines.push("");
|
|
67
|
+
}
|
|
68
|
+
if (plan.constraints.security.length > 0) {
|
|
69
|
+
lines.push("**Security:**");
|
|
70
|
+
for (const s of plan.constraints.security) lines.push(`- ${s}`);
|
|
71
|
+
lines.push("");
|
|
72
|
+
}
|
|
73
|
+
if (plan.constraints.pii.length > 0) {
|
|
74
|
+
lines.push("**PII Fields (handle with care):**");
|
|
75
|
+
for (const pii of plan.constraints.pii) lines.push(`- \`${pii}\``);
|
|
76
|
+
lines.push("");
|
|
77
|
+
}
|
|
78
|
+
lines.push("## Verification");
|
|
79
|
+
lines.push("");
|
|
80
|
+
lines.push("After implementation, verify:");
|
|
81
|
+
lines.push("");
|
|
82
|
+
for (const check of plan.verificationChecklist) lines.push(`- [ ] ${check}`);
|
|
83
|
+
lines.push("");
|
|
84
|
+
return {
|
|
85
|
+
agent: "generic-mcp",
|
|
86
|
+
systemPrompt: AGENT_SYSTEM_PROMPTS["generic-mcp"],
|
|
87
|
+
taskPrompt: lines.join("\n")
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Format the plan as an MCP resource.
|
|
92
|
+
* Returns JSON that can be served as an MCP resource.
|
|
93
|
+
*/
|
|
94
|
+
formatAsResource(plan) {
|
|
95
|
+
return {
|
|
96
|
+
uri: `spec://${plan.target.name}/v${plan.target.version}/plan`,
|
|
97
|
+
mimeType: "application/json",
|
|
98
|
+
data: JSON.stringify({
|
|
99
|
+
target: plan.target,
|
|
100
|
+
context: plan.context,
|
|
101
|
+
fileStructure: plan.fileStructure,
|
|
102
|
+
steps: plan.steps,
|
|
103
|
+
constraints: plan.constraints,
|
|
104
|
+
verificationChecklist: plan.verificationChecklist
|
|
105
|
+
}, null, 2)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Format the plan as an MCP prompt message.
|
|
110
|
+
*/
|
|
111
|
+
formatAsPromptMessage(plan) {
|
|
112
|
+
return {
|
|
113
|
+
role: "user",
|
|
114
|
+
content: {
|
|
115
|
+
type: "text",
|
|
116
|
+
text: this.formatPlan(plan).taskPrompt
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Generate configuration (generic markdown for any agent).
|
|
122
|
+
*/
|
|
123
|
+
generateConfig(spec) {
|
|
124
|
+
const m = spec.meta;
|
|
125
|
+
const lines = [];
|
|
126
|
+
lines.push(`# ${m.name} v${m.version}`);
|
|
127
|
+
lines.push("");
|
|
128
|
+
lines.push(`**Type:** ${m.kind}`);
|
|
129
|
+
lines.push(`**Stability:** ${m.stability}`);
|
|
130
|
+
lines.push("");
|
|
131
|
+
lines.push("## Goal");
|
|
132
|
+
lines.push("");
|
|
133
|
+
lines.push(m.goal);
|
|
134
|
+
lines.push("");
|
|
135
|
+
lines.push("## Description");
|
|
136
|
+
lines.push("");
|
|
137
|
+
lines.push(m.description);
|
|
138
|
+
lines.push("");
|
|
139
|
+
return lines.join("\n");
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Parse agent output - generic implementation.
|
|
143
|
+
*/
|
|
144
|
+
parseOutput(output) {
|
|
145
|
+
const codeBlockMatch = output.match(/```(?:typescript|ts|tsx|javascript|js|python|go|rust)?\n([\s\S]*?)\n```/);
|
|
146
|
+
if (codeBlockMatch?.[1]) return { code: codeBlockMatch[1] };
|
|
147
|
+
try {
|
|
148
|
+
const parsed = JSON.parse(output);
|
|
149
|
+
if (typeof parsed.code === "string") return { code: parsed.code };
|
|
150
|
+
if (typeof parsed.errors === "object") return { errors: Array.isArray(parsed.errors) ? parsed.errors : [String(parsed.errors)] };
|
|
151
|
+
} catch {}
|
|
152
|
+
return { code: output };
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
/** Singleton instance */
|
|
156
|
+
const genericMCPAdapter = new GenericMCPAdapter();
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
export { GenericMCPAdapter, genericMCPAdapter };
|
|
@@ -1 +1,30 @@
|
|
|
1
|
-
import{ClaudeCodeAdapter
|
|
1
|
+
import { ClaudeCodeAdapter, claudeCodeAdapter } from "./claude-code.js";
|
|
2
|
+
import { CursorCLIAdapter, cursorCLIAdapter } from "./cursor-cli.js";
|
|
3
|
+
import { GenericMCPAdapter, genericMCPAdapter } from "./generic-mcp.js";
|
|
4
|
+
|
|
5
|
+
//#region src/services/agent-guide/adapters/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* Registry of all available agent adapters.
|
|
8
|
+
*/
|
|
9
|
+
const agentAdapters = {
|
|
10
|
+
"claude-code": claudeCodeAdapter,
|
|
11
|
+
"cursor-cli": cursorCLIAdapter,
|
|
12
|
+
"generic-mcp": genericMCPAdapter
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Get an adapter for a specific agent type.
|
|
16
|
+
*/
|
|
17
|
+
function getAgentAdapter(agent) {
|
|
18
|
+
const adapter = agentAdapters[agent];
|
|
19
|
+
if (!adapter) throw new Error(`Unknown agent type: ${agent}`);
|
|
20
|
+
return adapter;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* List all available agent types.
|
|
24
|
+
*/
|
|
25
|
+
function listAgentTypes() {
|
|
26
|
+
return Object.keys(agentAdapters);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { agentAdapters, getAgentAdapter, listAgentTypes };
|