@lssm/bundle.contractspec-workspace 0.0.0-canary-20251217063201 → 0.0.0-canary-20251217073102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/rolldown_runtime.js +22 -1
- package/dist/adapters/ai.js +82 -1
- package/dist/adapters/factory.js +36 -1
- package/dist/adapters/fs.js +118 -1
- package/dist/adapters/git.js +54 -1
- package/dist/adapters/index.js +7 -1
- package/dist/adapters/logger.js +80 -1
- package/dist/adapters/watcher.js +69 -1
- package/dist/adapters/workspace.js +190 -2
- package/dist/ai/agents/claude-code-agent.js +146 -9
- package/dist/ai/agents/cursor-agent.js +286 -17
- package/dist/ai/agents/index.js +5 -1
- package/dist/ai/agents/openai-codex-agent.js +140 -8
- package/dist/ai/agents/orchestrator.js +142 -1
- package/dist/ai/agents/simple-agent.js +80 -4
- package/dist/ai/client.js +162 -1
- package/dist/ai/index.js +27 -1
- package/dist/ai/prompts/code-generation.js +55 -13
- package/dist/ai/prompts/index.js +12 -1
- package/dist/ai/prompts/spec-creation.js +61 -20
- package/dist/ai/providers.js +40 -1
- package/dist/formatters/index.js +18 -1
- package/dist/formatters/json.js +71 -1
- package/dist/formatters/sarif.js +163 -1
- package/dist/formatters/text.js +208 -2
- package/dist/index.js +81 -1
- package/dist/libs/ai-providers/dist/factory.js +154 -1
- package/dist/libs/ai-providers/dist/index.js +4 -1
- package/dist/libs/ai-providers/dist/legacy.js +72 -1
- package/dist/libs/ai-providers/dist/models.js +287 -1
- package/dist/libs/ai-providers/dist/validation.js +1 -1
- package/dist/libs/contracts/dist/capabilities/openbanking.js +88 -1
- package/dist/libs/contracts/dist/client/index.js +5 -1
- package/dist/libs/contracts/dist/client/react/feature-render.js +2 -1
- package/dist/libs/contracts/dist/client/react/form-render.js +4 -1
- package/dist/libs/contracts/dist/client/react/index.js +4 -1
- package/dist/libs/contracts/dist/contract-registry/index.js +1 -1
- package/dist/libs/contracts/dist/contract-registry/schemas.js +60 -1
- package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +16 -76
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +16 -350
- package/dist/libs/contracts/dist/docs/index.js +29 -1
- package/dist/libs/contracts/dist/docs/presentations.js +71 -1
- package/dist/libs/contracts/dist/docs/registry.js +44 -1
- package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +16 -383
- package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +16 -68
- package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +16 -140
- package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +16 -86
- package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +16 -1
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +24 -2
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +21 -2
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +16 -213
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +73 -5
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +37 -1
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +16 -1
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +20 -262
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +48 -1
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +24 -2
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +23 -2
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +25 -16
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +67 -1
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +22 -2
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +40 -36
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +47 -1
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +23 -2
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +36 -3
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +20 -1
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +36 -3
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +20 -1
- package/dist/libs/contracts/dist/events.js +8 -1
- package/dist/libs/contracts/dist/experiments/evaluator.js +1 -1
- package/dist/libs/contracts/dist/index.js +72 -1
- package/dist/libs/contracts/dist/install.js +2 -1
- package/dist/libs/contracts/dist/integrations/contracts.js +377 -1
- package/dist/libs/contracts/dist/integrations/index.js +18 -1
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +228 -1
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +159 -1
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +3 -1
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +210 -1
- package/dist/libs/contracts/dist/integrations/openbanking/models.js +242 -1
- package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +13 -1
- package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +52 -1
- package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +75 -1
- package/dist/libs/contracts/dist/integrations/providers/gmail.js +87 -1
- package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +66 -1
- package/dist/libs/contracts/dist/integrations/providers/index.js +11 -1
- package/dist/libs/contracts/dist/integrations/providers/mistral.js +68 -1
- package/dist/libs/contracts/dist/integrations/providers/postmark.js +68 -1
- package/dist/libs/contracts/dist/integrations/providers/powens.js +116 -1
- package/dist/libs/contracts/dist/integrations/providers/qdrant.js +73 -1
- package/dist/libs/contracts/dist/integrations/providers/registry.js +10 -1
- package/dist/libs/contracts/dist/integrations/providers/stripe.js +83 -1
- package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +61 -1
- package/dist/libs/contracts/dist/jsonschema.js +24 -1
- package/dist/libs/contracts/dist/knowledge/contracts.js +306 -1
- package/dist/libs/contracts/dist/knowledge/index.js +7 -1
- package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +34 -1
- package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +34 -1
- package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +38 -1
- package/dist/libs/contracts/dist/knowledge/spaces/index.js +6 -1
- package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +34 -1
- package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +37 -1
- package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +34 -1
- package/dist/libs/contracts/dist/llm/exporters.js +352 -4
- package/dist/libs/contracts/dist/llm/index.js +2 -1
- package/dist/libs/contracts/dist/llm/prompts.js +143 -7
- package/dist/libs/contracts/dist/onboarding-base.js +196 -1
- package/dist/libs/contracts/dist/openapi.js +75 -1
- package/dist/libs/contracts/dist/ownership.js +21 -1
- package/dist/libs/contracts/dist/presentations.js +1 -1
- package/dist/libs/contracts/dist/presentations.v2.js +11 -1
- package/dist/libs/contracts/dist/prompt.js +1 -1
- package/dist/libs/contracts/dist/promptRegistry.js +1 -1
- package/dist/libs/contracts/dist/regenerator/index.js +2 -1
- package/dist/libs/contracts/dist/regenerator/service.js +92 -1
- package/dist/libs/contracts/dist/regenerator/utils.js +51 -1
- package/dist/libs/contracts/dist/registry.js +208 -1
- package/dist/libs/contracts/dist/resources.js +1 -1
- package/dist/libs/contracts/dist/schema/dist/EnumType.js +2 -1
- package/dist/libs/contracts/dist/schema/dist/FieldType.js +49 -1
- package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +236 -1
- package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +34 -1
- package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +1 -1
- package/dist/libs/contracts/dist/schema/dist/entity/index.js +2 -1
- package/dist/libs/contracts/dist/schema/dist/entity/types.js +1 -1
- package/dist/libs/contracts/dist/schema/dist/index.js +6 -1
- package/dist/libs/contracts/dist/server/graphql-pothos.js +6 -1
- package/dist/libs/contracts/dist/server/index.js +8 -1
- package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +4 -1
- package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +2 -1
- package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +1 -1
- package/dist/libs/contracts/dist/server/mcp/registerResources.js +2 -1
- package/dist/libs/contracts/dist/server/mcp/registerTools.js +1 -1
- package/dist/libs/contracts/dist/server/provider-mcp.js +1 -1
- package/dist/libs/contracts/dist/server/rest-elysia.js +1 -1
- package/dist/libs/contracts/dist/server/rest-express.js +1 -1
- package/dist/libs/contracts/dist/server/rest-generic.js +1 -1
- package/dist/libs/contracts/dist/server/rest-next-app.js +1 -1
- package/dist/libs/contracts/dist/server/rest-next-pages.js +1 -1
- package/dist/libs/contracts/dist/spec.js +35 -1
- package/dist/libs/contracts/dist/telemetry/index.js +1 -1
- package/dist/libs/contracts/dist/telemetry/tracker.js +1 -1
- package/dist/libs/contracts/dist/tests/index.js +1 -1
- package/dist/libs/contracts/dist/tests/runner.js +150 -1
- package/dist/libs/contracts/dist/workflow/index.js +1 -1
- package/dist/libs/contracts/dist/workflow/runner.js +1 -1
- package/dist/libs/contracts-transformers/dist/common/utils.js +47 -1
- package/dist/libs/contracts-transformers/dist/openapi/exporter.js +1 -1
- package/dist/libs/contracts-transformers/dist/openapi/importer.js +255 -2
- package/dist/libs/contracts-transformers/dist/openapi/index.js +4 -1
- package/dist/libs/contracts-transformers/dist/openapi/parser.js +231 -1
- package/dist/libs/contracts-transformers/dist/openapi/schema-converter.js +201 -4
- package/dist/modules/contractspec-workspace/dist/ai/code-generation.js +50 -13
- package/dist/modules/contractspec-workspace/dist/ai/spec-creation.js +50 -18
- package/dist/modules/contractspec-workspace/dist/analysis/deps/graph.js +84 -2
- package/dist/modules/contractspec-workspace/dist/analysis/deps/parse-imports.js +30 -1
- package/dist/modules/contractspec-workspace/dist/analysis/diff/semantic.js +96 -1
- package/dist/modules/contractspec-workspace/dist/analysis/feature-scan.js +151 -1
- package/dist/modules/contractspec-workspace/dist/analysis/spec-scan.js +344 -1
- package/dist/modules/contractspec-workspace/dist/analysis/validate/spec-structure.js +122 -1
- package/dist/modules/contractspec-workspace/dist/templates/app-config.js +100 -28
- package/dist/modules/contractspec-workspace/dist/templates/data-view.js +41 -27
- package/dist/modules/contractspec-workspace/dist/templates/event.js +28 -14
- package/dist/modules/contractspec-workspace/dist/templates/experiment.js +76 -51
- package/dist/modules/contractspec-workspace/dist/templates/handler.js +49 -17
- package/dist/modules/contractspec-workspace/dist/templates/integration-utils.js +97 -26
- package/dist/modules/contractspec-workspace/dist/templates/integration.js +46 -23
- package/dist/modules/contractspec-workspace/dist/templates/knowledge.js +59 -19
- package/dist/modules/contractspec-workspace/dist/templates/migration.js +49 -26
- package/dist/modules/contractspec-workspace/dist/templates/operation.js +40 -28
- package/dist/modules/contractspec-workspace/dist/templates/presentation.js +45 -20
- package/dist/modules/contractspec-workspace/dist/templates/telemetry.js +73 -53
- package/dist/modules/contractspec-workspace/dist/templates/utils.js +38 -1
- package/dist/modules/contractspec-workspace/dist/templates/workflow-runner.js +12 -6
- package/dist/modules/contractspec-workspace/dist/templates/workflow.js +50 -24
- package/dist/modules/contractspec-workspace/dist/types/generation-types.js +20 -1
- package/dist/services/agent-guide/adapters/claude-code.js +144 -3
- package/dist/services/agent-guide/adapters/cursor-cli.js +135 -3
- package/dist/services/agent-guide/adapters/generic-mcp.js +159 -3
- package/dist/services/agent-guide/adapters/index.js +30 -1
- package/dist/services/agent-guide/agent-guide-service.js +148 -1
- package/dist/services/agent-guide/index.js +5 -1
- package/dist/services/build.js +140 -1
- package/dist/services/ci-check/ci-check-service.js +393 -1
- package/dist/services/ci-check/index.js +2 -1
- package/dist/services/ci-check/types.js +28 -1
- package/dist/services/clean.js +71 -1
- package/dist/services/config.js +76 -1
- package/dist/services/deps.js +62 -1
- package/dist/services/diff.js +33 -1
- package/dist/services/doctor/checks/ai.js +118 -2
- package/dist/services/doctor/checks/cli.js +146 -1
- package/dist/services/doctor/checks/config.js +170 -1
- package/dist/services/doctor/checks/deps.js +180 -1
- package/dist/services/doctor/checks/index.js +6 -1
- package/dist/services/doctor/checks/mcp.js +144 -1
- package/dist/services/doctor/checks/workspace.js +243 -1
- package/dist/services/doctor/doctor-service.js +115 -2
- package/dist/services/doctor/index.js +2 -1
- package/dist/services/doctor/types.js +26 -1
- package/dist/services/implementation/discovery.js +143 -2
- package/dist/services/implementation/index.js +2 -1
- package/dist/services/implementation/resolver.js +223 -1
- package/dist/services/index.js +53 -1
- package/dist/services/integrity-diagram.js +274 -6
- package/dist/services/integrity.js +272 -1
- package/dist/services/list.js +35 -1
- package/dist/services/openapi/export-service.js +51 -2
- package/dist/services/openapi/import-service.js +75 -1
- package/dist/services/openapi/index.js +4 -1
- package/dist/services/openapi/sync-service.js +121 -1
- package/dist/services/openapi/validate-service.js +130 -1
- package/dist/services/regenerator.js +23 -1
- package/dist/services/registry.js +73 -1
- package/dist/services/setup/config-generators.js +113 -26
- package/dist/services/setup/file-merger.js +60 -2
- package/dist/services/setup/index.js +4 -1
- package/dist/services/setup/setup-service.js +95 -1
- package/dist/services/setup/targets/agents-md.js +46 -1
- package/dist/services/setup/targets/cli-config.js +59 -1
- package/dist/services/setup/targets/cursor-rules.js +47 -1
- package/dist/services/setup/targets/mcp-claude.js +59 -1
- package/dist/services/setup/targets/mcp-cursor.js +58 -1
- package/dist/services/setup/targets/vscode-settings.js +62 -1
- package/dist/services/setup/types.js +26 -1
- package/dist/services/sync.js +62 -1
- package/dist/services/test.js +30 -1
- package/dist/services/validate-implementation.js +69 -1
- package/dist/services/validate.js +47 -1
- package/dist/services/verification-cache/adapters/filesystem.js +121 -1
- package/dist/services/verification-cache/adapters/in-memory.js +45 -1
- package/dist/services/verification-cache/adapters/index.js +3 -1
- package/dist/services/verification-cache/adapters/workspace-state.js +90 -1
- package/dist/services/verification-cache/cache-service.js +255 -1
- package/dist/services/verification-cache/index.js +6 -1
- package/dist/services/verification-cache/types.js +15 -1
- package/dist/services/verify/ai-verifier.js +336 -9
- package/dist/services/verify/behavior-verifier.js +185 -1
- package/dist/services/verify/index.js +4 -1
- package/dist/services/verify/structure-verifier.js +195 -2
- package/dist/services/verify/verify-service.js +203 -3
- package/dist/services/watch.js +31 -1
- package/dist/services/workspace-info.js +102 -2
- package/dist/templates/app-config.template.js +101 -28
- package/dist/templates/data-view.template.js +42 -27
- package/dist/templates/event.template.js +29 -14
- package/dist/templates/experiment.template.js +77 -51
- package/dist/templates/handler.template.js +53 -17
- package/dist/templates/index.js +36 -1
- package/dist/templates/integration.template.js +134 -50
- package/dist/templates/knowledge.template.js +62 -21
- package/dist/templates/migration.template.js +50 -26
- package/dist/templates/operation.template.js +44 -28
- package/dist/templates/presentation.template.js +46 -20
- package/dist/templates/telemetry.template.js +74 -53
- package/dist/templates/workflow-runner.template.js +12 -6
- package/dist/templates/workflow.template.js +51 -24
- package/package.json +13 -9
|
@@ -1,2 +1,143 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/services/implementation/discovery.ts
|
|
2
|
+
/**
|
|
3
|
+
* Patterns for detecting spec references in source code.
|
|
4
|
+
*/
|
|
5
|
+
const SPEC_REFERENCE_PATTERNS = {
|
|
6
|
+
namedImport: /import\s*\{[^}]*\b(\w+(?:Spec|Contract|Command|Query))\b[^}]*\}\s*from/g,
|
|
7
|
+
defaultImport: /import\s+(\w+(?:Spec|Contract|Command|Query))\s+from/g,
|
|
8
|
+
contractHandler: /ContractHandler\s*<\s*typeof\s+(\w+)\s*>/g,
|
|
9
|
+
typeofSpec: /typeof\s+(\w+(?:Spec|Contract|Command|Query))\b/g,
|
|
10
|
+
specAssignment: /(?:spec|contract)\s*[:=]\s*(\w+(?:Spec|Contract|Command|Query))\b/gi
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* File patterns that indicate implementation types.
|
|
14
|
+
*/
|
|
15
|
+
const IMPLEMENTATION_TYPE_PATTERNS = {
|
|
16
|
+
".handler.ts": "handler",
|
|
17
|
+
".handler.tsx": "handler",
|
|
18
|
+
".service.ts": "service",
|
|
19
|
+
".service.tsx": "service",
|
|
20
|
+
".test.ts": "test",
|
|
21
|
+
".test.tsx": "test",
|
|
22
|
+
".spec.ts": "test",
|
|
23
|
+
".spec.tsx": "test",
|
|
24
|
+
".component.tsx": "component",
|
|
25
|
+
".tsx": "component",
|
|
26
|
+
".form.tsx": "form",
|
|
27
|
+
".hook.ts": "hook",
|
|
28
|
+
".hook.tsx": "hook"
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Infer implementation type from file path.
|
|
32
|
+
*/
|
|
33
|
+
function inferImplementationType(filePath) {
|
|
34
|
+
const lowerPath = filePath.toLowerCase();
|
|
35
|
+
for (const [pattern, type] of Object.entries(IMPLEMENTATION_TYPE_PATTERNS)) if (lowerPath.endsWith(pattern)) return type;
|
|
36
|
+
if (lowerPath.includes("/handlers/")) return "handler";
|
|
37
|
+
if (lowerPath.includes("/services/")) return "service";
|
|
38
|
+
if (lowerPath.includes("/components/")) return "component";
|
|
39
|
+
if (lowerPath.includes("/forms/")) return "form";
|
|
40
|
+
if (lowerPath.includes("/hooks/")) return "hook";
|
|
41
|
+
if (lowerPath.includes("/__tests__/")) return "test";
|
|
42
|
+
return "other";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Extract spec references from source code.
|
|
46
|
+
*/
|
|
47
|
+
function extractSpecReferences(code, filePath) {
|
|
48
|
+
const matches = [];
|
|
49
|
+
const seenSpecs = /* @__PURE__ */ new Set();
|
|
50
|
+
const addMatch = (specName, referenceType, lineNumber) => {
|
|
51
|
+
const key = `${specName}:${referenceType}`;
|
|
52
|
+
if (seenSpecs.has(key)) return;
|
|
53
|
+
seenSpecs.add(key);
|
|
54
|
+
matches.push({
|
|
55
|
+
filePath,
|
|
56
|
+
specName,
|
|
57
|
+
referenceType,
|
|
58
|
+
lineNumber,
|
|
59
|
+
inferredType: inferImplementationType(filePath)
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const getLineNumber = (position) => {
|
|
63
|
+
return code.substring(0, position).split("\n").length;
|
|
64
|
+
};
|
|
65
|
+
let match;
|
|
66
|
+
const handlerPattern = new RegExp(SPEC_REFERENCE_PATTERNS.contractHandler);
|
|
67
|
+
while ((match = handlerPattern.exec(code)) !== null) addMatch(match[1], "handler", getLineNumber(match.index));
|
|
68
|
+
const typeofPattern = new RegExp(SPEC_REFERENCE_PATTERNS.typeofSpec);
|
|
69
|
+
while ((match = typeofPattern.exec(code)) !== null) addMatch(match[1], "typeof", getLineNumber(match.index));
|
|
70
|
+
const namedPattern = new RegExp(SPEC_REFERENCE_PATTERNS.namedImport);
|
|
71
|
+
while ((match = namedPattern.exec(code)) !== null) {
|
|
72
|
+
const specNames = match[0].match(/\b(\w+(?:Spec|Contract|Command|Query))\b/g);
|
|
73
|
+
if (specNames) for (const name of specNames) addMatch(name, "import", getLineNumber(match.index));
|
|
74
|
+
}
|
|
75
|
+
const defaultPattern = new RegExp(SPEC_REFERENCE_PATTERNS.defaultImport);
|
|
76
|
+
while ((match = defaultPattern.exec(code)) !== null) addMatch(match[1], "import", getLineNumber(match.index));
|
|
77
|
+
const assignPattern = new RegExp(SPEC_REFERENCE_PATTERNS.specAssignment);
|
|
78
|
+
while ((match = assignPattern.exec(code)) !== null) addMatch(match[1], "unknown", getLineNumber(match.index));
|
|
79
|
+
return matches;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Default glob patterns for implementation files.
|
|
83
|
+
*/
|
|
84
|
+
const DEFAULT_INCLUDE_PATTERNS = ["**/*.ts", "**/*.tsx"];
|
|
85
|
+
const DEFAULT_EXCLUDE_PATTERNS = [
|
|
86
|
+
"**/node_modules/**",
|
|
87
|
+
"**/dist/**",
|
|
88
|
+
"**/.git/**",
|
|
89
|
+
"**/*.d.ts",
|
|
90
|
+
"**/*.contracts.ts",
|
|
91
|
+
"**/*.spec.ts",
|
|
92
|
+
"**/*.feature.ts",
|
|
93
|
+
"**/*.event.ts",
|
|
94
|
+
"**/*.presentation.ts"
|
|
95
|
+
];
|
|
96
|
+
/**
|
|
97
|
+
* Discover implementations that reference a specific spec.
|
|
98
|
+
*/
|
|
99
|
+
async function discoverImplementationsForSpec(specName, adapters, options = {}) {
|
|
100
|
+
const { fs } = adapters;
|
|
101
|
+
const includePatterns = options.includePatterns ?? DEFAULT_INCLUDE_PATTERNS;
|
|
102
|
+
const excludePatterns = options.excludePatterns ?? DEFAULT_EXCLUDE_PATTERNS;
|
|
103
|
+
const allMatches = [];
|
|
104
|
+
for (const pattern of includePatterns) {
|
|
105
|
+
const files = await fs.glob({
|
|
106
|
+
pattern,
|
|
107
|
+
ignore: excludePatterns
|
|
108
|
+
});
|
|
109
|
+
for (const filePath of files) try {
|
|
110
|
+
const matchingRefs = extractSpecReferences(await fs.readFile(filePath), filePath).filter((ref) => ref.specName === specName);
|
|
111
|
+
allMatches.push(...matchingRefs);
|
|
112
|
+
} catch {}
|
|
113
|
+
}
|
|
114
|
+
return allMatches;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Discover all spec references in the workspace.
|
|
118
|
+
* Returns a map of spec name to implementation references.
|
|
119
|
+
*/
|
|
120
|
+
async function discoverAllImplementations(adapters, options = {}) {
|
|
121
|
+
const { fs } = adapters;
|
|
122
|
+
const includePatterns = options.includePatterns ?? DEFAULT_INCLUDE_PATTERNS;
|
|
123
|
+
const excludePatterns = options.excludePatterns ?? DEFAULT_EXCLUDE_PATTERNS;
|
|
124
|
+
const specToImplementations = /* @__PURE__ */ new Map();
|
|
125
|
+
for (const pattern of includePatterns) {
|
|
126
|
+
const files = await fs.glob({
|
|
127
|
+
pattern,
|
|
128
|
+
ignore: excludePatterns
|
|
129
|
+
});
|
|
130
|
+
for (const filePath of files) try {
|
|
131
|
+
const references = extractSpecReferences(await fs.readFile(filePath), filePath);
|
|
132
|
+
for (const ref of references) {
|
|
133
|
+
const existing = specToImplementations.get(ref.specName) ?? [];
|
|
134
|
+
existing.push(ref);
|
|
135
|
+
specToImplementations.set(ref.specName, existing);
|
|
136
|
+
}
|
|
137
|
+
} catch {}
|
|
138
|
+
}
|
|
139
|
+
return specToImplementations;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
export { discoverAllImplementations, discoverImplementationsForSpec, extractSpecReferences, inferImplementationType };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{discoverAllImplementations
|
|
1
|
+
import { discoverAllImplementations, discoverImplementationsForSpec, extractSpecReferences, inferImplementationType } from "./discovery.js";
|
|
2
|
+
import { getImplementationSummary, resolveAllImplementations, resolveImplementations } from "./resolver.js";
|
|
@@ -1 +1,223 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { scanSpecSource } from "../../modules/contractspec-workspace/dist/analysis/spec-scan.js";
|
|
2
|
+
import { discoverImplementationsForSpec } from "./discovery.js";
|
|
3
|
+
import { createHash } from "crypto";
|
|
4
|
+
|
|
5
|
+
//#region src/services/implementation/resolver.ts
|
|
6
|
+
/**
|
|
7
|
+
* Implementation resolver service.
|
|
8
|
+
*
|
|
9
|
+
* Resolves all implementations for a spec by merging:
|
|
10
|
+
* 1. Explicit mappings from spec.implementations
|
|
11
|
+
* 2. Auto-discovered references from workspace scanning
|
|
12
|
+
* 3. Convention-based paths (naming conventions)
|
|
13
|
+
*/
|
|
14
|
+
const DEFAULT_OPTIONS = {
|
|
15
|
+
includeExplicit: true,
|
|
16
|
+
includeDiscovered: true,
|
|
17
|
+
includeConvention: true,
|
|
18
|
+
computeHashes: true
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Convert string to kebab-case.
|
|
22
|
+
*/
|
|
23
|
+
function toKebabCase(value) {
|
|
24
|
+
return value.replace(/\./g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Compute SHA256 hash of content.
|
|
28
|
+
*/
|
|
29
|
+
function computeHash(content) {
|
|
30
|
+
return createHash("sha256").update(content).digest("hex");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get convention-based implementation paths for a spec.
|
|
34
|
+
*/
|
|
35
|
+
function getConventionPaths(specType, specName, outputDir) {
|
|
36
|
+
const kebab = toKebabCase(specName);
|
|
37
|
+
const paths = [];
|
|
38
|
+
if (specType === "operation") {
|
|
39
|
+
paths.push({
|
|
40
|
+
path: `${outputDir}/handlers/${kebab}.handler.ts`,
|
|
41
|
+
type: "handler"
|
|
42
|
+
});
|
|
43
|
+
paths.push({
|
|
44
|
+
path: `${outputDir}/handlers/${kebab}.handler.test.ts`,
|
|
45
|
+
type: "test"
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (specType === "presentation") {
|
|
49
|
+
paths.push({
|
|
50
|
+
path: `${outputDir}/components/${kebab}.tsx`,
|
|
51
|
+
type: "component"
|
|
52
|
+
});
|
|
53
|
+
paths.push({
|
|
54
|
+
path: `${outputDir}/components/${kebab}.test.tsx`,
|
|
55
|
+
type: "test"
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (specType === "form") {
|
|
59
|
+
paths.push({
|
|
60
|
+
path: `${outputDir}/forms/${kebab}.form.tsx`,
|
|
61
|
+
type: "form"
|
|
62
|
+
});
|
|
63
|
+
paths.push({
|
|
64
|
+
path: `${outputDir}/forms/${kebab}.form.test.tsx`,
|
|
65
|
+
type: "test"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (specType === "event") {
|
|
69
|
+
paths.push({
|
|
70
|
+
path: `${outputDir}/handlers/${kebab}.handler.ts`,
|
|
71
|
+
type: "handler"
|
|
72
|
+
});
|
|
73
|
+
paths.push({
|
|
74
|
+
path: `${outputDir}/handlers/${kebab}.handler.test.ts`,
|
|
75
|
+
type: "test"
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return paths;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Determine overall implementation status.
|
|
82
|
+
*/
|
|
83
|
+
function determineStatus(implementations) {
|
|
84
|
+
if (implementations.length === 0) return "missing";
|
|
85
|
+
const existingImpls = implementations.filter((i) => i.exists);
|
|
86
|
+
implementations.filter((i) => i.type !== "test");
|
|
87
|
+
if (existingImpls.filter((i) => i.type !== "test").length === 0) return "missing";
|
|
88
|
+
if (implementations.every((i) => i.exists)) return "implemented";
|
|
89
|
+
return "partial";
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Resolve all implementations for a spec file.
|
|
93
|
+
*/
|
|
94
|
+
async function resolveImplementations(specFile, adapters, config, options = {}) {
|
|
95
|
+
const opts = {
|
|
96
|
+
...DEFAULT_OPTIONS,
|
|
97
|
+
...options
|
|
98
|
+
};
|
|
99
|
+
const { fs } = adapters;
|
|
100
|
+
if (!await fs.exists(specFile)) throw new Error(`Spec file not found: ${specFile}`);
|
|
101
|
+
const specContent = await fs.readFile(specFile);
|
|
102
|
+
const specHash = opts.computeHashes ? computeHash(specContent) : void 0;
|
|
103
|
+
const scan = scanSpecSource(specContent, specFile);
|
|
104
|
+
const specName = scan.name ?? fs.basename(specFile).replace(/\.[jt]s$/, "");
|
|
105
|
+
const specVersion = scan.version ?? 1;
|
|
106
|
+
const specType = scan.specType ?? "operation";
|
|
107
|
+
const implementations = [];
|
|
108
|
+
const seenPaths = /* @__PURE__ */ new Set();
|
|
109
|
+
const addImpl = async (path, type, source, description) => {
|
|
110
|
+
if (seenPaths.has(path)) return;
|
|
111
|
+
seenPaths.add(path);
|
|
112
|
+
const exists = await fs.exists(path);
|
|
113
|
+
let contentHash;
|
|
114
|
+
if (exists && opts.computeHashes) try {
|
|
115
|
+
contentHash = computeHash(await fs.readFile(path));
|
|
116
|
+
} catch {}
|
|
117
|
+
implementations.push({
|
|
118
|
+
path,
|
|
119
|
+
type,
|
|
120
|
+
source,
|
|
121
|
+
exists,
|
|
122
|
+
contentHash,
|
|
123
|
+
description
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
if (opts.includeExplicit) {
|
|
127
|
+
const explicitImpls = parseExplicitImplementations(specContent);
|
|
128
|
+
for (const impl of explicitImpls) await addImpl(impl.path, impl.type, "explicit", impl.description);
|
|
129
|
+
}
|
|
130
|
+
if (opts.includeDiscovered) {
|
|
131
|
+
const discovered = await discoverImplementationsForSpec(specName, adapters, opts);
|
|
132
|
+
const specNameVariants = getSpecNameVariants(specName);
|
|
133
|
+
for (const variant of specNameVariants) {
|
|
134
|
+
const variantDiscovered = await discoverImplementationsForSpec(variant, adapters, opts);
|
|
135
|
+
discovered.push(...variantDiscovered);
|
|
136
|
+
}
|
|
137
|
+
for (const ref of discovered) {
|
|
138
|
+
if (ref.filePath === specFile) continue;
|
|
139
|
+
await addImpl(ref.filePath, ref.inferredType, "discovered");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (opts.includeConvention) {
|
|
143
|
+
const conventionPaths = getConventionPaths(specType, specName, opts.outputDir ?? config.outputDir ?? "./src");
|
|
144
|
+
for (const { path, type } of conventionPaths) await addImpl(path, type, "convention");
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
specName,
|
|
148
|
+
specVersion,
|
|
149
|
+
specPath: specFile,
|
|
150
|
+
specType,
|
|
151
|
+
implementations,
|
|
152
|
+
status: determineStatus(implementations),
|
|
153
|
+
specHash
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Parse explicit implementations from spec source code.
|
|
158
|
+
* Looks for: implementations: [{ path: '...', type: '...' }]
|
|
159
|
+
*/
|
|
160
|
+
function parseExplicitImplementations(code) {
|
|
161
|
+
const implementations = [];
|
|
162
|
+
const implMatch = code.match(/implementations\s*:\s*\[([\s\S]*?)\]/);
|
|
163
|
+
if (!implMatch) return implementations;
|
|
164
|
+
const implBlock = implMatch[1];
|
|
165
|
+
if (!implBlock) return implementations;
|
|
166
|
+
const objRegex = /\{\s*path\s*:\s*['"`]([^'"`]+)['"`]\s*,\s*type\s*:\s*['"`]([^'"`]+)['"`](?:\s*,\s*description\s*:\s*['"`]([^'"`]+)['"`])?\s*\}/g;
|
|
167
|
+
let match;
|
|
168
|
+
while ((match = objRegex.exec(implBlock)) !== null) implementations.push({
|
|
169
|
+
path: match[1],
|
|
170
|
+
type: match[2],
|
|
171
|
+
description: match[3]
|
|
172
|
+
});
|
|
173
|
+
return implementations;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Get common variants of a spec name for discovery.
|
|
177
|
+
*/
|
|
178
|
+
function getSpecNameVariants(specName) {
|
|
179
|
+
const variants = [];
|
|
180
|
+
const base = specName.replace(/Spec$/, "").replace(/Contract$/, "").replace(/Command$/, "").replace(/Query$/, "");
|
|
181
|
+
if (base !== specName) {
|
|
182
|
+
variants.push(base);
|
|
183
|
+
variants.push(`${base}Spec`);
|
|
184
|
+
variants.push(`${base}Contract`);
|
|
185
|
+
}
|
|
186
|
+
const parts = specName.split(".");
|
|
187
|
+
if (parts.length > 1) {
|
|
188
|
+
const pascalName = parts.map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join("");
|
|
189
|
+
variants.push(pascalName);
|
|
190
|
+
}
|
|
191
|
+
return variants;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Resolve implementations for multiple spec files.
|
|
195
|
+
*/
|
|
196
|
+
async function resolveAllImplementations(specFiles, adapters, config, options = {}) {
|
|
197
|
+
const results = [];
|
|
198
|
+
for (const specFile of specFiles) try {
|
|
199
|
+
const result = await resolveImplementations(specFile, adapters, config, options);
|
|
200
|
+
results.push(result);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
console.error(`Failed to resolve implementations for ${specFile}:`, error);
|
|
203
|
+
}
|
|
204
|
+
return results;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get implementation summary statistics.
|
|
208
|
+
*/
|
|
209
|
+
function getImplementationSummary(results) {
|
|
210
|
+
const implemented = results.filter((r) => r.status === "implemented").length;
|
|
211
|
+
const partial = results.filter((r) => r.status === "partial").length;
|
|
212
|
+
const missing = results.filter((r) => r.status === "missing").length;
|
|
213
|
+
return {
|
|
214
|
+
total: results.length,
|
|
215
|
+
implemented,
|
|
216
|
+
partial,
|
|
217
|
+
missing,
|
|
218
|
+
coverage: results.length > 0 ? Math.round(implemented / results.length * 100) : 100
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
//#endregion
|
|
223
|
+
export { getImplementationSummary, resolveAllImplementations, resolveImplementations };
|
package/dist/services/index.js
CHANGED
|
@@ -1 +1,53 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { detectPackageManager, findPackageRoot, findWorkspaceRoot, getWorkspaceInfo } from "../adapters/workspace.js";
|
|
2
|
+
import { validateSpec, validateSpecs } from "./validate.js";
|
|
3
|
+
import { validateImplementationFiles } from "./validate-implementation.js";
|
|
4
|
+
import { compareSpecs } from "./diff.js";
|
|
5
|
+
import { analyzeDeps, exportGraphAsDot, getContractNode, getGraphStats } from "./deps.js";
|
|
6
|
+
import { groupSpecsByType, listSpecs } from "./list.js";
|
|
7
|
+
import { getApiKey, loadWorkspaceConfig, mergeWorkspaceConfig } from "./config.js";
|
|
8
|
+
import { buildSpec } from "./build.js";
|
|
9
|
+
import { importFromOpenApiService } from "./openapi/import-service.js";
|
|
10
|
+
import { syncWithOpenApiService } from "./openapi/sync-service.js";
|
|
11
|
+
import { validateAgainstOpenApiService } from "./openapi/validate-service.js";
|
|
12
|
+
import { exportOpenApi } from "./openapi/export-service.js";
|
|
13
|
+
import "./openapi/index.js";
|
|
14
|
+
import { RegistryClient, addToRegistry, listFromRegistry, resolveRegistryUrl, searchRegistry } from "./registry.js";
|
|
15
|
+
import { syncSpecs } from "./sync.js";
|
|
16
|
+
import { watchSpecs } from "./watch.js";
|
|
17
|
+
import { cleanArtifacts } from "./clean.js";
|
|
18
|
+
import { runTests } from "./test.js";
|
|
19
|
+
import { createRegeneratorService } from "./regenerator.js";
|
|
20
|
+
import { findAllConfigFiles, formatWorkspaceInfo, getExtendedWorkspaceInfo, mergeMonorepoConfigs } from "./workspace-info.js";
|
|
21
|
+
import { analyzeIntegrity, filterIssuesBySeverity, filterIssuesByType, getAllSpecs } from "./integrity.js";
|
|
22
|
+
import { generateMermaidDiagram } from "./integrity-diagram.js";
|
|
23
|
+
import { ALL_SETUP_TARGETS, SETUP_TARGET_LABELS } from "./setup/types.js";
|
|
24
|
+
import { generateAgentsMd, generateClaudeMcpConfig, generateContractsrcConfig, generateCursorMcpConfig, generateCursorRules, generateVscodeSettings, getClaudeDesktopConfigPath } from "./setup/config-generators.js";
|
|
25
|
+
import { deepMergeOverwrite, deepMergePreserve, formatJson, safeParseJson } from "./setup/file-merger.js";
|
|
26
|
+
import { runSetup } from "./setup/setup-service.js";
|
|
27
|
+
import "./setup/index.js";
|
|
28
|
+
import { ALL_CHECK_CATEGORIES, CHECK_CATEGORY_LABELS } from "./doctor/types.js";
|
|
29
|
+
import { formatCheckResult, formatDoctorSummary, runDoctor } from "./doctor/doctor-service.js";
|
|
30
|
+
import "./doctor/index.js";
|
|
31
|
+
import { ALL_CI_CHECK_CATEGORIES, CI_CHECK_CATEGORY_LABELS } from "./ci-check/types.js";
|
|
32
|
+
import { discoverAllImplementations, discoverImplementationsForSpec, extractSpecReferences, inferImplementationType } from "./implementation/discovery.js";
|
|
33
|
+
import { getImplementationSummary, resolveAllImplementations, resolveImplementations } from "./implementation/resolver.js";
|
|
34
|
+
import { DEFAULT_CACHE_CONFIG } from "./verification-cache/types.js";
|
|
35
|
+
import { VerificationCacheService, cacheKeyToString, computeContentHash, createVerificationCacheService, stringToCacheKey } from "./verification-cache/cache-service.js";
|
|
36
|
+
import { InMemoryCacheStorage, createInMemoryCacheStorage } from "./verification-cache/adapters/in-memory.js";
|
|
37
|
+
import { FileSystemCacheStorage, createFileSystemCacheStorage } from "./verification-cache/adapters/filesystem.js";
|
|
38
|
+
import { WorkspaceStateCacheStorage, createWorkspaceStateCacheStorage } from "./verification-cache/adapters/workspace-state.js";
|
|
39
|
+
import "./verification-cache/index.js";
|
|
40
|
+
import { runCIChecks } from "./ci-check/ci-check-service.js";
|
|
41
|
+
import "./ci-check/index.js";
|
|
42
|
+
import { ClaudeCodeAdapter, claudeCodeAdapter } from "./agent-guide/adapters/claude-code.js";
|
|
43
|
+
import { CursorCLIAdapter, cursorCLIAdapter } from "./agent-guide/adapters/cursor-cli.js";
|
|
44
|
+
import { GenericMCPAdapter, genericMCPAdapter } from "./agent-guide/adapters/generic-mcp.js";
|
|
45
|
+
import { agentAdapters, getAgentAdapter, listAgentTypes } from "./agent-guide/adapters/index.js";
|
|
46
|
+
import { AgentGuideService, agentGuideService, createAgentGuideService } from "./agent-guide/agent-guide-service.js";
|
|
47
|
+
import "./agent-guide/index.js";
|
|
48
|
+
import { verifyStructure } from "./verify/structure-verifier.js";
|
|
49
|
+
import { verifyBehavior } from "./verify/behavior-verifier.js";
|
|
50
|
+
import { createQuickAIReview, verifySemanticFields, verifyWithAI, verifyWithAIEnhanced } from "./verify/ai-verifier.js";
|
|
51
|
+
import { VerifyService, createVerifyService, verifyService } from "./verify/verify-service.js";
|
|
52
|
+
import "./verify/index.js";
|
|
53
|
+
import "./implementation/index.js";
|