@specverse/engine-realize 3.5.3
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/assets/examples/09-api/ai-spec.yaml +194 -0
- package/assets/examples/09-api/converted.yaml +95 -0
- package/assets/examples/09-api/diagram-architecture.mmd +10 -0
- package/assets/examples/09-api/diagram-er.mmd +10 -0
- package/assets/examples/09-api/documentation.html +104 -0
- package/assets/examples/09-api/documentation.md +95 -0
- package/assets/examples/09-api/inferred-spec.yaml +420 -0
- package/assets/examples/09-api/openapi.json +61 -0
- package/assets/examples/10-api/README.md +216 -0
- package/assets/examples/10-api/ai-spec.yaml +194 -0
- package/assets/examples/10-api/converted.yaml +96 -0
- package/assets/examples/10-api/diagram-architecture.mmd +10 -0
- package/assets/examples/10-api/diagram-er.mmd +10 -0
- package/assets/examples/10-api/documentation.html +104 -0
- package/assets/examples/10-api/documentation.md +95 -0
- package/assets/examples/10-api/inferred-spec.yaml +7 -0
- package/assets/examples/10-api/metadata.yaml +89 -0
- package/assets/examples/10-api/openapi.json +61 -0
- package/assets/examples/10-api/package-integration-test.js +177 -0
- package/assets/examples/10-api/usage-example.js +323 -0
- package/assets/examples/10-api/usage-example.ts +363 -0
- package/assets/examples/10-api/workflow-test.js +113 -0
- package/assets/examples/manifests/01-simple-default-mappings.yaml +36 -0
- package/assets/examples/manifests/02-capability-mappings.yaml +55 -0
- package/assets/examples/manifests/03-hybrid-mappings.yaml +109 -0
- package/assets/examples/manifests/README.md +245 -0
- package/assets/examples/manifests/backend-only.yaml +43 -0
- package/assets/examples/manifests/blog-api.md +78 -0
- package/assets/examples/manifests/blog-api.specly +79 -0
- package/assets/examples/manifests/frontend-only.yaml +27 -0
- package/assets/examples/manifests/fullstack-app.yaml +44 -0
- package/assets/examples/manifests/fullstack-monorepo.yaml +62 -0
- package/assets/examples/validate-examples-with-expected-failures.cjs +328 -0
- package/assets/examples/validate-examples.cjs +225 -0
- package/assets/examples-decomposed/cloud-native-manifest.example.yaml +8 -0
- package/assets/examples-decomposed/cloud-native-manifest.md +379 -0
- package/assets/examples-decomposed/cloud-native-manifest.specly +60 -0
- package/assets/examples-decomposed/docker-compose-manifest.example.yaml +8 -0
- package/assets/examples-decomposed/docker-compose-manifest.md +326 -0
- package/assets/examples-decomposed/docker-compose-manifest.specly +40 -0
- package/assets/examples-decomposed/kubernetes-deployment-manifest.example.yaml +8 -0
- package/assets/examples-decomposed/kubernetes-deployment-manifest.md +237 -0
- package/assets/examples-decomposed/kubernetes-deployment-manifest.specly +41 -0
- package/assets/templates/README.md +559 -0
- package/assets/templates/TEMPLATE-ENHANCEMENTS-V33.md +462 -0
- package/assets/templates/backend-only/CLAUDE.md +73 -0
- package/assets/templates/backend-only/README.md +197 -0
- package/assets/templates/backend-only/deployments/README.md +149 -0
- package/assets/templates/backend-only/deployments/development.specly +53 -0
- package/assets/templates/backend-only/deployments/production.specly +87 -0
- package/assets/templates/backend-only/docs/README.md +50 -0
- package/assets/templates/backend-only/docs/api/README.md +7 -0
- package/assets/templates/backend-only/docs/diagrams/README.md +85 -0
- package/assets/templates/backend-only/docs/example-documentation-template.md +269 -0
- package/assets/templates/backend-only/docs/guides/README.md +15 -0
- package/assets/templates/backend-only/dot.env.example +18 -0
- package/assets/templates/backend-only/generated/README.md +56 -0
- package/assets/templates/backend-only/generated/code/integration-test.template.js +320 -0
- package/assets/templates/backend-only/generated/code/package.json.template +34 -0
- package/assets/templates/backend-only/generated/docs/README.md +49 -0
- package/assets/templates/backend-only/gitignore +54 -0
- package/assets/templates/backend-only/manifests/README.md +72 -0
- package/assets/templates/backend-only/manifests/docker-compose.specly +91 -0
- package/assets/templates/backend-only/manifests/implementation.yaml +100 -0
- package/assets/templates/backend-only/manifests/kubernetes.specly +140 -0
- package/assets/templates/backend-only/package.json +59 -0
- package/assets/templates/backend-only/scripts/test-all.sh +160 -0
- package/assets/templates/backend-only/scripts/test-generated-code.sh +165 -0
- package/assets/templates/backend-only/specs/main.specly +67 -0
- package/assets/templates/default/CLAUDE.md +141 -0
- package/assets/templates/default/README.md +404 -0
- package/assets/templates/default/deployments/README.md +149 -0
- package/assets/templates/default/deployments/development.specly +53 -0
- package/assets/templates/default/deployments/production.specly +87 -0
- package/assets/templates/default/docs/README.md +50 -0
- package/assets/templates/default/docs/api/README.md +7 -0
- package/assets/templates/default/docs/diagrams/README.md +85 -0
- package/assets/templates/default/docs/example-documentation-template.md +269 -0
- package/assets/templates/default/docs/guides/README.md +15 -0
- package/assets/templates/default/dot.env.example +18 -0
- package/assets/templates/default/generated/README.md +56 -0
- package/assets/templates/default/generated/code/integration-test.template.js +320 -0
- package/assets/templates/default/generated/code/package.json.template +34 -0
- package/assets/templates/default/generated/docs/README.md +49 -0
- package/assets/templates/default/gitignore +54 -0
- package/assets/templates/default/manifests/README.md +72 -0
- package/assets/templates/default/manifests/docker-compose.specly +91 -0
- package/assets/templates/default/manifests/implementation.yaml +176 -0
- package/assets/templates/default/manifests/kubernetes.specly +140 -0
- package/assets/templates/default/package.json +61 -0
- package/assets/templates/default/scripts/test-all.sh +160 -0
- package/assets/templates/default/scripts/test-generated-code.sh +165 -0
- package/assets/templates/default/specs/main.specly +67 -0
- package/assets/templates/frontend-only/CLAUDE.md +75 -0
- package/assets/templates/frontend-only/README.md +231 -0
- package/assets/templates/frontend-only/deployments/README.md +149 -0
- package/assets/templates/frontend-only/deployments/development.specly +53 -0
- package/assets/templates/frontend-only/deployments/production.specly +87 -0
- package/assets/templates/frontend-only/docs/README.md +50 -0
- package/assets/templates/frontend-only/docs/api/README.md +7 -0
- package/assets/templates/frontend-only/docs/diagrams/README.md +85 -0
- package/assets/templates/frontend-only/docs/example-documentation-template.md +269 -0
- package/assets/templates/frontend-only/docs/guides/README.md +15 -0
- package/assets/templates/frontend-only/dot.env.example +18 -0
- package/assets/templates/frontend-only/generated/README.md +56 -0
- package/assets/templates/frontend-only/generated/code/integration-test.template.js +320 -0
- package/assets/templates/frontend-only/generated/code/package.json.template +34 -0
- package/assets/templates/frontend-only/generated/docs/README.md +49 -0
- package/assets/templates/frontend-only/gitignore +54 -0
- package/assets/templates/frontend-only/manifests/README.md +72 -0
- package/assets/templates/frontend-only/manifests/docker-compose.specly +91 -0
- package/assets/templates/frontend-only/manifests/implementation.yaml +58 -0
- package/assets/templates/frontend-only/manifests/kubernetes.specly +140 -0
- package/assets/templates/frontend-only/package.json +59 -0
- package/assets/templates/frontend-only/scripts/test-all.sh +160 -0
- package/assets/templates/frontend-only/scripts/test-generated-code.sh +165 -0
- package/assets/templates/frontend-only/specs/main.specly +57 -0
- package/assets/templates/full-stack/AI-GUIDE.md +60 -0
- package/assets/templates/full-stack/CLAUDE.md +141 -0
- package/assets/templates/full-stack/README.md +382 -0
- package/assets/templates/full-stack/archive/AI-GUIDE-legacy.md +392 -0
- package/assets/templates/full-stack/deployments/README.md +149 -0
- package/assets/templates/full-stack/deployments/development.specly +53 -0
- package/assets/templates/full-stack/deployments/production.specly +87 -0
- package/assets/templates/full-stack/docs/README.md +51 -0
- package/assets/templates/full-stack/docs/api/README.md +7 -0
- package/assets/templates/full-stack/docs/diagrams/README.md +85 -0
- package/assets/templates/full-stack/docs/example-documentation-template.md +269 -0
- package/assets/templates/full-stack/docs/guides/README.md +15 -0
- package/assets/templates/full-stack/generated/README.md +56 -0
- package/assets/templates/full-stack/generated/code/integration-test.template.js +320 -0
- package/assets/templates/full-stack/generated/code/package.json.template +34 -0
- package/assets/templates/full-stack/generated/docs/README.md +49 -0
- package/assets/templates/full-stack/gitignore +54 -0
- package/assets/templates/full-stack/manifests/README.md +72 -0
- package/assets/templates/full-stack/manifests/docker-compose.specly +91 -0
- package/assets/templates/full-stack/manifests/implementation.yaml +155 -0
- package/assets/templates/full-stack/manifests/kubernetes.specly +140 -0
- package/assets/templates/full-stack/package.json +45 -0
- package/assets/templates/full-stack/scripts/test-all.sh +160 -0
- package/assets/templates/full-stack/scripts/test-generated-code.sh +165 -0
- package/assets/templates/full-stack/specs/example-v33.specly +297 -0
- package/assets/templates/full-stack/specs/main-simple.specly +73 -0
- package/assets/templates/full-stack/specs/main.specly +408 -0
- package/dist/engines/code-generator.d.ts +86 -0
- package/dist/engines/code-generator.d.ts.map +1 -0
- package/dist/engines/code-generator.js +159 -0
- package/dist/engines/code-generator.js.map +1 -0
- package/dist/engines/engine-registry.d.ts +94 -0
- package/dist/engines/engine-registry.d.ts.map +1 -0
- package/dist/engines/engine-registry.js +163 -0
- package/dist/engines/engine-registry.js.map +1 -0
- package/dist/engines/index.d.ts +10 -0
- package/dist/engines/index.d.ts.map +1 -0
- package/dist/engines/index.js +12 -0
- package/dist/engines/index.js.map +1 -0
- package/dist/engines/typescript-engine.d.ts +74 -0
- package/dist/engines/typescript-engine.d.ts.map +1 -0
- package/dist/engines/typescript-engine.js +288 -0
- package/dist/engines/typescript-engine.js.map +1 -0
- package/dist/generators/index.d.ts +11 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +11 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +434 -0
- package/dist/index.js.map +1 -0
- package/dist/library/index.d.ts +12 -0
- package/dist/library/index.d.ts.map +1 -0
- package/dist/library/index.js +15 -0
- package/dist/library/index.js.map +1 -0
- package/dist/library/library.d.ts +132 -0
- package/dist/library/library.d.ts.map +1 -0
- package/dist/library/library.js +343 -0
- package/dist/library/library.js.map +1 -0
- package/dist/library/loader.d.ts +73 -0
- package/dist/library/loader.d.ts.map +1 -0
- package/dist/library/loader.js +150 -0
- package/dist/library/loader.js.map +1 -0
- package/dist/library/resolver.d.ts +104 -0
- package/dist/library/resolver.d.ts.map +1 -0
- package/dist/library/resolver.js +299 -0
- package/dist/library/resolver.js.map +1 -0
- package/dist/library/validator.d.ts +65 -0
- package/dist/library/validator.d.ts.map +1 -0
- package/dist/library/validator.js +203 -0
- package/dist/library/validator.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/instance-factory.d.ts +289 -0
- package/dist/types/instance-factory.d.ts.map +1 -0
- package/dist/types/instance-factory.js +8 -0
- package/dist/types/instance-factory.js.map +1 -0
- package/dist/types/unified-mappings.d.ts +163 -0
- package/dist/types/unified-mappings.d.ts.map +1 -0
- package/dist/types/unified-mappings.js +110 -0
- package/dist/types/unified-mappings.js.map +1 -0
- package/dist/utils/ai-spec-loader.d.ts +77 -0
- package/dist/utils/ai-spec-loader.d.ts.map +1 -0
- package/dist/utils/ai-spec-loader.js +138 -0
- package/dist/utils/ai-spec-loader.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/manifest-loader.d.ts +107 -0
- package/dist/utils/manifest-loader.d.ts.map +1 -0
- package/dist/utils/manifest-loader.js +168 -0
- package/dist/utils/manifest-loader.js.map +1 -0
- package/dist/utils/mapping-migration.d.ts +53 -0
- package/dist/utils/mapping-migration.d.ts.map +1 -0
- package/dist/utils/mapping-migration.js +194 -0
- package/dist/utils/mapping-migration.js.map +1 -0
- package/libs/instance-factories/CURVED-INTERFACE.md +278 -0
- package/libs/instance-factories/README.md +433 -0
- package/libs/instance-factories/applications/generic-app.yaml +52 -0
- package/libs/instance-factories/applications/react-app.yaml +186 -0
- package/libs/instance-factories/applications/templates/generic/backend-env-generator.ts +31 -0
- package/libs/instance-factories/applications/templates/generic/backend-package-json-generator.ts +80 -0
- package/libs/instance-factories/applications/templates/generic/backend-tsconfig-generator.ts +69 -0
- package/libs/instance-factories/applications/templates/generic/main-generator.ts +308 -0
- package/libs/instance-factories/applications/templates/react/_view-components-source.ts +555 -0
- package/libs/instance-factories/applications/templates/react/api-client-generator.ts +436 -0
- package/libs/instance-factories/applications/templates/react/api-types-generator.ts +153 -0
- package/libs/instance-factories/applications/templates/react/app-tsx-generator.ts +94 -0
- package/libs/instance-factories/applications/templates/react/env-example-generator.ts +24 -0
- package/libs/instance-factories/applications/templates/react/field-helpers-generator.ts +106 -0
- package/libs/instance-factories/applications/templates/react/gitignore-generator.ts +38 -0
- package/libs/instance-factories/applications/templates/react/index-css-generator.ts +85 -0
- package/libs/instance-factories/applications/templates/react/index-html-generator.ts +30 -0
- package/libs/instance-factories/applications/templates/react/main-tsx-generator.ts +34 -0
- package/libs/instance-factories/applications/templates/react/package-json-generator.ts +54 -0
- package/libs/instance-factories/applications/templates/react/pattern-adapter-generator.ts +179 -0
- package/libs/instance-factories/applications/templates/react/react-pattern-adapter.tsx +1347 -0
- package/libs/instance-factories/applications/templates/react/relationship-field-generator.ts +150 -0
- package/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.ts +704 -0
- package/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.ts +84 -0
- package/libs/instance-factories/applications/templates/react/tsconfig-generator.ts +35 -0
- package/libs/instance-factories/applications/templates/react/use-api-hooks-generator.ts +121 -0
- package/libs/instance-factories/applications/templates/react/view-dashboard-generator.ts +150 -0
- package/libs/instance-factories/applications/templates/react/view-detail-generator.ts +150 -0
- package/libs/instance-factories/applications/templates/react/view-form-generator.ts +362 -0
- package/libs/instance-factories/applications/templates/react/view-list-generator.ts +98 -0
- package/libs/instance-factories/applications/templates/react/view-router-generator.ts +89 -0
- package/libs/instance-factories/applications/templates/react/vite-config-generator.ts +49 -0
- package/libs/instance-factories/archived/fastify-prisma.yaml +104 -0
- package/libs/instance-factories/cli/commander-js.yaml +55 -0
- package/libs/instance-factories/cli/templates/commander/cli-entry-generator.d.ts +12 -0
- package/libs/instance-factories/cli/templates/commander/cli-entry-generator.d.ts.map +1 -0
- package/libs/instance-factories/cli/templates/commander/cli-entry-generator.js +115 -0
- package/libs/instance-factories/cli/templates/commander/cli-entry-generator.js.map +1 -0
- package/libs/instance-factories/cli/templates/commander/cli-entry-generator.ts +145 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.d.ts +14 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.d.ts.map +1 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.js +182 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.js.map +1 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.ts +992 -0
- package/libs/instance-factories/communication/event-emitter.yaml +56 -0
- package/libs/instance-factories/communication/rabbitmq-events.yaml +87 -0
- package/libs/instance-factories/communication/templates/eventemitter/bus-generator.ts +93 -0
- package/libs/instance-factories/communication/templates/eventemitter/publisher-generator.ts +117 -0
- package/libs/instance-factories/communication/templates/eventemitter/subscriber-generator.ts +101 -0
- package/libs/instance-factories/controllers/fastify.yaml +127 -0
- package/libs/instance-factories/controllers/templates/fastify/meta-routes-generator.ts +103 -0
- package/libs/instance-factories/controllers/templates/fastify/routes-generator.ts +389 -0
- package/libs/instance-factories/controllers/templates/fastify/server-generator.ts +76 -0
- package/libs/instance-factories/infrastructure/docker-k8s.yaml +61 -0
- package/libs/instance-factories/infrastructure/templates/docker-k8s/infrastructure-generator.ts +46 -0
- package/libs/instance-factories/orms/prisma.yaml +89 -0
- package/libs/instance-factories/orms/templates/prisma/schema-generator.ts +563 -0
- package/libs/instance-factories/orms/templates/prisma/services-generator.ts +408 -0
- package/libs/instance-factories/scaffolding/generic-scaffold.yaml +65 -0
- package/libs/instance-factories/scaffolding/templates/generic/env-example-generator.ts +73 -0
- package/libs/instance-factories/scaffolding/templates/generic/env-generator.ts +85 -0
- package/libs/instance-factories/scaffolding/templates/generic/gitignore-generator.ts +69 -0
- package/libs/instance-factories/scaffolding/templates/generic/package-json-generator.ts +176 -0
- package/libs/instance-factories/scaffolding/templates/generic/readme-generator.ts +207 -0
- package/libs/instance-factories/scaffolding/templates/generic/tsconfig-generator.ts +78 -0
- package/libs/instance-factories/scaffolding/templates/generic/tsconfig-react-generator.ts +41 -0
- package/libs/instance-factories/sdks/python-sdk.yaml +66 -0
- package/libs/instance-factories/sdks/templates/python/sdk-generator.ts +50 -0
- package/libs/instance-factories/sdks/templates/typescript/sdk-generator.ts +49 -0
- package/libs/instance-factories/sdks/typescript-sdk.yaml +59 -0
- package/libs/instance-factories/services/prisma-services.yaml +71 -0
- package/libs/instance-factories/services/templates/prisma/behavior-generator.ts +303 -0
- package/libs/instance-factories/services/templates/prisma/controller-generator.ts +532 -0
- package/libs/instance-factories/services/templates/prisma/service-generator.ts +315 -0
- package/libs/instance-factories/shared/path-resolver.ts +111 -0
- package/libs/instance-factories/storage/mongodb.yaml +79 -0
- package/libs/instance-factories/storage/postgresql.yaml +75 -0
- package/libs/instance-factories/storage/redis.yaml +79 -0
- package/libs/instance-factories/storage/templates/mongodb/config-generator.ts +15 -0
- package/libs/instance-factories/storage/templates/mongodb/docker-generator.ts +18 -0
- package/libs/instance-factories/storage/templates/postgresql/config-generator.ts +54 -0
- package/libs/instance-factories/storage/templates/postgresql/docker-generator.ts +55 -0
- package/libs/instance-factories/storage/templates/redis/config-generator.ts +16 -0
- package/libs/instance-factories/storage/templates/redis/docker-generator.ts +18 -0
- package/libs/instance-factories/test-generation.ts +192 -0
- package/libs/instance-factories/testing/templates/vitest/tests-generator.ts +51 -0
- package/libs/instance-factories/testing/vitest-tests.yaml +63 -0
- package/libs/instance-factories/tools/templates/mcp/mcp-server-generator.ts +136 -0
- package/libs/instance-factories/tools/templates/mcp/static/docs/DEPLOYMENT_GUIDE.md +630 -0
- package/libs/instance-factories/tools/templates/mcp/static/docs/HYBRID_RESOURCE_SYSTEM.md +330 -0
- package/libs/instance-factories/tools/templates/mcp/static/docs/deployments/EXTENSION_DEPLOYMENT.md +552 -0
- package/libs/instance-factories/tools/templates/mcp/static/docs/deployments/LOCAL_DEPLOYMENT.md +164 -0
- package/libs/instance-factories/tools/templates/mcp/static/docs/deployments/WEB_DEPLOYMENT.md +247 -0
- package/libs/instance-factories/tools/templates/mcp/static/package.json +92 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/build-enterprise.js +284 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/build-extension.js +139 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/build-local.js +74 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/build-web.js +156 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/copy-canonical-files.js +41 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/test-deployments.js +259 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/test-hybrid-resources.js +231 -0
- package/libs/instance-factories/tools/templates/mcp/static/scripts/test-hybrid-simple.js +196 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/controllers/MCPServerController.ts +293 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/events/EventEmitter.ts +90 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/index.ts +24 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/interfaces/ResourceProvider.ts +15 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/models/LibrarySuggestion.ts +106 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/models/SpecVerseResource.ts +75 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/server/mcp-server.ts +239 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/CLIProxyService.ts +1501 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/EmbeddedResourcesAdapter.ts +211 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/EntityModuleService.ts +308 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/HybridResourcesProvider.ts +210 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/LibraryToolsService.ts +356 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/OrchestratorBridge.ts +524 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/OrchestratorToolsService.ts +530 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/PromptToolsService.ts +594 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/services/ResourcesProviderService.ts +170 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/tests/unit/CLIProxyService.init.test.ts +544 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/tests/unit/CLIProxyService.test.ts +189 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/tests/unit/ResourcesProviderService.test.ts +89 -0
- package/libs/instance-factories/tools/templates/mcp/static/src/types/index.ts +110 -0
- package/libs/instance-factories/tools/templates/mcp/static/tsconfig.json +28 -0
- package/libs/instance-factories/tools/templates/vscode/static/extension.ts +1195 -0
- package/libs/instance-factories/tools/templates/vscode/static/language-configuration.json +34 -0
- package/libs/instance-factories/tools/templates/vscode/static/schemas/specverse-v3-schema.json +4279 -0
- package/libs/instance-factories/tools/templates/vscode/static/syntaxes/specverse.tmLanguage.json +138 -0
- package/libs/instance-factories/tools/templates/vscode/static/themes/README.md +74 -0
- package/libs/instance-factories/tools/templates/vscode/static/themes/complete-specverse-colors.json +122 -0
- package/libs/instance-factories/tools/templates/vscode/static/themes/specverse-basic-theme.json +65 -0
- package/libs/instance-factories/tools/templates/vscode/static/themes/specverse-complete-theme.json +123 -0
- package/libs/instance-factories/tools/templates/vscode/static/themes/specverse-theme-colors.json +64 -0
- package/libs/instance-factories/tools/templates/vscode/vscode-extension-generator.ts +214 -0
- package/libs/instance-factories/validation/templates/zod/validation-generator.ts +46 -0
- package/libs/instance-factories/validation/zod.yaml +56 -0
- package/libs/instance-factories/views/index.d.ts +13 -0
- package/libs/instance-factories/views/index.d.ts.map +1 -0
- package/libs/instance-factories/views/index.js +18 -0
- package/libs/instance-factories/views/index.js.map +1 -0
- package/libs/instance-factories/views/index.ts +45 -0
- package/libs/instance-factories/views/react-components.yaml +129 -0
- package/libs/instance-factories/views/templates/ARCHITECTURE.md +198 -0
- package/libs/instance-factories/views/templates/react/adapters/antd-adapter.ts +869 -0
- package/libs/instance-factories/views/templates/react/adapters/mui-adapter.ts +953 -0
- package/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.ts +806 -0
- package/libs/instance-factories/views/templates/react/app-generator.ts +55 -0
- package/libs/instance-factories/views/templates/react/components-generator.ts +391 -0
- package/libs/instance-factories/views/templates/react/forms-generator.ts +343 -0
- package/libs/instance-factories/views/templates/react/frontend-package-json-generator.ts +54 -0
- package/libs/instance-factories/views/templates/react/hooks-generator.ts +122 -0
- package/libs/instance-factories/views/templates/react/index-css-generator.ts +209 -0
- package/libs/instance-factories/views/templates/react/index-html-generator.ts +34 -0
- package/libs/instance-factories/views/templates/react/main-tsx-generator.ts +29 -0
- package/libs/instance-factories/views/templates/react/react-component-generator.d.ts +152 -0
- package/libs/instance-factories/views/templates/react/react-component-generator.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/react/react-component-generator.js +398 -0
- package/libs/instance-factories/views/templates/react/react-component-generator.js.map +1 -0
- package/libs/instance-factories/views/templates/react/react-component-generator.ts +533 -0
- package/libs/instance-factories/views/templates/react/router-generator.ts +197 -0
- package/libs/instance-factories/views/templates/react/router-generic-generator.ts +103 -0
- package/libs/instance-factories/views/templates/react/spec-json-generator.ts +17 -0
- package/libs/instance-factories/views/templates/react/types-generator.ts +76 -0
- package/libs/instance-factories/views/templates/react/views-metadata-generator.ts +42 -0
- package/libs/instance-factories/views/templates/react/vite-config-generator.ts +38 -0
- package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js.map +1 -0
- package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.ts +474 -0
- package/libs/instance-factories/views/templates/shared/__tests__/composite-patterns.test.ts +242 -0
- package/libs/instance-factories/views/templates/shared/adapter-types.d.ts +77 -0
- package/libs/instance-factories/views/templates/shared/adapter-types.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/shared/adapter-types.js +47 -0
- package/libs/instance-factories/views/templates/shared/adapter-types.js.map +1 -0
- package/libs/instance-factories/views/templates/shared/adapter-types.ts +142 -0
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts +63 -0
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.js +822 -0
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.js.map +1 -0
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.ts +908 -0
- package/libs/instance-factories/views/templates/shared/base-generator.d.ts +247 -0
- package/libs/instance-factories/views/templates/shared/base-generator.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/shared/base-generator.js +363 -0
- package/libs/instance-factories/views/templates/shared/base-generator.js.map +1 -0
- package/libs/instance-factories/views/templates/shared/base-generator.ts +608 -0
- package/libs/instance-factories/views/templates/shared/component-metadata.d.ts +254 -0
- package/libs/instance-factories/views/templates/shared/component-metadata.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/shared/component-metadata.js +602 -0
- package/libs/instance-factories/views/templates/shared/component-metadata.js.map +1 -0
- package/libs/instance-factories/views/templates/shared/component-metadata.ts +803 -0
- package/libs/instance-factories/views/templates/shared/composite-pattern-types.ts +250 -0
- package/libs/instance-factories/views/templates/shared/composite-patterns.ts +535 -0
- package/libs/instance-factories/views/templates/shared/index.ts +68 -0
- package/libs/instance-factories/views/templates/shared/pattern-validator.ts +279 -0
- package/libs/instance-factories/views/templates/shared/property-mapper.d.ts +149 -0
- package/libs/instance-factories/views/templates/shared/property-mapper.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/shared/property-mapper.js +580 -0
- package/libs/instance-factories/views/templates/shared/property-mapper.js.map +1 -0
- package/libs/instance-factories/views/templates/shared/property-mapper.ts +700 -0
- package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts +143 -0
- package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts.map +1 -0
- package/libs/instance-factories/views/templates/shared/syntax-mapper.js +420 -0
- package/libs/instance-factories/views/templates/shared/syntax-mapper.js.map +1 -0
- package/libs/instance-factories/views/templates/shared/syntax-mapper.ts +539 -0
- package/package.json +42 -0
- package/schema/SPECVERSE-SCHEMA.json +4274 -0
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PromptToolsService
|
|
3
|
+
* Updated to use new src/ai/ commands for Phase 3 integration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { LibraryToolsService } from './LibraryToolsService.js';
|
|
7
|
+
import type { ResourceProvider } from '../interfaces/ResourceProvider.js';
|
|
8
|
+
import type {
|
|
9
|
+
PromptContext,
|
|
10
|
+
MCPToolResult,
|
|
11
|
+
LibrarySuggestion
|
|
12
|
+
} from '../types/index.js';
|
|
13
|
+
|
|
14
|
+
// Import AI commands from local package - same API as external developers
|
|
15
|
+
import { enhancePrompt, suggestLibraries } from '../../../../dist/index.js';
|
|
16
|
+
import type { UserRequirements, EnhancedPrompt } from '../../../../dist/index.js';
|
|
17
|
+
|
|
18
|
+
interface ExpandedPrompt {
|
|
19
|
+
system_prompt: string;
|
|
20
|
+
user_prompt: string;
|
|
21
|
+
context?: string;
|
|
22
|
+
examples?: string[];
|
|
23
|
+
libraries?: LibrarySuggestion[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface ValidationInstructions {
|
|
27
|
+
command: string;
|
|
28
|
+
description: string;
|
|
29
|
+
expected_output: string;
|
|
30
|
+
common_issues: string[];
|
|
31
|
+
fix_suggestions: string[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class PromptToolsService {
|
|
35
|
+
private resourcesProvider: ResourceProvider;
|
|
36
|
+
private libraryTools: LibraryToolsService;
|
|
37
|
+
|
|
38
|
+
constructor(
|
|
39
|
+
resourcesProvider: ResourceProvider,
|
|
40
|
+
libraryTools: LibraryToolsService
|
|
41
|
+
) {
|
|
42
|
+
this.resourcesProvider = resourcesProvider;
|
|
43
|
+
this.libraryTools = libraryTools;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async getCreationPrompt(context: PromptContext): Promise<MCPToolResult> {
|
|
47
|
+
try {
|
|
48
|
+
// Validate and sanitize input context
|
|
49
|
+
const sanitizedContext = this.sanitizeContext(context);
|
|
50
|
+
|
|
51
|
+
// Use CLI bridge to call the new AI API
|
|
52
|
+
const result = await this.callAICommand('enhance', 'create', {
|
|
53
|
+
requirements: sanitizedContext.requirements || '',
|
|
54
|
+
scale: this.mapScale(sanitizedContext.scale),
|
|
55
|
+
framework: sanitizedContext.preferredTech,
|
|
56
|
+
technology_preferences: sanitizedContext.preferredTech ? [sanitizedContext.preferredTech] : undefined
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Format the response to match MCP expectations
|
|
60
|
+
const expandedPrompt = {
|
|
61
|
+
system_prompt: result.systemPrompt,
|
|
62
|
+
user_prompt: result.userPrompt,
|
|
63
|
+
context: result.contextPrompt,
|
|
64
|
+
libraries: result.libraryContext?.suggestions?.slice(0, 5) || [],
|
|
65
|
+
estimated_tokens: result.estimatedTokens,
|
|
66
|
+
execution_options: result.executionOptions
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
content: [{
|
|
71
|
+
type: 'text',
|
|
72
|
+
text: JSON.stringify(expandedPrompt, null, 2)
|
|
73
|
+
}]
|
|
74
|
+
};
|
|
75
|
+
} catch (error) {
|
|
76
|
+
return this.createErrorResult('getCreationPrompt', error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async getAnalysisPrompt(context: PromptContext): Promise<MCPToolResult> {
|
|
81
|
+
try {
|
|
82
|
+
const sanitizedContext = this.sanitizeContext(context);
|
|
83
|
+
|
|
84
|
+
const result = await this.callAICommand('enhance', 'analyse', {
|
|
85
|
+
requirements: sanitizedContext.projectType || 'code analysis',
|
|
86
|
+
framework: sanitizedContext.frameworkHint
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const expandedPrompt = {
|
|
90
|
+
system_prompt: result.systemPrompt,
|
|
91
|
+
user_prompt: result.userPrompt,
|
|
92
|
+
context: result.contextPrompt,
|
|
93
|
+
estimated_tokens: result.estimatedTokens,
|
|
94
|
+
execution_options: result.executionOptions
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
content: [{
|
|
99
|
+
type: 'text',
|
|
100
|
+
text: JSON.stringify(expandedPrompt, null, 2)
|
|
101
|
+
}]
|
|
102
|
+
};
|
|
103
|
+
} catch (error) {
|
|
104
|
+
return this.createErrorResult('getAnalysisPrompt', error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async getImplementationPrompt(context: PromptContext): Promise<MCPToolResult> {
|
|
109
|
+
try {
|
|
110
|
+
const sanitizedContext = this.sanitizeContext(context);
|
|
111
|
+
|
|
112
|
+
const result = await this.callAICommand('enhance', 'materialise', {
|
|
113
|
+
requirements: `implementation planning for ${sanitizedContext.targetFramework || 'specified framework'}`,
|
|
114
|
+
framework: sanitizedContext.targetFramework,
|
|
115
|
+
technology_preferences: sanitizedContext.deploymentType ? [sanitizedContext.deploymentType] : undefined
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const expandedPrompt = {
|
|
119
|
+
system_prompt: result.systemPrompt,
|
|
120
|
+
user_prompt: result.userPrompt,
|
|
121
|
+
context: result.contextPrompt,
|
|
122
|
+
estimated_tokens: result.estimatedTokens,
|
|
123
|
+
execution_options: result.executionOptions
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
content: [{
|
|
128
|
+
type: 'text',
|
|
129
|
+
text: JSON.stringify(expandedPrompt, null, 2)
|
|
130
|
+
}]
|
|
131
|
+
};
|
|
132
|
+
} catch (error) {
|
|
133
|
+
return this.createErrorResult('getImplementationPrompt', error);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async getRealizationPrompt(context: PromptContext): Promise<MCPToolResult> {
|
|
138
|
+
try {
|
|
139
|
+
const sanitizedContext = this.sanitizeContext(context);
|
|
140
|
+
|
|
141
|
+
const result = await this.callAICommand('enhance', 'realize', {
|
|
142
|
+
requirements: `code generation for ${sanitizedContext.targetFramework || 'specified framework'}`,
|
|
143
|
+
framework: sanitizedContext.targetFramework,
|
|
144
|
+
scale: this.mapScale(sanitizedContext.implementationScope)
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const expandedPrompt = {
|
|
148
|
+
system_prompt: result.systemPrompt,
|
|
149
|
+
user_prompt: result.userPrompt,
|
|
150
|
+
context: result.contextPrompt,
|
|
151
|
+
estimated_tokens: result.estimatedTokens,
|
|
152
|
+
execution_options: result.executionOptions
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
content: [{
|
|
157
|
+
type: 'text',
|
|
158
|
+
text: JSON.stringify(expandedPrompt, null, 2)
|
|
159
|
+
}]
|
|
160
|
+
};
|
|
161
|
+
} catch (error) {
|
|
162
|
+
return this.createErrorResult('getRealizationPrompt', error);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async getValidationInstructions(args: { validationType?: string }): Promise<MCPToolResult> {
|
|
167
|
+
try {
|
|
168
|
+
const validationType = args.validationType || 'syntax';
|
|
169
|
+
const instructions = this.generateValidationInstructions(validationType);
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
content: [{
|
|
173
|
+
type: 'text',
|
|
174
|
+
text: JSON.stringify(instructions, null, 2)
|
|
175
|
+
}]
|
|
176
|
+
};
|
|
177
|
+
} catch (error) {
|
|
178
|
+
return this.createErrorResult('getValidationInstructions', error);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private parseTemplate(template: any): { systemRole: string, systemContext: string, userTemplate: string } {
|
|
183
|
+
return {
|
|
184
|
+
systemRole: template?.system?.role || template?.system_role || '',
|
|
185
|
+
systemContext: template?.system?.context || template?.system_context || '',
|
|
186
|
+
userTemplate: template?.user?.template || template?.user_template || ''
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private expandCreationPrompt(template: any, context: any): ExpandedPrompt {
|
|
191
|
+
const { requirements, scale = 'business', preferredTech = 'auto', libraries = [], reasoning = '' } = context;
|
|
192
|
+
|
|
193
|
+
// Parse template structure
|
|
194
|
+
const { systemRole, systemContext, userTemplate } = this.parseTemplate(template);
|
|
195
|
+
|
|
196
|
+
// Build system prompt
|
|
197
|
+
let systemPrompt = systemRole + '\\n\\n' + systemContext;
|
|
198
|
+
|
|
199
|
+
// Add scale-specific guidance
|
|
200
|
+
systemPrompt += '\\n\\n' + this.getScaleGuidance(scale);
|
|
201
|
+
|
|
202
|
+
// Add library context
|
|
203
|
+
if (libraries.length > 0) {
|
|
204
|
+
systemPrompt += '\\n\\nLIBRARY CONTEXT:\\n';
|
|
205
|
+
systemPrompt += `Consider these relevant SpecVerse libraries: ${libraries.map((lib: any) => lib.name).join(', ')}\\n`;
|
|
206
|
+
systemPrompt += `Library selection reasoning: ${reasoning}`;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Expand user prompt with MAXIMUM safety
|
|
210
|
+
let userPrompt = '';
|
|
211
|
+
|
|
212
|
+
try {
|
|
213
|
+
// Convert template to string safely
|
|
214
|
+
if (userTemplate === null || userTemplate === undefined) {
|
|
215
|
+
userPrompt = '';
|
|
216
|
+
} else if (typeof userTemplate === 'string') {
|
|
217
|
+
userPrompt = userTemplate;
|
|
218
|
+
} else {
|
|
219
|
+
userPrompt = String(userTemplate);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Perform template variable replacements
|
|
223
|
+
if (userPrompt && userPrompt.length > 0 && typeof userPrompt === 'string') {
|
|
224
|
+
userPrompt = userPrompt.replace(/\\{\\{requirements\\}\\}/g, requirements || 'Not specified');
|
|
225
|
+
userPrompt = userPrompt.replace(/\\{\\{scale\\}\\}/g, scale);
|
|
226
|
+
userPrompt = userPrompt.replace(/\\{\\{preferredTech\\}\\}/g, preferredTech);
|
|
227
|
+
}
|
|
228
|
+
} catch (error) {
|
|
229
|
+
userPrompt = '';
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Add constraints
|
|
233
|
+
const constraints = template.system_constraints?.join('\\n- ') || '';
|
|
234
|
+
const contextSection = constraints ? `\\nCONSTRAINTS:\\n- ${constraints}` : '';
|
|
235
|
+
|
|
236
|
+
return {
|
|
237
|
+
system_prompt: systemPrompt,
|
|
238
|
+
user_prompt: userPrompt,
|
|
239
|
+
context: contextSection,
|
|
240
|
+
libraries: libraries.slice(0, 5)
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
private expandAnalysisPrompt(template: any, context: any): ExpandedPrompt {
|
|
245
|
+
const { projectType, frameworkHint } = context;
|
|
246
|
+
|
|
247
|
+
const { systemRole, systemContext, userTemplate } = this.parseTemplate(template);
|
|
248
|
+
let systemPrompt = systemRole + '\\n\\n' + systemContext;
|
|
249
|
+
|
|
250
|
+
// Add project type guidance
|
|
251
|
+
if (projectType) {
|
|
252
|
+
systemPrompt += `\\n\\nPROJECT TYPE: ${projectType}`;
|
|
253
|
+
systemPrompt += this.getProjectTypeGuidance(projectType);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
let userPrompt = userTemplate || '';
|
|
257
|
+
|
|
258
|
+
// Additional safety check - ensure userPrompt is a string
|
|
259
|
+
if (typeof userPrompt !== 'string') {
|
|
260
|
+
userPrompt = '';
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (userPrompt && userPrompt.length > 0) {
|
|
264
|
+
try {
|
|
265
|
+
userPrompt = userPrompt.replace(/\\{\\{frameworkType\\}\\}/g, frameworkHint || 'auto-detect');
|
|
266
|
+
} catch (error) {
|
|
267
|
+
console.warn('Error during analysis template replacement:', error);
|
|
268
|
+
userPrompt = `Template expansion failed: ${userTemplate}`;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const analysisInstructions = `
|
|
273
|
+
ANALYSIS INSTRUCTIONS:
|
|
274
|
+
1. Scan the following files for models, controllers, and services
|
|
275
|
+
2. Identify relationships between data models
|
|
276
|
+
3. Extract API endpoints and map to controller actions
|
|
277
|
+
4. Detect business logic patterns and event flows
|
|
278
|
+
5. Generate a clean SpecVerse specification
|
|
279
|
+
|
|
280
|
+
Please provide the directory structure and key file contents for analysis.`;
|
|
281
|
+
|
|
282
|
+
return {
|
|
283
|
+
system_prompt: systemPrompt,
|
|
284
|
+
user_prompt: userPrompt,
|
|
285
|
+
context: analysisInstructions
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
private expandImplementationPrompt(template: any, context: any): ExpandedPrompt {
|
|
290
|
+
const { targetFramework, deploymentType } = context;
|
|
291
|
+
|
|
292
|
+
const { systemRole, systemContext, userTemplate } = this.parseTemplate(template);
|
|
293
|
+
let systemPrompt = systemRole + '\\n\\n' + systemContext;
|
|
294
|
+
systemPrompt += `\\n\\nTARGET FRAMEWORK: ${targetFramework}`;
|
|
295
|
+
|
|
296
|
+
if (deploymentType) {
|
|
297
|
+
systemPrompt += `\\nDEPLOYMENT TYPE: ${deploymentType}`;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
let userPrompt = userTemplate || '';
|
|
301
|
+
|
|
302
|
+
// Additional safety check - ensure userPrompt is a string
|
|
303
|
+
if (typeof userPrompt !== 'string') {
|
|
304
|
+
userPrompt = '';
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (userPrompt && userPrompt.length > 0) {
|
|
308
|
+
try {
|
|
309
|
+
userPrompt = userPrompt.replace(/\\{\\{targetFramework\\}\\}/g, targetFramework);
|
|
310
|
+
} catch (error) {
|
|
311
|
+
console.warn('Error during implementation template replacement:', error);
|
|
312
|
+
userPrompt = `Template expansion failed: ${userTemplate}`;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const implementationContext = `
|
|
317
|
+
IMPLEMENTATION PLANNING FOCUS:
|
|
318
|
+
1. Break down the specification into implementable modules
|
|
319
|
+
2. Define file structure and component organization
|
|
320
|
+
3. Identify dependencies and integration points
|
|
321
|
+
4. Create development workflow and build process
|
|
322
|
+
5. Plan testing strategy and deployment pipeline
|
|
323
|
+
|
|
324
|
+
Framework-specific patterns for ${targetFramework} will be prioritized.`;
|
|
325
|
+
|
|
326
|
+
return {
|
|
327
|
+
system_prompt: systemPrompt,
|
|
328
|
+
user_prompt: userPrompt,
|
|
329
|
+
context: implementationContext
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
private expandRealizationPrompt(template: any, context: any): ExpandedPrompt {
|
|
334
|
+
const { targetFramework, implementationScope = 'full' } = context;
|
|
335
|
+
|
|
336
|
+
const { systemRole, systemContext, userTemplate } = this.parseTemplate(template);
|
|
337
|
+
let systemPrompt = systemRole + '\\n\\n' + systemContext;
|
|
338
|
+
systemPrompt += `\\n\\nTARGET FRAMEWORK: ${targetFramework}`;
|
|
339
|
+
systemPrompt += `\\nSCOPE: ${implementationScope}`;
|
|
340
|
+
|
|
341
|
+
let userPrompt = userTemplate || '';
|
|
342
|
+
|
|
343
|
+
// Additional safety check - ensure userPrompt is a string
|
|
344
|
+
if (typeof userPrompt !== 'string') {
|
|
345
|
+
userPrompt = '';
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (userPrompt && userPrompt.length > 0) {
|
|
349
|
+
try {
|
|
350
|
+
userPrompt = userPrompt.replace(/\\{\\{targetFramework\\}\\}/g, targetFramework);
|
|
351
|
+
} catch (error) {
|
|
352
|
+
console.warn('Error during realization template replacement:', error);
|
|
353
|
+
userPrompt = `Template expansion failed: ${userTemplate}`;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const scopeGuidance = this.getScopeGuidance(implementationScope);
|
|
358
|
+
|
|
359
|
+
return {
|
|
360
|
+
system_prompt: systemPrompt,
|
|
361
|
+
user_prompt: userPrompt,
|
|
362
|
+
context: scopeGuidance
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
private getScaleGuidance(scale: string): string {
|
|
367
|
+
switch (scale) {
|
|
368
|
+
case 'personal':
|
|
369
|
+
return `
|
|
370
|
+
PERSONAL SCALE GUIDANCE:
|
|
371
|
+
- Focus on simplicity and ease of use
|
|
372
|
+
- Minimize dependencies and complexity
|
|
373
|
+
- Single-user scenarios are acceptable
|
|
374
|
+
- SQLite and local storage are preferred
|
|
375
|
+
- Simple authentication patterns`;
|
|
376
|
+
|
|
377
|
+
case 'enterprise':
|
|
378
|
+
return `
|
|
379
|
+
ENTERPRISE SCALE GUIDANCE:
|
|
380
|
+
- Multi-tenant architecture required
|
|
381
|
+
- Comprehensive audit trails and logging
|
|
382
|
+
- Role-based access control (RBAC)
|
|
383
|
+
- High availability and scalability
|
|
384
|
+
- Compliance considerations (SOX, GDPR, HIPAA)
|
|
385
|
+
- Microservices patterns preferred`;
|
|
386
|
+
|
|
387
|
+
default: // business
|
|
388
|
+
return `
|
|
389
|
+
BUSINESS SCALE GUIDANCE:
|
|
390
|
+
- Multi-user support with role management
|
|
391
|
+
- Professional authentication (OAuth)
|
|
392
|
+
- Relational database (PostgreSQL preferred)
|
|
393
|
+
- API-first architecture
|
|
394
|
+
- Moderate scalability requirements`;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
private getProjectTypeGuidance(projectType: string): string {
|
|
399
|
+
switch (projectType.toLowerCase()) {
|
|
400
|
+
case 'web':
|
|
401
|
+
return '\\nFocus on: Controllers for pages, Services for business logic, Events for user interactions';
|
|
402
|
+
case 'api':
|
|
403
|
+
return '\\nFocus on: RESTful endpoints, Data models, Service layers, Authentication';
|
|
404
|
+
case 'mobile':
|
|
405
|
+
return '\\nFocus on: Screen controllers, Local storage, Sync patterns, Offline support';
|
|
406
|
+
default:
|
|
407
|
+
return '\\nUse general analysis patterns for all architectural components';
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
private getScopeGuidance(scope: string): string {
|
|
412
|
+
switch (scope) {
|
|
413
|
+
case 'mvp':
|
|
414
|
+
return `
|
|
415
|
+
MVP SCOPE:
|
|
416
|
+
- Essential features only
|
|
417
|
+
- Minimal error handling
|
|
418
|
+
- Basic styling and UX
|
|
419
|
+
- Skip advanced features
|
|
420
|
+
- Focus on core user journey`;
|
|
421
|
+
|
|
422
|
+
case 'prototype':
|
|
423
|
+
return `
|
|
424
|
+
PROTOTYPE SCOPE:
|
|
425
|
+
- Rapid development approach
|
|
426
|
+
- Mock data acceptable
|
|
427
|
+
- Basic functionality demonstration
|
|
428
|
+
- Minimal production considerations`;
|
|
429
|
+
|
|
430
|
+
default: // full
|
|
431
|
+
return `
|
|
432
|
+
FULL IMPLEMENTATION SCOPE:
|
|
433
|
+
- Complete feature set
|
|
434
|
+
- Production-ready code quality
|
|
435
|
+
- Comprehensive error handling
|
|
436
|
+
- Full testing coverage
|
|
437
|
+
- Security best practices`;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
private generateValidationInstructions(validationType: string): ValidationInstructions {
|
|
442
|
+
switch (validationType) {
|
|
443
|
+
case 'syntax':
|
|
444
|
+
return {
|
|
445
|
+
command: 'specverse check specs/main.specly',
|
|
446
|
+
description: 'Validate SpecVerse specification syntax',
|
|
447
|
+
expected_output: 'Specification is valid',
|
|
448
|
+
common_issues: [
|
|
449
|
+
'Invalid YAML syntax',
|
|
450
|
+
'Missing required fields',
|
|
451
|
+
'Incorrect property names',
|
|
452
|
+
'Invalid relationship syntax'
|
|
453
|
+
],
|
|
454
|
+
fix_suggestions: [
|
|
455
|
+
'Check YAML indentation (use spaces, not tabs)',
|
|
456
|
+
'Ensure all required fields are present',
|
|
457
|
+
'Verify property names match schema',
|
|
458
|
+
'Use correct relationship syntax: hasMany, belongsTo, etc.'
|
|
459
|
+
]
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
case 'semantic':
|
|
463
|
+
return {
|
|
464
|
+
command: 'specverse check specs/main.specly --semantic',
|
|
465
|
+
description: 'Validate semantic consistency and relationships',
|
|
466
|
+
expected_output: 'No semantic errors found',
|
|
467
|
+
common_issues: [
|
|
468
|
+
'Circular relationship dependencies',
|
|
469
|
+
'Missing relationship targets',
|
|
470
|
+
'Inconsistent naming conventions',
|
|
471
|
+
'Unreferenced models'
|
|
472
|
+
],
|
|
473
|
+
fix_suggestions: [
|
|
474
|
+
'Check for circular references in relationships',
|
|
475
|
+
'Ensure all relationship targets exist',
|
|
476
|
+
'Use consistent PascalCase for models',
|
|
477
|
+
'Remove unused models or add references'
|
|
478
|
+
]
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
default:
|
|
482
|
+
return {
|
|
483
|
+
command: 'specverse check specs/main.specly',
|
|
484
|
+
description: 'Basic specification validation',
|
|
485
|
+
expected_output: 'Validation successful',
|
|
486
|
+
common_issues: ['Syntax errors', 'Schema violations'],
|
|
487
|
+
fix_suggestions: ['Fix syntax errors', 'Follow SpecVerse schema']
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
private mapScale(scale: string | undefined): 'personal' | 'business' | 'enterprise' {
|
|
493
|
+
switch (scale) {
|
|
494
|
+
case 'personal':
|
|
495
|
+
case 'mvp':
|
|
496
|
+
case 'prototype':
|
|
497
|
+
return 'personal';
|
|
498
|
+
case 'enterprise':
|
|
499
|
+
case 'full':
|
|
500
|
+
return 'enterprise';
|
|
501
|
+
default:
|
|
502
|
+
return 'business';
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Call AI commands directly using src/ai/ API.
|
|
508
|
+
* This provides better integration and type safety than CLI calls.
|
|
509
|
+
*/
|
|
510
|
+
private async callAICommand(action: string, operation: string, params: any): Promise<EnhancedPrompt> {
|
|
511
|
+
try {
|
|
512
|
+
// Convert params to UserRequirements format
|
|
513
|
+
const requirements: UserRequirements = {
|
|
514
|
+
requirements: params.requirements || '',
|
|
515
|
+
scale: params.scale as 'personal' | 'business' | 'enterprise' || 'business',
|
|
516
|
+
framework: params.framework,
|
|
517
|
+
technology_preferences: params.technology_preferences
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
// Call the enhance command directly from src/ai/
|
|
521
|
+
if (action === 'enhance') {
|
|
522
|
+
return await enhancePrompt(operation as any, requirements);
|
|
523
|
+
} else {
|
|
524
|
+
throw new Error(`Unsupported action: ${action}`);
|
|
525
|
+
}
|
|
526
|
+
} catch (error) {
|
|
527
|
+
console.warn('Direct API call failed, falling back to basic prompt:', error);
|
|
528
|
+
// Fallback to basic prompt structure matching EnhancedPrompt interface
|
|
529
|
+
return {
|
|
530
|
+
systemPrompt: `You are a SpecVerse specification ${operation} expert.`,
|
|
531
|
+
userPrompt: `Please ${operation} a specification for: ${params.requirements}`,
|
|
532
|
+
contextPrompt: `Scale: ${params.scale || 'business'}, Framework: ${params.framework || 'auto'}`,
|
|
533
|
+
estimatedTokens: 1000,
|
|
534
|
+
variables: [],
|
|
535
|
+
libraryContext: {
|
|
536
|
+
total: 0,
|
|
537
|
+
suggestions: [],
|
|
538
|
+
reasoning: 'Basic fallback mode - no library suggestions available'
|
|
539
|
+
},
|
|
540
|
+
executionOptions: [
|
|
541
|
+
{ provider: 'interactive', description: 'Interactive copy-paste (Free)', estimatedCost: 0 },
|
|
542
|
+
{ provider: 'openai', description: 'OpenAI GPT-3.5 ($0.002)', estimatedCost: 0.002 },
|
|
543
|
+
{ provider: 'openai', description: 'OpenAI GPT-4 ($0.03)', estimatedCost: 0.03 }
|
|
544
|
+
]
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
private sanitizeContext(context: any): PromptContext {
|
|
550
|
+
// Handle null/undefined context
|
|
551
|
+
if (!context || typeof context !== 'object') {
|
|
552
|
+
return { requirements: '', scale: 'business', preferredTech: 'auto' };
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// Create sanitized context with string conversion for all values
|
|
556
|
+
const sanitized: any = {};
|
|
557
|
+
|
|
558
|
+
// Convert all values to proper strings, handling backticks and other issues
|
|
559
|
+
for (const [key, value] of Object.entries(context)) {
|
|
560
|
+
if (value === null || value === undefined) {
|
|
561
|
+
sanitized[key] = '';
|
|
562
|
+
} else if (typeof value === 'string') {
|
|
563
|
+
// Clean up any backtick template literals that might have gotten through
|
|
564
|
+
sanitized[key] = String(value).trim();
|
|
565
|
+
} else {
|
|
566
|
+
// Convert non-strings to strings
|
|
567
|
+
sanitized[key] = String(value).trim();
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// Ensure required fields have safe defaults
|
|
572
|
+
return {
|
|
573
|
+
requirements: sanitized.requirements || '',
|
|
574
|
+
scale: sanitized.scale || 'business',
|
|
575
|
+
preferredTech: sanitized.preferredTech || 'auto',
|
|
576
|
+
projectType: sanitized.projectType || '',
|
|
577
|
+
frameworkHint: sanitized.frameworkHint || '',
|
|
578
|
+
targetFramework: sanitized.targetFramework || '',
|
|
579
|
+
deploymentType: sanitized.deploymentType || '',
|
|
580
|
+
implementationScope: sanitized.implementationScope || 'full',
|
|
581
|
+
...sanitized
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
private createErrorResult(operation: string, error: any): MCPToolResult {
|
|
586
|
+
return {
|
|
587
|
+
content: [{
|
|
588
|
+
type: 'text',
|
|
589
|
+
text: `Error in ${operation}: ${error instanceof Error ? error.message : String(error)}`
|
|
590
|
+
}],
|
|
591
|
+
isError: true
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
}
|