@agentuity/coder 2.0.6 → 2.0.8

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 (113) hide show
  1. package/AGENTS.md +43 -0
  2. package/README.md +75 -37
  3. package/dist/index.d.ts +1 -3
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -1577
  6. package/dist/index.js.map +1 -1
  7. package/package.json +9 -12
  8. package/src/index.ts +51 -1885
  9. package/dist/chain-preview.d.ts +0 -55
  10. package/dist/chain-preview.d.ts.map +0 -1
  11. package/dist/chain-preview.js +0 -472
  12. package/dist/chain-preview.js.map +0 -1
  13. package/dist/client.d.ts +0 -43
  14. package/dist/client.d.ts.map +0 -1
  15. package/dist/client.js +0 -405
  16. package/dist/client.js.map +0 -1
  17. package/dist/commands.d.ts +0 -22
  18. package/dist/commands.d.ts.map +0 -1
  19. package/dist/commands.js +0 -99
  20. package/dist/commands.js.map +0 -1
  21. package/dist/footer.d.ts +0 -34
  22. package/dist/footer.d.ts.map +0 -1
  23. package/dist/footer.js +0 -249
  24. package/dist/footer.js.map +0 -1
  25. package/dist/handlers.d.ts +0 -24
  26. package/dist/handlers.d.ts.map +0 -1
  27. package/dist/handlers.js +0 -83
  28. package/dist/handlers.js.map +0 -1
  29. package/dist/hub-overlay-state.d.ts +0 -31
  30. package/dist/hub-overlay-state.d.ts.map +0 -1
  31. package/dist/hub-overlay-state.js +0 -78
  32. package/dist/hub-overlay-state.js.map +0 -1
  33. package/dist/hub-overlay.d.ts +0 -146
  34. package/dist/hub-overlay.d.ts.map +0 -1
  35. package/dist/hub-overlay.js +0 -2354
  36. package/dist/hub-overlay.js.map +0 -1
  37. package/dist/native-remote-ui-context.d.ts +0 -5
  38. package/dist/native-remote-ui-context.d.ts.map +0 -1
  39. package/dist/native-remote-ui-context.js +0 -30
  40. package/dist/native-remote-ui-context.js.map +0 -1
  41. package/dist/output-viewer.d.ts +0 -49
  42. package/dist/output-viewer.d.ts.map +0 -1
  43. package/dist/output-viewer.js +0 -389
  44. package/dist/output-viewer.js.map +0 -1
  45. package/dist/overlay.d.ts +0 -40
  46. package/dist/overlay.d.ts.map +0 -1
  47. package/dist/overlay.js +0 -225
  48. package/dist/overlay.js.map +0 -1
  49. package/dist/protocol.d.ts +0 -605
  50. package/dist/protocol.d.ts.map +0 -1
  51. package/dist/protocol.js +0 -4
  52. package/dist/protocol.js.map +0 -1
  53. package/dist/remote-lifecycle.d.ts +0 -61
  54. package/dist/remote-lifecycle.d.ts.map +0 -1
  55. package/dist/remote-lifecycle.js +0 -190
  56. package/dist/remote-lifecycle.js.map +0 -1
  57. package/dist/remote-session.d.ts +0 -128
  58. package/dist/remote-session.d.ts.map +0 -1
  59. package/dist/remote-session.js +0 -876
  60. package/dist/remote-session.js.map +0 -1
  61. package/dist/remote-tui.d.ts +0 -40
  62. package/dist/remote-tui.d.ts.map +0 -1
  63. package/dist/remote-tui.js +0 -867
  64. package/dist/remote-tui.js.map +0 -1
  65. package/dist/remote-ui-handler.d.ts +0 -5
  66. package/dist/remote-ui-handler.d.ts.map +0 -1
  67. package/dist/remote-ui-handler.js +0 -53
  68. package/dist/remote-ui-handler.js.map +0 -1
  69. package/dist/renderers.d.ts +0 -34
  70. package/dist/renderers.d.ts.map +0 -1
  71. package/dist/renderers.js +0 -669
  72. package/dist/renderers.js.map +0 -1
  73. package/dist/review.d.ts +0 -15
  74. package/dist/review.d.ts.map +0 -1
  75. package/dist/review.js +0 -154
  76. package/dist/review.js.map +0 -1
  77. package/dist/titlebar.d.ts +0 -3
  78. package/dist/titlebar.d.ts.map +0 -1
  79. package/dist/titlebar.js +0 -59
  80. package/dist/titlebar.js.map +0 -1
  81. package/dist/todo/index.d.ts +0 -3
  82. package/dist/todo/index.d.ts.map +0 -1
  83. package/dist/todo/index.js +0 -3
  84. package/dist/todo/index.js.map +0 -1
  85. package/dist/todo/store.d.ts +0 -6
  86. package/dist/todo/store.d.ts.map +0 -1
  87. package/dist/todo/store.js +0 -43
  88. package/dist/todo/store.js.map +0 -1
  89. package/dist/todo/types.d.ts +0 -13
  90. package/dist/todo/types.d.ts.map +0 -1
  91. package/dist/todo/types.js +0 -2
  92. package/dist/todo/types.js.map +0 -1
  93. package/src/chain-preview.ts +0 -621
  94. package/src/client.ts +0 -518
  95. package/src/commands.ts +0 -132
  96. package/src/footer.ts +0 -305
  97. package/src/handlers.ts +0 -113
  98. package/src/hub-overlay-state.ts +0 -127
  99. package/src/hub-overlay.ts +0 -3037
  100. package/src/native-remote-ui-context.ts +0 -41
  101. package/src/output-viewer.ts +0 -480
  102. package/src/overlay.ts +0 -294
  103. package/src/protocol.ts +0 -758
  104. package/src/remote-lifecycle.ts +0 -270
  105. package/src/remote-session.ts +0 -1080
  106. package/src/remote-tui.ts +0 -1020
  107. package/src/remote-ui-handler.ts +0 -86
  108. package/src/renderers.ts +0 -740
  109. package/src/review.ts +0 -201
  110. package/src/titlebar.ts +0 -63
  111. package/src/todo/index.ts +0 -2
  112. package/src/todo/store.ts +0 -49
  113. package/src/todo/types.ts +0 -14
