@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/state-autonomous.ts
CHANGED
|
@@ -1,164 +1,163 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Crew - Autonomous Execution State
|
|
3
|
-
*
|
|
4
|
-
* Tracks autonomous mode, wave history, concurrency, and auto-work flag.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { normalizeCwd } from "./state.ts";
|
|
8
|
-
|
|
9
|
-
export interface WaveResult {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface AutonomousState {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const autonomousState: AutonomousState = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const MIN_CONCURRENCY = 1;
|
|
45
|
-
export const MAX_CONCURRENCY = 10;
|
|
46
|
-
|
|
47
|
-
function isProcessAlive(pid: number): boolean {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function clampConcurrency(value: number, configMax?: number): number {
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
let
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Crew - Autonomous Execution State
|
|
3
|
+
*
|
|
4
|
+
* Tracks autonomous mode, wave history, concurrency, and auto-work flag.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { normalizeCwd } from "./state.ts";
|
|
8
|
+
|
|
9
|
+
export interface WaveResult {
|
|
10
|
+
waveNumber: number;
|
|
11
|
+
tasksAttempted: string[];
|
|
12
|
+
succeeded: string[];
|
|
13
|
+
failed: string[];
|
|
14
|
+
blocked: string[];
|
|
15
|
+
timestamp: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface AutonomousState {
|
|
19
|
+
active: boolean;
|
|
20
|
+
cwd: string | null;
|
|
21
|
+
waveNumber: number;
|
|
22
|
+
waveHistory: WaveResult[];
|
|
23
|
+
startedAt: string | null;
|
|
24
|
+
stoppedAt: string | null;
|
|
25
|
+
stopReason: "completed" | "blocked" | "manual" | null;
|
|
26
|
+
concurrency: number;
|
|
27
|
+
autoOverlayPending: boolean;
|
|
28
|
+
pid: number | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const autonomousState: AutonomousState = {
|
|
32
|
+
active: false,
|
|
33
|
+
cwd: null,
|
|
34
|
+
waveNumber: 0,
|
|
35
|
+
waveHistory: [],
|
|
36
|
+
startedAt: null,
|
|
37
|
+
stoppedAt: null,
|
|
38
|
+
stopReason: null,
|
|
39
|
+
concurrency: 2,
|
|
40
|
+
autoOverlayPending: false,
|
|
41
|
+
pid: null,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const MIN_CONCURRENCY = 1;
|
|
45
|
+
export const MAX_CONCURRENCY = 10;
|
|
46
|
+
|
|
47
|
+
function isProcessAlive(pid: number): boolean {
|
|
48
|
+
try {
|
|
49
|
+
process.kill(pid, 0);
|
|
50
|
+
return true;
|
|
51
|
+
} catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function clampConcurrency(value: number, configMax?: number): number {
|
|
57
|
+
if (!Number.isFinite(value)) return MIN_CONCURRENCY;
|
|
58
|
+
const whole = Math.trunc(value);
|
|
59
|
+
const effectiveMax =
|
|
60
|
+
configMax != null && Number.isFinite(configMax) ? Math.min(configMax, MAX_CONCURRENCY) : MAX_CONCURRENCY;
|
|
61
|
+
return Math.max(MIN_CONCURRENCY, Math.min(effectiveMax, whole));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let concurrencyResolve: (() => void) | null = null;
|
|
65
|
+
|
|
66
|
+
export function adjustConcurrency(delta: number, configMax?: number): number {
|
|
67
|
+
autonomousState.concurrency = clampConcurrency(autonomousState.concurrency + delta, configMax);
|
|
68
|
+
if (concurrencyResolve) {
|
|
69
|
+
const resolve = concurrencyResolve;
|
|
70
|
+
concurrencyResolve = null;
|
|
71
|
+
resolve();
|
|
72
|
+
}
|
|
73
|
+
return autonomousState.concurrency;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function waitForConcurrencyChange(): Promise<void> {
|
|
77
|
+
return new Promise(resolve => {
|
|
78
|
+
concurrencyResolve = resolve;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function startAutonomous(cwd: string, concurrency: number): void {
|
|
83
|
+
autonomousState.active = true;
|
|
84
|
+
autonomousState.cwd = normalizeCwd(cwd);
|
|
85
|
+
autonomousState.waveNumber = 1;
|
|
86
|
+
autonomousState.waveHistory = [];
|
|
87
|
+
autonomousState.startedAt = new Date().toISOString();
|
|
88
|
+
autonomousState.stoppedAt = null;
|
|
89
|
+
autonomousState.stopReason = null;
|
|
90
|
+
autonomousState.concurrency = clampConcurrency(concurrency);
|
|
91
|
+
autonomousState.autoOverlayPending = true;
|
|
92
|
+
autonomousState.pid = process.pid;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function stopAutonomous(reason: "completed" | "blocked" | "manual"): void {
|
|
96
|
+
autonomousState.active = false;
|
|
97
|
+
autonomousState.autoOverlayPending = false;
|
|
98
|
+
autonomousState.stoppedAt = new Date().toISOString();
|
|
99
|
+
autonomousState.stopReason = reason;
|
|
100
|
+
autonomousState.pid = null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function addWaveResult(result: WaveResult): void {
|
|
104
|
+
autonomousState.waveHistory.push(result);
|
|
105
|
+
autonomousState.waveNumber++;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function restoreAutonomousState(data: Partial<AutonomousState>): void {
|
|
109
|
+
if (data.active !== undefined) autonomousState.active = data.active;
|
|
110
|
+
if (data.cwd !== undefined) {
|
|
111
|
+
autonomousState.cwd = data.cwd ? normalizeCwd(data.cwd) : data.cwd;
|
|
112
|
+
}
|
|
113
|
+
if (data.waveNumber !== undefined) autonomousState.waveNumber = data.waveNumber;
|
|
114
|
+
if (data.waveHistory !== undefined) autonomousState.waveHistory = data.waveHistory;
|
|
115
|
+
if (data.startedAt !== undefined) autonomousState.startedAt = data.startedAt;
|
|
116
|
+
if (data.stoppedAt !== undefined) autonomousState.stoppedAt = data.stoppedAt;
|
|
117
|
+
if (data.stopReason !== undefined) autonomousState.stopReason = data.stopReason;
|
|
118
|
+
if (data.concurrency !== undefined) {
|
|
119
|
+
autonomousState.concurrency = clampConcurrency(Number(data.concurrency));
|
|
120
|
+
}
|
|
121
|
+
if (data.pid !== undefined) {
|
|
122
|
+
autonomousState.pid = typeof data.pid === "number" ? data.pid : null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (!autonomousState.active) return;
|
|
126
|
+
|
|
127
|
+
const ownerPid = autonomousState.pid;
|
|
128
|
+
const sameProcess = ownerPid === process.pid;
|
|
129
|
+
const ownerAlive = typeof ownerPid === "number" && isProcessAlive(ownerPid);
|
|
130
|
+
|
|
131
|
+
if (!sameProcess || !ownerAlive) {
|
|
132
|
+
autonomousState.active = false;
|
|
133
|
+
autonomousState.autoOverlayPending = false;
|
|
134
|
+
autonomousState.stopReason = autonomousState.stopReason ?? "manual";
|
|
135
|
+
autonomousState.stoppedAt = autonomousState.stoppedAt ?? new Date().toISOString();
|
|
136
|
+
autonomousState.pid = null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function isAutonomousForCwd(cwd: string): boolean {
|
|
141
|
+
if (!autonomousState.active || !autonomousState.cwd) return false;
|
|
142
|
+
return normalizeCwd(autonomousState.cwd) === normalizeCwd(cwd);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let pendingAutoWork = false;
|
|
146
|
+
let pendingAutoWorkCwd: string | null = null;
|
|
147
|
+
|
|
148
|
+
export function isPendingAutoWork(): boolean {
|
|
149
|
+
return pendingAutoWork;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function setPendingAutoWork(cwd: string): void {
|
|
153
|
+
pendingAutoWork = true;
|
|
154
|
+
pendingAutoWorkCwd = normalizeCwd(cwd);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function consumePendingAutoWork(): { cwd: string } | null {
|
|
158
|
+
if (!pendingAutoWork || !pendingAutoWorkCwd) return null;
|
|
159
|
+
const consumed = { cwd: pendingAutoWorkCwd };
|
|
160
|
+
pendingAutoWork = false;
|
|
161
|
+
pendingAutoWorkCwd = null;
|
|
162
|
+
return consumed;
|
|
163
|
+
}
|