task-o-matic 0.0.13 → 0.0.15
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/dist/cli/display/progress.d.ts +15 -2
- package/dist/cli/display/progress.d.ts.map +1 -1
- package/dist/cli/display/progress.js +72 -4
- package/dist/commands/benchmark.d.ts.map +1 -1
- package/dist/commands/benchmark.js +11 -3
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +60 -12
- package/dist/commands/prd.js +7 -1
- package/dist/commands/tasks/delete.d.ts.map +1 -1
- package/dist/commands/tasks/delete.js +2 -1
- package/dist/commands/tasks/document/add.d.ts.map +1 -1
- package/dist/commands/tasks/document/add.js +5 -4
- package/dist/commands/tasks/document/get.d.ts.map +1 -1
- package/dist/commands/tasks/document/get.js +2 -1
- package/dist/commands/tasks/list.js +2 -2
- package/dist/commands/tasks/next.js +4 -4
- package/dist/commands/tasks/plan/set.d.ts.map +1 -1
- package/dist/commands/tasks/plan/set.js +11 -3
- package/dist/commands/tasks/show.d.ts.map +1 -1
- package/dist/commands/tasks/show.js +2 -1
- package/dist/commands/tasks/status.d.ts.map +1 -1
- package/dist/commands/tasks/status.js +4 -3
- package/dist/commands/tasks/update.d.ts.map +1 -1
- package/dist/commands/tasks/update.js +7 -1
- package/dist/lib/ai-service/ai-operations.d.ts +1 -1
- package/dist/lib/ai-service/ai-operations.d.ts.map +1 -1
- package/dist/lib/ai-service/base-operations.d.ts +22 -0
- package/dist/lib/ai-service/base-operations.d.ts.map +1 -1
- package/dist/lib/ai-service/base-operations.js +29 -1
- package/dist/lib/ai-service/model-provider.d.ts.map +1 -1
- package/dist/lib/ai-service/model-provider.js +37 -6
- package/dist/lib/ai-service/task-operations.d.ts +2 -1
- package/dist/lib/ai-service/task-operations.d.ts.map +1 -1
- package/dist/lib/ai-service/task-operations.js +135 -173
- package/dist/lib/benchmark/registry.d.ts.map +1 -1
- package/dist/lib/benchmark/registry.js +6 -10
- package/dist/lib/better-t-stack-cli.d.ts +36 -21
- package/dist/lib/better-t-stack-cli.d.ts.map +1 -1
- package/dist/lib/better-t-stack-cli.js +212 -33
- 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 +325 -0
- package/dist/lib/bootstrap/index.d.ts +4 -0
- package/dist/lib/bootstrap/index.d.ts.map +1 -0
- package/dist/lib/bootstrap/index.js +19 -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 +218 -0
- package/dist/lib/bootstrap/opentui-bootstrap.d.ts +11 -0
- package/dist/lib/bootstrap/opentui-bootstrap.d.ts.map +1 -0
- package/dist/lib/bootstrap/opentui-bootstrap.js +342 -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 +246 -0
- package/dist/lib/config.d.ts +14 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +37 -5
- package/dist/lib/storage/file-system.d.ts.map +1 -1
- package/dist/lib/storage/file-system.js +81 -21
- package/dist/lib/task-execution-core.d.ts.map +1 -1
- package/dist/lib/task-execution-core.js +3 -2
- package/dist/services/prd.d.ts +17 -0
- package/dist/services/prd.d.ts.map +1 -1
- package/dist/services/prd.js +67 -60
- package/dist/services/tasks.d.ts +317 -3
- package/dist/services/tasks.d.ts.map +1 -1
- package/dist/services/tasks.js +531 -185
- package/dist/services/workflow-ai-assistant.d.ts.map +1 -1
- package/dist/services/workflow-ai-assistant.js +19 -6
- 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/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/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 +352 -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/types/index.d.ts +36 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/results.d.ts +60 -6
- package/dist/types/results.d.ts.map +1 -1
- 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 +288 -0
- package/dist/utils/ai-service-factory.d.ts +10 -0
- package/dist/utils/ai-service-factory.d.ts.map +1 -1
- package/dist/utils/ai-service-factory.js +19 -1
- package/dist/utils/cli-validators.d.ts +2 -2
- package/dist/utils/cli-validators.d.ts.map +1 -1
- package/dist/utils/cli-validators.js +7 -6
- 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 +49 -0
- package/dist/utils/file-utils.d.ts.map +1 -0
- package/dist/utils/file-utils.js +82 -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/model-executor-parser.d.ts +1 -1
- package/dist/utils/model-executor-parser.d.ts.map +1 -1
- package/dist/utils/model-executor-parser.js +3 -2
- package/dist/utils/stack-formatter.d.ts +2 -1
- package/dist/utils/stack-formatter.d.ts.map +1 -1
- package/dist/utils/stack-formatter.js +8 -2
- 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 +56 -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/docs/agents/cli.md +58 -149
- package/package.json +2 -2
|
@@ -11,8 +11,36 @@ class BaseOperations {
|
|
|
11
11
|
context7Client = new mcp_client_1.Context7Client();
|
|
12
12
|
retryHandler = new retry_handler_1.RetryHandler();
|
|
13
13
|
modelProvider = new model_provider_1.ModelProvider();
|
|
14
|
+
/**
|
|
15
|
+
* Merges AI configuration with proper precedence.
|
|
16
|
+
*
|
|
17
|
+
* Configuration precedence (highest to lowest):
|
|
18
|
+
* 1. Method parameter `config` (operation-specific overrides)
|
|
19
|
+
* 2. ConfigManager global config (project-level settings)
|
|
20
|
+
* 3. Environment variables (OPENAI_API_KEY, etc.)
|
|
21
|
+
* 4. Provider defaults (defined in config.ts)
|
|
22
|
+
*
|
|
23
|
+
* @param config - Optional operation-specific config overrides
|
|
24
|
+
* @returns Merged AIConfig with all precedence levels applied
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Override just the model for this operation
|
|
29
|
+
* const finalConfig = this.mergeAIConfig({ model: "gpt-4o" });
|
|
30
|
+
*
|
|
31
|
+
* // Use default config (from ConfigManager + env vars)
|
|
32
|
+
* const finalConfig = this.mergeAIConfig();
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
mergeAIConfig(config) {
|
|
36
|
+
// Get base config (includes ConfigManager + env vars + defaults)
|
|
37
|
+
const baseConfig = this.modelProvider.getAIConfig();
|
|
38
|
+
// Apply operation-specific overrides (highest priority)
|
|
39
|
+
return { ...baseConfig, ...config };
|
|
40
|
+
}
|
|
14
41
|
async streamText(prompt, config, systemPrompt, userMessage, streamingOptions, retryConfig) {
|
|
15
|
-
|
|
42
|
+
// Merge config with proper precedence (Bug fix 2.9)
|
|
43
|
+
const aiConfig = this.mergeAIConfig(config);
|
|
16
44
|
return this.retryHandler.executeWithRetry(async () => {
|
|
17
45
|
const model = this.modelProvider.getModel(aiConfig);
|
|
18
46
|
const result = (0, ai_1.streamText)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-provider.d.ts","sourceRoot":"","sources":["../../../src/lib/ai-service/model-provider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"model-provider.d.ts","sourceRoot":"","sources":["../../../src/lib/ai-service/model-provider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAOvC,qBAAa,aAAa;IACjB,WAAW,IAAI,QAAQ;IAY9B,OAAO,CAAC,YAAY;IAsBpB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,eAAe;CA0F9C"}
|
|
@@ -6,6 +6,7 @@ const anthropic_1 = require("@ai-sdk/anthropic");
|
|
|
6
6
|
const openai_compatible_1 = require("@ai-sdk/openai-compatible");
|
|
7
7
|
const ai_sdk_provider_1 = require("@openrouter/ai-sdk-provider");
|
|
8
8
|
const config_1 = require("../config");
|
|
9
|
+
const task_o_matic_error_1 = require("../../utils/task-o-matic-error");
|
|
9
10
|
class ModelProvider {
|
|
10
11
|
getAIConfig() {
|
|
11
12
|
const config = config_1.configManager.getAIConfig();
|
|
@@ -41,22 +42,47 @@ class ModelProvider {
|
|
|
41
42
|
switch (provider) {
|
|
42
43
|
case "openai":
|
|
43
44
|
if (!apiKey)
|
|
44
|
-
throw
|
|
45
|
+
throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.AI_CONFIGURATION_ERROR, "OpenAI API key is required", {
|
|
46
|
+
suggestions: [
|
|
47
|
+
"Set the OPENAI_API_KEY environment variable.",
|
|
48
|
+
"Run `task-o-matic config set-ai-key <key>`",
|
|
49
|
+
],
|
|
50
|
+
});
|
|
45
51
|
return (0, openai_1.openai)(model);
|
|
46
52
|
case "anthropic":
|
|
47
53
|
if (!apiKey)
|
|
48
|
-
throw
|
|
54
|
+
throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.AI_CONFIGURATION_ERROR, "Anthropic API key is required", {
|
|
55
|
+
suggestions: [
|
|
56
|
+
"Set the ANTHROPIC_API_KEY environment variable.",
|
|
57
|
+
"Run `task-o-matic config set-ai-key <key>`",
|
|
58
|
+
],
|
|
59
|
+
});
|
|
49
60
|
return (0, anthropic_1.anthropic)(model);
|
|
50
61
|
case "openrouter":
|
|
51
62
|
if (!apiKey)
|
|
52
|
-
throw
|
|
63
|
+
throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.AI_CONFIGURATION_ERROR, "OpenRouter API key is required", {
|
|
64
|
+
suggestions: [
|
|
65
|
+
"Set the OPENROUTER_API_KEY environment variable.",
|
|
66
|
+
"Run `task-o-matic config set-ai-key <key>`",
|
|
67
|
+
],
|
|
68
|
+
});
|
|
53
69
|
const openRouterProvider = (0, ai_sdk_provider_1.createOpenRouter)({ apiKey });
|
|
54
70
|
return openRouterProvider(model);
|
|
55
71
|
case "custom":
|
|
56
72
|
if (!apiKey)
|
|
57
|
-
throw
|
|
73
|
+
throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.AI_CONFIGURATION_ERROR, "Custom API key is required for custom provider", {
|
|
74
|
+
suggestions: [
|
|
75
|
+
"Set the CUSTOM_API_KEY environment variable.",
|
|
76
|
+
"Run `task-o-matic config set-ai-key <key>`",
|
|
77
|
+
],
|
|
78
|
+
});
|
|
58
79
|
if (!baseURL)
|
|
59
|
-
throw
|
|
80
|
+
throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.AI_CONFIGURATION_ERROR, "Custom provider requires baseURL", {
|
|
81
|
+
suggestions: [
|
|
82
|
+
"Set the CUSTOM_API_URL environment variable.",
|
|
83
|
+
"Run `task-o-matic config set-ai-provider-url <url>`",
|
|
84
|
+
],
|
|
85
|
+
});
|
|
60
86
|
const customProvider = (0, openai_compatible_1.createOpenAICompatible)({
|
|
61
87
|
name: "custom",
|
|
62
88
|
apiKey,
|
|
@@ -64,7 +90,12 @@ class ModelProvider {
|
|
|
64
90
|
});
|
|
65
91
|
return customProvider(model);
|
|
66
92
|
default:
|
|
67
|
-
throw
|
|
93
|
+
throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.AI_CONFIGURATION_ERROR, `Unsupported provider: ${provider}`, {
|
|
94
|
+
suggestions: [
|
|
95
|
+
"Use one of the supported providers: 'openai', 'anthropic', 'openrouter', 'custom'.",
|
|
96
|
+
"Run `task-o-matic config set-ai-provider <provider>`",
|
|
97
|
+
],
|
|
98
|
+
});
|
|
68
99
|
}
|
|
69
100
|
}
|
|
70
101
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { AIConfig, Task, StreamingOptions, RetryConfig } from "../../types";
|
|
2
2
|
import { BaseOperations } from "./base-operations";
|
|
3
3
|
export declare class TaskOperations extends BaseOperations {
|
|
4
|
+
private aiOperationUtility;
|
|
4
5
|
breakdownTask(task: Task, config?: Partial<AIConfig>, promptOverride?: string, userMessage?: string, streamingOptions?: StreamingOptions, retryConfig?: Partial<RetryConfig>, fullContent?: string, stackInfo?: string, existingSubtasks?: Task[], enableFilesystemTools?: boolean): Promise<Array<{
|
|
5
6
|
title: string;
|
|
6
7
|
content: string;
|
|
7
8
|
estimatedEffort?: string;
|
|
8
9
|
}>>;
|
|
9
10
|
enhanceTask(title: string, description?: string, config?: Partial<AIConfig>, promptOverride?: string, userMessage?: string, taskId?: string, streamingOptions?: StreamingOptions, retryConfig?: Partial<RetryConfig>): Promise<string>;
|
|
10
|
-
planTask(taskContext: string, taskDetails: string, config?: Partial<AIConfig>, promptOverride?: string, userMessage?: string, streamingOptions?: StreamingOptions, retryConfig?: Partial<RetryConfig>): Promise<
|
|
11
|
+
planTask(taskContext: string, taskDetails: string, config?: Partial<AIConfig>, promptOverride?: string, userMessage?: string, streamingOptions?: StreamingOptions, retryConfig?: Partial<RetryConfig>): Promise<string>;
|
|
11
12
|
}
|
|
12
13
|
//# sourceMappingURL=task-operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-operations.d.ts","sourceRoot":"","sources":["../../../src/lib/ai-service/task-operations.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,IAAI,EACJ,gBAAgB,EAChB,WAAW,EAEZ,MAAM,aAAa,CAAC;AAUrB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"task-operations.d.ts","sourceRoot":"","sources":["../../../src/lib/ai-service/task-operations.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,IAAI,EACJ,gBAAgB,EAChB,WAAW,EAEZ,MAAM,aAAa,CAAC;AAUrB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,qBAAa,cAAe,SAAQ,cAAc;IAChD,OAAO,CAAC,kBAAkB,CAA4B;IAChD,aAAa,CACjB,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC1B,cAAc,CAAC,EAAE,MAAM,EACvB,WAAW,CAAC,EAAE,MAAM,EACpB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,EAClC,WAAW,CAAC,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,MAAM,EAClB,gBAAgB,CAAC,EAAE,IAAI,EAAE,EACzB,qBAAqB,CAAC,EAAE,OAAO,GAC9B,OAAO,CACR,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CACpE;IAmGK,WAAW,CACf,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC1B,cAAc,CAAC,EAAE,MAAM,EACvB,WAAW,CAAC,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GACjC,OAAO,CAAC,MAAM,CAAC;IAoFZ,QAAQ,CACZ,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC1B,cAAc,CAAC,EAAE,MAAM,EACvB,WAAW,CAAC,EAAE,MAAM,EACpB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GACjC,OAAO,CAAC,MAAM,CAAC;CA4DnB"}
|
|
@@ -1,95 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TaskOperations = void 0;
|
|
4
|
-
const ai_1 = require("ai");
|
|
5
4
|
const prompt_builder_1 = require("../prompt-builder");
|
|
6
5
|
const stack_formatter_1 = require("../../utils/stack-formatter");
|
|
7
6
|
const prompts_1 = require("../../prompts");
|
|
8
7
|
const ai_service_factory_1 = require("../../utils/ai-service-factory");
|
|
9
8
|
const filesystem_tools_1 = require("./filesystem-tools");
|
|
10
9
|
const base_operations_1 = require("./base-operations");
|
|
10
|
+
const ai_operation_utility_1 = require("../../utils/ai-operation-utility");
|
|
11
11
|
class TaskOperations extends base_operations_1.BaseOperations {
|
|
12
|
+
aiOperationUtility = new ai_operation_utility_1.AIOperationUtility();
|
|
12
13
|
async breakdownTask(task, config, promptOverride, userMessage, streamingOptions, retryConfig, fullContent, stackInfo, existingSubtasks, enableFilesystemTools) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
// Build prompt
|
|
15
|
+
let prompt;
|
|
16
|
+
if (promptOverride) {
|
|
17
|
+
prompt = promptOverride;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const variables = {
|
|
21
|
+
TASK_TITLE: task.title,
|
|
22
|
+
TASK_DESCRIPTION: task.description || "No description",
|
|
23
|
+
};
|
|
24
|
+
if (fullContent) {
|
|
25
|
+
variables.TASK_CONTENT = fullContent;
|
|
17
26
|
}
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
const promptResult = prompt_builder_1.PromptBuilder.buildPrompt({
|
|
36
|
-
name: "task-breakdown",
|
|
37
|
-
type: "user",
|
|
38
|
-
variables,
|
|
39
|
-
});
|
|
40
|
-
if (!promptResult.success) {
|
|
41
|
-
throw new Error(`Failed to build task breakdown prompt: ${promptResult.error}`);
|
|
42
|
-
}
|
|
43
|
-
prompt = promptResult.prompt;
|
|
27
|
+
if (existingSubtasks && existingSubtasks.length > 0) {
|
|
28
|
+
const existingSubtasksText = existingSubtasks
|
|
29
|
+
.map((subtask, index) => `${index + 1}. ${subtask.title}: ${subtask.description || "No description"}`)
|
|
30
|
+
.join("\n");
|
|
31
|
+
variables.EXISTING_SUBTASKS = existingSubtasksText;
|
|
32
|
+
}
|
|
33
|
+
if (stackInfo) {
|
|
34
|
+
variables.STACK_INFO = stackInfo;
|
|
35
|
+
}
|
|
36
|
+
const promptResult = prompt_builder_1.PromptBuilder.buildPrompt({
|
|
37
|
+
name: "task-breakdown",
|
|
38
|
+
type: "user",
|
|
39
|
+
variables,
|
|
40
|
+
});
|
|
41
|
+
if (!promptResult.success) {
|
|
42
|
+
throw new Error(`Failed to build task breakdown prompt: ${promptResult.error}`);
|
|
44
43
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const result = await (0, ai_1.streamText)({
|
|
55
|
-
model,
|
|
56
|
-
tools: allTools,
|
|
57
|
-
system: prompts_1.TASK_BREAKDOWN_SYSTEM_PROMPT +
|
|
58
|
-
`
|
|
44
|
+
prompt = promptResult.prompt;
|
|
45
|
+
}
|
|
46
|
+
// Execute AI operation with proper error handling
|
|
47
|
+
const result = await this.aiOperationUtility.executeAIOperation("Task breakdown", async () => {
|
|
48
|
+
// Prepare tools if filesystem tools are enabled
|
|
49
|
+
const tools = enableFilesystemTools ? filesystem_tools_1.filesystemTools : undefined;
|
|
50
|
+
const response = await this.aiOperationUtility.streamTextWithTools(prompts_1.TASK_BREAKDOWN_SYSTEM_PROMPT +
|
|
51
|
+
(enableFilesystemTools
|
|
52
|
+
? `
|
|
59
53
|
|
|
60
54
|
You have access to filesystem tools that allow you to:
|
|
61
55
|
- readFile: Read the contents of any file in the project
|
|
62
56
|
- listDirectory: List contents of directories
|
|
63
57
|
|
|
64
|
-
Use these tools to understand the project structure, existing code, and dependencies when breaking down tasks into subtasks
|
|
65
|
-
|
|
66
|
-
maxRetries: 0,
|
|
67
|
-
onChunk: streamingOptions?.onChunk
|
|
68
|
-
? ({ chunk }) => {
|
|
69
|
-
if (chunk.type === "text-delta") {
|
|
70
|
-
streamingOptions.onChunk(chunk.text);
|
|
71
|
-
}
|
|
72
|
-
else if (chunk.type === "reasoning-delta") {
|
|
73
|
-
streamingOptions.onReasoning?.(chunk.text);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
: undefined,
|
|
77
|
-
onFinish: streamingOptions?.onFinish
|
|
78
|
-
? ({ text, finishReason, usage }) => {
|
|
79
|
-
streamingOptions.onFinish({
|
|
80
|
-
text,
|
|
81
|
-
finishReason,
|
|
82
|
-
usage,
|
|
83
|
-
isAborted: false,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
: undefined,
|
|
87
|
-
});
|
|
88
|
-
response = await result.text;
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
response = await this.streamText("", config, prompts_1.TASK_BREAKDOWN_SYSTEM_PROMPT, userMessage || prompt, streamingOptions, { maxAttempts: 1 });
|
|
92
|
-
}
|
|
58
|
+
Use these tools to understand the project structure, existing code, and dependencies when breaking down tasks into subtasks.`
|
|
59
|
+
: ""), userMessage || prompt, config, streamingOptions, tools);
|
|
93
60
|
const parseResult = this.jsonParser.parseJSONFromResponse(response);
|
|
94
61
|
if (!parseResult.success) {
|
|
95
62
|
throw new Error(parseResult.error || "Failed to parse task breakdown response");
|
|
@@ -100,126 +67,121 @@ Use these tools to understand the project structure, existing code, and dependen
|
|
|
100
67
|
content: subtask.description || "",
|
|
101
68
|
estimatedEffort: subtask.effort,
|
|
102
69
|
}));
|
|
103
|
-
},
|
|
70
|
+
}, {
|
|
71
|
+
streamingOptions,
|
|
72
|
+
retryConfig,
|
|
73
|
+
aiConfig: config,
|
|
74
|
+
maxRetries: retryConfig?.maxAttempts || 2,
|
|
75
|
+
});
|
|
76
|
+
// Return the result directly (errors are thrown, not returned)
|
|
77
|
+
return result.result;
|
|
104
78
|
}
|
|
105
79
|
async enhanceTask(title, description, config, promptOverride, userMessage, taskId, streamingOptions, retryConfig) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (context.prdContent) {
|
|
127
|
-
prdContent = context.prdContent;
|
|
80
|
+
// Build context
|
|
81
|
+
let contextInfo = "";
|
|
82
|
+
let prdContent = "";
|
|
83
|
+
if (taskId) {
|
|
84
|
+
const contextBuilder = (0, ai_service_factory_1.getContextBuilder)();
|
|
85
|
+
try {
|
|
86
|
+
const context = await contextBuilder.buildContext(taskId);
|
|
87
|
+
if (context.documentation || context.stack || context.prdContent) {
|
|
88
|
+
contextInfo = "\n\nAvailable Context:\n";
|
|
89
|
+
if (context.stack) {
|
|
90
|
+
contextInfo += (0, stack_formatter_1.formatStackForContext)(context.stack) + "\n";
|
|
91
|
+
}
|
|
92
|
+
if (context.documentation) {
|
|
93
|
+
contextInfo += `Documentation Available: ${context.documentation.recap}\n`;
|
|
94
|
+
if (context.documentation.files.length > 0) {
|
|
95
|
+
contextInfo += `Documentation Files: ${context.documentation.files
|
|
96
|
+
.map((f) => f.path)
|
|
97
|
+
.join(", ")}\n`;
|
|
128
98
|
}
|
|
129
99
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
100
|
+
if (context.prdContent) {
|
|
101
|
+
prdContent = context.prdContent;
|
|
102
|
+
}
|
|
133
103
|
}
|
|
134
104
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
prompt = promptOverride;
|
|
105
|
+
catch (error) {
|
|
106
|
+
throw error;
|
|
138
107
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
108
|
+
}
|
|
109
|
+
// Build prompt
|
|
110
|
+
let prompt;
|
|
111
|
+
if (promptOverride) {
|
|
112
|
+
prompt = promptOverride;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const promptResult = prompt_builder_1.PromptBuilder.buildPrompt({
|
|
116
|
+
name: "task-enhancement",
|
|
117
|
+
type: "user",
|
|
118
|
+
variables: {
|
|
119
|
+
TASK_TITLE: title,
|
|
120
|
+
TASK_DESCRIPTION: description || "None",
|
|
121
|
+
CONTEXT_INFO: contextInfo,
|
|
122
|
+
PRD_CONTENT: prdContent || "No PRD content available",
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
if (!promptResult.success) {
|
|
126
|
+
throw new Error(`Failed to build task enhancement prompt: ${promptResult.error}`);
|
|
154
127
|
}
|
|
155
|
-
|
|
156
|
-
}
|
|
128
|
+
prompt = promptResult.prompt;
|
|
129
|
+
}
|
|
130
|
+
// Execute AI operation with proper error handling
|
|
131
|
+
const result = await this.aiOperationUtility.executeAIOperation("Task enhancement", async () => {
|
|
132
|
+
return await this.aiOperationUtility.streamText("", config, prompts_1.TASK_ENHANCEMENT_SYSTEM_PROMPT, userMessage || prompt, streamingOptions, { maxAttempts: 1 });
|
|
133
|
+
}, {
|
|
134
|
+
streamingOptions,
|
|
135
|
+
retryConfig,
|
|
136
|
+
aiConfig: config,
|
|
137
|
+
maxRetries: retryConfig?.maxAttempts || 2,
|
|
138
|
+
});
|
|
139
|
+
// Return the result directly (errors are thrown, not returned)
|
|
140
|
+
return result.result;
|
|
157
141
|
}
|
|
158
142
|
async planTask(taskContext, taskDetails, config, promptOverride, userMessage, streamingOptions, retryConfig) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
});
|
|
173
|
-
if (!promptResult.success) {
|
|
174
|
-
throw new Error(`Failed to build task planning prompt: ${promptResult.error}`);
|
|
175
|
-
}
|
|
176
|
-
prompt = promptResult.prompt;
|
|
177
|
-
}
|
|
178
|
-
const model = this.modelProvider.getModel({
|
|
179
|
-
...this.modelProvider.getAIConfig(),
|
|
180
|
-
...config,
|
|
143
|
+
// Build prompt
|
|
144
|
+
let prompt;
|
|
145
|
+
if (promptOverride) {
|
|
146
|
+
prompt = promptOverride;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const promptResult = prompt_builder_1.PromptBuilder.buildPrompt({
|
|
150
|
+
name: "task-planning",
|
|
151
|
+
type: "user",
|
|
152
|
+
variables: {
|
|
153
|
+
TASK_CONTEXT: taskContext,
|
|
154
|
+
TASK_DETAILS: taskDetails,
|
|
155
|
+
},
|
|
181
156
|
});
|
|
157
|
+
if (!promptResult.success) {
|
|
158
|
+
throw new Error(`Failed to build task planning prompt: ${promptResult.error}`);
|
|
159
|
+
}
|
|
160
|
+
prompt = promptResult.prompt;
|
|
161
|
+
}
|
|
162
|
+
// Execute AI operation with proper error handling
|
|
163
|
+
const result = await this.aiOperationUtility.executeAIOperation("Task planning", async () => {
|
|
182
164
|
const mcpTools = await this.context7Client.getMCPTools();
|
|
183
165
|
const allTools = {
|
|
184
166
|
...mcpTools,
|
|
185
167
|
...filesystem_tools_1.filesystemTools,
|
|
186
168
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
tools: allTools,
|
|
190
|
-
system: prompts_1.TASK_PLANNING_SYSTEM_PROMPT +
|
|
191
|
-
`
|
|
169
|
+
return await this.aiOperationUtility.streamTextWithTools(prompts_1.TASK_PLANNING_SYSTEM_PROMPT +
|
|
170
|
+
`
|
|
192
171
|
|
|
193
172
|
You have access to filesystem tools that allow you to:
|
|
194
173
|
- readFile: Read the contents of any file in the project
|
|
195
174
|
- listDirectory: List contents of directories
|
|
196
175
|
|
|
197
|
-
Use these tools to understand the project structure, existing code, and dependencies when creating implementation plans.`,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
streamingOptions.onReasoning?.(chunk.text);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
: undefined,
|
|
210
|
-
onFinish: streamingOptions?.onFinish
|
|
211
|
-
? ({ text, finishReason, usage }) => {
|
|
212
|
-
streamingOptions.onFinish({
|
|
213
|
-
text,
|
|
214
|
-
finishReason,
|
|
215
|
-
usage,
|
|
216
|
-
isAborted: false,
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
: undefined,
|
|
220
|
-
});
|
|
221
|
-
return (await result).text;
|
|
222
|
-
}, retryConfig, "Task planning");
|
|
176
|
+
Use these tools to understand the project structure, existing code, and dependencies when creating implementation plans.`, userMessage || prompt, config, streamingOptions, allTools);
|
|
177
|
+
}, {
|
|
178
|
+
streamingOptions,
|
|
179
|
+
retryConfig,
|
|
180
|
+
aiConfig: config,
|
|
181
|
+
maxRetries: retryConfig?.maxAttempts || 2,
|
|
182
|
+
});
|
|
183
|
+
// Return the result directly (errors are thrown, not returned)
|
|
184
|
+
return result.result;
|
|
223
185
|
}
|
|
224
186
|
}
|
|
225
187
|
exports.TaskOperations = TaskOperations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/lib/benchmark/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAA0B,MAAM,SAAS,CAAC;AAOzE,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAkD;;IAMpE,QAAQ,CAAC,EAAE,EAAE,sBAAsB;IAInC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS;IAInD,IAAI,IAAI,sBAAsB,EAAE;IAIhC,OAAO,CAAC,gBAAgB;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/lib/benchmark/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAA0B,MAAM,SAAS,CAAC;AAOzE,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAkD;;IAMpE,QAAQ,CAAC,EAAE,EAAE,sBAAsB;IAInC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS;IAInD,IAAI,IAAI,sBAAsB,EAAE;IAIhC,OAAO,CAAC,gBAAgB;CAsRzB;AAED,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.benchmarkRegistry = exports.BenchmarkRegistry = void 0;
|
|
4
4
|
const prd_1 = require("../../services/prd");
|
|
5
|
-
const tasks_1 = require("../../services/tasks");
|
|
5
|
+
const tasks_1 = require("../../services/tasks");
|
|
6
6
|
const workflow_benchmark_1 = require("../../services/workflow-benchmark");
|
|
7
7
|
class BenchmarkRegistry {
|
|
8
8
|
operations = new Map();
|
|
@@ -59,17 +59,13 @@ class BenchmarkRegistry {
|
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
61
|
// Task Breakdown Adapter
|
|
62
|
-
// Note: TaskService is a class, we need an instance.
|
|
63
|
-
// In a real app we should use dependency injection or a singleton.
|
|
64
|
-
// For now, we'll create a new instance or assume one is available.
|
|
65
|
-
const taskService = new tasks_1.TaskService();
|
|
66
62
|
this.register({
|
|
67
63
|
id: "task-breakdown",
|
|
68
64
|
name: "Task Breakdown",
|
|
69
65
|
description: "Break down a task into subtasks",
|
|
70
66
|
validateInput: (input) => typeof input.taskId === "string",
|
|
71
67
|
execute: async (input, aiOptions, streamingOptions) => {
|
|
72
|
-
return await taskService.splitTask(input.taskId, aiOptions, input.prompt, input.message, streamingOptions, // streaming options
|
|
68
|
+
return await tasks_1.taskService.splitTask(input.taskId, aiOptions, input.prompt, input.message, streamingOptions, // streaming options
|
|
73
69
|
input.tools);
|
|
74
70
|
},
|
|
75
71
|
});
|
|
@@ -90,7 +86,7 @@ class BenchmarkRegistry {
|
|
|
90
86
|
description: "Create a new task with AI enhancement using Context7 documentation",
|
|
91
87
|
validateInput: (input) => typeof input.title === "string" && input.title.length > 0,
|
|
92
88
|
execute: async (input, aiOptions, streamingOptions) => {
|
|
93
|
-
return await taskService.createTask({
|
|
89
|
+
return await tasks_1.taskService.createTask({
|
|
94
90
|
title: input.title,
|
|
95
91
|
content: input.content,
|
|
96
92
|
parentId: input.parentId,
|
|
@@ -108,7 +104,7 @@ class BenchmarkRegistry {
|
|
|
108
104
|
description: "Enhance an existing task with AI using Context7 documentation",
|
|
109
105
|
validateInput: (input) => typeof input.taskId === "string",
|
|
110
106
|
execute: async (input, aiOptions, streamingOptions) => {
|
|
111
|
-
return await taskService.enhanceTask(input.taskId, aiOptions, streamingOptions);
|
|
107
|
+
return await tasks_1.taskService.enhanceTask(input.taskId, aiOptions, streamingOptions);
|
|
112
108
|
},
|
|
113
109
|
});
|
|
114
110
|
// Task Planning
|
|
@@ -118,7 +114,7 @@ class BenchmarkRegistry {
|
|
|
118
114
|
description: "Create a detailed implementation plan for a task",
|
|
119
115
|
validateInput: (input) => typeof input.taskId === "string",
|
|
120
116
|
execute: async (input, aiOptions, streamingOptions) => {
|
|
121
|
-
return await taskService.planTask(input.taskId, aiOptions, streamingOptions);
|
|
117
|
+
return await tasks_1.taskService.planTask(input.taskId, aiOptions, streamingOptions);
|
|
122
118
|
},
|
|
123
119
|
});
|
|
124
120
|
// Task Documentation
|
|
@@ -128,7 +124,7 @@ class BenchmarkRegistry {
|
|
|
128
124
|
description: "Analyze and generate documentation for a task",
|
|
129
125
|
validateInput: (input) => typeof input.taskId === "string",
|
|
130
126
|
execute: async (input, aiOptions, streamingOptions) => {
|
|
131
|
-
return await taskService.documentTask(input.taskId, input.force || false, aiOptions, streamingOptions);
|
|
127
|
+
return await tasks_1.taskService.documentTask(input.taskId, input.force || false, aiOptions, streamingOptions);
|
|
132
128
|
},
|
|
133
129
|
});
|
|
134
130
|
// PRD Creation
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BTSConfig } from "../types";
|
|
1
|
+
import { BTSConfig, InitOptions } from "../types";
|
|
2
2
|
export declare class BetterTStackService {
|
|
3
3
|
createProject(name: string, config: BTSConfig, workingDirectory?: string): Promise<{
|
|
4
4
|
success: boolean;
|
|
@@ -10,26 +10,41 @@ export declare class BetterTStackService {
|
|
|
10
10
|
private addCheckTypesScript;
|
|
11
11
|
private copyDocumentation;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
export declare class BetterTStackIntegration {
|
|
14
|
+
private btsService;
|
|
15
|
+
constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Parse frontend option into array of frontends
|
|
18
|
+
*/
|
|
19
|
+
private parseFrontends;
|
|
20
|
+
/**
|
|
21
|
+
* Split frontends into Better-T-Stack frontends vs custom frontends
|
|
22
|
+
*/
|
|
23
|
+
private splitFrontends;
|
|
24
|
+
/**
|
|
25
|
+
* Create project with support for multiple frontends
|
|
26
|
+
*/
|
|
27
|
+
createProject(name: string, options: InitOptions, workingDirectory?: string): Promise<{
|
|
28
|
+
success: boolean;
|
|
29
|
+
message: string;
|
|
30
|
+
projectPath?: string;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Bootstrap Better-T-Stack project with one or more frontends
|
|
34
|
+
*/
|
|
35
|
+
private bootstrapBetterTStackProject;
|
|
36
|
+
/**
|
|
37
|
+
* Add CLI app to project (standalone or monorepo)
|
|
38
|
+
*/
|
|
39
|
+
private addCliToProject;
|
|
40
|
+
/**
|
|
41
|
+
* Add TUI app to project (standalone or monorepo)
|
|
42
|
+
*/
|
|
43
|
+
private addTuiToProject;
|
|
44
|
+
/**
|
|
45
|
+
* Add MedusaJS app to project (standalone or monorepo)
|
|
46
|
+
*/
|
|
47
|
+
private addMedusaToProject;
|
|
33
48
|
}
|
|
34
49
|
export declare function runBetterTStackCLI(options: InitOptions, workingDirectory?: string): Promise<{
|
|
35
50
|
success: boolean;
|