oh-my-claude-sisyphus 3.5.8 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/executor-high.md +2 -0
- package/agents/executor-low.md +2 -0
- package/agents/executor.md +2 -0
- package/agents/templates/base-agent.md +9 -0
- package/commands/cancel.md +8 -8
- package/commands/swarm.md +350 -148
- package/dist/__tests__/hooks.test.js +10 -9
- package/dist/__tests__/hooks.test.js.map +1 -1
- package/dist/agents/codex-agents.d.ts +20 -0
- package/dist/agents/codex-agents.d.ts.map +1 -0
- package/dist/agents/codex-agents.js +36 -0
- package/dist/agents/codex-agents.js.map +1 -0
- package/dist/agents/preamble.d.ts +14 -0
- package/dist/agents/preamble.d.ts.map +1 -0
- package/dist/agents/preamble.js +26 -0
- package/dist/agents/preamble.js.map +1 -0
- package/dist/hooks/autopilot/__tests__/cancel.test.js +14 -4
- package/dist/hooks/autopilot/__tests__/cancel.test.js.map +1 -1
- package/dist/hooks/autopilot/__tests__/state.test.js +1 -0
- package/dist/hooks/autopilot/__tests__/state.test.js.map +1 -1
- package/dist/hooks/autopilot/__tests__/summary.test.js +38 -3
- package/dist/hooks/autopilot/__tests__/summary.test.js.map +1 -1
- package/dist/hooks/autopilot/state.d.ts +1 -1
- package/dist/hooks/autopilot/state.d.ts.map +1 -1
- package/dist/hooks/autopilot/state.js +15 -8
- package/dist/hooks/autopilot/state.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/mode-registry/index.d.ts +135 -0
- package/dist/hooks/mode-registry/index.d.ts.map +1 -0
- package/dist/hooks/mode-registry/index.js +445 -0
- package/dist/hooks/mode-registry/index.js.map +1 -0
- package/dist/hooks/mode-registry/types.d.ts +31 -0
- package/dist/hooks/mode-registry/types.d.ts.map +1 -0
- package/dist/hooks/mode-registry/types.js +7 -0
- package/dist/hooks/mode-registry/types.js.map +1 -0
- package/dist/hooks/ralph/loop.js +6 -6
- package/dist/hooks/ralph/loop.js.map +1 -1
- package/dist/hooks/swarm/__tests__/claiming.test.d.ts +2 -0
- package/dist/hooks/swarm/__tests__/claiming.test.d.ts.map +1 -0
- package/dist/hooks/swarm/__tests__/claiming.test.js +170 -0
- package/dist/hooks/swarm/__tests__/claiming.test.js.map +1 -0
- package/dist/hooks/swarm/__tests__/index.test.d.ts +2 -0
- package/dist/hooks/swarm/__tests__/index.test.d.ts.map +1 -0
- package/dist/hooks/swarm/__tests__/index.test.js +157 -0
- package/dist/hooks/swarm/__tests__/index.test.js.map +1 -0
- package/dist/hooks/swarm/__tests__/mode-registry.test.d.ts +2 -0
- package/dist/hooks/swarm/__tests__/mode-registry.test.d.ts.map +1 -0
- package/dist/hooks/swarm/__tests__/mode-registry.test.js +177 -0
- package/dist/hooks/swarm/__tests__/mode-registry.test.js.map +1 -0
- package/dist/hooks/swarm/claiming.d.ts +101 -0
- package/dist/hooks/swarm/claiming.d.ts.map +1 -0
- package/dist/hooks/swarm/claiming.js +460 -0
- package/dist/hooks/swarm/claiming.js.map +1 -0
- package/dist/hooks/swarm/index.d.ts +221 -0
- package/dist/hooks/swarm/index.d.ts.map +1 -0
- package/dist/hooks/swarm/index.js +413 -0
- package/dist/hooks/swarm/index.js.map +1 -0
- package/dist/hooks/swarm/state.d.ts +94 -0
- package/dist/hooks/swarm/state.d.ts.map +1 -0
- package/dist/hooks/swarm/state.js +530 -0
- package/dist/hooks/swarm/state.js.map +1 -0
- package/dist/hooks/swarm/types.d.ts +116 -0
- package/dist/hooks/swarm/types.d.ts.map +1 -0
- package/dist/hooks/swarm/types.js +22 -0
- package/dist/hooks/swarm/types.js.map +1 -0
- package/dist/hooks/ultrapilot/decomposer.d.ts +141 -0
- package/dist/hooks/ultrapilot/decomposer.d.ts.map +1 -0
- package/dist/hooks/ultrapilot/decomposer.js +377 -0
- package/dist/hooks/ultrapilot/decomposer.js.map +1 -0
- package/dist/hooks/ultrapilot/index.d.ts +31 -0
- package/dist/hooks/ultrapilot/index.d.ts.map +1 -1
- package/dist/hooks/ultrapilot/index.js +43 -2
- package/dist/hooks/ultrapilot/index.js.map +1 -1
- package/dist/hooks/ultrapilot/state.d.ts +1 -1
- package/dist/hooks/ultrapilot/state.d.ts.map +1 -1
- package/dist/hooks/ultrapilot/state.js +7 -0
- package/dist/hooks/ultrapilot/state.js.map +1 -1
- package/dist/hooks/ultraqa/index.js +5 -5
- package/dist/hooks/ultraqa/index.js.map +1 -1
- package/dist/hooks/ultrawork/index.js +3 -3
- package/dist/hooks/ultrawork/index.js.map +1 -1
- package/package.json +3 -1
- package/skills/autopilot/SKILL.md +18 -0
- package/skills/cancel/SKILL.md +166 -141
- package/skills/ecomode/SKILL.md +14 -0
- package/skills/pipeline/SKILL.md +13 -0
- package/skills/ralph/SKILL.md +22 -1
- package/skills/swarm/SKILL.md +521 -197
- package/skills/ultrapilot/SKILL.md +82 -13
- package/skills/ultraqa/SKILL.md +13 -0
- package/skills/ultrawork/SKILL.md +14 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Coordination Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the SQLite-based swarm coordination system.
|
|
5
|
+
* Swarm enables multiple agents to claim and work on tasks atomically
|
|
6
|
+
* with lease-based ownership and heartbeat monitoring.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A task in the swarm task pool
|
|
10
|
+
*/
|
|
11
|
+
export interface SwarmTask {
|
|
12
|
+
/** Unique task identifier */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Human-readable task description */
|
|
15
|
+
description: string;
|
|
16
|
+
/** Current task status */
|
|
17
|
+
status: 'pending' | 'claimed' | 'done' | 'failed';
|
|
18
|
+
/** Agent ID that claimed this task (null if unclaimed) */
|
|
19
|
+
claimedBy: string | null;
|
|
20
|
+
/** Unix timestamp when task was claimed (null if unclaimed) */
|
|
21
|
+
claimedAt: number | null;
|
|
22
|
+
/** Unix timestamp when task was completed (null if incomplete) */
|
|
23
|
+
completedAt: number | null;
|
|
24
|
+
/** Error message if task failed */
|
|
25
|
+
error?: string;
|
|
26
|
+
/** Result/output from completed task */
|
|
27
|
+
result?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Overall swarm state
|
|
31
|
+
*/
|
|
32
|
+
export interface SwarmState {
|
|
33
|
+
/** Whether swarm is currently active */
|
|
34
|
+
active: boolean;
|
|
35
|
+
/** Unique session identifier */
|
|
36
|
+
sessionId: string;
|
|
37
|
+
/** Number of agents participating in the swarm */
|
|
38
|
+
agentCount: number;
|
|
39
|
+
/** All tasks in the swarm */
|
|
40
|
+
tasks: SwarmTask[];
|
|
41
|
+
/** Timestamp when swarm was started */
|
|
42
|
+
startedAt: number;
|
|
43
|
+
/** Timestamp when swarm completed (null if still running) */
|
|
44
|
+
completedAt: number | null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Result of attempting to claim a task
|
|
48
|
+
*/
|
|
49
|
+
export interface ClaimResult {
|
|
50
|
+
/** Whether the claim was successful */
|
|
51
|
+
success: boolean;
|
|
52
|
+
/** ID of the claimed task (null if claim failed) */
|
|
53
|
+
taskId: string | null;
|
|
54
|
+
/** Task description (for convenience) */
|
|
55
|
+
description?: string;
|
|
56
|
+
/** Reason for failure if claim was unsuccessful */
|
|
57
|
+
reason?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Configuration for swarm initialization
|
|
61
|
+
*/
|
|
62
|
+
export interface SwarmConfig {
|
|
63
|
+
/** Number of agents to spawn */
|
|
64
|
+
agentCount: number;
|
|
65
|
+
/** Task descriptions to add to the pool */
|
|
66
|
+
tasks: string[];
|
|
67
|
+
/** Agent type/model to use (default: executor) */
|
|
68
|
+
agentType?: string;
|
|
69
|
+
/** Lease timeout in milliseconds (default: 5 minutes) */
|
|
70
|
+
leaseTimeout?: number;
|
|
71
|
+
/** Heartbeat interval in milliseconds (default: 60 seconds) */
|
|
72
|
+
heartbeatInterval?: number;
|
|
73
|
+
/** Working directory */
|
|
74
|
+
cwd?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Agent heartbeat record
|
|
78
|
+
*/
|
|
79
|
+
export interface AgentHeartbeat {
|
|
80
|
+
/** Agent identifier */
|
|
81
|
+
agentId: string;
|
|
82
|
+
/** Unix timestamp of last heartbeat */
|
|
83
|
+
lastHeartbeat: number;
|
|
84
|
+
/** Task currently being worked on (null if idle) */
|
|
85
|
+
currentTaskId: string | null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Swarm statistics
|
|
89
|
+
*/
|
|
90
|
+
export interface SwarmStats {
|
|
91
|
+
/** Total number of tasks */
|
|
92
|
+
totalTasks: number;
|
|
93
|
+
/** Number of pending tasks */
|
|
94
|
+
pendingTasks: number;
|
|
95
|
+
/** Number of claimed/in-progress tasks */
|
|
96
|
+
claimedTasks: number;
|
|
97
|
+
/** Number of completed tasks */
|
|
98
|
+
doneTasks: number;
|
|
99
|
+
/** Number of failed tasks */
|
|
100
|
+
failedTasks: number;
|
|
101
|
+
/** Number of active agents */
|
|
102
|
+
activeAgents: number;
|
|
103
|
+
/** Elapsed time in milliseconds */
|
|
104
|
+
elapsedTime: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Default configuration values
|
|
108
|
+
*/
|
|
109
|
+
export declare const DEFAULT_SWARM_CONFIG: Required<Omit<SwarmConfig, 'tasks' | 'cwd'>> & {
|
|
110
|
+
tasks: string[];
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Database schema version for migrations
|
|
114
|
+
*/
|
|
115
|
+
export declare const DB_SCHEMA_VERSION = 1;
|
|
116
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hooks/swarm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;IAChB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,KAAK,CAAC,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAA;CAMlG,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Coordination Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the SQLite-based swarm coordination system.
|
|
5
|
+
* Swarm enables multiple agents to claim and work on tasks atomically
|
|
6
|
+
* with lease-based ownership and heartbeat monitoring.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Default configuration values
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_SWARM_CONFIG = {
|
|
12
|
+
agentCount: 3,
|
|
13
|
+
tasks: [],
|
|
14
|
+
agentType: 'executor',
|
|
15
|
+
leaseTimeout: 5 * 60 * 1000, // 5 minutes
|
|
16
|
+
heartbeatInterval: 60 * 1000 // 60 seconds
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Database schema version for migrations
|
|
20
|
+
*/
|
|
21
|
+
export const DB_SCHEMA_VERSION = 1;
|
|
22
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/hooks/swarm/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA0GH;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAuE;IACtG,UAAU,EAAE,CAAC;IACb,KAAK,EAAE,EAAE;IACT,SAAS,EAAE,UAAU;IACrB,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,YAAY;IACzC,iBAAiB,EAAE,EAAE,GAAG,IAAI,CAAC,aAAa;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI-Powered Task Decomposition for Ultrapilot
|
|
3
|
+
*
|
|
4
|
+
* This module provides intelligent task decomposition using an Architect agent
|
|
5
|
+
* to analyze tasks and break them into parallel-safe subtasks with proper
|
|
6
|
+
* file ownership and dependency tracking.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Agent type for task execution, determines model complexity
|
|
10
|
+
*/
|
|
11
|
+
export type AgentType = 'executor-low' | 'executor' | 'executor-high';
|
|
12
|
+
/**
|
|
13
|
+
* Model tier for agent execution
|
|
14
|
+
*/
|
|
15
|
+
export type ModelTier = 'haiku' | 'sonnet' | 'opus';
|
|
16
|
+
/**
|
|
17
|
+
* A decomposed subtask with file ownership and dependencies
|
|
18
|
+
*/
|
|
19
|
+
export interface DecomposedTask {
|
|
20
|
+
/** Unique identifier for this subtask */
|
|
21
|
+
id: string;
|
|
22
|
+
/** Clear description of what to implement */
|
|
23
|
+
description: string;
|
|
24
|
+
/** Files this task will touch (can include globs) */
|
|
25
|
+
files: string[];
|
|
26
|
+
/** Task IDs this subtask depends on (must complete first) */
|
|
27
|
+
blockedBy: string[];
|
|
28
|
+
/** Agent type based on task complexity */
|
|
29
|
+
agentType: AgentType;
|
|
30
|
+
/** Model tier for execution */
|
|
31
|
+
model: ModelTier;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Result of task decomposition
|
|
35
|
+
*/
|
|
36
|
+
export interface DecompositionResult {
|
|
37
|
+
/** Array of parallelizable subtasks */
|
|
38
|
+
subtasks: DecomposedTask[];
|
|
39
|
+
/** Files that need sequential handling (config, lock files) */
|
|
40
|
+
sharedFiles: string[];
|
|
41
|
+
/** Groups of task IDs that can run in parallel (dependency-ordered) */
|
|
42
|
+
parallelGroups: string[][];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Options for decomposition prompt generation
|
|
46
|
+
*/
|
|
47
|
+
export interface DecompositionOptions {
|
|
48
|
+
/** Maximum number of subtasks to generate */
|
|
49
|
+
maxSubtasks?: number;
|
|
50
|
+
/** Preferred model tier for workers */
|
|
51
|
+
preferredModel?: ModelTier;
|
|
52
|
+
/** Additional context about project structure */
|
|
53
|
+
projectContext?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Default shared file patterns that should be handled by coordinator
|
|
57
|
+
*/
|
|
58
|
+
export declare const DEFAULT_SHARED_FILE_PATTERNS: string[];
|
|
59
|
+
/**
|
|
60
|
+
* Generate a prompt for the Architect agent to decompose a task
|
|
61
|
+
*
|
|
62
|
+
* This prompt instructs the Architect to analyze the task and codebase context,
|
|
63
|
+
* then produce a structured JSON decomposition with file ownership and dependencies.
|
|
64
|
+
*
|
|
65
|
+
* @param task - The task description to decompose
|
|
66
|
+
* @param codebaseContext - Context about the codebase structure, files, and patterns
|
|
67
|
+
* @param options - Optional configuration for decomposition
|
|
68
|
+
* @returns Formatted prompt string for the Architect agent
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const prompt = generateDecompositionPrompt(
|
|
73
|
+
* "Build a full-stack todo app with React and Express",
|
|
74
|
+
* "Project has src/client and src/server directories..."
|
|
75
|
+
* );
|
|
76
|
+
* // Use with Architect agent via Task tool
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function generateDecompositionPrompt(task: string, codebaseContext: string, options?: DecompositionOptions): string;
|
|
80
|
+
/**
|
|
81
|
+
* Parse the Architect's response into a structured DecompositionResult
|
|
82
|
+
*
|
|
83
|
+
* Handles various response formats including:
|
|
84
|
+
* - Raw JSON
|
|
85
|
+
* - JSON wrapped in markdown code fences
|
|
86
|
+
* - JSON with surrounding explanation text
|
|
87
|
+
*
|
|
88
|
+
* @param response - Raw response string from the Architect agent
|
|
89
|
+
* @returns Parsed and validated DecompositionResult
|
|
90
|
+
* @throws Error if response cannot be parsed or is invalid
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const result = parseDecompositionResult(architectResponse);
|
|
95
|
+
* console.log(result.subtasks.length); // Number of parallel tasks
|
|
96
|
+
* console.log(result.parallelGroups); // Execution order
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare function parseDecompositionResult(response: string): DecompositionResult;
|
|
100
|
+
/**
|
|
101
|
+
* Generate parallel groups from subtask dependencies
|
|
102
|
+
*
|
|
103
|
+
* Creates an ordered array of task ID groups where each group can run
|
|
104
|
+
* in parallel, and later groups depend on earlier ones completing.
|
|
105
|
+
*
|
|
106
|
+
* @param subtasks - Array of decomposed subtasks with blockedBy fields
|
|
107
|
+
* @returns Array of parallel groups (each group is array of task IDs)
|
|
108
|
+
*/
|
|
109
|
+
export declare function generateParallelGroups(subtasks: DecomposedTask[]): string[][];
|
|
110
|
+
/**
|
|
111
|
+
* Validate that file ownership doesn't overlap between subtasks
|
|
112
|
+
*
|
|
113
|
+
* @param subtasks - Array of decomposed subtasks
|
|
114
|
+
* @returns Object with isValid flag and any conflicts found
|
|
115
|
+
*/
|
|
116
|
+
export declare function validateFileOwnership(subtasks: DecomposedTask[]): {
|
|
117
|
+
isValid: boolean;
|
|
118
|
+
conflicts: Array<{
|
|
119
|
+
file: string;
|
|
120
|
+
owners: string[];
|
|
121
|
+
}>;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Merge shared files from subtasks into the sharedFiles list
|
|
125
|
+
*
|
|
126
|
+
* Identifies files that match shared file patterns and removes them
|
|
127
|
+
* from subtask ownership, adding them to sharedFiles instead.
|
|
128
|
+
*
|
|
129
|
+
* @param result - DecompositionResult to process
|
|
130
|
+
* @param patterns - Array of glob patterns for shared files
|
|
131
|
+
* @returns Updated DecompositionResult with shared files extracted
|
|
132
|
+
*/
|
|
133
|
+
export declare function extractSharedFiles(result: DecompositionResult, patterns?: string[]): DecompositionResult;
|
|
134
|
+
/**
|
|
135
|
+
* Convert DecompositionResult to simple string array for legacy compatibility
|
|
136
|
+
*
|
|
137
|
+
* @param result - Full decomposition result
|
|
138
|
+
* @returns Array of task description strings
|
|
139
|
+
*/
|
|
140
|
+
export declare function toSimpleSubtasks(result: DecompositionResult): string[];
|
|
141
|
+
//# sourceMappingURL=decomposer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decomposer.d.ts","sourceRoot":"","sources":["../../../src/hooks/ultrapilot/decomposer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,UAAU,GAAG,eAAe,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAA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Ac,EAAE,GAAG;IACjE,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;CACtD,CAuBA;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,GAAE,MAAM,EAAiC,GAChD,mBAAmB,CAoCrB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAEtE"}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI-Powered Task Decomposition for Ultrapilot
|
|
3
|
+
*
|
|
4
|
+
* This module provides intelligent task decomposition using an Architect agent
|
|
5
|
+
* to analyze tasks and break them into parallel-safe subtasks with proper
|
|
6
|
+
* file ownership and dependency tracking.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Default shared file patterns that should be handled by coordinator
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_SHARED_FILE_PATTERNS = [
|
|
12
|
+
'package.json',
|
|
13
|
+
'package-lock.json',
|
|
14
|
+
'yarn.lock',
|
|
15
|
+
'pnpm-lock.yaml',
|
|
16
|
+
'tsconfig.json',
|
|
17
|
+
'tsconfig.*.json',
|
|
18
|
+
'jest.config.js',
|
|
19
|
+
'jest.config.ts',
|
|
20
|
+
'vitest.config.ts',
|
|
21
|
+
'.eslintrc.*',
|
|
22
|
+
'.prettierrc.*',
|
|
23
|
+
'.gitignore',
|
|
24
|
+
'README.md',
|
|
25
|
+
'Makefile',
|
|
26
|
+
'go.mod',
|
|
27
|
+
'go.sum',
|
|
28
|
+
'Cargo.toml',
|
|
29
|
+
'Cargo.lock',
|
|
30
|
+
'pyproject.toml',
|
|
31
|
+
'requirements.txt',
|
|
32
|
+
'setup.py',
|
|
33
|
+
'Dockerfile',
|
|
34
|
+
'docker-compose.yml',
|
|
35
|
+
'.github/**',
|
|
36
|
+
'.gitlab-ci.yml'
|
|
37
|
+
];
|
|
38
|
+
/**
|
|
39
|
+
* Generate a prompt for the Architect agent to decompose a task
|
|
40
|
+
*
|
|
41
|
+
* This prompt instructs the Architect to analyze the task and codebase context,
|
|
42
|
+
* then produce a structured JSON decomposition with file ownership and dependencies.
|
|
43
|
+
*
|
|
44
|
+
* @param task - The task description to decompose
|
|
45
|
+
* @param codebaseContext - Context about the codebase structure, files, and patterns
|
|
46
|
+
* @param options - Optional configuration for decomposition
|
|
47
|
+
* @returns Formatted prompt string for the Architect agent
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const prompt = generateDecompositionPrompt(
|
|
52
|
+
* "Build a full-stack todo app with React and Express",
|
|
53
|
+
* "Project has src/client and src/server directories..."
|
|
54
|
+
* );
|
|
55
|
+
* // Use with Architect agent via Task tool
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export function generateDecompositionPrompt(task, codebaseContext, options = {}) {
|
|
59
|
+
const { maxSubtasks = 5, preferredModel = 'sonnet', projectContext = '' } = options;
|
|
60
|
+
const additionalContext = projectContext ? `\nPROJECT NOTES:\n${projectContext}\n` : '';
|
|
61
|
+
return `Analyze this task and decompose it into parallel-safe subtasks for concurrent execution.
|
|
62
|
+
|
|
63
|
+
TASK: ${task}
|
|
64
|
+
|
|
65
|
+
CODEBASE CONTEXT:
|
|
66
|
+
${codebaseContext}
|
|
67
|
+
${additionalContext}
|
|
68
|
+
OUTPUT REQUIREMENTS:
|
|
69
|
+
Return a valid JSON object matching this exact schema:
|
|
70
|
+
|
|
71
|
+
{
|
|
72
|
+
"subtasks": [
|
|
73
|
+
{
|
|
74
|
+
"id": "1",
|
|
75
|
+
"description": "Clear, actionable description of what to implement",
|
|
76
|
+
"files": ["src/path/to/file.ts", "src/path/to/other.ts"],
|
|
77
|
+
"blockedBy": [],
|
|
78
|
+
"agentType": "executor",
|
|
79
|
+
"model": "sonnet"
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
"sharedFiles": ["package.json", "tsconfig.json"],
|
|
83
|
+
"parallelGroups": [["1", "2"], ["3"]]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
DECOMPOSITION RULES:
|
|
87
|
+
|
|
88
|
+
1. FILE OWNERSHIP:
|
|
89
|
+
- Each subtask should have exclusive ownership of its files
|
|
90
|
+
- NO file should appear in multiple subtasks' files arrays
|
|
91
|
+
- Use specific file paths, not directories (unless truly needed)
|
|
92
|
+
- Mark config/lock files as sharedFiles (handled by coordinator)
|
|
93
|
+
|
|
94
|
+
2. DEPENDENCIES (blockedBy):
|
|
95
|
+
- Only add blockedBy if subtask TRULY requires another to complete first
|
|
96
|
+
- Prefer parallel execution - maximize independent subtasks
|
|
97
|
+
- Common dependencies: type definitions, shared utilities, API contracts
|
|
98
|
+
|
|
99
|
+
3. PARALLEL GROUPS:
|
|
100
|
+
- Group subtasks that can run simultaneously
|
|
101
|
+
- First group has no dependencies
|
|
102
|
+
- Later groups depend on earlier ones completing
|
|
103
|
+
- Example: [["1", "2", "3"], ["4", "5"]] means 1,2,3 run first, then 4,5
|
|
104
|
+
|
|
105
|
+
4. AGENT/MODEL SELECTION:
|
|
106
|
+
- executor-low/haiku: Simple changes, single file, straightforward logic
|
|
107
|
+
- executor/sonnet: Standard implementation, moderate complexity (DEFAULT)
|
|
108
|
+
- executor-high/opus: Complex refactoring, architectural changes, multi-file coordination
|
|
109
|
+
|
|
110
|
+
5. SUBTASK GUIDELINES:
|
|
111
|
+
- Maximum ${maxSubtasks} subtasks
|
|
112
|
+
- Preferred model tier: ${preferredModel}
|
|
113
|
+
- Each subtask should be completable in 2-10 minutes
|
|
114
|
+
- Subtask description should be actionable and specific
|
|
115
|
+
- Include all files the subtask will CREATE or MODIFY
|
|
116
|
+
|
|
117
|
+
6. SHARED FILES (coordinator handles):
|
|
118
|
+
- package.json, lock files
|
|
119
|
+
- tsconfig.json, config files
|
|
120
|
+
- Root README.md
|
|
121
|
+
- Docker/CI configuration
|
|
122
|
+
- Any file multiple subtasks would need to modify
|
|
123
|
+
|
|
124
|
+
EXAMPLE OUTPUT:
|
|
125
|
+
|
|
126
|
+
{
|
|
127
|
+
"subtasks": [
|
|
128
|
+
{
|
|
129
|
+
"id": "1",
|
|
130
|
+
"description": "Create Express API routes for todo CRUD operations",
|
|
131
|
+
"files": ["src/server/routes/todos.ts", "src/server/controllers/todoController.ts"],
|
|
132
|
+
"blockedBy": [],
|
|
133
|
+
"agentType": "executor",
|
|
134
|
+
"model": "sonnet"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"id": "2",
|
|
138
|
+
"description": "Create React components for todo list UI",
|
|
139
|
+
"files": ["src/client/components/TodoList.tsx", "src/client/components/TodoItem.tsx"],
|
|
140
|
+
"blockedBy": [],
|
|
141
|
+
"agentType": "executor",
|
|
142
|
+
"model": "sonnet"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"id": "3",
|
|
146
|
+
"description": "Create database schema and migrations for todos",
|
|
147
|
+
"files": ["src/db/migrations/001_create_todos.ts", "src/db/models/Todo.ts"],
|
|
148
|
+
"blockedBy": [],
|
|
149
|
+
"agentType": "executor-low",
|
|
150
|
+
"model": "haiku"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"id": "4",
|
|
154
|
+
"description": "Wire up API client in frontend to connect to backend",
|
|
155
|
+
"files": ["src/client/api/todoApi.ts", "src/client/hooks/useTodos.ts"],
|
|
156
|
+
"blockedBy": ["1", "2"],
|
|
157
|
+
"agentType": "executor",
|
|
158
|
+
"model": "sonnet"
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"sharedFiles": ["package.json", "tsconfig.json", "src/types/todo.ts"],
|
|
162
|
+
"parallelGroups": [["1", "2", "3"], ["4"]]
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
Return ONLY the JSON object, no markdown code fences or additional text.`;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Parse the Architect's response into a structured DecompositionResult
|
|
169
|
+
*
|
|
170
|
+
* Handles various response formats including:
|
|
171
|
+
* - Raw JSON
|
|
172
|
+
* - JSON wrapped in markdown code fences
|
|
173
|
+
* - JSON with surrounding explanation text
|
|
174
|
+
*
|
|
175
|
+
* @param response - Raw response string from the Architect agent
|
|
176
|
+
* @returns Parsed and validated DecompositionResult
|
|
177
|
+
* @throws Error if response cannot be parsed or is invalid
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const result = parseDecompositionResult(architectResponse);
|
|
182
|
+
* console.log(result.subtasks.length); // Number of parallel tasks
|
|
183
|
+
* console.log(result.parallelGroups); // Execution order
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export function parseDecompositionResult(response) {
|
|
187
|
+
// Try to extract JSON from response (may be wrapped in markdown or have surrounding text)
|
|
188
|
+
let jsonStr;
|
|
189
|
+
// First, try to find JSON in markdown code fences
|
|
190
|
+
const fencedMatch = response.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
191
|
+
if (fencedMatch && fencedMatch[1]) {
|
|
192
|
+
jsonStr = fencedMatch[1].trim();
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
// Try to find raw JSON object
|
|
196
|
+
const jsonMatch = response.match(/\{[\s\S]*\}/);
|
|
197
|
+
if (!jsonMatch) {
|
|
198
|
+
throw new Error('Could not parse decomposition result: no JSON object found in response');
|
|
199
|
+
}
|
|
200
|
+
jsonStr = jsonMatch[0];
|
|
201
|
+
}
|
|
202
|
+
let parsed;
|
|
203
|
+
try {
|
|
204
|
+
parsed = JSON.parse(jsonStr);
|
|
205
|
+
}
|
|
206
|
+
catch (e) {
|
|
207
|
+
throw new Error(`Could not parse decomposition result: invalid JSON - ${e instanceof Error ? e.message : 'unknown error'}`);
|
|
208
|
+
}
|
|
209
|
+
// Validate structure
|
|
210
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
211
|
+
throw new Error('Could not parse decomposition result: response is not an object');
|
|
212
|
+
}
|
|
213
|
+
const result = parsed;
|
|
214
|
+
// Validate required fields
|
|
215
|
+
if (!Array.isArray(result.subtasks)) {
|
|
216
|
+
throw new Error('Could not parse decomposition result: missing or invalid subtasks array');
|
|
217
|
+
}
|
|
218
|
+
// Validate each subtask
|
|
219
|
+
for (const subtask of result.subtasks) {
|
|
220
|
+
if (!subtask || typeof subtask !== 'object') {
|
|
221
|
+
throw new Error('Could not parse decomposition result: invalid subtask object');
|
|
222
|
+
}
|
|
223
|
+
const st = subtask;
|
|
224
|
+
if (typeof st.id !== 'string' || !st.id) {
|
|
225
|
+
throw new Error('Could not parse decomposition result: subtask missing id');
|
|
226
|
+
}
|
|
227
|
+
if (typeof st.description !== 'string' || !st.description) {
|
|
228
|
+
throw new Error('Could not parse decomposition result: subtask missing description');
|
|
229
|
+
}
|
|
230
|
+
if (!Array.isArray(st.files)) {
|
|
231
|
+
throw new Error(`Could not parse decomposition result: subtask ${st.id} missing files array`);
|
|
232
|
+
}
|
|
233
|
+
if (!Array.isArray(st.blockedBy)) {
|
|
234
|
+
// Default to empty array if not provided
|
|
235
|
+
st.blockedBy = [];
|
|
236
|
+
}
|
|
237
|
+
// Validate and default agentType
|
|
238
|
+
const validAgentTypes = ['executor-low', 'executor', 'executor-high'];
|
|
239
|
+
if (!st.agentType || !validAgentTypes.includes(st.agentType)) {
|
|
240
|
+
st.agentType = 'executor';
|
|
241
|
+
}
|
|
242
|
+
// Validate and default model
|
|
243
|
+
const validModels = ['haiku', 'sonnet', 'opus'];
|
|
244
|
+
if (!st.model || !validModels.includes(st.model)) {
|
|
245
|
+
st.model = 'sonnet';
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Validate/default sharedFiles
|
|
249
|
+
if (!Array.isArray(result.sharedFiles)) {
|
|
250
|
+
result.sharedFiles = [];
|
|
251
|
+
}
|
|
252
|
+
// Validate/default parallelGroups
|
|
253
|
+
if (!Array.isArray(result.parallelGroups)) {
|
|
254
|
+
// Generate default parallel groups based on blockedBy
|
|
255
|
+
result.parallelGroups = generateParallelGroups(result.subtasks);
|
|
256
|
+
}
|
|
257
|
+
return result;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Generate parallel groups from subtask dependencies
|
|
261
|
+
*
|
|
262
|
+
* Creates an ordered array of task ID groups where each group can run
|
|
263
|
+
* in parallel, and later groups depend on earlier ones completing.
|
|
264
|
+
*
|
|
265
|
+
* @param subtasks - Array of decomposed subtasks with blockedBy fields
|
|
266
|
+
* @returns Array of parallel groups (each group is array of task IDs)
|
|
267
|
+
*/
|
|
268
|
+
export function generateParallelGroups(subtasks) {
|
|
269
|
+
const groups = [];
|
|
270
|
+
const completed = new Set();
|
|
271
|
+
const remaining = new Set(subtasks.map((t) => t.id));
|
|
272
|
+
while (remaining.size > 0) {
|
|
273
|
+
const currentGroup = [];
|
|
274
|
+
for (const subtask of subtasks) {
|
|
275
|
+
if (!remaining.has(subtask.id))
|
|
276
|
+
continue;
|
|
277
|
+
// Check if all dependencies are completed
|
|
278
|
+
const depsCompleted = subtask.blockedBy.every((dep) => completed.has(dep));
|
|
279
|
+
if (depsCompleted) {
|
|
280
|
+
currentGroup.push(subtask.id);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (currentGroup.length === 0) {
|
|
284
|
+
// Circular dependency detected - add remaining tasks to break cycle
|
|
285
|
+
const remainingIds = Array.from(remaining);
|
|
286
|
+
groups.push(remainingIds);
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
// Mark current group as completed
|
|
290
|
+
for (const id of currentGroup) {
|
|
291
|
+
completed.add(id);
|
|
292
|
+
remaining.delete(id);
|
|
293
|
+
}
|
|
294
|
+
groups.push(currentGroup);
|
|
295
|
+
}
|
|
296
|
+
return groups;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Validate that file ownership doesn't overlap between subtasks
|
|
300
|
+
*
|
|
301
|
+
* @param subtasks - Array of decomposed subtasks
|
|
302
|
+
* @returns Object with isValid flag and any conflicts found
|
|
303
|
+
*/
|
|
304
|
+
export function validateFileOwnership(subtasks) {
|
|
305
|
+
const fileToOwners = new Map();
|
|
306
|
+
for (const subtask of subtasks) {
|
|
307
|
+
for (const file of subtask.files) {
|
|
308
|
+
if (!fileToOwners.has(file)) {
|
|
309
|
+
fileToOwners.set(file, []);
|
|
310
|
+
}
|
|
311
|
+
fileToOwners.get(file).push(subtask.id);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const conflicts = [];
|
|
315
|
+
for (const [file, owners] of fileToOwners.entries()) {
|
|
316
|
+
if (owners.length > 1) {
|
|
317
|
+
conflicts.push({ file, owners });
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
isValid: conflicts.length === 0,
|
|
322
|
+
conflicts
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Merge shared files from subtasks into the sharedFiles list
|
|
327
|
+
*
|
|
328
|
+
* Identifies files that match shared file patterns and removes them
|
|
329
|
+
* from subtask ownership, adding them to sharedFiles instead.
|
|
330
|
+
*
|
|
331
|
+
* @param result - DecompositionResult to process
|
|
332
|
+
* @param patterns - Array of glob patterns for shared files
|
|
333
|
+
* @returns Updated DecompositionResult with shared files extracted
|
|
334
|
+
*/
|
|
335
|
+
export function extractSharedFiles(result, patterns = DEFAULT_SHARED_FILE_PATTERNS) {
|
|
336
|
+
const sharedSet = new Set(result.sharedFiles);
|
|
337
|
+
// Simple pattern matching (exact match or basic glob)
|
|
338
|
+
const isSharedFile = (file) => {
|
|
339
|
+
const fileName = file.split('/').pop() || file;
|
|
340
|
+
return patterns.some((pattern) => {
|
|
341
|
+
if (pattern.includes('*')) {
|
|
342
|
+
// Basic glob: convert to regex
|
|
343
|
+
const regex = new RegExp('^' + pattern.replace(/\./g, '\\.').replace(/\*/g, '.*') + '$');
|
|
344
|
+
return regex.test(file) || regex.test(fileName);
|
|
345
|
+
}
|
|
346
|
+
return file === pattern || fileName === pattern;
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
// Process each subtask
|
|
350
|
+
const updatedSubtasks = result.subtasks.map((subtask) => {
|
|
351
|
+
const ownedFiles = [];
|
|
352
|
+
for (const file of subtask.files) {
|
|
353
|
+
if (isSharedFile(file)) {
|
|
354
|
+
sharedSet.add(file);
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
ownedFiles.push(file);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return { ...subtask, files: ownedFiles };
|
|
361
|
+
});
|
|
362
|
+
return {
|
|
363
|
+
subtasks: updatedSubtasks,
|
|
364
|
+
sharedFiles: Array.from(sharedSet),
|
|
365
|
+
parallelGroups: result.parallelGroups
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Convert DecompositionResult to simple string array for legacy compatibility
|
|
370
|
+
*
|
|
371
|
+
* @param result - Full decomposition result
|
|
372
|
+
* @returns Array of task description strings
|
|
373
|
+
*/
|
|
374
|
+
export function toSimpleSubtasks(result) {
|
|
375
|
+
return result.subtasks.map((t) => t.description);
|
|
376
|
+
}
|
|
377
|
+
//# sourceMappingURL=decomposer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decomposer.js","sourceRoot":"","sources":["../../../src/hooks/ultrapilot/decomposer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsDH;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,cAAc;IACd,mBAAmB;IACnB,WAAW;IACX,gBAAgB;IAChB,eAAe;IACf,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;IAChB,kBAAkB;IAClB,aAAa;IACb,eAAe;IACf,YAAY;IACZ,WAAW;IACX,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,YAAY;I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