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,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AIOperationUtility = void 0;
|
|
4
|
+
const ai_1 = require("ai");
|
|
5
|
+
const base_operations_1 = require("../lib/ai-service/base-operations");
|
|
6
|
+
const task_o_matic_error_1 = require("./task-o-matic-error");
|
|
7
|
+
/**
|
|
8
|
+
* AIOperationUtility - Centralized utility for AI operations with metrics and error handling
|
|
9
|
+
*
|
|
10
|
+
* Extends BaseOperations to inherit core AI functionality (streamText, model provider, etc.)
|
|
11
|
+
* and adds standardized metrics collection, error handling, and retry logic.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const utility = new AIOperationUtility();
|
|
16
|
+
*
|
|
17
|
+
* // Execute operation with metrics
|
|
18
|
+
* const result = await utility.executeAIOperation(
|
|
19
|
+
* "Task breakdown",
|
|
20
|
+
* async () => performBreakdown(task),
|
|
21
|
+
* {
|
|
22
|
+
* maxRetries: 3,
|
|
23
|
+
* streamingOptions: { onChunk: console.log }
|
|
24
|
+
* }
|
|
25
|
+
* );
|
|
26
|
+
*
|
|
27
|
+
* console.log(result.metrics.duration);
|
|
28
|
+
* console.log(result.metrics.timeToFirstToken);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
class AIOperationUtility extends base_operations_1.BaseOperations {
|
|
32
|
+
/**
|
|
33
|
+
* Execute an AI operation with standardized metrics, error handling, and streaming support
|
|
34
|
+
*
|
|
35
|
+
* This method wraps AI operations to provide:
|
|
36
|
+
* - Automatic retry logic with configurable attempts
|
|
37
|
+
* - Metrics collection (duration, token usage, time to first token)
|
|
38
|
+
* - Error handling with TaskOMaticError wrapping
|
|
39
|
+
* - Streaming support with metrics capture
|
|
40
|
+
*
|
|
41
|
+
* @param operationName - Human-readable name for the operation (used in errors)
|
|
42
|
+
* @param operation - The async operation to execute
|
|
43
|
+
* @param options - Configuration options for retry, streaming, and AI config
|
|
44
|
+
* @returns Promise resolving to AIOperationResult with result and metrics
|
|
45
|
+
* @throws {TaskOMaticError} If operation fails after all retry attempts
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* try {
|
|
50
|
+
* const result = await utility.executeAIOperation(
|
|
51
|
+
* "Task enhancement",
|
|
52
|
+
* async () => enhanceTask(task),
|
|
53
|
+
* { maxRetries: 2 }
|
|
54
|
+
* );
|
|
55
|
+
* console.log(`Operation took ${result.metrics.duration}ms`);
|
|
56
|
+
* } catch (error) {
|
|
57
|
+
* if (error instanceof TaskOMaticError) {
|
|
58
|
+
* console.error(error.getDetails());
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
async executeAIOperation(operationName, operation, options = {}) {
|
|
64
|
+
const startTime = Date.now();
|
|
65
|
+
let timeToFirstToken;
|
|
66
|
+
// Create wrapped streaming options to capture metrics
|
|
67
|
+
const wrappedStreamingOptions = this.wrapStreamingOptions(options.streamingOptions, startTime, (time) => {
|
|
68
|
+
timeToFirstToken = time;
|
|
69
|
+
});
|
|
70
|
+
try {
|
|
71
|
+
// Execute with retry logic
|
|
72
|
+
const result = await this.retryHandler.executeWithRetry(async () => {
|
|
73
|
+
// Execute operation - note: operations should use the streaming options
|
|
74
|
+
// passed through the closure, not directly from options
|
|
75
|
+
return await operation();
|
|
76
|
+
}, {
|
|
77
|
+
maxAttempts: options.maxRetries || options.retryConfig?.maxAttempts || 2,
|
|
78
|
+
...options.retryConfig,
|
|
79
|
+
}, operationName);
|
|
80
|
+
const duration = Date.now() - startTime;
|
|
81
|
+
return {
|
|
82
|
+
result,
|
|
83
|
+
metrics: {
|
|
84
|
+
duration,
|
|
85
|
+
timeToFirstToken,
|
|
86
|
+
tokenUsage: this.extractTokenUsageFromResult(result),
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
const duration = Date.now() - startTime;
|
|
92
|
+
const typedError = error instanceof Error ? error : new Error(String(error));
|
|
93
|
+
// THROW error instead of returning it
|
|
94
|
+
throw new task_o_matic_error_1.TaskOMaticError(`AI operation failed: ${operationName} - ${this.getErrorMessage(typedError)}`, {
|
|
95
|
+
code: "AI_OPERATION_FAILED",
|
|
96
|
+
context: JSON.stringify({
|
|
97
|
+
operation: operationName,
|
|
98
|
+
duration,
|
|
99
|
+
error: this.getErrorMessage(typedError),
|
|
100
|
+
}),
|
|
101
|
+
cause: typedError,
|
|
102
|
+
suggestions: [
|
|
103
|
+
"Check AI configuration",
|
|
104
|
+
"Verify network connectivity",
|
|
105
|
+
"Review operation parameters",
|
|
106
|
+
"Check API keys and endpoints",
|
|
107
|
+
],
|
|
108
|
+
metadata: {
|
|
109
|
+
operationName,
|
|
110
|
+
duration,
|
|
111
|
+
attemptedRetries: options.maxRetries || 2,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Standardized streaming text operation with tool support
|
|
118
|
+
*
|
|
119
|
+
* This method provides a unified interface for AI text generation with:
|
|
120
|
+
* - Optional tool integration (filesystem, MCP, etc.)
|
|
121
|
+
* - Streaming support with callbacks
|
|
122
|
+
* - Context7 documentation caching
|
|
123
|
+
* - Metrics collection
|
|
124
|
+
* - Error handling
|
|
125
|
+
*
|
|
126
|
+
* @param systemPrompt - System prompt for the AI
|
|
127
|
+
* @param userMessage - User message/prompt
|
|
128
|
+
* @param config - Optional AI configuration overrides
|
|
129
|
+
* @param streamingOptions - Optional streaming callbacks
|
|
130
|
+
* @param tools - Optional tool set to provide to the AI
|
|
131
|
+
* @returns Promise resolving to the generated text
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const result = await utility.streamTextWithTools(
|
|
136
|
+
* "You are a helpful assistant",
|
|
137
|
+
* "Explain quantum computing",
|
|
138
|
+
* undefined,
|
|
139
|
+
* { onChunk: (chunk) => console.log(chunk) },
|
|
140
|
+
* filesystemTools
|
|
141
|
+
* );
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
async streamTextWithTools(systemPrompt, userMessage, config, streamingOptions, tools) {
|
|
145
|
+
const aiConfig = this.mergeAIConfig(config);
|
|
146
|
+
const model = this.modelProvider.getModel(aiConfig);
|
|
147
|
+
// Create streaming configuration with Context7 handling and callbacks
|
|
148
|
+
const streamConfig = this.createStreamingConfig(streamingOptions);
|
|
149
|
+
let accumulatedText = "";
|
|
150
|
+
const originalOnChunk = streamConfig.onChunk;
|
|
151
|
+
// Wrap onChunk to accumulate text locally
|
|
152
|
+
streamConfig.onChunk = (event) => {
|
|
153
|
+
// Debug log for chunk structure
|
|
154
|
+
// console.log(
|
|
155
|
+
// `[DEBUG] Chunk type: ${event.chunk?.type} | keys: ${Object.keys(
|
|
156
|
+
// event.chunk || {}
|
|
157
|
+
// ).join(",")}`
|
|
158
|
+
// );
|
|
159
|
+
if (event.chunk?.type === "text-delta" &&
|
|
160
|
+
typeof event.chunk.text === "string") {
|
|
161
|
+
accumulatedText += event.chunk.text;
|
|
162
|
+
// } else {
|
|
163
|
+
// console.log(
|
|
164
|
+
// `[DEBUG] Ignored chunk content:`,
|
|
165
|
+
// JSON.stringify(event.chunk)
|
|
166
|
+
// );
|
|
167
|
+
}
|
|
168
|
+
if (originalOnChunk) {
|
|
169
|
+
originalOnChunk(event);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
const result = await (0, ai_1.streamText)({
|
|
173
|
+
model,
|
|
174
|
+
tools: tools || {},
|
|
175
|
+
system: systemPrompt,
|
|
176
|
+
messages: [{ role: "user", content: userMessage }],
|
|
177
|
+
maxRetries: 0,
|
|
178
|
+
...streamConfig,
|
|
179
|
+
...(aiConfig.provider === "openrouter" &&
|
|
180
|
+
aiConfig.reasoning &&
|
|
181
|
+
aiConfig.reasoning.maxTokens
|
|
182
|
+
? {
|
|
183
|
+
providerOptions: {
|
|
184
|
+
openrouter: {
|
|
185
|
+
reasoning: {
|
|
186
|
+
max_tokens: aiConfig.reasoning.maxTokens,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
}
|
|
191
|
+
: {}),
|
|
192
|
+
});
|
|
193
|
+
const fullText = await result.text;
|
|
194
|
+
return fullText || accumulatedText;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Wrap streaming options to capture metrics
|
|
198
|
+
*
|
|
199
|
+
* @private
|
|
200
|
+
*/
|
|
201
|
+
wrapStreamingOptions(streamingOptions, startTime, onFirstToken) {
|
|
202
|
+
if (!streamingOptions) {
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
let firstTokenCaptured = false;
|
|
206
|
+
return {
|
|
207
|
+
...streamingOptions,
|
|
208
|
+
onChunk: (chunk) => {
|
|
209
|
+
if (!firstTokenCaptured && chunk.trim()) {
|
|
210
|
+
onFirstToken(Date.now() - startTime);
|
|
211
|
+
firstTokenCaptured = true;
|
|
212
|
+
}
|
|
213
|
+
streamingOptions.onChunk?.(chunk);
|
|
214
|
+
},
|
|
215
|
+
onFinish: (result) => {
|
|
216
|
+
streamingOptions.onFinish?.(result);
|
|
217
|
+
},
|
|
218
|
+
onReasoning: (reasoning) => {
|
|
219
|
+
streamingOptions.onReasoning?.(reasoning);
|
|
220
|
+
},
|
|
221
|
+
onError: (error) => {
|
|
222
|
+
streamingOptions.onError?.(error);
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Create streaming configuration with Context7 handling and callbacks
|
|
228
|
+
*
|
|
229
|
+
* This method creates a unified streaming configuration that:
|
|
230
|
+
* - Always handles Context7 tool-result events (even without streaming UI)
|
|
231
|
+
* - Forwards text-delta events to onChunk callback
|
|
232
|
+
* - Forwards reasoning-delta events to onReasoning callback
|
|
233
|
+
* - Handles errors with onError callback
|
|
234
|
+
* - Provides onFinish callback with completion data
|
|
235
|
+
*
|
|
236
|
+
* @private
|
|
237
|
+
*/
|
|
238
|
+
createStreamingConfig(streamingOptions) {
|
|
239
|
+
return {
|
|
240
|
+
onChunk: streamingOptions?.onChunk || streamingOptions?.onReasoning
|
|
241
|
+
? (event) => {
|
|
242
|
+
// Handle Context7 tool results ALWAYS (critical for caching)
|
|
243
|
+
this.handleContext7ToolResult(event.chunk);
|
|
244
|
+
// Forward text deltas to user callback
|
|
245
|
+
if (event.chunk?.type === "text-delta") {
|
|
246
|
+
streamingOptions?.onChunk?.(event.chunk.text);
|
|
247
|
+
}
|
|
248
|
+
// Forward reasoning deltas to user callback
|
|
249
|
+
if (event.chunk?.type === "reasoning-delta") {
|
|
250
|
+
streamingOptions?.onReasoning?.(event.chunk.text);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
: undefined,
|
|
254
|
+
onFinish: streamingOptions?.onFinish
|
|
255
|
+
? (event) => {
|
|
256
|
+
streamingOptions.onFinish({
|
|
257
|
+
text: event.text,
|
|
258
|
+
finishReason: event.finishReason,
|
|
259
|
+
usage: event.usage,
|
|
260
|
+
isAborted: false,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
: undefined,
|
|
264
|
+
onError: streamingOptions?.onError
|
|
265
|
+
? (event) => {
|
|
266
|
+
streamingOptions.onError(event.error);
|
|
267
|
+
}
|
|
268
|
+
: undefined,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Extract token usage from AI result
|
|
273
|
+
*
|
|
274
|
+
* @private
|
|
275
|
+
*/
|
|
276
|
+
extractTokenUsageFromResult(result) {
|
|
277
|
+
if (result && result.usage) {
|
|
278
|
+
return {
|
|
279
|
+
prompt: result.usage.prompt_tokens || 0,
|
|
280
|
+
completion: result.usage.completion_tokens || 0,
|
|
281
|
+
total: result.usage.total_tokens || 0,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Get error message from any error type
|
|
288
|
+
*
|
|
289
|
+
* @private
|
|
290
|
+
*/
|
|
291
|
+
getErrorMessage(error) {
|
|
292
|
+
if (error instanceof Error) {
|
|
293
|
+
return error.message;
|
|
294
|
+
}
|
|
295
|
+
else if (typeof error === "string") {
|
|
296
|
+
return error;
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
return "Unknown error";
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
exports.AIOperationUtility = AIOperationUtility;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TaskRepository } from "../lib/storage/types";
|
|
2
|
+
import { ContextBuilder, ContextCallbacks } from "../lib/context-builder";
|
|
3
|
+
import { ConfigCallbacks } from "../lib/config";
|
|
4
|
+
import { AIOperations } from "../lib/ai-service/ai-operations";
|
|
5
|
+
import { ModelProvider } from "../lib/ai-service/model-provider";
|
|
6
|
+
import { StorageCallbacks } from "../lib/storage/storage-callbacks";
|
|
7
|
+
export interface ServiceOptions {
|
|
8
|
+
storageCallbacks?: StorageCallbacks;
|
|
9
|
+
configCallbacks?: ConfigCallbacks;
|
|
10
|
+
contextCallbacks?: ContextCallbacks;
|
|
11
|
+
workingDirectory?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Initialize services with optional custom callbacks.
|
|
15
|
+
* This is the entry point for web applications or custom environments.
|
|
16
|
+
* It also ensures configuration is loaded asynchronously.
|
|
17
|
+
*/
|
|
18
|
+
export declare function initializeServices(options?: ServiceOptions): Promise<void>;
|
|
19
|
+
export declare function getAIOperations(): AIOperations;
|
|
20
|
+
export declare function getModelProvider(): ModelProvider;
|
|
21
|
+
export declare function getStorage(): TaskRepository;
|
|
22
|
+
export declare function getContextBuilder(): ContextBuilder;
|
|
23
|
+
export declare function resetServiceInstances(): void;
|
|
24
|
+
/**
|
|
25
|
+
* FOR TESTING ONLY: Inject mock instances
|
|
26
|
+
* This allows tests to provide mock implementations without complex module mocking
|
|
27
|
+
*/
|
|
28
|
+
export declare function injectTestInstances(instances: {
|
|
29
|
+
storage?: TaskRepository;
|
|
30
|
+
aiOperations?: AIOperations;
|
|
31
|
+
modelProvider?: ModelProvider;
|
|
32
|
+
contextBuilder?: ContextBuilder;
|
|
33
|
+
}): void;
|
|
34
|
+
//# sourceMappingURL=ai-service-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-service-factory.d.ts","sourceRoot":"","sources":["../../src/utils/ai-service-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,EAAiB,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAMpE,MAAM,WAAW,cAAc;IAC7B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAOD;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED,wBAAgB,eAAe,IAAI,YAAY,CAK9C;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD;AAED,wBAAgB,UAAU,IAAI,cAAc,CAsB3C;AAED,wBAAgB,iBAAiB,IAAI,cAAc,CAMlD;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAK5C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE;IAC7C,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,GAAG,IAAI,CAKP"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initializeServices = initializeServices;
|
|
4
|
+
exports.getAIOperations = getAIOperations;
|
|
5
|
+
exports.getModelProvider = getModelProvider;
|
|
6
|
+
exports.getStorage = getStorage;
|
|
7
|
+
exports.getContextBuilder = getContextBuilder;
|
|
8
|
+
exports.resetServiceInstances = resetServiceInstances;
|
|
9
|
+
exports.injectTestInstances = injectTestInstances;
|
|
10
|
+
const file_system_1 = require("../lib/storage/file-system");
|
|
11
|
+
const context_builder_1 = require("../lib/context-builder");
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const config_1 = require("../lib/config");
|
|
14
|
+
const ai_operations_1 = require("../lib/ai-service/ai-operations");
|
|
15
|
+
const model_provider_1 = require("../lib/ai-service/model-provider");
|
|
16
|
+
const task_o_matic_error_1 = require("./task-o-matic-error");
|
|
17
|
+
let aiOperations = null;
|
|
18
|
+
let modelProvider = null;
|
|
19
|
+
let storage = null;
|
|
20
|
+
let contextBuilder = null;
|
|
21
|
+
/**
|
|
22
|
+
* Initialize services with optional custom callbacks.
|
|
23
|
+
* This is the entry point for web applications or custom environments.
|
|
24
|
+
* It also ensures configuration is loaded asynchronously.
|
|
25
|
+
*/
|
|
26
|
+
async function initializeServices(options = {}) {
|
|
27
|
+
if (options.workingDirectory) {
|
|
28
|
+
config_1.configManager.setWorkingDirectory(options.workingDirectory);
|
|
29
|
+
}
|
|
30
|
+
if (options.configCallbacks) {
|
|
31
|
+
config_1.configManager.setCallbacks(options.configCallbacks);
|
|
32
|
+
}
|
|
33
|
+
// Ensure config is loaded (async)
|
|
34
|
+
await config_1.configManager.load();
|
|
35
|
+
// Initialize storage
|
|
36
|
+
// If storageCallbacks provided, use them.
|
|
37
|
+
// If not, FileSystemStorage will use default callbacks (which use configManager.getTaskOMaticDir)
|
|
38
|
+
storage = new file_system_1.FileSystemStorage(options.storageCallbacks);
|
|
39
|
+
// Initialize context builder
|
|
40
|
+
contextBuilder = new context_builder_1.ContextBuilder(storage, options.contextCallbacks);
|
|
41
|
+
// Reset other services to ensure they use fresh dependencies if needed
|
|
42
|
+
aiOperations = null;
|
|
43
|
+
modelProvider = null;
|
|
44
|
+
}
|
|
45
|
+
function getAIOperations() {
|
|
46
|
+
if (!aiOperations) {
|
|
47
|
+
aiOperations = new ai_operations_1.AIOperations();
|
|
48
|
+
}
|
|
49
|
+
return aiOperations;
|
|
50
|
+
}
|
|
51
|
+
function getModelProvider() {
|
|
52
|
+
if (!modelProvider) {
|
|
53
|
+
modelProvider = new model_provider_1.ModelProvider();
|
|
54
|
+
}
|
|
55
|
+
return modelProvider;
|
|
56
|
+
}
|
|
57
|
+
function getStorage() {
|
|
58
|
+
if (!storage) {
|
|
59
|
+
// Default behavior for CLI (if initializeServices wasn't called)
|
|
60
|
+
// Ensure we're in a task-o-matic project before creating storage
|
|
61
|
+
// We use configManager (sync path) to check existence.
|
|
62
|
+
const taskOMaticDir = config_1.configManager.getTaskOMaticDir();
|
|
63
|
+
// Note: This check relies on FS. Web apps should call initializeServices first.
|
|
64
|
+
if (!(0, fs_1.existsSync)(taskOMaticDir)) {
|
|
65
|
+
throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.CONFIGURATION_ERROR, "Not a task-o-matic project. Run 'task-o-matic init' first.", {
|
|
66
|
+
suggestions: ["Run `task-o-matic init` in your project root."],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
storage = new file_system_1.FileSystemStorage();
|
|
70
|
+
}
|
|
71
|
+
return storage;
|
|
72
|
+
}
|
|
73
|
+
function getContextBuilder() {
|
|
74
|
+
if (!contextBuilder) {
|
|
75
|
+
const storage = getStorage();
|
|
76
|
+
contextBuilder = new context_builder_1.ContextBuilder(storage);
|
|
77
|
+
}
|
|
78
|
+
return contextBuilder;
|
|
79
|
+
}
|
|
80
|
+
function resetServiceInstances() {
|
|
81
|
+
aiOperations = null;
|
|
82
|
+
modelProvider = null;
|
|
83
|
+
storage = null;
|
|
84
|
+
contextBuilder = null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* FOR TESTING ONLY: Inject mock instances
|
|
88
|
+
* This allows tests to provide mock implementations without complex module mocking
|
|
89
|
+
*/
|
|
90
|
+
function injectTestInstances(instances) {
|
|
91
|
+
if (instances.storage)
|
|
92
|
+
storage = instances.storage;
|
|
93
|
+
if (instances.aiOperations)
|
|
94
|
+
aiOperations = instances.aiOperations;
|
|
95
|
+
if (instances.modelProvider)
|
|
96
|
+
modelProvider = instances.modelProvider;
|
|
97
|
+
if (instances.contextBuilder)
|
|
98
|
+
contextBuilder = instances.contextBuilder;
|
|
99
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts a readable error message from an unknown error value.
|
|
3
|
+
* Handles Error objects, strings, objects with message property, and unknown types.
|
|
4
|
+
*
|
|
5
|
+
* @param error - The error value to extract message from
|
|
6
|
+
* @returns A string error message
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* try {
|
|
11
|
+
* throw new Error("Something went wrong");
|
|
12
|
+
* } catch (error) {
|
|
13
|
+
* console.log(getErrorMessage(error)); // "Something went wrong"
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
18
|
+
/**
|
|
19
|
+
* Formats an error with optional context information.
|
|
20
|
+
* Useful for adding context to error messages when rethrowing.
|
|
21
|
+
*
|
|
22
|
+
* @param error - The error value
|
|
23
|
+
* @param context - Optional context string to prepend to the error message
|
|
24
|
+
* @returns Formatted error message
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* try {
|
|
29
|
+
* await fetchData();
|
|
30
|
+
* } catch (error) {
|
|
31
|
+
* throw new Error(formatError(error, "Failed to fetch data"));
|
|
32
|
+
* // Result: "Failed to fetch data: Connection timeout"
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatError(error: unknown, context?: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Creates an error with a formatted message including context.
|
|
39
|
+
*
|
|
40
|
+
* @param error - The original error
|
|
41
|
+
* @param context - Context to add to the error
|
|
42
|
+
* @returns A new TaskOMaticError instance with formatted message
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* try {
|
|
47
|
+
* await operation();
|
|
48
|
+
* } catch (error) {
|
|
49
|
+
* throw createContextError(error, "Operation failed");
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function createContextError(error: unknown, context: string): import("./task-o-matic-error").TaskOMaticError;
|
|
54
|
+
/**
|
|
55
|
+
* Type guard to check if an error is an Error instance.
|
|
56
|
+
*
|
|
57
|
+
* @param error - Value to check
|
|
58
|
+
* @returns true if error is an Error instance
|
|
59
|
+
*/
|
|
60
|
+
export declare function isError(error: unknown): error is Error;
|
|
61
|
+
/**
|
|
62
|
+
* Safely converts any value to an Error instance.
|
|
63
|
+
* If the value is already an Error, returns it unchanged.
|
|
64
|
+
* Otherwise, creates a new Error with the string representation.
|
|
65
|
+
*
|
|
66
|
+
* @param error - Value to convert
|
|
67
|
+
* @returns An Error instance
|
|
68
|
+
*/
|
|
69
|
+
export declare function toError(error: unknown): import("./task-o-matic-error").TaskOMaticError;
|
|
70
|
+
//# sourceMappingURL=error-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-utils.d.ts","sourceRoot":"","sources":["../../src/utils/error-utils.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAkBtD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,GACd,OAAO,sBAAsB,EAAE,eAAe,CAMhD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAEtD;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,OAAO,GACb,OAAO,sBAAsB,EAAE,eAAe,CAYhD"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getErrorMessage = getErrorMessage;
|
|
4
|
+
exports.formatError = formatError;
|
|
5
|
+
exports.createContextError = createContextError;
|
|
6
|
+
exports.isError = isError;
|
|
7
|
+
exports.toError = toError;
|
|
8
|
+
const task_o_matic_error_1 = require("./task-o-matic-error");
|
|
9
|
+
/**
|
|
10
|
+
* Extracts a readable error message from an unknown error value.
|
|
11
|
+
* Handles Error objects, strings, objects with message property, and unknown types.
|
|
12
|
+
*
|
|
13
|
+
* @param error - The error value to extract message from
|
|
14
|
+
* @returns A string error message
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* try {
|
|
19
|
+
* throw new Error("Something went wrong");
|
|
20
|
+
* } catch (error) {
|
|
21
|
+
* console.log(getErrorMessage(error)); // "Something went wrong"
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function getErrorMessage(error) {
|
|
26
|
+
// Error instance
|
|
27
|
+
if (error instanceof Error) {
|
|
28
|
+
return error.message;
|
|
29
|
+
}
|
|
30
|
+
// String error
|
|
31
|
+
if (typeof error === "string") {
|
|
32
|
+
return error;
|
|
33
|
+
}
|
|
34
|
+
// Object with message property
|
|
35
|
+
if (error && typeof error === "object" && "message" in error) {
|
|
36
|
+
return String(error.message);
|
|
37
|
+
}
|
|
38
|
+
// Unknown type - convert to string
|
|
39
|
+
return "Unknown error occurred";
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Formats an error with optional context information.
|
|
43
|
+
* Useful for adding context to error messages when rethrowing.
|
|
44
|
+
*
|
|
45
|
+
* @param error - The error value
|
|
46
|
+
* @param context - Optional context string to prepend to the error message
|
|
47
|
+
* @returns Formatted error message
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* try {
|
|
52
|
+
* await fetchData();
|
|
53
|
+
* } catch (error) {
|
|
54
|
+
* throw new Error(formatError(error, "Failed to fetch data"));
|
|
55
|
+
* // Result: "Failed to fetch data: Connection timeout"
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
function formatError(error, context) {
|
|
60
|
+
const message = getErrorMessage(error);
|
|
61
|
+
return context ? `${context}: ${message}` : message;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Creates an error with a formatted message including context.
|
|
65
|
+
*
|
|
66
|
+
* @param error - The original error
|
|
67
|
+
* @param context - Context to add to the error
|
|
68
|
+
* @returns A new TaskOMaticError instance with formatted message
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* try {
|
|
73
|
+
* await operation();
|
|
74
|
+
* } catch (error) {
|
|
75
|
+
* throw createContextError(error, "Operation failed");
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
function createContextError(error, context) {
|
|
80
|
+
return (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.UNEXPECTED_ERROR, formatError(error, context), { cause: error instanceof Error ? error : undefined });
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Type guard to check if an error is an Error instance.
|
|
84
|
+
*
|
|
85
|
+
* @param error - Value to check
|
|
86
|
+
* @returns true if error is an Error instance
|
|
87
|
+
*/
|
|
88
|
+
function isError(error) {
|
|
89
|
+
return error instanceof Error;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Safely converts any value to an Error instance.
|
|
93
|
+
* If the value is already an Error, returns it unchanged.
|
|
94
|
+
* Otherwise, creates a new Error with the string representation.
|
|
95
|
+
*
|
|
96
|
+
* @param error - Value to convert
|
|
97
|
+
* @returns An Error instance
|
|
98
|
+
*/
|
|
99
|
+
function toError(error) {
|
|
100
|
+
if (error instanceof Error) {
|
|
101
|
+
return (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.UNEXPECTED_ERROR, error.message, { cause: error });
|
|
102
|
+
}
|
|
103
|
+
return (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.UNEXPECTED_ERROR, getErrorMessage(error));
|
|
104
|
+
}
|