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.
Files changed (95) hide show
  1. package/dist/commands/tasks/create.d.ts.map +1 -1
  2. package/dist/commands/tasks/create.js +6 -13
  3. package/dist/commands/tasks/document/add.d.ts +3 -0
  4. package/dist/commands/tasks/document/add.d.ts.map +1 -0
  5. package/dist/commands/tasks/document/add.js +35 -0
  6. package/dist/commands/tasks/document/analyze.d.ts +3 -0
  7. package/dist/commands/tasks/document/analyze.d.ts.map +1 -0
  8. package/dist/commands/tasks/document/analyze.js +49 -0
  9. package/dist/commands/tasks/document/get.d.ts +3 -0
  10. package/dist/commands/tasks/document/get.d.ts.map +1 -0
  11. package/dist/commands/tasks/document/get.js +29 -0
  12. package/dist/commands/tasks/document/index.d.ts +8 -0
  13. package/dist/commands/tasks/document/index.d.ts.map +1 -0
  14. package/dist/commands/tasks/document/index.js +13 -0
  15. package/dist/commands/tasks/enhance.d.ts.map +1 -1
  16. package/dist/commands/tasks/enhance.js +64 -61
  17. package/dist/commands/tasks/execute-loop.d.ts.map +1 -1
  18. package/dist/commands/tasks/execute-loop.js +64 -90
  19. package/dist/commands/tasks/execute.d.ts.map +1 -1
  20. package/dist/commands/tasks/execute.js +52 -16
  21. package/dist/commands/tasks/plan/create.d.ts +3 -0
  22. package/dist/commands/tasks/plan/create.d.ts.map +1 -0
  23. package/dist/commands/tasks/plan/create.js +37 -0
  24. package/dist/commands/tasks/plan/delete.d.ts +3 -0
  25. package/dist/commands/tasks/plan/delete.d.ts.map +1 -0
  26. package/dist/commands/tasks/plan/delete.js +14 -0
  27. package/dist/commands/tasks/plan/get.d.ts +3 -0
  28. package/dist/commands/tasks/plan/get.d.ts.map +1 -0
  29. package/dist/commands/tasks/plan/get.js +24 -0
  30. package/dist/commands/tasks/plan/index.d.ts +10 -0
  31. package/dist/commands/tasks/plan/index.d.ts.map +1 -0
  32. package/dist/commands/tasks/plan/index.js +17 -0
  33. package/dist/commands/tasks/plan/list.d.ts +3 -0
  34. package/dist/commands/tasks/plan/list.d.ts.map +1 -0
  35. package/dist/commands/tasks/plan/list.js +21 -0
  36. package/dist/commands/tasks/plan/set.d.ts +3 -0
  37. package/dist/commands/tasks/plan/set.d.ts.map +1 -0
  38. package/dist/commands/tasks/plan/set.js +33 -0
  39. package/dist/commands/tasks/split.d.ts.map +1 -1
  40. package/dist/commands/tasks/split.js +65 -60
  41. package/dist/lib/git-utils.d.ts +45 -0
  42. package/dist/lib/git-utils.d.ts.map +1 -0
  43. package/dist/lib/git-utils.js +160 -0
  44. package/dist/lib/task-execution-core.d.ts +7 -0
  45. package/dist/lib/task-execution-core.d.ts.map +1 -0
  46. package/dist/lib/task-execution-core.js +360 -0
  47. package/dist/lib/task-execution.d.ts +4 -0
  48. package/dist/lib/task-execution.d.ts.map +1 -1
  49. package/dist/lib/task-execution.js +31 -149
  50. package/dist/lib/task-loop-execution.d.ts +1 -19
  51. package/dist/lib/task-loop-execution.d.ts.map +1 -1
  52. package/dist/lib/task-loop-execution.js +50 -585
  53. package/dist/lib/task-planning.d.ts +28 -0
  54. package/dist/lib/task-planning.d.ts.map +1 -0
  55. package/dist/lib/task-planning.js +109 -0
  56. package/dist/lib/task-review.d.ts +27 -0
  57. package/dist/lib/task-review.d.ts.map +1 -0
  58. package/dist/lib/task-review.js +106 -0
  59. package/dist/lib/validation.d.ts +20 -3
  60. package/dist/lib/validation.d.ts.map +1 -1
  61. package/dist/lib/validation.js +39 -10
  62. package/dist/test/task-loop-git.test.js +6 -6
  63. package/dist/types/cli-options.d.ts +138 -0
  64. package/dist/types/cli-options.d.ts.map +1 -0
  65. package/dist/types/cli-options.js +6 -0
  66. package/dist/types/index.d.ts +38 -0
  67. package/dist/types/index.d.ts.map +1 -1
  68. package/dist/utils/bulk-operations.d.ts +51 -0
  69. package/dist/utils/bulk-operations.d.ts.map +1 -0
  70. package/dist/utils/bulk-operations.js +68 -0
  71. package/dist/utils/cli-validators.d.ts +54 -0
  72. package/dist/utils/cli-validators.d.ts.map +1 -0
  73. package/dist/utils/cli-validators.js +75 -0
  74. package/dist/utils/command-error-handler.d.ts +32 -0
  75. package/dist/utils/command-error-handler.d.ts.map +1 -0
  76. package/dist/utils/command-error-handler.js +52 -0
  77. package/dist/utils/confirmation.d.ts +19 -0
  78. package/dist/utils/confirmation.d.ts.map +1 -0
  79. package/dist/utils/confirmation.js +39 -0
  80. package/dist/utils/display-helpers.d.ts +81 -0
  81. package/dist/utils/display-helpers.d.ts.map +1 -0
  82. package/dist/utils/display-helpers.js +109 -0
  83. package/dist/utils/model-executor-parser.d.ts +38 -0
  84. package/dist/utils/model-executor-parser.d.ts.map +1 -0
  85. package/dist/utils/model-executor-parser.js +67 -0
  86. package/dist/utils/progress-tracking.d.ts +28 -0
  87. package/dist/utils/progress-tracking.d.ts.map +1 -0
  88. package/dist/utils/progress-tracking.js +43 -0
  89. package/package.json +1 -1
  90. package/dist/commands/tasks/document.d.ts +0 -5
  91. package/dist/commands/tasks/document.d.ts.map +0 -1
  92. package/dist/commands/tasks/document.js +0 -118
  93. package/dist/commands/tasks/plan.d.ts +0 -7
  94. package/dist/commands/tasks/plan.d.ts.map +0 -1
  95. 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 tasks_1 = require("../services/tasks");
