olympus-ai 3.4.1 → 3.5.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.
Files changed (90) hide show
  1. package/README.md +631 -630
  2. package/dist/__tests__/workflow-engine/checkpoint.test.d.ts +7 -0
  3. package/dist/__tests__/workflow-engine/checkpoint.test.d.ts.map +1 -0
  4. package/dist/__tests__/workflow-engine/checkpoint.test.js +373 -0
  5. package/dist/__tests__/workflow-engine/checkpoint.test.js.map +1 -0
  6. package/dist/agents/definitions.d.ts.map +1 -1
  7. package/dist/agents/definitions.js +8 -0
  8. package/dist/agents/definitions.js.map +1 -1
  9. package/dist/agents/idea-intake.d.ts +20 -0
  10. package/dist/agents/idea-intake.d.ts.map +1 -0
  11. package/dist/agents/idea-intake.js +255 -0
  12. package/dist/agents/idea-intake.js.map +1 -0
  13. package/dist/agents/index.d.ts +4 -0
  14. package/dist/agents/index.d.ts.map +1 -1
  15. package/dist/agents/index.js +4 -0
  16. package/dist/agents/index.js.map +1 -1
  17. package/dist/agents/intent-generator.d.ts +19 -0
  18. package/dist/agents/intent-generator.d.ts.map +1 -0
  19. package/dist/agents/intent-generator.js +303 -0
  20. package/dist/agents/intent-generator.js.map +1 -0
  21. package/dist/agents/prd-writer.d.ts +19 -0
  22. package/dist/agents/prd-writer.d.ts.map +1 -0
  23. package/dist/agents/prd-writer.js +236 -0
  24. package/dist/agents/prd-writer.js.map +1 -0
  25. package/dist/agents/prometheus.d.ts.map +1 -1
  26. package/dist/agents/prometheus.js +96 -2
  27. package/dist/agents/prometheus.js.map +1 -1
  28. package/dist/agents/spec-writer.d.ts +19 -0
  29. package/dist/agents/spec-writer.d.ts.map +1 -0
  30. package/dist/agents/spec-writer.js +528 -0
  31. package/dist/agents/spec-writer.js.map +1 -0
  32. package/dist/features/index.d.ts +1 -0
  33. package/dist/features/index.d.ts.map +1 -1
  34. package/dist/features/index.js +6 -0
  35. package/dist/features/index.js.map +1 -1
  36. package/dist/features/workflow-engine/artifacts.d.ts +96 -0
  37. package/dist/features/workflow-engine/artifacts.d.ts.map +1 -0
  38. package/dist/features/workflow-engine/artifacts.js +399 -0
  39. package/dist/features/workflow-engine/artifacts.js.map +1 -0
  40. package/dist/features/workflow-engine/checkpoint.d.ts +67 -0
  41. package/dist/features/workflow-engine/checkpoint.d.ts.map +1 -0
  42. package/dist/features/workflow-engine/checkpoint.js +249 -0
  43. package/dist/features/workflow-engine/checkpoint.js.map +1 -0
  44. package/dist/features/workflow-engine/engine.d.ts +128 -0
  45. package/dist/features/workflow-engine/engine.d.ts.map +1 -0
  46. package/dist/features/workflow-engine/engine.js +600 -0
  47. package/dist/features/workflow-engine/engine.js.map +1 -0
  48. package/dist/features/workflow-engine/execution.d.ts +99 -0
  49. package/dist/features/workflow-engine/execution.d.ts.map +1 -0
  50. package/dist/features/workflow-engine/execution.js +493 -0
  51. package/dist/features/workflow-engine/execution.js.map +1 -0
  52. package/dist/features/workflow-engine/hooks.d.ts +78 -0
  53. package/dist/features/workflow-engine/hooks.d.ts.map +1 -0
  54. package/dist/features/workflow-engine/hooks.js +188 -0
  55. package/dist/features/workflow-engine/hooks.js.map +1 -0
  56. package/dist/features/workflow-engine/index.d.ts +17 -0
  57. package/dist/features/workflow-engine/index.d.ts.map +1 -0
  58. package/dist/features/workflow-engine/index.js +19 -0
  59. package/dist/features/workflow-engine/index.js.map +1 -0
  60. package/dist/features/workflow-engine/types.d.ts +220 -0
  61. package/dist/features/workflow-engine/types.d.ts.map +1 -0
  62. package/dist/features/workflow-engine/types.js +8 -0
  63. package/dist/features/workflow-engine/types.js.map +1 -0
  64. package/dist/features/workflow-engine/validation.d.ts +128 -0
  65. package/dist/features/workflow-engine/validation.d.ts.map +1 -0
  66. package/dist/features/workflow-engine/validation.js +746 -0
  67. package/dist/features/workflow-engine/validation.js.map +1 -0
  68. package/dist/hooks/ascent-verifier/index.d.ts +52 -0
  69. package/dist/hooks/ascent-verifier/index.d.ts.map +1 -1
  70. package/dist/hooks/ascent-verifier/index.js +146 -0
  71. package/dist/hooks/ascent-verifier/index.js.map +1 -1
  72. package/dist/hooks/registrations/learning-capture.d.ts.map +1 -1
  73. package/dist/hooks/registrations/learning-capture.js +32 -9
  74. package/dist/hooks/registrations/learning-capture.js.map +1 -1
  75. package/dist/hooks/registrations/user-prompt-submit.d.ts.map +1 -1
  76. package/dist/hooks/registrations/user-prompt-submit.js +85 -0
  77. package/dist/hooks/registrations/user-prompt-submit.js.map +1 -1
  78. package/dist/installer/index.d.ts.map +1 -1
  79. package/dist/installer/index.js +310 -1
  80. package/dist/installer/index.js.map +1 -1
  81. package/dist/learning/session-state.d.ts.map +1 -1
  82. package/dist/learning/session-state.js +17 -0
  83. package/dist/learning/session-state.js.map +1 -1
  84. package/dist/learning/types.d.ts +3 -0
  85. package/dist/learning/types.d.ts.map +1 -1
  86. package/dist/shared/types.d.ts +17 -0
  87. package/dist/shared/types.d.ts.map +1 -1
  88. package/package.json +3 -1
  89. package/scripts/dist/hooks/olympus-hooks.cjs +208 -97
  90. package/scripts/rebrand.mjs +0 -206
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Workflow Execution Module
3
+ *
4
+ * Handles task status tracking, dependency resolution, and execution order.
5
+ * Integrates with checkpoint.ts for persistence and dependency-graph.json for task relationships.
6
+ */
7
+ /**
8
+ * Task execution status.
9
+ *
10
+ * - pending: Task hasn't started yet
11
+ * - in_progress: Currently working on this task
12
+ * - complete: Task is finished
13
+ * - failed: Task execution failed
14
+ * - blocked: Cannot proceed due to unmet dependencies
15
+ */
16
+ export type TaskStatus = 'pending' | 'in_progress' | 'complete' | 'failed' | 'blocked';
17
+ /**
18
+ * Task status record stored in checkpoint.
19
+ */
20
+ export interface TaskStatusRecord {
21
+ /** Task ID */
22
+ task_id: string;
23
+ /** Current status */
24
+ status: TaskStatus;
25
+ /** ISO timestamp when status was last updated */
26
+ updated_at: string;
27
+ /** Error message if status is 'failed' */
28
+ error?: string;
29
+ }
30
+ /**
31
+ * Update the status of a task in the workflow checkpoint.
32
+ * Creates a new status record or updates existing one.
33
+ * Automatically updates the master plan progress section.
34
+ *
35
+ * @param projectPath - Root path of the project
36
+ * @param workflowId - ID of the workflow
37
+ * @param taskId - ID of the task to update
38
+ * @param status - New status for the task
39
+ * @param error - Optional error message if status is 'failed'
40
+ * @throws Error if checkpoint doesn't exist
41
+ * @throws Error if disk is full or permissions are denied
42
+ */
43
+ export declare function updateTaskStatus(projectPath: string, workflowId: string, taskId: string, status: TaskStatus, error?: string): Promise<void>;
44
+ /**
45
+ * Get the current status of a task.
46
+ * Returns 'pending' if task hasn't been started yet.
47
+ *
48
+ * @param projectPath - Root path of the project
49
+ * @param workflowId - ID of the workflow
50
+ * @param taskId - ID of the task
51
+ * @returns Current task status
52
+ * @throws Error if checkpoint doesn't exist
53
+ */
54
+ export declare function getTaskStatus(projectPath: string, workflowId: string, taskId: string): Promise<TaskStatus>;
55
+ /**
56
+ * Get all tasks that are blocked by unmet dependencies.
57
+ * A task is blocked if any of its dependencies are not in 'complete' status.
58
+ *
59
+ * @param projectPath - Root path of the project
60
+ * @param workflowId - ID of the workflow
61
+ * @returns Array of blocked task IDs
62
+ * @throws Error if checkpoint doesn't exist
63
+ */
64
+ export declare function getBlockedTasks(projectPath: string, workflowId: string): Promise<string[]>;
65
+ /**
66
+ * Get the next task that is ready to execute.
67
+ * A task is ready if:
68
+ * - Its status is 'pending'
69
+ * - All of its dependencies are in 'complete' status
70
+ *
71
+ * @param projectPath - Root path of the project
72
+ * @param workflowId - ID of the workflow
73
+ * @returns Next ready task ID or null if no tasks are ready
74
+ * @throws Error if checkpoint doesn't exist
75
+ */
76
+ export declare function getNextReadyTask(projectPath: string, workflowId: string): Promise<string | null>;
77
+ /**
78
+ * Get execution order for all tasks in the workflow.
79
+ * Uses topological sorting based on the dependency graph.
80
+ *
81
+ * @param projectPath - Root path of the project
82
+ * @param workflowId - ID of the workflow
83
+ * @returns Array of task IDs in execution order
84
+ * @throws Error if checkpoint doesn't exist
85
+ * @throws Error if dependency graph contains circular dependencies
86
+ * @throws Error if dependency graph doesn't exist
87
+ */
88
+ export declare function getExecutionOrder(projectPath: string, workflowId: string): Promise<string[]>;
89
+ /**
90
+ * Update the master plan file with current progress information.
91
+ * Updates/creates a "## Progress" section showing completion stats, current task, and blocked tasks.
92
+ *
93
+ * @param baseDir - Base directory of the project (typically process.cwd())
94
+ * @param workflowId - ID of the workflow
95
+ * @throws Error if checkpoint or dependency graph doesn't exist
96
+ * @throws Error if disk is full or permissions are denied
97
+ */
98
+ export declare function updateMasterPlanProgress(baseDir: string, workflowId: string): Promise<void>;
99
+ //# sourceMappingURL=execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../src/features/workflow-engine/execution.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEvF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAEhB,qBAAqB;IACrB,MAAM,EAAE,UAAU,CAAC;IAEnB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IAEnB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,UAAU,EAClB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAoEf;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,CAAC,CAerB;AAsDD;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAuCnB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA+CxB;AAyDD;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAmEnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAuKf"}
@@ -0,0 +1,493 @@
1
+ /**
2
+ * Workflow Execution Module
3
+ *
4
+ * Handles task status tracking, dependency resolution, and execution order.
5
+ * Integrates with checkpoint.ts for persistence and dependency-graph.json for task relationships.
6
+ */
7
+ import * as fs from 'fs-extra';
8
+ import { join } from 'path';
9
+ import { loadCheckpoint, saveCheckpoint } from './checkpoint.js';
10
+ const WORKFLOW_DIR = '.olympus/workflow';
11
+ const DEPENDENCY_GRAPH_PATH = 'intents/dependency-graph.json';
12
+ /**
13
+ * Update the status of a task in the workflow checkpoint.
14
+ * Creates a new status record or updates existing one.
15
+ * Automatically updates the master plan progress section.
16
+ *
17
+ * @param projectPath - Root path of the project
18
+ * @param workflowId - ID of the workflow
19
+ * @param taskId - ID of the task to update
20
+ * @param status - New status for the task
21
+ * @param error - Optional error message if status is 'failed'
22
+ * @throws Error if checkpoint doesn't exist
23
+ * @throws Error if disk is full or permissions are denied
24
+ */
25
+ export async function updateTaskStatus(projectPath, workflowId, taskId, status, error) {
26
+ let checkpoint;
27
+ try {
28
+ checkpoint = await loadCheckpoint(projectPath, workflowId);
29
+ }
30
+ catch (error) {
31
+ const err = error;
32
+ console.error(`[Execution] Failed to load checkpoint for task status update: ${err.message}`);
33
+ console.error(`[Execution] Workflow ID: ${workflowId}, Task ID: ${taskId}`);
34
+ throw new Error(`Failed to update task status: Could not load checkpoint for workflow ${workflowId}`);
35
+ }
36
+ if (!checkpoint) {
37
+ console.error(`[Execution] Workflow ${workflowId} not found for task status update`);
38
+ console.error(`[Execution] Task ID: ${taskId}`);
39
+ throw new Error(`Workflow ${workflowId} not found`);
40
+ }
41
+ // Initialize task_statuses if it doesn't exist
42
+ if (!checkpoint.resume_context) {
43
+ checkpoint.resume_context = {};
44
+ }
45
+ if (!checkpoint.resume_context.task_statuses) {
46
+ checkpoint.resume_context.task_statuses = [];
47
+ }
48
+ const taskStatuses = checkpoint.resume_context.task_statuses;
49
+ // Find existing status record
50
+ const existingIndex = taskStatuses.findIndex(t => t.task_id === taskId);
51
+ const statusRecord = {
52
+ task_id: taskId,
53
+ status,
54
+ updated_at: new Date().toISOString(),
55
+ ...(error && { error })
56
+ };
57
+ if (existingIndex >= 0) {
58
+ // Update existing record
59
+ taskStatuses[existingIndex] = statusRecord;
60
+ }
61
+ else {
62
+ // Add new record
63
+ taskStatuses.push(statusRecord);
64
+ }
65
+ // Save updated checkpoint
66
+ try {
67
+ await saveCheckpoint(projectPath, checkpoint);
68
+ }
69
+ catch (error) {
70
+ const err = error;
71
+ console.error(`[Execution] Failed to save checkpoint after task status update: ${err.message}`);
72
+ console.error(`[Execution] Workflow ID: ${workflowId}, Task ID: ${taskId}, Status: ${status}`);
73
+ throw new Error(`Failed to update task status: Could not save checkpoint - ${err.message}`);
74
+ }
75
+ // Update master plan progress section
76
+ try {
77
+ await updateMasterPlanProgress(projectPath, workflowId);
78
+ }
79
+ catch (error) {
80
+ // Log warning but don't fail the status update if plan update fails
81
+ console.warn(`[Execution] Failed to update master plan progress: ${error.message}`);
82
+ console.warn(`[Execution] Task status was saved, but plan file was not updated`);
83
+ }
84
+ }
85
+ /**
86
+ * Get the current status of a task.
87
+ * Returns 'pending' if task hasn't been started yet.
88
+ *
89
+ * @param projectPath - Root path of the project
90
+ * @param workflowId - ID of the workflow
91
+ * @param taskId - ID of the task
92
+ * @returns Current task status
93
+ * @throws Error if checkpoint doesn't exist
94
+ */
95
+ export async function getTaskStatus(projectPath, workflowId, taskId) {
96
+ const checkpoint = await loadCheckpoint(projectPath, workflowId);
97
+ if (!checkpoint) {
98
+ throw new Error(`Workflow ${workflowId} not found`);
99
+ }
100
+ const taskStatuses = checkpoint.resume_context?.task_statuses;
101
+ if (!taskStatuses) {
102
+ return 'pending';
103
+ }
104
+ const statusRecord = taskStatuses.find(t => t.task_id === taskId);
105
+ return statusRecord ? statusRecord.status : 'pending';
106
+ }
107
+ /**
108
+ * Load dependency graph from disk.
109
+ *
110
+ * @param projectPath - Root path of the project
111
+ * @param workflowId - ID of the workflow
112
+ * @returns Dependency graph or null if not found or corrupt
113
+ */
114
+ async function loadDependencyGraph(projectPath, workflowId) {
115
+ const graphPath = join(projectPath, WORKFLOW_DIR, workflowId, DEPENDENCY_GRAPH_PATH);
116
+ try {
117
+ const exists = await fs.pathExists(graphPath);
118
+ if (!exists) {
119
+ return null;
120
+ }
121
+ return await fs.readJson(graphPath);
122
+ }
123
+ catch (error) {
124
+ const err = error;
125
+ // Handle JSON parse errors (corrupt graph)
126
+ if (err.name === 'SyntaxError' || err.message.includes('JSON')) {
127
+ console.warn(`[Execution] Corrupt dependency graph detected for workflow ${workflowId}`);
128
+ console.warn(`[Execution] Path: ${graphPath}`);
129
+ console.warn(`[Execution] Error: ${err.message}`);
130
+ console.warn(`[Execution] To reset, regenerate the dependency graph from SPEC`);
131
+ return null;
132
+ }
133
+ // Handle permission errors
134
+ const nodeErr = err;
135
+ if (nodeErr.code === 'EACCES' || nodeErr.code === 'EPERM') {
136
+ console.warn(`[Execution] Permission denied reading dependency graph for ${workflowId}`);
137
+ console.warn(`[Execution] Path: ${graphPath}`);
138
+ return null;
139
+ }
140
+ // Generic error
141
+ console.warn(`[Execution] Failed to load dependency graph for ${workflowId}: ${err.message}`);
142
+ console.warn(`[Execution] Path: ${graphPath}`);
143
+ return null;
144
+ }
145
+ }
146
+ /**
147
+ * Get all tasks that are blocked by unmet dependencies.
148
+ * A task is blocked if any of its dependencies are not in 'complete' status.
149
+ *
150
+ * @param projectPath - Root path of the project
151
+ * @param workflowId - ID of the workflow
152
+ * @returns Array of blocked task IDs
153
+ * @throws Error if checkpoint doesn't exist
154
+ */
155
+ export async function getBlockedTasks(projectPath, workflowId) {
156
+ const checkpoint = await loadCheckpoint(projectPath, workflowId);
157
+ if (!checkpoint) {
158
+ throw new Error(`Workflow ${workflowId} not found`);
159
+ }
160
+ const graph = await loadDependencyGraph(projectPath, workflowId);
161
+ if (!graph) {
162
+ return [];
163
+ }
164
+ const taskStatuses = checkpoint.resume_context?.task_statuses;
165
+ const blockedTasks = [];
166
+ // Build dependency map: task -> [dependencies]
167
+ const dependencyMap = new Map();
168
+ for (const edge of graph.edges) {
169
+ if (!dependencyMap.has(edge.to)) {
170
+ dependencyMap.set(edge.to, []);
171
+ }
172
+ dependencyMap.get(edge.to).push(edge.from);
173
+ }
174
+ // Check each task with dependencies
175
+ for (const [taskId, dependencies] of dependencyMap.entries()) {
176
+ const hasUnmetDependencies = dependencies.some(depId => {
177
+ const depStatus = taskStatuses?.find(t => t.task_id === depId)?.status || 'pending';
178
+ return depStatus !== 'complete';
179
+ });
180
+ if (hasUnmetDependencies) {
181
+ blockedTasks.push(taskId);
182
+ }
183
+ }
184
+ return blockedTasks;
185
+ }
186
+ /**
187
+ * Get the next task that is ready to execute.
188
+ * A task is ready if:
189
+ * - Its status is 'pending'
190
+ * - All of its dependencies are in 'complete' status
191
+ *
192
+ * @param projectPath - Root path of the project
193
+ * @param workflowId - ID of the workflow
194
+ * @returns Next ready task ID or null if no tasks are ready
195
+ * @throws Error if checkpoint doesn't exist
196
+ */
197
+ export async function getNextReadyTask(projectPath, workflowId) {
198
+ const checkpoint = await loadCheckpoint(projectPath, workflowId);
199
+ if (!checkpoint) {
200
+ throw new Error(`Workflow ${workflowId} not found`);
201
+ }
202
+ const graph = await loadDependencyGraph(projectPath, workflowId);
203
+ if (!graph || graph.nodes.length === 0) {
204
+ return null;
205
+ }
206
+ const taskStatuses = checkpoint.resume_context?.task_statuses;
207
+ // Build dependency map: task -> [dependencies]
208
+ const dependencyMap = new Map();
209
+ for (const edge of graph.edges) {
210
+ if (!dependencyMap.has(edge.to)) {
211
+ dependencyMap.set(edge.to, []);
212
+ }
213
+ dependencyMap.get(edge.to).push(edge.from);
214
+ }
215
+ // Find first pending task with all dependencies met
216
+ for (const node of graph.nodes) {
217
+ const taskId = node.id;
218
+ const currentStatus = taskStatuses?.find(t => t.task_id === taskId)?.status || 'pending';
219
+ // Skip if not pending
220
+ if (currentStatus !== 'pending') {
221
+ continue;
222
+ }
223
+ // Check if all dependencies are complete
224
+ const dependencies = dependencyMap.get(taskId) || [];
225
+ const allDependenciesMet = dependencies.every(depId => {
226
+ const depStatus = taskStatuses?.find(t => t.task_id === depId)?.status || 'pending';
227
+ return depStatus === 'complete';
228
+ });
229
+ if (allDependenciesMet) {
230
+ return taskId;
231
+ }
232
+ }
233
+ return null;
234
+ }
235
+ /**
236
+ * Detect circular dependencies in the dependency graph.
237
+ * Uses depth-first search with cycle detection.
238
+ *
239
+ * @param graph - Dependency graph to check
240
+ * @returns Array of task IDs involved in circular dependencies (empty if no cycles)
241
+ */
242
+ function detectCircularDependencies(graph) {
243
+ const adjacencyList = new Map();
244
+ // Build adjacency list
245
+ for (const edge of graph.edges) {
246
+ if (!adjacencyList.has(edge.from)) {
247
+ adjacencyList.set(edge.from, []);
248
+ }
249
+ adjacencyList.get(edge.from).push(edge.to);
250
+ }
251
+ const visited = new Set();
252
+ const recursionStack = new Set();
253
+ const cycleNodes = new Set();
254
+ function dfs(node) {
255
+ visited.add(node);
256
+ recursionStack.add(node);
257
+ const neighbors = adjacencyList.get(node) || [];
258
+ for (const neighbor of neighbors) {
259
+ if (!visited.has(neighbor)) {
260
+ if (dfs(neighbor)) {
261
+ cycleNodes.add(node);
262
+ return true;
263
+ }
264
+ }
265
+ else if (recursionStack.has(neighbor)) {
266
+ // Cycle detected
267
+ cycleNodes.add(node);
268
+ cycleNodes.add(neighbor);
269
+ return true;
270
+ }
271
+ }
272
+ recursionStack.delete(node);
273
+ return false;
274
+ }
275
+ // Check all nodes
276
+ for (const node of graph.nodes) {
277
+ if (!visited.has(node.id)) {
278
+ dfs(node.id);
279
+ }
280
+ }
281
+ return Array.from(cycleNodes);
282
+ }
283
+ /**
284
+ * Get execution order for all tasks in the workflow.
285
+ * Uses topological sorting based on the dependency graph.
286
+ *
287
+ * @param projectPath - Root path of the project
288
+ * @param workflowId - ID of the workflow
289
+ * @returns Array of task IDs in execution order
290
+ * @throws Error if checkpoint doesn't exist
291
+ * @throws Error if dependency graph contains circular dependencies
292
+ * @throws Error if dependency graph doesn't exist
293
+ */
294
+ export async function getExecutionOrder(projectPath, workflowId) {
295
+ const checkpoint = await loadCheckpoint(projectPath, workflowId);
296
+ if (!checkpoint) {
297
+ throw new Error(`Workflow ${workflowId} not found`);
298
+ }
299
+ const graph = await loadDependencyGraph(projectPath, workflowId);
300
+ if (!graph) {
301
+ throw new Error(`Dependency graph not found for workflow ${workflowId}`);
302
+ }
303
+ // Check for circular dependencies
304
+ const circularDeps = detectCircularDependencies(graph);
305
+ if (circularDeps.length > 0) {
306
+ throw new Error(`Circular dependencies detected: ${circularDeps.join(', ')}`);
307
+ }
308
+ // Topological sort using Kahn's algorithm
309
+ const inDegree = new Map();
310
+ const adjacencyList = new Map();
311
+ // Initialize in-degrees and adjacency list
312
+ for (const node of graph.nodes) {
313
+ inDegree.set(node.id, 0);
314
+ adjacencyList.set(node.id, []);
315
+ }
316
+ // Build adjacency list and calculate in-degrees
317
+ for (const edge of graph.edges) {
318
+ adjacencyList.get(edge.from).push(edge.to);
319
+ inDegree.set(edge.to, (inDegree.get(edge.to) || 0) + 1);
320
+ }
321
+ // Queue of nodes with no incoming edges
322
+ const queue = [];
323
+ for (const [nodeId, degree] of inDegree.entries()) {
324
+ if (degree === 0) {
325
+ queue.push(nodeId);
326
+ }
327
+ }
328
+ const sorted = [];
329
+ while (queue.length > 0) {
330
+ const current = queue.shift();
331
+ sorted.push(current);
332
+ // Reduce in-degree for neighbors
333
+ const neighbors = adjacencyList.get(current) || [];
334
+ for (const neighbor of neighbors) {
335
+ const newDegree = (inDegree.get(neighbor) || 0) - 1;
336
+ inDegree.set(neighbor, newDegree);
337
+ if (newDegree === 0) {
338
+ queue.push(neighbor);
339
+ }
340
+ }
341
+ }
342
+ // If sorted array doesn't contain all nodes, there's a cycle (shouldn't happen due to earlier check)
343
+ if (sorted.length !== graph.nodes.length) {
344
+ throw new Error('Failed to compute execution order: cyclic dependency detected');
345
+ }
346
+ return sorted;
347
+ }
348
+ /**
349
+ * Update the master plan file with current progress information.
350
+ * Updates/creates a "## Progress" section showing completion stats, current task, and blocked tasks.
351
+ *
352
+ * @param baseDir - Base directory of the project (typically process.cwd())
353
+ * @param workflowId - ID of the workflow
354
+ * @throws Error if checkpoint or dependency graph doesn't exist
355
+ * @throws Error if disk is full or permissions are denied
356
+ */
357
+ export async function updateMasterPlanProgress(baseDir, workflowId) {
358
+ let checkpoint;
359
+ try {
360
+ checkpoint = await loadCheckpoint(baseDir, workflowId);
361
+ }
362
+ catch (error) {
363
+ const err = error;
364
+ console.error(`[Execution] Failed to load checkpoint for plan update: ${err.message}`);
365
+ console.error(`[Execution] Workflow ID: ${workflowId}`);
366
+ throw new Error(`Failed to update master plan progress: Could not load checkpoint for ${workflowId}`);
367
+ }
368
+ if (!checkpoint) {
369
+ console.error(`[Execution] Workflow ${workflowId} not found for plan update`);
370
+ throw new Error(`Workflow ${workflowId} not found`);
371
+ }
372
+ const graph = await loadDependencyGraph(baseDir, workflowId);
373
+ if (!graph) {
374
+ console.error(`[Execution] Dependency graph not found for workflow ${workflowId}`);
375
+ console.error(`[Execution] Cannot update master plan progress without dependency graph`);
376
+ throw new Error(`Dependency graph not found for workflow ${workflowId}`);
377
+ }
378
+ const planPath = join(baseDir, '.olympus', 'plans', `${workflowId}-plan.md`);
379
+ // Check if plan file exists
380
+ try {
381
+ const planExists = await fs.pathExists(planPath);
382
+ if (!planExists) {
383
+ console.warn(`[Execution] Plan file not found: ${planPath}`);
384
+ console.warn(`[Execution] Skipping master plan progress update`);
385
+ return;
386
+ }
387
+ }
388
+ catch (error) {
389
+ const err = error;
390
+ console.warn(`[Execution] Failed to check plan file existence: ${err.message}`);
391
+ console.warn(`[Execution] Path: ${planPath}`);
392
+ return;
393
+ }
394
+ // Read existing plan content
395
+ let planContent;
396
+ try {
397
+ planContent = await fs.readFile(planPath, 'utf-8');
398
+ }
399
+ catch (error) {
400
+ const err = error;
401
+ if (err.code === 'EACCES' || err.code === 'EPERM') {
402
+ console.error(`[Execution] Permission denied reading plan file: ${planPath}`);
403
+ throw new Error(`Failed to update master plan progress: Permission denied for ${planPath}`);
404
+ }
405
+ console.error(`[Execution] Failed to read plan file: ${err.message}`);
406
+ console.error(`[Execution] Path: ${planPath}`);
407
+ throw new Error(`Failed to update master plan progress: Could not read plan file - ${err.message}`);
408
+ }
409
+ // Get task statuses
410
+ const taskStatuses = checkpoint.resume_context?.task_statuses;
411
+ // Calculate completion statistics
412
+ const totalTasks = graph.nodes.length;
413
+ const completedTasks = taskStatuses?.filter(t => t.status === 'complete').length || 0;
414
+ const completionPercentage = totalTasks > 0 ? Math.round((completedTasks / totalTasks) * 100) : 0;
415
+ // Find current in-progress task
416
+ const inProgressTask = taskStatuses?.find(t => t.status === 'in_progress');
417
+ const inProgressNode = inProgressTask
418
+ ? graph.nodes.find(n => n.id === inProgressTask.task_id)
419
+ : null;
420
+ // Get blocked tasks
421
+ const blockedTaskIds = await getBlockedTasks(baseDir, workflowId);
422
+ const blockedNodes = blockedTaskIds
423
+ .map(id => graph.nodes.find(n => n.id === id))
424
+ .filter((n) => n !== undefined);
425
+ // Build progress section content
426
+ let progressSection = '## Progress\n\n';
427
+ progressSection += `**Completion**: ${completedTasks}/${totalTasks} tasks (${completionPercentage}%)\n\n`;
428
+ if (inProgressNode) {
429
+ progressSection += `**Current Task**: ${inProgressNode.id} - ${inProgressNode.title}\n\n`;
430
+ }
431
+ if (blockedNodes.length > 0) {
432
+ progressSection += `**Blocked Tasks**:\n`;
433
+ for (const node of blockedNodes) {
434
+ progressSection += `- ${node.id} - ${node.title}\n`;
435
+ }
436
+ progressSection += '\n';
437
+ }
438
+ progressSection += `**Last Updated**: ${new Date().toISOString()}\n\n`;
439
+ // Check if progress section already exists
440
+ const progressRegex = /^## Progress\s*\n[\s\S]*?(?=\n## |\n---|\n$)/m;
441
+ const hasProgressSection = progressRegex.test(planContent);
442
+ if (hasProgressSection) {
443
+ // Replace existing progress section
444
+ planContent = planContent.replace(progressRegex, progressSection.trim() + '\n');
445
+ }
446
+ else {
447
+ // Insert progress section after the first heading or at the beginning
448
+ const firstHeadingMatch = planContent.match(/^# .+$/m);
449
+ if (firstHeadingMatch && firstHeadingMatch.index !== undefined) {
450
+ const insertPosition = firstHeadingMatch.index + firstHeadingMatch[0].length;
451
+ planContent =
452
+ planContent.slice(0, insertPosition) +
453
+ '\n\n' +
454
+ progressSection +
455
+ planContent.slice(insertPosition);
456
+ }
457
+ else {
458
+ // No heading found, prepend to beginning
459
+ planContent = progressSection + planContent;
460
+ }
461
+ }
462
+ // Write updated plan back to disk
463
+ try {
464
+ await fs.writeFile(planPath, planContent, 'utf-8');
465
+ }
466
+ catch (error) {
467
+ const err = error;
468
+ // Handle disk full error
469
+ if (err.code === 'ENOSPC') {
470
+ console.error(`[Execution] Failed to write plan file: Disk full`);
471
+ console.error(`[Execution] Please free up disk space and try again.`);
472
+ console.error(`[Execution] Path: ${planPath}`);
473
+ throw new Error('Failed to update master plan progress: Disk is full. Please free up space and retry.');
474
+ }
475
+ // Handle permission denied error
476
+ if (err.code === 'EACCES' || err.code === 'EPERM') {
477
+ console.error(`[Execution] Failed to write plan file: Permission denied`);
478
+ console.error(`[Execution] Path: ${planPath}`);
479
+ throw new Error(`Failed to update master plan progress: Permission denied for ${planPath}`);
480
+ }
481
+ // Handle read-only filesystem
482
+ if (err.code === 'EROFS') {
483
+ console.error(`[Execution] Failed to write plan file: Read-only filesystem`);
484
+ console.error(`[Execution] Path: ${planPath}`);
485
+ throw new Error('Failed to update master plan progress: Filesystem is read-only');
486
+ }
487
+ // Generic error with context
488
+ console.error(`[Execution] Failed to write plan file: ${err.message}`);
489
+ console.error(`[Execution] Path: ${planPath}`);
490
+ throw new Error(`Failed to update master plan progress: ${err.message}`);
491
+ }
492
+ }
493
+ //# sourceMappingURL=execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../src/features/workflow-engine/execution.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjE,MAAM,YAAY,GAAG,mBAAmB,CAAC;AACzC,MAAM,qBAAqB,GAAG,+BAA+B,CAAC;AA8B9D;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,WAAmB,EACnB,UAAkB,EAClB,MAAc,EACd,MAAkB,EAClB,KAAc;IAEd,IAAI,UAAU,CAAC;IAEf,IAAI,CAAC;QACH,UAAU,GAAG,MAAM,cAAc,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,GAAG,GAAG,KAAc,CAAC;QAC3B,OAAO,CAAC,KAAK,CAAC,iEAAiE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9F,OAAO,CAAC,KAAK,CAAC,4BAA4B,UAAU,cAAc,MAAM,EAAE,CAAC,CAAC;QAC5E,M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