@linxiraos/pi-messenger 1.1.1 → 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/overlay-coordinator.ts
CHANGED
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
import type { OverlayHandle, TUI } from "@
|
|
2
|
-
|
|
3
|
-
const QUIET_PERIOD_MS = 80;
|
|
4
|
-
const RENDER_THROTTLE_MS = 32;
|
|
5
|
-
const STDOUT_GUARD_MS = 32;
|
|
6
|
-
|
|
7
|
-
type StdoutWrite = typeof process.stdout.write;
|
|
8
|
-
|
|
9
|
-
function hasRenderableOutput(chunk: unknown): boolean {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Coordinates overlay rendering with main agent stdout to prevent visual collision.
|
|
17
|
-
*
|
|
18
|
-
* Strategy: Keep overlay visible, but schedule a "repair" render after foreign
|
|
19
|
-
* output settles. Brief visual corruption is acceptable if it self-heals quickly.
|
|
20
|
-
*/
|
|
21
|
-
export class OverlayRenderCoordinator {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
1
|
+
import type { OverlayHandle, TUI } from "@linxiraos/pi-tui";
|
|
2
|
+
|
|
3
|
+
const QUIET_PERIOD_MS = 80;
|
|
4
|
+
const RENDER_THROTTLE_MS = 32;
|
|
5
|
+
const STDOUT_GUARD_MS = 32;
|
|
6
|
+
|
|
7
|
+
type StdoutWrite = typeof process.stdout.write;
|
|
8
|
+
|
|
9
|
+
function hasRenderableOutput(chunk: unknown): boolean {
|
|
10
|
+
if (typeof chunk === "string") return chunk.length > 0;
|
|
11
|
+
if (chunk instanceof Uint8Array) return chunk.length > 0;
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Coordinates overlay rendering with main agent stdout to prevent visual collision.
|
|
17
|
+
*
|
|
18
|
+
* Strategy: Keep overlay visible, but schedule a "repair" render after foreign
|
|
19
|
+
* output settles. Brief visual corruption is acceptable if it self-heals quickly.
|
|
20
|
+
*/
|
|
21
|
+
export class OverlayRenderCoordinator {
|
|
22
|
+
private tui: TUI | null = null;
|
|
23
|
+
private handle: OverlayHandle | null = null;
|
|
24
|
+
private originalRequestRender: TUI["requestRender"] | null = null;
|
|
25
|
+
private originalStdoutWrite: StdoutWrite | null = null;
|
|
26
|
+
private repairTimer: ReturnType<typeof setTimeout> | null = null;
|
|
27
|
+
private lastRenderAt = 0;
|
|
28
|
+
private stdoutGuardUntil = 0;
|
|
29
|
+
private foreignOutputDetected = false;
|
|
30
|
+
|
|
31
|
+
installStdoutInterceptor(): void {
|
|
32
|
+
if (this.originalStdoutWrite) return;
|
|
33
|
+
|
|
34
|
+
const original = process.stdout.write.bind(process.stdout) as StdoutWrite;
|
|
35
|
+
this.originalStdoutWrite = original;
|
|
36
|
+
|
|
37
|
+
const coordinator = this;
|
|
38
|
+
(process.stdout.write as StdoutWrite) = function writeIntercept(
|
|
39
|
+
chunk: Parameters<StdoutWrite>[0],
|
|
40
|
+
...args: Parameters<StdoutWrite> extends [unknown, ...infer Rest] ? Rest : never
|
|
41
|
+
) {
|
|
42
|
+
const result = original(chunk, ...args);
|
|
43
|
+
coordinator.handleStdoutWrite(chunk);
|
|
44
|
+
return result;
|
|
45
|
+
} as StdoutWrite;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
uninstallStdoutInterceptor(): void {
|
|
49
|
+
if (!this.originalStdoutWrite) return;
|
|
50
|
+
(process.stdout.write as StdoutWrite) = this.originalStdoutWrite;
|
|
51
|
+
this.originalStdoutWrite = null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
attach(tui: TUI): void {
|
|
55
|
+
if (this.tui === tui && this.originalRequestRender) return;
|
|
56
|
+
|
|
57
|
+
this.detach();
|
|
58
|
+
this.tui = tui;
|
|
59
|
+
this.originalRequestRender = tui.requestRender.bind(tui);
|
|
60
|
+
tui.requestRender = ((force?: boolean) => {
|
|
61
|
+
this.requestRender(force);
|
|
62
|
+
}) as TUI["requestRender"];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
setHandle(handle: OverlayHandle | null): void {
|
|
66
|
+
this.handle = handle;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
detach(): void {
|
|
70
|
+
if (this.repairTimer) {
|
|
71
|
+
clearTimeout(this.repairTimer);
|
|
72
|
+
this.repairTimer = null;
|
|
73
|
+
}
|
|
74
|
+
if (this.tui && this.originalRequestRender) {
|
|
75
|
+
this.tui.requestRender = this.originalRequestRender;
|
|
76
|
+
}
|
|
77
|
+
this.tui = null;
|
|
78
|
+
this.handle = null;
|
|
79
|
+
this.originalRequestRender = null;
|
|
80
|
+
this.lastRenderAt = 0;
|
|
81
|
+
this.stdoutGuardUntil = 0;
|
|
82
|
+
this.foreignOutputDetected = false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
dispose(): void {
|
|
86
|
+
this.detach();
|
|
87
|
+
this.uninstallStdoutInterceptor();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Called by hooks when main agent activity is expected */
|
|
91
|
+
noteForegroundActivity(): void {
|
|
92
|
+
if (!this.tui || !this.handle) return;
|
|
93
|
+
if (this.handle.isHidden()) return;
|
|
94
|
+
|
|
95
|
+
this.foreignOutputDetected = true;
|
|
96
|
+
this.scheduleRepair();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private handleStdoutWrite(chunk: unknown): void {
|
|
100
|
+
if (!this.tui || !this.handle) return;
|
|
101
|
+
if (!hasRenderableOutput(chunk)) return;
|
|
102
|
+
if (Date.now() <= this.stdoutGuardUntil) return;
|
|
103
|
+
if (this.handle.isHidden()) return;
|
|
104
|
+
|
|
105
|
+
this.foreignOutputDetected = true;
|
|
106
|
+
this.scheduleRepair();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private scheduleRepair(): void {
|
|
110
|
+
if (this.repairTimer) clearTimeout(this.repairTimer);
|
|
111
|
+
this.repairTimer = setTimeout(() => {
|
|
112
|
+
this.repairTimer = null;
|
|
113
|
+
this.repair();
|
|
114
|
+
}, QUIET_PERIOD_MS);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private repair(): void {
|
|
118
|
+
if (!this.tui || !this.handle) return;
|
|
119
|
+
if (this.handle.isHidden()) return;
|
|
120
|
+
if (!this.foreignOutputDetected) return;
|
|
121
|
+
|
|
122
|
+
this.foreignOutputDetected = false;
|
|
123
|
+
this.flushRender(true);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
requestRender(force = false): void {
|
|
127
|
+
if (!this.originalRequestRender) return;
|
|
128
|
+
if (this.handle?.isHidden()) return;
|
|
129
|
+
|
|
130
|
+
const now = Date.now();
|
|
131
|
+
if (!force) {
|
|
132
|
+
const elapsed = now - this.lastRenderAt;
|
|
133
|
+
if (elapsed < RENDER_THROTTLE_MS) {
|
|
134
|
+
// Skip this render, repair timer will catch up
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this.flushRender(force);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private flushRender(force: boolean): void {
|
|
143
|
+
if (!this.originalRequestRender) return;
|
|
144
|
+
if (this.handle?.isHidden()) return;
|
|
145
|
+
|
|
146
|
+
this.lastRenderAt = Date.now();
|
|
147
|
+
this.stdoutGuardUntil = this.lastRenderAt + STDOUT_GUARD_MS;
|
|
148
|
+
this.originalRequestRender(force);
|
|
149
|
+
}
|
|
150
|
+
}
|