@lssm/bundle.contractspec-workspace 0.0.0-canary-20251217063201 → 0.0.0-canary-20251217072406
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 +1,148 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { featureToMarkdown, specToAgentPrompt, specToFullMarkdown } from "../../libs/contracts/dist/llm/exporters.js";
|
|
2
|
+
import { generateImplementationPlan } from "../../libs/contracts/dist/llm/prompts.js";
|
|
3
|
+
import "../../libs/contracts/dist/llm/index.js";
|
|
4
|
+
import { getAgentAdapter, listAgentTypes } from "./adapters/index.js";
|
|
5
|
+
|
|
6
|
+
//#region src/services/agent-guide/agent-guide-service.ts
|
|
7
|
+
const DEFAULT_CONFIG = {
|
|
8
|
+
defaultAgent: "generic-mcp",
|
|
9
|
+
verbose: false
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Agent Guide Service
|
|
13
|
+
*
|
|
14
|
+
* Main service for generating implementation guidance for AI coding agents.
|
|
15
|
+
*/
|
|
16
|
+
var AgentGuideService = class {
|
|
17
|
+
config;
|
|
18
|
+
constructor(config = {}) {
|
|
19
|
+
this.config = {
|
|
20
|
+
...DEFAULT_CONFIG,
|
|
21
|
+
...config
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Generate an implementation guide for a spec.
|
|
26
|
+
*/
|
|
27
|
+
generateGuide(spec, options = {}) {
|
|
28
|
+
const adapter = getAgentAdapter(options.agent ?? this.config.defaultAgent);
|
|
29
|
+
const plan = generateImplementationPlan(spec, {
|
|
30
|
+
projectRoot: this.config.projectRoot,
|
|
31
|
+
existingFiles: options.targetPath ? [options.targetPath] : void 0
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
plan,
|
|
35
|
+
prompt: adapter.formatPlan(plan),
|
|
36
|
+
markdown: specToFullMarkdown(spec)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Generate a guide for a feature (includes all related specs).
|
|
41
|
+
*/
|
|
42
|
+
generateFeatureGuide(feature, deps, options = {}) {
|
|
43
|
+
const adapter = getAgentAdapter(options.agent ?? this.config.defaultAgent);
|
|
44
|
+
const firstOp = feature.operations?.[0];
|
|
45
|
+
const spec = firstOp ? deps.specs?.getSpec(firstOp.name, firstOp.version) : void 0;
|
|
46
|
+
let plan;
|
|
47
|
+
if (spec) {
|
|
48
|
+
plan = generateImplementationPlan(spec, { projectRoot: this.config.projectRoot });
|
|
49
|
+
plan.target = {
|
|
50
|
+
type: "feature",
|
|
51
|
+
name: feature.meta.key,
|
|
52
|
+
version: 1
|
|
53
|
+
};
|
|
54
|
+
plan.context.goal = feature.meta.description ?? plan.context.goal;
|
|
55
|
+
} else plan = {
|
|
56
|
+
target: {
|
|
57
|
+
type: "feature",
|
|
58
|
+
name: feature.meta.key,
|
|
59
|
+
version: 1
|
|
60
|
+
},
|
|
61
|
+
context: {
|
|
62
|
+
goal: feature.meta.description ?? `Implement feature ${feature.meta.key}`,
|
|
63
|
+
description: feature.meta.title ?? feature.meta.key,
|
|
64
|
+
background: ""
|
|
65
|
+
},
|
|
66
|
+
specMarkdown: featureToMarkdown(feature, deps),
|
|
67
|
+
fileStructure: [],
|
|
68
|
+
steps: [{
|
|
69
|
+
order: 1,
|
|
70
|
+
title: "Implement Feature",
|
|
71
|
+
description: `Implement the ${feature.meta.key} feature`,
|
|
72
|
+
acceptanceCriteria: []
|
|
73
|
+
}],
|
|
74
|
+
constraints: {
|
|
75
|
+
policy: [],
|
|
76
|
+
security: [],
|
|
77
|
+
pii: []
|
|
78
|
+
},
|
|
79
|
+
verificationChecklist: []
|
|
80
|
+
};
|
|
81
|
+
plan.specMarkdown = featureToMarkdown(feature, deps, {
|
|
82
|
+
format: "full",
|
|
83
|
+
includeRelatedSpecs: true,
|
|
84
|
+
includeRelatedEvents: true,
|
|
85
|
+
includeRelatedPresentations: true
|
|
86
|
+
});
|
|
87
|
+
if (feature.operations?.length) plan.steps = feature.operations.map((op, idx) => ({
|
|
88
|
+
order: idx + 1,
|
|
89
|
+
title: `Implement ${op.name}`,
|
|
90
|
+
description: `Implement operation ${op.name}.v${op.version}`,
|
|
91
|
+
acceptanceCriteria: [`Operation ${op.name} works as specified`]
|
|
92
|
+
}));
|
|
93
|
+
const prompt = adapter.formatPlan(plan);
|
|
94
|
+
const markdown = featureToMarkdown(feature, deps);
|
|
95
|
+
return {
|
|
96
|
+
plan,
|
|
97
|
+
prompt,
|
|
98
|
+
markdown
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Generate agent-specific configuration (e.g., cursor rules).
|
|
103
|
+
*/
|
|
104
|
+
generateAgentConfig(spec, agent) {
|
|
105
|
+
return getAgentAdapter(agent ?? this.config.defaultAgent).generateConfig?.(spec);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Export a spec in a specific format for an agent.
|
|
109
|
+
*/
|
|
110
|
+
exportForAgent(spec, agent, taskType = "implement", existingCode) {
|
|
111
|
+
return specToAgentPrompt(spec, {
|
|
112
|
+
taskType,
|
|
113
|
+
existingCode
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* List available agent types.
|
|
118
|
+
*/
|
|
119
|
+
listAgentTypes() {
|
|
120
|
+
return listAgentTypes();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get the default agent type.
|
|
124
|
+
*/
|
|
125
|
+
getDefaultAgent() {
|
|
126
|
+
return this.config.defaultAgent;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Update configuration.
|
|
130
|
+
*/
|
|
131
|
+
configure(config) {
|
|
132
|
+
this.config = {
|
|
133
|
+
...this.config,
|
|
134
|
+
...config
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Create a new AgentGuideService instance.
|
|
140
|
+
*/
|
|
141
|
+
function createAgentGuideService(config) {
|
|
142
|
+
return new AgentGuideService(config);
|
|
143
|
+
}
|
|
144
|
+
/** Default singleton instance */
|
|
145
|
+
const agentGuideService = new AgentGuideService();
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
export { AgentGuideService, agentGuideService, createAgentGuideService };
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ClaudeCodeAdapter, claudeCodeAdapter } from "./adapters/claude-code.js";
|
|
2
|
+
import { CursorCLIAdapter, cursorCLIAdapter } from "./adapters/cursor-cli.js";
|
|
3
|
+
import { GenericMCPAdapter, genericMCPAdapter } from "./adapters/generic-mcp.js";
|
|
4
|
+
import { agentAdapters, getAgentAdapter, listAgentTypes } from "./adapters/index.js";
|
|
5
|
+
import { AgentGuideService, agentGuideService, createAgentGuideService } from "./agent-guide-service.js";
|
package/dist/services/build.js
CHANGED
|
@@ -1 +1,140 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { inferSpecTypeFromFilePath, scanSpecSource } from "../modules/contractspec-workspace/dist/analysis/spec-scan.js";
|
|
2
|
+
import { generateComponentTemplate, generateHandlerTemplate, generateTestTemplate } from "../modules/contractspec-workspace/dist/templates/handler.js";
|
|
3
|
+
|
|
4
|
+
//#region src/services/build.ts
|
|
5
|
+
/**
|
|
6
|
+
* Build/scaffold service for generating implementation files from specs.
|
|
7
|
+
*
|
|
8
|
+
* Uses templates from @lssm/module.contractspec-workspace to generate
|
|
9
|
+
* handler, component, and test skeletons without requiring AI.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Build implementation files from a spec.
|
|
13
|
+
*/
|
|
14
|
+
async function buildSpec(specPath, adapters, config, options = {}) {
|
|
15
|
+
const { fs, logger } = adapters;
|
|
16
|
+
const { targets = detectDefaultTargets(specPath), outputDir = config.outputDir, overwrite = false, dryRun = false } = options;
|
|
17
|
+
const specCode = await fs.readFile(specPath);
|
|
18
|
+
const specInfo = scanSpecSource(specCode, specPath);
|
|
19
|
+
const specType = inferSpecTypeFromFilePath(specPath);
|
|
20
|
+
logger.info(`Building from spec: ${specPath}`, { specType });
|
|
21
|
+
const results = [];
|
|
22
|
+
for (const target of targets) try {
|
|
23
|
+
const result = await buildTarget(target, specPath, specCode, specInfo, specType, {
|
|
24
|
+
fs,
|
|
25
|
+
logger
|
|
26
|
+
}, outputDir, overwrite, dryRun);
|
|
27
|
+
results.push(result);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
results.push({
|
|
30
|
+
target,
|
|
31
|
+
outputPath: "",
|
|
32
|
+
success: false,
|
|
33
|
+
error: error instanceof Error ? error.message : String(error)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
specPath,
|
|
38
|
+
specInfo,
|
|
39
|
+
results
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Build a single target from a spec.
|
|
44
|
+
*/
|
|
45
|
+
async function buildTarget(target, specPath, _specCode, specInfo, specType, adapters, outputDir, overwrite, dryRun) {
|
|
46
|
+
const { fs, logger } = adapters;
|
|
47
|
+
let code;
|
|
48
|
+
let outputPath;
|
|
49
|
+
switch (target) {
|
|
50
|
+
case "handler": {
|
|
51
|
+
if (specType !== "operation") return {
|
|
52
|
+
target,
|
|
53
|
+
outputPath: "",
|
|
54
|
+
success: false,
|
|
55
|
+
skipped: true,
|
|
56
|
+
error: `Handler generation only supported for operation specs (got ${specType})`
|
|
57
|
+
};
|
|
58
|
+
const kind = specInfo.kind === "command" || specInfo.kind === "query" ? specInfo.kind : "command";
|
|
59
|
+
code = generateHandlerTemplate(specInfo.name ?? "unknown", kind);
|
|
60
|
+
outputPath = resolveOutputPath(specPath, outputDir, "handlers", specInfo.name ?? "unknown", ".handler.ts", adapters.fs);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
case "component":
|
|
64
|
+
if (specType !== "presentation") return {
|
|
65
|
+
target,
|
|
66
|
+
outputPath: "",
|
|
67
|
+
success: false,
|
|
68
|
+
skipped: true,
|
|
69
|
+
error: `Component generation only supported for presentation specs (got ${specType})`
|
|
70
|
+
};
|
|
71
|
+
code = generateComponentTemplate(specInfo.name ?? "unknown", specInfo.description ?? "");
|
|
72
|
+
outputPath = resolveOutputPath(specPath, outputDir, "components", specInfo.name ?? "unknown", ".tsx", adapters.fs);
|
|
73
|
+
break;
|
|
74
|
+
case "test": {
|
|
75
|
+
const testType = specType === "operation" ? "handler" : "component";
|
|
76
|
+
code = generateTestTemplate(specInfo.name ?? "unknown", testType);
|
|
77
|
+
outputPath = resolveOutputPath(specPath, outputDir, "__tests__", specInfo.name ?? "unknown", ".test.ts", adapters.fs);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
default: return {
|
|
81
|
+
target,
|
|
82
|
+
outputPath: "",
|
|
83
|
+
success: false,
|
|
84
|
+
error: `Unknown target: ${target}`
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (await fs.exists(outputPath) && !overwrite) return {
|
|
88
|
+
target,
|
|
89
|
+
outputPath,
|
|
90
|
+
success: false,
|
|
91
|
+
skipped: true,
|
|
92
|
+
error: "File already exists (use overwrite option)"
|
|
93
|
+
};
|
|
94
|
+
if (dryRun) {
|
|
95
|
+
logger.info(`[dry-run] Would write: ${outputPath}`);
|
|
96
|
+
return {
|
|
97
|
+
target,
|
|
98
|
+
outputPath,
|
|
99
|
+
success: true
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const dirPath = fs.dirname(outputPath);
|
|
103
|
+
await fs.mkdir(dirPath);
|
|
104
|
+
await fs.writeFile(outputPath, code);
|
|
105
|
+
logger.info(`Generated: ${outputPath}`);
|
|
106
|
+
return {
|
|
107
|
+
target,
|
|
108
|
+
outputPath,
|
|
109
|
+
success: true
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Detect default targets based on spec type.
|
|
114
|
+
*/
|
|
115
|
+
function detectDefaultTargets(specPath) {
|
|
116
|
+
switch (inferSpecTypeFromFilePath(specPath)) {
|
|
117
|
+
case "operation": return ["handler"];
|
|
118
|
+
case "presentation": return ["component"];
|
|
119
|
+
default: return [];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Resolve output path for generated file.
|
|
124
|
+
*/
|
|
125
|
+
function resolveOutputPath(specPath, outputDir, subdir, specName, extension, fs) {
|
|
126
|
+
const sanitizedName = toKebabCase(specName.split(".").pop() ?? "unknown");
|
|
127
|
+
let baseDir;
|
|
128
|
+
if (outputDir.startsWith(".")) baseDir = fs.resolve(fs.dirname(specPath), "..", outputDir, subdir);
|
|
129
|
+
else baseDir = fs.resolve(outputDir, subdir);
|
|
130
|
+
return fs.join(baseDir, `${sanitizedName}${extension}`);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Convert string to kebab-case.
|
|
134
|
+
*/
|
|
135
|
+
function toKebabCase(str) {
|
|
136
|
+
return str.replace(/\./g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
//#endregion
|
|
140
|
+
export { buildSpec };
|