@lssm/bundle.contractspec-workspace 0.0.0-canary-20251217083314 → 1.41.1
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 +1 -22
- package/dist/adapters/ai.js +1 -82
- package/dist/adapters/factory.js +1 -36
- package/dist/adapters/fs.js +1 -118
- package/dist/adapters/git.js +1 -54
- package/dist/adapters/index.js +1 -7
- package/dist/adapters/logger.js +1 -80
- package/dist/adapters/watcher.js +1 -69
- package/dist/adapters/workspace.js +2 -190
- package/dist/ai/agents/claude-code-agent.js +9 -146
- package/dist/ai/agents/cursor-agent.js +17 -286
- package/dist/ai/agents/index.js +1 -5
- package/dist/ai/agents/openai-codex-agent.js +8 -140
- package/dist/ai/agents/orchestrator.js +1 -142
- package/dist/ai/agents/simple-agent.js +4 -80
- package/dist/ai/client.js +1 -162
- package/dist/ai/index.js +1 -27
- package/dist/ai/prompts/code-generation.js +13 -55
- package/dist/ai/prompts/index.js +1 -12
- package/dist/ai/prompts/spec-creation.js +20 -61
- package/dist/ai/providers.js +1 -40
- package/dist/formatters/index.js +1 -18
- package/dist/formatters/json.js +1 -71
- package/dist/formatters/sarif.js +1 -163
- package/dist/formatters/text.js +2 -208
- package/dist/index.js +1 -81
- package/dist/services/agent-guide/adapters/claude-code.js +3 -144
- package/dist/services/agent-guide/adapters/cursor-cli.js +3 -135
- package/dist/services/agent-guide/adapters/generic-mcp.js +3 -159
- package/dist/services/agent-guide/adapters/index.js +1 -30
- package/dist/services/agent-guide/agent-guide-service.js +1 -148
- package/dist/services/agent-guide/index.js +1 -5
- package/dist/services/build.js +1 -140
- package/dist/services/ci-check/ci-check-service.js +1 -393
- package/dist/services/ci-check/index.js +1 -2
- package/dist/services/ci-check/types.js +1 -28
- package/dist/services/clean.js +1 -71
- package/dist/services/config.js +1 -76
- package/dist/services/deps.js +1 -62
- package/dist/services/diff.js +1 -33
- package/dist/services/doctor/checks/ai.js +2 -118
- package/dist/services/doctor/checks/cli.js +1 -146
- package/dist/services/doctor/checks/config.js +1 -170
- package/dist/services/doctor/checks/deps.js +1 -180
- package/dist/services/doctor/checks/index.js +1 -6
- package/dist/services/doctor/checks/mcp.js +1 -144
- package/dist/services/doctor/checks/workspace.js +1 -243
- package/dist/services/doctor/doctor-service.js +2 -115
- package/dist/services/doctor/index.js +1 -2
- package/dist/services/doctor/types.js +1 -26
- package/dist/services/implementation/discovery.js +2 -143
- package/dist/services/implementation/index.js +1 -2
- package/dist/services/implementation/resolver.js +1 -223
- package/dist/services/index.js +1 -53
- package/dist/services/integrity-diagram.js +6 -274
- package/dist/services/integrity.js +1 -272
- package/dist/services/list.js +1 -35
- package/dist/services/openapi/export-service.js +2 -51
- package/dist/services/openapi/import-service.js +1 -75
- package/dist/services/openapi/index.js +1 -4
- package/dist/services/openapi/sync-service.js +1 -121
- package/dist/services/openapi/validate-service.js +1 -130
- package/dist/services/regenerator.js +1 -23
- package/dist/services/registry.js +1 -73
- package/dist/services/setup/config-generators.js +26 -113
- package/dist/services/setup/file-merger.js +2 -60
- package/dist/services/setup/index.js +1 -4
- package/dist/services/setup/setup-service.js +1 -95
- package/dist/services/setup/targets/agents-md.js +1 -46
- package/dist/services/setup/targets/cli-config.js +1 -59
- package/dist/services/setup/targets/cursor-rules.js +1 -47
- package/dist/services/setup/targets/mcp-claude.js +1 -59
- package/dist/services/setup/targets/mcp-cursor.js +1 -58
- package/dist/services/setup/targets/vscode-settings.js +1 -62
- package/dist/services/setup/types.js +1 -26
- package/dist/services/sync.js +1 -62
- package/dist/services/test.js +1 -30
- package/dist/services/validate-implementation.js +1 -69
- package/dist/services/validate.js +1 -47
- package/dist/services/verification-cache/adapters/filesystem.js +1 -121
- package/dist/services/verification-cache/adapters/in-memory.js +1 -45
- package/dist/services/verification-cache/adapters/index.js +1 -3
- package/dist/services/verification-cache/adapters/workspace-state.js +1 -90
- package/dist/services/verification-cache/cache-service.js +1 -255
- package/dist/services/verification-cache/index.js +1 -6
- package/dist/services/verification-cache/types.js +1 -15
- package/dist/services/verify/ai-verifier.js +9 -336
- package/dist/services/verify/behavior-verifier.js +1 -185
- package/dist/services/verify/index.js +1 -4
- package/dist/services/verify/structure-verifier.js +2 -195
- package/dist/services/verify/verify-service.js +3 -203
- package/dist/services/watch.js +1 -31
- package/dist/services/workspace-info.js +2 -102
- package/dist/templates/app-config.template.js +28 -101
- package/dist/templates/data-view.template.js +27 -42
- package/dist/templates/event.template.js +14 -29
- package/dist/templates/experiment.template.js +51 -77
- package/dist/templates/handler.template.js +17 -53
- package/dist/templates/index.js +1 -36
- package/dist/templates/integration.template.js +50 -134
- package/dist/templates/knowledge.template.js +21 -62
- package/dist/templates/migration.template.js +26 -50
- package/dist/templates/operation.template.js +28 -44
- package/dist/templates/presentation.template.js +20 -46
- package/dist/templates/telemetry.template.js +53 -74
- package/dist/templates/workflow-runner.template.js +6 -12
- package/dist/templates/workflow.template.js +24 -51
- package/package.json +10 -15
- package/dist/adapters/ai.d.ts +0 -11
- package/dist/adapters/factory.d.ts +0 -28
- package/dist/adapters/fs.d.ts +0 -10
- package/dist/adapters/git.d.ts +0 -10
- package/dist/adapters/logger.d.ts +0 -17
- package/dist/adapters/watcher.d.ts +0 -10
- package/dist/adapters/workspace.d.ts +0 -93
- package/dist/ai/agents/claude-code-agent.d.ts +0 -21
- package/dist/ai/agents/cursor-agent.d.ts +0 -67
- package/dist/ai/agents/openai-codex-agent.d.ts +0 -21
- package/dist/ai/agents/orchestrator.d.ts +0 -49
- package/dist/ai/agents/simple-agent.d.ts +0 -16
- package/dist/ai/agents/types.d.ts +0 -35
- package/dist/ai/client.d.ts +0 -82
- package/dist/ai/index.d.ts +0 -16
- package/dist/ai/prompts/code-generation.d.ts +0 -25
- package/dist/ai/prompts/index.d.ts +0 -9
- package/dist/ai/prompts/spec-creation.d.ts +0 -28
- package/dist/ai/providers.d.ts +0 -28
- package/dist/formatters/index.d.ts +0 -10
- package/dist/formatters/json.d.ts +0 -88
- package/dist/formatters/sarif.d.ts +0 -100
- package/dist/formatters/text.d.ts +0 -34
- package/dist/index.d.ts +0 -66
- package/dist/libs/ai-providers/dist/factory.js +0 -154
- package/dist/libs/ai-providers/dist/index.js +0 -4
- package/dist/libs/ai-providers/dist/legacy.js +0 -72
- package/dist/libs/ai-providers/dist/models.js +0 -287
- package/dist/libs/ai-providers/dist/validation.js +0 -1
- package/dist/libs/contracts/dist/capabilities/openbanking.js +0 -88
- package/dist/libs/contracts/dist/client/index.js +0 -5
- package/dist/libs/contracts/dist/client/react/feature-render.js +0 -2
- package/dist/libs/contracts/dist/client/react/form-render.js +0 -4
- package/dist/libs/contracts/dist/client/react/index.js +0 -4
- package/dist/libs/contracts/dist/contract-registry/index.js +0 -1
- package/dist/libs/contracts/dist/contract-registry/schemas.js +0 -60
- package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/index.js +0 -29
- package/dist/libs/contracts/dist/docs/presentations.js +0 -71
- package/dist/libs/contracts/dist/docs/registry.js +0 -44
- package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +0 -80
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +0 -57
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +0 -357
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +0 -37
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +0 -20
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +0 -48
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +0 -79
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +0 -84
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +0 -45
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +0 -67
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +0 -40
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +0 -69
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +0 -47
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +0 -62
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +0 -155
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +0 -20
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +0 -101
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +0 -20
- package/dist/libs/contracts/dist/events.js +0 -8
- package/dist/libs/contracts/dist/experiments/evaluator.js +0 -1
- package/dist/libs/contracts/dist/index.js +0 -72
- package/dist/libs/contracts/dist/install.js +0 -2
- package/dist/libs/contracts/dist/integrations/contracts.js +0 -377
- package/dist/libs/contracts/dist/integrations/index.js +0 -18
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +0 -228
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +0 -159
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +0 -3
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +0 -210
- package/dist/libs/contracts/dist/integrations/openbanking/models.js +0 -242
- package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +0 -13
- package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +0 -52
- package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +0 -75
- package/dist/libs/contracts/dist/integrations/providers/gmail.js +0 -87
- package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +0 -66
- package/dist/libs/contracts/dist/integrations/providers/index.js +0 -11
- package/dist/libs/contracts/dist/integrations/providers/mistral.js +0 -68
- package/dist/libs/contracts/dist/integrations/providers/postmark.js +0 -68
- package/dist/libs/contracts/dist/integrations/providers/powens.js +0 -116
- package/dist/libs/contracts/dist/integrations/providers/qdrant.js +0 -73
- package/dist/libs/contracts/dist/integrations/providers/registry.js +0 -10
- package/dist/libs/contracts/dist/integrations/providers/stripe.js +0 -83
- package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +0 -61
- package/dist/libs/contracts/dist/jsonschema.js +0 -24
- package/dist/libs/contracts/dist/knowledge/contracts.js +0 -306
- package/dist/libs/contracts/dist/knowledge/index.js +0 -7
- package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +0 -34
- package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +0 -34
- package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +0 -38
- package/dist/libs/contracts/dist/knowledge/spaces/index.js +0 -6
- package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +0 -34
- package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +0 -37
- package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +0 -34
- package/dist/libs/contracts/dist/llm/exporters.js +0 -352
- package/dist/libs/contracts/dist/llm/index.js +0 -2
- package/dist/libs/contracts/dist/llm/prompts.js +0 -211
- package/dist/libs/contracts/dist/onboarding-base.js +0 -196
- package/dist/libs/contracts/dist/openapi.js +0 -75
- package/dist/libs/contracts/dist/ownership.js +0 -21
- package/dist/libs/contracts/dist/presentations.js +0 -1
- package/dist/libs/contracts/dist/presentations.v2.js +0 -11
- package/dist/libs/contracts/dist/prompt.js +0 -1
- package/dist/libs/contracts/dist/promptRegistry.js +0 -1
- package/dist/libs/contracts/dist/regenerator/index.js +0 -2
- package/dist/libs/contracts/dist/regenerator/service.js +0 -92
- package/dist/libs/contracts/dist/regenerator/utils.js +0 -51
- package/dist/libs/contracts/dist/registry.js +0 -208
- package/dist/libs/contracts/dist/resources.js +0 -1
- package/dist/libs/contracts/dist/schema/dist/EnumType.js +0 -2
- package/dist/libs/contracts/dist/schema/dist/FieldType.js +0 -49
- package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +0 -236
- package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +0 -34
- package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +0 -1
- package/dist/libs/contracts/dist/schema/dist/entity/index.js +0 -2
- package/dist/libs/contracts/dist/schema/dist/entity/types.js +0 -1
- package/dist/libs/contracts/dist/schema/dist/index.js +0 -6
- package/dist/libs/contracts/dist/server/graphql-pothos.js +0 -6
- package/dist/libs/contracts/dist/server/index.js +0 -8
- package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +0 -4
- package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +0 -2
- package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +0 -1
- package/dist/libs/contracts/dist/server/mcp/registerResources.js +0 -2
- package/dist/libs/contracts/dist/server/mcp/registerTools.js +0 -1
- package/dist/libs/contracts/dist/server/provider-mcp.js +0 -1
- package/dist/libs/contracts/dist/server/rest-elysia.js +0 -1
- package/dist/libs/contracts/dist/server/rest-express.js +0 -1
- package/dist/libs/contracts/dist/server/rest-generic.js +0 -1
- package/dist/libs/contracts/dist/server/rest-next-app.js +0 -1
- package/dist/libs/contracts/dist/server/rest-next-pages.js +0 -1
- package/dist/libs/contracts/dist/spec.js +0 -35
- package/dist/libs/contracts/dist/telemetry/index.js +0 -1
- package/dist/libs/contracts/dist/telemetry/tracker.js +0 -1
- package/dist/libs/contracts/dist/tests/index.js +0 -1
- package/dist/libs/contracts/dist/tests/runner.js +0 -150
- package/dist/libs/contracts/dist/workflow/index.js +0 -1
- package/dist/libs/contracts/dist/workflow/runner.js +0 -1
- package/dist/libs/contracts-transformers/dist/common/utils.js +0 -47
- package/dist/libs/contracts-transformers/dist/openapi/exporter.js +0 -1
- package/dist/libs/contracts-transformers/dist/openapi/importer.js +0 -255
- package/dist/libs/contracts-transformers/dist/openapi/index.js +0 -4
- package/dist/libs/contracts-transformers/dist/openapi/parser.js +0 -231
- package/dist/libs/contracts-transformers/dist/openapi/schema-converter.js +0 -201
- package/dist/modules/contractspec-workspace/dist/ai/code-generation.js +0 -137
- package/dist/modules/contractspec-workspace/dist/ai/spec-creation.js +0 -101
- package/dist/modules/contractspec-workspace/dist/analysis/deps/graph.js +0 -84
- package/dist/modules/contractspec-workspace/dist/analysis/deps/parse-imports.js +0 -30
- package/dist/modules/contractspec-workspace/dist/analysis/diff/semantic.js +0 -96
- package/dist/modules/contractspec-workspace/dist/analysis/feature-scan.js +0 -151
- package/dist/modules/contractspec-workspace/dist/analysis/spec-scan.js +0 -344
- package/dist/modules/contractspec-workspace/dist/analysis/validate/spec-structure.js +0 -122
- package/dist/modules/contractspec-workspace/dist/templates/app-config.js +0 -105
- package/dist/modules/contractspec-workspace/dist/templates/data-view.js +0 -68
- package/dist/modules/contractspec-workspace/dist/templates/event.js +0 -38
- package/dist/modules/contractspec-workspace/dist/templates/experiment.js +0 -87
- package/dist/modules/contractspec-workspace/dist/templates/handler.js +0 -95
- package/dist/modules/contractspec-workspace/dist/templates/integration-utils.js +0 -104
- package/dist/modules/contractspec-workspace/dist/templates/integration.js +0 -62
- package/dist/modules/contractspec-workspace/dist/templates/knowledge.js +0 -68
- package/dist/modules/contractspec-workspace/dist/templates/migration.js +0 -60
- package/dist/modules/contractspec-workspace/dist/templates/operation.js +0 -100
- package/dist/modules/contractspec-workspace/dist/templates/presentation.js +0 -78
- package/dist/modules/contractspec-workspace/dist/templates/telemetry.js +0 -89
- package/dist/modules/contractspec-workspace/dist/templates/utils.js +0 -38
- package/dist/modules/contractspec-workspace/dist/templates/workflow-runner.js +0 -48
- package/dist/modules/contractspec-workspace/dist/templates/workflow.js +0 -67
- package/dist/modules/contractspec-workspace/dist/types/generation-types.js +0 -20
- package/dist/ports/ai.d.ts +0 -58
- package/dist/ports/fs.d.ts +0 -80
- package/dist/ports/git.d.ts +0 -32
- package/dist/ports/logger.d.ts +0 -87
- package/dist/ports/watcher.d.ts +0 -51
- package/dist/services/agent-guide/adapters/claude-code.d.ts +0 -34
- package/dist/services/agent-guide/adapters/cursor-cli.d.ts +0 -38
- package/dist/services/agent-guide/adapters/generic-mcp.d.ts +0 -52
- package/dist/services/agent-guide/adapters/index.d.ts +0 -22
- package/dist/services/agent-guide/agent-guide-service.d.ts +0 -55
- package/dist/services/agent-guide/types.d.ts +0 -57
- package/dist/services/build.d.ts +0 -58
- package/dist/services/ci-check/ci-check-service.d.ts +0 -15
- package/dist/services/ci-check/types.d.ts +0 -142
- package/dist/services/clean.d.ts +0 -40
- package/dist/services/config.d.ts +0 -25
- package/dist/services/deps.d.ts +0 -52
- package/dist/services/diff.d.ts +0 -33
- package/dist/services/doctor/doctor-service.d.ts +0 -23
- package/dist/services/doctor/types.d.ts +0 -117
- package/dist/services/implementation/discovery.d.ts +0 -29
- package/dist/services/implementation/resolver.d.ts +0 -43
- package/dist/services/implementation/types.d.ts +0 -78
- package/dist/services/integrity-diagram.d.ts +0 -35
- package/dist/services/integrity.d.ts +0 -133
- package/dist/services/list.d.ts +0 -30
- package/dist/services/openapi/export-service.d.ts +0 -52
- package/dist/services/openapi/import-service.d.ts +0 -15
- package/dist/services/openapi/sync-service.d.ts +0 -18
- package/dist/services/openapi/types.d.ts +0 -184
- package/dist/services/openapi/validate-service.d.ts +0 -15
- package/dist/services/regenerator.d.ts +0 -17
- package/dist/services/registry.d.ts +0 -52
- package/dist/services/setup/config-generators.d.ts +0 -41
- package/dist/services/setup/file-merger.d.ts +0 -26
- package/dist/services/setup/setup-service.d.ts +0 -11
- package/dist/services/setup/types.d.ts +0 -84
- package/dist/services/sync.d.ts +0 -40
- package/dist/services/test.d.ts +0 -14
- package/dist/services/validate-implementation.d.ts +0 -31
- package/dist/services/validate.d.ts +0 -40
- package/dist/services/verification-cache/adapters/filesystem.d.ts +0 -45
- package/dist/services/verification-cache/adapters/in-memory.d.ts +0 -26
- package/dist/services/verification-cache/adapters/workspace-state.d.ts +0 -48
- package/dist/services/verification-cache/cache-service.d.ts +0 -69
- package/dist/services/verification-cache/types.d.ts +0 -123
- package/dist/services/verify/ai-verifier.d.ts +0 -24
- package/dist/services/verify/behavior-verifier.d.ts +0 -11
- package/dist/services/verify/structure-verifier.d.ts +0 -11
- package/dist/services/verify/types.d.ts +0 -136
- package/dist/services/verify/verify-service.d.ts +0 -59
- package/dist/services/watch.d.ts +0 -24
- package/dist/services/workspace-info.d.ts +0 -61
- package/dist/templates/app-config.template.d.ts +0 -6
- package/dist/templates/data-view.template.d.ts +0 -6
- package/dist/templates/event.template.d.ts +0 -10
- package/dist/templates/experiment.template.d.ts +0 -6
- package/dist/templates/handler.template.d.ts +0 -15
- package/dist/templates/index.d.ts +0 -20
- package/dist/templates/integration.template.d.ts +0 -6
- package/dist/templates/knowledge.template.d.ts +0 -6
- package/dist/templates/migration.template.d.ts +0 -6
- package/dist/templates/operation.template.d.ts +0 -10
- package/dist/templates/presentation.template.d.ts +0 -10
- package/dist/templates/telemetry.template.d.ts +0 -6
- package/dist/templates/workflow-runner.template.d.ts +0 -15
- package/dist/templates/workflow.template.d.ts +0 -6
- package/dist/types/config.d.ts +0 -33
- package/dist/types.d.ts +0 -323
|
@@ -1,69 +1,14 @@
|
|
|
1
|
-
import
|
|
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: `
|
|
1
|
+
import{anthropic as e}from"../../node_modules/@ai-sdk/anthropic/dist/index.js";import{generateText as t}from"ai";var n=class{name=`claude-code`;apiKey;constructor(){this.apiKey=process.env.ANTHROPIC_API_KEY}canHandle(e){return!!this.apiKey}async generate(n){if(!this.apiKey)return{success:!1,errors:[`ANTHROPIC_API_KEY not set. Claude Code agent requires API access.`]};try{let r=e(`claude-3-7-sonnet-20250219`),i=this.buildSystemPrompt(n),a=await t({model:r,prompt:this.buildUserPrompt(n),system:i,temperature:.2});return{success:!0,code:this.extractCode(a.text),metadata:{model:`claude-3-7-sonnet`,agentMode:`claude-code`,usage:a.usage}}}catch(e){return{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}async validate(n){if(!this.apiKey)return{success:!1,errors:[`ANTHROPIC_API_KEY not set`]};try{let r=await t({model:e(`claude-3-7-sonnet-20250219`),prompt:`
|
|
57
2
|
You are an expert code reviewer. Carefully analyze this implementation against its specification.
|
|
58
3
|
|
|
59
4
|
SPECIFICATION:
|
|
60
5
|
\`\`\`typescript
|
|
61
|
-
${
|
|
6
|
+
${n.specCode}
|
|
62
7
|
\`\`\`
|
|
63
8
|
|
|
64
9
|
IMPLEMENTATION:
|
|
65
10
|
\`\`\`typescript
|
|
66
|
-
${
|
|
11
|
+
${n.existingCode||`// No implementation provided`}
|
|
67
12
|
\`\`\`
|
|
68
13
|
|
|
69
14
|
Provide a structured validation report:
|
|
@@ -82,31 +27,7 @@ Provide a structured validation report:
|
|
|
82
27
|
- Are there any missing edge cases?
|
|
83
28
|
|
|
84
29
|
Be thorough and precise. Use a critical but constructive tone.
|
|
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.
|
|
30
|
+
`,system:`You are a senior software engineer performing a critical code review.`,temperature:.3}),i=this.detectIssues(r.text);return{success:!i,code:r.text,errors:i?this.extractErrors(r.text):[],warnings:this.extractWarnings(r.text),suggestions:this.extractSuggestions(r.text),metadata:{agentMode:`claude-code`,validationType:`comprehensive`}}}catch(e){return{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}buildSystemPrompt(e){let t=`You are an expert TypeScript developer specializing in contract-driven development.
|
|
110
31
|
|
|
111
32
|
Your code is:
|
|
112
33
|
- Type-safe with comprehensive TypeScript types
|
|
@@ -115,67 +36,9 @@ Your code is:
|
|
|
115
36
|
- Following SOLID principles and best practices
|
|
116
37
|
- Modular and testable
|
|
117
38
|
|
|
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
|
-
};
|
|
39
|
+
Generate clean, idiomatic TypeScript code that exactly matches the specification.`;return e.type===`test`?t+`
|
|
179
40
|
|
|
180
|
-
|
|
181
|
-
|
|
41
|
+
You are also an expert in testing. Write comprehensive tests using Vitest.`:t}buildUserPrompt(e){let t={generate:`Generate a complete, production-ready implementation for this specification:\n\n${e.specCode}\n\nProvide ONLY the TypeScript code, no explanations.`,test:`Generate comprehensive tests for this code:\n\nSpec:\n${e.specCode}\n\nImplementation:\n${e.existingCode}\n\nProvide complete Vitest test suite.`,refactor:`Refactor this code while preserving functionality:\n\n${e.existingCode}\n\nSpec:\n${e.specCode}`,validate:`Validate this implementation:\n\nSpec:\n${e.specCode}\n\nCode:\n${e.existingCode}`};return t[e.type]||t.generate}extractCode(e){let t=e.match(/```(?:typescript|ts|tsx)?\n([\s\S]*?)\n```/);return t&&t[1]?t[1]:e}detectIssues(e){let t=[`missing`,`incorrect`,`bug`,`error`,`violation`,`does not`,`fails to`,`not implemented`,`critical`],n=e.toLowerCase();return t.some(e=>n.includes(e))}extractErrors(e){let t=[],n=e.split(`
|
|
42
|
+
`);for(let e of n){let n=e.toLowerCase();(n.includes(`error`)||n.includes(`bug`)||n.includes(`incorrect`)||n.includes(`missing`))&&t.push(e.trim())}return t.length>0?t:[`Code review identified issues`]}extractWarnings(e){let t=[],n=e.split(`
|
|
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};
|
|
@@ -1,188 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
1
|
+
import{join as e}from"path";import{existsSync as t}from"fs";import{exec as n,spawn as r}from"child_process";import{mkdir as i,readFile as a,rm as o,writeFile as s}from"fs/promises";import{homedir as c,tmpdir as l}from"os";import{promisify as u}from"util";u(n);var d=class{name=`cursor`;cursorPath=null;isWindsurf=!1;composerPort;constructor(){this.composerPort=process.env.CURSOR_COMPOSER_PORT||`3000`,this.detectEnvironment()}canHandle(e){return this.isCursorAvailable()}async generate(t){try{let n=e(l(),`cursor-agent-${Date.now()}`);await i(n,{recursive:!0});let r=await this.executeWithBestMethod(t,n);return await this.cleanupWorkDir(n),r}catch(e){return{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}async validate(t){try{let n=e(l(),`cursor-validate-${Date.now()}`);await i(n,{recursive:!0}),await this.setupValidationWorkspace(t,n);let r=await this.executeWithBestMethod({...t,type:`validate`},n);return await this.cleanupWorkDir(n),r}catch(e){return{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}detectEnvironment(){this.isWindsurf=!!(process.env.WINDSURF_SESSION||process.env.CURSOR_USER_DATA||process.env.VSCODE_CWD?.includes(`Cursor`)||process.env.VSCODE_CWD?.includes(`Windsurf`));let n=[`/usr/local/bin/cursor`,`/Applications/Cursor.app/Contents/MacOS/Cursor`,`/Applications/Windsurf.app/Contents/MacOS/Windsurf`,e(c(),`.cursor`,`cursor`),e(c(),`AppData`,`Local`,`Programs`,`cursor`,`Cursor.exe`),e(c(),`AppData`,`Local`,`Programs`,`windsurf`,`Windsurf.exe`),`cursor`,`windsurf`];for(let e of n)if(e.includes(`cursor`)||e.includes(`Cursor`)||e.includes(`windsurf`)||e.includes(`Windsurf`))try{if(t(e)){this.cursorPath=e;break}}catch{continue}}async executeWithBestMethod(e,t){let n=[{name:`cursor-cli`,fn:()=>this.useCursorCLI(e,t)},{name:`file-based`,fn:()=>this.useFileBasedApproach(e,t)}];for(let e of n)try{let t=await e.fn();if(t.success)return t}catch{continue}return{success:!1,warnings:[`Cursor agent could not connect to IDE.`,`Ensure Cursor/Windsurf is running with API enabled.`,`Falling back to simple agent mode is recommended.`],errors:[`All Cursor integration methods failed`],metadata:{agentMode:`cursor`,status:`unavailable`,suggestion:`Use --agent-mode claude-code or --agent-mode simple`}}}async useCursorCLI(n,i){if(!this.cursorPath)throw Error(`Cursor executable not found`);let o=e(i,`spec.ts`),c=e(i,`output.ts`),l=e(i,`INSTRUCTIONS.md`);return await s(o,n.specCode),await s(l,this.buildDetailedPrompt(n)),n.existingCode&&await s(e(i,`existing.ts`),n.existingCode),new Promise((e,n)=>{let o=[`--wait`,`--new-window`,i],s=r(this.cursorPath,o,{cwd:i,stdio:`pipe`,detached:!1}),l=``,u=``;s.stdout?.on(`data`,e=>{l+=e.toString()}),s.stderr?.on(`data`,e=>{u+=e.toString()}),s.on(`error`,e=>{n(e)}),s.on(`close`,async r=>{if(t(c))try{e({success:!0,code:await a(c,`utf-8`),metadata:{agentMode:`cursor`,method:`cli`,exitCode:r}})}catch{n(Error(`Failed to read generated output`))}else n(Error(`Cursor CLI exited with code ${r}. No output generated.`))}),setTimeout(()=>{s.kill(),n(Error(`Cursor CLI timeout`))},6e4)})}async useFileBasedApproach(t,n){let r=e(n,`SPECIFICATION.ts`),i=e(n,`INSTRUCTIONS.md`),a=e(n,`template.ts`);return await s(r,t.specCode),await s(i,this.buildDetailedPrompt(t)),await s(a,this.generateTemplate(t)),await s(e(n,`README.md`),`# Cursor Agent Workspace
|
|
186
2
|
|
|
187
3
|
This workspace was prepared for Cursor AI code generation.
|
|
188
4
|
|
|
@@ -197,53 +13,8 @@ This workspace was prepared for Cursor AI code generation.
|
|
|
197
13
|
3. Use Cursor AI to generate code based on the spec
|
|
198
14
|
4. Save the result as output.ts
|
|
199
15
|
|
|
200
|
-
Workspace path: ${
|
|
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
|
|
16
|
+
Workspace path: ${n}
|
|
17
|
+
`),{success:!1,warnings:[`Cursor agent created workspace but cannot auto-execute.`,`Workspace prepared at: ${n}`,`Open this folder in Cursor IDE to complete code generation.`],code:this.generateTemplate(t),metadata:{agentMode:`cursor`,method:`file-based`,workDir:n}}}async setupValidationWorkspace(t,n){await s(e(n,`specification.ts`),t.specCode),await s(e(n,`implementation.ts`),t.existingCode||`// No implementation`),await s(e(n,`VALIDATION_INSTRUCTIONS.md`),this.buildValidationPrompt(t))}async prepareFilesForAPI(e,t){let n=[{path:`spec.ts`,content:e.specCode}];return e.existingCode&&n.push({path:`existing.ts`,content:e.existingCode}),n}buildDetailedPrompt(e){let t=`# AI Code Generation Task - Cursor Agent\n\n**Task Type:** ${e.type}\n**Generated:** ${new Date().toISOString()}\n\n`,n=`## Specification\n\n\`\`\`typescript\n${e.specCode}\n\`\`\`\n\n`,r={generate:`## Task: Generate Implementation
|
|
247
18
|
|
|
248
19
|
### Requirements:
|
|
249
20
|
1. **Type Safety**: Use strict TypeScript with comprehensive types
|
|
@@ -263,12 +34,11 @@ Workspace path: ${workDir}
|
|
|
263
34
|
|
|
264
35
|
### Output Format:
|
|
265
36
|
Provide complete, executable TypeScript code that fully implements the specification.
|
|
266
|
-
Include all necessary imports and type definitions.`,
|
|
267
|
-
validate: `## Task: Validate Implementation
|
|
37
|
+
Include all necessary imports and type definitions.`,validate:`## Task: Validate Implementation
|
|
268
38
|
|
|
269
39
|
### Current Implementation:
|
|
270
40
|
\`\`\`typescript
|
|
271
|
-
${
|
|
41
|
+
${e.existingCode||`// No implementation provided`}
|
|
272
42
|
\`\`\`
|
|
273
43
|
|
|
274
44
|
### Validation Criteria:
|
|
@@ -292,12 +62,11 @@ Provide a detailed validation report with:
|
|
|
292
62
|
- **Status**: Pass/Fail
|
|
293
63
|
- **Issues Found**: List all problems
|
|
294
64
|
- **Recommendations**: Specific improvements needed
|
|
295
|
-
- **Code Quality Score**: Rate the implementation`,
|
|
296
|
-
test: `## Task: Generate Tests
|
|
65
|
+
- **Code Quality Score**: Rate the implementation`,test:`## Task: Generate Tests
|
|
297
66
|
|
|
298
67
|
### Implementation to Test:
|
|
299
68
|
\`\`\`typescript
|
|
300
|
-
${
|
|
69
|
+
${e.existingCode||``}
|
|
301
70
|
\`\`\`
|
|
302
71
|
|
|
303
72
|
### Test Requirements:
|
|
@@ -315,12 +84,11 @@ ${task.existingCode || ""}
|
|
|
315
84
|
- Performance tests (if applicable)
|
|
316
85
|
|
|
317
86
|
### Output Format:
|
|
318
|
-
Complete Vitest test file with comprehensive test coverage.`,
|
|
319
|
-
refactor: `## Task: Refactor Code
|
|
87
|
+
Complete Vitest test file with comprehensive test coverage.`,refactor:`## Task: Refactor Code
|
|
320
88
|
|
|
321
89
|
### Current Code:
|
|
322
90
|
\`\`\`typescript
|
|
323
|
-
${
|
|
91
|
+
${e.existingCode||``}
|
|
324
92
|
\`\`\`
|
|
325
93
|
|
|
326
94
|
### Refactoring Goals:
|
|
@@ -339,24 +107,16 @@ ${task.existingCode || ""}
|
|
|
339
107
|
- Enhance error messages
|
|
340
108
|
|
|
341
109
|
### Output Format:
|
|
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
|
|
110
|
+
Refactored code that maintains functionality while improving quality.`};return t+n+(r[e.type]||r.generate)}buildValidationPrompt(e){return`# Implementation Validation Report
|
|
351
111
|
|
|
352
112
|
## Specification
|
|
353
113
|
\`\`\`typescript
|
|
354
|
-
${
|
|
114
|
+
${e.specCode}
|
|
355
115
|
\`\`\`
|
|
356
116
|
|
|
357
117
|
## Implementation
|
|
358
118
|
\`\`\`typescript
|
|
359
|
-
${
|
|
119
|
+
${e.existingCode||`// No implementation`}
|
|
360
120
|
\`\`\`
|
|
361
121
|
|
|
362
122
|
## Validation Checklist
|
|
@@ -392,15 +152,11 @@ ${task.existingCode || "// No implementation"}
|
|
|
392
152
|
## Instructions
|
|
393
153
|
Review the implementation against the specification and complete the checklist.
|
|
394
154
|
Provide detailed feedback for each failed item.
|
|
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
|
|
155
|
+
Suggest specific improvements with code examples where applicable.`}generateTemplate(e){return`// Auto-generated template for ${e.type} task
|
|
402
156
|
// Specification:
|
|
403
|
-
${
|
|
157
|
+
${e.specCode.split(`
|
|
158
|
+
`).map(e=>`// ${e}`).join(`
|
|
159
|
+
`)}
|
|
404
160
|
|
|
405
161
|
// TODO: Implement according to specification
|
|
406
162
|
// Use Cursor AI to complete this implementation
|
|
@@ -409,29 +165,4 @@ export function implementation() {
|
|
|
409
165
|
// Implementation goes here
|
|
410
166
|
throw new Error('Not implemented');
|
|
411
167
|
}
|
|
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 };
|
|
168
|
+
`}async cleanupWorkDir(e){try{await o(e,{recursive:!0,force:!0})}catch{}}isCursorAvailable(){return this.isWindsurf||this.cursorPath!==null||this.hasComposerAPI()}hasComposerAPI(){return!!(process.env.CURSOR_COMPOSER_PORT||process.env.CURSOR_API_ENABLED||this.isWindsurf)}};export{d as CursorAgent};
|
package/dist/ai/agents/index.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import {
|
|
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";
|
|
1
|
+
import{SimpleAgent as e}from"./simple-agent.js";import{CursorAgent as t}from"./cursor-agent.js";import{ClaudeCodeAgent as n}from"./claude-code-agent.js";import{OpenAICodexAgent as r}from"./openai-codex-agent.js";import{AgentOrchestrator as i}from"./orchestrator.js";
|