@linxiraos/pi-messenger 1.1.0 → 1.3.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/CHANGELOG.md +741 -676
- package/LICENSE +45 -0
- package/README.md +424 -424
- package/THIRD-PARTY-NOTICES.txt +22951 -0
- package/config-overlay.ts +175 -171
- package/config.ts +221 -209
- package/crew/agents/crew-plan-sync.md +66 -64
- package/crew/agents/crew-planner.md +173 -172
- package/crew/agents/crew-reviewer.md +58 -58
- package/crew/agents/crew-worker.md +130 -129
- package/crew/agents.ts +507 -434
- package/crew/handlers/coordination.ts +350 -332
- package/crew/handlers/plan.ts +988 -906
- package/crew/handlers/review.ts +354 -333
- package/crew/handlers/revise.ts +400 -376
- package/crew/handlers/status.ts +303 -295
- package/crew/handlers/sync.ts +237 -233
- package/crew/handlers/task.ts +820 -792
- package/crew/handlers/team.ts +294 -235
- package/crew/handlers/work.ts +467 -425
- package/crew/id-allocator.ts +30 -30
- package/crew/index.ts +297 -257
- package/crew/live-progress.ts +58 -58
- package/crew/lobby.ts +504 -473
- package/crew/prompt.ts +262 -252
- package/crew/registry.ts +114 -114
- package/crew/spawn.ts +135 -111
- package/crew/state-autonomous.ts +163 -164
- package/crew/state-planning.ts +264 -263
- package/crew/state.ts +20 -20
- package/crew/store.ts +646 -642
- package/crew/task-actions.ts +162 -131
- package/crew/team/store.ts +572 -479
- package/crew/team/subagent-roles.ts +105 -87
- package/crew/team/types.ts +50 -50
- package/crew/types.ts +194 -194
- package/crew/utils/artifacts.ts +57 -62
- package/crew/utils/config.ts +158 -156
- package/crew/utils/discover.ts +221 -219
- package/crew/utils/install.ts +94 -85
- package/crew/utils/migrations.ts +126 -0
- package/crew/utils/progress.ts +191 -187
- package/crew/utils/result.ts +16 -16
- package/crew/utils/risk-labels.ts +5 -7
- package/crew/utils/task-format.ts +14 -14
- package/crew/utils/team-roles.ts +44 -28
- package/crew/utils/truncate.ts +76 -79
- package/crew/utils/verdict.ts +55 -55
- package/editor-binary.ts +150 -0
- package/editor-command.ts +107 -0
- package/editor-target.ts +40 -0
- package/feed.ts +321 -268
- package/handlers.ts +1041 -1107
- package/index.ts +1314 -1206
- package/install.mjs +187 -189
- package/lib.ts +587 -467
- package/overlay-actions.ts +519 -511
- package/overlay-coordinator.ts +150 -150
- package/overlay-render.ts +770 -676
- package/overlay.ts +872 -830
- package/package.json +64 -60
- package/paths.ts +60 -0
- package/skills/pi-messenger-crew/SKILL.md +375 -347
- package/store.ts +1147 -1139
- package/teamagent-command.ts +321 -0
- package/vitest.config.ts +10 -10
package/crew/task-actions.ts
CHANGED
|
@@ -1,131 +1,162 @@
|
|
|
1
|
-
import { logFeedEvent } from "../feed.ts";
|
|
2
|
-
import * as store from "./store.ts";
|
|
3
|
-
import { loadCrewConfig } from "./utils/config.ts";
|
|
4
|
-
import { killWorkerByTask } from "./registry.ts";
|
|
5
|
-
import type { Task } from "./types.ts";
|
|
6
|
-
|
|
7
|
-
export type TaskAction = "start" | "block" | "unblock" | "reset" | "cascade-reset" | "delete" | "stop";
|
|
8
|
-
|
|
9
|
-
export interface TaskActionOptions {
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface TaskActionResult {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function executeTaskAction(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
): TaskActionResult {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
1
|
+
import { logFeedEvent } from "../feed.ts";
|
|
2
|
+
import * as store from "./store.ts";
|
|
3
|
+
import { loadCrewConfig } from "./utils/config.ts";
|
|
4
|
+
import { killWorkerByTask } from "./registry.ts";
|
|
5
|
+
import type { Task } from "./types.ts";
|
|
6
|
+
|
|
7
|
+
export type TaskAction = "start" | "block" | "unblock" | "reset" | "cascade-reset" | "delete" | "stop";
|
|
8
|
+
|
|
9
|
+
export interface TaskActionOptions {
|
|
10
|
+
isWorkerActive?: (taskId: string) => boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface TaskActionResult {
|
|
14
|
+
success: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
task?: Task;
|
|
18
|
+
resetTasks?: Task[];
|
|
19
|
+
unmetDependencies?: string[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function executeTaskAction(
|
|
23
|
+
cwd: string,
|
|
24
|
+
action: TaskAction,
|
|
25
|
+
taskId: string,
|
|
26
|
+
agentName: string,
|
|
27
|
+
reason?: string,
|
|
28
|
+
options?: TaskActionOptions,
|
|
29
|
+
): TaskActionResult {
|
|
30
|
+
const task = store.getTask(cwd, taskId);
|
|
31
|
+
if (!task) return { success: false, error: "not_found", message: `Task ${taskId} not found` };
|
|
32
|
+
|
|
33
|
+
switch (action) {
|
|
34
|
+
case "start": {
|
|
35
|
+
if (task.milestone) {
|
|
36
|
+
return {
|
|
37
|
+
success: false,
|
|
38
|
+
error: "milestone_not_startable",
|
|
39
|
+
message: `Task ${taskId} is a milestone and cannot be started manually`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (task.status === "in_progress" && task.assigned_to === agentName) {
|
|
43
|
+
return { success: true, message: `Already started ${taskId}`, task };
|
|
44
|
+
}
|
|
45
|
+
if (task.status !== "todo") {
|
|
46
|
+
return { success: false, error: "invalid_status", message: `Task ${taskId} is ${task.status}, not todo` };
|
|
47
|
+
}
|
|
48
|
+
const config = loadCrewConfig(store.getCrewDir(cwd));
|
|
49
|
+
if (config.dependencies !== "advisory") {
|
|
50
|
+
const unmetDependencies = task.depends_on.filter(depId => store.getTask(cwd, depId)?.status !== "done");
|
|
51
|
+
if (unmetDependencies.length > 0) {
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
error: "unmet_dependencies",
|
|
55
|
+
message: `Unmet dependencies: ${unmetDependencies.join(", ")}`,
|
|
56
|
+
unmetDependencies,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const started = store.startTask(cwd, taskId, agentName);
|
|
61
|
+
if (!started) return { success: false, error: "start_failed", message: `Failed to start ${taskId}` };
|
|
62
|
+
logFeedEvent(cwd, agentName, "task.start", taskId, started.title);
|
|
63
|
+
return { success: true, message: `Started ${taskId}`, task: started };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
case "block": {
|
|
67
|
+
if (task.status !== "in_progress") {
|
|
68
|
+
return { success: false, error: "invalid_status", message: `Task ${taskId} must be in_progress to block` };
|
|
69
|
+
}
|
|
70
|
+
if (!reason) {
|
|
71
|
+
return { success: false, error: "missing_reason", message: `Reason required to block ${taskId}` };
|
|
72
|
+
}
|
|
73
|
+
const blocked = store.blockTask(cwd, taskId, reason);
|
|
74
|
+
if (!blocked) return { success: false, error: "block_failed", message: `Failed to block ${taskId}` };
|
|
75
|
+
logFeedEvent(cwd, agentName, "task.block", taskId, reason);
|
|
76
|
+
return { success: true, message: `Blocked ${taskId}`, task: blocked };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
case "unblock": {
|
|
80
|
+
if (task.status !== "blocked") {
|
|
81
|
+
return {
|
|
82
|
+
success: false,
|
|
83
|
+
error: "invalid_status",
|
|
84
|
+
message: `Task ${taskId} is ${task.status}, not blocked`,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const unblocked = store.unblockTask(cwd, taskId);
|
|
88
|
+
if (!unblocked) return { success: false, error: "unblock_failed", message: `Failed to unblock ${taskId}` };
|
|
89
|
+
logFeedEvent(cwd, agentName, "task.unblock", taskId, unblocked.title);
|
|
90
|
+
return { success: true, message: `Unblocked ${taskId}`, task: unblocked };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
case "reset": {
|
|
94
|
+
if (options?.isWorkerActive?.(taskId)) {
|
|
95
|
+
return {
|
|
96
|
+
success: false,
|
|
97
|
+
error: "active_worker",
|
|
98
|
+
message: `Cannot reset ${taskId} while its worker is active`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const resetTasks = store.resetTask(cwd, taskId, false);
|
|
102
|
+
if (resetTasks.length === 0)
|
|
103
|
+
return { success: false, error: "reset_failed", message: `Failed to reset ${taskId}` };
|
|
104
|
+
logFeedEvent(cwd, agentName, "task.reset", taskId, task.title);
|
|
105
|
+
return { success: true, message: `Reset ${taskId}`, resetTasks };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
case "cascade-reset": {
|
|
109
|
+
const subtree = [task, ...store.getTransitiveDependents(cwd, taskId)];
|
|
110
|
+
const activeTask = subtree.find(t => options?.isWorkerActive?.(t.id));
|
|
111
|
+
if (activeTask) {
|
|
112
|
+
return {
|
|
113
|
+
success: false,
|
|
114
|
+
error: "active_worker",
|
|
115
|
+
message: `Cannot reset ${activeTask.id} while its worker is active`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const resetTasks = store.resetTask(cwd, taskId, true);
|
|
119
|
+
if (resetTasks.length === 0)
|
|
120
|
+
return { success: false, error: "reset_failed", message: `Failed to reset ${taskId}` };
|
|
121
|
+
logFeedEvent(cwd, agentName, "task.reset", taskId, `cascade (${resetTasks.length} tasks)`);
|
|
122
|
+
return {
|
|
123
|
+
success: true,
|
|
124
|
+
message: `Reset ${taskId} + ${Math.max(0, resetTasks.length - 1)} dependents`,
|
|
125
|
+
resetTasks,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
case "delete": {
|
|
130
|
+
if (task.status === "in_progress" && options?.isWorkerActive?.(taskId)) {
|
|
131
|
+
return {
|
|
132
|
+
success: false,
|
|
133
|
+
error: "active_worker",
|
|
134
|
+
message: `Cannot delete ${taskId} while its worker is active`,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (!store.deleteTask(cwd, taskId))
|
|
138
|
+
return { success: false, error: "delete_failed", message: `Failed to delete ${taskId}` };
|
|
139
|
+
logFeedEvent(cwd, agentName, "task.delete", taskId, task.title);
|
|
140
|
+
return { success: true, message: `Deleted ${taskId}` };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
case "stop": {
|
|
144
|
+
if (task.status !== "in_progress") {
|
|
145
|
+
return {
|
|
146
|
+
success: false,
|
|
147
|
+
error: "invalid_status",
|
|
148
|
+
message: `Task ${taskId} is ${task.status}, not in_progress`,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (options?.isWorkerActive?.(taskId)) {
|
|
152
|
+
killWorkerByTask(cwd, taskId);
|
|
153
|
+
store.appendTaskProgress(cwd, taskId, agentName, "Worker stopped by user");
|
|
154
|
+
} else {
|
|
155
|
+
store.appendTaskProgress(cwd, taskId, agentName, "Task unassigned (no active worker)");
|
|
156
|
+
}
|
|
157
|
+
store.updateTask(cwd, taskId, { status: "todo", assigned_to: undefined });
|
|
158
|
+
logFeedEvent(cwd, agentName, "task.reset", taskId, "stopped");
|
|
159
|
+
return { success: true, message: `Stopped ${taskId}` };
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|