@lssm/bundle.contractspec-workspace 0.0.0-canary-20251217083314 → 1.41.1
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 +1 -22
- package/dist/adapters/ai.js +1 -82
- package/dist/adapters/factory.js +1 -36
- package/dist/adapters/fs.js +1 -118
- package/dist/adapters/git.js +1 -54
- package/dist/adapters/index.js +1 -7
- package/dist/adapters/logger.js +1 -80
- package/dist/adapters/watcher.js +1 -69
- package/dist/adapters/workspace.js +2 -190
- package/dist/ai/agents/claude-code-agent.js +9 -146
- package/dist/ai/agents/cursor-agent.js +17 -286
- package/dist/ai/agents/index.js +1 -5
- package/dist/ai/agents/openai-codex-agent.js +8 -140
- package/dist/ai/agents/orchestrator.js +1 -142
- package/dist/ai/agents/simple-agent.js +4 -80
- package/dist/ai/client.js +1 -162
- package/dist/ai/index.js +1 -27
- package/dist/ai/prompts/code-generation.js +13 -55
- package/dist/ai/prompts/index.js +1 -12
- package/dist/ai/prompts/spec-creation.js +20 -61
- package/dist/ai/providers.js +1 -40
- package/dist/formatters/index.js +1 -18
- package/dist/formatters/json.js +1 -71
- package/dist/formatters/sarif.js +1 -163
- package/dist/formatters/text.js +2 -208
- package/dist/index.js +1 -81
- package/dist/services/agent-guide/adapters/claude-code.js +3 -144
- package/dist/services/agent-guide/adapters/cursor-cli.js +3 -135
- package/dist/services/agent-guide/adapters/generic-mcp.js +3 -159
- package/dist/services/agent-guide/adapters/index.js +1 -30
- package/dist/services/agent-guide/agent-guide-service.js +1 -148
- package/dist/services/agent-guide/index.js +1 -5
- package/dist/services/build.js +1 -140
- package/dist/services/ci-check/ci-check-service.js +1 -393
- package/dist/services/ci-check/index.js +1 -2
- package/dist/services/ci-check/types.js +1 -28
- package/dist/services/clean.js +1 -71
- package/dist/services/config.js +1 -76
- package/dist/services/deps.js +1 -62
- package/dist/services/diff.js +1 -33
- package/dist/services/doctor/checks/ai.js +2 -118
- package/dist/services/doctor/checks/cli.js +1 -146
- package/dist/services/doctor/checks/config.js +1 -170
- package/dist/services/doctor/checks/deps.js +1 -180
- package/dist/services/doctor/checks/index.js +1 -6
- package/dist/services/doctor/checks/mcp.js +1 -144
- package/dist/services/doctor/checks/workspace.js +1 -243
- package/dist/services/doctor/doctor-service.js +2 -115
- package/dist/services/doctor/index.js +1 -2
- package/dist/services/doctor/types.js +1 -26
- package/dist/services/implementation/discovery.js +2 -143
- package/dist/services/implementation/index.js +1 -2
- package/dist/services/implementation/resolver.js +1 -223
- package/dist/services/index.js +1 -53
- package/dist/services/integrity-diagram.js +6 -274
- package/dist/services/integrity.js +1 -272
- package/dist/services/list.js +1 -35
- package/dist/services/openapi/export-service.js +2 -51
- package/dist/services/openapi/import-service.js +1 -75
- package/dist/services/openapi/index.js +1 -4
- package/dist/services/openapi/sync-service.js +1 -121
- package/dist/services/openapi/validate-service.js +1 -130
- package/dist/services/regenerator.js +1 -23
- package/dist/services/registry.js +1 -73
- package/dist/services/setup/config-generators.js +26 -113
- package/dist/services/setup/file-merger.js +2 -60
- package/dist/services/setup/index.js +1 -4
- package/dist/services/setup/setup-service.js +1 -95
- package/dist/services/setup/targets/agents-md.js +1 -46
- package/dist/services/setup/targets/cli-config.js +1 -59
- package/dist/services/setup/targets/cursor-rules.js +1 -47
- package/dist/services/setup/targets/mcp-claude.js +1 -59
- package/dist/services/setup/targets/mcp-cursor.js +1 -58
- package/dist/services/setup/targets/vscode-settings.js +1 -62
- package/dist/services/setup/types.js +1 -26
- package/dist/services/sync.js +1 -62
- package/dist/services/test.js +1 -30
- package/dist/services/validate-implementation.js +1 -69
- package/dist/services/validate.js +1 -47
- package/dist/services/verification-cache/adapters/filesystem.js +1 -121
- package/dist/services/verification-cache/adapters/in-memory.js +1 -45
- package/dist/services/verification-cache/adapters/index.js +1 -3
- package/dist/services/verification-cache/adapters/workspace-state.js +1 -90
- package/dist/services/verification-cache/cache-service.js +1 -255
- package/dist/services/verification-cache/index.js +1 -6
- package/dist/services/verification-cache/types.js +1 -15
- package/dist/services/verify/ai-verifier.js +9 -336
- package/dist/services/verify/behavior-verifier.js +1 -185
- package/dist/services/verify/index.js +1 -4
- package/dist/services/verify/structure-verifier.js +2 -195
- package/dist/services/verify/verify-service.js +3 -203
- package/dist/services/watch.js +1 -31
- package/dist/services/workspace-info.js +2 -102
- package/dist/templates/app-config.template.js +28 -101
- package/dist/templates/data-view.template.js +27 -42
- package/dist/templates/event.template.js +14 -29
- package/dist/templates/experiment.template.js +51 -77
- package/dist/templates/handler.template.js +17 -53
- package/dist/templates/index.js +1 -36
- package/dist/templates/integration.template.js +50 -134
- package/dist/templates/knowledge.template.js +21 -62
- package/dist/templates/migration.template.js +26 -50
- package/dist/templates/operation.template.js +28 -44
- package/dist/templates/presentation.template.js +20 -46
- package/dist/templates/telemetry.template.js +53 -74
- package/dist/templates/workflow-runner.template.js +6 -12
- package/dist/templates/workflow.template.js +24 -51
- package/package.json +10 -15
- package/dist/adapters/ai.d.ts +0 -11
- package/dist/adapters/factory.d.ts +0 -28
- package/dist/adapters/fs.d.ts +0 -10
- package/dist/adapters/git.d.ts +0 -10
- package/dist/adapters/logger.d.ts +0 -17
- package/dist/adapters/watcher.d.ts +0 -10
- package/dist/adapters/workspace.d.ts +0 -93
- package/dist/ai/agents/claude-code-agent.d.ts +0 -21
- package/dist/ai/agents/cursor-agent.d.ts +0 -67
- package/dist/ai/agents/openai-codex-agent.d.ts +0 -21
- package/dist/ai/agents/orchestrator.d.ts +0 -49
- package/dist/ai/agents/simple-agent.d.ts +0 -16
- package/dist/ai/agents/types.d.ts +0 -35
- package/dist/ai/client.d.ts +0 -82
- package/dist/ai/index.d.ts +0 -16
- package/dist/ai/prompts/code-generation.d.ts +0 -25
- package/dist/ai/prompts/index.d.ts +0 -9
- package/dist/ai/prompts/spec-creation.d.ts +0 -28
- package/dist/ai/providers.d.ts +0 -28
- package/dist/formatters/index.d.ts +0 -10
- package/dist/formatters/json.d.ts +0 -88
- package/dist/formatters/sarif.d.ts +0 -100
- package/dist/formatters/text.d.ts +0 -34
- package/dist/index.d.ts +0 -66
- package/dist/libs/ai-providers/dist/factory.js +0 -154
- package/dist/libs/ai-providers/dist/index.js +0 -4
- package/dist/libs/ai-providers/dist/legacy.js +0 -72
- package/dist/libs/ai-providers/dist/models.js +0 -287
- package/dist/libs/ai-providers/dist/validation.js +0 -1
- package/dist/libs/contracts/dist/capabilities/openbanking.js +0 -88
- package/dist/libs/contracts/dist/client/index.js +0 -5
- package/dist/libs/contracts/dist/client/react/feature-render.js +0 -2
- package/dist/libs/contracts/dist/client/react/form-render.js +0 -4
- package/dist/libs/contracts/dist/client/react/index.js +0 -4
- package/dist/libs/contracts/dist/contract-registry/index.js +0 -1
- package/dist/libs/contracts/dist/contract-registry/schemas.js +0 -60
- package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/index.js +0 -29
- package/dist/libs/contracts/dist/docs/presentations.js +0 -71
- package/dist/libs/contracts/dist/docs/registry.js +0 -44
- package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +0 -80
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +0 -57
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +0 -357
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +0 -37
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +0 -20
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +0 -48
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +0 -79
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +0 -84
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +0 -45
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +0 -67
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +0 -40
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +0 -69
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +0 -47
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +0 -62
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +0 -155
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +0 -20
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +0 -101
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +0 -20
- package/dist/libs/contracts/dist/events.js +0 -8
- package/dist/libs/contracts/dist/experiments/evaluator.js +0 -1
- package/dist/libs/contracts/dist/index.js +0 -72
- package/dist/libs/contracts/dist/install.js +0 -2
- package/dist/libs/contracts/dist/integrations/contracts.js +0 -377
- package/dist/libs/contracts/dist/integrations/index.js +0 -18
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +0 -228
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +0 -159
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +0 -3
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +0 -210
- package/dist/libs/contracts/dist/integrations/openbanking/models.js +0 -242
- package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +0 -13
- package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +0 -52
- package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +0 -75
- package/dist/libs/contracts/dist/integrations/providers/gmail.js +0 -87
- package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +0 -66
- package/dist/libs/contracts/dist/integrations/providers/index.js +0 -11
- package/dist/libs/contracts/dist/integrations/providers/mistral.js +0 -68
- package/dist/libs/contracts/dist/integrations/providers/postmark.js +0 -68
- package/dist/libs/contracts/dist/integrations/providers/powens.js +0 -116
- package/dist/libs/contracts/dist/integrations/providers/qdrant.js +0 -73
- package/dist/libs/contracts/dist/integrations/providers/registry.js +0 -10
- package/dist/libs/contracts/dist/integrations/providers/stripe.js +0 -83
- package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +0 -61
- package/dist/libs/contracts/dist/jsonschema.js +0 -24
- package/dist/libs/contracts/dist/knowledge/contracts.js +0 -306
- package/dist/libs/contracts/dist/knowledge/index.js +0 -7
- package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +0 -34
- package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +0 -34
- package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +0 -38
- package/dist/libs/contracts/dist/knowledge/spaces/index.js +0 -6
- package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +0 -34
- package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +0 -37
- package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +0 -34
- package/dist/libs/contracts/dist/llm/exporters.js +0 -352
- package/dist/libs/contracts/dist/llm/index.js +0 -2
- package/dist/libs/contracts/dist/llm/prompts.js +0 -211
- package/dist/libs/contracts/dist/onboarding-base.js +0 -196
- package/dist/libs/contracts/dist/openapi.js +0 -75
- package/dist/libs/contracts/dist/ownership.js +0 -21
- package/dist/libs/contracts/dist/presentations.js +0 -1
- package/dist/libs/contracts/dist/presentations.v2.js +0 -11
- package/dist/libs/contracts/dist/prompt.js +0 -1
- package/dist/libs/contracts/dist/promptRegistry.js +0 -1
- package/dist/libs/contracts/dist/regenerator/index.js +0 -2
- package/dist/libs/contracts/dist/regenerator/service.js +0 -92
- package/dist/libs/contracts/dist/regenerator/utils.js +0 -51
- package/dist/libs/contracts/dist/registry.js +0 -208
- package/dist/libs/contracts/dist/resources.js +0 -1
- package/dist/libs/contracts/dist/schema/dist/EnumType.js +0 -2
- package/dist/libs/contracts/dist/schema/dist/FieldType.js +0 -49
- package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +0 -236
- package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +0 -34
- package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +0 -1
- package/dist/libs/contracts/dist/schema/dist/entity/index.js +0 -2
- package/dist/libs/contracts/dist/schema/dist/entity/types.js +0 -1
- package/dist/libs/contracts/dist/schema/dist/index.js +0 -6
- package/dist/libs/contracts/dist/server/graphql-pothos.js +0 -6
- package/dist/libs/contracts/dist/server/index.js +0 -8
- package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +0 -4
- package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +0 -2
- package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +0 -1
- package/dist/libs/contracts/dist/server/mcp/registerResources.js +0 -2
- package/dist/libs/contracts/dist/server/mcp/registerTools.js +0 -1
- package/dist/libs/contracts/dist/server/provider-mcp.js +0 -1
- package/dist/libs/contracts/dist/server/rest-elysia.js +0 -1
- package/dist/libs/contracts/dist/server/rest-express.js +0 -1
- package/dist/libs/contracts/dist/server/rest-generic.js +0 -1
- package/dist/libs/contracts/dist/server/rest-next-app.js +0 -1
- package/dist/libs/contracts/dist/server/rest-next-pages.js +0 -1
- package/dist/libs/contracts/dist/spec.js +0 -35
- package/dist/libs/contracts/dist/telemetry/index.js +0 -1
- package/dist/libs/contracts/dist/telemetry/tracker.js +0 -1
- package/dist/libs/contracts/dist/tests/index.js +0 -1
- package/dist/libs/contracts/dist/tests/runner.js +0 -150
- package/dist/libs/contracts/dist/workflow/index.js +0 -1
- package/dist/libs/contracts/dist/workflow/runner.js +0 -1
- package/dist/libs/contracts-transformers/dist/common/utils.js +0 -47
- package/dist/libs/contracts-transformers/dist/openapi/exporter.js +0 -1
- package/dist/libs/contracts-transformers/dist/openapi/importer.js +0 -255
- package/dist/libs/contracts-transformers/dist/openapi/index.js +0 -4
- package/dist/libs/contracts-transformers/dist/openapi/parser.js +0 -231
- package/dist/libs/contracts-transformers/dist/openapi/schema-converter.js +0 -201
- package/dist/modules/contractspec-workspace/dist/ai/code-generation.js +0 -137
- package/dist/modules/contractspec-workspace/dist/ai/spec-creation.js +0 -101
- package/dist/modules/contractspec-workspace/dist/analysis/deps/graph.js +0 -84
- package/dist/modules/contractspec-workspace/dist/analysis/deps/parse-imports.js +0 -30
- package/dist/modules/contractspec-workspace/dist/analysis/diff/semantic.js +0 -96
- package/dist/modules/contractspec-workspace/dist/analysis/feature-scan.js +0 -151
- package/dist/modules/contractspec-workspace/dist/analysis/spec-scan.js +0 -344
- package/dist/modules/contractspec-workspace/dist/analysis/validate/spec-structure.js +0 -122
- package/dist/modules/contractspec-workspace/dist/templates/app-config.js +0 -105
- package/dist/modules/contractspec-workspace/dist/templates/data-view.js +0 -68
- package/dist/modules/contractspec-workspace/dist/templates/event.js +0 -38
- package/dist/modules/contractspec-workspace/dist/templates/experiment.js +0 -87
- package/dist/modules/contractspec-workspace/dist/templates/handler.js +0 -95
- package/dist/modules/contractspec-workspace/dist/templates/integration-utils.js +0 -104
- package/dist/modules/contractspec-workspace/dist/templates/integration.js +0 -62
- package/dist/modules/contractspec-workspace/dist/templates/knowledge.js +0 -68
- package/dist/modules/contractspec-workspace/dist/templates/migration.js +0 -60
- package/dist/modules/contractspec-workspace/dist/templates/operation.js +0 -100
- package/dist/modules/contractspec-workspace/dist/templates/presentation.js +0 -78
- package/dist/modules/contractspec-workspace/dist/templates/telemetry.js +0 -89
- package/dist/modules/contractspec-workspace/dist/templates/utils.js +0 -38
- package/dist/modules/contractspec-workspace/dist/templates/workflow-runner.js +0 -48
- package/dist/modules/contractspec-workspace/dist/templates/workflow.js +0 -67
- package/dist/modules/contractspec-workspace/dist/types/generation-types.js +0 -20
- package/dist/ports/ai.d.ts +0 -58
- package/dist/ports/fs.d.ts +0 -80
- package/dist/ports/git.d.ts +0 -32
- package/dist/ports/logger.d.ts +0 -87
- package/dist/ports/watcher.d.ts +0 -51
- package/dist/services/agent-guide/adapters/claude-code.d.ts +0 -34
- package/dist/services/agent-guide/adapters/cursor-cli.d.ts +0 -38
- package/dist/services/agent-guide/adapters/generic-mcp.d.ts +0 -52
- package/dist/services/agent-guide/adapters/index.d.ts +0 -22
- package/dist/services/agent-guide/agent-guide-service.d.ts +0 -55
- package/dist/services/agent-guide/types.d.ts +0 -57
- package/dist/services/build.d.ts +0 -58
- package/dist/services/ci-check/ci-check-service.d.ts +0 -15
- package/dist/services/ci-check/types.d.ts +0 -142
- package/dist/services/clean.d.ts +0 -40
- package/dist/services/config.d.ts +0 -25
- package/dist/services/deps.d.ts +0 -52
- package/dist/services/diff.d.ts +0 -33
- package/dist/services/doctor/doctor-service.d.ts +0 -23
- package/dist/services/doctor/types.d.ts +0 -117
- package/dist/services/implementation/discovery.d.ts +0 -29
- package/dist/services/implementation/resolver.d.ts +0 -43
- package/dist/services/implementation/types.d.ts +0 -78
- package/dist/services/integrity-diagram.d.ts +0 -35
- package/dist/services/integrity.d.ts +0 -133
- package/dist/services/list.d.ts +0 -30
- package/dist/services/openapi/export-service.d.ts +0 -52
- package/dist/services/openapi/import-service.d.ts +0 -15
- package/dist/services/openapi/sync-service.d.ts +0 -18
- package/dist/services/openapi/types.d.ts +0 -184
- package/dist/services/openapi/validate-service.d.ts +0 -15
- package/dist/services/regenerator.d.ts +0 -17
- package/dist/services/registry.d.ts +0 -52
- package/dist/services/setup/config-generators.d.ts +0 -41
- package/dist/services/setup/file-merger.d.ts +0 -26
- package/dist/services/setup/setup-service.d.ts +0 -11
- package/dist/services/setup/types.d.ts +0 -84
- package/dist/services/sync.d.ts +0 -40
- package/dist/services/test.d.ts +0 -14
- package/dist/services/validate-implementation.d.ts +0 -31
- package/dist/services/validate.d.ts +0 -40
- package/dist/services/verification-cache/adapters/filesystem.d.ts +0 -45
- package/dist/services/verification-cache/adapters/in-memory.d.ts +0 -26
- package/dist/services/verification-cache/adapters/workspace-state.d.ts +0 -48
- package/dist/services/verification-cache/cache-service.d.ts +0 -69
- package/dist/services/verification-cache/types.d.ts +0 -123
- package/dist/services/verify/ai-verifier.d.ts +0 -24
- package/dist/services/verify/behavior-verifier.d.ts +0 -11
- package/dist/services/verify/structure-verifier.d.ts +0 -11
- package/dist/services/verify/types.d.ts +0 -136
- package/dist/services/verify/verify-service.d.ts +0 -59
- package/dist/services/watch.d.ts +0 -24
- package/dist/services/workspace-info.d.ts +0 -61
- package/dist/templates/app-config.template.d.ts +0 -6
- package/dist/templates/data-view.template.d.ts +0 -6
- package/dist/templates/event.template.d.ts +0 -10
- package/dist/templates/experiment.template.d.ts +0 -6
- package/dist/templates/handler.template.d.ts +0 -15
- package/dist/templates/index.d.ts +0 -20
- package/dist/templates/integration.template.d.ts +0 -6
- package/dist/templates/knowledge.template.d.ts +0 -6
- package/dist/templates/migration.template.d.ts +0 -6
- package/dist/templates/operation.template.d.ts +0 -10
- package/dist/templates/presentation.template.d.ts +0 -10
- package/dist/templates/telemetry.template.d.ts +0 -6
- package/dist/templates/workflow-runner.template.d.ts +0 -15
- package/dist/templates/workflow.template.d.ts +0 -6
- package/dist/types/config.d.ts +0 -33
- package/dist/types.d.ts +0 -323
|
@@ -1,159 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
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
|
+
import{AGENT_SYSTEM_PROMPTS as e}from"@lssm/lib.contracts/llm";var t=class{agentType=`generic-mcp`;formatPlan(t){let n=[];if(n.push(`# Implementation Task: ${t.target.name}.v${t.target.version}`),n.push(``),n.push(`## Task`),n.push(``),n.push(`Implement the ${t.target.type} \`${t.target.name}\` version ${t.target.version}.`),n.push(``),n.push(`## Context`),n.push(``),n.push(`**Goal:** ${t.context.goal}`),n.push(``),n.push(`**Description:** ${t.context.description}`),n.push(``),t.context.background&&(n.push(`**Background:**`),n.push(``),n.push(t.context.background),n.push(``)),n.push(`## Specification`),n.push(``),n.push(t.specMarkdown),n.push(``),t.fileStructure.length>0){n.push(`## Files`),n.push(``),n.push(`| Path | Action | Purpose |`),n.push(`|------|--------|---------|`);for(let e of t.fileStructure)n.push(`| \`${e.path}\` | ${e.type} | ${e.purpose} |`);n.push(``)}n.push(`## Implementation Steps`),n.push(``);for(let e of t.steps)if(n.push(`### Step ${e.order}: ${e.title}`),n.push(``),n.push(e.description),n.push(``),e.acceptanceCriteria.length>0){n.push(`**Acceptance Criteria:**`),n.push(``);for(let t of e.acceptanceCriteria)n.push(`- ${t}`);n.push(``)}if(n.push(`## Constraints`),n.push(``),t.constraints.policy.length>0){n.push(`**Policy:**`);for(let e of t.constraints.policy)n.push(`- ${e}`);n.push(``)}if(t.constraints.security.length>0){n.push(`**Security:**`);for(let e of t.constraints.security)n.push(`- ${e}`);n.push(``)}if(t.constraints.pii.length>0){n.push(`**PII Fields (handle with care):**`);for(let e of t.constraints.pii)n.push(`- \`${e}\``);n.push(``)}n.push(`## Verification`),n.push(``),n.push(`After implementation, verify:`),n.push(``);for(let e of t.verificationChecklist)n.push(`- [ ] ${e}`);return n.push(``),{agent:`generic-mcp`,systemPrompt:e[`generic-mcp`],taskPrompt:n.join(`
|
|
2
|
+
`)}}formatAsResource(e){return{uri:`spec://${e.target.name}/v${e.target.version}/plan`,mimeType:`application/json`,data:JSON.stringify({target:e.target,context:e.context,fileStructure:e.fileStructure,steps:e.steps,constraints:e.constraints,verificationChecklist:e.verificationChecklist},null,2)}}formatAsPromptMessage(e){return{role:`user`,content:{type:`text`,text:this.formatPlan(e).taskPrompt}}}generateConfig(e){let t=e.meta,n=[];return n.push(`# ${t.name} v${t.version}`),n.push(``),n.push(`**Type:** ${t.kind}`),n.push(`**Stability:** ${t.stability}`),n.push(``),n.push(`## Goal`),n.push(``),n.push(t.goal),n.push(``),n.push(`## Description`),n.push(``),n.push(t.description),n.push(``),n.join(`
|
|
3
|
+
`)}parseOutput(e){let t=e.match(/```(?:typescript|ts|tsx|javascript|js|python|go|rust)?\n([\s\S]*?)\n```/);if(t?.[1])return{code:t[1]};try{let t=JSON.parse(e);if(typeof t.code==`string`)return{code:t.code};if(typeof t.errors==`object`)return{errors:Array.isArray(t.errors)?t.errors:[String(t.errors)]}}catch{}return{code:e}}};const n=new t;export{t as GenericMCPAdapter,n as genericMCPAdapter};
|
|
@@ -1,30 +1 @@
|
|
|
1
|
-
import
|
|
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 };
|
|
1
|
+
import{ClaudeCodeAdapter as e,claudeCodeAdapter as t}from"./claude-code.js";import{CursorCLIAdapter as n,cursorCLIAdapter as r}from"./cursor-cli.js";import{GenericMCPAdapter as i,genericMCPAdapter as a}from"./generic-mcp.js";const o={"claude-code":t,"cursor-cli":r,"generic-mcp":a};function s(e){let t=o[e];if(!t)throw Error(`Unknown agent type: ${e}`);return t}function c(){return Object.keys(o)}export{o as agentAdapters,s as getAgentAdapter,c as listAgentTypes};
|
|
@@ -1,148 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { generateImplementationPlan } from "../../libs/contracts/dist/llm/prompts.js";
|
|
3
|
-
import "../../libs/contracts/dist/llm/index.js";
|
|
4
|
-
import { getAgentAdapter, listAgentTypes } from "./adapters/index.js";
|
|
5
|
-
|
|
6
|
-
//#region src/services/agent-guide/agent-guide-service.ts
|
|
7
|
-
const DEFAULT_CONFIG = {
|
|
8
|
-
defaultAgent: "generic-mcp",
|
|
9
|
-
verbose: false
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Agent Guide Service
|
|
13
|
-
*
|
|
14
|
-
* Main service for generating implementation guidance for AI coding agents.
|
|
15
|
-
*/
|
|
16
|
-
var AgentGuideService = class {
|
|
17
|
-
config;
|
|
18
|
-
constructor(config = {}) {
|
|
19
|
-
this.config = {
|
|
20
|
-
...DEFAULT_CONFIG,
|
|
21
|
-
...config
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Generate an implementation guide for a spec.
|
|
26
|
-
*/
|
|
27
|
-
generateGuide(spec, options = {}) {
|
|
28
|
-
const adapter = getAgentAdapter(options.agent ?? this.config.defaultAgent);
|
|
29
|
-
const plan = generateImplementationPlan(spec, {
|
|
30
|
-
projectRoot: this.config.projectRoot,
|
|
31
|
-
existingFiles: options.targetPath ? [options.targetPath] : void 0
|
|
32
|
-
});
|
|
33
|
-
return {
|
|
34
|
-
plan,
|
|
35
|
-
prompt: adapter.formatPlan(plan),
|
|
36
|
-
markdown: specToFullMarkdown(spec)
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Generate a guide for a feature (includes all related specs).
|
|
41
|
-
*/
|
|
42
|
-
generateFeatureGuide(feature, deps, options = {}) {
|
|
43
|
-
const adapter = getAgentAdapter(options.agent ?? this.config.defaultAgent);
|
|
44
|
-
const firstOp = feature.operations?.[0];
|
|
45
|
-
const spec = firstOp ? deps.specs?.getSpec(firstOp.name, firstOp.version) : void 0;
|
|
46
|
-
let plan;
|
|
47
|
-
if (spec) {
|
|
48
|
-
plan = generateImplementationPlan(spec, { projectRoot: this.config.projectRoot });
|
|
49
|
-
plan.target = {
|
|
50
|
-
type: "feature",
|
|
51
|
-
name: feature.meta.key,
|
|
52
|
-
version: 1
|
|
53
|
-
};
|
|
54
|
-
plan.context.goal = feature.meta.description ?? plan.context.goal;
|
|
55
|
-
} else plan = {
|
|
56
|
-
target: {
|
|
57
|
-
type: "feature",
|
|
58
|
-
name: feature.meta.key,
|
|
59
|
-
version: 1
|
|
60
|
-
},
|
|
61
|
-
context: {
|
|
62
|
-
goal: feature.meta.description ?? `Implement feature ${feature.meta.key}`,
|
|
63
|
-
description: feature.meta.title ?? feature.meta.key,
|
|
64
|
-
background: ""
|
|
65
|
-
},
|
|
66
|
-
specMarkdown: featureToMarkdown(feature, deps),
|
|
67
|
-
fileStructure: [],
|
|
68
|
-
steps: [{
|
|
69
|
-
order: 1,
|
|
70
|
-
title: "Implement Feature",
|
|
71
|
-
description: `Implement the ${feature.meta.key} feature`,
|
|
72
|
-
acceptanceCriteria: []
|
|
73
|
-
}],
|
|
74
|
-
constraints: {
|
|
75
|
-
policy: [],
|
|
76
|
-
security: [],
|
|
77
|
-
pii: []
|
|
78
|
-
},
|
|
79
|
-
verificationChecklist: []
|
|
80
|
-
};
|
|
81
|
-
plan.specMarkdown = featureToMarkdown(feature, deps, {
|
|
82
|
-
format: "full",
|
|
83
|
-
includeRelatedSpecs: true,
|
|
84
|
-
includeRelatedEvents: true,
|
|
85
|
-
includeRelatedPresentations: true
|
|
86
|
-
});
|
|
87
|
-
if (feature.operations?.length) plan.steps = feature.operations.map((op, idx) => ({
|
|
88
|
-
order: idx + 1,
|
|
89
|
-
title: `Implement ${op.name}`,
|
|
90
|
-
description: `Implement operation ${op.name}.v${op.version}`,
|
|
91
|
-
acceptanceCriteria: [`Operation ${op.name} works as specified`]
|
|
92
|
-
}));
|
|
93
|
-
const prompt = adapter.formatPlan(plan);
|
|
94
|
-
const markdown = featureToMarkdown(feature, deps);
|
|
95
|
-
return {
|
|
96
|
-
plan,
|
|
97
|
-
prompt,
|
|
98
|
-
markdown
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Generate agent-specific configuration (e.g., cursor rules).
|
|
103
|
-
*/
|
|
104
|
-
generateAgentConfig(spec, agent) {
|
|
105
|
-
return getAgentAdapter(agent ?? this.config.defaultAgent).generateConfig?.(spec);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Export a spec in a specific format for an agent.
|
|
109
|
-
*/
|
|
110
|
-
exportForAgent(spec, agent, taskType = "implement", existingCode) {
|
|
111
|
-
return specToAgentPrompt(spec, {
|
|
112
|
-
taskType,
|
|
113
|
-
existingCode
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* List available agent types.
|
|
118
|
-
*/
|
|
119
|
-
listAgentTypes() {
|
|
120
|
-
return listAgentTypes();
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Get the default agent type.
|
|
124
|
-
*/
|
|
125
|
-
getDefaultAgent() {
|
|
126
|
-
return this.config.defaultAgent;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Update configuration.
|
|
130
|
-
*/
|
|
131
|
-
configure(config) {
|
|
132
|
-
this.config = {
|
|
133
|
-
...this.config,
|
|
134
|
-
...config
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* Create a new AgentGuideService instance.
|
|
140
|
-
*/
|
|
141
|
-
function createAgentGuideService(config) {
|
|
142
|
-
return new AgentGuideService(config);
|
|
143
|
-
}
|
|
144
|
-
/** Default singleton instance */
|
|
145
|
-
const agentGuideService = new AgentGuideService();
|
|
146
|
-
|
|
147
|
-
//#endregion
|
|
148
|
-
export { AgentGuideService, agentGuideService, createAgentGuideService };
|
|
1
|
+
import{getAgentAdapter as e,listAgentTypes as t}from"./adapters/index.js";import{featureToMarkdown as n,generateImplementationPlan as r,specToAgentPrompt as i,specToFullMarkdown as a}from"@lssm/lib.contracts/llm";const o={defaultAgent:`generic-mcp`,verbose:!1};var s=class{config;constructor(e={}){this.config={...o,...e}}generateGuide(t,n={}){let i=e(n.agent??this.config.defaultAgent),o=r(t,{projectRoot:this.config.projectRoot,existingFiles:n.targetPath?[n.targetPath]:void 0});return{plan:o,prompt:i.formatPlan(o),markdown:a(t)}}generateFeatureGuide(t,i,a={}){let o=e(a.agent??this.config.defaultAgent),s=t.operations?.[0],c=s?i.specs?.getSpec(s.name,s.version):void 0,l;c?(l=r(c,{projectRoot:this.config.projectRoot}),l.target={type:`feature`,name:t.meta.key,version:1},l.context.goal=t.meta.description??l.context.goal):l={target:{type:`feature`,name:t.meta.key,version:1},context:{goal:t.meta.description??`Implement feature ${t.meta.key}`,description:t.meta.title??t.meta.key,background:``},specMarkdown:n(t,i),fileStructure:[],steps:[{order:1,title:`Implement Feature`,description:`Implement the ${t.meta.key} feature`,acceptanceCriteria:[]}],constraints:{policy:[],security:[],pii:[]},verificationChecklist:[]},l.specMarkdown=n(t,i,{format:`full`,includeRelatedSpecs:!0,includeRelatedEvents:!0,includeRelatedPresentations:!0}),t.operations?.length&&(l.steps=t.operations.map((e,t)=>({order:t+1,title:`Implement ${e.name}`,description:`Implement operation ${e.name}.v${e.version}`,acceptanceCriteria:[`Operation ${e.name} works as specified`]})));let u=o.formatPlan(l),d=n(t,i);return{plan:l,prompt:u,markdown:d}}generateAgentConfig(t,n){return e(n??this.config.defaultAgent).generateConfig?.(t)}exportForAgent(e,t,n=`implement`,r){return i(e,{taskType:n,existingCode:r})}listAgentTypes(){return t()}getDefaultAgent(){return this.config.defaultAgent}configure(e){this.config={...this.config,...e}}};function c(e){return new s(e)}const l=new s;export{s as AgentGuideService,l as agentGuideService,c as createAgentGuideService};
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CursorCLIAdapter, cursorCLIAdapter } from "./adapters/cursor-cli.js";
|
|
3
|
-
import { GenericMCPAdapter, genericMCPAdapter } from "./adapters/generic-mcp.js";
|
|
4
|
-
import { agentAdapters, getAgentAdapter, listAgentTypes } from "./adapters/index.js";
|
|
5
|
-
import { AgentGuideService, agentGuideService, createAgentGuideService } from "./agent-guide-service.js";
|
|
1
|
+
import{ClaudeCodeAdapter as e,claudeCodeAdapter as t}from"./adapters/claude-code.js";import{CursorCLIAdapter as n,cursorCLIAdapter as r}from"./adapters/cursor-cli.js";import{GenericMCPAdapter as i,genericMCPAdapter as a}from"./adapters/generic-mcp.js";import{agentAdapters as o,getAgentAdapter as s,listAgentTypes as c}from"./adapters/index.js";import{AgentGuideService as l,agentGuideService as u,createAgentGuideService as d}from"./agent-guide-service.js";
|
package/dist/services/build.js
CHANGED
|
@@ -1,140 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { generateComponentTemplate, generateHandlerTemplate, generateTestTemplate } from "../modules/contractspec-workspace/dist/templates/handler.js";
|
|
3
|
-
|
|
4
|
-
//#region src/services/build.ts
|
|
5
|
-
/**
|
|
6
|
-
* Build/scaffold service for generating implementation files from specs.
|
|
7
|
-
*
|
|
8
|
-
* Uses templates from @lssm/module.contractspec-workspace to generate
|
|
9
|
-
* handler, component, and test skeletons without requiring AI.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Build implementation files from a spec.
|
|
13
|
-
*/
|
|
14
|
-
async function buildSpec(specPath, adapters, config, options = {}) {
|
|
15
|
-
const { fs, logger } = adapters;
|
|
16
|
-
const { targets = detectDefaultTargets(specPath), outputDir = config.outputDir, overwrite = false, dryRun = false } = options;
|
|
17
|
-
const specCode = await fs.readFile(specPath);
|
|
18
|
-
const specInfo = scanSpecSource(specCode, specPath);
|
|
19
|
-
const specType = inferSpecTypeFromFilePath(specPath);
|
|
20
|
-
logger.info(`Building from spec: ${specPath}`, { specType });
|
|
21
|
-
const results = [];
|
|
22
|
-
for (const target of targets) try {
|
|
23
|
-
const result = await buildTarget(target, specPath, specCode, specInfo, specType, {
|
|
24
|
-
fs,
|
|
25
|
-
logger
|
|
26
|
-
}, outputDir, overwrite, dryRun);
|
|
27
|
-
results.push(result);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
results.push({
|
|
30
|
-
target,
|
|
31
|
-
outputPath: "",
|
|
32
|
-
success: false,
|
|
33
|
-
error: error instanceof Error ? error.message : String(error)
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
specPath,
|
|
38
|
-
specInfo,
|
|
39
|
-
results
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Build a single target from a spec.
|
|
44
|
-
*/
|
|
45
|
-
async function buildTarget(target, specPath, _specCode, specInfo, specType, adapters, outputDir, overwrite, dryRun) {
|
|
46
|
-
const { fs, logger } = adapters;
|
|
47
|
-
let code;
|
|
48
|
-
let outputPath;
|
|
49
|
-
switch (target) {
|
|
50
|
-
case "handler": {
|
|
51
|
-
if (specType !== "operation") return {
|
|
52
|
-
target,
|
|
53
|
-
outputPath: "",
|
|
54
|
-
success: false,
|
|
55
|
-
skipped: true,
|
|
56
|
-
error: `Handler generation only supported for operation specs (got ${specType})`
|
|
57
|
-
};
|
|
58
|
-
const kind = specInfo.kind === "command" || specInfo.kind === "query" ? specInfo.kind : "command";
|
|
59
|
-
code = generateHandlerTemplate(specInfo.name ?? "unknown", kind);
|
|
60
|
-
outputPath = resolveOutputPath(specPath, outputDir, "handlers", specInfo.name ?? "unknown", ".handler.ts", adapters.fs);
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
case "component":
|
|
64
|
-
if (specType !== "presentation") return {
|
|
65
|
-
target,
|
|
66
|
-
outputPath: "",
|
|
67
|
-
success: false,
|
|
68
|
-
skipped: true,
|
|
69
|
-
error: `Component generation only supported for presentation specs (got ${specType})`
|
|
70
|
-
};
|
|
71
|
-
code = generateComponentTemplate(specInfo.name ?? "unknown", specInfo.description ?? "");
|
|
72
|
-
outputPath = resolveOutputPath(specPath, outputDir, "components", specInfo.name ?? "unknown", ".tsx", adapters.fs);
|
|
73
|
-
break;
|
|
74
|
-
case "test": {
|
|
75
|
-
const testType = specType === "operation" ? "handler" : "component";
|
|
76
|
-
code = generateTestTemplate(specInfo.name ?? "unknown", testType);
|
|
77
|
-
outputPath = resolveOutputPath(specPath, outputDir, "__tests__", specInfo.name ?? "unknown", ".test.ts", adapters.fs);
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
default: return {
|
|
81
|
-
target,
|
|
82
|
-
outputPath: "",
|
|
83
|
-
success: false,
|
|
84
|
-
error: `Unknown target: ${target}`
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
if (await fs.exists(outputPath) && !overwrite) return {
|
|
88
|
-
target,
|
|
89
|
-
outputPath,
|
|
90
|
-
success: false,
|
|
91
|
-
skipped: true,
|
|
92
|
-
error: "File already exists (use overwrite option)"
|
|
93
|
-
};
|
|
94
|
-
if (dryRun) {
|
|
95
|
-
logger.info(`[dry-run] Would write: ${outputPath}`);
|
|
96
|
-
return {
|
|
97
|
-
target,
|
|
98
|
-
outputPath,
|
|
99
|
-
success: true
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
const dirPath = fs.dirname(outputPath);
|
|
103
|
-
await fs.mkdir(dirPath);
|
|
104
|
-
await fs.writeFile(outputPath, code);
|
|
105
|
-
logger.info(`Generated: ${outputPath}`);
|
|
106
|
-
return {
|
|
107
|
-
target,
|
|
108
|
-
outputPath,
|
|
109
|
-
success: true
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Detect default targets based on spec type.
|
|
114
|
-
*/
|
|
115
|
-
function detectDefaultTargets(specPath) {
|
|
116
|
-
switch (inferSpecTypeFromFilePath(specPath)) {
|
|
117
|
-
case "operation": return ["handler"];
|
|
118
|
-
case "presentation": return ["component"];
|
|
119
|
-
default: return [];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Resolve output path for generated file.
|
|
124
|
-
*/
|
|
125
|
-
function resolveOutputPath(specPath, outputDir, subdir, specName, extension, fs) {
|
|
126
|
-
const sanitizedName = toKebabCase(specName.split(".").pop() ?? "unknown");
|
|
127
|
-
let baseDir;
|
|
128
|
-
if (outputDir.startsWith(".")) baseDir = fs.resolve(fs.dirname(specPath), "..", outputDir, subdir);
|
|
129
|
-
else baseDir = fs.resolve(outputDir, subdir);
|
|
130
|
-
return fs.join(baseDir, `${sanitizedName}${extension}`);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Convert string to kebab-case.
|
|
134
|
-
*/
|
|
135
|
-
function toKebabCase(str) {
|
|
136
|
-
return str.replace(/\./g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
//#endregion
|
|
140
|
-
export { buildSpec };
|
|
1
|
+
import{generateComponentTemplate as e,generateHandlerTemplate as t,generateTestTemplate as n,inferSpecTypeFromFilePath as r,scanSpecSource as i}from"@lssm/module.contractspec-workspace";async function a(e,t,n,a={}){let{fs:c,logger:l}=t,{targets:u=s(e),outputDir:d=n.outputDir,overwrite:f=!1,dryRun:p=!1}=a,m=await c.readFile(e),h=i(m,e),g=r(e);l.info(`Building from spec: ${e}`,{specType:g});let _=[];for(let t of u)try{let n=await o(t,e,m,h,g,{fs:c,logger:l},d,f,p);_.push(n)}catch(e){_.push({target:t,outputPath:``,success:!1,error:e instanceof Error?e.message:String(e)})}return{specPath:e,specInfo:h,results:_}}async function o(r,i,a,o,s,l,u,d,f){let{fs:p,logger:m}=l,h,g;switch(r){case`handler`:{if(s!==`operation`)return{target:r,outputPath:``,success:!1,skipped:!0,error:`Handler generation only supported for operation specs (got ${s})`};let e=o.kind===`command`||o.kind===`query`?o.kind:`command`;h=t(o.name??`unknown`,e),g=c(i,u,`handlers`,o.name??`unknown`,`.handler.ts`,l.fs);break}case`component`:if(s!==`presentation`)return{target:r,outputPath:``,success:!1,skipped:!0,error:`Component generation only supported for presentation specs (got ${s})`};h=e(o.name??`unknown`,o.description??``),g=c(i,u,`components`,o.name??`unknown`,`.tsx`,l.fs);break;case`test`:{let e=s===`operation`?`handler`:`component`;h=n(o.name??`unknown`,e),g=c(i,u,`__tests__`,o.name??`unknown`,`.test.ts`,l.fs);break}default:return{target:r,outputPath:``,success:!1,error:`Unknown target: ${r}`}}if(await p.exists(g)&&!d)return{target:r,outputPath:g,success:!1,skipped:!0,error:`File already exists (use overwrite option)`};if(f)return m.info(`[dry-run] Would write: ${g}`),{target:r,outputPath:g,success:!0};let _=p.dirname(g);return await p.mkdir(_),await p.writeFile(g,h),m.info(`Generated: ${g}`),{target:r,outputPath:g,success:!0}}function s(e){switch(r(e)){case`operation`:return[`handler`];case`presentation`:return[`component`];default:return[]}}function c(e,t,n,r,i,a){let o=l(r.split(`.`).pop()??`unknown`),s;return s=t.startsWith(`.`)?a.resolve(a.dirname(e),`..`,t,n):a.resolve(t,n),a.join(s,`${o}${i}`)}function l(e){return e.replace(/\./g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}export{a as buildSpec};
|