pi-subagent-manager 1.10.0 → 1.12.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 (95) hide show
  1. package/README.md +9 -9
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +790 -0
  4. package/dist/orch/checklist-integration.js +176 -0
  5. package/dist/orch/context-entries.js +6 -0
  6. package/dist/orch/cost-ledger.js +38 -0
  7. package/dist/orch/diagnostics.js +86 -0
  8. package/dist/orch/extensions.js +66 -0
  9. package/dist/orch/housekeeping-usage.js +22 -0
  10. package/dist/orch/housekeeping.js +248 -0
  11. package/dist/orch/inherited-tools.js +57 -0
  12. package/dist/orch/mailbox.js +195 -0
  13. package/dist/orch/manager.js +970 -0
  14. package/dist/orch/paths.js +69 -0
  15. package/dist/orch/prompt.js +30 -0
  16. package/dist/orch/registry.js +115 -0
  17. package/dist/orch/runtime.js +835 -0
  18. package/dist/orch/tools.js +112 -0
  19. package/dist/orch/transcript.js +165 -0
  20. package/dist/prefs/agent-import.js +188 -0
  21. package/dist/prefs/config.js +878 -0
  22. package/dist/prefs/import-discovery.js +547 -0
  23. package/{src/prefs/import-instructions.ts → dist/prefs/import-instructions.js} +0 -1
  24. package/dist/prefs/models.js +56 -0
  25. package/dist/prefs/settings.js +491 -0
  26. package/dist/types.js +1 -0
  27. package/dist/ui/agent-loader.js +63 -0
  28. package/dist/ui/agent-navigation-editor.js +168 -0
  29. package/dist/ui/cost-footer.js +209 -0
  30. package/dist/ui/dialog.js +505 -0
  31. package/dist/ui/import-picker.js +191 -0
  32. package/dist/ui/live-agent-view.js +527 -0
  33. package/dist/ui/model-picker.js +529 -0
  34. package/dist/ui/settings-ui.js +671 -0
  35. package/dist/ui/status-ui.js +470 -0
  36. package/dist/ui/thread-tree.js +142 -0
  37. package/dist/ui/tool-picker.js +331 -0
  38. package/dist/ui/transcript-tool.js +91 -0
  39. package/dist/ui/ui.js +1019 -0
  40. package/package.json +17 -5
  41. package/docs/assets/subagent-manager-demo.gif +0 -0
  42. package/docs/async-lifecycle.md +0 -153
  43. package/docs/custom-agents.md +0 -154
  44. package/docs/default-agents.md +0 -95
  45. package/docs/demo.md +0 -63
  46. package/docs/development.md +0 -74
  47. package/docs/importing-agents.md +0 -41
  48. package/docs/pi-footer.md +0 -128
  49. package/docs/research-claude.md +0 -258
  50. package/docs/research-codex.md +0 -143
  51. package/docs/research-default-agent-models.md +0 -121
  52. package/docs/research-model-audit-2026-10.md +0 -154
  53. package/docs/research-model-roles-coding.md +0 -99
  54. package/docs/research-model-roles-writing.md +0 -78
  55. package/docs/research-researcher-workflow.md +0 -97
  56. package/docs/settings.md +0 -293
  57. package/docs/subagent-extension-limitations.md +0 -98
  58. package/docs/threads.md +0 -73
  59. package/docs/tools-and-ui.md +0 -129
  60. package/src/index.ts +0 -920
  61. package/src/orch/checklist-integration.ts +0 -230
  62. package/src/orch/context-entries.ts +0 -15
  63. package/src/orch/cost-ledger.ts +0 -56
  64. package/src/orch/diagnostics.ts +0 -95
  65. package/src/orch/extensions.ts +0 -83
  66. package/src/orch/housekeeping-usage.ts +0 -47
  67. package/src/orch/housekeeping.ts +0 -348
  68. package/src/orch/inherited-tools.ts +0 -84
  69. package/src/orch/mailbox.ts +0 -261
  70. package/src/orch/manager.ts +0 -1084
  71. package/src/orch/paths.ts +0 -73
  72. package/src/orch/prompt.ts +0 -39
  73. package/src/orch/registry.ts +0 -168
  74. package/src/orch/runtime.ts +0 -1041
  75. package/src/orch/tools.ts +0 -190
  76. package/src/orch/transcript.ts +0 -186
  77. package/src/prefs/agent-import.ts +0 -245
  78. package/src/prefs/config.ts +0 -1017
  79. package/src/prefs/import-discovery.ts +0 -643
  80. package/src/prefs/models.ts +0 -74
  81. package/src/prefs/settings.ts +0 -614
  82. package/src/types.ts +0 -271
  83. package/src/ui/agent-loader.ts +0 -98
  84. package/src/ui/agent-navigation-editor.ts +0 -233
  85. package/src/ui/cost-footer.ts +0 -230
  86. package/src/ui/dialog.ts +0 -678
  87. package/src/ui/import-picker.ts +0 -231
  88. package/src/ui/live-agent-view.ts +0 -600
  89. package/src/ui/model-picker.ts +0 -701
  90. package/src/ui/settings-ui.ts +0 -830
  91. package/src/ui/status-ui.ts +0 -628
  92. package/src/ui/thread-tree.ts +0 -173
  93. package/src/ui/tool-picker.ts +0 -398
  94. package/src/ui/transcript-tool.ts +0 -142
  95. package/src/ui/ui.ts +0 -1407
