@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,14 +1,69 @@
|
|
|
1
|
-
import{anthropic
|
|
1
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
2
|
+
import { generateText } from "ai";
|
|
3
|
+
|
|
4
|
+
//#region src/ai/agents/claude-code-agent.ts
|
|
5
|
+
/**
|
|
6
|
+
* Claude Code Agent - Uses Anthropic's advanced code capabilities
|
|
7
|
+
* with extended context and agentic workflows
|
|
8
|
+
*/
|
|
9
|
+
var ClaudeCodeAgent = class {
|
|
10
|
+
name = "claude-code";
|
|
11
|
+
apiKey;
|
|
12
|
+
constructor() {
|
|
13
|
+
this.apiKey = process.env.ANTHROPIC_API_KEY;
|
|
14
|
+
}
|
|
15
|
+
canHandle(task) {
|
|
16
|
+
return !!this.apiKey;
|
|
17
|
+
}
|
|
18
|
+
async generate(task) {
|
|
19
|
+
if (!this.apiKey) return {
|
|
20
|
+
success: false,
|
|
21
|
+
errors: ["ANTHROPIC_API_KEY not set. Claude Code agent requires API access."]
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
const model = anthropic("claude-3-7-sonnet-20250219");
|
|
25
|
+
const systemPrompt = this.buildSystemPrompt(task);
|
|
26
|
+
const result = await generateText({
|
|
27
|
+
model,
|
|
28
|
+
prompt: this.buildUserPrompt(task),
|
|
29
|
+
system: systemPrompt,
|
|
30
|
+
temperature: .2
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
code: this.extractCode(result.text),
|
|
35
|
+
metadata: {
|
|
36
|
+
model: "claude-3-7-sonnet",
|
|
37
|
+
agentMode: "claude-code",
|
|
38
|
+
usage: result.usage
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return {
|
|
43
|
+
success: false,
|
|
44
|
+
errors: [error instanceof Error ? error.message : String(error)]
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async validate(task) {
|
|
49
|
+
if (!this.apiKey) return {
|
|
50
|
+
success: false,
|
|
51
|
+
errors: ["ANTHROPIC_API_KEY not set"]
|
|
52
|
+
};
|
|
53
|
+
try {
|
|
54
|
+
const result = await generateText({
|
|
55
|
+
model: anthropic("claude-3-7-sonnet-20250219"),
|
|
56
|
+
prompt: `
|
|
2
57
|
You are an expert code reviewer. Carefully analyze this implementation against its specification.
|
|
3
58
|
|
|
4
59
|
SPECIFICATION:
|
|
5
60
|
\`\`\`typescript
|
|
6
|
-
${
|
|
61
|
+
${task.specCode}
|
|
7
62
|
\`\`\`
|
|
8
63
|
|
|
9
64
|
IMPLEMENTATION:
|
|
10
65
|
\`\`\`typescript
|
|
11
|
-
${
|
|
66
|
+
${task.existingCode || "// No implementation provided"}
|
|
12
67
|
\`\`\`
|
|
13
68
|
|
|
14
69
|
Provide a structured validation report:
|
|
@@ -27,7 +82,31 @@ Provide a structured validation report:
|
|
|
27
82
|
- Are there any missing edge cases?
|
|
28
83
|
|
|
29
84
|
Be thorough and precise. Use a critical but constructive tone.
|
|
30
|
-
`,
|
|
85
|
+
`,
|
|
86
|
+
system: "You are a senior software engineer performing a critical code review.",
|
|
87
|
+
temperature: .3
|
|
88
|
+
});
|
|
89
|
+
const hasErrors = this.detectIssues(result.text);
|
|
90
|
+
return {
|
|
91
|
+
success: !hasErrors,
|
|
92
|
+
code: result.text,
|
|
93
|
+
errors: hasErrors ? this.extractErrors(result.text) : [],
|
|
94
|
+
warnings: this.extractWarnings(result.text),
|
|
95
|
+
suggestions: this.extractSuggestions(result.text),
|
|
96
|
+
metadata: {
|
|
97
|
+
agentMode: "claude-code",
|
|
98
|
+
validationType: "comprehensive"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
} catch (error) {
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
errors: [error instanceof Error ? error.message : String(error)]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
buildSystemPrompt(task) {
|
|
109
|
+
const basePrompt = `You are an expert TypeScript developer specializing in contract-driven development.
|
|
31
110
|
|
|
32
111
|
Your code is:
|
|
33
112
|
- Type-safe with comprehensive TypeScript types
|
|
@@ -36,9 +115,67 @@ Your code is:
|
|
|
36
115
|
- Following SOLID principles and best practices
|
|
37
116
|
- Modular and testable
|
|
38
117
|
|
|
39
|
-
Generate clean, idiomatic TypeScript code that exactly matches the specification.`;
|
|
118
|
+
Generate clean, idiomatic TypeScript code that exactly matches the specification.`;
|
|
119
|
+
if (task.type === "test") return basePrompt + "\n\nYou are also an expert in testing. Write comprehensive tests using Vitest.";
|
|
120
|
+
return basePrompt;
|
|
121
|
+
}
|
|
122
|
+
buildUserPrompt(task) {
|
|
123
|
+
const prompts = {
|
|
124
|
+
generate: `Generate a complete, production-ready implementation for this specification:\n\n${task.specCode}\n\nProvide ONLY the TypeScript code, no explanations.`,
|
|
125
|
+
test: `Generate comprehensive tests for this code:\n\nSpec:\n${task.specCode}\n\nImplementation:\n${task.existingCode}\n\nProvide complete Vitest test suite.`,
|
|
126
|
+
refactor: `Refactor this code while preserving functionality:\n\n${task.existingCode}\n\nSpec:\n${task.specCode}`,
|
|
127
|
+
validate: `Validate this implementation:\n\nSpec:\n${task.specCode}\n\nCode:\n${task.existingCode}`
|
|
128
|
+
};
|
|
129
|
+
return prompts[task.type] || prompts.generate;
|
|
130
|
+
}
|
|
131
|
+
extractCode(text) {
|
|
132
|
+
const codeBlockMatch = text.match(/```(?:typescript|ts|tsx)?\n([\s\S]*?)\n```/);
|
|
133
|
+
if (codeBlockMatch && codeBlockMatch[1]) return codeBlockMatch[1];
|
|
134
|
+
return text;
|
|
135
|
+
}
|
|
136
|
+
detectIssues(reviewText) {
|
|
137
|
+
const errorIndicators = [
|
|
138
|
+
"missing",
|
|
139
|
+
"incorrect",
|
|
140
|
+
"bug",
|
|
141
|
+
"error",
|
|
142
|
+
"violation",
|
|
143
|
+
"does not",
|
|
144
|
+
"fails to",
|
|
145
|
+
"not implemented",
|
|
146
|
+
"critical"
|
|
147
|
+
];
|
|
148
|
+
const lowerText = reviewText.toLowerCase();
|
|
149
|
+
return errorIndicators.some((indicator) => lowerText.includes(indicator));
|
|
150
|
+
}
|
|
151
|
+
extractErrors(text) {
|
|
152
|
+
const errors = [];
|
|
153
|
+
const lines = text.split("\n");
|
|
154
|
+
for (const line of lines) {
|
|
155
|
+
const lower = line.toLowerCase();
|
|
156
|
+
if (lower.includes("error") || lower.includes("bug") || lower.includes("incorrect") || lower.includes("missing")) errors.push(line.trim());
|
|
157
|
+
}
|
|
158
|
+
return errors.length > 0 ? errors : ["Code review identified issues"];
|
|
159
|
+
}
|
|
160
|
+
extractWarnings(text) {
|
|
161
|
+
const warnings = [];
|
|
162
|
+
const lines = text.split("\n");
|
|
163
|
+
for (const line of lines) {
|
|
164
|
+
const lower = line.toLowerCase();
|
|
165
|
+
if (lower.includes("warning") || lower.includes("should") || lower.includes("consider")) warnings.push(line.trim());
|
|
166
|
+
}
|
|
167
|
+
return warnings;
|
|
168
|
+
}
|
|
169
|
+
extractSuggestions(text) {
|
|
170
|
+
const suggestions = [];
|
|
171
|
+
const lines = text.split("\n");
|
|
172
|
+
for (const line of lines) {
|
|
173
|
+
const lower = line.toLowerCase();
|
|
174
|
+
if (lower.includes("suggest") || lower.includes("recommend") || lower.includes("could") || lower.includes("improvement")) suggestions.push(line.trim());
|
|
175
|
+
}
|
|
176
|
+
return suggestions;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
40
179
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
`);for(let e of n){let n=e.toLowerCase();(n.includes(`warning`)||n.includes(`should`)||n.includes(`consider`))&&t.push(e.trim())}return t}extractSuggestions(e){let t=[],n=e.split(`
|
|
44
|
-
`);for(let e of n){let n=e.toLowerCase();(n.includes(`suggest`)||n.includes(`recommend`)||n.includes(`could`)||n.includes(`improvement`))&&t.push(e.trim())}return t}};export{n as ClaudeCodeAgent};
|
|
180
|
+
//#endregion
|
|
181
|
+
export { ClaudeCodeAgent };
|
|
@@ -1,4 +1,188 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { exec, spawn } from "child_process";
|
|
4
|
+
import { mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
5
|
+
import { homedir, tmpdir } from "os";
|
|
6
|
+
import { promisify } from "util";
|
|
7
|
+
|
|
8
|
+
//#region src/ai/agents/cursor-agent.ts
|
|
9
|
+
/**
|
|
10
|
+
* Cursor/Windsurf Agent - Fully Implemented
|
|
11
|
+
* Leverages Windsurf AI capabilities and Cursor IDE integration for code generation and validation
|
|
12
|
+
*/
|
|
13
|
+
promisify(exec);
|
|
14
|
+
var CursorAgent = class {
|
|
15
|
+
name = "cursor";
|
|
16
|
+
cursorPath = null;
|
|
17
|
+
isWindsurf = false;
|
|
18
|
+
composerPort;
|
|
19
|
+
constructor() {
|
|
20
|
+
this.composerPort = process.env.CURSOR_COMPOSER_PORT || "3000";
|
|
21
|
+
this.detectEnvironment();
|
|
22
|
+
}
|
|
23
|
+
canHandle(task) {
|
|
24
|
+
return this.isCursorAvailable();
|
|
25
|
+
}
|
|
26
|
+
async generate(task) {
|
|
27
|
+
try {
|
|
28
|
+
const workDir = join(tmpdir(), `cursor-agent-${Date.now()}`);
|
|
29
|
+
await mkdir(workDir, { recursive: true });
|
|
30
|
+
const result = await this.executeWithBestMethod(task, workDir);
|
|
31
|
+
await this.cleanupWorkDir(workDir);
|
|
32
|
+
return result;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
success: false,
|
|
36
|
+
errors: [error instanceof Error ? error.message : String(error)]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async validate(task) {
|
|
41
|
+
try {
|
|
42
|
+
const workDir = join(tmpdir(), `cursor-validate-${Date.now()}`);
|
|
43
|
+
await mkdir(workDir, { recursive: true });
|
|
44
|
+
await this.setupValidationWorkspace(task, workDir);
|
|
45
|
+
const result = await this.executeWithBestMethod({
|
|
46
|
+
...task,
|
|
47
|
+
type: "validate"
|
|
48
|
+
}, workDir);
|
|
49
|
+
await this.cleanupWorkDir(workDir);
|
|
50
|
+
return result;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
errors: [error instanceof Error ? error.message : String(error)]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Detect if running in Cursor/Windsurf environment
|
|
60
|
+
*/
|
|
61
|
+
detectEnvironment() {
|
|
62
|
+
this.isWindsurf = !!(process.env.WINDSURF_SESSION || process.env.CURSOR_USER_DATA || process.env.VSCODE_CWD?.includes("Cursor") || process.env.VSCODE_CWD?.includes("Windsurf"));
|
|
63
|
+
const possiblePaths = [
|
|
64
|
+
"/usr/local/bin/cursor",
|
|
65
|
+
"/Applications/Cursor.app/Contents/MacOS/Cursor",
|
|
66
|
+
"/Applications/Windsurf.app/Contents/MacOS/Windsurf",
|
|
67
|
+
join(homedir(), ".cursor", "cursor"),
|
|
68
|
+
join(homedir(), "AppData", "Local", "Programs", "cursor", "Cursor.exe"),
|
|
69
|
+
join(homedir(), "AppData", "Local", "Programs", "windsurf", "Windsurf.exe"),
|
|
70
|
+
"cursor",
|
|
71
|
+
"windsurf"
|
|
72
|
+
];
|
|
73
|
+
for (const path of possiblePaths) if (path.includes("cursor") || path.includes("Cursor") || path.includes("windsurf") || path.includes("Windsurf")) try {
|
|
74
|
+
if (existsSync(path)) {
|
|
75
|
+
this.cursorPath = path;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
} catch {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Execute task using the best available method
|
|
84
|
+
*/
|
|
85
|
+
async executeWithBestMethod(task, workDir) {
|
|
86
|
+
const methods = [{
|
|
87
|
+
name: "cursor-cli",
|
|
88
|
+
fn: () => this.useCursorCLI(task, workDir)
|
|
89
|
+
}, {
|
|
90
|
+
name: "file-based",
|
|
91
|
+
fn: () => this.useFileBasedApproach(task, workDir)
|
|
92
|
+
}];
|
|
93
|
+
for (const method of methods) try {
|
|
94
|
+
const result = await method.fn();
|
|
95
|
+
if (result.success) return result;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
success: false,
|
|
101
|
+
warnings: [
|
|
102
|
+
"Cursor agent could not connect to IDE.",
|
|
103
|
+
"Ensure Cursor/Windsurf is running with API enabled.",
|
|
104
|
+
"Falling back to simple agent mode is recommended."
|
|
105
|
+
],
|
|
106
|
+
errors: ["All Cursor integration methods failed"],
|
|
107
|
+
metadata: {
|
|
108
|
+
agentMode: "cursor",
|
|
109
|
+
status: "unavailable",
|
|
110
|
+
suggestion: "Use --agent-mode claude-code or --agent-mode simple"
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Use Windsurf's native API
|
|
116
|
+
*/
|
|
117
|
+
/**
|
|
118
|
+
* Use Cursor Composer API
|
|
119
|
+
*/
|
|
120
|
+
/**
|
|
121
|
+
* Use Cursor CLI directly
|
|
122
|
+
*/
|
|
123
|
+
async useCursorCLI(task, workDir) {
|
|
124
|
+
if (!this.cursorPath) throw new Error("Cursor executable not found");
|
|
125
|
+
const specPath = join(workDir, "spec.ts");
|
|
126
|
+
const outputPath = join(workDir, "output.ts");
|
|
127
|
+
const instructionsPath = join(workDir, "INSTRUCTIONS.md");
|
|
128
|
+
await writeFile(specPath, task.specCode);
|
|
129
|
+
await writeFile(instructionsPath, this.buildDetailedPrompt(task));
|
|
130
|
+
if (task.existingCode) await writeFile(join(workDir, "existing.ts"), task.existingCode);
|
|
131
|
+
return new Promise((resolve, reject) => {
|
|
132
|
+
const args = [
|
|
133
|
+
"--wait",
|
|
134
|
+
"--new-window",
|
|
135
|
+
workDir
|
|
136
|
+
];
|
|
137
|
+
const cursor = spawn(this.cursorPath, args, {
|
|
138
|
+
cwd: workDir,
|
|
139
|
+
stdio: "pipe",
|
|
140
|
+
detached: false
|
|
141
|
+
});
|
|
142
|
+
let stdout = "";
|
|
143
|
+
let stderr = "";
|
|
144
|
+
cursor.stdout?.on("data", (data) => {
|
|
145
|
+
stdout += data.toString();
|
|
146
|
+
});
|
|
147
|
+
cursor.stderr?.on("data", (data) => {
|
|
148
|
+
stderr += data.toString();
|
|
149
|
+
});
|
|
150
|
+
cursor.on("error", (error) => {
|
|
151
|
+
reject(error);
|
|
152
|
+
});
|
|
153
|
+
cursor.on("close", async (code) => {
|
|
154
|
+
if (existsSync(outputPath)) try {
|
|
155
|
+
resolve({
|
|
156
|
+
success: true,
|
|
157
|
+
code: await readFile(outputPath, "utf-8"),
|
|
158
|
+
metadata: {
|
|
159
|
+
agentMode: "cursor",
|
|
160
|
+
method: "cli",
|
|
161
|
+
exitCode: code
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
} catch (error) {
|
|
165
|
+
reject(/* @__PURE__ */ new Error("Failed to read generated output"));
|
|
166
|
+
}
|
|
167
|
+
else reject(/* @__PURE__ */ new Error(`Cursor CLI exited with code ${code}. No output generated.`));
|
|
168
|
+
});
|
|
169
|
+
setTimeout(() => {
|
|
170
|
+
cursor.kill();
|
|
171
|
+
reject(/* @__PURE__ */ new Error("Cursor CLI timeout"));
|
|
172
|
+
}, 6e4);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* File-based approach - create workspace and instructions for manual completion
|
|
177
|
+
*/
|
|
178
|
+
async useFileBasedApproach(task, workDir) {
|
|
179
|
+
const specPath = join(workDir, "SPECIFICATION.ts");
|
|
180
|
+
const instructionsPath = join(workDir, "INSTRUCTIONS.md");
|
|
181
|
+
const templatePath = join(workDir, "template.ts");
|
|
182
|
+
await writeFile(specPath, task.specCode);
|
|
183
|
+
await writeFile(instructionsPath, this.buildDetailedPrompt(task));
|
|
184
|
+
await writeFile(templatePath, this.generateTemplate(task));
|
|
185
|
+
await writeFile(join(workDir, "README.md"), `# Cursor Agent Workspace
|
|
2
186
|
|
|
3
187
|
This workspace was prepared for Cursor AI code generation.
|
|
4
188
|
|
|
@@ -13,8 +197,53 @@ This workspace was prepared for Cursor AI code generation.
|
|
|
13
197
|
3. Use Cursor AI to generate code based on the spec
|
|
14
198
|
4. Save the result as output.ts
|
|
15
199
|
|
|
16
|
-
Workspace path: ${
|
|
17
|
-
`)
|
|
200
|
+
Workspace path: ${workDir}
|
|
201
|
+
`);
|
|
202
|
+
return {
|
|
203
|
+
success: false,
|
|
204
|
+
warnings: [
|
|
205
|
+
"Cursor agent created workspace but cannot auto-execute.",
|
|
206
|
+
`Workspace prepared at: ${workDir}`,
|
|
207
|
+
"Open this folder in Cursor IDE to complete code generation."
|
|
208
|
+
],
|
|
209
|
+
code: this.generateTemplate(task),
|
|
210
|
+
metadata: {
|
|
211
|
+
agentMode: "cursor",
|
|
212
|
+
method: "file-based",
|
|
213
|
+
workDir
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Setup workspace for validation
|
|
219
|
+
*/
|
|
220
|
+
async setupValidationWorkspace(task, workDir) {
|
|
221
|
+
await writeFile(join(workDir, "specification.ts"), task.specCode);
|
|
222
|
+
await writeFile(join(workDir, "implementation.ts"), task.existingCode || "// No implementation");
|
|
223
|
+
await writeFile(join(workDir, "VALIDATION_INSTRUCTIONS.md"), this.buildValidationPrompt(task));
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Prepare files for API submission
|
|
227
|
+
*/
|
|
228
|
+
async prepareFilesForAPI(task, workDir) {
|
|
229
|
+
const files = [{
|
|
230
|
+
path: "spec.ts",
|
|
231
|
+
content: task.specCode
|
|
232
|
+
}];
|
|
233
|
+
if (task.existingCode) files.push({
|
|
234
|
+
path: "existing.ts",
|
|
235
|
+
content: task.existingCode
|
|
236
|
+
});
|
|
237
|
+
return files;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Build detailed prompt for cursor
|
|
241
|
+
*/
|
|
242
|
+
buildDetailedPrompt(task) {
|
|
243
|
+
const header = `# AI Code Generation Task - Cursor Agent\n\n**Task Type:** ${task.type}\n**Generated:** ${(/* @__PURE__ */ new Date()).toISOString()}\n\n`;
|
|
244
|
+
const specification = `## Specification\n\n\`\`\`typescript\n${task.specCode}\n\`\`\`\n\n`;
|
|
245
|
+
const taskInstructions = {
|
|
246
|
+
generate: `## Task: Generate Implementation
|
|
18
247
|
|
|
19
248
|
### Requirements:
|
|
20
249
|
1. **Type Safety**: Use strict TypeScript with comprehensive types
|
|
@@ -34,11 +263,12 @@ Workspace path: ${n}
|
|
|
34
263
|
|
|
35
264
|
### Output Format:
|
|
36
265
|
Provide complete, executable TypeScript code that fully implements the specification.
|
|
37
|
-
Include all necessary imports and type definitions.`,
|
|
266
|
+
Include all necessary imports and type definitions.`,
|
|
267
|
+
validate: `## Task: Validate Implementation
|
|
38
268
|
|
|
39
269
|
### Current Implementation:
|
|
40
270
|
\`\`\`typescript
|
|
41
|
-
${
|
|
271
|
+
${task.existingCode || "// No implementation provided"}
|
|
42
272
|
\`\`\`
|
|
43
273
|
|
|
44
274
|
### Validation Criteria:
|
|
@@ -62,11 +292,12 @@ Provide a detailed validation report with:
|
|
|
62
292
|
- **Status**: Pass/Fail
|
|
63
293
|
- **Issues Found**: List all problems
|
|
64
294
|
- **Recommendations**: Specific improvements needed
|
|
65
|
-
- **Code Quality Score**: Rate the implementation`,
|
|
295
|
+
- **Code Quality Score**: Rate the implementation`,
|
|
296
|
+
test: `## Task: Generate Tests
|
|
66
297
|
|
|
67
298
|
### Implementation to Test:
|
|
68
299
|
\`\`\`typescript
|
|
69
|
-
${
|
|
300
|
+
${task.existingCode || ""}
|
|
70
301
|
\`\`\`
|
|
71
302
|
|
|
72
303
|
### Test Requirements:
|
|
@@ -84,11 +315,12 @@ ${e.existingCode||``}
|
|
|
84
315
|
- Performance tests (if applicable)
|
|
85
316
|
|
|
86
317
|
### Output Format:
|
|
87
|
-
Complete Vitest test file with comprehensive test coverage.`,
|
|
318
|
+
Complete Vitest test file with comprehensive test coverage.`,
|
|
319
|
+
refactor: `## Task: Refactor Code
|
|
88
320
|
|
|
89
321
|
### Current Code:
|
|
90
322
|
\`\`\`typescript
|
|
91
|
-
${
|
|
323
|
+
${task.existingCode || ""}
|
|
92
324
|
\`\`\`
|
|
93
325
|
|
|
94
326
|
### Refactoring Goals:
|
|
@@ -107,16 +339,24 @@ ${e.existingCode||``}
|
|
|
107
339
|
- Enhance error messages
|
|
108
340
|
|
|
109
341
|
### Output Format:
|
|
110
|
-
Refactored code that maintains functionality while improving quality.`
|
|
342
|
+
Refactored code that maintains functionality while improving quality.`
|
|
343
|
+
};
|
|
344
|
+
return header + specification + (taskInstructions[task.type] || taskInstructions.generate);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Build validation-specific prompt
|
|
348
|
+
*/
|
|
349
|
+
buildValidationPrompt(task) {
|
|
350
|
+
return `# Implementation Validation Report
|
|
111
351
|
|
|
112
352
|
## Specification
|
|
113
353
|
\`\`\`typescript
|
|
114
|
-
${
|
|
354
|
+
${task.specCode}
|
|
115
355
|
\`\`\`
|
|
116
356
|
|
|
117
357
|
## Implementation
|
|
118
358
|
\`\`\`typescript
|
|
119
|
-
${
|
|
359
|
+
${task.existingCode || "// No implementation"}
|
|
120
360
|
\`\`\`
|
|
121
361
|
|
|
122
362
|
## Validation Checklist
|
|
@@ -152,11 +392,15 @@ ${e.existingCode||`// No implementation`}
|
|
|
152
392
|
## Instructions
|
|
153
393
|
Review the implementation against the specification and complete the checklist.
|
|
154
394
|
Provide detailed feedback for each failed item.
|
|
155
|
-
Suggest specific improvements with code examples where applicable
|
|
395
|
+
Suggest specific improvements with code examples where applicable.`;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Generate basic template for task
|
|
399
|
+
*/
|
|
400
|
+
generateTemplate(task) {
|
|
401
|
+
return `// Auto-generated template for ${task.type} task
|
|
156
402
|
// Specification:
|
|
157
|
-
${
|
|
158
|
-
`).map(e=>`// ${e}`).join(`
|
|
159
|
-
`)}
|
|
403
|
+
${task.specCode.split("\n").map((line) => `// ${line}`).join("\n")}
|
|
160
404
|
|
|
161
405
|
// TODO: Implement according to specification
|
|
162
406
|
// Use Cursor AI to complete this implementation
|
|
@@ -165,4 +409,29 @@ export function implementation() {
|
|
|
165
409
|
// Implementation goes here
|
|
166
410
|
throw new Error('Not implemented');
|
|
167
411
|
}
|
|
168
|
-
|
|
412
|
+
`;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Cleanup temporary work directory
|
|
416
|
+
*/
|
|
417
|
+
async cleanupWorkDir(workDir) {
|
|
418
|
+
try {
|
|
419
|
+
await rm(workDir, {
|
|
420
|
+
recursive: true,
|
|
421
|
+
force: true
|
|
422
|
+
});
|
|
423
|
+
} catch {}
|
|
424
|
+
}
|
|
425
|
+
isCursorAvailable() {
|
|
426
|
+
return this.isWindsurf || this.cursorPath !== null || this.hasComposerAPI();
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Check if Cursor Composer API might be available
|
|
430
|
+
*/
|
|
431
|
+
hasComposerAPI() {
|
|
432
|
+
return !!(process.env.CURSOR_COMPOSER_PORT || process.env.CURSOR_API_ENABLED || this.isWindsurf);
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
//#endregion
|
|
437
|
+
export { CursorAgent };
|
package/dist/ai/agents/index.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SimpleAgent } from "./simple-agent.js";
|
|
2
|
+
import { CursorAgent } from "./cursor-agent.js";
|
|
3
|
+
import { ClaudeCodeAgent } from "./claude-code-agent.js";
|
|
4
|
+
import { OpenAICodexAgent } from "./openai-codex-agent.js";
|
|
5
|
+
import { AgentOrchestrator } from "./orchestrator.js";
|