package/src/overlay.ts DELETED
@@ -1,294 +0,0 @@
1
- import type { Theme } from '@mariozechner/pi-coding-agent';
2
- import { matchesKey } from '@mariozechner/pi-tui';
3
- import type { AgentDefinition } from './protocol.ts';
4
- import { truncateToWidth } from './renderers.ts';
5
-
6
- export interface AgentManagerResult {
7
- agent: string;
8
- action: 'run';
9
- }
10
-
11
- interface Component {
12
- render(width: number): string[];
13
- handleInput?(data: string): void;
14
- invalidate(): void;
15
- }
16
-
17
- interface Focusable {
18
- focused: boolean;
19
- }
20
-
21
- type DoneFn = (result: AgentManagerResult | undefined) => void;
22
- type Screen = 'list' | 'detail';
23
-
24
- const ANSI_RE = /\x1b\[[0-9;]*m/g;
25
-
26
- function visibleWidth(text: string): number {
27
- return text.replace(ANSI_RE, '').length;
28
- }
29
-
30
- function padRight(text: string, width: number): string {
31
- if (width <= 0) return '';
32
- const truncated = truncateToWidth(text, width);
33
- const remaining = width - visibleWidth(truncated);
34
- return remaining > 0 ? truncated + ' '.repeat(remaining) : truncated;
35
- }
36
-
37
- function hLine(width: number): string {
38
- return width > 0 ? '─'.repeat(width) : '';
39
- }
40
-
41
- function buildTopBorder(width: number, title: string): string {
42
- if (width <= 0) return '';
43
- if (width === 1) return '╭';
44
- if (width === 2) return '╭╮';
45
-
46
- const inner = width - 2;
47
- const titleText = ` ${title} `;
48
- if (titleText.length >= inner) {
49
- return `╭${hLine(inner)}╮`;
50
- }
51
-
52
- const left = Math.floor((inner - titleText.length) / 2);
53
- const right = inner - titleText.length - left;
54
- return `╭${hLine(left)}${titleText}${hLine(right)}╮`;
55
- }
56
-
57
- function buildBottomBorder(width: number): string {
58
- if (width <= 0) return '';
59
- if (width === 1) return '╰';
60
- if (width === 2) return '╰╯';
61
- return `╰${hLine(width - 2)}╯`;
62
- }
63
-
64
- export class AgentManagerOverlay implements Component, Focusable {
65
- public focused = true;
66
-
67
- private readonly theme: Theme;
68
- private readonly agents: AgentDefinition[];
69
- private readonly done: DoneFn;
70
-
71
- private screen: Screen = 'list';
72
- private selectedIndex = 0;
73
- private readonly listWindowSize = 6;
74
- private disposed = false;
75
-
76
- constructor(theme: Theme, agents: AgentDefinition[], done: DoneFn) {
77
- this.theme = theme;
78
- this.agents = agents;
79
- this.done = done;
80
- }
81
-
82
- handleInput(data: string): void {
83
- if (this.disposed) return;
84
-
85
- if (matchesKey(data, 'escape')) {
86
- if (this.screen === 'detail') {
87
- this.screen = 'list';
88
- this.invalidate();
89
- return;
90
- }
91
- this.close(undefined);
92
- return;
93
- }
94
-
95
- if (this.screen === 'list') {
96
- this.handleListInput(data);
97
- return;
98
- }
99
-
100
- this.handleDetailInput(data);
101
- }
102
-
103
- render(width: number): string[] {
104
- const safeWidth = Math.max(4, width);
105
- const termHeight = process.stdout.rows || 40;
106
- // Match overlay maxHeight of 95%, leave margin for overlay chrome
107
- const maxLines = Math.max(10, Math.floor(termHeight * 0.95) - 2);
108
-
109
- const lines =
110
- this.screen === 'detail'
111
- ? this.renderDetailScreen(safeWidth)
112
- : this.renderListScreen(safeWidth, maxLines);
113
- return lines.map((line) => truncateToWidth(line, safeWidth));
114
- }
115
-
116
- invalidate(): void {
117
- // Stateless rendering; no cache invalidation required.
118
- }
119
-
120
- dispose(): void {
121
- this.disposed = true;
122
- }
123
-
124
- private handleListInput(data: string): void {
125
- const count = this.agents.length;
126
- if (count === 0) return;
127
-
128
- if (matchesKey(data, 'up')) {
129
- this.selectedIndex = (this.selectedIndex - 1 + count) % count;
130
- this.invalidate();
131
- return;
132
- }
133
-
134
- if (matchesKey(data, 'down')) {
135
- this.selectedIndex = (this.selectedIndex + 1) % count;
136
- this.invalidate();
137
- return;
138
- }
139
-
140
- if (matchesKey(data, 'enter')) {
141
- this.screen = 'detail';
142
- this.invalidate();
143
- }
144
- }
145
-
146
- private handleDetailInput(data: string): void {
147
- if (matchesKey(data, 'r') || data.toLowerCase() === 'r') {
148
- const selected = this.agents[this.selectedIndex];
149
- if (!selected) return;
150
- this.close({ action: 'run', agent: selected.name });
151
- }
152
- }
153
-
154
- private close(result: AgentManagerResult | undefined): void {
155
- if (this.disposed) return;
156
- this.disposed = true;
157
- this.done(result);
158
- }
159
-
160
- private renderListScreen(width: number, maxLines: number): string[] {
161
- const inner = Math.max(0, width - 2);
162
-
163
- // Fixed header (always rendered)
164
- const header: string[] = [
165
- buildTopBorder(width, 'Agent Manager'),
166
- this.contentLine('', inner),
167
- ];
168
-
169
- // Fixed footer (always rendered)
170
- const footer: string[] = [
171
- this.contentLine(
172
- this.theme.fg('dim', ' [↑↓] Navigate [Enter] Details [Esc] Close'),
173
- inner
174
- ),
175
- buildBottomBorder(width),
176
- ];
177
-
178
- // Available lines for scrollable content area
179
- const contentBudget = Math.max(4, maxLines - header.length - footer.length);
180
-
181
- if (this.agents.length === 0) {
182
- const content = [
183
- this.contentLine(this.theme.fg('muted', ' No agents available'), inner),
184
- this.contentLine('', inner),
185
- ];
186
- return [...header, ...content, ...footer];
187
- }
188
-
189
- // Each agent takes 4 lines: name, description, capabilities, empty line
190
- const LINES_PER_AGENT = 4;
191
- // Reserve 2 lines for possible scroll indicators
192
- const scrollReserve = 2;
193
- const maxAgents = Math.max(1, Math.floor((contentBudget - scrollReserve) / LINES_PER_AGENT));
194
-
195
- // Dynamic window size based on available space
196
- const windowSize = Math.min(maxAgents, this.agents.length);
197
- const [start, end] = this.getVisibleRange(windowSize);
198
-
199
- const content: string[] = [];
200
-
201
- if (start > 0) {
202
- content.push(this.contentLine(this.theme.fg('dim', ` ↑ ${start} more above`), inner));
203
- }
204
-
205
- for (let i = start; i < end; i++) {
206
- const agent = this.agents[i]!;
207
- const selected = i === this.selectedIndex;
208
- const prefix = selected ? this.theme.fg('accent', '› ') : ' ';
209
-
210
- const model = agent.model ? this.theme.fg('dim', ` [${agent.model}]`) : '';
211
- const readOnly = agent.readOnly ? this.theme.fg('warning', ' read-only') : '';
212
- const title = `${prefix}${this.theme.bold(agent.name)}${model}${readOnly}`;
213
- content.push(this.contentLine(title, inner));
214
-
215
- const description = this.theme.fg('text', ` ${agent.description || 'No description'}`);
216
- content.push(this.contentLine(description, inner));
217
-
218
- const capsText = agent.capabilities?.length ? agent.capabilities.join(', ') : 'none';
219
- const caps = this.theme.fg('muted', ` capabilities: ${capsText}`);
220
- content.push(this.contentLine(caps, inner));
221
-
222
- content.push(this.contentLine('', inner));
223
- }
224
-
225
- if (end < this.agents.length) {
226
- content.push(
227
- this.contentLine(
228
- this.theme.fg('dim', ` ↓ ${this.agents.length - end} more below`),
229
- inner
230
- )
231
- );
232
- }
233
-
234
- return [...header, ...content, ...footer];
235
- }
236
-
237
- private renderDetailScreen(width: number): string[] {
238
- const inner = Math.max(0, width - 2);
239
- const lines: string[] = [];
240
- const agent = this.agents[this.selectedIndex];
241
-
242
- lines.push(buildTopBorder(width, agent?.name || 'Agent'));
243
- lines.push(this.contentLine('', inner));
244
-
245
- if (!agent) {
246
- lines.push(this.contentLine(this.theme.fg('error', ' Agent not found'), inner));
247
- lines.push(this.contentLine('', inner));
248
- lines.push(this.contentLine(this.theme.fg('dim', ' [Esc] Back'), inner));
249
- lines.push(buildBottomBorder(width));
250
- return lines;
251
- }
252
-
253
- const readOnly = agent.readOnly ? 'yes' : 'no';
254
- const capabilities = agent.capabilities?.length ? agent.capabilities.join(', ') : 'none';
255
- const status = agent.status || 'idle';
256
-
257
- lines.push(this.fieldLine('Model', agent.model || 'default', inner));
258
- lines.push(this.fieldLine('Read-only', readOnly, inner));
259
- lines.push(this.fieldLine('Description', agent.description || 'No description', inner));
260
- lines.push(this.fieldLine('Capabilities', capabilities, inner));
261
- lines.push(this.fieldLine('Status', status, inner));
262
- lines.push(this.contentLine('', inner));
263
- lines.push(this.contentLine(this.theme.fg('dim', ' [r] Run agent [Esc] Back'), inner));
264
- lines.push(buildBottomBorder(width));
265
- return lines;
266
- }
267
-
268
- private fieldLine(label: string, value: string, innerWidth: number): string {
269
- const labelText = this.theme.fg('dim', ` ${label}:`);
270
- const content = `${labelText} ${this.theme.fg('text', value)}`;
271
- return this.contentLine(content, innerWidth);
272
- }
273
-
274
- private contentLine(content: string, innerWidth: number): string {
275
- return `│${padRight(content, innerWidth)}│`;
276
- }
277
-
278
- private getVisibleRange(windowSize?: number): [number, number] {
279
- const count = this.agents.length;
280
- const ws = windowSize ?? this.listWindowSize;
281
- if (count <= ws) return [0, count];
282
-
283
- const half = Math.floor(ws / 2);
284
- let start = Math.max(0, this.selectedIndex - half);
285
- let end = start + ws;
286
-
287
- if (end > count) {
288
- end = count;
289
- start = Math.max(0, end - ws);
290
- }
291
-
292
- return [start, end];
293
- }
294
- }