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,121 @@
|
|
|
1
|
+
import { AIOptions } from "../../utils/ai-config-builder";
|
|
2
|
+
|
|
3
|
+
export interface BenchmarkModelConfig {
|
|
4
|
+
provider: string;
|
|
5
|
+
model: string;
|
|
6
|
+
reasoningTokens?: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface BenchmarkConfig {
|
|
10
|
+
models: BenchmarkModelConfig[];
|
|
11
|
+
concurrency: number;
|
|
12
|
+
delay: number; // ms
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface BenchmarkProgressEvent {
|
|
16
|
+
type: "start" | "progress" | "complete" | "error";
|
|
17
|
+
modelId: string;
|
|
18
|
+
duration?: number;
|
|
19
|
+
error?: string;
|
|
20
|
+
currentSize?: number; // bytes
|
|
21
|
+
currentBps?: number;
|
|
22
|
+
chunk?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
import { StreamingOptions } from "../../types";
|
|
26
|
+
import { WorkflowAutomationOptions } from "../../types/workflow-options";
|
|
27
|
+
import { Task } from "../../types";
|
|
28
|
+
|
|
29
|
+
export interface BenchmarkResult {
|
|
30
|
+
modelId: string; // provider:model[:reasoning]
|
|
31
|
+
output: any;
|
|
32
|
+
duration: number;
|
|
33
|
+
error?: string;
|
|
34
|
+
timestamp: number;
|
|
35
|
+
tokenUsage?: {
|
|
36
|
+
prompt: number;
|
|
37
|
+
completion: number;
|
|
38
|
+
total: number;
|
|
39
|
+
};
|
|
40
|
+
responseSize?: number; // bytes
|
|
41
|
+
bps?: number; // bytes per second
|
|
42
|
+
tps?: number; // tokens per second (output)
|
|
43
|
+
timeToFirstToken?: number; // ms
|
|
44
|
+
cost?: number; // estimated cost in USD
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface WorkflowBenchmarkResult extends BenchmarkResult {
|
|
48
|
+
output: {
|
|
49
|
+
projectDir?: string;
|
|
50
|
+
prdFile?: string;
|
|
51
|
+
prdContent?: string;
|
|
52
|
+
tasks: Task[];
|
|
53
|
+
stats: {
|
|
54
|
+
initDuration?: number;
|
|
55
|
+
prdGenerationDuration?: number;
|
|
56
|
+
prdRefinementDuration?: number;
|
|
57
|
+
taskGenerationDuration?: number;
|
|
58
|
+
taskSplittingDuration?: number;
|
|
59
|
+
totalTasks: number;
|
|
60
|
+
tasksWithSubtasks: number;
|
|
61
|
+
avgTaskComplexity?: number;
|
|
62
|
+
prdSize?: number; // characters
|
|
63
|
+
totalSteps: number;
|
|
64
|
+
successfulSteps: number;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface BenchmarkRun {
|
|
70
|
+
id: string;
|
|
71
|
+
timestamp: number;
|
|
72
|
+
command: string; // e.g. "prd-parse"
|
|
73
|
+
input: any;
|
|
74
|
+
config: BenchmarkConfig;
|
|
75
|
+
results: BenchmarkResult[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface WorkflowBenchmarkInput {
|
|
79
|
+
// Collected user responses for consistent execution across models
|
|
80
|
+
collectedResponses: {
|
|
81
|
+
projectName: string;
|
|
82
|
+
initMethod: "quick" | "custom" | "ai";
|
|
83
|
+
projectDescription?: string;
|
|
84
|
+
stackConfig?: {
|
|
85
|
+
frontend?: string;
|
|
86
|
+
backend?: string;
|
|
87
|
+
database?: string;
|
|
88
|
+
auth?: boolean;
|
|
89
|
+
};
|
|
90
|
+
prdMethod: "upload" | "manual" | "ai" | "skip";
|
|
91
|
+
prdContent?: string;
|
|
92
|
+
prdDescription?: string;
|
|
93
|
+
prdFile?: string;
|
|
94
|
+
refinePrd?: boolean;
|
|
95
|
+
refineFeedback?: string;
|
|
96
|
+
generateTasks?: boolean;
|
|
97
|
+
customInstructions?: string;
|
|
98
|
+
splitTasks?: boolean;
|
|
99
|
+
tasksToSplit?: string[];
|
|
100
|
+
splitInstructions?: string;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// Original workflow automation options
|
|
104
|
+
workflowOptions: WorkflowAutomationOptions;
|
|
105
|
+
|
|
106
|
+
// Benchmark-specific settings
|
|
107
|
+
projectDir?: string;
|
|
108
|
+
tempDirBase?: string; // Base directory for temporary project directories
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface BenchmarkableOperation {
|
|
112
|
+
id: string;
|
|
113
|
+
name: string;
|
|
114
|
+
description: string;
|
|
115
|
+
execute: (
|
|
116
|
+
input: any,
|
|
117
|
+
aiOptions: AIOptions,
|
|
118
|
+
streamingOptions?: StreamingOptions
|
|
119
|
+
) => Promise<any>;
|
|
120
|
+
validateInput: (input: any) => boolean;
|
|
121
|
+
}
|
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
import { BTSConfig, BTSFrontend, InitOptions } from "../types";
|
|
2
|
+
import { configManager } from "./config";
|
|
3
|
+
import { writeFileSync, mkdirSync, readFileSync } from "fs";
|
|
4
|
+
// import { glob } from "glob";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
import { logger } from "./logger";
|
|
7
|
+
|
|
8
|
+
export class BetterTStackService {
|
|
9
|
+
async createProject(
|
|
10
|
+
name: string,
|
|
11
|
+
config: BTSConfig,
|
|
12
|
+
workingDirectory?: string
|
|
13
|
+
): Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
projectPath: string;
|
|
16
|
+
message: string;
|
|
17
|
+
}> {
|
|
18
|
+
try {
|
|
19
|
+
logger.info(`🚀 Bootstrapping Better-T-Stack project: ${name}`);
|
|
20
|
+
|
|
21
|
+
// Change to working directory if provided
|
|
22
|
+
const originalCwd = process.cwd();
|
|
23
|
+
if (workingDirectory) {
|
|
24
|
+
process.chdir(workingDirectory);
|
|
25
|
+
logger.info(`🔥 Changed working directory to: ${workingDirectory}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Convert our config to Better-T-Stack API format
|
|
29
|
+
const apiConfig = this.convertToAPIConfig(config);
|
|
30
|
+
|
|
31
|
+
logger.info(`🔥 Calling Better-T-Stack programmatic API...`);
|
|
32
|
+
|
|
33
|
+
// Use dynamic import with eval to bypass TypeScript module resolution
|
|
34
|
+
// The module exports `init` as a named export, but depending on how it's bundled,
|
|
35
|
+
// it might be directly on the module or wrapped in a default export
|
|
36
|
+
const btsModule = await eval(`import("create-better-t-stack")`);
|
|
37
|
+
|
|
38
|
+
// Handle different module structures and API versions
|
|
39
|
+
// The package renamed 'init' to 'create' in a recent update
|
|
40
|
+
const initFn =
|
|
41
|
+
btsModule.create ||
|
|
42
|
+
btsModule.init ||
|
|
43
|
+
btsModule.default?.create ||
|
|
44
|
+
btsModule.default?.init ||
|
|
45
|
+
btsModule.default;
|
|
46
|
+
if (typeof initFn !== "function") {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`Could not find 'create' or 'init' function in create-better-t-stack module. ` +
|
|
49
|
+
`Available exports: ${Object.keys(btsModule).join(", ")}`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const result = await initFn(name, apiConfig);
|
|
54
|
+
|
|
55
|
+
// Restore original directory
|
|
56
|
+
if (workingDirectory) {
|
|
57
|
+
process.chdir(originalCwd);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (result.success) {
|
|
61
|
+
// Save configuration
|
|
62
|
+
await this.saveBTSConfig(name, config, result.projectDirectory);
|
|
63
|
+
|
|
64
|
+
// Post-bootstrap enhancements
|
|
65
|
+
try {
|
|
66
|
+
const projectDir = result.projectDirectory;
|
|
67
|
+
|
|
68
|
+
// 1. Add check-types script to packages
|
|
69
|
+
await this.addCheckTypesScript(projectDir);
|
|
70
|
+
|
|
71
|
+
// 2. Copy documentation if requested
|
|
72
|
+
if (config.includeDocs) {
|
|
73
|
+
await this.copyDocumentation(projectDir);
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
logger.error(`⚠ Post-bootstrap enhancements failed: ${error}`);
|
|
77
|
+
// Don't fail the whole process, just log warning
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
success: true,
|
|
82
|
+
projectPath: result.relativePath,
|
|
83
|
+
message: `Better-T-Stack project ${name} created successfully at ${result.projectDirectory}`,
|
|
84
|
+
};
|
|
85
|
+
} else {
|
|
86
|
+
return {
|
|
87
|
+
success: false,
|
|
88
|
+
projectPath: "",
|
|
89
|
+
message: `Better-T-Stack bootstrap failed: ${result.error}`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return {
|
|
94
|
+
success: false,
|
|
95
|
+
projectPath: "",
|
|
96
|
+
message: `Better-T-Stack initialization failed: ${
|
|
97
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
98
|
+
}`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private convertToAPIConfig(config: BTSConfig) {
|
|
104
|
+
// Ensure frontend is always an array for Better-T-Stack API
|
|
105
|
+
const frontend = Array.isArray(config.frontend)
|
|
106
|
+
? config.frontend
|
|
107
|
+
: [config.frontend];
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
// Don't use 'yes' flag when providing explicit configuration
|
|
111
|
+
frontend,
|
|
112
|
+
backend: config.backend,
|
|
113
|
+
runtime: config.runtime,
|
|
114
|
+
api: config.api,
|
|
115
|
+
auth: config.auth,
|
|
116
|
+
database: config.database,
|
|
117
|
+
orm: config.orm,
|
|
118
|
+
dbSetup: config.dbSetup,
|
|
119
|
+
packageManager: config.packageManager,
|
|
120
|
+
webDeploy: config.webDeploy,
|
|
121
|
+
serverDeploy: config.serverDeploy,
|
|
122
|
+
git: config.git,
|
|
123
|
+
install: config.install,
|
|
124
|
+
addons: config.addons,
|
|
125
|
+
examples:
|
|
126
|
+
config.examples &&
|
|
127
|
+
config.examples.length > 0 &&
|
|
128
|
+
config.examples[0] !== "none"
|
|
129
|
+
? config.examples
|
|
130
|
+
: ["none"],
|
|
131
|
+
disableAnalytics: true,
|
|
132
|
+
payments: config.payments,
|
|
133
|
+
template: config.template, // v3.13.0: mern, pern, t3, uniwind
|
|
134
|
+
// Non-interactive options (yes: true conflicts with explicit config)
|
|
135
|
+
manualDb: true, // Skip DB setup prompts
|
|
136
|
+
renderTitle: false, // Cleaner output
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private async saveBTSConfig(
|
|
141
|
+
name: string,
|
|
142
|
+
config: BTSConfig,
|
|
143
|
+
projectPath?: string
|
|
144
|
+
): Promise<void> {
|
|
145
|
+
const taskOMaticDir = projectPath
|
|
146
|
+
? join(projectPath, ".task-o-matic")
|
|
147
|
+
: configManager.getTaskOMaticDir();
|
|
148
|
+
|
|
149
|
+
// Ensure directory exists if we're using a specific project path
|
|
150
|
+
if (projectPath && !require("fs").existsSync(taskOMaticDir)) {
|
|
151
|
+
require("fs").mkdirSync(taskOMaticDir, { recursive: true });
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const configData = JSON.stringify(
|
|
155
|
+
{
|
|
156
|
+
...config,
|
|
157
|
+
projectName: config.projectName || name,
|
|
158
|
+
createdAt: new Date().toISOString(),
|
|
159
|
+
},
|
|
160
|
+
null,
|
|
161
|
+
2
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
// Save with project-specific name for tracking multiple projects
|
|
165
|
+
const namedConfigPath = join(taskOMaticDir, `${name}-bts-config.json`);
|
|
166
|
+
writeFileSync(namedConfigPath, configData);
|
|
167
|
+
|
|
168
|
+
// Also save as canonical stack.json for easy discovery by context-builder
|
|
169
|
+
const stackConfigPath = join(taskOMaticDir, "stack.json");
|
|
170
|
+
writeFileSync(stackConfigPath, configData);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private async addCheckTypesScript(projectDir: string): Promise<void> {
|
|
174
|
+
const { glob } = await import("glob");
|
|
175
|
+
// const { readFileSync, writeFileSync } = await import("fs");
|
|
176
|
+
|
|
177
|
+
logger.info("🔍 Adding check-types scripts to packages...");
|
|
178
|
+
|
|
179
|
+
// Find all package.json files in apps and backend directories
|
|
180
|
+
const packageFiles = await glob(
|
|
181
|
+
["apps/*/package.json", "backend/*/package.json"],
|
|
182
|
+
{ cwd: projectDir, absolute: true }
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
for (const file of packageFiles) {
|
|
186
|
+
try {
|
|
187
|
+
const content = JSON.parse(readFileSync(file, "utf-8"));
|
|
188
|
+
if (!content.scripts) {
|
|
189
|
+
content.scripts = {};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Add check-types script if not present
|
|
193
|
+
if (!content.scripts["check-types"]) {
|
|
194
|
+
content.scripts["check-types"] = "tsc --noEmit";
|
|
195
|
+
writeFileSync(file, JSON.stringify(content, null, 2) + "\n");
|
|
196
|
+
logger.success(
|
|
197
|
+
` ✓ Added check-types to ${file.split("/").slice(-3).join("/")}`
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
} catch (err) {
|
|
201
|
+
logger.warn(` ⚠ Failed to update ${file}: ${err}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private async copyDocumentation(projectDir: string): Promise<void> {
|
|
207
|
+
const { copyFileSync, mkdirSync, existsSync } = await import("fs");
|
|
208
|
+
const { resolve, dirname } = await import("path");
|
|
209
|
+
|
|
210
|
+
logger.info("📚 Copying documentation...");
|
|
211
|
+
|
|
212
|
+
try {
|
|
213
|
+
// Source: docs/agents/cli.md in the current package
|
|
214
|
+
// We need to find where the package is installed or running from
|
|
215
|
+
// Assuming we are running from dist/lib/better-t-stack-cli.js or similar
|
|
216
|
+
// The docs should be in ../../docs/agents/cli.md relative to this file's location in source
|
|
217
|
+
// Or in the package root if installed
|
|
218
|
+
|
|
219
|
+
let sourcePath = resolve(__dirname, "../../../docs/agents/cli.md");
|
|
220
|
+
|
|
221
|
+
// Check if we're in dist
|
|
222
|
+
if (!existsSync(sourcePath)) {
|
|
223
|
+
// Try to find it relative to package root (cwd when running dev)
|
|
224
|
+
sourcePath = resolve(process.cwd(), "docs/agents/cli.md");
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (!existsSync(sourcePath)) {
|
|
228
|
+
// Try to find it in node_modules if installed as dependency
|
|
229
|
+
try {
|
|
230
|
+
sourcePath = require.resolve("task-o-matic/docs/agents/cli.md");
|
|
231
|
+
} catch (e) {
|
|
232
|
+
// Ignore
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (existsSync(sourcePath)) {
|
|
237
|
+
const destPath = join(projectDir, "docs/task-o-matic.md");
|
|
238
|
+
const destDir = dirname(destPath);
|
|
239
|
+
|
|
240
|
+
if (!existsSync(destDir)) {
|
|
241
|
+
mkdirSync(destDir, { recursive: true });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
copyFileSync(sourcePath, destPath);
|
|
245
|
+
logger.success(` ✓ Copied documentation to docs/task-o-matic.md`);
|
|
246
|
+
} else {
|
|
247
|
+
logger.warn(" ⚠ Could not locate source documentation file");
|
|
248
|
+
}
|
|
249
|
+
} catch (err) {
|
|
250
|
+
logger.warn(` ⚠ Failed to copy documentation: ${err}`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Helper methods for multi-frontend support
|
|
256
|
+
export class BetterTStackIntegration {
|
|
257
|
+
private btsService: BetterTStackService;
|
|
258
|
+
|
|
259
|
+
constructor() {
|
|
260
|
+
this.btsService = new BetterTStackService();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Parse frontend option into array of frontends
|
|
265
|
+
*/
|
|
266
|
+
private parseFrontends(
|
|
267
|
+
frontendOption?: BTSFrontend | BTSFrontend[] | string
|
|
268
|
+
): BTSFrontend[] {
|
|
269
|
+
if (!frontendOption) return [];
|
|
270
|
+
|
|
271
|
+
// If already array, return it
|
|
272
|
+
if (Array.isArray(frontendOption)) return frontendOption;
|
|
273
|
+
|
|
274
|
+
// If string, split by comma or space
|
|
275
|
+
if (typeof frontendOption === "string") {
|
|
276
|
+
return frontendOption
|
|
277
|
+
.split(/[\s,]+/)
|
|
278
|
+
.map((f) => f.trim())
|
|
279
|
+
.filter(Boolean) as BTSFrontend[];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Single value
|
|
283
|
+
return [frontendOption];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Split frontends into Better-T-Stack frontends vs custom frontends
|
|
288
|
+
*/
|
|
289
|
+
private splitFrontends(frontends: BTSFrontend[]): {
|
|
290
|
+
btsFrontends: BTSFrontend[];
|
|
291
|
+
customFrontends: BTSFrontend[];
|
|
292
|
+
} {
|
|
293
|
+
const customTypes = new Set<string>(["cli", "medusa"]);
|
|
294
|
+
|
|
295
|
+
return {
|
|
296
|
+
btsFrontends: frontends.filter((f) => !customTypes.has(f)),
|
|
297
|
+
customFrontends: frontends.filter((f) => customTypes.has(f)),
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Create project with support for multiple frontends
|
|
303
|
+
*/
|
|
304
|
+
async createProject(
|
|
305
|
+
name: string,
|
|
306
|
+
options: InitOptions,
|
|
307
|
+
workingDirectory?: string
|
|
308
|
+
): Promise<{ success: boolean; message: string; projectPath?: string }> {
|
|
309
|
+
const workingDir = workingDirectory || configManager.getWorkingDirectory();
|
|
310
|
+
const frontends = this.parseFrontends(options.frontend);
|
|
311
|
+
const { btsFrontends, customFrontends } = this.splitFrontends(frontends);
|
|
312
|
+
|
|
313
|
+
const isMonorepo = frontends.length > 1;
|
|
314
|
+
let projectPath = join(workingDir, name);
|
|
315
|
+
const results: string[] = [];
|
|
316
|
+
|
|
317
|
+
try {
|
|
318
|
+
// Step 1: Bootstrap Better-T-Stack project FIRST (if any BTS frontends)
|
|
319
|
+
// This creates the monorepo structure that CLI/TUI will be added to
|
|
320
|
+
if (btsFrontends.length > 0) {
|
|
321
|
+
const result = await this.bootstrapBetterTStackProject(
|
|
322
|
+
name,
|
|
323
|
+
btsFrontends,
|
|
324
|
+
options,
|
|
325
|
+
workingDir
|
|
326
|
+
);
|
|
327
|
+
if (!result.success) throw new Error(result.message);
|
|
328
|
+
|
|
329
|
+
// Get the actual project path from Better-T-Stack result
|
|
330
|
+
// This is the full path where the project was created
|
|
331
|
+
projectPath = join(workingDir, name);
|
|
332
|
+
results.push(result.message);
|
|
333
|
+
} else if (isMonorepo) {
|
|
334
|
+
// Create monorepo structure manually if no BTS frontends
|
|
335
|
+
// (e.g., just cli + tui with no web/native)
|
|
336
|
+
mkdirSync(projectPath, { recursive: true });
|
|
337
|
+
mkdirSync(join(projectPath, "apps"), { recursive: true });
|
|
338
|
+
logger.info(`📁 Created monorepo structure at ${projectPath}`);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Step 2: AFTER Better-T-Stack creates the structure, add custom frontends
|
|
342
|
+
// These get added into the apps/ directory that Better-T-Stack created
|
|
343
|
+
for (const frontend of customFrontends) {
|
|
344
|
+
if (frontend === "cli") {
|
|
345
|
+
const result = await this.addCliToProject(
|
|
346
|
+
name,
|
|
347
|
+
projectPath,
|
|
348
|
+
isMonorepo,
|
|
349
|
+
options
|
|
350
|
+
);
|
|
351
|
+
results.push(result.message);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (frontend === "medusa") {
|
|
355
|
+
const result = await this.addMedusaToProject(
|
|
356
|
+
name,
|
|
357
|
+
projectPath,
|
|
358
|
+
isMonorepo,
|
|
359
|
+
options
|
|
360
|
+
);
|
|
361
|
+
results.push(result.message);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
success: true,
|
|
367
|
+
message: results.join("\n"),
|
|
368
|
+
projectPath,
|
|
369
|
+
};
|
|
370
|
+
} catch (error) {
|
|
371
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
372
|
+
return {
|
|
373
|
+
success: false,
|
|
374
|
+
message: `Project creation failed: ${message}`,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Bootstrap Better-T-Stack project with one or more frontends
|
|
381
|
+
*/
|
|
382
|
+
private async bootstrapBetterTStackProject(
|
|
383
|
+
name: string,
|
|
384
|
+
frontends: BTSFrontend[],
|
|
385
|
+
options: InitOptions,
|
|
386
|
+
workingDir: string
|
|
387
|
+
): Promise<{ success: boolean; message: string; projectPath: string }> {
|
|
388
|
+
const backend = options.backend || "hono";
|
|
389
|
+
const isConvex = backend === "convex";
|
|
390
|
+
|
|
391
|
+
const btsConfig: BTSConfig = {
|
|
392
|
+
projectName: options.name || options.projectName || name,
|
|
393
|
+
frontend: frontends.length === 1 ? frontends[0] : frontends, // Pass array if multiple
|
|
394
|
+
backend: (backend as BTSConfig["backend"]) || "hono",
|
|
395
|
+
database: isConvex
|
|
396
|
+
? "none"
|
|
397
|
+
: (options.database as BTSConfig["database"]) || "sqlite",
|
|
398
|
+
auth: options.noAuth
|
|
399
|
+
? "none"
|
|
400
|
+
: (options.auth as BTSConfig["auth"]) || "better-auth",
|
|
401
|
+
addons: (options.addons as BTSConfig["addons"]) || ["turborepo"],
|
|
402
|
+
runtime: (isConvex || backend === "self"
|
|
403
|
+
? "none"
|
|
404
|
+
: options.runtime || "node") as BTSConfig["runtime"],
|
|
405
|
+
api: (options.api as BTSConfig["api"]) || "none",
|
|
406
|
+
payments: (options.payment as BTSConfig["payments"]) || "none",
|
|
407
|
+
orm: (isConvex ? "none" : options.orm || "drizzle") as BTSConfig["orm"],
|
|
408
|
+
dbSetup: (isConvex
|
|
409
|
+
? "none"
|
|
410
|
+
: options.dbSetup || "none") as BTSConfig["dbSetup"],
|
|
411
|
+
packageManager:
|
|
412
|
+
(options.packageManager as BTSConfig["packageManager"]) || "npm",
|
|
413
|
+
git: !options.noGit,
|
|
414
|
+
webDeploy: (options.webDeploy as BTSConfig["webDeploy"]) || "none",
|
|
415
|
+
serverDeploy:
|
|
416
|
+
(options.serverDeploy as BTSConfig["serverDeploy"]) || "none",
|
|
417
|
+
install: !options.noInstall,
|
|
418
|
+
examples: (options.examples as BTSConfig["examples"]) || ["none"],
|
|
419
|
+
template: options.template as BTSConfig["template"], // Optional shortcut, don't default
|
|
420
|
+
// Non-interactive options (yes: true conflicts with explicit config)
|
|
421
|
+
manualDb: true,
|
|
422
|
+
renderTitle: false,
|
|
423
|
+
includeDocs: options.includeDocs,
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
const result = await this.btsService.createProject(
|
|
427
|
+
name,
|
|
428
|
+
btsConfig,
|
|
429
|
+
workingDir
|
|
430
|
+
);
|
|
431
|
+
return {
|
|
432
|
+
success: result.success,
|
|
433
|
+
message: result.message,
|
|
434
|
+
projectPath: result.projectPath,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Add CLI app to project (standalone or monorepo)
|
|
440
|
+
*/
|
|
441
|
+
private async addCliToProject(
|
|
442
|
+
projectName: string,
|
|
443
|
+
projectPath: string,
|
|
444
|
+
isMonorepo: boolean,
|
|
445
|
+
options: InitOptions
|
|
446
|
+
): Promise<{ success: boolean; message: string }> {
|
|
447
|
+
const { bootstrapCliProject } = await import(
|
|
448
|
+
"./bootstrap/cli-bootstrap.js"
|
|
449
|
+
);
|
|
450
|
+
|
|
451
|
+
const cliPath = isMonorepo ? join(projectPath, "apps", "cli") : projectPath;
|
|
452
|
+
const cliName = isMonorepo ? `${projectName}-cli` : projectName;
|
|
453
|
+
|
|
454
|
+
const result = await bootstrapCliProject({
|
|
455
|
+
projectName: cliName,
|
|
456
|
+
projectPath: cliPath,
|
|
457
|
+
dependencyLevel: options.cliDeps || "standard",
|
|
458
|
+
packageManager:
|
|
459
|
+
(options.packageManager as "npm" | "pnpm" | "bun") || "npm",
|
|
460
|
+
runtime: (options.runtime as "node" | "bun") || "node",
|
|
461
|
+
typescript: true,
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
if (!result.success) throw new Error(result.message);
|
|
465
|
+
|
|
466
|
+
return {
|
|
467
|
+
success: true,
|
|
468
|
+
message: isMonorepo
|
|
469
|
+
? `✅ CLI app added to apps/cli/`
|
|
470
|
+
: `✅ CLI project "${projectName}" created successfully!`,
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Add MedusaJS app to project (standalone or monorepo)
|
|
476
|
+
*/
|
|
477
|
+
private async addMedusaToProject(
|
|
478
|
+
projectName: string,
|
|
479
|
+
projectPath: string,
|
|
480
|
+
isMonorepo: boolean,
|
|
481
|
+
options: InitOptions
|
|
482
|
+
): Promise<{ success: boolean; message: string }> {
|
|
483
|
+
const { bootstrapMedusaProject } = await import(
|
|
484
|
+
"./bootstrap/medusa-bootstrap.js"
|
|
485
|
+
);
|
|
486
|
+
|
|
487
|
+
const medusaPath = isMonorepo
|
|
488
|
+
? join(projectPath, "apps", "medusa")
|
|
489
|
+
: projectPath;
|
|
490
|
+
const medusaName = isMonorepo ? `${projectName}-medusa` : projectName;
|
|
491
|
+
|
|
492
|
+
const result = await bootstrapMedusaProject({
|
|
493
|
+
projectName: medusaName,
|
|
494
|
+
projectPath: medusaPath,
|
|
495
|
+
packageManager:
|
|
496
|
+
(options.packageManager as "npm" | "pnpm" | "bun") || "npm",
|
|
497
|
+
database: (options.database as "postgres" | "sqlite") || "sqlite",
|
|
498
|
+
skipDb: options.noInstall, // Skip DB setup if not installing deps
|
|
499
|
+
skipInstall: options.noInstall,
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
if (!result.success) throw new Error(result.message);
|
|
503
|
+
|
|
504
|
+
return {
|
|
505
|
+
success: true,
|
|
506
|
+
message: isMonorepo
|
|
507
|
+
? `✅ MedusaJS app added to apps/medusa/`
|
|
508
|
+
: `✅ MedusaJS project "${projectName}" created successfully!`,
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// Export backward-compatible function
|
|
514
|
+
export async function runBetterTStackCLI(
|
|
515
|
+
options: InitOptions,
|
|
516
|
+
workingDirectory?: string
|
|
517
|
+
): Promise<{ success: boolean; message: string; projectPath?: string }> {
|
|
518
|
+
const integration = new BetterTStackIntegration();
|
|
519
|
+
return integration.createProject(
|
|
520
|
+
options.projectName || options.name || "default-project",
|
|
521
|
+
options,
|
|
522
|
+
workingDirectory
|
|
523
|
+
);
|
|
524
|
+
}
|