8
- const executor_factory_1 = require("./executors/executor-factory");
9
- const validation_1 = require("./validation");
10
- const ai_service_factory_1 = require("../utils/ai-service-factory");
11
- const hooks_1 = require("./hooks");
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 executor config from options
108
- const executorConfig = model || continueSession
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
- : undefined;
114
- // If custom message is provided, execute just this task (ignore subtasks)
115
- if (message) {
116
- const task = await tasks_1.taskService.getTask(taskId);
117
- if (!task) {
118
- throw new Error(`Task with ID ${taskId} not found`);
119
- }
120
- console.log(chalk_1.default.blue(`🎯 ${dry ? "DRY RUN - Would execute" : "Executing"} task with custom message: ${task.title} (${taskId})`));
121
- if (!dry) {
122
- await tasks_1.taskService.setTaskStatus(taskId, "in-progress");
123
- console.log(chalk_1.default.yellow("⏳ Task status updated to in-progress"));
124
- }
125
- // Emit execution:start event
126
- await hooks_1.hooks.emit("execution:start", { taskId, tool });
127
- try {
128
- const executor = executor_factory_1.ExecutorFactory.create(tool, executorConfig);
129
- await executor.execute(message, dry, executorConfig);
130
- if (!dry) {
131
- await tasks_1.taskService.setTaskStatus(taskId, "completed");
132
- console.log(chalk_1.default.green("Task execution completed successfully"));
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,EAMlB,MAAM,UAAU,CAAC;AAgBlB;;;GAGG;AACH;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE;IACR,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB,EAAE,OAAO,CAAC;CAChC,EACD,MAAM,GAAE,CACN,OAAO,EAAE,MAAM,KACZ,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAa,EAC5D,KAAK,GAAE,GAAuB,GAC7B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA+G/C;AA6oBD;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAmK5B"}
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"}