task-o-matic 0.0.12 → 0.0.13
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/commands/tasks/create.d.ts.map +1 -1
- package/dist/commands/tasks/create.js +6 -13
- package/dist/commands/tasks/document/add.d.ts +3 -0
- package/dist/commands/tasks/document/add.d.ts.map +1 -0
- package/dist/commands/tasks/document/add.js +35 -0
- package/dist/commands/tasks/document/analyze.d.ts +3 -0
- package/dist/commands/tasks/document/analyze.d.ts.map +1 -0
- package/dist/commands/tasks/document/analyze.js +49 -0
- package/dist/commands/tasks/document/get.d.ts +3 -0
- package/dist/commands/tasks/document/get.d.ts.map +1 -0
- package/dist/commands/tasks/document/get.js +29 -0
- package/dist/commands/tasks/document/index.d.ts +8 -0
- package/dist/commands/tasks/document/index.d.ts.map +1 -0
- package/dist/commands/tasks/document/index.js +13 -0
- package/dist/commands/tasks/enhance.d.ts.map +1 -1
- package/dist/commands/tasks/enhance.js +64 -61
- package/dist/commands/tasks/execute-loop.d.ts.map +1 -1
- package/dist/commands/tasks/execute-loop.js +64 -90
- package/dist/commands/tasks/execute.d.ts.map +1 -1
- package/dist/commands/tasks/execute.js +52 -16
- package/dist/commands/tasks/plan/create.d.ts +3 -0
- package/dist/commands/tasks/plan/create.d.ts.map +1 -0
- package/dist/commands/tasks/plan/create.js +37 -0
- package/dist/commands/tasks/plan/delete.d.ts +3 -0
- package/dist/commands/tasks/plan/delete.d.ts.map +1 -0
- package/dist/commands/tasks/plan/delete.js +14 -0
- package/dist/commands/tasks/plan/get.d.ts +3 -0
- package/dist/commands/tasks/plan/get.d.ts.map +1 -0
- package/dist/commands/tasks/plan/get.js +24 -0
- package/dist/commands/tasks/plan/index.d.ts +10 -0
- package/dist/commands/tasks/plan/index.d.ts.map +1 -0
- package/dist/commands/tasks/plan/index.js +17 -0
- package/dist/commands/tasks/plan/list.d.ts +3 -0
- package/dist/commands/tasks/plan/list.d.ts.map +1 -0
- package/dist/commands/tasks/plan/list.js +21 -0
- package/dist/commands/tasks/plan/set.d.ts +3 -0
- package/dist/commands/tasks/plan/set.d.ts.map +1 -0
- package/dist/commands/tasks/plan/set.js +33 -0
- package/dist/commands/tasks/split.d.ts.map +1 -1
- package/dist/commands/tasks/split.js +65 -60
- package/dist/lib/git-utils.d.ts +45 -0
- package/dist/lib/git-utils.d.ts.map +1 -0
- package/dist/lib/git-utils.js +160 -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 +360 -0
- package/dist/lib/task-execution.d.ts +4 -0
- package/dist/lib/task-execution.d.ts.map +1 -1
- package/dist/lib/task-execution.js +31 -149
- package/dist/lib/task-loop-execution.d.ts +1 -19
- package/dist/lib/task-loop-execution.d.ts.map +1 -1
- package/dist/lib/task-loop-execution.js +50 -585
- package/dist/lib/task-planning.d.ts +28 -0
- package/dist/lib/task-planning.d.ts.map +1 -0
- package/dist/lib/task-planning.js +109 -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 +106 -0
- package/dist/lib/validation.d.ts +20 -3
- package/dist/lib/validation.d.ts.map +1 -1
- package/dist/lib/validation.js +39 -10
- package/dist/test/task-loop-git.test.js +6 -6
- package/dist/types/cli-options.d.ts +138 -0
- package/dist/types/cli-options.d.ts.map +1 -0
- package/dist/types/cli-options.js +6 -0
- package/dist/types/index.d.ts +38 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/bulk-operations.d.ts +51 -0
- package/dist/utils/bulk-operations.d.ts.map +1 -0
- package/dist/utils/bulk-operations.js +68 -0
- package/dist/utils/cli-validators.d.ts +54 -0
- package/dist/utils/cli-validators.d.ts.map +1 -0
- package/dist/utils/cli-validators.js +75 -0
- package/dist/utils/command-error-handler.d.ts +32 -0
- package/dist/utils/command-error-handler.d.ts.map +1 -0
- package/dist/utils/command-error-handler.js +52 -0
- package/dist/utils/confirmation.d.ts +19 -0
- package/dist/utils/confirmation.d.ts.map +1 -0
- package/dist/utils/confirmation.js +39 -0
- package/dist/utils/display-helpers.d.ts +81 -0
- package/dist/utils/display-helpers.d.ts.map +1 -0
- package/dist/utils/display-helpers.js +109 -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 +67 -0
- package/dist/utils/progress-tracking.d.ts +28 -0
- package/dist/utils/progress-tracking.d.ts.map +1 -0
- package/dist/utils/progress-tracking.js +43 -0
- package/package.json +1 -1
- package/dist/commands/tasks/document.d.ts +0 -5
- package/dist/commands/tasks/document.d.ts.map +0 -1
- package/dist/commands/tasks/document.js +0 -118
- package/dist/commands/tasks/plan.d.ts +0 -7
- package/dist/commands/tasks/plan.d.ts.map +0 -1
- package/dist/commands/tasks/plan.js +0 -131
|
@@ -1,157 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.executeTask = executeTask;
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const prompt_builder_1 = require("./prompt-builder");
|
|
13
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
-
async function executeSingleTask(taskId, tool, dry, executorConfig) {
|
|
15
|
-
// Load task
|
|
16
|
-
const task = await tasks_1.taskService.getTask(taskId);
|
|
17
|
-
if (!task) {
|
|
18
|
-
throw new Error(`Task with ID ${taskId} not found`);
|
|
19
|
-
}
|
|
20
|
-
console.log(chalk_1.default.blue(`🎯 ${dry ? "DRY RUN" : "Executing"} task: ${task.title} (${taskId})`));
|
|
21
|
-
// Build comprehensive execution message with full context
|
|
22
|
-
const contextBuilder = (0, ai_service_factory_1.getContextBuilder)();
|
|
23
|
-
const taskContext = await contextBuilder.buildContext(taskId);
|
|
24
|
-
// Get task plan if available
|
|
25
|
-
const planData = await tasks_1.taskService.getTaskPlan(taskId);
|
|
26
|
-
// Build execution prompt using PromptBuilder
|
|
27
|
-
const promptResult = prompt_builder_1.PromptBuilder.buildExecutionPrompt({
|
|
28
|
-
taskTitle: task.title,
|
|
29
|
-
taskDescription: task.description,
|
|
30
|
-
taskPlan: planData?.plan,
|
|
31
|
-
stack: taskContext.stack,
|
|
32
|
-
documentation: taskContext.documentation,
|
|
33
|
-
});
|
|
34
|
-
if (!promptResult.success) {
|
|
35
|
-
throw new Error(`Failed to build execution prompt: ${promptResult.error}`);
|
|
36
|
-
}
|
|
37
|
-
const executionMessage = promptResult.prompt;
|
|
38
|
-
if (!dry) {
|
|
39
|
-
// Update task status to in-progress
|
|
40
|
-
await tasks_1.taskService.setTaskStatus(taskId, "in-progress");
|
|
41
|
-
console.log(chalk_1.default.yellow("⏳ Task status updated to in-progress"));
|
|
42
|
-
}
|
|
43
|
-
// Emit execution:start event
|
|
44
|
-
await hooks_1.hooks.emit("execution:start", { taskId, tool });
|
|
45
|
-
try {
|
|
46
|
-
// Create executor and run
|
|
47
|
-
const executor = executor_factory_1.ExecutorFactory.create(tool, executorConfig);
|
|
48
|
-
await executor.execute(executionMessage, dry, executorConfig);
|
|
49
|
-
if (!dry) {
|
|
50
|
-
// Update task status to completed
|
|
51
|
-
await tasks_1.taskService.setTaskStatus(taskId, "completed");
|
|
52
|
-
console.log(chalk_1.default.green("✅ Task execution completed successfully"));
|
|
53
|
-
}
|
|
54
|
-
// Emit execution:end event
|
|
55
|
-
await hooks_1.hooks.emit("execution:end", { taskId, success: true });
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
// Emit execution:error event
|
|
59
|
-
await hooks_1.hooks.emit("execution:error", {
|
|
60
|
-
taskId,
|
|
61
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
62
|
-
});
|
|
63
|
-
if (!dry) {
|
|
64
|
-
// Update task status back to todo on failure
|
|
65
|
-
await tasks_1.taskService.setTaskStatus(taskId, "todo");
|
|
66
|
-
console.log(chalk_1.default.red("❌ Task execution failed, status reset to todo"));
|
|
67
|
-
}
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
async function executeTaskWithSubtasks(taskId, tool, dry, executorConfig) {
|
|
72
|
-
const task = await tasks_1.taskService.getTask(taskId);
|
|
73
|
-
if (!task) {
|
|
74
|
-
throw new Error(`Task with ID ${taskId} not found`);
|
|
75
|
-
}
|
|
76
|
-
// Get subtasks
|
|
77
|
-
const subtasks = await tasks_1.taskService.getSubtasks(taskId);
|
|
78
|
-
if (subtasks.length === 0) {
|
|
79
|
-
// No subtasks, execute this task directly
|
|
80
|
-
await executeSingleTask(taskId, tool, dry);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
// Has subtasks - execute them one by one
|
|
84
|
-
console.log(chalk_1.default.blue(`📋 Task has ${subtasks.length} subtasks, executing recursively...`));
|
|
85
|
-
for (let i = 0; i < subtasks.length; i++) {
|
|
86
|
-
const subtask = subtasks[i];
|
|
87
|
-
console.log(chalk_1.default.cyan(`\n[${i + 1}/${subtasks.length}] Executing subtask: ${subtask.title} (${subtask.id})`));
|
|
88
|
-
try {
|
|
89
|
-
await executeTaskWithSubtasks(subtask.id, tool, dry, executorConfig);
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
console.error(chalk_1.default.red(`❌ Failed to execute subtask ${subtask.id}: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
93
|
-
throw error;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
// After all subtasks are done, mark the main task as completed
|
|
97
|
-
if (!dry) {
|
|
98
|
-
await tasks_1.taskService.setTaskStatus(taskId, "completed");
|
|
99
|
-
console.log(chalk_1.default.green(`✅ Main task ${task.title} completed after all subtasks`));
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
console.log(chalk_1.default.cyan(`🔍 DRY RUN - Main task ${task.title} would be completed after all subtasks`));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
4
|
+
const task_execution_core_1 = require("./task-execution-core");
|
|
5
|
+
/**
|
|
6
|
+
* Execute a task using an external coding assistant
|
|
7
|
+
* This is the simplified entry point that delegates to the unified core
|
|
8
|
+
*/
|
|
105
9
|
async function executeTask(options) {
|
|
106
|
-
const { taskId, tool = "opencode", message, model, continueSession, dry = false, validate = [], } = options;
|
|
107
|
-
// Build
|
|
108
|
-
const
|
|
109
|
-
|
|
10
|
+
const { taskId, tool = "opencode", message, model, continueSession, dry = false, validate = [], maxRetries, tryModels, plan, planModel, reviewPlan, review, reviewModel, autoCommit, } = options;
|
|
11
|
+
// Build unified task execution config
|
|
12
|
+
const config = {
|
|
13
|
+
tool,
|
|
14
|
+
executorConfig: {
|
|
110
15
|
model,
|
|
111
16
|
continueLastSession: continueSession,
|
|
112
|
-
}
|
|
113
|
-
:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
// Emit execution:end event
|
|
135
|
-
await hooks_1.hooks.emit("execution:end", { taskId, success: true });
|
|
136
|
-
// Run validations after task completion
|
|
137
|
-
await (0, validation_1.runValidations)(validate, dry);
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
if (!dry) {
|
|
141
|
-
await tasks_1.taskService.setTaskStatus(taskId, "todo");
|
|
142
|
-
console.log(chalk_1.default.red("❌ Task execution failed, status reset to todo"));
|
|
143
|
-
}
|
|
144
|
-
// Emit execution:error event
|
|
145
|
-
await hooks_1.hooks.emit("execution:error", {
|
|
146
|
-
taskId,
|
|
147
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
148
|
-
});
|
|
149
|
-
throw error;
|
|
150
|
-
}
|
|
151
|
-
return;
|
|
17
|
+
},
|
|
18
|
+
customMessage: message,
|
|
19
|
+
verificationCommands: validate,
|
|
20
|
+
enableRetry: maxRetries !== undefined && maxRetries > 0, // Opt-in retry
|
|
21
|
+
maxRetries: maxRetries || 3,
|
|
22
|
+
tryModels,
|
|
23
|
+
enablePlanPhase: plan,
|
|
24
|
+
planModel,
|
|
25
|
+
reviewPlan,
|
|
26
|
+
enableReviewPhase: review,
|
|
27
|
+
reviewModel,
|
|
28
|
+
autoCommit,
|
|
29
|
+
executeSubtasks: true, // Always execute subtasks in execute command
|
|
30
|
+
dry,
|
|
31
|
+
};
|
|
32
|
+
// Delegate to unified core execution
|
|
33
|
+
const result = await (0, task_execution_core_1.executeTaskCore)(taskId, config);
|
|
34
|
+
// Throw error if execution failed (maintains backward compatibility)
|
|
35
|
+
if (!result.success) {
|
|
36
|
+
const lastAttempt = result.attempts[result.attempts.length - 1];
|
|
37
|
+
throw new Error(lastAttempt?.error || "Task execution failed");
|
|
152
38
|
}
|
|
153
|
-
// No custom message - execute recursively with subtasks
|
|
154
|
-
await executeTaskWithSubtasks(taskId, tool, dry, executorConfig);
|
|
155
|
-
// Run validations after all subtasks complete
|
|
156
|
-
await (0, validation_1.runValidations)(validate, dry);
|
|
157
39
|
}
|
|
@@ -1,25 +1,7 @@
|
|
|
1
1
|
import { ExecuteLoopOptions, ExecuteLoopResult } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* Extract commit message and file list from AI conversation/output
|
|
4
|
-
* This function analyzes the executor's work and generates appropriate commit info
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Extract commit message and file list from git state
|
|
8
|
-
* This function analyzes the actual git state to generate appropriate commit info
|
|
9
|
-
*/
|
|
10
|
-
export declare function extractCommitInfo(taskId: string, taskTitle: string, executionMessage: string, gitState: {
|
|
11
|
-
beforeHead: string;
|
|
12
|
-
afterHead: string;
|
|
13
|
-
hasUncommittedChanges: boolean;
|
|
14
|
-
}, execFn?: (command: string) => Promise<{
|
|
15
|
-
stdout: string;
|
|
16
|
-
stderr: string;
|
|
17
|
-
}>, aiOps?: any): Promise<{
|
|
18
|
-
message: string;
|
|
19
|
-
files: string[];
|
|
20
|
-
}>;
|
|
21
2
|
/**
|
|
22
3
|
* Execute multiple tasks in a loop with retry and verification
|
|
4
|
+
* This delegates to the unified executeTaskCore for each task
|
|
23
5
|
*/
|
|
24
6
|
export declare function executeTaskLoop(options: ExecuteLoopOptions): Promise<ExecuteLoopResult>;
|
|
25
7
|
//# sourceMappingURL=task-loop-execution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-loop-execution.d.ts","sourceRoot":"","sources":["../../src/lib/task-loop-execution.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"task-loop-execution.d.ts","sourceRoot":"","sources":["../../src/lib/task-loop-execution.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EAIlB,MAAM,UAAU,CAAC;AAIlB;;;GAGG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAgL5B"}
|