@@ -1,231 +0,0 @@
1
- import type { ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
2
- import {
3
- CURSOR_MARKER,
4
- getKeybindings,
5
- Key,
6
- matchesKey,
7
- truncateToWidth,
8
- visibleWidth,
9
- } from "@earendil-works/pi-tui";
10
- import {
11
- DIALOG_OPTIONS,
12
- dialogHeight,
13
- dialogText,
14
- frameDialog,
15
- type DialogHost,
16
- } from "./dialog.ts";
17
-
18
- export interface ImportPickerItem {
19
- id: string;
20
- label: string;
21
- detail: string;
22
- }
23
-
24
- const TITLE = "Import agents";
25
- const DETAIL_LINE_CAP = 3;
26
- // Critical controls first so a truncated footer still shows how to finish.
27
- const FOOTER =
28
- "Space toggle · Enter import (empty skip) · Esc cancel · Ctrl+A all · ↑↓ navigate · PgUp/PgDn · Home/End";
29
-
30
- /**
31
- * Agent labels and paths are untrusted. dialogText strips known sequences;
32
- * also drop Pi's cursor marker and any leftover ESC so a source file cannot
33
- * spoof the cursor or inject a title/color sequence.
34
- */
35
- function agentText(text: string): string {
36
- return dialogText(text).split(CURSOR_MARKER).join("").replaceAll("\x1b", " ");
37
- }
38
-
39
- /**
40
- * truncateToWidth appends ESC [ 0 m when it clips. That reset is not a theme
41
- * color and must not become part of the wrapped agent text.
42
- */
43
- function clipVisible(text: string, columns: number): string {
44
- if (columns <= 0 || !text) return "";
45
- if (visibleWidth(text) <= columns) return text;
46
- const clipped = truncateToWidth(text, columns, "").replaceAll("\x1b[0m", "");
47
- return clipped && text.startsWith(clipped) ? clipped : "";
48
- }
49
-
50
- /** Split sanitized text into frame-width lines without dropping a fitting prefix. */
51
- function wrapText(text: string, columns: number): string[] {
52
- const clean = agentText(text);
53
- if (!clean || columns <= 0) return [];
54
- const lines: string[] = [];
55
- let rest = clean;
56
- while (rest.length > 0) {
57
- const chunk = clipVisible(rest, columns);
58
- if (!chunk) {
59
- rest = rest.slice(1);
60
- continue;
61
- }
62
- lines.push(chunk);
63
- if (chunk.length >= rest.length) break;
64
- rest = rest.slice(chunk.length);
65
- }
66
- return lines;
67
- }
68
-
69
- /**
70
- * Checkbox dialog for choosing external agents to migrate.
71
- * Selection only — the caller imports; this does not read or write agent files.
72
- */
73
- export class ImportPicker {
74
- private cursor = 0;
75
- private viewport = 1;
76
- private readonly checked = new Set<string>();
77
-
78
- constructor(
79
- private host: DialogHost,
80
- private theme: Theme,
81
- private readonly items: readonly ImportPickerItem[],
82
- private done: (ids: string[] | undefined) => void,
83
- ) {}
84
-
85
- /** Selected ids in source order. Empty until the user toggles a row. */
86
- getSelectedIds(): string[] {
87
- const seen = new Set<string>();
88
- const ids: string[] = [];
89
- for (const item of this.items) {
90
- if (!this.checked.has(item.id) || seen.has(item.id)) continue;
91
- seen.add(item.id);
92
- ids.push(item.id);
93
- }
94
- return ids;
95
- }
96
-
97
- getCursorIndex(): number {
98
- return this.cursor;
99
- }
100
-
101
- invalidate(): void {}
102
-
103
- handleInput(data: string): void {
104
- const keys = getKeybindings();
105
- if (keys.matches(data, "tui.select.cancel")) {
106
- this.done(undefined);
107
- return;
108
- }
109
- if (keys.matches(data, "tui.select.confirm")) {
110
- this.done(this.getSelectedIds());
111
- return;
112
- }
113
- if (matchesKey(data, Key.space)) {
114
- this.toggleCursor();
115
- this.host.requestRender();
116
- return;
117
- }
118
- if (matchesKey(data, Key.ctrl("a"))) {
119
- this.toggleAll();
120
- this.host.requestRender();
121
- return;
122
- }
123
- if (this.items.length === 0) return;
124
- if (keys.matches(data, "tui.select.up")) this.move(this.cursor - 1);
125
- else if (keys.matches(data, "tui.select.down")) this.move(this.cursor + 1);
126
- else if (keys.matches(data, "tui.select.pageUp") || matchesKey(data, Key.pageUp))
127
- this.move(this.cursor - this.viewport);
128
- else if (keys.matches(data, "tui.select.pageDown") || matchesKey(data, Key.pageDown))
129
- this.move(this.cursor + this.viewport);
130
- else if (matchesKey(data, Key.home)) this.move(0);
131
- else if (matchesKey(data, Key.end)) this.move(this.items.length - 1);
132
- }
133
-
134
- render(width: number): string[] {
135
- const height = dialogHeight(this.host);
136
- const budget = Math.max(0, height - 4);
137
- const columns = Math.max(1, width - 4);
138
- const current = this.items[this.cursor];
139
- const detail = current ? wrapText(current.detail, columns) : [];
140
- const headerCount = budget > 0 ? 1 : 0;
141
- // Keep the checkbox list usable: at most 3 detail lines, and never more than 1/3 of the body.
142
- let detailCount = Math.min(detail.length, DETAIL_LINE_CAP, Math.floor(budget / 3));
143
- if (this.items.length > 0)
144
- detailCount = Math.min(detailCount, Math.max(0, budget - headerCount - 1));
145
- const room = Math.max(0, budget - headerCount - detailCount);
146
- const gap = detailCount > 0 && room >= 3 ? 1 : 0;
147
- const listCount = Math.max(0, room - gap);
148
- this.viewport = Math.max(1, listCount);
149
- const start = this.windowStart(listCount);
150
- const shown = Math.min(listCount, Math.max(0, this.items.length - start));
151
- const body: string[] = [];
152
- if (headerCount) body.push(this.countLine(start, shown));
153
- if (this.items.length === 0) {
154
- if (listCount > 0) body.push(this.theme.fg("muted", " No external agents to import"));
155
- } else {
156
- const rows = this.items.slice(start, start + listCount);
157
- for (let offset = 0; offset < rows.length; offset++)
158
- body.push(this.row(rows[offset]!, start + offset === this.cursor));
159
- }
160
- if (gap) body.push("");
161
- for (const line of detail.slice(0, detailCount)) body.push(this.theme.fg("muted", ` ${line}`));
162
- return frameDialog(this.theme, width, height, TITLE, body, FOOTER);
163
- }
164
-
165
- private countLine(start: number, shown: number): string {
166
- const position = this.items.length ? this.cursor + 1 : 0;
167
- return this.theme.fg(
168
- "dim",
169
- ` ${this.scrollHint(start, shown)}${this.checked.size} selected · ${position}/${this.items.length}`,
170
- );
171
- }
172
-
173
- /** ▲/▼ counts when the checkbox list is scrolled. Omitted when every row fits. */
174
- private scrollHint(start: number, shown: number): string {
175
- if (this.items.length === 0) return "";
176
- const above = shown > 0 ? start : this.cursor;
177
- const below =
178
- shown > 0
179
- ? Math.max(0, this.items.length - (start + shown))
180
- : Math.max(0, this.items.length - this.cursor - 1);
181
- if (above <= 0 && below <= 0) return "";
182
- const parts: string[] = [];
183
- if (above > 0) parts.push(`▲${above}`);
184
- if (below > 0) parts.push(`▼${below}`);
185
- return `${parts.join(" ")} `;
186
- }
187
-
188
- private row(item: ImportPickerItem, active: boolean): string {
189
- const mark = this.checked.has(item.id) ? "x" : " ";
190
- const text = `${active ? "›" : " "}[${mark}] ${agentText(item.label)}`;
191
- return active ? this.theme.fg("accent", text) : text;
192
- }
193
-
194
- private windowStart(listCount: number): number {
195
- if (listCount <= 0 || this.items.length === 0) return 0;
196
- return Math.max(0, Math.min(this.cursor - listCount + 1, this.items.length - listCount));
197
- }
198
-
199
- private move(next: number): void {
200
- if (this.items.length === 0) return;
201
- this.cursor = Math.max(0, Math.min(this.items.length - 1, next));
202
- this.host.requestRender();
203
- }
204
-
205
- private toggleCursor(): void {
206
- const item = this.items[this.cursor];
207
- if (!item) return;
208
- if (this.checked.has(item.id)) this.checked.delete(item.id);
209
- else this.checked.add(item.id);
210
- }
211
-
212
- private toggleAll(): void {
213
- const all = this.items.length > 0 && this.items.every((item) => this.checked.has(item.id));
214
- if (all) {
215
- this.checked.clear();
216
- return;
217
- }
218
- for (const item of this.items) this.checked.add(item.id);
219
- }
220
- }
221
-
222
- /** Open the import checkbox dialog. Returns ids, [] to skip, or undefined if cancelled. */
223
- export function selectImportAgents(
224
- ctx: ExtensionContext,
225
- items: readonly ImportPickerItem[],
226
- ): Promise<string[] | undefined> {
227
- return ctx.ui.custom(
228
- (host, theme, _keys, done) => new ImportPicker(host, theme, items, done),
229
- DIALOG_OPTIONS,
230
- );
231
- }