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,307 @@
|
|
|
1
|
+
import { BenchmarkableOperation, WorkflowBenchmarkInput } from "./types";
|
|
2
|
+
import { prdService } from "../../services/prd";
|
|
3
|
+
import { taskService } from "../../services/tasks";
|
|
4
|
+
import { workflowBenchmarkService } from "../../services/workflow-benchmark";
|
|
5
|
+
import { AIOptions } from "../../utils/ai-config-builder";
|
|
6
|
+
import { StreamingOptions } from "../../types";
|
|
7
|
+
|
|
8
|
+
export class BenchmarkRegistry {
|
|
9
|
+
private operations: Map<string, BenchmarkableOperation> = new Map();
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
this.registerDefaults();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
register(op: BenchmarkableOperation) {
|
|
16
|
+
this.operations.set(op.id, op);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get(id: string): BenchmarkableOperation | undefined {
|
|
20
|
+
return this.operations.get(id);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
list(): BenchmarkableOperation[] {
|
|
24
|
+
return Array.from(this.operations.values());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private registerDefaults() {
|
|
28
|
+
// PRD Parsing Adapter
|
|
29
|
+
this.register({
|
|
30
|
+
id: "prd-parse",
|
|
31
|
+
name: "PRD Parsing",
|
|
32
|
+
description: "Parse a PRD file into tasks",
|
|
33
|
+
validateInput: (input: any) =>
|
|
34
|
+
typeof input.file === "string" && input.file.length > 0,
|
|
35
|
+
execute: async (
|
|
36
|
+
input: any,
|
|
37
|
+
aiOptions: AIOptions,
|
|
38
|
+
streamingOptions?: StreamingOptions
|
|
39
|
+
) => {
|
|
40
|
+
return await prdService.parsePRD({
|
|
41
|
+
file: input.file,
|
|
42
|
+
workingDirectory: input.workingDirectory,
|
|
43
|
+
enableFilesystemTools: input.tools,
|
|
44
|
+
promptOverride: input.prompt,
|
|
45
|
+
messageOverride: input.message,
|
|
46
|
+
aiOptions,
|
|
47
|
+
streamingOptions,
|
|
48
|
+
callbacks: {},
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// PRD Rework Adapter
|
|
54
|
+
this.register({
|
|
55
|
+
id: "prd-rework",
|
|
56
|
+
name: "PRD Rework",
|
|
57
|
+
description: "Rework a PRD based on feedback",
|
|
58
|
+
validateInput: (input: any) =>
|
|
59
|
+
typeof input.file === "string" && typeof input.feedback === "string",
|
|
60
|
+
execute: async (
|
|
61
|
+
input: any,
|
|
62
|
+
aiOptions: AIOptions,
|
|
63
|
+
streamingOptions?: StreamingOptions
|
|
64
|
+
) => {
|
|
65
|
+
return await prdService.reworkPRD({
|
|
66
|
+
file: input.file,
|
|
67
|
+
feedback: input.feedback,
|
|
68
|
+
workingDirectory: input.workingDirectory,
|
|
69
|
+
enableFilesystemTools: input.tools,
|
|
70
|
+
promptOverride: input.prompt,
|
|
71
|
+
messageOverride: input.message,
|
|
72
|
+
aiOptions,
|
|
73
|
+
streamingOptions,
|
|
74
|
+
callbacks: {},
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Task Breakdown Adapter
|
|
80
|
+
this.register({
|
|
81
|
+
id: "task-breakdown",
|
|
82
|
+
name: "Task Breakdown",
|
|
83
|
+
description: "Break down a task into subtasks",
|
|
84
|
+
validateInput: (input: any) => typeof input.taskId === "string",
|
|
85
|
+
execute: async (
|
|
86
|
+
input: any,
|
|
87
|
+
aiOptions: AIOptions,
|
|
88
|
+
streamingOptions?: StreamingOptions
|
|
89
|
+
) => {
|
|
90
|
+
return await taskService.splitTask(
|
|
91
|
+
input.taskId,
|
|
92
|
+
aiOptions,
|
|
93
|
+
input.prompt,
|
|
94
|
+
input.message,
|
|
95
|
+
streamingOptions, // streaming options
|
|
96
|
+
input.tools
|
|
97
|
+
);
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Workflow Full Execution
|
|
102
|
+
this.register({
|
|
103
|
+
id: "workflow-full",
|
|
104
|
+
name: "Complete Workflow",
|
|
105
|
+
description: "Execute the complete workflow: initialization, PRD creation, task generation, and splitting",
|
|
106
|
+
validateInput: (input: any) => workflowBenchmarkService.validateInput(input),
|
|
107
|
+
execute: async (
|
|
108
|
+
input: WorkflowBenchmarkInput,
|
|
109
|
+
aiOptions: AIOptions,
|
|
110
|
+
streamingOptions?: StreamingOptions
|
|
111
|
+
) => {
|
|
112
|
+
return await workflowBenchmarkService.executeWorkflow(
|
|
113
|
+
input,
|
|
114
|
+
aiOptions,
|
|
115
|
+
streamingOptions
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Task Create with AI Enhancement
|
|
121
|
+
this.register({
|
|
122
|
+
id: "task-create",
|
|
123
|
+
name: "Task Creation (AI-Enhanced)",
|
|
124
|
+
description: "Create a new task with AI enhancement using Context7 documentation",
|
|
125
|
+
validateInput: (input: any) =>
|
|
126
|
+
typeof input.title === "string" && input.title.length > 0,
|
|
127
|
+
execute: async (
|
|
128
|
+
input: any,
|
|
129
|
+
aiOptions: AIOptions,
|
|
130
|
+
streamingOptions?: StreamingOptions
|
|
131
|
+
) => {
|
|
132
|
+
return await taskService.createTask({
|
|
133
|
+
title: input.title,
|
|
134
|
+
content: input.content,
|
|
135
|
+
parentId: input.parentId,
|
|
136
|
+
effort: input.effort,
|
|
137
|
+
aiEnhance: true, // Always use AI enhancement for benchmarking
|
|
138
|
+
aiOptions,
|
|
139
|
+
streamingOptions,
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Task Enhancement
|
|
145
|
+
this.register({
|
|
146
|
+
id: "task-enhance",
|
|
147
|
+
name: "Task Enhancement",
|
|
148
|
+
description: "Enhance an existing task with AI using Context7 documentation",
|
|
149
|
+
validateInput: (input: any) => typeof input.taskId === "string",
|
|
150
|
+
execute: async (
|
|
151
|
+
input: any,
|
|
152
|
+
aiOptions: AIOptions,
|
|
153
|
+
streamingOptions?: StreamingOptions
|
|
154
|
+
) => {
|
|
155
|
+
return await taskService.enhanceTask(
|
|
156
|
+
input.taskId,
|
|
157
|
+
aiOptions,
|
|
158
|
+
streamingOptions
|
|
159
|
+
);
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// Task Planning
|
|
164
|
+
this.register({
|
|
165
|
+
id: "task-plan",
|
|
166
|
+
name: "Task Planning",
|
|
167
|
+
description: "Create a detailed implementation plan for a task",
|
|
168
|
+
validateInput: (input: any) => typeof input.taskId === "string",
|
|
169
|
+
execute: async (
|
|
170
|
+
input: any,
|
|
171
|
+
aiOptions: AIOptions,
|
|
172
|
+
streamingOptions?: StreamingOptions
|
|
173
|
+
) => {
|
|
174
|
+
return await taskService.planTask(
|
|
175
|
+
input.taskId,
|
|
176
|
+
aiOptions,
|
|
177
|
+
streamingOptions
|
|
178
|
+
);
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Task Documentation
|
|
183
|
+
this.register({
|
|
184
|
+
id: "task-document",
|
|
185
|
+
name: "Task Documentation",
|
|
186
|
+
description: "Analyze and generate documentation for a task",
|
|
187
|
+
validateInput: (input: any) => typeof input.taskId === "string",
|
|
188
|
+
execute: async (
|
|
189
|
+
input: any,
|
|
190
|
+
aiOptions: AIOptions,
|
|
191
|
+
streamingOptions?: StreamingOptions
|
|
192
|
+
) => {
|
|
193
|
+
return await taskService.documentTask(
|
|
194
|
+
input.taskId,
|
|
195
|
+
input.force || false,
|
|
196
|
+
aiOptions,
|
|
197
|
+
streamingOptions
|
|
198
|
+
);
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// PRD Creation
|
|
203
|
+
this.register({
|
|
204
|
+
id: "prd-create",
|
|
205
|
+
name: "PRD Creation",
|
|
206
|
+
description: "Generate a Product Requirements Document from a description",
|
|
207
|
+
validateInput: (input: any) =>
|
|
208
|
+
typeof input.description === "string" && input.description.length > 0,
|
|
209
|
+
execute: async (
|
|
210
|
+
input: any,
|
|
211
|
+
aiOptions: AIOptions,
|
|
212
|
+
streamingOptions?: StreamingOptions
|
|
213
|
+
) => {
|
|
214
|
+
return await prdService.generatePRD({
|
|
215
|
+
description: input.description,
|
|
216
|
+
outputDir: input.outputDir,
|
|
217
|
+
filename: input.filename,
|
|
218
|
+
aiOptions,
|
|
219
|
+
streamingOptions,
|
|
220
|
+
callbacks: {},
|
|
221
|
+
});
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// PRD Combine
|
|
226
|
+
this.register({
|
|
227
|
+
id: "prd-combine",
|
|
228
|
+
name: "PRD Combination",
|
|
229
|
+
description: "Combine multiple PRD files into a single master PRD",
|
|
230
|
+
validateInput: (input: any) =>
|
|
231
|
+
Array.isArray(input.prds) &&
|
|
232
|
+
input.prds.length > 0 &&
|
|
233
|
+
typeof input.originalDescription === "string",
|
|
234
|
+
execute: async (
|
|
235
|
+
input: any,
|
|
236
|
+
aiOptions: AIOptions,
|
|
237
|
+
streamingOptions?: StreamingOptions
|
|
238
|
+
) => {
|
|
239
|
+
return await prdService.combinePRDs({
|
|
240
|
+
prds: input.prds,
|
|
241
|
+
originalDescription: input.originalDescription,
|
|
242
|
+
outputDir: input.outputDir,
|
|
243
|
+
filename: input.filename,
|
|
244
|
+
aiOptions,
|
|
245
|
+
streamingOptions,
|
|
246
|
+
callbacks: {},
|
|
247
|
+
});
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// PRD Question Generation
|
|
252
|
+
this.register({
|
|
253
|
+
id: "prd-question",
|
|
254
|
+
name: "PRD Question Generation",
|
|
255
|
+
description: "Generate clarifying questions for a PRD",
|
|
256
|
+
validateInput: (input: any) =>
|
|
257
|
+
typeof input.file === "string" && input.file.length > 0,
|
|
258
|
+
execute: async (
|
|
259
|
+
input: any,
|
|
260
|
+
aiOptions: AIOptions,
|
|
261
|
+
streamingOptions?: StreamingOptions
|
|
262
|
+
) => {
|
|
263
|
+
return await prdService.generateQuestions({
|
|
264
|
+
file: input.file,
|
|
265
|
+
workingDirectory: input.workingDirectory,
|
|
266
|
+
enableFilesystemTools: input.tools,
|
|
267
|
+
promptOverride: input.prompt,
|
|
268
|
+
messageOverride: input.message,
|
|
269
|
+
aiOptions,
|
|
270
|
+
streamingOptions,
|
|
271
|
+
callbacks: {},
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// PRD Refinement
|
|
277
|
+
this.register({
|
|
278
|
+
id: "prd-refine",
|
|
279
|
+
name: "PRD Refinement",
|
|
280
|
+
description: "Refine a PRD by generating questions and incorporating answers",
|
|
281
|
+
validateInput: (input: any) =>
|
|
282
|
+
typeof input.file === "string" &&
|
|
283
|
+
input.file.length > 0 &&
|
|
284
|
+
typeof input.questionMode === "string" &&
|
|
285
|
+
(input.questionMode === "user" || input.questionMode === "ai"),
|
|
286
|
+
execute: async (
|
|
287
|
+
input: any,
|
|
288
|
+
aiOptions: AIOptions,
|
|
289
|
+
streamingOptions?: StreamingOptions
|
|
290
|
+
) => {
|
|
291
|
+
return await prdService.refinePRDWithQuestions({
|
|
292
|
+
file: input.file,
|
|
293
|
+
questionMode: input.questionMode,
|
|
294
|
+
answers: input.answers,
|
|
295
|
+
questionAIOptions: input.questionAIOptions,
|
|
296
|
+
workingDirectory: input.workingDirectory,
|
|
297
|
+
enableFilesystemTools: input.tools,
|
|
298
|
+
aiOptions,
|
|
299
|
+
streamingOptions,
|
|
300
|
+
callbacks: {},
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export const benchmarkRegistry = new BenchmarkRegistry();
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BenchmarkConfig,
|
|
3
|
+
BenchmarkResult,
|
|
4
|
+
BenchmarkRun,
|
|
5
|
+
BenchmarkProgressEvent,
|
|
6
|
+
} from "./types";
|
|
7
|
+
import { benchmarkRegistry } from "./registry";
|
|
8
|
+
import { benchmarkStorage } from "./storage";
|
|
9
|
+
import { AIConfig } from "../../types";
|
|
10
|
+
import { configManager } from "../config";
|
|
11
|
+
|
|
12
|
+
export class BenchmarkRunner {
|
|
13
|
+
async run(
|
|
14
|
+
operationId: string,
|
|
15
|
+
input: any,
|
|
16
|
+
config: BenchmarkConfig,
|
|
17
|
+
onProgress?: (event: BenchmarkProgressEvent) => void
|
|
18
|
+
): Promise<BenchmarkRun> {
|
|
19
|
+
const operation = benchmarkRegistry.get(operationId);
|
|
20
|
+
if (!operation) {
|
|
21
|
+
throw new Error(`Operation ${operationId} not found`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!operation.validateInput(input)) {
|
|
25
|
+
throw new Error(`Invalid input for operation ${operationId}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const runId = `run-${Date.now()}`;
|
|
29
|
+
const results: BenchmarkResult[] = [];
|
|
30
|
+
|
|
31
|
+
// Create a queue of models to process
|
|
32
|
+
const queue = [...config.models];
|
|
33
|
+
const activePromises: Promise<void>[] = [];
|
|
34
|
+
|
|
35
|
+
// Helper to process a single model
|
|
36
|
+
const processModel = async (modelConfig: any) => {
|
|
37
|
+
const modelId = `${modelConfig.provider}:${modelConfig.model}${
|
|
38
|
+
modelConfig.reasoningTokens
|
|
39
|
+
? `:reasoning=${modelConfig.reasoningTokens}`
|
|
40
|
+
: ""
|
|
41
|
+
}`;
|
|
42
|
+
|
|
43
|
+
const startTime = Date.now();
|
|
44
|
+
let output: any;
|
|
45
|
+
let error: string | undefined;
|
|
46
|
+
let tokenUsage:
|
|
47
|
+
| { prompt: number; completion: number; total: number }
|
|
48
|
+
| undefined;
|
|
49
|
+
let responseSize = 0;
|
|
50
|
+
let firstTokenTime: number | undefined;
|
|
51
|
+
|
|
52
|
+
// Emit start event
|
|
53
|
+
onProgress?.({ type: "start", modelId });
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
// Construct AI options for this specific run
|
|
57
|
+
const aiOptions: any = {
|
|
58
|
+
aiProvider: modelConfig.provider,
|
|
59
|
+
aiModel: modelConfig.model,
|
|
60
|
+
aiReasoning: modelConfig.reasoningTokens,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Setup streaming options to capture metrics
|
|
64
|
+
const streamingOptions = {
|
|
65
|
+
onFinish: async (result: any) => {
|
|
66
|
+
if (result.usage) {
|
|
67
|
+
tokenUsage = {
|
|
68
|
+
prompt:
|
|
69
|
+
result.usage.inputTokens || result.usage.promptTokens || 0,
|
|
70
|
+
completion:
|
|
71
|
+
result.usage.outputTokens ||
|
|
72
|
+
result.usage.completionTokens ||
|
|
73
|
+
0,
|
|
74
|
+
total: result.usage.totalTokens || 0,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Estimate response size from text length if available, or JSON stringify
|
|
78
|
+
if (result.text) {
|
|
79
|
+
responseSize = Buffer.byteLength(result.text, "utf8");
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
onChunk: (chunk: string) => {
|
|
83
|
+
if (chunk) {
|
|
84
|
+
if (!firstTokenTime) {
|
|
85
|
+
firstTokenTime = Date.now();
|
|
86
|
+
}
|
|
87
|
+
const chunkSize = Buffer.byteLength(chunk, "utf8");
|
|
88
|
+
responseSize += chunkSize;
|
|
89
|
+
|
|
90
|
+
const currentDuration = Date.now() - startTime;
|
|
91
|
+
const currentBps =
|
|
92
|
+
currentDuration > 0
|
|
93
|
+
? Math.round(responseSize / (currentDuration / 1000))
|
|
94
|
+
: 0;
|
|
95
|
+
|
|
96
|
+
onProgress?.({
|
|
97
|
+
type: "progress",
|
|
98
|
+
modelId,
|
|
99
|
+
currentSize: responseSize,
|
|
100
|
+
currentBps,
|
|
101
|
+
chunk: chunk,
|
|
102
|
+
duration: currentDuration,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Execute operation
|
|
109
|
+
output = await operation.execute(input, aiOptions, streamingOptions);
|
|
110
|
+
|
|
111
|
+
// If responseSize wasn't captured via streaming (e.g. non-streaming response), calculate from output
|
|
112
|
+
if (responseSize === 0 && output) {
|
|
113
|
+
const outputStr =
|
|
114
|
+
typeof output === "string" ? output : JSON.stringify(output);
|
|
115
|
+
responseSize = Buffer.byteLength(outputStr, "utf8");
|
|
116
|
+
}
|
|
117
|
+
} catch (e: any) {
|
|
118
|
+
error = e.message || String(e);
|
|
119
|
+
onProgress?.({ type: "error", modelId, error });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const duration = Date.now() - startTime;
|
|
123
|
+
const bps =
|
|
124
|
+
duration > 0 && responseSize > 0
|
|
125
|
+
? Math.round(responseSize / (duration / 1000))
|
|
126
|
+
: 0;
|
|
127
|
+
const tps =
|
|
128
|
+
duration > 0 && tokenUsage?.completion
|
|
129
|
+
? Math.round(tokenUsage.completion / (duration / 1000))
|
|
130
|
+
: 0;
|
|
131
|
+
|
|
132
|
+
results.push({
|
|
133
|
+
modelId,
|
|
134
|
+
output,
|
|
135
|
+
duration,
|
|
136
|
+
error,
|
|
137
|
+
timestamp: Date.now(),
|
|
138
|
+
tokenUsage,
|
|
139
|
+
responseSize,
|
|
140
|
+
bps,
|
|
141
|
+
tps,
|
|
142
|
+
timeToFirstToken: firstTokenTime
|
|
143
|
+
? firstTokenTime - startTime
|
|
144
|
+
: undefined,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// Emit complete event
|
|
148
|
+
onProgress?.({ type: "complete", modelId, duration });
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// Process queue with concurrency limit
|
|
152
|
+
while (queue.length > 0 || activePromises.length > 0) {
|
|
153
|
+
// Fill active promises up to concurrency limit
|
|
154
|
+
while (queue.length > 0 && activePromises.length < config.concurrency) {
|
|
155
|
+
const modelConfig = queue.shift();
|
|
156
|
+
if (modelConfig) {
|
|
157
|
+
const promise = processModel(modelConfig).then(() => {
|
|
158
|
+
// Remove self from active promises
|
|
159
|
+
activePromises.splice(activePromises.indexOf(promise), 1);
|
|
160
|
+
});
|
|
161
|
+
activePromises.push(promise);
|
|
162
|
+
|
|
163
|
+
// Add delay if configured and there are more items
|
|
164
|
+
if (config.delay > 0 && queue.length > 0) {
|
|
165
|
+
await new Promise((resolve) => setTimeout(resolve, config.delay));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Wait for at least one promise to complete if we're at capacity or queue is empty
|
|
171
|
+
if (activePromises.length > 0) {
|
|
172
|
+
await Promise.race(activePromises);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const run: BenchmarkRun = {
|
|
177
|
+
id: runId,
|
|
178
|
+
timestamp: Date.now(),
|
|
179
|
+
command: operationId,
|
|
180
|
+
input,
|
|
181
|
+
config,
|
|
182
|
+
results,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
benchmarkStorage.saveRun(run);
|
|
186
|
+
return run;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export const benchmarkRunner = new BenchmarkRunner();
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import {
|
|
3
|
+
existsSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
writeFileSync,
|
|
6
|
+
readFileSync,
|
|
7
|
+
readdirSync,
|
|
8
|
+
} from "fs";
|
|
9
|
+
import { configManager } from "../config";
|
|
10
|
+
import { BenchmarkRun } from "./types";
|
|
11
|
+
import { logger } from "../logger";
|
|
12
|
+
|
|
13
|
+
export class BenchmarkStorage {
|
|
14
|
+
private getBenchmarkDir(): string {
|
|
15
|
+
const taskOMaticDir = configManager.getTaskOMaticDir();
|
|
16
|
+
const benchmarkDir = join(taskOMaticDir, "benchmarks");
|
|
17
|
+
if (!existsSync(benchmarkDir)) {
|
|
18
|
+
mkdirSync(benchmarkDir, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
return benchmarkDir;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
saveRun(run: BenchmarkRun): string {
|
|
24
|
+
const dir = this.getBenchmarkDir();
|
|
25
|
+
const runDir = join(dir, run.id);
|
|
26
|
+
|
|
27
|
+
if (!existsSync(runDir)) {
|
|
28
|
+
mkdirSync(runDir, { recursive: true });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Save metadata
|
|
32
|
+
writeFileSync(
|
|
33
|
+
join(runDir, "metadata.json"),
|
|
34
|
+
JSON.stringify(
|
|
35
|
+
{
|
|
36
|
+
id: run.id,
|
|
37
|
+
timestamp: run.timestamp,
|
|
38
|
+
command: run.command,
|
|
39
|
+
config: run.config,
|
|
40
|
+
},
|
|
41
|
+
null,
|
|
42
|
+
2
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// Save input
|
|
47
|
+
writeFileSync(
|
|
48
|
+
join(runDir, "input.json"),
|
|
49
|
+
JSON.stringify(run.input, null, 2)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
// Save results
|
|
53
|
+
const resultsDir = join(runDir, "results");
|
|
54
|
+
if (!existsSync(resultsDir)) {
|
|
55
|
+
mkdirSync(resultsDir);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
run.results.forEach((result) => {
|
|
59
|
+
// Sanitize filename: replace : and / with -
|
|
60
|
+
const filename = result.modelId.replace(/[:\/]/g, "-") + ".json";
|
|
61
|
+
writeFileSync(
|
|
62
|
+
join(resultsDir, filename),
|
|
63
|
+
JSON.stringify(result, null, 2)
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return runDir;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getRun(id: string): BenchmarkRun | null {
|
|
71
|
+
const dir = this.getBenchmarkDir();
|
|
72
|
+
const runDir = join(dir, id);
|
|
73
|
+
|
|
74
|
+
if (!existsSync(runDir)) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
const metadata = JSON.parse(
|
|
80
|
+
readFileSync(join(runDir, "metadata.json"), "utf-8")
|
|
81
|
+
);
|
|
82
|
+
const input = JSON.parse(
|
|
83
|
+
readFileSync(join(runDir, "input.json"), "utf-8")
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const resultsDir = join(runDir, "results");
|
|
87
|
+
const results = [];
|
|
88
|
+
|
|
89
|
+
if (existsSync(resultsDir)) {
|
|
90
|
+
const files = readdirSync(resultsDir).filter((f) =>
|
|
91
|
+
f.endsWith(".json")
|
|
92
|
+
);
|
|
93
|
+
for (const file of files) {
|
|
94
|
+
results.push(
|
|
95
|
+
JSON.parse(readFileSync(join(resultsDir, file), "utf-8"))
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
...metadata,
|
|
102
|
+
input,
|
|
103
|
+
results,
|
|
104
|
+
};
|
|
105
|
+
} catch (error) {
|
|
106
|
+
logger.error(`Failed to load benchmark run ${id}: ${error}`);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
listRuns(): Array<{ id: string; timestamp: number; command: string }> {
|
|
112
|
+
const dir = this.getBenchmarkDir();
|
|
113
|
+
if (!existsSync(dir)) return [];
|
|
114
|
+
|
|
115
|
+
const runs = [];
|
|
116
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
117
|
+
|
|
118
|
+
for (const entry of entries) {
|
|
119
|
+
if (entry.isDirectory()) {
|
|
120
|
+
try {
|
|
121
|
+
const metadataPath = join(dir, entry.name, "metadata.json");
|
|
122
|
+
if (existsSync(metadataPath)) {
|
|
123
|
+
const metadata = JSON.parse(readFileSync(metadataPath, "utf-8"));
|
|
124
|
+
runs.push({
|
|
125
|
+
id: metadata.id,
|
|
126
|
+
timestamp: metadata.timestamp,
|
|
127
|
+
command: metadata.command,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
} catch (e) {
|
|
131
|
+
// Skip invalid runs
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return runs.sort((a, b) => b.timestamp - a.timestamp);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export const benchmarkStorage = new BenchmarkStorage();
|