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,298 @@
|
|
|
1
|
+
import { AIConfig, StreamingOptions } from "../types";
|
|
2
|
+
import { getAIOperations } from "../utils/ai-service-factory";
|
|
3
|
+
import { buildAIConfig, AIOptions } from "../utils/ai-config-builder";
|
|
4
|
+
import { configManager } from "../lib/config";
|
|
5
|
+
import { PromptBuilder } from "../lib/prompt-builder";
|
|
6
|
+
import {
|
|
7
|
+
createStandardError,
|
|
8
|
+
TaskOMaticErrorCodes,
|
|
9
|
+
} from "../utils/task-o-matic-error";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* WorkflowAIAssistant - AI-powered decision making for workflow steps
|
|
13
|
+
* Helps users make configuration choices using natural language
|
|
14
|
+
*/
|
|
15
|
+
export class WorkflowAIAssistant {
|
|
16
|
+
/**
|
|
17
|
+
* Assist with initialization and bootstrap configuration
|
|
18
|
+
*/
|
|
19
|
+
async assistInitConfig(input: {
|
|
20
|
+
userDescription: string;
|
|
21
|
+
aiOptions?: AIOptions;
|
|
22
|
+
streamingOptions?: StreamingOptions;
|
|
23
|
+
}): Promise<{
|
|
24
|
+
projectName: string;
|
|
25
|
+
aiProvider: string;
|
|
26
|
+
aiModel: string;
|
|
27
|
+
frontend?: string;
|
|
28
|
+
backend?: string;
|
|
29
|
+
database?: string;
|
|
30
|
+
auth?: boolean;
|
|
31
|
+
reasoning: string;
|
|
32
|
+
}> {
|
|
33
|
+
const aiConfig = buildAIConfig(input.aiOptions);
|
|
34
|
+
|
|
35
|
+
const promptResult = PromptBuilder.buildPrompt({
|
|
36
|
+
name: "project-init-suggestion",
|
|
37
|
+
type: "user",
|
|
38
|
+
variables: {
|
|
39
|
+
USER_DESCRIPTION: input.userDescription,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (!promptResult.success) {
|
|
44
|
+
throw createStandardError(
|
|
45
|
+
TaskOMaticErrorCodes.CONFIGURATION_ERROR,
|
|
46
|
+
`Failed to build project init prompt: ${promptResult.error}`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const systemPromptResult = PromptBuilder.buildPrompt({
|
|
51
|
+
name: "project-init-suggestion",
|
|
52
|
+
type: "system",
|
|
53
|
+
variables: {},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const result = await getAIOperations().streamText(
|
|
57
|
+
promptResult.prompt!,
|
|
58
|
+
aiConfig,
|
|
59
|
+
systemPromptResult.prompt,
|
|
60
|
+
undefined,
|
|
61
|
+
input.streamingOptions
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// Parse AI response
|
|
65
|
+
try {
|
|
66
|
+
const jsonMatch = result.match(/\{[\s\S]*\}/);
|
|
67
|
+
if (!jsonMatch) {
|
|
68
|
+
throw createStandardError(
|
|
69
|
+
TaskOMaticErrorCodes.AI_OPERATION_FAILED,
|
|
70
|
+
"No JSON found in AI response for init config",
|
|
71
|
+
{
|
|
72
|
+
context: "The AI did not return a valid JSON object.",
|
|
73
|
+
suggestions: [
|
|
74
|
+
"Try a different model or provider.",
|
|
75
|
+
"Check the prompt for clarity.",
|
|
76
|
+
],
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return JSON.parse(jsonMatch[0]);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
// Fallback to sensible defaults
|
|
83
|
+
return {
|
|
84
|
+
projectName: "my-project",
|
|
85
|
+
aiProvider: "openrouter",
|
|
86
|
+
aiModel: "anthropic/claude-3.5-sonnet",
|
|
87
|
+
frontend: "next",
|
|
88
|
+
backend: "hono",
|
|
89
|
+
database: "sqlite",
|
|
90
|
+
auth: true,
|
|
91
|
+
reasoning: "Using modern, well-supported defaults",
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Generate a PRD from user's product description
|
|
98
|
+
*/
|
|
99
|
+
async assistPRDCreation(input: {
|
|
100
|
+
userDescription: string;
|
|
101
|
+
aiOptions?: AIOptions;
|
|
102
|
+
streamingOptions?: StreamingOptions;
|
|
103
|
+
}): Promise<string> {
|
|
104
|
+
const aiConfig = buildAIConfig(input.aiOptions);
|
|
105
|
+
|
|
106
|
+
return getAIOperations().generatePRD(
|
|
107
|
+
input.userDescription,
|
|
108
|
+
aiConfig,
|
|
109
|
+
undefined,
|
|
110
|
+
undefined,
|
|
111
|
+
input.streamingOptions
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Suggest improvements to an existing PRD
|
|
117
|
+
*/
|
|
118
|
+
async assistPRDRefinement(input: {
|
|
119
|
+
currentPRD: string;
|
|
120
|
+
userFeedback: string;
|
|
121
|
+
aiOptions?: AIOptions;
|
|
122
|
+
streamingOptions?: StreamingOptions;
|
|
123
|
+
}): Promise<string> {
|
|
124
|
+
const aiConfig = buildAIConfig(input.aiOptions);
|
|
125
|
+
|
|
126
|
+
const promptResult = PromptBuilder.buildPrompt({
|
|
127
|
+
name: "prd-improvement",
|
|
128
|
+
type: "user",
|
|
129
|
+
variables: {
|
|
130
|
+
CURRENT_PRD: input.currentPRD,
|
|
131
|
+
USER_FEEDBACK: input.userFeedback,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (!promptResult.success) {
|
|
136
|
+
throw createStandardError(
|
|
137
|
+
TaskOMaticErrorCodes.CONFIGURATION_ERROR,
|
|
138
|
+
`Failed to build PRD improvement prompt: ${promptResult.error}`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const systemPromptResult = PromptBuilder.buildPrompt({
|
|
143
|
+
name: "prd-improvement",
|
|
144
|
+
type: "system",
|
|
145
|
+
variables: {},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const result = await getAIOperations().streamText(
|
|
149
|
+
promptResult.prompt!,
|
|
150
|
+
aiConfig,
|
|
151
|
+
systemPromptResult.prompt,
|
|
152
|
+
undefined,
|
|
153
|
+
input.streamingOptions
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Help prioritize and organize tasks
|
|
161
|
+
*/
|
|
162
|
+
async assistTaskPrioritization(input: {
|
|
163
|
+
tasks: Array<{ id: string; title: string; description?: string }>;
|
|
164
|
+
userGuidance: string;
|
|
165
|
+
aiOptions?: AIOptions;
|
|
166
|
+
streamingOptions?: StreamingOptions;
|
|
167
|
+
}): Promise<{
|
|
168
|
+
prioritizedTasks: Array<{
|
|
169
|
+
id: string;
|
|
170
|
+
priority: number;
|
|
171
|
+
reasoning: string;
|
|
172
|
+
}>;
|
|
173
|
+
recommendations: string;
|
|
174
|
+
}> {
|
|
175
|
+
const aiConfig = buildAIConfig(input.aiOptions);
|
|
176
|
+
|
|
177
|
+
const tasksDescription = input.tasks
|
|
178
|
+
.map(
|
|
179
|
+
(t, i) =>
|
|
180
|
+
`${i + 1}. [${t.id}] ${t.title}${
|
|
181
|
+
t.description ? `: ${t.description}` : ""
|
|
182
|
+
}`
|
|
183
|
+
)
|
|
184
|
+
.join("\n");
|
|
185
|
+
|
|
186
|
+
const promptResult = PromptBuilder.buildPrompt({
|
|
187
|
+
name: "task-prioritization",
|
|
188
|
+
type: "user",
|
|
189
|
+
variables: {
|
|
190
|
+
TASKS_DESCRIPTION: tasksDescription,
|
|
191
|
+
USER_GUIDANCE: input.userGuidance,
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
if (!promptResult.success) {
|
|
196
|
+
throw createStandardError(
|
|
197
|
+
TaskOMaticErrorCodes.CONFIGURATION_ERROR,
|
|
198
|
+
`Failed to build task prioritization prompt: ${promptResult.error}`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const systemPromptResult = PromptBuilder.buildPrompt({
|
|
203
|
+
name: "task-prioritization",
|
|
204
|
+
type: "system",
|
|
205
|
+
variables: {},
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
const result = await getAIOperations().streamText(
|
|
209
|
+
promptResult.prompt!,
|
|
210
|
+
aiConfig,
|
|
211
|
+
systemPromptResult.prompt,
|
|
212
|
+
undefined,
|
|
213
|
+
input.streamingOptions
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
// Parse AI response
|
|
217
|
+
try {
|
|
218
|
+
const jsonMatch = result.match(/\{[\s\S]*\}/);
|
|
219
|
+
if (!jsonMatch) {
|
|
220
|
+
throw createStandardError(
|
|
221
|
+
TaskOMaticErrorCodes.AI_OPERATION_FAILED,
|
|
222
|
+
"No JSON found in AI response for task prioritization",
|
|
223
|
+
{
|
|
224
|
+
context: "The AI did not return a valid JSON object.",
|
|
225
|
+
suggestions: [
|
|
226
|
+
"Try a different model or provider.",
|
|
227
|
+
"Check the prompt for clarity.",
|
|
228
|
+
],
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
return JSON.parse(jsonMatch[0]);
|
|
233
|
+
} catch (error) {
|
|
234
|
+
// Fallback: return tasks in original order
|
|
235
|
+
return {
|
|
236
|
+
prioritizedTasks: input.tasks.map((t, i) => ({
|
|
237
|
+
id: t.id,
|
|
238
|
+
priority: i + 1,
|
|
239
|
+
reasoning: "Default ordering",
|
|
240
|
+
})),
|
|
241
|
+
recommendations: "Review and adjust priorities as needed",
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Generate custom instructions for task splitting
|
|
248
|
+
*/
|
|
249
|
+
async assistTaskSplitting(input: {
|
|
250
|
+
taskTitle: string;
|
|
251
|
+
taskContent?: string;
|
|
252
|
+
userGuidance: string;
|
|
253
|
+
aiOptions?: AIOptions;
|
|
254
|
+
streamingOptions?: StreamingOptions;
|
|
255
|
+
}): Promise<string> {
|
|
256
|
+
const aiConfig = buildAIConfig(input.aiOptions);
|
|
257
|
+
|
|
258
|
+
const taskContentText = input.taskContent
|
|
259
|
+
? `Description: ${input.taskContent}`
|
|
260
|
+
: "";
|
|
261
|
+
|
|
262
|
+
const promptResult = PromptBuilder.buildPrompt({
|
|
263
|
+
name: "task-splitting-assistance",
|
|
264
|
+
type: "user",
|
|
265
|
+
variables: {
|
|
266
|
+
TASK_TITLE: input.taskTitle,
|
|
267
|
+
TASK_CONTENT: taskContentText,
|
|
268
|
+
USER_GUIDANCE: input.userGuidance,
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
if (!promptResult.success) {
|
|
273
|
+
throw createStandardError(
|
|
274
|
+
TaskOMaticErrorCodes.CONFIGURATION_ERROR,
|
|
275
|
+
`Failed to build task splitting prompt: ${promptResult.error}`
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const systemPromptResult = PromptBuilder.buildPrompt({
|
|
280
|
+
name: "task-splitting-assistance",
|
|
281
|
+
type: "system",
|
|
282
|
+
variables: {},
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
const result = await getAIOperations().streamText(
|
|
286
|
+
promptResult.prompt!,
|
|
287
|
+
aiConfig,
|
|
288
|
+
systemPromptResult.prompt,
|
|
289
|
+
undefined,
|
|
290
|
+
input.streamingOptions
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Export singleton instance
|
|
298
|
+
export const workflowAIAssistant = new WorkflowAIAssistant();
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { join, resolve } from "path";
|
|
2
|
+
import { existsSync, mkdirSync, rmSync } from "fs";
|
|
3
|
+
import { workflowService } from "./workflow";
|
|
4
|
+
import { AIOptions } from "../utils/ai-config-builder";
|
|
5
|
+
import { StreamingOptions, Task } from "../types";
|
|
6
|
+
import { WorkflowBenchmarkInput, WorkflowBenchmarkResult } from "../lib/benchmark/types";
|
|
7
|
+
import { WorkflowAutomationOptions } from "../types/workflow-options";
|
|
8
|
+
import { logger } from "../lib/logger";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* WorkflowBenchmarkService - Executes complete workflows for benchmarking
|
|
12
|
+
* Creates isolated environments for each model to ensure fair comparison
|
|
13
|
+
*/
|
|
14
|
+
export class WorkflowBenchmarkService {
|
|
15
|
+
/**
|
|
16
|
+
* Execute a complete workflow for benchmarking purposes
|
|
17
|
+
*/
|
|
18
|
+
async executeWorkflow(
|
|
19
|
+
input: WorkflowBenchmarkInput,
|
|
20
|
+
aiOptions: AIOptions,
|
|
21
|
+
streamingOptions?: StreamingOptions
|
|
22
|
+
): Promise<WorkflowBenchmarkResult["output"]> {
|
|
23
|
+
const startTime = Date.now();
|
|
24
|
+
|
|
25
|
+
// Create temporary project directory for this benchmark run
|
|
26
|
+
const tempProjectDir = this.createTempProjectDir(
|
|
27
|
+
input.tempDirBase || "/tmp",
|
|
28
|
+
input.collectedResponses.projectName,
|
|
29
|
+
aiOptions.aiProvider || "unknown",
|
|
30
|
+
aiOptions.aiModel || "unknown"
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const stats = {
|
|
34
|
+
initDuration: 0,
|
|
35
|
+
prdGenerationDuration: 0,
|
|
36
|
+
prdRefinementDuration: 0,
|
|
37
|
+
taskGenerationDuration: 0,
|
|
38
|
+
taskSplittingDuration: 0,
|
|
39
|
+
totalTasks: 0,
|
|
40
|
+
tasksWithSubtasks: 0,
|
|
41
|
+
avgTaskComplexity: 0,
|
|
42
|
+
prdSize: 0,
|
|
43
|
+
totalSteps: 0,
|
|
44
|
+
successfulSteps: 0,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
let projectDir = tempProjectDir;
|
|
48
|
+
let prdFile = "";
|
|
49
|
+
let prdContent = "";
|
|
50
|
+
let tasks: Task[] = [];
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
// Step 1: Initialize Project
|
|
54
|
+
const stepStart = Date.now();
|
|
55
|
+
stats.totalSteps++;
|
|
56
|
+
|
|
57
|
+
const initResult = await workflowService.initializeProject({
|
|
58
|
+
projectName: input.collectedResponses.projectName,
|
|
59
|
+
projectDir: tempProjectDir,
|
|
60
|
+
initMethod: input.collectedResponses.initMethod,
|
|
61
|
+
projectDescription: input.collectedResponses.projectDescription,
|
|
62
|
+
aiOptions,
|
|
63
|
+
stackConfig: input.collectedResponses.stackConfig,
|
|
64
|
+
bootstrap: true, // Always bootstrap for benchmark unless explicitly disabled
|
|
65
|
+
streamingOptions,
|
|
66
|
+
callbacks: {
|
|
67
|
+
onProgress: () => {}, // Silent for benchmarking
|
|
68
|
+
onError: () => {},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
stats.initDuration = Date.now() - stepStart;
|
|
73
|
+
stats.successfulSteps++;
|
|
74
|
+
projectDir = initResult.projectDir;
|
|
75
|
+
|
|
76
|
+
// Step 2: Define PRD
|
|
77
|
+
if (input.collectedResponses.prdMethod !== "skip") {
|
|
78
|
+
const prdStart = Date.now();
|
|
79
|
+
stats.totalSteps++;
|
|
80
|
+
|
|
81
|
+
const prdResult = await workflowService.definePRD({
|
|
82
|
+
method: input.collectedResponses.prdMethod,
|
|
83
|
+
prdFile: input.collectedResponses.prdFile,
|
|
84
|
+
prdDescription: input.collectedResponses.prdDescription,
|
|
85
|
+
prdContent: input.collectedResponses.prdContent,
|
|
86
|
+
projectDir,
|
|
87
|
+
aiOptions,
|
|
88
|
+
streamingOptions,
|
|
89
|
+
callbacks: {
|
|
90
|
+
onProgress: () => {},
|
|
91
|
+
onError: () => {},
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
stats.prdGenerationDuration = Date.now() - prdStart;
|
|
96
|
+
stats.successfulSteps++;
|
|
97
|
+
prdFile = prdResult.prdFile;
|
|
98
|
+
prdContent = prdResult.prdContent;
|
|
99
|
+
stats.prdSize = prdContent.length;
|
|
100
|
+
|
|
101
|
+
// Step 3: Refine PRD (if requested)
|
|
102
|
+
if (input.collectedResponses.refinePrd && input.collectedResponses.refineFeedback) {
|
|
103
|
+
const refineStart = Date.now();
|
|
104
|
+
stats.totalSteps++;
|
|
105
|
+
|
|
106
|
+
const refineResult = await workflowService.refinePRD({
|
|
107
|
+
method: "ai",
|
|
108
|
+
prdFile,
|
|
109
|
+
feedback: input.collectedResponses.refineFeedback,
|
|
110
|
+
projectDir,
|
|
111
|
+
aiOptions,
|
|
112
|
+
streamingOptions,
|
|
113
|
+
callbacks: {
|
|
114
|
+
onProgress: () => {},
|
|
115
|
+
onError: () => {},
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
stats.prdRefinementDuration = Date.now() - refineStart;
|
|
120
|
+
stats.successfulSteps++;
|
|
121
|
+
prdContent = refineResult.prdContent;
|
|
122
|
+
stats.prdSize = prdContent.length;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Step 4: Generate Tasks
|
|
126
|
+
if (input.collectedResponses.generateTasks !== false && prdFile) {
|
|
127
|
+
const tasksStart = Date.now();
|
|
128
|
+
stats.totalSteps++;
|
|
129
|
+
|
|
130
|
+
const tasksResult = await workflowService.generateTasks({
|
|
131
|
+
prdFile,
|
|
132
|
+
method: input.collectedResponses.customInstructions ? "ai" : "standard",
|
|
133
|
+
customInstructions: input.collectedResponses.customInstructions,
|
|
134
|
+
projectDir,
|
|
135
|
+
aiOptions,
|
|
136
|
+
streamingOptions,
|
|
137
|
+
callbacks: {
|
|
138
|
+
onProgress: () => {},
|
|
139
|
+
onError: () => {},
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
stats.taskGenerationDuration = Date.now() - tasksStart;
|
|
144
|
+
stats.successfulSteps++;
|
|
145
|
+
tasks = tasksResult.tasks;
|
|
146
|
+
stats.totalTasks = tasks.length;
|
|
147
|
+
|
|
148
|
+
// Step 5: Split Tasks (if requested)
|
|
149
|
+
if (input.collectedResponses.splitTasks && tasks.length > 0) {
|
|
150
|
+
const splitStart = Date.now();
|
|
151
|
+
stats.totalSteps++;
|
|
152
|
+
|
|
153
|
+
const tasksToSplit = input.collectedResponses.tasksToSplit?.length
|
|
154
|
+
? input.collectedResponses.tasksToSplit
|
|
155
|
+
: tasks.slice(0, Math.min(3, tasks.length)).map(t => t.id); // Split first 3 tasks by default
|
|
156
|
+
|
|
157
|
+
const splitResult = await workflowService.splitTasks({
|
|
158
|
+
taskIds: tasksToSplit,
|
|
159
|
+
splitMethod: input.collectedResponses.splitInstructions ? "custom" : "standard",
|
|
160
|
+
customInstructions: input.collectedResponses.splitInstructions,
|
|
161
|
+
aiOptions,
|
|
162
|
+
streamingOptions,
|
|
163
|
+
callbacks: {
|
|
164
|
+
onProgress: () => {},
|
|
165
|
+
onError: () => {},
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
stats.taskSplittingDuration = Date.now() - splitStart;
|
|
170
|
+
stats.successfulSteps++;
|
|
171
|
+
stats.tasksWithSubtasks = splitResult.results.filter(r => !r.error && r.subtasks.length > 0).length;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Calculate complexity metrics
|
|
177
|
+
if (tasks.length > 0) {
|
|
178
|
+
const totalComplexity = tasks.reduce((sum, task) => {
|
|
179
|
+
const contentLength = (task.description || "").length;
|
|
180
|
+
return sum + (contentLength > 200 ? 3 : contentLength > 100 ? 2 : 1);
|
|
181
|
+
}, 0);
|
|
182
|
+
stats.avgTaskComplexity = totalComplexity / tasks.length;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
projectDir,
|
|
187
|
+
prdFile,
|
|
188
|
+
prdContent,
|
|
189
|
+
tasks,
|
|
190
|
+
stats,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
} finally {
|
|
194
|
+
// Clean up temporary directory
|
|
195
|
+
this.cleanupTempProjectDir(tempProjectDir);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Create a temporary project directory for benchmarking
|
|
201
|
+
*/
|
|
202
|
+
private createTempProjectDir(tempBase: string, projectName: string, provider: string, model: string): string {
|
|
203
|
+
const sanitizedModel = model.replace(/[^a-zA-Z0-9-]/g, "-");
|
|
204
|
+
const dirName = `benchmark-${projectName}-${provider}-${sanitizedModel}-${Date.now()}`;
|
|
205
|
+
const tempDir = join(tempBase, "task-o-matic-benchmark", dirName);
|
|
206
|
+
|
|
207
|
+
if (!existsSync(tempDir)) {
|
|
208
|
+
mkdirSync(tempDir, { recursive: true });
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return tempDir;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Clean up temporary project directory
|
|
216
|
+
*/
|
|
217
|
+
private cleanupTempProjectDir(projectDir: string): void {
|
|
218
|
+
try {
|
|
219
|
+
if (existsSync(projectDir) && projectDir.includes("task-o-matic-benchmark")) {
|
|
220
|
+
rmSync(projectDir, { recursive: true, force: true });
|
|
221
|
+
}
|
|
222
|
+
} catch (error) {
|
|
223
|
+
// Ignore cleanup errors
|
|
224
|
+
logger.warn(`Warning: Could not clean up temp directory ${projectDir}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Apply the results from a selected benchmark to the actual project
|
|
230
|
+
*/
|
|
231
|
+
async applyBenchmarkResult(
|
|
232
|
+
selectedResult: WorkflowBenchmarkResult,
|
|
233
|
+
targetProjectDir: string,
|
|
234
|
+
originalResponses: WorkflowBenchmarkInput["collectedResponses"]
|
|
235
|
+
): Promise<{ success: boolean; message: string }> {
|
|
236
|
+
try {
|
|
237
|
+
const { workflowService } = await import("./workflow");
|
|
238
|
+
const { writeFileSync, existsSync, mkdirSync } = await import("fs");
|
|
239
|
+
const { join } = await import("path");
|
|
240
|
+
|
|
241
|
+
// Ensure target directory exists
|
|
242
|
+
if (!existsSync(targetProjectDir)) {
|
|
243
|
+
mkdirSync(targetProjectDir, { recursive: true });
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Extract model configuration from modelId (e.g., "openai:gpt-4o")
|
|
247
|
+
const [provider, model] = selectedResult.modelId.split(":").slice(0, 2);
|
|
248
|
+
|
|
249
|
+
// Step 1: Initialize actual project with selected model
|
|
250
|
+
const actualResult = await workflowService.initializeProject({
|
|
251
|
+
projectName: originalResponses.projectName,
|
|
252
|
+
projectDir: targetProjectDir,
|
|
253
|
+
initMethod: originalResponses.initMethod,
|
|
254
|
+
projectDescription: originalResponses.projectDescription,
|
|
255
|
+
aiOptions: {
|
|
256
|
+
aiProvider: provider,
|
|
257
|
+
aiModel: model,
|
|
258
|
+
},
|
|
259
|
+
stackConfig: originalResponses.stackConfig,
|
|
260
|
+
bootstrap: true,
|
|
261
|
+
streamingOptions: {},
|
|
262
|
+
callbacks: {
|
|
263
|
+
onProgress: (msg) => {
|
|
264
|
+
const message = typeof msg === 'string' ? msg :
|
|
265
|
+
'message' in msg ? msg.message :
|
|
266
|
+
'text' in msg ? msg.text : 'Progress update';
|
|
267
|
+
logger.progress(` ${message}`);
|
|
268
|
+
},
|
|
269
|
+
onError: (err) => logger.error(` Error: ${err.message || err}`),
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// Step 2: Copy PRD content if available
|
|
274
|
+
if (selectedResult.output.prdContent && selectedResult.output.prdFile) {
|
|
275
|
+
const taskOMaticDir = join(targetProjectDir, ".task-o-matic", "prd");
|
|
276
|
+
if (!existsSync(taskOMaticDir)) {
|
|
277
|
+
mkdirSync(taskOMaticDir, { recursive: true });
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const targetPrdFile = join(taskOMaticDir, "prd.md");
|
|
281
|
+
writeFileSync(targetPrdFile, selectedResult.output.prdContent);
|
|
282
|
+
logger.success(` ✓ PRD copied to ${targetPrdFile}`);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Step 3: Import tasks if available
|
|
286
|
+
if (selectedResult.output.tasks && selectedResult.output.tasks.length > 0) {
|
|
287
|
+
const { getStorage } = await import("../utils/ai-service-factory");
|
|
288
|
+
|
|
289
|
+
// Switch to target directory context
|
|
290
|
+
process.chdir(targetProjectDir);
|
|
291
|
+
|
|
292
|
+
for (const task of selectedResult.output.tasks) {
|
|
293
|
+
try {
|
|
294
|
+
await getStorage().createTask(
|
|
295
|
+
{
|
|
296
|
+
title: task.title,
|
|
297
|
+
description: task.description || "",
|
|
298
|
+
content: task.description || "",
|
|
299
|
+
parentId: task.parentId,
|
|
300
|
+
estimatedEffort: task.estimatedEffort as "small" | "medium" | "large" | undefined,
|
|
301
|
+
}
|
|
302
|
+
);
|
|
303
|
+
} catch (error) {
|
|
304
|
+
logger.warn(` Warning: Could not import task "${task.title}"`);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
logger.success(` ✓ Imported ${selectedResult.output.tasks.length} tasks`);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return {
|
|
312
|
+
success: true,
|
|
313
|
+
message: `Successfully applied results from ${selectedResult.modelId} to ${targetProjectDir}`,
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
} catch (error) {
|
|
317
|
+
return {
|
|
318
|
+
success: false,
|
|
319
|
+
message: `Failed to apply benchmark results: ${error instanceof Error ? error.message : String(error)}`,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Validate workflow benchmark input
|
|
326
|
+
*/
|
|
327
|
+
validateInput(input: any): input is WorkflowBenchmarkInput {
|
|
328
|
+
return (
|
|
329
|
+
input &&
|
|
330
|
+
input.collectedResponses &&
|
|
331
|
+
typeof input.collectedResponses.projectName === "string" &&
|
|
332
|
+
input.collectedResponses.projectName.length > 0 &&
|
|
333
|
+
typeof input.collectedResponses.initMethod === "string" &&
|
|
334
|
+
["quick", "custom", "ai"].includes(input.collectedResponses.initMethod)
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export const workflowBenchmarkService = new WorkflowBenchmarkService();
|