@lssm/bundle.contractspec-workspace 0.0.0-canary-20251217060804 → 0.0.0-canary-20251217062139
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/adapters/ai.js +1 -1
- package/dist/ai/agents/claude-code-agent.js +1 -1
- package/dist/ai/agents/openai-codex-agent.js +1 -1
- package/dist/ai/agents/orchestrator.js +1 -1
- package/dist/ai/providers.js +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +1 -1
- package/dist/libs/ai-providers/dist/factory.js +1 -0
- package/dist/libs/ai-providers/dist/index.js +1 -0
- package/dist/libs/ai-providers/dist/legacy.js +1 -0
- package/dist/libs/ai-providers/dist/models.js +1 -0
- package/dist/libs/ai-providers/dist/validation.js +1 -0
- package/dist/libs/contracts/dist/capabilities/openbanking.js +1 -0
- package/dist/libs/contracts/dist/client/index.js +1 -0
- package/dist/libs/contracts/dist/client/react/feature-render.js +1 -0
- package/dist/libs/contracts/dist/client/react/form-render.js +1 -0
- package/dist/libs/contracts/dist/client/react/index.js +1 -0
- package/dist/libs/contracts/dist/contract-registry/index.js +1 -0
- package/dist/libs/contracts/dist/contract-registry/schemas.js +1 -0
- package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +76 -0
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +350 -0
- package/dist/libs/contracts/dist/docs/index.js +1 -0
- package/dist/libs/contracts/dist/docs/presentations.js +1 -0
- package/dist/libs/contracts/dist/docs/registry.js +1 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +383 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +68 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +140 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +86 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +1 -0
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +58 -0
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +38 -0
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +213 -0
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +289 -0
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +1 -0
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +1 -0
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +262 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +57 -0
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +63 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +36 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +20 -0
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +65 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +41 -0
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +122 -0
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +1 -0
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +68 -0
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +1 -0
- package/dist/libs/contracts/dist/events.js +1 -0
- package/dist/libs/contracts/dist/experiments/evaluator.js +1 -0
- package/dist/libs/contracts/dist/index.js +1 -0
- package/dist/libs/contracts/dist/install.js +1 -0
- package/dist/libs/contracts/dist/integrations/contracts.js +1 -0
- package/dist/libs/contracts/dist/integrations/index.js +1 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +1 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +1 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +1 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +1 -0
- package/dist/libs/contracts/dist/integrations/openbanking/models.js +1 -0
- package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/gmail.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/index.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/mistral.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/postmark.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/powens.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/qdrant.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/registry.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/stripe.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +1 -0
- package/dist/libs/contracts/dist/jsonschema.js +1 -0
- package/dist/libs/contracts/dist/knowledge/contracts.js +1 -0
- package/dist/libs/contracts/dist/knowledge/index.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/index.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +1 -0
- package/dist/libs/contracts/dist/llm/exporters.js +4 -0
- package/dist/libs/contracts/dist/llm/index.js +1 -0
- package/dist/libs/contracts/dist/llm/prompts.js +75 -0
- package/dist/libs/contracts/dist/onboarding-base.js +1 -0
- package/dist/libs/contracts/dist/openapi.js +1 -0
- package/dist/libs/contracts/dist/ownership.js +1 -0
- package/dist/libs/contracts/dist/presentations.js +1 -0
- package/dist/libs/contracts/dist/presentations.v2.js +1 -0
- package/dist/libs/contracts/dist/prompt.js +1 -0
- package/dist/libs/contracts/dist/promptRegistry.js +1 -0
- package/dist/libs/contracts/dist/regenerator/index.js +1 -0
- package/dist/libs/contracts/dist/regenerator/service.js +1 -0
- package/dist/libs/contracts/dist/regenerator/utils.js +1 -0
- package/dist/libs/contracts/dist/registry.js +1 -0
- package/dist/libs/contracts/dist/resources.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/EnumType.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/FieldType.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/entity/index.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/entity/types.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/index.js +1 -0
- package/dist/libs/contracts/dist/server/graphql-pothos.js +1 -0
- package/dist/libs/contracts/dist/server/index.js +1 -0
- package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +1 -0
- package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +1 -0
- package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +1 -0
- package/dist/libs/contracts/dist/server/mcp/registerResources.js +1 -0
- package/dist/libs/contracts/dist/server/mcp/registerTools.js +1 -0
- package/dist/libs/contracts/dist/server/provider-mcp.js +1 -0
- package/dist/libs/contracts/dist/server/rest-elysia.js +1 -0
- package/dist/libs/contracts/dist/server/rest-express.js +1 -0
- package/dist/libs/contracts/dist/server/rest-generic.js +1 -0
- package/dist/libs/contracts/dist/server/rest-next-app.js +1 -0
- package/dist/libs/contracts/dist/server/rest-next-pages.js +1 -0
- package/dist/libs/contracts/dist/spec.js +1 -0
- package/dist/libs/contracts/dist/telemetry/index.js +1 -0
- package/dist/libs/contracts/dist/telemetry/tracker.js +1 -0
- package/dist/libs/contracts/dist/tests/index.js +1 -0
- package/dist/libs/contracts/dist/tests/runner.js +1 -0
- package/dist/libs/contracts/dist/workflow/index.js +1 -0
- package/dist/libs/contracts/dist/workflow/runner.js +1 -0
- package/dist/libs/contracts-transformers/dist/common/utils.js +1 -0
- package/dist/libs/contracts-transformers/dist/openapi/exporter.js +1 -0
- package/dist/libs/contracts-transformers/dist/openapi/importer.js +2 -0
- package/dist/libs/contracts-transformers/dist/openapi/index.js +1 -0
- package/dist/libs/contracts-transformers/dist/openapi/parser.js +1 -0
- package/dist/libs/contracts-transformers/dist/openapi/schema-converter.js +4 -0
- package/dist/modules/contractspec-workspace/dist/ai/code-generation.js +100 -0
- package/dist/modules/contractspec-workspace/dist/ai/spec-creation.js +69 -0
- package/dist/modules/contractspec-workspace/dist/analysis/deps/graph.js +2 -0
- package/dist/modules/contractspec-workspace/dist/analysis/deps/parse-imports.js +1 -0
- package/dist/modules/contractspec-workspace/dist/analysis/diff/semantic.js +1 -0
- package/dist/modules/contractspec-workspace/dist/analysis/feature-scan.js +1 -0
- package/dist/modules/contractspec-workspace/dist/analysis/spec-scan.js +1 -0
- package/dist/modules/contractspec-workspace/dist/analysis/validate/spec-structure.js +1 -0
- package/dist/modules/contractspec-workspace/dist/templates/app-config.js +33 -0
- package/dist/modules/contractspec-workspace/dist/templates/data-view.js +54 -0
- package/dist/modules/contractspec-workspace/dist/templates/event.js +24 -0
- package/dist/modules/contractspec-workspace/dist/templates/experiment.js +62 -0
- package/dist/modules/contractspec-workspace/dist/templates/handler.js +63 -0
- package/dist/modules/contractspec-workspace/dist/templates/integration-utils.js +33 -0
- package/dist/modules/contractspec-workspace/dist/templates/integration.js +39 -0
- package/dist/modules/contractspec-workspace/dist/templates/knowledge.js +28 -0
- package/dist/modules/contractspec-workspace/dist/templates/migration.js +37 -0
- package/dist/modules/contractspec-workspace/dist/templates/operation.js +88 -0
- package/dist/modules/contractspec-workspace/dist/templates/presentation.js +53 -0
- package/dist/modules/contractspec-workspace/dist/templates/telemetry.js +69 -0
- package/dist/modules/contractspec-workspace/dist/templates/utils.js +1 -0
- package/dist/modules/contractspec-workspace/dist/templates/workflow-runner.js +42 -0
- package/dist/modules/contractspec-workspace/dist/templates/workflow.js +41 -0
- package/dist/modules/contractspec-workspace/dist/types/generation-types.js +1 -0
- package/dist/services/agent-guide/adapters/claude-code.js +1 -1
- package/dist/services/agent-guide/adapters/cursor-cli.js +2 -2
- package/dist/services/agent-guide/adapters/generic-mcp.js +1 -1
- package/dist/services/agent-guide/agent-guide-service.js +1 -1
- package/dist/services/build.js +1 -1
- package/dist/services/ci-check/ci-check-service.js +1 -1
- package/dist/services/config.js +1 -1
- package/dist/services/deps.js +1 -1
- package/dist/services/diff.js +1 -1
- package/dist/services/implementation/resolver.js +1 -1
- package/dist/services/integrity.js +1 -1
- package/dist/services/list.js +1 -1
- package/dist/services/openapi/export-service.js +1 -1
- package/dist/services/openapi/import-service.js +1 -1
- package/dist/services/openapi/sync-service.js +1 -1
- package/dist/services/openapi/validate-service.js +1 -1
- package/dist/services/regenerator.js +1 -1
- package/dist/services/test.js +1 -1
- package/dist/services/validate-implementation.js +1 -1
- package/dist/services/validate.js +1 -1
- package/dist/services/verify/ai-verifier.js +6 -6
- package/dist/services/verify/behavior-verifier.js +1 -1
- package/dist/services/verify/structure-verifier.js +1 -1
- package/package.json +9 -9
- package/dist/adapters/index.d.ts +0 -7
- package/dist/ports/index.d.ts +0 -5
- package/dist/services/agent-guide/index.d.ts +0 -6
- package/dist/services/ci-check/index.d.ts +0 -2
- package/dist/services/doctor/index.d.ts +0 -2
- package/dist/services/implementation/index.d.ts +0 -3
- package/dist/services/index.d.ts +0 -56
- package/dist/services/openapi/index.d.ts +0 -5
- package/dist/services/verification-cache/adapters/index.d.ts +0 -3
- package/dist/services/verification-cache/index.d.ts +0 -6
- package/dist/services/verify/index.d.ts +0 -5
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import{t as e}from"./utils.js";import{a as t,c as n,e as r,i,l as a,n as o,r as s,s as c,t as l,u}from"./integration-utils.js";function d(d){let f=e(d.name.split(`.`).pop()??`Integration`),p=`${f}IntegrationSpec`,m=`register${f}Integration`,h=d.supportedModes.length?d.supportedModes:[`managed`],g=h.map(e=>`'${e}'`).join(`, `),_=n(d),v=a(d),y=r(d.configFields),b=o(d.configFields),x=l(d.secretFields),S=s(d.secretFields),C=d.docsUrl?` docsUrl: '${u(d.docsUrl)}',\n`:``,w=i(d.rateLimitRpm,d.rateLimitRph),T=t(h,d.byokSetupInstructions,d.byokRequiredScopes);return`import { StabilityEnum } from '@lssm/lib.contracts/ownership';
|
|
2
|
+
import type { IntegrationSpec } from '@lssm/lib.contracts/integrations/spec';
|
|
3
|
+
import type { IntegrationSpecRegistry } from '@lssm/lib.contracts/integrations/spec';
|
|
4
|
+
|
|
5
|
+
export const ${p}: IntegrationSpec = {
|
|
6
|
+
meta: {
|
|
7
|
+
key: '${u(d.name)}',
|
|
8
|
+
version: ${d.version},
|
|
9
|
+
category: '${d.category}',
|
|
10
|
+
displayName: '${u(d.displayName)}',
|
|
11
|
+
title: '${u(d.title)}',
|
|
12
|
+
description: '${u(d.description)}',
|
|
13
|
+
domain: '${u(d.domain)}',
|
|
14
|
+
owners: [${d.owners.map(e=>`'${u(e)}'`).join(`, `)}],
|
|
15
|
+
tags: [${d.tags.map(e=>`'${u(e)}'`).join(`, `)}],
|
|
16
|
+
stability: StabilityEnum.${c(d.stability)},
|
|
17
|
+
},
|
|
18
|
+
supportedModes: [${g}],
|
|
19
|
+
capabilities: {
|
|
20
|
+
provides: [
|
|
21
|
+
${_}
|
|
22
|
+
],
|
|
23
|
+
${v.length>0?`${v}\n`:``} },
|
|
24
|
+
configSchema: {
|
|
25
|
+
${y} example: ${b},
|
|
26
|
+
},
|
|
27
|
+
secretSchema: {
|
|
28
|
+
${x} example: ${S},
|
|
29
|
+
},
|
|
30
|
+
${C}${w}${T} healthCheck: {
|
|
31
|
+
method: '${d.healthCheckMethod}',
|
|
32
|
+
timeoutMs: ${d.healthCheckTimeoutMs??5e3},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export function ${m}(registry: IntegrationSpecRegistry): IntegrationSpecRegistry {
|
|
37
|
+
return registry.register(${p});
|
|
38
|
+
}
|
|
39
|
+
`}export{d};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import{i as e,t}from"./utils.js";function n(n){let c=t(n.name.split(`.`).pop()??`KnowledgeSpace`),l=`${c}KnowledgeSpace`,u=`register${c}KnowledgeSpace`,d=r(n),f=i(n),p=a(n),m=n.policyName&&!n.policyVersion?` // defaults to latest version`:``;return`import { StabilityEnum } from '@lssm/lib.contracts/ownership';
|
|
2
|
+
import type { KnowledgeSpaceSpec } from '@lssm/lib.contracts/knowledge/spec';
|
|
3
|
+
import type { KnowledgeSpaceRegistry } from '@lssm/lib.contracts/knowledge/spec';
|
|
4
|
+
|
|
5
|
+
export const ${l}: KnowledgeSpaceSpec = {
|
|
6
|
+
meta: {
|
|
7
|
+
key: '${e(n.name)}',
|
|
8
|
+
version: ${n.version},
|
|
9
|
+
category: '${n.category}',
|
|
10
|
+
displayName: '${s(n.displayName)}',
|
|
11
|
+
title: '${s(n.title)}',
|
|
12
|
+
description: '${s(n.description)}',
|
|
13
|
+
domain: '${s(n.domain)}',
|
|
14
|
+
owners: [${n.owners.map(t=>`'${e(t)}'`).join(`, `)}],
|
|
15
|
+
tags: [${n.tags.map(t=>`'${e(t)}'`).join(`, `)}],
|
|
16
|
+
stability: StabilityEnum.${o(n.stability)},
|
|
17
|
+
},
|
|
18
|
+
retention: ${d},
|
|
19
|
+
access: {
|
|
20
|
+
${f}${n.policyName?` policy: { name: '${e(n.policyName)}',${n.policyVersion?` version: ${n.policyVersion}`:``} },${m}\n`:``} },
|
|
21
|
+
${p} description: '${s(n.description||n.displayName)}',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function ${u}(registry: KnowledgeSpaceRegistry): KnowledgeSpaceRegistry {
|
|
25
|
+
return registry.register(${l});
|
|
26
|
+
}
|
|
27
|
+
`}function r(e){return`{ ttlDays: ${e.retention.ttlDays===null?`null`:typeof e.retention.ttlDays==`number`?String(e.retention.ttlDays):`null`}${typeof e.retention.archiveAfterDays==`number`?`, archiveAfterDays: ${e.retention.archiveAfterDays}`:``} }`}function i(e){return`${` trustLevel: '${e.trustLevel}',\n`}${` automationWritable: ${e.automationWritable},\n`}`}function a(e){let t=[];return e.embeddingModel&&t.push(` embeddingModel: '${s(e.embeddingModel)}'`),typeof e.chunkSize==`number`&&t.push(` chunkSize: ${e.chunkSize}`),e.vectorDbIntegration&&t.push(` vectorDbIntegration: '${s(e.vectorDbIntegration)}'`),t.length===0?``:` indexing: {\n${t.join(`,
|
|
28
|
+
`)}\n },\n`}function o(e){switch(e){case`beta`:return`Beta`;case`stable`:return`Stable`;case`deprecated`:return`Deprecated`;case`experimental`:default:return`Experimental`}}function s(e){return e.replace(/`/g,"\\`").replace(/'/g,`\\'`)}export{n};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import{i as e,t}from"./utils.js";function n(n){let a=`${t(n.name.split(`.`).pop()??`Migration`)}Migration`,o=n.dependencies.length>0?`dependencies: [${n.dependencies.map(t=>`'${e(t)}'`).join(`, `)}],`:``;return`import type { MigrationSpec } from '@lssm/lib.contracts/migrations';
|
|
2
|
+
|
|
3
|
+
export const ${a}: MigrationSpec = {
|
|
4
|
+
meta: {
|
|
5
|
+
name: '${e(n.name)}',
|
|
6
|
+
version: ${n.version},
|
|
7
|
+
title: '${i(n.title)}',
|
|
8
|
+
description: '${i(n.description??``)}',
|
|
9
|
+
domain: '${i(n.domain)}',
|
|
10
|
+
owners: [${n.owners.map(t=>`'${e(t)}'`).join(`, `)}],
|
|
11
|
+
tags: [${n.tags.map(t=>`'${e(t)}'`).join(`, `)}],
|
|
12
|
+
stability: '${n.stability}',
|
|
13
|
+
},
|
|
14
|
+
plan: {
|
|
15
|
+
up: [
|
|
16
|
+
${r(n.up)}
|
|
17
|
+
],${n.down&&n.down.length?`
|
|
18
|
+
down: [
|
|
19
|
+
${r(n.down)}
|
|
20
|
+
],`:``}
|
|
21
|
+
},
|
|
22
|
+
${o}
|
|
23
|
+
};
|
|
24
|
+
`}function r(e){return e.map(e=>{let t=e.description?`description: '${i(e.description)}',`:``;switch(e.kind){case`schema`:return` {
|
|
25
|
+
kind: 'schema',
|
|
26
|
+
${t}
|
|
27
|
+
sql: \`${i(e.sql??``)}\`,
|
|
28
|
+
}`;case`data`:return` {
|
|
29
|
+
kind: 'data',
|
|
30
|
+
${t}
|
|
31
|
+
script: \`${i(e.script??``)}\`,
|
|
32
|
+
}`;case`validation`:default:return` {
|
|
33
|
+
kind: 'validation',
|
|
34
|
+
${t}
|
|
35
|
+
assertion: \`${i(e.assertion??``)}\`,
|
|
36
|
+
}`}}).join(`,
|
|
37
|
+
`)}function i(e){return e.replace(/`/g,"\\`").replace(/'/g,`\\'`)}export{n};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import{r as e,t}from"./utils.js";function n(n){let{name:r,version:i,kind:a,description:o,goal:s,context:c,stability:l,owners:u,tags:d,auth:f,flags:p}=n,m=t(r.split(`.`).pop()??`Unknown`)+`Spec`,h=m.replace(`Spec`,`Input`),g=m.replace(`Spec`,`Output`);return`import { define${e(a)} } from '@lssm/lib.contracts';
|
|
2
|
+
import { ScalarTypeEnum, SchemaModel } from '@lssm/lib.schema';
|
|
3
|
+
|
|
4
|
+
// TODO: Define input schema
|
|
5
|
+
export const ${h} = new SchemaModel({
|
|
6
|
+
name: '${h}',
|
|
7
|
+
description: 'Input for ${r}',
|
|
8
|
+
fields: {
|
|
9
|
+
// Add your fields here
|
|
10
|
+
// example: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// TODO: Define output schema
|
|
15
|
+
export const ${g} = new SchemaModel({
|
|
16
|
+
name: '${g}',
|
|
17
|
+
description: 'Output for ${r}',
|
|
18
|
+
fields: {
|
|
19
|
+
// Add your fields here
|
|
20
|
+
ok: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const ${m} = define${e(a)}({
|
|
25
|
+
meta: {
|
|
26
|
+
name: '${r}',
|
|
27
|
+
version: ${i},
|
|
28
|
+
stability: '${l}',
|
|
29
|
+
owners: [${u.map(e=>`'${e}'`).join(`, `)}],
|
|
30
|
+
tags: [${d.map(e=>`'${e}'`).join(`, `)}],
|
|
31
|
+
description: '${o}',
|
|
32
|
+
goal: '${s}',
|
|
33
|
+
context: '${c}',
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
io: {
|
|
37
|
+
input: ${h},
|
|
38
|
+
output: ${g},
|
|
39
|
+
errors: {
|
|
40
|
+
// Define possible errors
|
|
41
|
+
// EXAMPLE_ERROR: {
|
|
42
|
+
// description: 'Example error description',
|
|
43
|
+
// http: 400,
|
|
44
|
+
// when: 'When this error occurs',
|
|
45
|
+
// },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
policy: {
|
|
50
|
+
auth: '${f}',
|
|
51
|
+
${p.length>0?`flags: [${p.map(e=>`'${e}'`).join(`, `)}],`:`// flags: [],`}
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
sideEffects: {
|
|
55
|
+
${n.emitsEvents?`emits: [
|
|
56
|
+
// Define events to emit
|
|
57
|
+
// { ref: SomeEventSpec, when: 'always' }
|
|
58
|
+
],`:`// emits: [],`}
|
|
59
|
+
analytics: [
|
|
60
|
+
// Define analytics events
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
transport: {
|
|
65
|
+
rest: { method: '${a===`command`?`POST`:`GET`}' },
|
|
66
|
+
gql: { field: '${r.replace(/\./g,`_`)}' },
|
|
67
|
+
mcp: { toolName: '${r}.v${i}' },
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
acceptance: {
|
|
71
|
+
scenarios: [
|
|
72
|
+
{
|
|
73
|
+
name: 'Happy path',
|
|
74
|
+
given: ['preconditions'],
|
|
75
|
+
when: ['action taken'],
|
|
76
|
+
then: ['expected outcome'],
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
examples: [
|
|
80
|
+
{
|
|
81
|
+
name: 'Example usage',
|
|
82
|
+
input: { /* example input */ },
|
|
83
|
+
output: { ok: true },
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
`}export{n};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import{t as e}from"./utils.js";function t(t){let{name:n,version:r,description:i,stability:a,owners:o,tags:s,presentationKind:c}=t,l=e(n.replace(/\./g,`_`))+`Presentation`,u=``;switch(c){case`web_component`:u=` content: {
|
|
2
|
+
kind: 'web_component',
|
|
3
|
+
framework: 'react',
|
|
4
|
+
componentKey: '${n.replace(/\./g,`_`)}',
|
|
5
|
+
props: new SchemaModel({
|
|
6
|
+
name: '${l}Props',
|
|
7
|
+
description: 'Props for ${n}',
|
|
8
|
+
fields: {
|
|
9
|
+
// TODO: Define component props
|
|
10
|
+
},
|
|
11
|
+
}),
|
|
12
|
+
analytics: [
|
|
13
|
+
// TODO: Define analytics events
|
|
14
|
+
],
|
|
15
|
+
},`;break;case`markdown`:u=` content: {
|
|
16
|
+
kind: 'markdown',
|
|
17
|
+
content: \`
|
|
18
|
+
# ${i}
|
|
19
|
+
|
|
20
|
+
TODO: Add markdown content here
|
|
21
|
+
\`,
|
|
22
|
+
// Or use resourceUri: 'feature://${n}/guide.md'
|
|
23
|
+
},`;break;case`data`:u=` content: {
|
|
24
|
+
kind: 'data',
|
|
25
|
+
mimeType: 'application/json',
|
|
26
|
+
model: new SchemaModel({
|
|
27
|
+
name: '${l}Data',
|
|
28
|
+
description: 'Data structure for ${n}',
|
|
29
|
+
fields: {
|
|
30
|
+
// TODO: Define data structure
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
},`;break}return`import type { PresentationSpec } from '@lssm/lib.contracts/presentations';
|
|
34
|
+
import { SchemaModel, ScalarTypeEnum } from '@lssm/lib.schema';
|
|
35
|
+
|
|
36
|
+
export const ${l}: PresentationSpec = {
|
|
37
|
+
meta: {
|
|
38
|
+
name: '${n}',
|
|
39
|
+
version: ${r},
|
|
40
|
+
stability: '${a}',
|
|
41
|
+
owners: [${o.map(e=>`'${e}'`).join(`, `)}],
|
|
42
|
+
tags: [${s.map(e=>`'${e}'`).join(`, `)}],
|
|
43
|
+
description: '${i}',
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
policy: {
|
|
47
|
+
// flags: [],
|
|
48
|
+
// pii: [],
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
${u}
|
|
52
|
+
};
|
|
53
|
+
`}export{t};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import{t as e}from"./utils.js";function t(t){let i=e(t.name.split(`.`).pop()??`Telemetry`)+`Telemetry`,a=t.providers?.length?`providers: [
|
|
2
|
+
${t.providers.map(e=>` {
|
|
3
|
+
type: '${e.type}',
|
|
4
|
+
config: ${r(e.config)},
|
|
5
|
+
}`).join(`,
|
|
6
|
+
`)}
|
|
7
|
+
],`:``,o=t.events.map(e=>{let t=e.properties.map(e=>` '${e.name}': {
|
|
8
|
+
type: '${e.type}',
|
|
9
|
+
${e.required?`required: true,`:``}
|
|
10
|
+
${e.pii?`pii: true,`:``}
|
|
11
|
+
${e.redact?`redact: true,`:``}
|
|
12
|
+
${e.description?`description: '${n(e.description)}',`:``}
|
|
13
|
+
}`).join(`,
|
|
14
|
+
`),r=e.anomalyRules?.length?` anomalyDetection: {
|
|
15
|
+
enabled: true,
|
|
16
|
+
${typeof e.anomalyMinimumSample==`number`?`minimumSample: ${e.anomalyMinimumSample},`:``}
|
|
17
|
+
thresholds: [
|
|
18
|
+
${e.anomalyRules.map(e=>` {
|
|
19
|
+
metric: '${n(e.metric)}',
|
|
20
|
+
${typeof e.min==`number`?`min: ${e.min},`:``}
|
|
21
|
+
${typeof e.max==`number`?`max: ${e.max},`:``}
|
|
22
|
+
}`).join(`,
|
|
23
|
+
`)}
|
|
24
|
+
],
|
|
25
|
+
actions: [${(e.anomalyActions??[]).map(e=>`'${e}'`).join(`, `)}],
|
|
26
|
+
},`:e.anomalyEnabled?` anomalyDetection: {
|
|
27
|
+
enabled: true,
|
|
28
|
+
${typeof e.anomalyMinimumSample==`number`?`minimumSample: ${e.anomalyMinimumSample},`:``}
|
|
29
|
+
},`:``;return` {
|
|
30
|
+
name: '${n(e.name)}',
|
|
31
|
+
version: ${e.version},
|
|
32
|
+
semantics: {
|
|
33
|
+
what: '${n(e.what)}',
|
|
34
|
+
${e.who?`who: '${n(e.who)}',`:``}
|
|
35
|
+
${e.why?`why: '${n(e.why)}',`:``}
|
|
36
|
+
},
|
|
37
|
+
privacy: '${e.privacy}',
|
|
38
|
+
properties: {
|
|
39
|
+
${t}
|
|
40
|
+
},
|
|
41
|
+
${typeof e.retentionDays==`number`?`retention: { days: ${e.retentionDays}, ${e.retentionPolicy?`policy: '${e.retentionPolicy}'`:``} },`:``}
|
|
42
|
+
${typeof e.samplingRate==`number`?`sampling: { rate: ${e.samplingRate}${e.samplingConditions?`, conditions: ['${n(e.samplingConditions)}']`:``} },`:``}
|
|
43
|
+
${r}
|
|
44
|
+
${e.tags?.length?`tags: [${e.tags.map(e=>`'${n(e)}'`).join(`, `)}],`:``}
|
|
45
|
+
}`}).join(`,
|
|
46
|
+
`);return`import type { TelemetrySpec } from '@lssm/lib.contracts/telemetry';
|
|
47
|
+
|
|
48
|
+
export const ${i}: TelemetrySpec = {
|
|
49
|
+
meta: {
|
|
50
|
+
name: '${n(t.name)}',
|
|
51
|
+
version: ${t.version},
|
|
52
|
+
title: '${n(t.name)} telemetry',
|
|
53
|
+
description: '${n(t.description||`Describe the purpose of this telemetry spec.`)}',
|
|
54
|
+
domain: '${n(t.domain)}',
|
|
55
|
+
owners: [${t.owners.map(e=>`'${n(e)}'`).join(`, `)}],
|
|
56
|
+
tags: [${t.tags.map(e=>`'${n(e)}'`).join(`, `)}],
|
|
57
|
+
stability: '${t.stability}',
|
|
58
|
+
},
|
|
59
|
+
config: {
|
|
60
|
+
${typeof t.defaultRetentionDays==`number`?`defaultRetentionDays: ${t.defaultRetentionDays},`:``}
|
|
61
|
+
${typeof t.defaultSamplingRate==`number`?`defaultSamplingRate: ${t.defaultSamplingRate},`:``}
|
|
62
|
+
${t.anomalyEnabled?`anomalyDetection: { enabled: true${typeof t.anomalyCheckIntervalMs==`number`?`, checkIntervalMs: ${t.anomalyCheckIntervalMs}`:``} },`:``}
|
|
63
|
+
${a}
|
|
64
|
+
},
|
|
65
|
+
events: [
|
|
66
|
+
${o}
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
`}function n(e){return e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}function r(e){let t=e.trim();return t?t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`)?t:`'${n(t)}'`:`{}`}export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){let n=t(e);return n.charAt(0).toLowerCase()+n.slice(1)}function t(e){return e.split(/[-_.]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function n(e){return e.replace(/\./g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}function r(e){return e.charAt(0).toUpperCase()+e.slice(1)}function i(e){return e.replace(/'/g,`\\'`)}export{e,i,n,r,t};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function e({exportName:e,specImportPath:t,runnerName:n,workflowName:r}){return`import {
|
|
2
|
+
InMemoryStateStore,
|
|
3
|
+
WorkflowRegistry,
|
|
4
|
+
WorkflowRunner,
|
|
5
|
+
} from '@lssm/lib.contracts/workflow';
|
|
6
|
+
import { ${e} } from '${t}';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Runner wiring for ${r}.
|
|
10
|
+
*
|
|
11
|
+
* TODO:
|
|
12
|
+
* - Replace the in-memory state store with a persistent adapter if needed.
|
|
13
|
+
* - Implement opExecutor to invoke the correct contract handlers.
|
|
14
|
+
* - Wire eventEmitter to telemetry sinks.
|
|
15
|
+
*/
|
|
16
|
+
const registry = new WorkflowRegistry();
|
|
17
|
+
registry.register(${e});
|
|
18
|
+
|
|
19
|
+
const stateStore = new InMemoryStateStore();
|
|
20
|
+
|
|
21
|
+
export const ${n} = new WorkflowRunner({
|
|
22
|
+
registry,
|
|
23
|
+
stateStore,
|
|
24
|
+
opExecutor: async (operation, input, ctx) => {
|
|
25
|
+
// TODO: route to the appropriate contract handler
|
|
26
|
+
// Example: return contractRegistry.execute(operation.name, operation.version, input, ctx);
|
|
27
|
+
throw new Error(
|
|
28
|
+
\`opExecutor for \${operation.name}.v\${operation.version} is not implemented\`
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
// appConfigProvider: async (state) => {
|
|
32
|
+
// // TODO: return the ResolvedAppConfig for this workflow run (tenant/environment)
|
|
33
|
+
// return undefined;
|
|
34
|
+
// },
|
|
35
|
+
// enforceCapabilities: async (operation, context) => {
|
|
36
|
+
// // TODO: ensure required capabilities are satisfied using context.integrations/context.resolvedAppConfig
|
|
37
|
+
// },
|
|
38
|
+
eventEmitter: (_event, _payload) => {
|
|
39
|
+
// TODO: forward workflow events to telemetry or logging sinks
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
`}export{e};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import{i as e,t}from"./utils.js";function n(n){let i=t(n.name.split(`.`).pop()??`Workflow`)+`Workflow`,a=n.steps.map(e=>r(e)).join(`,
|
|
2
|
+
`),o=n.transitions.map(t=>` {
|
|
3
|
+
from: '${t.from}',
|
|
4
|
+
to: '${t.to}',
|
|
5
|
+
${t.condition?` condition: '${e(t.condition)}',`:``}
|
|
6
|
+
}`).join(`,
|
|
7
|
+
`);return`import type { WorkflowSpec } from '@lssm/lib.contracts/workflow';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Workflow generated via contractspec CLI.
|
|
11
|
+
* TODO:
|
|
12
|
+
* - Review step definitions and descriptions.
|
|
13
|
+
* - Wire automation steps to actual operations.
|
|
14
|
+
* - Provide form renderers for human steps.
|
|
15
|
+
* - Add guards/conditions as needed.
|
|
16
|
+
*/
|
|
17
|
+
export const ${i}: WorkflowSpec = {
|
|
18
|
+
meta: {
|
|
19
|
+
name: '${n.name}',
|
|
20
|
+
version: ${n.version},
|
|
21
|
+
title: '${e(n.title)}',
|
|
22
|
+
description: '${e(n.description)}',
|
|
23
|
+
domain: '${e(n.domain)}',
|
|
24
|
+
stability: '${n.stability}',
|
|
25
|
+
owners: [${n.owners.map(e=>`'${e}'`).join(`, `)}],
|
|
26
|
+
tags: [${n.tags.map(e=>`'${e}'`).join(`, `)}],
|
|
27
|
+
},
|
|
28
|
+
definition: {
|
|
29
|
+
${n.entryStepId?` entryStepId: '${n.entryStepId}',\n`:``} steps: [
|
|
30
|
+
${a}
|
|
31
|
+
],
|
|
32
|
+
transitions: [
|
|
33
|
+
${o}
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
${n.policyFlags.length>0?`policy: {
|
|
37
|
+
flags: [${n.policyFlags.map(e=>`'${e}'`).join(`, `)}],
|
|
38
|
+
},`:`// policy: { flags: [] },`}
|
|
39
|
+
};
|
|
40
|
+
`}function r(t){let n=[` {`,` id: '${t.id}',`,` type: '${t.type}',`,` label: '${e(t.label)}',`];t.description&&n.push(` description: '${e(t.description)}',`);let r=[];return t.operation&&r.push(`operation: { name: '${t.operation.name}', version: ${t.operation.version} }`),t.form&&r.push(`form: { key: '${t.form.key}', version: ${t.form.version} }`),r.length&&n.push(` action: { ${r.join(`, `)} },`),n.push(` }`),n.join(`
|
|
41
|
+
`)}export{n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={aiProvider:`claude`,agentMode:`simple`,outputDir:`./src`,conventions:{operations:`interactions/commands|queries`,events:`events`,presentations:`presentations`,forms:`forms`},defaultOwners:[],defaultTags:[]};export{e};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e}from"../../../libs/contracts/dist/llm/prompts.js";import"../../../libs/contracts/dist/llm/index.js";var t=class{agentType=`claude-code`;formatPlan(t){let n=[];if(n.push(`# Implement: ${t.target.name}.v${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(t.context.background),n.push(``)),n.push(`## Specification`),n.push(``),n.push(t.specMarkdown),n.push(``),t.fileStructure.length>0){n.push(`## Files to Create/Modify`),n.push(``);for(let e of t.fileStructure){let t=e.type===`create`?`📝`:`✏️`;n.push(`${t} \`${e.path}\``),n.push(` ${e.purpose}`),n.push(``)}}n.push(`## Implementation Steps`),n.push(``);for(let e of t.steps){n.push(`### ${e.order}. ${e.title}`),n.push(``),n.push(e.description),n.push(``),n.push(`**Acceptance Criteria:**`);for(let t of e.acceptanceCriteria)n.push(`- [ ] ${t}`);n.push(``)}if(t.constraints.policy.length>0||t.constraints.security.length>0||t.constraints.pii.length>0){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 Handling`),n.push(`The following fields contain personally identifiable information:`);for(let e of t.constraints.pii)n.push(`- \`${e}\``);n.push(``)}}n.push(`## Verification Checklist`),n.push(``),n.push(`Before submitting, verify:`);for(let e of t.verificationChecklist)n.push(`- [ ] ${e}`);return n.push(``),n.push(`## Instructions`),n.push(``),n.push(`1. Implement each step in order`),n.push("2. Use TypeScript with strict typing (no `any`)"),n.push(`3. Include JSDoc comments for public APIs`),n.push(`4. Handle all error cases defined in the spec`),n.push(`5. Emit events as specified`),n.push(`6. Mark checklist items as you complete them`),n.push(``),{agent:`claude-code`,systemPrompt:e[`claude-code`],taskPrompt:n.join(`
|
|
2
2
|
`)}}generateConfig(e){let t=[];return t.push(`# ContractSpec Implementation Context`),t.push(``),t.push(`This codebase uses ContractSpec for spec-first development.`),t.push(``),t.push(`## Spec Details`),t.push(``),t.push(`- **Name:** ${e.meta.name}`),t.push(`- **Version:** ${e.meta.version}`),t.push(`- **Kind:** ${e.meta.kind}`),t.push(`- **Stability:** ${e.meta.stability}`),t.push(``),t.push(`## Implementation Requirements`),t.push(``),t.push(`1. Match input/output types exactly`),t.push(`2. Handle all defined error cases`),t.push(`3. Emit events as specified`),t.push(`4. Respect policy constraints`),t.push(``),t.join(`
|
|
3
3
|
`)}parseOutput(e){let t=e.match(/```(?:typescript|ts|tsx)?\n([\s\S]*?)\n```/);if(t?.[1])return{code:t[1]};let n=[];for(let t of[/error:\s*(.+)/gi,/failed:\s*(.+)/gi,/cannot\s+(.+)/gi]){let r=e.matchAll(t);for(let e of r)e[1]&&n.push(e[1])}return n.length>0?{errors:n}:{code:e}}};const n=new t;export{t as ClaudeCodeAdapter,n as claudeCodeAdapter};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e}from"../../../libs/contracts/dist/llm/prompts.js";import"../../../libs/contracts/dist/llm/index.js";var t=class{agentType=`cursor-cli`;formatPlan(t){let n=[];if(n.push(`# ${t.target.name}.v${t.target.version}`),n.push(``),n.push(`> ${t.context.goal}`),n.push(``),t.fileStructure.length>0){n.push(`## Files`),n.push(``);for(let e of t.fileStructure)n.push(`- ${e.type}: \`${e.path}\` - ${e.purpose}`);n.push(``)}n.push(`## Spec`),n.push(``),n.push(t.specMarkdown),n.push(``),n.push(`## Steps`),n.push(``);for(let e of t.steps)n.push(`${e.order}. **${e.title}**: ${e.description}`);n.push(``);let r=[...t.constraints.policy,...t.constraints.security.map(e=>`⚠️ ${e}`)];if(r.length>0){n.push(`## Constraints`),n.push(``);for(let e of r)n.push(`- ${e}`);n.push(``)}return t.constraints.pii.length>0&&(n.push(`## PII Fields`),n.push(``),n.push(`Handle carefully: ${t.constraints.pii.map(e=>`\`${e}\``).join(`, `)}`),n.push(``)),{agent:`cursor-cli`,systemPrompt:e[`cursor-cli`],taskPrompt:n.join(`
|
|
2
2
|
`)}}generateConfig(e){let t=e.meta,n=[];if(n.push(`---`),n.push(`description: Implementation rules for ${t.name}.v${t.version}`),n.push(`globs: ["**/${t.name.replace(/\./g,`/`)}/**"]`),n.push(`alwaysApply: false`),n.push(`---`),n.push(``),n.push(`# ${t.name} Implementation Rules`),n.push(``),n.push(`This ${t.kind} operation must follow the ContractSpec specification.`),n.push(``),n.push(`## Goal`),n.push(``),n.push(t.goal),n.push(``),n.push(`## Requirements`),n.push(``),n.push(`1. Input/output types MUST match the spec schema exactly`),n.push(`2. All error cases MUST be handled`),e.sideEffects?.emits?.length&&n.push(`3. Events MUST be emitted as specified`),n.push(`4. Auth level: ${e.policy.auth}`),e.policy.idempotent!==void 0&&n.push(`5. Idempotency: ${e.policy.idempotent}`),n.push(``),e.io.errors&&Object.keys(e.io.errors).length>0){n.push(`## Error Cases`),n.push(``);for(let[t,r]of Object.entries(e.io.errors))n.push(`- \`${t}\` (HTTP ${r.http??400}): ${r.when}`);n.push(``)}if(e.sideEffects?.emits?.length){n.push(`## Events to Emit`),n.push(``);for(let t of e.sideEffects.emits)`ref`in t?n.push(`- \`${t.ref.name}.v${t.ref.version}\`: ${t.when}`):n.push(`- \`${t.name}.v${t.version}\`: ${t.when}`);n.push(``)}if(e.policy.pii?.length){n.push(`## PII Handling`),n.push(``),n.push(`These fields contain PII and must be handled with care:`);for(let t of e.policy.pii)n.push(`- \`${t}\``);n.push(``)}if(e.acceptance?.scenarios?.length){n.push(`## Acceptance Scenarios`),n.push(``);for(let t of e.acceptance.scenarios)n.push(`### ${t.name}`),n.push(`- Given: ${t.given.join(`; `)}`),n.push(`- When: ${t.when.join(`; `)}`),n.push(`- Then: ${t.then.join(`; `)}`),n.push(``)}return n.join(`
|
|
3
|
-
`)}getCursorRulesPath(e){return`.cursor/rules/${e.meta.name.replace(/\./g,`-`)}.mdc`}parseOutput(e){let t=e.match(/```(?:typescript|ts|tsx|javascript|js)?\n([\s\S]*?)\n```/);return t?.[1]?{code:t[1]}:{code:e}}};const
|
|
3
|
+
`)}getCursorRulesPath(e){return`.cursor/rules/${e.meta.name.replace(/\./g,`-`)}.mdc`}parseOutput(e){let t=e.match(/```(?:typescript|ts|tsx|javascript|js)?\n([\s\S]*?)\n```/);return t?.[1]?{code:t[1]}:{code:e}}};const n=new t;export{t as CursorCLIAdapter,n as cursorCLIAdapter};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e}from"../../../libs/contracts/dist/llm/prompts.js";import"../../../libs/contracts/dist/llm/index.js";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
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
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 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as e,o as t,s as n}from"../../libs/contracts/dist/llm/exporters.js";import{s as r}from"../../libs/contracts/dist/llm/prompts.js";import"../../libs/contracts/dist/llm/index.js";import{getAgentAdapter as i,listAgentTypes as a}from"./adapters/index.js";const o={defaultAgent:`generic-mcp`,verbose:!1};var s=class{config;constructor(e={}){this.config={...o,...e}}generateGuide(t,n={}){let a=i(n.agent??this.config.defaultAgent),o=r(t,{projectRoot:this.config.projectRoot,existingFiles:n.targetPath?[n.targetPath]:void 0});return{plan:o,prompt:a.formatPlan(o),markdown:e(t)}}generateFeatureGuide(e,t,a={}){let o=i(a.agent??this.config.defaultAgent),s=e.operations?.[0],c=s?t.specs?.getSpec(s.name,s.version):void 0,l;c?(l=r(c,{projectRoot:this.config.projectRoot}),l.target={type:`feature`,name:e.meta.key,version:1},l.context.goal=e.meta.description??l.context.goal):l={target:{type:`feature`,name:e.meta.key,version:1},context:{goal:e.meta.description??`Implement feature ${e.meta.key}`,description:e.meta.title??e.meta.key,background:``},specMarkdown:n(e,t),fileStructure:[],steps:[{order:1,title:`Implement Feature`,description:`Implement the ${e.meta.key} feature`,acceptanceCriteria:[]}],constraints:{policy:[],security:[],pii:[]},verificationChecklist:[]},l.specMarkdown=n(e,t,{format:`full`,includeRelatedSpecs:!0,includeRelatedEvents:!0,includeRelatedPresentations:!0}),e.operations?.length&&(l.steps=e.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(e,t);return{plan:l,prompt:u,markdown:d}}generateAgentConfig(e,t){return i(t??this.config.defaultAgent).generateConfig?.(e)}exportForAgent(e,n,r=`implement`,i){return t(e,{taskType:r,existingCode:i})}listAgentTypes(){return a()}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};
|
package/dist/services/build.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{e,t}from"../modules/contractspec-workspace/dist/analysis/spec-scan.js";import{a as n,i as r,r as i}from"../modules/contractspec-workspace/dist/templates/handler.js";async function a(n,r,i,a={}){let{fs:c,logger:l}=r,{targets:u=s(n),outputDir:d=i.outputDir,overwrite:f=!1,dryRun:p=!1}=a,m=await c.readFile(n),h=t(m,n),g=e(n);l.info(`Building from spec: ${n}`,{specType:g});let _=[];for(let e of u)try{let t=await o(e,n,m,h,g,{fs:c,logger:l},d,f,p);_.push(t)}catch(t){_.push({target:e,outputPath:``,success:!1,error:t instanceof Error?t.message:String(t)})}return{specPath:n,specInfo:h,results:_}}async function o(e,t,a,o,s,l,u,d,f){let{fs:p,logger:m}=l,h,g;switch(e){case`handler`:{if(s!==`operation`)return{target:e,outputPath:``,success:!1,skipped:!0,error:`Handler generation only supported for operation specs (got ${s})`};let n=o.kind===`command`||o.kind===`query`?o.kind:`command`;h=i(o.name??`unknown`,n),g=c(t,u,`handlers`,o.name??`unknown`,`.handler.ts`,l.fs);break}case`component`:if(s!==`presentation`)return{target:e,outputPath:``,success:!1,skipped:!0,error:`Component generation only supported for presentation specs (got ${s})`};h=r(o.name??`unknown`,o.description??``),g=c(t,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(t,u,`__tests__`,o.name??`unknown`,`.test.ts`,l.fs);break}default:return{target:e,outputPath:``,success:!1,error:`Unknown target: ${e}`}}if(await p.exists(g)&&!d)return{target:e,outputPath:g,success:!1,skipped:!0,error:`File already exists (use overwrite option)`};if(f)return m.info(`[dry-run] Would write: ${g}`),{target:e,outputPath:g,success:!0};let _=p.dirname(g);return await p.mkdir(_),await p.writeFile(g,h),m.info(`Generated: ${g}`),{target:e,outputPath:g,success:!0}}function s(t){switch(e(t)){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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{validateImplementationFiles as
|
|
1
|
+
import{e}from"../../modules/contractspec-workspace/dist/analysis/feature-scan.js";import{e as t}from"../../modules/contractspec-workspace/dist/analysis/validate/spec-structure.js";import{validateImplementationFiles as n}from"../validate-implementation.js";import{analyzeDeps as r}from"../deps.js";import{loadWorkspaceConfig as i}from"../config.js";import{analyzeIntegrity as a}from"../integrity.js";import{runDoctor as o}from"../doctor/doctor-service.js";import{resolveAllImplementations as s}from"../implementation/resolver.js";import"../verification-cache/index.js";async function c(t,n={}){let r=Date.now(),{fs:i,logger:a}=t,o=[],s=[],c=l(n);a.info(`Starting CI checks...`,{checks:c});let y=(await i.glob({pattern:n.pattern})).filter(t=>!e(t)&&!t.includes(`.test.`)&&!t.includes(`.spec.`));if(c.includes(`structure`)){let e=Date.now(),n=await u(t,y);o.push(...n),s.push(_(`structure`,n,Date.now()-e))}if(c.includes(`integrity`)){let e=Date.now(),r=await d(t,n);o.push(...r),s.push(_(`integrity`,r,Date.now()-e))}if(c.includes(`deps`)){let e=Date.now(),r=await f(t,n);o.push(...r),s.push(_(`deps`,r,Date.now()-e))}if(c.includes(`doctor`)){let e=Date.now(),r=await p(t,n);o.push(...r),s.push(_(`doctor`,r,Date.now()-e))}if(c.includes(`handlers`)||n.checkHandlers){let e=Date.now(),n=await m(t,y);o.push(...n),s.push(_(`handlers`,n,Date.now()-e))}if(c.includes(`tests`)||n.checkTests){let e=Date.now(),n=await h(t,y);o.push(...n),s.push(_(`tests`,n,Date.now()-e))}if(c.includes(`implementation`)){let e=Date.now(),r=await g(t,y,n);o.push(...r),s.push(_(`implementation`,r,Date.now()-e))}let b=o.filter(e=>e.severity===`error`).length,x=o.filter(e=>e.severity===`warning`).length,S=o.filter(e=>e.severity===`note`).length,C=n.failOnWarnings?b===0&&x===0:b===0,w=await v(i),T={success:C,totalErrors:b,totalWarnings:x,totalNotes:S,issues:o,categories:s,durationMs:Date.now()-r,timestamp:new Date().toISOString(),...w};return a.info(`CI checks complete`,{success:C,errors:b,warnings:x,durationMs:T.durationMs}),T}function l(e){let t=[`structure`,`integrity`,`deps`,`doctor`];return e.checkHandlers&&t.push(`handlers`),e.checkTests&&t.push(`tests`),e.implementation&&t.push(`implementation`),e.checks&&e.checks.length>0?e.checks:e.skip&&e.skip.length>0?t.filter(t=>!e.skip?.includes(t)):t}async function u(e,n){let{fs:r}=e,i=[];for(let e of n){let n=t(await r.readFile(e),r.basename(e));for(let t of n.errors)i.push({ruleId:`spec-structure-error`,severity:`error`,message:t,category:`structure`,file:e});for(let t of n.warnings)i.push({ruleId:`spec-structure-warning`,severity:`warning`,message:t,category:`structure`,file:e})}return i}async function d(e,t){let n=[],r=await a(e,{pattern:t.pattern,all:!0});for(let e of r.issues)n.push({ruleId:`integrity-${e.type}`,severity:e.severity===`error`?`error`:`warning`,message:e.message,category:`integrity`,file:e.file,context:{specName:e.specName,specType:e.specType,featureKey:e.featureKey,ref:e.ref}});return n}async function f(e,t){let n=[],i=await r(e,{pattern:t.pattern});for(let e of i.cycles)n.push({ruleId:`deps-circular`,severity:`error`,message:`Circular dependency detected: ${e.join(` → `)}`,category:`deps`,context:{cycle:e}});for(let e of i.missing)for(let t of e.missing)n.push({ruleId:`deps-missing`,severity:`error`,message:`Missing dependency: ${e.contract} requires ${t}`,category:`deps`,context:{contract:e.contract,missing:t}});return n}async function p(e,t){let n=[],r=await o(e,{workspaceRoot:t.workspaceRoot??process.cwd(),skipAi:!0,categories:[`cli`,`config`,`deps`,`workspace`]});for(let e of r.checks)e.status===`fail`?n.push({ruleId:`doctor-${e.category}-${e.name.toLowerCase().replace(/\s+/g,`-`)}`,severity:`error`,message:`${e.name}: ${e.message}`,category:`doctor`,context:{details:e.details}}):e.status===`warn`&&n.push({ruleId:`doctor-${e.category}-${e.name.toLowerCase().replace(/\s+/g,`-`)}`,severity:`warning`,message:`${e.name}: ${e.message}`,category:`doctor`,context:{details:e.details}});return n}async function m(e,t){let{fs:r}=e,a=[],o=await i(r);for(let e of t){if(!e.includes(`.contracts.`))continue;let t=await n(e,{fs:r},o,{checkHandlers:!0,outputDir:o.outputDir});for(let n of t.errors)a.push({ruleId:`handler-missing`,severity:`warning`,message:n,category:`handlers`,file:e});for(let n of t.warnings)a.push({ruleId:`handler-warning`,severity:`warning`,message:n,category:`handlers`,file:e})}return a}async function h(e,t){let{fs:r}=e,a=[],o=await i(r);for(let e of t){if(!e.includes(`.contracts.`))continue;let t=await n(e,{fs:r},o,{checkTests:!0,outputDir:o.outputDir});for(let n of t.errors)a.push({ruleId:`test-missing`,severity:`warning`,message:n,category:`tests`,file:e});for(let n of t.warnings)a.push({ruleId:`test-warning`,severity:`warning`,message:n,category:`tests`,file:e})}return a}async function g(e,t,n){let{fs:r}=e,a=[],o=await i(r),c=n.implementation??{},l=await s(t.filter(e=>e.includes(`.contracts.`)),{fs:r},o,{computeHashes:c.useCache??!0});for(let e of l){if(c.requireImplemented&&e.status===`missing`?a.push({ruleId:`impl-missing`,severity:`error`,message:`Spec ${e.specName} has no implementation`,category:`implementation`,file:e.specPath,context:{specName:e.specName,specVersion:e.specVersion,status:e.status}}):e.status===`missing`&&a.push({ruleId:`impl-missing`,severity:`warning`,message:`Spec ${e.specName} has no implementation`,category:`implementation`,file:e.specPath,context:{specName:e.specName,specVersion:e.specVersion,status:e.status}}),!c.allowPartial&&e.status===`partial`){let t=e.implementations.filter(e=>!e.exists&&e.type!==`test`).map(e=>e.path);a.push({ruleId:`impl-partial`,severity:`warning`,message:`Spec ${e.specName} has partial implementation: missing ${t.join(`, `)}`,category:`implementation`,file:e.specPath,context:{specName:e.specName,specVersion:e.specVersion,status:e.status,missingFiles:t}})}let t=e.implementations.filter(e=>!e.exists&&e.type===`test`);t.length>0&&a.push({ruleId:`impl-missing-tests`,severity:`note`,message:`Spec ${e.specName} missing test files: ${t.map(e=>e.path).join(`, `)}`,category:`implementation`,file:e.specPath,context:{specName:e.specName,missingTests:t.map(e=>e.path)}})}return a}function _(e,t,n){let r={structure:`Spec Structure Validation`,integrity:`Contract Integrity Analysis`,deps:`Dependency Analysis`,doctor:`Installation Health`,handlers:`Handler Implementation`,tests:`Test Coverage`,implementation:`Implementation Verification`},i=t.filter(e=>e.severity===`error`).length,a=t.filter(e=>e.severity===`warning`).length,o=t.filter(e=>e.severity===`note`).length;return{category:e,label:r[e],errors:i,warnings:a,notes:o,passed:i===0,durationMs:n}}async function v(e){try{let t=`.git/HEAD`;if(!await e.exists(t))return{};let n=await e.readFile(t),r=n.match(/^ref: (.+)$/m);if(r){let t=r[1]?.replace(`refs/heads/`,``),n=`.git/${r[1]}`;return await e.exists(n)?{commitSha:(await e.readFile(n)).trim(),branch:t}:{branch:t}}return{commitSha:n.trim()}}catch{return{}}}export{c as runCIChecks};
|
package/dist/services/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{e}from"../modules/contractspec-workspace/dist/types/generation-types.js";import*as t from"zod";const n=t.object({aiProvider:t.enum([`claude`,`openai`,`ollama`,`custom`]).default(`claude`),aiModel:t.string().optional(),agentMode:t.enum([`simple`,`cursor`,`claude-code`,`openai-codex`]).default(`simple`),customEndpoint:t.string().url().nullable().optional(),customApiKey:t.string().nullable().optional(),outputDir:t.string().default(`./src`),conventions:t.object({operations:t.string().default(`interactions/commands|queries`),events:t.string().default(`events`),presentations:t.string().default(`presentations`),forms:t.string().default(`forms`)}),defaultOwners:t.array(t.string()).default([]),defaultTags:t.array(t.string()).default([])});async function r(t,r){let i=t.join(r??`.`,`.contractsrc.json`);if(!await t.exists(i))return e;try{let e=await t.readFile(i),r=JSON.parse(e);return n.parse(r)}catch{return e}}function i(e,t){return{...e,aiProvider:t.provider??process.env.CONTRACTSPEC_AI_PROVIDER??e.aiProvider,aiModel:t.model??process.env.CONTRACTSPEC_AI_MODEL??e.aiModel,agentMode:t.agentMode??process.env.CONTRACTSPEC_AGENT_MODE??e.agentMode,customEndpoint:t.endpoint??process.env.CONTRACTSPEC_LLM_ENDPOINT??e.customEndpoint??void 0,customApiKey:process.env.CONTRACTSPEC_LLM_API_KEY??e.customApiKey??void 0,outputDir:t.outputDir??e.outputDir}}function a(e){switch(e){case`claude`:return process.env.ANTHROPIC_API_KEY;case`openai`:return process.env.OPENAI_API_KEY;case`custom`:return process.env.CONTRACTSPEC_LLM_API_KEY;case`ollama`:return;default:return}}export{a as getApiKey,r as loadWorkspaceConfig,i as mergeWorkspaceConfig};
|
package/dist/services/deps.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as e,e as t,i as n,n as r,r as i,t as a}from"../modules/contractspec-workspace/dist/analysis/deps/graph.js";import{e as o}from"../modules/contractspec-workspace/dist/analysis/deps/parse-imports.js";async function s(i,s={}){let{fs:c}=i,l=await c.glob({pattern:s.pattern}),u=n();for(let t of l){let n=await c.readFile(t),r=c.relative(`.`,t),i=n.match(/name:\s*['"]([^'"]+)['"]/);e(u,(i?.[1]?i[1]:c.basename(t).replace(/\.[jt]s$/,``).replace(/\.(contracts|event|presentation|workflow|data-view|migration|telemetry|experiment|app-config|integration|knowledge)$/,``))||`unknown`,r,o(n,t))}t(u);let d=a(u),f=r(u);return{graph:u,total:u.size,cycles:d,missing:f}}function c(e,t){return e.get(t)}function l(e){return i(e)}function u(e){let t=Array.from(e.values()),n=t.filter(e=>e.dependencies.length>0),r=t.filter(e=>e.dependencies.length===0),i=t.filter(e=>e.dependents.length>0),a=t.filter(e=>e.dependents.length===0);return{total:e.size,withDeps:n.length,withoutDeps:r.length,used:i.length,unused:a.length}}export{s as analyzeDeps,l as exportGraphAsDot,c as getContractNode,u as getGraphStats};
|
package/dist/services/diff.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"../modules/contractspec-workspace/dist/analysis/diff/semantic.js";async function t(t,n,r,i={}){let{fs:a,git:o}=r;if(!await a.exists(t))throw Error(`Spec file not found: ${t}`);let s=await a.readFile(t),c,l;if(i.baseline)c=await o.showFile(i.baseline,t),l=`${i.baseline}:${t}`;else{if(!await a.exists(n))throw Error(`Spec file not found: ${n}`);c=await a.readFile(n),l=n}let u=e(s,t,c,l,{breakingOnly:i.breakingOnly});return{spec1:t,spec2:l,differences:u}}export{t as compareSpecs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"../../modules/contractspec-workspace/dist/analysis/spec-scan.js";import{discoverImplementationsForSpec as t}from"./discovery.js";import{createHash as n}from"crypto";const r={includeExplicit:!0,includeDiscovered:!0,includeConvention:!0,computeHashes:!0};function i(e){return e.replace(/\./g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}function a(e){return n(`sha256`).update(e).digest(`hex`)}function o(e,t,n){let r=i(t),a=[];return e===`operation`&&(a.push({path:`${n}/handlers/${r}.handler.ts`,type:`handler`}),a.push({path:`${n}/handlers/${r}.handler.test.ts`,type:`test`})),e===`presentation`&&(a.push({path:`${n}/components/${r}.tsx`,type:`component`}),a.push({path:`${n}/components/${r}.test.tsx`,type:`test`})),e===`form`&&(a.push({path:`${n}/forms/${r}.form.tsx`,type:`form`}),a.push({path:`${n}/forms/${r}.form.test.tsx`,type:`test`})),e===`event`&&(a.push({path:`${n}/handlers/${r}.handler.ts`,type:`handler`}),a.push({path:`${n}/handlers/${r}.handler.test.ts`,type:`test`})),a}function s(e){if(e.length===0)return`missing`;let t=e.filter(e=>e.exists);return e.filter(e=>e.type!==`test`),t.filter(e=>e.type!==`test`).length===0?`missing`:e.every(e=>e.exists)?`implemented`:`partial`}async function c(n,i,c,d={}){let f={...r,...d},{fs:p}=i;if(!await p.exists(n))throw Error(`Spec file not found: ${n}`);let m=await p.readFile(n),h=f.computeHashes?a(m):void 0,g=e(m,n),_=g.name??p.basename(n).replace(/\.[jt]s$/,``),v=g.version??1,y=g.specType??`operation`,b=[],x=new Set,S=async(e,t,n,r)=>{if(x.has(e))return;x.add(e);let i=await p.exists(e),o;if(i&&f.computeHashes)try{o=a(await p.readFile(e))}catch{}b.push({path:e,type:t,source:n,exists:i,contentHash:o,description:r})};if(f.includeExplicit){let e=l(m);for(let t of e)await S(t.path,t.type,`explicit`,t.description)}if(f.includeDiscovered){let e=await t(_,i,f),r=u(_);for(let n of r){let r=await t(n,i,f);e.push(...r)}for(let t of e)t.filePath!==n&&await S(t.filePath,t.inferredType,`discovered`)}if(f.includeConvention){let e=o(y,_,f.outputDir??c.outputDir??`./src`);for(let{path:t,type:n}of e)await S(t,n,`convention`)}return{specName:_,specVersion:v,specPath:n,specType:y,implementations:b,status:s(b),specHash:h}}function l(e){let t=[],n=e.match(/implementations\s*:\s*\[([\s\S]*?)\]/);if(!n)return t;let r=n[1];if(!r)return t;let i=/\{\s*path\s*:\s*['"`]([^'"`]+)['"`]\s*,\s*type\s*:\s*['"`]([^'"`]+)['"`](?:\s*,\s*description\s*:\s*['"`]([^'"`]+)['"`])?\s*\}/g,a;for(;(a=i.exec(r))!==null;)t.push({path:a[1],type:a[2],description:a[3]});return t}function u(e){let t=[],n=e.replace(/Spec$/,``).replace(/Contract$/,``).replace(/Command$/,``).replace(/Query$/,``);n!==e&&(t.push(n),t.push(`${n}Spec`),t.push(`${n}Contract`));let r=e.split(`.`);if(r.length>1){let e=r.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);t.push(e)}return t}async function d(e,t,n,r={}){let i=[];for(let a of e)try{let e=await c(a,t,n,r);i.push(e)}catch(e){console.error(`Failed to resolve implementations for ${a}:`,e)}return i}function f(e){let t=e.filter(e=>e.status===`implemented`).length,n=e.filter(e=>e.status===`partial`).length,r=e.filter(e=>e.status===`missing`).length;return{total:e.length,implemented:t,partial:n,missing:r,coverage:e.length>0?Math.round(t/e.length*100):100}}export{f as getImplementationSummary,d as resolveAllImplementations,c as resolveImplementations};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as e}from"../modules/contractspec-workspace/dist/analysis/spec-scan.js";import{e as t,t as n}from"../modules/contractspec-workspace/dist/analysis/feature-scan.js";function r(e,t){return`${e}.v${t}`}function i(){return{operations:new Map,events:new Map,presentations:new Map,capabilities:new Map,workflows:new Map,dataViews:new Map,forms:new Map,migrations:new Map,experiments:new Map,integrations:new Map,knowledge:new Map,telemetry:new Map,appConfigs:new Map,policies:new Map,testSpecs:new Map}}function a(e,t){return{operation:e.operations,event:e.events,presentation:e.presentations,capability:e.capabilities,workflow:e.workflows,"data-view":e.dataViews,form:e.forms,migration:e.migrations,experiment:e.experiments,integration:e.integrations,knowledge:e.knowledge,telemetry:e.telemetry,"app-config":e.appConfigs,policy:e.policies,"test-spec":e.testSpecs}[t]}async function o(o,s={}){let{fs:c,logger:l}=o;l.info(`Starting integrity analysis...`,{options:s});let u=await c.glob({pattern:s.pattern}),d=i(),f=[],p=[];for(let i of u){let o=await c.readFile(i);if(t(i)){let e=n(o,i);f.push(e)}else{let t=e(o,i);for(let e of t)if(e.specType!==`unknown`&&e.specType!==`feature`){let t=a(d,e.specType);if(t&&e.name&&e.version!==void 0){let n=r(e.name,e.version);t.set(n,{name:e.name,version:e.version,file:e.filePath,type:e.specType,stability:e.stability})}}}}let m=s.featureKey?f.filter(e=>e.key===s.featureKey):f,h=new Set;for(let e of m){for(let t of e.operations){let n=r(t.name,t.version);h.add(`operation:${n}`),d.operations.has(n)||p.push({severity:`error`,type:`unresolved-ref`,message:`Operation ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`operation`,ref:t})}for(let t of e.events){let n=r(t.name,t.version);h.add(`event:${n}`),d.events.has(n)||p.push({severity:`error`,type:`unresolved-ref`,message:`Event ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`event`,ref:t})}for(let t of e.presentations){let n=r(t.name,t.version);h.add(`presentation:${n}`),d.presentations.has(n)||p.push({severity:`error`,type:`unresolved-ref`,message:`Presentation ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`presentation`,ref:t})}for(let t of e.experiments){let n=r(t.name,t.version);h.add(`experiment:${n}`),d.experiments.has(n)||p.push({severity:`error`,type:`unresolved-ref`,message:`Experiment ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`experiment`,ref:t})}for(let t of e.capabilities.provides){let n=r(t.name,t.version);h.add(`capability:${n}`),d.capabilities.has(n)||p.push({severity:`warning`,type:`unresolved-ref`,message:`Provided capability ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`capability`,ref:t})}for(let t of e.capabilities.requires){let e=r(t.name,t.version);h.add(`capability:${e}`)}for(let t of e.opToPresentationLinks){let n=r(t.op.name,t.op.version),i=r(t.pres.name,t.pres.version);d.operations.has(n)||p.push({severity:`error`,type:`broken-link`,message:`Linked operation ${t.op.name}.v${t.op.version} not found`,file:e.filePath,featureKey:e.key,specType:`operation`,ref:t.op}),d.presentations.has(i)||p.push({severity:`error`,type:`broken-link`,message:`Linked presentation ${t.pres.name}.v${t.pres.version} not found`,file:e.filePath,featureKey:e.key,specType:`presentation`,ref:t.pres})}}let g=[],_=[`operation`,`event`,`presentation`,`experiment`];for(let e of _){let t=a(d,e);if(t)for(let[n,r]of t)h.has(`${e}:${n}`)||(g.push(r),p.push({severity:`warning`,type:`orphaned`,message:`${e} ${r.name}.v${r.version} is not linked to any feature`,file:r.file,specName:r.name,specType:r.type}))}let v={};for(let e of _){let t=a(d,e);if(!t)continue;let n=t.size,r=0;for(let n of t.keys())h.has(`${e}:${n}`)&&r++;v[e]={total:n,covered:r,orphaned:n-r}}let y=Object.values(v).reduce((e,t)=>e+t.total,0),b=Object.values(v).reduce((e,t)=>e+t.covered,0),x={total:y,linkedToFeature:b,orphaned:y-b,byType:v},S=!p.some(e=>e.severity===`error`);return l.info(`Integrity analysis complete`,{features:f.length,totalSpecs:y,orphaned:g.length,issues:p.length,healthy:S}),{inventory:d,features:m,coverage:x,issues:p,orphanedSpecs:g,healthy:S}}function s(e){let t=[];for(let n of Object.values(e))for(let e of n.values())t.push(e);return t}function c(e,t){return e.filter(e=>e.type===t)}function l(e,t){return e.filter(e=>e.severity===t)}export{o as analyzeIntegrity,l as filterIssuesBySeverity,c as filterIssuesByType,s as getAllSpecs};
|
package/dist/services/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"../modules/contractspec-workspace/dist/analysis/spec-scan.js";async function t(t,n={}){let{fs:r}=t,i=await r.glob({pattern:n.pattern}),a=[];for(let t of i){let i=e(await r.readFile(t),t);n.type&&i.specType!==n.type||a.push(i)}return a}function n(e){let t=new Map;for(let n of e){let e=t.get(n.specType)??[];e.push(n),t.set(n.specType,e)}return t}export{n as groupSpecsByType,t as listSpecs};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{o as e}from"../../libs/contracts/dist/registry.js";import{o as t}from"../../libs/contracts/dist/openapi.js";import"../../libs/contracts/dist/index.js";async function n(e,n){let{fs:i,logger:a}=n,{registryPath:o,outputPath:s=`./openapi.json`}=e;a.info(`Loading registry...`,{registryPath:o});let c=await r(o,i);a.info(`Generating OpenAPI document...`);let l=t(c,{title:e.title,version:e.version,description:e.description,servers:e.servers}),u=JSON.stringify(l,null,2)+`
|
|
2
2
|
`,d=i.resolve(s);return await i.mkdir(i.dirname(d)),await i.writeFile(d,u),a.info(`OpenAPI document written to ${d}`),{document:l,outputPath:d,json:u}}async function r(t,n){let r=await import(n.resolve(t));if(r instanceof e)return r;if(r.registry instanceof e)return r.registry;let i=typeof r.createRegistry==`function`?r.createRegistry:typeof r.default==`function`?r.default:void 0;if(i){let t=await i();if(t instanceof e)return t}throw Error(`Registry module ${t} must export a SpecRegistry instance or a factory function returning one.`)}export{n as exportOpenApi};
|