task-o-matic-core 0.1.0
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/README.md +646 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/lib/ai-service/ai-operations.d.ts +45 -0
- package/dist/lib/ai-service/ai-operations.d.ts.map +1 -0
- package/dist/lib/ai-service/ai-operations.js +60 -0
- package/dist/lib/ai-service/base-operations.d.ts +43 -0
- package/dist/lib/ai-service/base-operations.d.ts.map +1 -0
- package/dist/lib/ai-service/base-operations.js +119 -0
- package/dist/lib/ai-service/documentation-operations.d.ts +18 -0
- package/dist/lib/ai-service/documentation-operations.d.ts.map +1 -0
- package/dist/lib/ai-service/documentation-operations.js +308 -0
- package/dist/lib/ai-service/filesystem-tools.d.ts +69 -0
- package/dist/lib/ai-service/filesystem-tools.d.ts.map +1 -0
- package/dist/lib/ai-service/filesystem-tools.js +70 -0
- package/dist/lib/ai-service/json-parser.d.ts +34 -0
- package/dist/lib/ai-service/json-parser.d.ts.map +1 -0
- package/dist/lib/ai-service/json-parser.js +177 -0
- package/dist/lib/ai-service/mcp-client.d.ts +9 -0
- package/dist/lib/ai-service/mcp-client.d.ts.map +1 -0
- package/dist/lib/ai-service/mcp-client.js +48 -0
- package/dist/lib/ai-service/model-provider.d.ts +12 -0
- package/dist/lib/ai-service/model-provider.d.ts.map +1 -0
- package/dist/lib/ai-service/model-provider.js +146 -0
- package/dist/lib/ai-service/prd-operations.d.ts +25 -0
- package/dist/lib/ai-service/prd-operations.d.ts.map +1 -0
- package/dist/lib/ai-service/prd-operations.js +592 -0
- package/dist/lib/ai-service/research-tools.d.ts +4 -0
- package/dist/lib/ai-service/research-tools.d.ts.map +1 -0
- package/dist/lib/ai-service/research-tools.js +8 -0
- package/dist/lib/ai-service/retry-handler.d.ts +8 -0
- package/dist/lib/ai-service/retry-handler.d.ts.map +1 -0
- package/dist/lib/ai-service/retry-handler.js +63 -0
- package/dist/lib/ai-service/task-operations.d.ts +13 -0
- package/dist/lib/ai-service/task-operations.d.ts.map +1 -0
- package/dist/lib/ai-service/task-operations.js +220 -0
- package/dist/lib/benchmark/registry.d.ts +11 -0
- package/dist/lib/benchmark/registry.d.ts.map +1 -0
- package/dist/lib/benchmark/registry.js +212 -0
- package/dist/lib/benchmark/runner.d.ts +6 -0
- package/dist/lib/benchmark/runner.d.ts.map +1 -0
- package/dist/lib/benchmark/runner.js +150 -0
- package/dist/lib/benchmark/storage.d.ts +13 -0
- package/dist/lib/benchmark/storage.d.ts.map +1 -0
- package/dist/lib/benchmark/storage.js +100 -0
- package/dist/lib/benchmark/types.d.ts +104 -0
- package/dist/lib/benchmark/types.d.ts.map +1 -0
- package/dist/lib/benchmark/types.js +2 -0
- package/dist/lib/better-t-stack-cli.d.ts +50 -0
- package/dist/lib/better-t-stack-cli.d.ts.map +1 -0
- package/dist/lib/better-t-stack-cli.js +428 -0
- package/dist/lib/bootstrap/cli-bootstrap.d.ts +14 -0
- package/dist/lib/bootstrap/cli-bootstrap.d.ts.map +1 -0
- package/dist/lib/bootstrap/cli-bootstrap.js +322 -0
- package/dist/lib/bootstrap/index.d.ts +3 -0
- package/dist/lib/bootstrap/index.d.ts.map +1 -0
- package/dist/lib/bootstrap/index.js +18 -0
- package/dist/lib/bootstrap/medusa-bootstrap.d.ts +14 -0
- package/dist/lib/bootstrap/medusa-bootstrap.d.ts.map +1 -0
- package/dist/lib/bootstrap/medusa-bootstrap.js +215 -0
- package/dist/lib/config-validation.d.ts +215 -0
- package/dist/lib/config-validation.d.ts.map +1 -0
- package/dist/lib/config-validation.js +254 -0
- package/dist/lib/config.d.ts +55 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +351 -0
- package/dist/lib/context-builder.d.ts +66 -0
- package/dist/lib/context-builder.d.ts.map +1 -0
- package/dist/lib/context-builder.js +322 -0
- package/dist/lib/executors/claude-code-executor.d.ts +9 -0
- package/dist/lib/executors/claude-code-executor.d.ts.map +1 -0
- package/dist/lib/executors/claude-code-executor.js +69 -0
- package/dist/lib/executors/codex-executor.d.ts +9 -0
- package/dist/lib/executors/codex-executor.d.ts.map +1 -0
- package/dist/lib/executors/codex-executor.js +73 -0
- package/dist/lib/executors/executor-factory.d.ts +5 -0
- package/dist/lib/executors/executor-factory.d.ts.map +1 -0
- package/dist/lib/executors/executor-factory.js +27 -0
- package/dist/lib/executors/gemini-executor.d.ts +9 -0
- package/dist/lib/executors/gemini-executor.d.ts.map +1 -0
- package/dist/lib/executors/gemini-executor.js +67 -0
- package/dist/lib/executors/kilo-executor.d.ts +9 -0
- package/dist/lib/executors/kilo-executor.d.ts.map +1 -0
- package/dist/lib/executors/kilo-executor.js +69 -0
- package/dist/lib/executors/opencode-executor.d.ts +9 -0
- package/dist/lib/executors/opencode-executor.d.ts.map +1 -0
- package/dist/lib/executors/opencode-executor.js +67 -0
- package/dist/lib/git-utils.d.ts +88 -0
- package/dist/lib/git-utils.d.ts.map +1 -0
- package/dist/lib/git-utils.js +242 -0
- package/dist/lib/hooks.d.ts +73 -0
- package/dist/lib/hooks.d.ts.map +1 -0
- package/dist/lib/hooks.js +62 -0
- package/dist/lib/index.d.ts +100 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +143 -0
- package/dist/lib/logger.d.ts +20 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +32 -0
- package/dist/lib/notifications.d.ts +7 -0
- package/dist/lib/notifications.d.ts.map +1 -0
- package/dist/lib/notifications.js +81 -0
- package/dist/lib/prompt-builder.d.ts +70 -0
- package/dist/lib/prompt-builder.d.ts.map +1 -0
- package/dist/lib/prompt-builder.js +344 -0
- package/dist/lib/prompt-registry.d.ts +22 -0
- package/dist/lib/prompt-registry.d.ts.map +1 -0
- package/dist/lib/prompt-registry.js +409 -0
- package/dist/lib/provider-defaults.json +32 -0
- package/dist/lib/storage/file-system.d.ts +57 -0
- package/dist/lib/storage/file-system.d.ts.map +1 -0
- package/dist/lib/storage/file-system.js +638 -0
- package/dist/lib/storage/storage-callbacks.d.ts +17 -0
- package/dist/lib/storage/storage-callbacks.d.ts.map +1 -0
- package/dist/lib/storage/storage-callbacks.js +94 -0
- package/dist/lib/storage/types.d.ts +43 -0
- package/dist/lib/storage/types.d.ts.map +1 -0
- package/dist/lib/storage/types.js +2 -0
- package/dist/lib/task-execution-core.d.ts +7 -0
- package/dist/lib/task-execution-core.d.ts.map +1 -0
- package/dist/lib/task-execution-core.js +381 -0
- package/dist/lib/task-execution.d.ts +7 -0
- package/dist/lib/task-execution.d.ts.map +1 -0
- package/dist/lib/task-execution.js +40 -0
- package/dist/lib/task-loop-execution.d.ts +7 -0
- package/dist/lib/task-loop-execution.d.ts.map +1 -0
- package/dist/lib/task-loop-execution.js +156 -0
- package/dist/lib/task-planning.d.ts +29 -0
- package/dist/lib/task-planning.d.ts.map +1 -0
- package/dist/lib/task-planning.js +103 -0
- package/dist/lib/task-review.d.ts +27 -0
- package/dist/lib/task-review.d.ts.map +1 -0
- package/dist/lib/task-review.js +103 -0
- package/dist/lib/validation.d.ts +26 -0
- package/dist/lib/validation.d.ts.map +1 -0
- package/dist/lib/validation.js +98 -0
- package/dist/prompts/documentation-detection.d.ts +2 -0
- package/dist/prompts/documentation-detection.d.ts.map +1 -0
- package/dist/prompts/documentation-detection.js +24 -0
- package/dist/prompts/documentation-recap.d.ts +3 -0
- package/dist/prompts/documentation-recap.d.ts.map +1 -0
- package/dist/prompts/documentation-recap.js +13 -0
- package/dist/prompts/index.d.ts +15 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +30 -0
- package/dist/prompts/prd-combination.d.ts +2 -0
- package/dist/prompts/prd-combination.d.ts.map +1 -0
- package/dist/prompts/prd-combination.js +35 -0
- package/dist/prompts/prd-generation.d.ts +2 -0
- package/dist/prompts/prd-generation.d.ts.map +1 -0
- package/dist/prompts/prd-generation.js +49 -0
- package/dist/prompts/prd-parsing.d.ts +3 -0
- package/dist/prompts/prd-parsing.d.ts.map +1 -0
- package/dist/prompts/prd-parsing.js +172 -0
- package/dist/prompts/prd-question-answer.d.ts +3 -0
- package/dist/prompts/prd-question-answer.d.ts.map +1 -0
- package/dist/prompts/prd-question-answer.js +27 -0
- package/dist/prompts/prd-question.d.ts +3 -0
- package/dist/prompts/prd-question.d.ts.map +1 -0
- package/dist/prompts/prd-question.js +40 -0
- package/dist/prompts/prd-rework.d.ts +3 -0
- package/dist/prompts/prd-rework.d.ts.map +1 -0
- package/dist/prompts/prd-rework.js +81 -0
- package/dist/prompts/prd-suggest-stack.d.ts +3 -0
- package/dist/prompts/prd-suggest-stack.d.ts.map +1 -0
- package/dist/prompts/prd-suggest-stack.js +99 -0
- package/dist/prompts/task-breakdown.d.ts +3 -0
- package/dist/prompts/task-breakdown.d.ts.map +1 -0
- package/dist/prompts/task-breakdown.js +151 -0
- package/dist/prompts/task-enhancement.d.ts +3 -0
- package/dist/prompts/task-enhancement.d.ts.map +1 -0
- package/dist/prompts/task-enhancement.js +140 -0
- package/dist/prompts/task-execution.d.ts +3 -0
- package/dist/prompts/task-execution.d.ts.map +1 -0
- package/dist/prompts/task-execution.js +24 -0
- package/dist/prompts/task-planning.d.ts +3 -0
- package/dist/prompts/task-planning.d.ts.map +1 -0
- package/dist/prompts/task-planning.js +66 -0
- package/dist/prompts/workflow-assistance.d.ts +32 -0
- package/dist/prompts/workflow-assistance.d.ts.map +1 -0
- package/dist/prompts/workflow-assistance.js +130 -0
- package/dist/prompts/workflow-prompts.d.ts +9 -0
- package/dist/prompts/workflow-prompts.d.ts.map +1 -0
- package/dist/prompts/workflow-prompts.js +93 -0
- package/dist/services/benchmark.d.ts +26 -0
- package/dist/services/benchmark.d.ts.map +1 -0
- package/dist/services/benchmark.js +343 -0
- package/dist/services/prd.d.ts +136 -0
- package/dist/services/prd.d.ts.map +1 -0
- package/dist/services/prd.js +550 -0
- package/dist/services/tasks.d.ts +388 -0
- package/dist/services/tasks.d.ts.map +1 -0
- package/dist/services/tasks.js +1150 -0
- package/dist/services/workflow-ai-assistant.d.ts +74 -0
- package/dist/services/workflow-ai-assistant.d.ts.map +1 -0
- package/dist/services/workflow-ai-assistant.js +175 -0
- package/dist/services/workflow-benchmark.d.ts +34 -0
- package/dist/services/workflow-benchmark.d.ts.map +1 -0
- package/dist/services/workflow-benchmark.js +318 -0
- package/dist/services/workflow.d.ts +107 -0
- package/dist/services/workflow.d.ts.map +1 -0
- package/dist/services/workflow.js +580 -0
- package/dist/test/hooks.test.d.ts +2 -0
- package/dist/test/hooks.test.d.ts.map +1 -0
- package/dist/test/hooks.test.js +67 -0
- package/dist/test/integration/callbacks.test.d.ts +2 -0
- package/dist/test/integration/callbacks.test.d.ts.map +1 -0
- package/dist/test/integration/callbacks.test.js +64 -0
- package/dist/test/lib/ai-service/task-operations.test.d.ts +2 -0
- package/dist/test/lib/ai-service/task-operations.test.d.ts.map +1 -0
- package/dist/test/lib/ai-service/task-operations.test.js +362 -0
- package/dist/test/lib/config.test.d.ts +2 -0
- package/dist/test/lib/config.test.d.ts.map +1 -0
- package/dist/test/lib/config.test.js +128 -0
- package/dist/test/lib/git-utils.test.d.ts +2 -0
- package/dist/test/lib/git-utils.test.d.ts.map +1 -0
- package/dist/test/lib/git-utils.test.js +168 -0
- package/dist/test/mocks/mock-ai-operations.d.ts +15 -0
- package/dist/test/mocks/mock-ai-operations.d.ts.map +1 -0
- package/dist/test/mocks/mock-ai-operations.js +107 -0
- package/dist/test/mocks/mock-context-builder.d.ts +10 -0
- package/dist/test/mocks/mock-context-builder.d.ts.map +1 -0
- package/dist/test/mocks/mock-context-builder.js +81 -0
- package/dist/test/mocks/mock-model-provider.d.ts +7 -0
- package/dist/test/mocks/mock-model-provider.d.ts.map +1 -0
- package/dist/test/mocks/mock-model-provider.js +21 -0
- package/dist/test/mocks/mock-service-factory.d.ts +11 -0
- package/dist/test/mocks/mock-service-factory.d.ts.map +1 -0
- package/dist/test/mocks/mock-service-factory.js +61 -0
- package/dist/test/mocks/mock-storage.d.ts +50 -0
- package/dist/test/mocks/mock-storage.d.ts.map +1 -0
- package/dist/test/mocks/mock-storage.js +145 -0
- package/dist/test/model-parsing.test.d.ts +2 -0
- package/dist/test/model-parsing.test.d.ts.map +1 -0
- package/dist/test/model-parsing.test.js +73 -0
- package/dist/test/services/task-service.test.d.ts +2 -0
- package/dist/test/services/task-service.test.d.ts.map +1 -0
- package/dist/test/services/task-service.test.js +459 -0
- package/dist/test/storage.test.d.ts +2 -0
- package/dist/test/storage.test.d.ts.map +1 -0
- package/dist/test/storage.test.js +207 -0
- package/dist/test/task-loop-git.test.d.ts +2 -0
- package/dist/test/task-loop-git.test.d.ts.map +1 -0
- package/dist/test/task-loop-git.test.js +95 -0
- package/dist/test/test-mock-setup.d.ts +26 -0
- package/dist/test/test-mock-setup.d.ts.map +1 -0
- package/dist/test/test-mock-setup.js +41 -0
- package/dist/test/test-setup.d.ts +9 -0
- package/dist/test/test-setup.d.ts.map +1 -0
- package/dist/test/test-setup.js +44 -0
- package/dist/test/test-utils.d.ts +22 -0
- package/dist/test/test-utils.d.ts.map +1 -0
- package/dist/test/test-utils.js +37 -0
- package/dist/test/utils/ai-operation-utility.test.d.ts +2 -0
- package/dist/test/utils/ai-operation-utility.test.d.ts.map +1 -0
- package/dist/test/utils/ai-operation-utility.test.js +290 -0
- package/dist/test/utils/error-handling.test.d.ts +2 -0
- package/dist/test/utils/error-handling.test.d.ts.map +1 -0
- package/dist/test/utils/error-handling.test.js +231 -0
- package/dist/test/utils/file-utils.test.d.ts +2 -0
- package/dist/test/utils/file-utils.test.d.ts.map +1 -0
- package/dist/test/utils/file-utils.test.js +76 -0
- package/dist/test/utils/id-generator.test.d.ts +2 -0
- package/dist/test/utils/id-generator.test.d.ts.map +1 -0
- package/dist/test/utils/id-generator.test.js +41 -0
- package/dist/test/utils/model-parser.test.d.ts +2 -0
- package/dist/test/utils/model-parser.test.d.ts.map +1 -0
- package/dist/test/utils/model-parser.test.js +65 -0
- package/dist/test/validation.test.d.ts +2 -0
- package/dist/test/validation.test.d.ts.map +1 -0
- package/dist/test/validation.test.js +22 -0
- package/dist/types/callbacks.d.ts +30 -0
- package/dist/types/callbacks.d.ts.map +1 -0
- package/dist/types/callbacks.js +2 -0
- package/dist/types/index.d.ts +435 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +30 -0
- package/dist/types/mcp.d.ts +3 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +3 -0
- package/dist/types/options.d.ts +112 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/options.js +2 -0
- package/dist/types/results.d.ts +200 -0
- package/dist/types/results.d.ts.map +1 -0
- package/dist/types/results.js +2 -0
- package/dist/types/workflow-options.d.ts +82 -0
- package/dist/types/workflow-options.d.ts.map +1 -0
- package/dist/types/workflow-options.js +2 -0
- package/dist/types/workflow-results.d.ts +82 -0
- package/dist/types/workflow-results.d.ts.map +1 -0
- package/dist/types/workflow-results.js +2 -0
- package/dist/utils/ai-config-builder.d.ts +14 -0
- package/dist/utils/ai-config-builder.d.ts.map +1 -0
- package/dist/utils/ai-config-builder.js +22 -0
- package/dist/utils/ai-operation-utility.d.ts +142 -0
- package/dist/utils/ai-operation-utility.d.ts.map +1 -0
- package/dist/utils/ai-operation-utility.js +303 -0
- package/dist/utils/ai-service-factory.d.ts +34 -0
- package/dist/utils/ai-service-factory.d.ts.map +1 -0
- package/dist/utils/ai-service-factory.js +99 -0
- package/dist/utils/error-utils.d.ts +70 -0
- package/dist/utils/error-utils.d.ts.map +1 -0
- package/dist/utils/error-utils.js +104 -0
- package/dist/utils/file-utils.d.ts +107 -0
- package/dist/utils/file-utils.d.ts.map +1 -0
- package/dist/utils/file-utils.js +171 -0
- package/dist/utils/id-generator.d.ts +92 -0
- package/dist/utils/id-generator.d.ts.map +1 -0
- package/dist/utils/id-generator.js +146 -0
- package/dist/utils/metadata-utils.d.ts +40 -0
- package/dist/utils/metadata-utils.d.ts.map +1 -0
- package/dist/utils/metadata-utils.js +43 -0
- package/dist/utils/model-executor-parser.d.ts +38 -0
- package/dist/utils/model-executor-parser.d.ts.map +1 -0
- package/dist/utils/model-executor-parser.js +69 -0
- package/dist/utils/model-parser.d.ts +6 -0
- package/dist/utils/model-parser.d.ts.map +1 -0
- package/dist/utils/model-parser.js +49 -0
- package/dist/utils/stack-formatter.d.ts +12 -0
- package/dist/utils/stack-formatter.d.ts.map +1 -0
- package/dist/utils/stack-formatter.js +36 -0
- package/dist/utils/storage-utils.d.ts +49 -0
- package/dist/utils/storage-utils.d.ts.map +1 -0
- package/dist/utils/storage-utils.js +80 -0
- package/dist/utils/streaming-utils.d.ts +38 -0
- package/dist/utils/streaming-utils.d.ts.map +1 -0
- package/dist/utils/streaming-utils.js +64 -0
- package/dist/utils/task-o-matic-error.d.ts +206 -0
- package/dist/utils/task-o-matic-error.d.ts.map +1 -0
- package/dist/utils/task-o-matic-error.js +304 -0
- package/package.json +40 -0
- package/src/index.ts +36 -0
- package/src/lib/ai-service/ai-operations.ts +310 -0
- package/src/lib/ai-service/base-operations.ts +139 -0
- package/src/lib/ai-service/documentation-operations.ts +438 -0
- package/src/lib/ai-service/filesystem-tools.ts +73 -0
- package/src/lib/ai-service/gemini-proxy.ts.bak +52 -0
- package/src/lib/ai-service/json-parser.ts +203 -0
- package/src/lib/ai-service/mcp-client.ts +54 -0
- package/src/lib/ai-service/model-provider.ts +192 -0
- package/src/lib/ai-service/prd-operations.ts +854 -0
- package/src/lib/ai-service/research-tools.ts +207 -0
- package/src/lib/ai-service/retry-handler.ts +89 -0
- package/src/lib/ai-service/task-operations.ts +342 -0
- package/src/lib/benchmark/registry.ts +307 -0
- package/src/lib/benchmark/runner.ts +190 -0
- package/src/lib/benchmark/storage.ts +140 -0
- package/src/lib/benchmark/types.ts +121 -0
- package/src/lib/better-t-stack-cli.ts +524 -0
- package/src/lib/bootstrap/cli-bootstrap.ts +397 -0
- package/src/lib/bootstrap/index.ts +2 -0
- package/src/lib/bootstrap/medusa-bootstrap.ts +261 -0
- package/src/lib/config-validation.ts +278 -0
- package/src/lib/config.ts +435 -0
- package/src/lib/context-builder.ts +383 -0
- package/src/lib/executors/claude-code-executor.ts +83 -0
- package/src/lib/executors/codex-executor.ts +85 -0
- package/src/lib/executors/executor-factory.ts +28 -0
- package/src/lib/executors/gemini-executor.ts +80 -0
- package/src/lib/executors/kilo-executor.ts +83 -0
- package/src/lib/executors/opencode-executor.ts +81 -0
- package/src/lib/git-utils.ts +334 -0
- package/src/lib/hooks.ts +121 -0
- package/src/lib/index.ts +166 -0
- package/src/lib/logger.ts +43 -0
- package/src/lib/notifications.ts +103 -0
- package/src/lib/prompt-builder.ts +471 -0
- package/src/lib/prompt-registry.ts +491 -0
- package/src/lib/provider-defaults.json +32 -0
- package/src/lib/storage/file-system.ts +864 -0
- package/src/lib/storage/storage-callbacks.ts +120 -0
- package/src/lib/storage/types.ts +58 -0
- package/src/lib/task-execution-core.ts +591 -0
- package/src/lib/task-execution.ts +59 -0
- package/src/lib/task-loop-execution.ts +214 -0
- package/src/lib/task-planning.ts +157 -0
- package/src/lib/task-review.ts +138 -0
- package/src/lib/validation.ts +140 -0
- package/src/prompts/documentation-detection.ts +21 -0
- package/src/prompts/documentation-recap.ts +11 -0
- package/src/prompts/index.ts +14 -0
- package/src/prompts/prd-combination.ts +32 -0
- package/src/prompts/prd-generation.ts +46 -0
- package/src/prompts/prd-parsing.ts +170 -0
- package/src/prompts/prd-question-answer.ts +25 -0
- package/src/prompts/prd-question.ts +38 -0
- package/src/prompts/prd-rework.ts +79 -0
- package/src/prompts/prd-suggest-stack.ts +97 -0
- package/src/prompts/task-breakdown.ts +149 -0
- package/src/prompts/task-enhancement.ts +138 -0
- package/src/prompts/task-execution.ts +22 -0
- package/src/prompts/task-planning.ts +64 -0
- package/src/prompts/workflow-assistance.ts +151 -0
- package/src/prompts/workflow-prompts.ts +97 -0
- package/src/services/benchmark.ts +433 -0
- package/src/services/prd.ts +845 -0
- package/src/services/tasks.ts +1515 -0
- package/src/services/workflow-ai-assistant.ts +298 -0
- package/src/services/workflow-benchmark.ts +339 -0
- package/src/services/workflow.ts +779 -0
- package/src/test/hooks.test.ts +77 -0
- package/src/test/integration/callbacks.test.ts +39 -0
- package/src/test/lib/ai-service/task-operations.test.ts +430 -0
- package/src/test/lib/config.test.ts +150 -0
- package/src/test/lib/git-utils.test.ts +198 -0
- package/src/test/mocks/mock-ai-operations.ts +205 -0
- package/src/test/mocks/mock-context-builder.ts +84 -0
- package/src/test/mocks/mock-model-provider.ts +21 -0
- package/src/test/mocks/mock-service-factory.ts +64 -0
- package/src/test/mocks/mock-storage.ts +204 -0
- package/src/test/model-parsing.test.ts +78 -0
- package/src/test/services/task-service.test.ts +551 -0
- package/src/test/storage.test.ts +206 -0
- package/src/test/task-loop-git.test.ts +142 -0
- package/src/test/test-mock-setup.ts +46 -0
- package/src/test/test-setup.ts +48 -0
- package/src/test/test-utils.ts +45 -0
- package/src/test/utils/ai-operation-utility.test.ts +306 -0
- package/src/test/utils/error-handling.test.ts +241 -0
- package/src/test/utils/file-utils.test.ts +80 -0
- package/src/test/utils/id-generator.test.ts +44 -0
- package/src/test/utils/model-parser.test.ts +67 -0
- package/src/test/validation.test.ts +19 -0
- package/src/types/callbacks.ts +14 -0
- package/src/types/index.ts +628 -0
- package/src/types/mcp.ts +5 -0
- package/src/types/options.ts +165 -0
- package/src/types/results.ts +216 -0
- package/src/types/workflow-options.ts +113 -0
- package/src/types/workflow-results.ts +87 -0
- package/src/utils/ai-config-builder.ts +33 -0
- package/src/utils/ai-operation-utility.ts +380 -0
- package/src/utils/ai-service-factory.ts +125 -0
- package/src/utils/error-utils.ts +124 -0
- package/src/utils/file-utils.ts +197 -0
- package/src/utils/id-generator.ts +168 -0
- package/src/utils/metadata-utils.ts +48 -0
- package/src/utils/model-executor-parser.ts +80 -0
- package/src/utils/model-parser.ts +58 -0
- package/src/utils/stack-formatter.ts +53 -0
- package/src/utils/storage-utils.ts +94 -0
- package/src/utils/streaming-utils.ts +91 -0
- package/src/utils/task-o-matic-error.ts +393 -0
- package/tsconfig.json +20 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFileSystemCallbacks = createFileSystemCallbacks;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
/**
|
|
8
|
+
* Default file system callbacks (Node.js environment)
|
|
9
|
+
* Uses fs/promises to implement the storage interface
|
|
10
|
+
*/
|
|
11
|
+
function createFileSystemCallbacks(baseDir = process.cwd()) {
|
|
12
|
+
const resolvePath = (key) => (0, path_1.join)(baseDir, key);
|
|
13
|
+
const ensureDir = (filePath) => {
|
|
14
|
+
const dir = (0, path_1.dirname)(filePath);
|
|
15
|
+
if (!(0, fs_1.existsSync)(dir)) {
|
|
16
|
+
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
read: async (key) => {
|
|
21
|
+
try {
|
|
22
|
+
const path = resolvePath(key);
|
|
23
|
+
if (!(0, fs_1.existsSync)(path))
|
|
24
|
+
return null;
|
|
25
|
+
return await (0, promises_1.readFile)(path, "utf-8");
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (error.code === "ENOENT")
|
|
29
|
+
return null;
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
write: async (key, value) => {
|
|
34
|
+
const path = resolvePath(key);
|
|
35
|
+
ensureDir(path);
|
|
36
|
+
await (0, promises_1.writeFile)(path, value, "utf-8");
|
|
37
|
+
},
|
|
38
|
+
delete: async (key) => {
|
|
39
|
+
try {
|
|
40
|
+
const path = resolvePath(key);
|
|
41
|
+
if ((0, fs_1.existsSync)(path)) {
|
|
42
|
+
await (0, promises_1.unlink)(path);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
// Ignore if already gone
|
|
47
|
+
if (error.code !== "ENOENT")
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
list: async (prefix) => {
|
|
52
|
+
const searchPath = prefix ? resolvePath(prefix) : baseDir;
|
|
53
|
+
try {
|
|
54
|
+
// If it's a directory, recursively list all files in it
|
|
55
|
+
if ((0, fs_1.existsSync)(searchPath) && (await (0, promises_1.stat)(searchPath)).isDirectory()) {
|
|
56
|
+
const files = [];
|
|
57
|
+
const scan = async (dir, currentPrefix) => {
|
|
58
|
+
const items = await (0, promises_1.readdir)(dir);
|
|
59
|
+
for (const item of items) {
|
|
60
|
+
const fullPath = (0, path_1.join)(dir, item);
|
|
61
|
+
const itemPrefix = currentPrefix
|
|
62
|
+
? (0, path_1.join)(currentPrefix, item)
|
|
63
|
+
: item;
|
|
64
|
+
if ((await (0, promises_1.stat)(fullPath)).isDirectory()) {
|
|
65
|
+
await scan(fullPath, itemPrefix);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
files.push(itemPrefix);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
await scan(searchPath, prefix || "");
|
|
73
|
+
return files;
|
|
74
|
+
}
|
|
75
|
+
// If it's a file prefix (e.g. "tasks/task-")
|
|
76
|
+
const dir = (0, path_1.dirname)(searchPath);
|
|
77
|
+
if ((0, fs_1.existsSync)(dir)) {
|
|
78
|
+
const files = await (0, promises_1.readdir)(dir);
|
|
79
|
+
const namePrefix = prefix ? prefix.split("/").pop() || "" : "";
|
|
80
|
+
return files
|
|
81
|
+
.filter((f) => f.startsWith(namePrefix))
|
|
82
|
+
.map((f) => (0, path_1.join)((0, path_1.dirname)(prefix || ""), f));
|
|
83
|
+
}
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
exists: async (key) => {
|
|
91
|
+
return (0, fs_1.existsSync)(resolvePath(key));
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Task, CreateTaskRequest, TaskAIMetadata } from "../../types";
|
|
2
|
+
export interface TaskRepository {
|
|
3
|
+
getTasks(): Promise<Task[]>;
|
|
4
|
+
getTopLevelTasks(): Promise<Task[]>;
|
|
5
|
+
getTask(id: string): Promise<Task | null>;
|
|
6
|
+
createTask(task: CreateTaskRequest, aiMetadata?: TaskAIMetadata): Promise<Task>;
|
|
7
|
+
updateTask(id: string, updates: Partial<Task>): Promise<Task | null>;
|
|
8
|
+
deleteTask(id: string): Promise<boolean>;
|
|
9
|
+
getSubtasks(parentId: string): Promise<Task[]>;
|
|
10
|
+
getTaskContent(taskId: string): Promise<string | null>;
|
|
11
|
+
saveTaskContent(taskId: string, content: string): Promise<string>;
|
|
12
|
+
saveEnhancedTaskContent(taskId: string, content: string): Promise<string>;
|
|
13
|
+
deleteTaskContent(taskId: string): Promise<void>;
|
|
14
|
+
migrateTaskContent(): Promise<number>;
|
|
15
|
+
cleanupOrphanedContent(): Promise<number>;
|
|
16
|
+
getTaskAIMetadata(taskId: string): Promise<TaskAIMetadata | null>;
|
|
17
|
+
saveTaskAIMetadata(metadata: TaskAIMetadata): Promise<void>;
|
|
18
|
+
deleteTaskAIMetadata(taskId: string): Promise<void>;
|
|
19
|
+
getTaskDocumentation(taskId: string): Promise<string | null>;
|
|
20
|
+
saveTaskDocumentation(taskId: string, content: string): Promise<string>;
|
|
21
|
+
saveContext7Documentation(library: string, query: string, content: string): Promise<string>;
|
|
22
|
+
getDocumentationFile(fileName: string): Promise<string | null>;
|
|
23
|
+
listDocumentationFiles(): Promise<string[]>;
|
|
24
|
+
getPlan(taskId: string): Promise<{
|
|
25
|
+
plan: string;
|
|
26
|
+
createdAt: number;
|
|
27
|
+
updatedAt: number;
|
|
28
|
+
} | null>;
|
|
29
|
+
savePlan(taskId: string, plan: string): Promise<void>;
|
|
30
|
+
listPlans(): Promise<Array<{
|
|
31
|
+
taskId: string;
|
|
32
|
+
plan: string;
|
|
33
|
+
createdAt: number;
|
|
34
|
+
updatedAt: number;
|
|
35
|
+
}>>;
|
|
36
|
+
deletePlan(taskId: string): Promise<boolean>;
|
|
37
|
+
sanitizeForFilename(name: string): string;
|
|
38
|
+
validateStorageIntegrity(): Promise<{
|
|
39
|
+
isValid: boolean;
|
|
40
|
+
issues: string[];
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/storage/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEtE,MAAM,WAAW,cAAc;IAE7B,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5B,gBAAgB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAC1C,UAAU,CACR,IAAI,EAAE,iBAAiB,EACvB,UAAU,CAAC,EAAE,cAAc,GAC1B,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACrE,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAG/C,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvD,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAClE,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1E,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAG1C,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAClE,kBAAkB,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGpD,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7D,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxE,yBAAyB,CACvB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAAC;IACnB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC/D,sBAAsB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAG5C,OAAO,CACL,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IAC1E,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,SAAS,IAAI,OAAO,CAClB,KAAK,CAAC;QACJ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CACH,CAAC;IACF,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAG7C,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1C,wBAAwB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;CAC7E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TaskExecutionConfig, TaskExecutionResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Execute a single task with all features (retry, planning, review, etc.)
|
|
4
|
+
* This is the core unified execution logic used by both execute and execute-loop commands
|
|
5
|
+
*/
|
|
6
|
+
export declare function executeTaskCore(taskId: string, config: TaskExecutionConfig): Promise<TaskExecutionResult>;
|
|
7
|
+
//# sourceMappingURL=task-execution-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-execution-core.d.ts","sourceRoot":"","sources":["../../src/lib/task-execution-core.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EAKpB,MAAM,UAAU,CAAC;AAiBlB;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CAyE9B"}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeTaskCore = executeTaskCore;
|
|
4
|
+
const task_o_matic_error_1 = require("../utils/task-o-matic-error");
|
|
5
|
+
const tasks_1 = require("../services/tasks");
|
|
6
|
+
const executor_factory_1 = require("./executors/executor-factory");
|
|
7
|
+
const validation_1 = require("./validation");
|
|
8
|
+
const ai_service_factory_1 = require("../utils/ai-service-factory");
|
|
9
|
+
const hooks_1 = require("./hooks");
|
|
10
|
+
const prompt_builder_1 = require("./prompt-builder");
|
|
11
|
+
const task_planning_1 = require("./task-planning");
|
|
12
|
+
const task_review_1 = require("./task-review");
|
|
13
|
+
const git_utils_1 = require("./git-utils");
|
|
14
|
+
const logger_1 = require("./logger");
|
|
15
|
+
/**
|
|
16
|
+
* Execute a single task with all features (retry, planning, review, etc.)
|
|
17
|
+
* This is the core unified execution logic used by both execute and execute-loop commands
|
|
18
|
+
*/
|
|
19
|
+
async function executeTaskCore(taskId, config) {
|
|
20
|
+
const { tool, executorConfig, customMessage, verificationCommands = [], enableRetry = false, maxRetries = 3, tryModels, enablePlanPhase = false, planModel, reviewPlan = false, enableReviewPhase = false, reviewModel, autoCommit: enableAutoCommit = false, executeSubtasks = true, includePrd = false, dry = false, onPlanReview, } = config;
|
|
21
|
+
// Load task
|
|
22
|
+
const task = await tasks_1.taskService.getTask(taskId);
|
|
23
|
+
if (!task) {
|
|
24
|
+
throw (0, task_o_matic_error_1.formatTaskNotFoundError)(taskId);
|
|
25
|
+
}
|
|
26
|
+
// Check if task has subtasks and should execute them recursively
|
|
27
|
+
if (executeSubtasks && !customMessage) {
|
|
28
|
+
const subtasks = await tasks_1.taskService.getSubtasks(taskId);
|
|
29
|
+
if (subtasks.length > 0) {
|
|
30
|
+
return await executeTaskWithSubtasks(task, subtasks, config);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// ----------------------------------------------------------------------
|
|
34
|
+
// PLANNING PHASE
|
|
35
|
+
// ----------------------------------------------------------------------
|
|
36
|
+
let planContent;
|
|
37
|
+
if (enablePlanPhase) {
|
|
38
|
+
const planningResult = await (0, task_planning_1.executePlanningPhase)(task, tool, {
|
|
39
|
+
planModel,
|
|
40
|
+
reviewPlan,
|
|
41
|
+
autoCommit: enableAutoCommit,
|
|
42
|
+
dry,
|
|
43
|
+
onPlanReview,
|
|
44
|
+
});
|
|
45
|
+
if (planningResult.success && planningResult.planContent) {
|
|
46
|
+
planContent = planningResult.planContent;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// ----------------------------------------------------------------------
|
|
50
|
+
// EXECUTION PHASE (with optional retry logic)
|
|
51
|
+
// ----------------------------------------------------------------------
|
|
52
|
+
const attempts = [];
|
|
53
|
+
if (enableRetry) {
|
|
54
|
+
// Execute with retry logic
|
|
55
|
+
return await executeTaskWithRetry(task, config, attempts, planContent);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// Execute once without retry (simpler path for execute command)
|
|
59
|
+
return await executeSingleAttempt(task, config, attempts, planContent, 1, maxRetries);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Execute task with subtasks recursively
|
|
64
|
+
*/
|
|
65
|
+
async function executeTaskWithSubtasks(task, subtasks, config) {
|
|
66
|
+
const { dry, includeCompleted = false } = config;
|
|
67
|
+
logger_1.logger.info(`📋 Task has ${subtasks.length} subtasks, executing recursively...`);
|
|
68
|
+
const subtaskResults = [];
|
|
69
|
+
let allSuccess = true;
|
|
70
|
+
// Execute subtasks one by one
|
|
71
|
+
for (let i = 0; i < subtasks.length; i++) {
|
|
72
|
+
const subtask = subtasks[i];
|
|
73
|
+
// Skip completed subtasks unless includeCompleted is set
|
|
74
|
+
if (!includeCompleted && subtask.status === "completed") {
|
|
75
|
+
logger_1.logger.info(`⏭️ Skipping completed subtask: ${subtask.title} (${subtask.id})`);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
logger_1.logger.progress(`\n[${i + 1}/${subtasks.length}] Executing subtask: ${subtask.title} (${subtask.id})`);
|
|
79
|
+
try {
|
|
80
|
+
const result = await executeTaskCore(subtask.id, config);
|
|
81
|
+
subtaskResults.push(result);
|
|
82
|
+
if (!result.success) {
|
|
83
|
+
allSuccess = false;
|
|
84
|
+
logger_1.logger.error(`❌ Failed to execute subtask ${subtask.id}: ${subtask.title}`);
|
|
85
|
+
break; // Stop on first failure
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
allSuccess = false;
|
|
90
|
+
logger_1.logger.error(`❌ Failed to execute subtask ${subtask.id}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// After all subtasks are done (or on failure), update the main task status
|
|
95
|
+
if (!dry) {
|
|
96
|
+
if (allSuccess) {
|
|
97
|
+
await tasks_1.taskService.setTaskStatus(task.id, "completed");
|
|
98
|
+
logger_1.logger.success(`✅ Main task ${task.title} completed after all subtasks`);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
await tasks_1.taskService.setTaskStatus(task.id, "todo");
|
|
102
|
+
logger_1.logger.error(`❌ Main task ${task.title} failed due to subtask failure, status reset to todo`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
success: allSuccess,
|
|
107
|
+
attempts: [], // Parent task doesn't have its own attempts
|
|
108
|
+
subtaskResults,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Execute task with retry logic
|
|
113
|
+
*/
|
|
114
|
+
async function executeTaskWithRetry(task, config, attempts, planContent) {
|
|
115
|
+
const { tool, maxRetries = 3, tryModels, verificationCommands = [], enableReviewPhase = false, reviewModel, autoCommit: enableAutoCommit = false, dry = false, } = config;
|
|
116
|
+
let currentAttempt = 1;
|
|
117
|
+
let lastError;
|
|
118
|
+
while (currentAttempt <= maxRetries) {
|
|
119
|
+
// Determine which executor and model to use for this attempt
|
|
120
|
+
let currentExecutor = tool;
|
|
121
|
+
let currentModel;
|
|
122
|
+
if (tryModels && tryModels.length > 0) {
|
|
123
|
+
const modelConfigIndex = Math.min(currentAttempt - 1, tryModels.length - 1);
|
|
124
|
+
const modelConfig = tryModels[modelConfigIndex];
|
|
125
|
+
if (modelConfig.executor) {
|
|
126
|
+
currentExecutor = modelConfig.executor;
|
|
127
|
+
}
|
|
128
|
+
if (modelConfig.model) {
|
|
129
|
+
currentModel = modelConfig.model;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
logger_1.logger.info(`\n🎯 Attempt ${currentAttempt}/${maxRetries} for task: ${task.title} (${task.id})`);
|
|
133
|
+
if (currentModel) {
|
|
134
|
+
logger_1.logger.progress(` Using executor: ${currentExecutor} with model: ${currentModel}`);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
logger_1.logger.progress(` Using executor: ${currentExecutor}`);
|
|
138
|
+
}
|
|
139
|
+
// Build retry context if this is a retry attempt
|
|
140
|
+
let retryContext = "";
|
|
141
|
+
if (currentAttempt > 1 && lastError) {
|
|
142
|
+
const retryParts = [];
|
|
143
|
+
retryParts.push(`# RETRY ATTEMPT ${currentAttempt}/${maxRetries}\n\n`);
|
|
144
|
+
if (currentModel) {
|
|
145
|
+
retryParts.push(`**Note**: You are ${currentExecutor} using the ${currentModel} model. This is a more capable model than the previous attempt.\n\n`);
|
|
146
|
+
}
|
|
147
|
+
retryParts.push(`## Previous Attempt Failed With Error:\n\n${lastError}\n\n`);
|
|
148
|
+
retryParts.push(`Please analyze the error carefully and fix it. The error might be due to:\n`);
|
|
149
|
+
retryParts.push(`- Syntax errors\n`);
|
|
150
|
+
retryParts.push(`- Logic errors\n`);
|
|
151
|
+
retryParts.push(`- Missing dependencies or imports\n`);
|
|
152
|
+
retryParts.push(`- Incorrect configuration\n`);
|
|
153
|
+
retryParts.push(`- Build or test failures\n\n`);
|
|
154
|
+
retryParts.push(`Please fix the error above and complete the task successfully.\n\n`);
|
|
155
|
+
retryContext = retryParts.join("");
|
|
156
|
+
}
|
|
157
|
+
// Update executor config for this attempt
|
|
158
|
+
const attemptConfig = {
|
|
159
|
+
...config,
|
|
160
|
+
tool: currentExecutor,
|
|
161
|
+
executorConfig: {
|
|
162
|
+
...config.executorConfig,
|
|
163
|
+
model: currentModel,
|
|
164
|
+
continueLastSession: currentAttempt > 1, // Resume session on retries
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
try {
|
|
168
|
+
const result = await executeSingleAttempt(task, attemptConfig, attempts, planContent, currentAttempt, maxRetries, retryContext);
|
|
169
|
+
// Check if all verifications passed
|
|
170
|
+
const allVerificationsPassed = result.attempts[result.attempts.length - 1]?.verificationResults?.every((r) => r.success) ?? true;
|
|
171
|
+
if (!allVerificationsPassed) {
|
|
172
|
+
const failedVerification = result.attempts[result.attempts.length - 1]?.verificationResults?.find((r) => !r.success);
|
|
173
|
+
lastError = `Verification command "${failedVerification?.command}" failed:\n${failedVerification?.error}`;
|
|
174
|
+
currentAttempt++;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
// ----------------------------------------------------------------------
|
|
178
|
+
// AI REVIEW PHASE
|
|
179
|
+
// ----------------------------------------------------------------------
|
|
180
|
+
if (enableReviewPhase && !dry) {
|
|
181
|
+
const reviewResult = await (0, task_review_1.executeReviewPhase)(task, {
|
|
182
|
+
reviewModel,
|
|
183
|
+
planContent,
|
|
184
|
+
dry,
|
|
185
|
+
});
|
|
186
|
+
if (!reviewResult.approved) {
|
|
187
|
+
lastError = `AI Review Failed:\n${reviewResult.feedback}`;
|
|
188
|
+
logger_1.logger.error(`❌ AI Review Rejected Changes: ${reviewResult.feedback}`);
|
|
189
|
+
currentAttempt++;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
logger_1.logger.success(`✅ AI Review Approved: ${reviewResult.feedback}`);
|
|
194
|
+
result.reviewFeedback = reviewResult.feedback;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Success! Return the result
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
lastError = error instanceof Error ? error.message : String(error);
|
|
202
|
+
logger_1.logger.error(`❌ Task execution failed on attempt ${currentAttempt}: ${lastError}`);
|
|
203
|
+
if (!dry && currentAttempt < maxRetries) {
|
|
204
|
+
await tasks_1.taskService.setTaskStatus(task.id, "todo");
|
|
205
|
+
logger_1.logger.warn("⏸ Task status reset to todo for retry");
|
|
206
|
+
}
|
|
207
|
+
currentAttempt++;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// All retries exhausted
|
|
211
|
+
if (!dry) {
|
|
212
|
+
await tasks_1.taskService.setTaskStatus(task.id, "todo");
|
|
213
|
+
logger_1.logger.error("❌ All retry attempts exhausted, task status reset to todo");
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
success: false,
|
|
217
|
+
attempts,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Execute a single attempt of the task
|
|
222
|
+
*/
|
|
223
|
+
async function executeSingleAttempt(task, config, attempts, planContent, attemptNumber, maxRetries, retryContext) {
|
|
224
|
+
const { tool, executorConfig, customMessage, verificationCommands = [], autoCommit: enableAutoCommit = false, includePrd = false, dry = false, } = config;
|
|
225
|
+
const attemptStartTime = Date.now();
|
|
226
|
+
logger_1.logger.info(`🎯 ${dry ? "DRY RUN" : "Executing"} task: ${task.title} (${task.id})`);
|
|
227
|
+
// Capture git state before execution
|
|
228
|
+
const gitStateBefore = await (0, git_utils_1.captureGitState)();
|
|
229
|
+
// Build execution message
|
|
230
|
+
let executionMessage;
|
|
231
|
+
if (customMessage) {
|
|
232
|
+
// Use custom message override
|
|
233
|
+
executionMessage = customMessage;
|
|
234
|
+
logger_1.logger.progress("📝 Using custom execution message");
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
// Build comprehensive execution message with full context
|
|
238
|
+
const contextBuilder = (0, ai_service_factory_1.getContextBuilder)();
|
|
239
|
+
const taskContext = await contextBuilder.buildContext(task.id);
|
|
240
|
+
// Get task plan if available
|
|
241
|
+
const storedPlanData = await tasks_1.taskService.getTaskPlan(task.id);
|
|
242
|
+
let finalPlan;
|
|
243
|
+
if (planContent) {
|
|
244
|
+
finalPlan = `${planContent}\n\nPlease follow this plan to implement the task.`;
|
|
245
|
+
}
|
|
246
|
+
else if (storedPlanData) {
|
|
247
|
+
finalPlan = storedPlanData.plan;
|
|
248
|
+
}
|
|
249
|
+
// Build execution prompt using PromptBuilder
|
|
250
|
+
const promptResult = prompt_builder_1.PromptBuilder.buildExecutionPrompt({
|
|
251
|
+
taskTitle: task.title,
|
|
252
|
+
taskDescription: task.description,
|
|
253
|
+
taskPlan: finalPlan,
|
|
254
|
+
stack: taskContext.stack,
|
|
255
|
+
documentation: taskContext.documentation,
|
|
256
|
+
retryContext,
|
|
257
|
+
prdContent: includePrd ? taskContext.prdContent : undefined,
|
|
258
|
+
});
|
|
259
|
+
if (!promptResult.success) {
|
|
260
|
+
throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.CONFIGURATION_ERROR, `Failed to build execution prompt: ${promptResult.error}`);
|
|
261
|
+
}
|
|
262
|
+
executionMessage = promptResult.prompt;
|
|
263
|
+
}
|
|
264
|
+
// Update task status to in-progress
|
|
265
|
+
if (!dry) {
|
|
266
|
+
await tasks_1.taskService.setTaskStatus(task.id, "in-progress");
|
|
267
|
+
logger_1.logger.warn("⏳ Task status updated to in-progress");
|
|
268
|
+
}
|
|
269
|
+
// Emit execution:start event
|
|
270
|
+
await hooks_1.hooks.emit("execution:start", { taskId: task.id, tool });
|
|
271
|
+
try {
|
|
272
|
+
// Create executor and run
|
|
273
|
+
const executor = executor_factory_1.ExecutorFactory.create(tool, executorConfig);
|
|
274
|
+
// Log session resumption if applicable
|
|
275
|
+
if (executorConfig?.continueLastSession && attemptNumber > 1) {
|
|
276
|
+
logger_1.logger.progress("🔄 Resuming previous session to provide error feedback to AI");
|
|
277
|
+
}
|
|
278
|
+
await executor.execute(executionMessage, dry, executorConfig);
|
|
279
|
+
// Run verification commands
|
|
280
|
+
const verificationResults = await (0, validation_1.runValidations)(verificationCommands, dry);
|
|
281
|
+
const allVerificationsPassed = verificationResults.every((r) => r.success);
|
|
282
|
+
if (!allVerificationsPassed) {
|
|
283
|
+
const failedVerification = verificationResults.find((r) => !r.success);
|
|
284
|
+
const formattedError = (0, validation_1.formatVerificationError)(failedVerification);
|
|
285
|
+
attempts.push({
|
|
286
|
+
attemptNumber,
|
|
287
|
+
success: false,
|
|
288
|
+
error: formattedError,
|
|
289
|
+
executor: tool,
|
|
290
|
+
model: executorConfig?.model,
|
|
291
|
+
verificationResults,
|
|
292
|
+
timestamp: Date.now() - attemptStartTime,
|
|
293
|
+
});
|
|
294
|
+
logger_1.logger.error(`❌ Task execution failed verification on attempt ${attemptNumber}`);
|
|
295
|
+
// Don't throw - return failure so retry loop can handle with session continuation
|
|
296
|
+
// This enables automatic error feedback to the AI
|
|
297
|
+
return {
|
|
298
|
+
success: false,
|
|
299
|
+
attempts,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
// Extract commit info if enabled
|
|
303
|
+
let commitInfo;
|
|
304
|
+
if (enableAutoCommit && !dry) {
|
|
305
|
+
logger_1.logger.info("📝 Checking git state for auto-commit...");
|
|
306
|
+
// Check if agent already committed during execution
|
|
307
|
+
const agentCommitted = await (0, git_utils_1.hasNewCommitsSince)(gitStateBefore.beforeHead || "");
|
|
308
|
+
if (agentCommitted) {
|
|
309
|
+
logger_1.logger.info("📝 Agent already committed changes during execution, skipping auto-commit");
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
const gitStateAfter = await (0, git_utils_1.captureGitState)();
|
|
313
|
+
if (gitStateAfter.hasUncommittedChanges) {
|
|
314
|
+
const gitState = {
|
|
315
|
+
beforeHead: gitStateBefore.beforeHead || "",
|
|
316
|
+
afterHead: gitStateAfter.afterHead || "",
|
|
317
|
+
hasUncommittedChanges: gitStateAfter.hasUncommittedChanges || false,
|
|
318
|
+
};
|
|
319
|
+
commitInfo = await (0, git_utils_1.extractCommitInfo)(task.id, task.title, executionMessage, gitState);
|
|
320
|
+
logger_1.logger.success(`✅ Commit message: ${commitInfo.message}`);
|
|
321
|
+
if (commitInfo.files.length > 0) {
|
|
322
|
+
logger_1.logger.success(`📁 Changed files: ${commitInfo.files.join(", ")}`);
|
|
323
|
+
}
|
|
324
|
+
// Auto-commit the changes
|
|
325
|
+
await (0, git_utils_1.autoCommit)(commitInfo);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
logger_1.logger.info("📝 No uncommitted changes to commit");
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
// Update task status to completed
|
|
333
|
+
if (!dry) {
|
|
334
|
+
await tasks_1.taskService.setTaskStatus(task.id, "completed");
|
|
335
|
+
logger_1.logger.success("✅ Task execution completed successfully");
|
|
336
|
+
}
|
|
337
|
+
// Record successful attempt
|
|
338
|
+
attempts.push({
|
|
339
|
+
attemptNumber,
|
|
340
|
+
success: true,
|
|
341
|
+
executor: tool,
|
|
342
|
+
model: executorConfig?.model,
|
|
343
|
+
verificationResults,
|
|
344
|
+
commitInfo,
|
|
345
|
+
timestamp: Date.now() - attemptStartTime,
|
|
346
|
+
});
|
|
347
|
+
// Emit execution:end event
|
|
348
|
+
await hooks_1.hooks.emit("execution:end", { taskId: task.id, success: true });
|
|
349
|
+
return {
|
|
350
|
+
success: true,
|
|
351
|
+
attempts,
|
|
352
|
+
commitInfo,
|
|
353
|
+
planContent,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
358
|
+
// Record failed attempt if not already recorded
|
|
359
|
+
if (attempts.length === 0 ||
|
|
360
|
+
attempts[attempts.length - 1].attemptNumber !== attemptNumber) {
|
|
361
|
+
attempts.push({
|
|
362
|
+
attemptNumber,
|
|
363
|
+
success: false,
|
|
364
|
+
error: errorMessage,
|
|
365
|
+
executor: tool,
|
|
366
|
+
model: executorConfig?.model,
|
|
367
|
+
timestamp: Date.now() - attemptStartTime,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
// Emit execution:error event
|
|
371
|
+
await hooks_1.hooks.emit("execution:error", {
|
|
372
|
+
taskId: task.id,
|
|
373
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
374
|
+
});
|
|
375
|
+
if (!dry) {
|
|
376
|
+
await tasks_1.taskService.setTaskStatus(task.id, "todo");
|
|
377
|
+
logger_1.logger.error("❌ Task execution failed, status reset to todo");
|
|
378
|
+
}
|
|
379
|
+
throw error;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ExecuteTaskOptions } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Execute a task using an external coding assistant
|
|
4
|
+
* This is the simplified entry point that delegates to the unified core
|
|
5
|
+
*/
|
|
6
|
+
export declare function executeTask(options: ExecuteTaskOptions): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=task-execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-execution.d.ts","sourceRoot":"","sources":["../../src/lib/task-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,UAAU,CAAC;AAGnE;;;GAGG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmD5E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeTask = executeTask;
|
|
4
|
+
const task_execution_core_1 = require("./task-execution-core");
|
|
5
|
+
/**
|
|
6
|
+
* Execute a task using an external coding assistant
|
|
7
|
+
* This is the simplified entry point that delegates to the unified core
|
|
8
|
+
*/
|
|
9
|
+
async function executeTask(options) {
|
|
10
|
+
const { taskId, tool = "opencode", message, model, continueSession, dry = false, validate = [], maxRetries, tryModels, plan, planModel, reviewPlan, review, reviewModel, autoCommit, includePrd, } = options;
|
|
11
|
+
// Build unified task execution config
|
|
12
|
+
const config = {
|
|
13
|
+
tool,
|
|
14
|
+
executorConfig: {
|
|
15
|
+
model,
|
|
16
|
+
continueLastSession: continueSession,
|
|
17
|
+
},
|
|
18
|
+
customMessage: message,
|
|
19
|
+
verificationCommands: validate,
|
|
20
|
+
enableRetry: maxRetries !== undefined && maxRetries > 0, // Opt-in retry
|
|
21
|
+
maxRetries: maxRetries || 3,
|
|
22
|
+
tryModels,
|
|
23
|
+
enablePlanPhase: plan,
|
|
24
|
+
planModel,
|
|
25
|
+
reviewPlan,
|
|
26
|
+
enableReviewPhase: review,
|
|
27
|
+
reviewModel,
|
|
28
|
+
autoCommit,
|
|
29
|
+
executeSubtasks: true, // Always execute subtasks in execute command
|
|
30
|
+
includePrd,
|
|
31
|
+
dry,
|
|
32
|
+
};
|
|
33
|
+
// Delegate to unified core execution
|
|
34
|
+
const result = await (0, task_execution_core_1.executeTaskCore)(taskId, config);
|
|
35
|
+
// Throw error if execution failed (maintains backward compatibility)
|
|
36
|
+
if (!result.success) {
|
|
37
|
+
const lastAttempt = result.attempts[result.attempts.length - 1];
|
|
38
|
+
throw new Error(lastAttempt?.error || "Task execution failed");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ExecuteLoopOptions, ExecuteLoopResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Execute multiple tasks in a loop with retry and verification
|
|
4
|
+
* This delegates to the unified executeTaskCore for each task
|
|
5
|
+
*/
|
|
6
|
+
export declare function executeTaskLoop(options: ExecuteLoopOptions): Promise<ExecuteLoopResult>;
|
|
7
|
+
//# sourceMappingURL=task-loop-execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-loop-execution.d.ts","sourceRoot":"","sources":["../../src/lib/task-loop-execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EAGlB,MAAM,UAAU,CAAC;AAMlB;;;GAGG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAoM5B"}
|