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,207 @@
|
|
|
1
|
+
import { tool, type Tool } from "ai";
|
|
2
|
+
import { z } from "zod/v3";
|
|
3
|
+
import { TaskRepository } from "../storage/types";
|
|
4
|
+
import { getStorage } from "../../utils/ai-service-factory";
|
|
5
|
+
|
|
6
|
+
export class ResearchTools {
|
|
7
|
+
private storage: TaskRepository = getStorage();
|
|
8
|
+
// /**
|
|
9
|
+
// * Creates a tool for getting cached Context7 content
|
|
10
|
+
// */
|
|
11
|
+
// createCacheTool(): Tool {
|
|
12
|
+
// const cacheTool: Tool<string, string> = tool({
|
|
13
|
+
// description:
|
|
14
|
+
// "Get cached Context7 content using the cache file path from .task-o-matic/docs/_cache/",
|
|
15
|
+
// parameters: z.object({
|
|
16
|
+
// cacheKey: z
|
|
17
|
+
// .string()
|
|
18
|
+
// .describe(
|
|
19
|
+
// "The cache file path, e.g., 'react-hooks' or 'docs/_cache/react-hooks.json'"
|
|
20
|
+
// ),
|
|
21
|
+
// }),
|
|
22
|
+
// execute: async () => {
|
|
23
|
+
// try {
|
|
24
|
+
// const normalizedKey = cacheKey
|
|
25
|
+
// .replace(/^docs\/_cache\//, "")
|
|
26
|
+
// .replace(/\.json$/, "");
|
|
27
|
+
// const content =
|
|
28
|
+
// await this.storage.getCachedDocumentation(normalizedKey);
|
|
29
|
+
|
|
30
|
+
// if (!content) {
|
|
31
|
+
// return `Cache content not found for key: ${normalizedKey}`;
|
|
32
|
+
// }
|
|
33
|
+
|
|
34
|
+
// return content;
|
|
35
|
+
// } catch (error) {
|
|
36
|
+
// return `Error retrieving cache content: ${error instanceof Error ? error.message : String(error)}`;
|
|
37
|
+
// }
|
|
38
|
+
// },
|
|
39
|
+
// });
|
|
40
|
+
// return cacheTool;
|
|
41
|
+
// }
|
|
42
|
+
// /**
|
|
43
|
+
// * Creates a tool for getting documentation file content
|
|
44
|
+
// */
|
|
45
|
+
// createDocumentationTool() {
|
|
46
|
+
// return tool({
|
|
47
|
+
// description: "Get documentation file content from .task-o-matic/docs/ directory",
|
|
48
|
+
// inputSchema: z.object({
|
|
49
|
+
// docKey: z
|
|
50
|
+
// .string()
|
|
51
|
+
// .describe("The documentation file path, e.g., 'react/components.md' or just 'components'"),
|
|
52
|
+
// }),
|
|
53
|
+
// execute: async ({ docKey }) => {
|
|
54
|
+
// try {
|
|
55
|
+
// // Handle both full path and just the filename
|
|
56
|
+
// const normalizedKey = docKey.replace(/^docs\//, "");
|
|
57
|
+
// const content = await this.storage.getDocumentationFile(normalizedKey);
|
|
58
|
+
// if (!content) {
|
|
59
|
+
// return {
|
|
60
|
+
// success: false,
|
|
61
|
+
// error: `Documentation file not found for key: ${normalizedKey}`,
|
|
62
|
+
// };
|
|
63
|
+
// }
|
|
64
|
+
// return {
|
|
65
|
+
// success: true,
|
|
66
|
+
// content,
|
|
67
|
+
// key: normalizedKey,
|
|
68
|
+
// };
|
|
69
|
+
// } catch (error) {
|
|
70
|
+
// return {
|
|
71
|
+
// success: false,
|
|
72
|
+
// error: error instanceof Error ? error.message : String(error),
|
|
73
|
+
// };
|
|
74
|
+
// }
|
|
75
|
+
// },
|
|
76
|
+
// });
|
|
77
|
+
// }
|
|
78
|
+
// /**
|
|
79
|
+
// * Creates a tool for listing available cache files
|
|
80
|
+
// */
|
|
81
|
+
// createListCacheTool() {
|
|
82
|
+
// return tool({
|
|
83
|
+
// description: "List all available cached Context7 files in .task-o-matic/docs/_cache/",
|
|
84
|
+
// inputSchema: z.object({
|
|
85
|
+
// filter: z
|
|
86
|
+
// .string()
|
|
87
|
+
// .optional()
|
|
88
|
+
// .describe("Optional filter to search for specific cache files (e.g., 'react', 'nextjs')"),
|
|
89
|
+
// }),
|
|
90
|
+
// execute: async ({ filter }) => {
|
|
91
|
+
// try {
|
|
92
|
+
// const availableKeys = await this.getAvailableCacheKeys();
|
|
93
|
+
// let filteredKeys = availableKeys;
|
|
94
|
+
// if (filter) {
|
|
95
|
+
// filteredKeys = availableKeys.filter(key =>
|
|
96
|
+
// key.toLowerCase().includes(filter.toLowerCase())
|
|
97
|
+
// );
|
|
98
|
+
// }
|
|
99
|
+
// return {
|
|
100
|
+
// success: true,
|
|
101
|
+
// cacheFiles: filteredKeys,
|
|
102
|
+
// total: filteredKeys.length,
|
|
103
|
+
// filter: filter || null,
|
|
104
|
+
// };
|
|
105
|
+
// } catch (error) {
|
|
106
|
+
// return {
|
|
107
|
+
// success: false,
|
|
108
|
+
// error: error instanceof Error ? error.message : String(error),
|
|
109
|
+
// };
|
|
110
|
+
// }
|
|
111
|
+
// },
|
|
112
|
+
// });
|
|
113
|
+
// }
|
|
114
|
+
// /**
|
|
115
|
+
// * Creates a tool for listing available documentation files
|
|
116
|
+
// */
|
|
117
|
+
// createListDocumentationTool() {
|
|
118
|
+
// return tool({
|
|
119
|
+
// description: "List all available documentation files in .task-o-matic/docs/ directory",
|
|
120
|
+
// inputSchema: z.object({
|
|
121
|
+
// filter: z
|
|
122
|
+
// .string()
|
|
123
|
+
// .optional()
|
|
124
|
+
// .describe("Optional filter to search for specific documentation files (e.g., 'react', 'api')"),
|
|
125
|
+
// }),
|
|
126
|
+
// execute: async ({ filter }) => {
|
|
127
|
+
// try {
|
|
128
|
+
// const availableFiles = await this.getAvailableDocumentationFiles();
|
|
129
|
+
// let filteredFiles = availableFiles;
|
|
130
|
+
// if (filter) {
|
|
131
|
+
// filteredFiles = availableFiles.filter(file =>
|
|
132
|
+
// file.toLowerCase().includes(filter.toLowerCase())
|
|
133
|
+
// );
|
|
134
|
+
// }
|
|
135
|
+
// return {
|
|
136
|
+
// success: true,
|
|
137
|
+
// documentationFiles: filteredFiles,
|
|
138
|
+
// total: filteredFiles.length,
|
|
139
|
+
// filter: filter || null,
|
|
140
|
+
// };
|
|
141
|
+
// } catch (error) {
|
|
142
|
+
// return {
|
|
143
|
+
// success: false,
|
|
144
|
+
// error: error instanceof Error ? error.message : String(error),
|
|
145
|
+
// };
|
|
146
|
+
// }
|
|
147
|
+
// },
|
|
148
|
+
// });
|
|
149
|
+
// }
|
|
150
|
+
// /**
|
|
151
|
+
// * Get all available cache keys
|
|
152
|
+
// */
|
|
153
|
+
// private async getAvailableCacheKeys(): Promise<string[]> {
|
|
154
|
+
// try {
|
|
155
|
+
// return await this.storage.listCachedDocumentationFiles();
|
|
156
|
+
// } catch (error) {
|
|
157
|
+
// console.error("Error getting available cache keys:", error);
|
|
158
|
+
// return [];
|
|
159
|
+
// }
|
|
160
|
+
// }
|
|
161
|
+
// /**
|
|
162
|
+
// * Get all available documentation files
|
|
163
|
+
// */
|
|
164
|
+
// private async getAvailableDocumentationFiles(): Promise<string[]> {
|
|
165
|
+
// try {
|
|
166
|
+
// return await this.storage.listDocumentationFiles();
|
|
167
|
+
// } catch (error) {
|
|
168
|
+
// console.error("Error getting available documentation files:", error);
|
|
169
|
+
// return [];
|
|
170
|
+
// }
|
|
171
|
+
// }
|
|
172
|
+
// /**
|
|
173
|
+
// * Get all research tools as a ToolSet
|
|
174
|
+
// */
|
|
175
|
+
// getResearchTools(): ToolSet {
|
|
176
|
+
// return {
|
|
177
|
+
// get_cache_context7: this.createCacheTool(),
|
|
178
|
+
// get_documentation: this.createDocumentationTool(),
|
|
179
|
+
// list_cache_files: this.createListCacheTool(),
|
|
180
|
+
// list_documentation_files: this.createListDocumentationTool(),
|
|
181
|
+
// };
|
|
182
|
+
// }
|
|
183
|
+
// /**
|
|
184
|
+
// * Get tool descriptions for system prompt
|
|
185
|
+
// */
|
|
186
|
+
// getToolDescriptions(): string {
|
|
187
|
+
// return `
|
|
188
|
+
// ## Available Research Tools:
|
|
189
|
+
// 1. **get_cache_context7**: Get cached Context7 content using cache file path
|
|
190
|
+
// - Input: cacheKey (string) - e.g., 'react-hooks' or 'docs/_cache/react-hooks.json'
|
|
191
|
+
// - Returns: Cached Context7 documentation content
|
|
192
|
+
// 2. **get_documentation**: Get documentation file content from docs directory
|
|
193
|
+
// - Input: docKey (string) - e.g., 'components' or 'docs/components.md'
|
|
194
|
+
// - Returns: Processed documentation file content
|
|
195
|
+
// 3. **list_cache_files**: List all available cached Context7 files
|
|
196
|
+
// - Input: filter (optional string) - Filter results by keyword
|
|
197
|
+
// - Returns: List of available cache files
|
|
198
|
+
// 4. **list_documentation_files**: List all available documentation files
|
|
199
|
+
// - Input: filter (optional string) - Filter results by keyword
|
|
200
|
+
// - Returns: List of available documentation files
|
|
201
|
+
// ## Usage Strategy:
|
|
202
|
+
// 1. Use list_* tools first to discover available content
|
|
203
|
+
// 2. Use get_* tools to retrieve specific content
|
|
204
|
+
// 3. Combine with Context7 MCP tools for comprehensive research
|
|
205
|
+
// `;
|
|
206
|
+
// }
|
|
207
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { RetryConfig } from "../../types";
|
|
2
|
+
import { logger } from "../logger";
|
|
3
|
+
|
|
4
|
+
export class RetryHandler {
|
|
5
|
+
private getRetryConfig(): RetryConfig {
|
|
6
|
+
return {
|
|
7
|
+
maxAttempts: parseInt(process.env.AI_MAX_RETRY_ATTEMPTS || "3", 10),
|
|
8
|
+
baseDelay: parseInt(process.env.AI_RETRY_BASE_DELAY || "1000", 10),
|
|
9
|
+
maxDelay: parseInt(process.env.AI_RETRY_MAX_DELAY || "10000", 10),
|
|
10
|
+
backoffFactor: parseFloat(process.env.AI_RETRY_BACKOFF_FACTOR || "2"),
|
|
11
|
+
retryableErrors: [
|
|
12
|
+
"ECONNRESET",
|
|
13
|
+
"ENOTFOUND",
|
|
14
|
+
"ECONNREFUSED",
|
|
15
|
+
"ETIMEDOUT",
|
|
16
|
+
"NETWORK_ERROR",
|
|
17
|
+
"RATE_LIMIT",
|
|
18
|
+
"TEMPORARY_FAILURE",
|
|
19
|
+
"INTERNAL_ERROR",
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private shouldRetryError(error: unknown, retryableErrors: string[]): boolean {
|
|
25
|
+
if (!error) return false;
|
|
26
|
+
|
|
27
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
28
|
+
const errorName = error instanceof Error ? error.name : "";
|
|
29
|
+
|
|
30
|
+
return retryableErrors.some(
|
|
31
|
+
(retryableError) =>
|
|
32
|
+
errorMessage.toUpperCase().includes(retryableError) ||
|
|
33
|
+
errorName.toUpperCase().includes(retryableError)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private async delay(ms: number): Promise<void> {
|
|
38
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async executeWithRetry<T>(
|
|
42
|
+
operation: () => Promise<T>,
|
|
43
|
+
retryConfig?: Partial<RetryConfig>,
|
|
44
|
+
operationName: string = "AI operation"
|
|
45
|
+
): Promise<T> {
|
|
46
|
+
const finalRetryConfig = { ...this.getRetryConfig(), ...retryConfig };
|
|
47
|
+
const {
|
|
48
|
+
maxAttempts = 3,
|
|
49
|
+
baseDelay = 1000,
|
|
50
|
+
maxDelay = 10000,
|
|
51
|
+
backoffFactor = 2,
|
|
52
|
+
retryableErrors = [],
|
|
53
|
+
} = finalRetryConfig;
|
|
54
|
+
|
|
55
|
+
let lastError: unknown;
|
|
56
|
+
|
|
57
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
58
|
+
try {
|
|
59
|
+
return await operation();
|
|
60
|
+
} catch (error) {
|
|
61
|
+
lastError = error;
|
|
62
|
+
|
|
63
|
+
// Don't retry on the last attempt
|
|
64
|
+
if (attempt === maxAttempts) {
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Check if error is retryable
|
|
69
|
+
if (!this.shouldRetryError(error, retryableErrors)) {
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Calculate delay with exponential backoff
|
|
74
|
+
const delayMs = Math.min(
|
|
75
|
+
baseDelay * Math.pow(backoffFactor, attempt - 1),
|
|
76
|
+
maxDelay
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
logger.warn(
|
|
80
|
+
`${operationName} failed (attempt ${attempt}/${maxAttempts}), retrying in ${delayMs}ms: ${error}`
|
|
81
|
+
);
|
|
82
|
+
await this.delay(delayMs);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Throw the original error - NO rebuilding bullshit
|
|
87
|
+
throw lastError;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { streamText } from "ai";
|
|
2
|
+
import type { ToolSet } from "ai";
|
|
3
|
+
import {
|
|
4
|
+
AIConfig,
|
|
5
|
+
Task,
|
|
6
|
+
StreamingOptions,
|
|
7
|
+
RetryConfig,
|
|
8
|
+
ParsedAITask,
|
|
9
|
+
} from "../../types";
|
|
10
|
+
import { PromptBuilder } from "../prompt-builder";
|
|
11
|
+
import { formatStackForContext } from "../../utils/stack-formatter";
|
|
12
|
+
import {
|
|
13
|
+
TASK_BREAKDOWN_SYSTEM_PROMPT,
|
|
14
|
+
TASK_ENHANCEMENT_SYSTEM_PROMPT,
|
|
15
|
+
TASK_PLANNING_SYSTEM_PROMPT,
|
|
16
|
+
} from "../../prompts";
|
|
17
|
+
import { getContextBuilder } from "../../utils/ai-service-factory";
|
|
18
|
+
import { filesystemTools } from "./filesystem-tools";
|
|
19
|
+
import { BaseOperations } from "./base-operations";
|
|
20
|
+
import { AIOperationUtility } from "../../utils/ai-operation-utility";
|
|
21
|
+
import {
|
|
22
|
+
createStandardError,
|
|
23
|
+
TaskOMaticErrorCodes,
|
|
24
|
+
} from "../../utils/task-o-matic-error";
|
|
25
|
+
|
|
26
|
+
export class TaskOperations extends BaseOperations {
|
|
27
|
+
private aiOperationUtility = new AIOperationUtility();
|
|
28
|
+
async breakdownTask(
|
|
29
|
+
task: Task,
|
|
30
|
+
config?: Partial<AIConfig>,
|
|
31
|
+
promptOverride?: string,
|
|
32
|
+
userMessage?: string,
|
|
33
|
+
streamingOptions?: StreamingOptions,
|
|
34
|
+
retryConfig?: Partial<RetryConfig>,
|
|
35
|
+
fullContent?: string,
|
|
36
|
+
stackInfo?: string,
|
|
37
|
+
existingSubtasks?: Task[],
|
|
38
|
+
enableFilesystemTools?: boolean
|
|
39
|
+
): Promise<
|
|
40
|
+
Array<{ title: string; content: string; estimatedEffort?: string }>
|
|
41
|
+
> {
|
|
42
|
+
// Build prompt
|
|
43
|
+
let prompt: string;
|
|
44
|
+
if (promptOverride) {
|
|
45
|
+
prompt = promptOverride;
|
|
46
|
+
} else {
|
|
47
|
+
const variables: Record<string, string> = {
|
|
48
|
+
TASK_TITLE: task.title,
|
|
49
|
+
TASK_DESCRIPTION: task.description || "No description",
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
if (fullContent) {
|
|
53
|
+
variables.TASK_CONTENT = fullContent;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (existingSubtasks && existingSubtasks.length > 0) {
|
|
57
|
+
const existingSubtasksText = existingSubtasks
|
|
58
|
+
.map(
|
|
59
|
+
(subtask, index) =>
|
|
60
|
+
`${index + 1}. ${subtask.title}: ${
|
|
61
|
+
subtask.description || "No description"
|
|
62
|
+
}`
|
|
63
|
+
)
|
|
64
|
+
.join("\n");
|
|
65
|
+
variables.EXISTING_SUBTASKS = existingSubtasksText;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (stackInfo) {
|
|
69
|
+
variables.STACK_INFO = stackInfo;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const promptResult = PromptBuilder.buildPrompt({
|
|
73
|
+
name: "task-breakdown",
|
|
74
|
+
type: "user",
|
|
75
|
+
variables,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (!promptResult.success) {
|
|
79
|
+
throw createStandardError(
|
|
80
|
+
TaskOMaticErrorCodes.AI_OPERATION_FAILED,
|
|
81
|
+
`Failed to build task breakdown prompt: ${promptResult.error}`,
|
|
82
|
+
{
|
|
83
|
+
context: "Prompt building failed during task breakdown operation",
|
|
84
|
+
suggestions: [
|
|
85
|
+
"Verify prompt template exists",
|
|
86
|
+
"Check variable substitution",
|
|
87
|
+
],
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
prompt = promptResult.prompt!;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Execute AI operation with proper error handling
|
|
96
|
+
const result = await this.aiOperationUtility.executeAIOperation(
|
|
97
|
+
"Task breakdown",
|
|
98
|
+
async () => {
|
|
99
|
+
// Prepare tools if filesystem tools are enabled
|
|
100
|
+
const tools = enableFilesystemTools ? filesystemTools : undefined;
|
|
101
|
+
|
|
102
|
+
const response = await this.aiOperationUtility.streamTextWithTools(
|
|
103
|
+
TASK_BREAKDOWN_SYSTEM_PROMPT +
|
|
104
|
+
(enableFilesystemTools
|
|
105
|
+
? `
|
|
106
|
+
|
|
107
|
+
You have access to filesystem tools that allow you to:
|
|
108
|
+
- readFile: Read the contents of any file in the project
|
|
109
|
+
- listDirectory: List contents of directories
|
|
110
|
+
|
|
111
|
+
Use these tools to understand the project structure, existing code, and dependencies when breaking down tasks into subtasks.`
|
|
112
|
+
: ""),
|
|
113
|
+
userMessage || prompt,
|
|
114
|
+
config,
|
|
115
|
+
streamingOptions,
|
|
116
|
+
tools
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const parseResult = this.jsonParser.parseJSONFromResponse<
|
|
120
|
+
{ subtasks?: ParsedAITask[]; tasks?: ParsedAITask[] } | ParsedAITask[]
|
|
121
|
+
>(response);
|
|
122
|
+
|
|
123
|
+
if (!parseResult.success) {
|
|
124
|
+
throw createStandardError(
|
|
125
|
+
TaskOMaticErrorCodes.AI_OPERATION_FAILED,
|
|
126
|
+
parseResult.error || "Failed to parse task breakdown response",
|
|
127
|
+
{
|
|
128
|
+
context: "AI response parsing failed during task breakdown",
|
|
129
|
+
suggestions: [
|
|
130
|
+
"Check AI response format",
|
|
131
|
+
"Verify JSON structure",
|
|
132
|
+
],
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const parsed = parseResult.data;
|
|
138
|
+
let subtasksList: ParsedAITask[] = [];
|
|
139
|
+
|
|
140
|
+
// Handle various output formats (Array, { subtasks: [] }, { tasks: [] })
|
|
141
|
+
if (Array.isArray(parsed)) {
|
|
142
|
+
subtasksList = parsed;
|
|
143
|
+
} else if (parsed && typeof parsed === "object") {
|
|
144
|
+
subtasksList = parsed.subtasks || parsed.tasks || [];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return subtasksList.map((subtask: ParsedAITask) => ({
|
|
148
|
+
title: subtask.title,
|
|
149
|
+
content: subtask.description || subtask.content || "",
|
|
150
|
+
estimatedEffort: subtask.effort,
|
|
151
|
+
}));
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
streamingOptions,
|
|
155
|
+
retryConfig,
|
|
156
|
+
aiConfig: config,
|
|
157
|
+
maxRetries: retryConfig?.maxAttempts || 2,
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
// Return the result directly (errors are thrown, not returned)
|
|
162
|
+
return result.result;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async enhanceTask(
|
|
166
|
+
title: string,
|
|
167
|
+
description?: string,
|
|
168
|
+
config?: Partial<AIConfig>,
|
|
169
|
+
promptOverride?: string,
|
|
170
|
+
userMessage?: string,
|
|
171
|
+
taskId?: string,
|
|
172
|
+
streamingOptions?: StreamingOptions,
|
|
173
|
+
retryConfig?: Partial<RetryConfig>
|
|
174
|
+
): Promise<string> {
|
|
175
|
+
// Build context
|
|
176
|
+
let contextInfo = "";
|
|
177
|
+
let prdContent = "";
|
|
178
|
+
|
|
179
|
+
if (taskId) {
|
|
180
|
+
const contextBuilder = getContextBuilder();
|
|
181
|
+
try {
|
|
182
|
+
const context = await contextBuilder.buildContext(taskId);
|
|
183
|
+
if (context.documentation || context.stack || context.prdContent) {
|
|
184
|
+
contextInfo = "\n\nAvailable Context:\n";
|
|
185
|
+
|
|
186
|
+
if (context.stack) {
|
|
187
|
+
contextInfo += formatStackForContext(context.stack) + "\n";
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (context.documentation) {
|
|
191
|
+
contextInfo += `Documentation Available: ${context.documentation.recap}\n`;
|
|
192
|
+
if (context.documentation.files.length > 0) {
|
|
193
|
+
contextInfo += `Documentation Files: ${context.documentation.files
|
|
194
|
+
.map((f) => f.path)
|
|
195
|
+
.join(", ")}\n`;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (context.prdContent) {
|
|
200
|
+
prdContent = context.prdContent;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
} catch (error) {
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Build prompt
|
|
209
|
+
let prompt: string;
|
|
210
|
+
if (promptOverride) {
|
|
211
|
+
prompt = promptOverride;
|
|
212
|
+
} else {
|
|
213
|
+
const promptResult = PromptBuilder.buildPrompt({
|
|
214
|
+
name: "task-enhancement",
|
|
215
|
+
type: "user",
|
|
216
|
+
variables: {
|
|
217
|
+
TASK_TITLE: title,
|
|
218
|
+
TASK_DESCRIPTION: description || "None",
|
|
219
|
+
CONTEXT_INFO: contextInfo,
|
|
220
|
+
PRD_CONTENT: prdContent || "No PRD content available",
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
if (!promptResult.success) {
|
|
225
|
+
throw createStandardError(
|
|
226
|
+
TaskOMaticErrorCodes.AI_OPERATION_FAILED,
|
|
227
|
+
`Failed to build task enhancement prompt: ${promptResult.error}`,
|
|
228
|
+
{
|
|
229
|
+
context: "Prompt building failed during task enhancement operation",
|
|
230
|
+
suggestions: [
|
|
231
|
+
"Verify prompt template exists",
|
|
232
|
+
"Check variable substitution",
|
|
233
|
+
],
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
prompt = promptResult.prompt!;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Execute AI operation with proper error handling
|
|
242
|
+
const result = await this.aiOperationUtility.executeAIOperation(
|
|
243
|
+
"Task enhancement",
|
|
244
|
+
async () => {
|
|
245
|
+
return await this.aiOperationUtility.streamText(
|
|
246
|
+
"",
|
|
247
|
+
config,
|
|
248
|
+
TASK_ENHANCEMENT_SYSTEM_PROMPT,
|
|
249
|
+
userMessage || prompt,
|
|
250
|
+
streamingOptions,
|
|
251
|
+
{ maxAttempts: 1 }
|
|
252
|
+
);
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
streamingOptions,
|
|
256
|
+
retryConfig,
|
|
257
|
+
aiConfig: config,
|
|
258
|
+
maxRetries: retryConfig?.maxAttempts || 2,
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
// Return the result directly (errors are thrown, not returned)
|
|
263
|
+
return result.result;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
async planTask(
|
|
267
|
+
taskContext: string,
|
|
268
|
+
taskDetails: string,
|
|
269
|
+
config?: Partial<AIConfig>,
|
|
270
|
+
promptOverride?: string,
|
|
271
|
+
userMessage?: string,
|
|
272
|
+
streamingOptions?: StreamingOptions,
|
|
273
|
+
retryConfig?: Partial<RetryConfig>
|
|
274
|
+
): Promise<string> {
|
|
275
|
+
// Build prompt
|
|
276
|
+
let prompt: string;
|
|
277
|
+
if (promptOverride) {
|
|
278
|
+
prompt = promptOverride;
|
|
279
|
+
} else {
|
|
280
|
+
const promptResult = PromptBuilder.buildPrompt({
|
|
281
|
+
name: "task-planning",
|
|
282
|
+
type: "user",
|
|
283
|
+
variables: {
|
|
284
|
+
TASK_CONTEXT: taskContext,
|
|
285
|
+
TASK_DETAILS: taskDetails,
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
if (!promptResult.success) {
|
|
290
|
+
throw createStandardError(
|
|
291
|
+
TaskOMaticErrorCodes.AI_OPERATION_FAILED,
|
|
292
|
+
`Failed to build task planning prompt: ${promptResult.error}`,
|
|
293
|
+
{
|
|
294
|
+
context: "Prompt building failed during task planning operation",
|
|
295
|
+
suggestions: [
|
|
296
|
+
"Verify prompt template exists",
|
|
297
|
+
"Check variable substitution",
|
|
298
|
+
],
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
prompt = promptResult.prompt!;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Execute AI operation with proper error handling
|
|
307
|
+
const result = await this.aiOperationUtility.executeAIOperation(
|
|
308
|
+
"Task planning",
|
|
309
|
+
async () => {
|
|
310
|
+
const mcpTools = await this.context7Client.getMCPTools();
|
|
311
|
+
const allTools = {
|
|
312
|
+
...(mcpTools as ToolSet),
|
|
313
|
+
...filesystemTools,
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
return await this.aiOperationUtility.streamTextWithTools(
|
|
317
|
+
TASK_PLANNING_SYSTEM_PROMPT +
|
|
318
|
+
`
|
|
319
|
+
|
|
320
|
+
You have access to filesystem tools that allow you to:
|
|
321
|
+
- readFile: Read the contents of any file in the project
|
|
322
|
+
- listDirectory: List contents of directories
|
|
323
|
+
|
|
324
|
+
Use these tools to understand the project structure, existing code, and dependencies when creating implementation plans.`,
|
|
325
|
+
userMessage || prompt,
|
|
326
|
+
config,
|
|
327
|
+
streamingOptions,
|
|
328
|
+
allTools
|
|
329
|
+
);
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
streamingOptions,
|
|
333
|
+
retryConfig,
|
|
334
|
+
aiConfig: config,
|
|
335
|
+
maxRetries: retryConfig?.maxAttempts || 2,
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
// Return the result directly (errors are thrown, not returned)
|
|
340
|
+
return result.result;
|
|
341
|
+
}
|
|
342
|
+
}
|