@warren-dean/code-kit 0.25.0 → 0.26.1
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +24 -0
- package/README.md +70 -59
- package/bin/code-kit.mjs +113 -3
- package/hooks/act.mjs +96 -0
- package/hooks/guard-bash.mjs +27 -1
- package/hooks/hooks.json +42 -1
- package/hooks/lib/config.mjs +26 -2
- package/hooks/lib/events.mjs +626 -0
- package/hooks/lib/harness.mjs +8 -0
- package/hooks/lib/instructions.mjs +1 -1
- package/hooks/lib/next.mjs +22 -0
- package/hooks/lib/plan.mjs +45 -9
- package/hooks/lib/publish.mjs +144 -0
- package/hooks/lib/queue.mjs +36 -0
- package/hooks/lib/snapshot.mjs +33 -3
- package/hooks/lib/storymap.mjs +54 -17
- package/hooks/lib/timeline.mjs +94 -44
- package/hooks/lib/worktrees.mjs +19 -11
- package/hooks/mod/art.mjs +0 -81
- package/hooks/mod/board.mjs +1743 -0
- package/hooks/mod/characters.mjs +516 -0
- package/hooks/mod/loop.mjs +17 -3
- package/hooks/mod/mission.mjs +2 -93
- package/hooks/mod/panes.mjs +111 -422
- package/hooks/mod/register.mjs +482 -184
- package/hooks/mod/surface/character.mjs +79 -0
- package/hooks/mod/surface/clock.mjs +37 -0
- package/hooks/mod/surface/rail.mjs +33 -0
- package/hooks/mod/view.mjs +30 -602
- package/hooks/session.mjs +14 -11
- package/package.json +2 -1
- package/skills/decide/SKILL.md +1 -1
- package/skills/dispatch/SKILL.md +1 -1
- package/skills/init/SKILL.md +1 -1
- package/skills/next/SKILL.md +1 -1
- package/skills/review/SKILL.md +1 -1
- package/templates/agent.md +1 -1
- package/templates/claude-md.md +2 -2
- package/hooks/mod/register.test.ts +0 -4932
package/hooks/mod/view.mjs
CHANGED
|
@@ -7,8 +7,6 @@ export const NOT_CODE_KIT = "This project doesn't use code-kit.";
|
|
|
7
7
|
const LEAD = 'lead';
|
|
8
8
|
|
|
9
9
|
/** A CLI run's stdout as JSON, or null when it printed none. */
|
|
10
|
-
import { BAR, POSE_GLYPH, rasterCells, runs, sprite, spriteSvg, timelineSvg } from './art.mjs';
|
|
11
|
-
import { missionLines, nextText } from './mission.mjs';
|
|
12
10
|
import { teamLines } from './teamview.mjs';
|
|
13
11
|
|
|
14
12
|
export function parseJson(stdout) {
|
|
@@ -22,6 +20,17 @@ export function parseJson(stdout) {
|
|
|
22
20
|
/** The agent statuses that mean an agent is at work in the session now. */
|
|
23
21
|
const AT_WORK = new Set(['pending', 'running', 'waiting']);
|
|
24
22
|
|
|
23
|
+
/** The agent statuses that mean an agent has ended: anything else may still act, idle included. */
|
|
24
|
+
const ENDED = new Set(['completed', 'failed', 'killed']);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The subagent types not yet ended, from `$.agent.list()`: an idle or waiting agent can still write,
|
|
28
|
+
* so its lane's claim stays (SCHED-1). A status Claude Code adds later counts as alive.
|
|
29
|
+
*/
|
|
30
|
+
export function agentsAlive(agents) {
|
|
31
|
+
return new Set((agents ?? []).filter((a) => !ENDED.has(a.status)).map((a) => a.type));
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
/** The subagent types at work, from `$.agent.list()`. */
|
|
26
35
|
export function agentsAtWork(agents) {
|
|
27
36
|
return new Set((agents ?? []).filter((a) => AT_WORK.has(a.status)).map((a) => a.type));
|
|
@@ -108,17 +117,6 @@ export function projectState(check, status, next = null, atWork = new Set()) {
|
|
|
108
117
|
};
|
|
109
118
|
}
|
|
110
119
|
|
|
111
|
-
export const STATE_COLOR = {
|
|
112
|
-
building: 'blue',
|
|
113
|
-
working: 'green',
|
|
114
|
-
orchestrating: 'yellow',
|
|
115
|
-
'in review': 'yellow',
|
|
116
|
-
'sent back': 'magenta',
|
|
117
|
-
'waiting on you': 'cyan',
|
|
118
|
-
blocked: 'red',
|
|
119
|
-
idle: undefined,
|
|
120
|
-
};
|
|
121
|
-
|
|
122
120
|
/**
|
|
123
121
|
* A lane's state as the pane shows it: `queued` while its branch waits in the merge queue (MQ-4), and
|
|
124
122
|
* `working` while its agent (or the lead, mid-turn) is at work on nothing the plan names.
|
|
@@ -135,378 +133,6 @@ export function shownState(lane, queue = []) {
|
|
|
135
133
|
return lane.branch && waiting ? 'queued' : lane.state;
|
|
136
134
|
}
|
|
137
135
|
|
|
138
|
-
/**
|
|
139
|
-
* The Lanes tab's body, drawn with the elements `$.ui.resolve(e)` returned; `usage` is
|
|
140
|
-
* usageSummary's, `plan` planOf's (USE-2), either null before there is any. `lanesOf` narrows and
|
|
141
|
-
* marks the rows (VIEW-1, VIEW-6): { filter, search, selected }, and `live` is each lane's last tool
|
|
142
|
-
* call (VIEW-4): { [lane]: { tool, ago, level } }, level null, 'quiet' or 'stalled'.
|
|
143
|
-
*/
|
|
144
|
-
export function lanesPane(
|
|
145
|
-
state,
|
|
146
|
-
els,
|
|
147
|
-
usage = null,
|
|
148
|
-
plan = null,
|
|
149
|
-
loop = null,
|
|
150
|
-
{
|
|
151
|
-
filter = null,
|
|
152
|
-
search = '',
|
|
153
|
-
selected = null,
|
|
154
|
-
live = {},
|
|
155
|
-
art = null,
|
|
156
|
-
combined = null,
|
|
157
|
-
detail = null,
|
|
158
|
-
} = {},
|
|
159
|
-
) {
|
|
160
|
-
const { Box, Text } = els;
|
|
161
|
-
const text = (value, style = {}) => Text({ ...style, children: [value] });
|
|
162
|
-
if (!state || state.kind === 'none') return text(NOT_CODE_KIT, { dimColor: true });
|
|
163
|
-
if (state.kind === 'invalid')
|
|
164
|
-
return text('The config is invalid: run code-kit check.', { color: 'red' });
|
|
165
|
-
const width = Math.max(...state.lanes.map((l) => l.name.length));
|
|
166
|
-
// VIEW-3: the lane's character: half-block cells in the terminal, SVG on Desktop, its glyph elsewhere.
|
|
167
|
-
const character = (l) => {
|
|
168
|
-
const pose = art.poses[l.name] ?? 'idle';
|
|
169
|
-
const lead = l.name === LEAD;
|
|
170
|
-
if (art.surface === 'terminal' && els.Raster)
|
|
171
|
-
return els.Raster({
|
|
172
|
-
key: `char-${l.name}`,
|
|
173
|
-
columns: 6,
|
|
174
|
-
rows: 3,
|
|
175
|
-
cells: rasterCells(sprite(pose, art.frame, art.tints[l.name], { lead })),
|
|
176
|
-
});
|
|
177
|
-
if (els.Svg)
|
|
178
|
-
return els.Svg({
|
|
179
|
-
source: spriteSvg(pose, art.tints[l.name], { lead }),
|
|
180
|
-
alt: `${l.name}: ${pose}`,
|
|
181
|
-
width: 24,
|
|
182
|
-
height: 24,
|
|
183
|
-
...(pose === 'working' ? { isInteractive: true } : {}),
|
|
184
|
-
});
|
|
185
|
-
return text(POSE_GLYPH[pose]);
|
|
186
|
-
};
|
|
187
|
-
// VIEW-2: the lane's story on the shared time axis.
|
|
188
|
-
const bar = (l) => {
|
|
189
|
-
const cells = art?.bars?.[l.name];
|
|
190
|
-
if (!cells) return [];
|
|
191
|
-
if (art.surface !== 'terminal' && els.Svg)
|
|
192
|
-
return [
|
|
193
|
-
els.Svg({
|
|
194
|
-
source: timelineSvg([{ cells }], { width: art.svgWidth ?? 480 }),
|
|
195
|
-
alt: `${l.name}'s timeline`,
|
|
196
|
-
}),
|
|
197
|
-
];
|
|
198
|
-
return [
|
|
199
|
-
Box({
|
|
200
|
-
key: `bar-${l.name}`,
|
|
201
|
-
flexDirection: 'row',
|
|
202
|
-
children: [
|
|
203
|
-
text(' '),
|
|
204
|
-
...runs(cells).map((run) =>
|
|
205
|
-
text(
|
|
206
|
-
BAR[run.kind].glyph.repeat(run.n),
|
|
207
|
-
BAR[run.kind].color ? { color: BAR[run.kind].color } : {},
|
|
208
|
-
),
|
|
209
|
-
),
|
|
210
|
-
],
|
|
211
|
-
}),
|
|
212
|
-
];
|
|
213
|
-
};
|
|
214
|
-
const inQueue = new Set(
|
|
215
|
-
(loop?.queue ?? [])
|
|
216
|
-
.filter((e) => ['waiting', 'merging'].includes(e.state))
|
|
217
|
-
.map((e) => e.branch),
|
|
218
|
-
);
|
|
219
|
-
// MQ-4: a branch in the merge queue is shown as queued, not as waiting for review.
|
|
220
|
-
const queued = (l) => Boolean(l.branch && inQueue.has(l.branch));
|
|
221
|
-
const needle = search.trim().toLowerCase();
|
|
222
|
-
const shown = state.lanes.filter(
|
|
223
|
-
(l) =>
|
|
224
|
-
(!filter || shownState(l, loop?.queue) === filter) &&
|
|
225
|
-
(!needle ||
|
|
226
|
-
[l.name, l.agent, l.story?.id, l.story?.title, l.branch]
|
|
227
|
-
.filter(Boolean)
|
|
228
|
-
.some((s) => s.toLowerCase().includes(needle))),
|
|
229
|
-
);
|
|
230
|
-
const LIVE = { quiet: 'yellow', stalled: 'red' };
|
|
231
|
-
// LANES-2: fixed columns that never wrap: name, state, then the story (and the agent's current tool
|
|
232
|
-
// beneath it), then tokens; another tool's facts only when they aren't zero.
|
|
233
|
-
const STATE_WIDTH = 13;
|
|
234
|
-
const rows = shown.map((l) => {
|
|
235
|
-
const s = shownState(l, loop?.queue);
|
|
236
|
-
const facts = combined?.[l.name];
|
|
237
|
-
const chips = [
|
|
238
|
-
...(facts?.without
|
|
239
|
-
? [text(`${facts.without} edited without understanding`, { color: 'red' })]
|
|
240
|
-
: []),
|
|
241
|
-
...(facts?.owed
|
|
242
|
-
? [text(`${facts.owed} card${facts.owed === 1 ? '' : 's'} owed`, { color: 'yellow' })]
|
|
243
|
-
: []),
|
|
244
|
-
...(loop?.laneNotes?.[l.name]
|
|
245
|
-
? [
|
|
246
|
-
text(loop.laneNotes[l.name], {
|
|
247
|
-
color: loop.laneNotes[l.name] === 'stalled' ? 'red' : 'yellow',
|
|
248
|
-
}),
|
|
249
|
-
]
|
|
250
|
-
: []),
|
|
251
|
-
];
|
|
252
|
-
const story = l.story
|
|
253
|
-
? `${l.story.id} ${l.story.title}${
|
|
254
|
-
l.story.state === 'blocked' && l.story.waitingOn?.length
|
|
255
|
-
? ` · waits on ${l.story.waitingOn.join(', ')}`
|
|
256
|
-
: l.branch
|
|
257
|
-
? ` · ${l.branch}`
|
|
258
|
-
: ''
|
|
259
|
-
}${l.story.slice ? ` · slice ${l.story.slice}` : ''}`
|
|
260
|
-
: l.name === LEAD
|
|
261
|
-
? 'the main session'
|
|
262
|
-
: (l.agent ?? '');
|
|
263
|
-
const lines = [
|
|
264
|
-
Box({
|
|
265
|
-
flexDirection: 'row',
|
|
266
|
-
columnGap: 1,
|
|
267
|
-
children: [
|
|
268
|
-
text(l.name === selected ? '›' : l.active ? '●' : ' ', {
|
|
269
|
-
color: l.name === selected ? 'cyan' : 'green',
|
|
270
|
-
}),
|
|
271
|
-
text(l.name.padEnd(width), {
|
|
272
|
-
bold: true,
|
|
273
|
-
...(l.name === selected ? { color: 'cyan' } : {}),
|
|
274
|
-
}),
|
|
275
|
-
text(
|
|
276
|
-
s.padEnd(STATE_WIDTH),
|
|
277
|
-
s === 'queued'
|
|
278
|
-
? { color: 'cyan' }
|
|
279
|
-
: STATE_COLOR[s]
|
|
280
|
-
? { color: STATE_COLOR[s] }
|
|
281
|
-
: { dimColor: true },
|
|
282
|
-
),
|
|
283
|
-
Box({
|
|
284
|
-
flexGrow: 1,
|
|
285
|
-
flexShrink: 1,
|
|
286
|
-
children: [text(story, { wrap: 'truncate-end', dimColor: !l.story })],
|
|
287
|
-
}),
|
|
288
|
-
...chips,
|
|
289
|
-
...(usage?.lanes[l.name]
|
|
290
|
-
? [text(tokens(usage.lanes[l.name]).padStart(6), { dimColor: true })]
|
|
291
|
-
: []),
|
|
292
|
-
],
|
|
293
|
-
}),
|
|
294
|
-
// VIEW-4: what its agent is doing now, and since when, beneath the story.
|
|
295
|
-
...(live[l.name]
|
|
296
|
-
? [
|
|
297
|
-
Box({
|
|
298
|
-
flexDirection: 'row',
|
|
299
|
-
columnGap: 1,
|
|
300
|
-
children: [
|
|
301
|
-
text(''.padEnd(width + STATE_WIDTH + 3)),
|
|
302
|
-
text(`${live[l.name].tool} · ${live[l.name].ago}`, {
|
|
303
|
-
wrap: 'truncate-end',
|
|
304
|
-
...(LIVE[live[l.name].level]
|
|
305
|
-
? { color: LIVE[live[l.name].level] }
|
|
306
|
-
: { dimColor: true }),
|
|
307
|
-
}),
|
|
308
|
-
],
|
|
309
|
-
}),
|
|
310
|
-
]
|
|
311
|
-
: []),
|
|
312
|
-
...bar(l),
|
|
313
|
-
// LANES-3: the selected lane's stories as cards, then what it owns.
|
|
314
|
-
...(l.name === selected && detail ? laneDetail(detail, els, width) : []),
|
|
315
|
-
];
|
|
316
|
-
return art
|
|
317
|
-
? Box({
|
|
318
|
-
key: `lane-${l.name}`,
|
|
319
|
-
flexDirection: 'row',
|
|
320
|
-
columnGap: 1,
|
|
321
|
-
children: [character(l), Box({ flexDirection: 'column', flexGrow: 1, children: lines })],
|
|
322
|
-
})
|
|
323
|
-
: Box({ key: `lane-${l.name}`, flexDirection: 'column', children: lines });
|
|
324
|
-
});
|
|
325
|
-
const notes = [];
|
|
326
|
-
if (state.planGaps)
|
|
327
|
-
notes.push(
|
|
328
|
-
text(`The plan has ${state.planGaps} gap(s): run code-kit status.`, { color: 'yellow' }),
|
|
329
|
-
);
|
|
330
|
-
const ready = state.ready.length
|
|
331
|
-
? [
|
|
332
|
-
text('Ready', { bold: true }),
|
|
333
|
-
...state.ready.map((r) =>
|
|
334
|
-
Box({
|
|
335
|
-
key: `ready-${r.id}`,
|
|
336
|
-
flexDirection: 'row',
|
|
337
|
-
columnGap: 2,
|
|
338
|
-
children: [
|
|
339
|
-
text(r.id),
|
|
340
|
-
text(r.title, { wrap: 'truncate-end' }),
|
|
341
|
-
text(r.lane === LEAD ? "the lead's own" : (r.lane ?? ''), { dimColor: true }),
|
|
342
|
-
],
|
|
343
|
-
}),
|
|
344
|
-
),
|
|
345
|
-
]
|
|
346
|
-
: [text('Nothing is ready to start.', { dimColor: true })];
|
|
347
|
-
return Box({
|
|
348
|
-
flexDirection: 'column',
|
|
349
|
-
rowGap: 1,
|
|
350
|
-
children: [
|
|
351
|
-
...loopCard(loop, els),
|
|
352
|
-
...notes,
|
|
353
|
-
Box({
|
|
354
|
-
flexDirection: 'column',
|
|
355
|
-
children: rows.length ? rows : [text('No lane matches the filter.', { dimColor: true })],
|
|
356
|
-
}),
|
|
357
|
-
Box({ flexDirection: 'column', children: ready }),
|
|
358
|
-
...reviewsSection(loop, text, Box),
|
|
359
|
-
],
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
const CARD_STATE = {
|
|
364
|
-
done: { label: 'merged', color: 'gray' },
|
|
365
|
-
review: { label: 'in review', color: 'yellow' },
|
|
366
|
-
'in progress': { label: 'building', color: 'blue' },
|
|
367
|
-
'sent back': { label: 'sent back', color: 'magenta' },
|
|
368
|
-
'waiting on you': { label: 'waiting on you', color: 'cyan' },
|
|
369
|
-
blocked: { label: 'blocked', color: 'red' },
|
|
370
|
-
ready: { label: 'ready', color: 'green' },
|
|
371
|
-
todo: { label: 'to do', color: 'gray' },
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* LANES-3: a lane's stories as cards (id and state, title, requirements, and what it waits on or its
|
|
376
|
-
* branch), wrapping across the pane, then its agent and the paths it owns. `detail` is { agent, owns,
|
|
377
|
-
* stories }.
|
|
378
|
-
*/
|
|
379
|
-
export function laneDetail(detail, { Box, Text }, indent = 0) {
|
|
380
|
-
const text = (value, style = {}) => Text({ ...style, children: [value] });
|
|
381
|
-
const cards = detail.stories.map((s) => {
|
|
382
|
-
const st = CARD_STATE[s.state] ?? { label: s.state, color: 'gray' };
|
|
383
|
-
return Box({
|
|
384
|
-
key: `card-${s.id}`,
|
|
385
|
-
flexDirection: 'column',
|
|
386
|
-
borderStyle: 'round',
|
|
387
|
-
borderColor: st.color,
|
|
388
|
-
...(s.state === 'done' ? { borderDimColor: true } : {}),
|
|
389
|
-
paddingX: 1,
|
|
390
|
-
width: 30,
|
|
391
|
-
children: [
|
|
392
|
-
Box({
|
|
393
|
-
flexDirection: 'row',
|
|
394
|
-
justifyContent: 'space-between',
|
|
395
|
-
children: [
|
|
396
|
-
text(s.id, { bold: true, dimColor: s.state === 'done' }),
|
|
397
|
-
text(st.label, { color: st.color }),
|
|
398
|
-
],
|
|
399
|
-
}),
|
|
400
|
-
text(s.title, { wrap: 'truncate-end', dimColor: s.state === 'done' }),
|
|
401
|
-
...(s.requirements?.length
|
|
402
|
-
? [text(s.requirements.join(' '), { dimColor: true, wrap: 'truncate-end' })]
|
|
403
|
-
: []),
|
|
404
|
-
...(s.state === 'blocked' && s.waitingOn?.length
|
|
405
|
-
? [text(`waits on ${s.waitingOn.join(', ')}`, { color: 'red', wrap: 'truncate-end' })]
|
|
406
|
-
: s.branch && s.state !== 'done'
|
|
407
|
-
? [text(s.branch, { dimColor: true, wrap: 'truncate-end' })]
|
|
408
|
-
: []),
|
|
409
|
-
],
|
|
410
|
-
});
|
|
411
|
-
});
|
|
412
|
-
return [
|
|
413
|
-
Box({
|
|
414
|
-
key: 'lane-cards',
|
|
415
|
-
flexDirection: 'row',
|
|
416
|
-
flexWrap: 'wrap',
|
|
417
|
-
columnGap: 1,
|
|
418
|
-
marginLeft: Math.min(indent + 2, 8),
|
|
419
|
-
children: cards.length
|
|
420
|
-
? cards
|
|
421
|
-
: [text('No stories in the plan for this lane.', { dimColor: true })],
|
|
422
|
-
}),
|
|
423
|
-
Box({
|
|
424
|
-
key: 'lane-owns',
|
|
425
|
-
flexDirection: 'row',
|
|
426
|
-
flexWrap: 'wrap',
|
|
427
|
-
columnGap: 2,
|
|
428
|
-
marginLeft: Math.min(indent + 2, 8),
|
|
429
|
-
children: [
|
|
430
|
-
...(detail.agent ? [text('agent', { dimColor: true }), text(detail.agent)] : []),
|
|
431
|
-
text('owns', { dimColor: true }),
|
|
432
|
-
...(detail.owns.length
|
|
433
|
-
? detail.owns.map((p) => text(p, { color: 'cyan' }))
|
|
434
|
-
: [text('nothing yet', { dimColor: true })]),
|
|
435
|
-
],
|
|
436
|
-
}),
|
|
437
|
-
];
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* LANES-1: the loop as a card at the top of the Lanes tab: its mode, then the steps it took, the one
|
|
442
|
-
* running and the one it takes next. None while the loop is off and has taken no step.
|
|
443
|
-
*/
|
|
444
|
-
export function loopCard(loop, { Box, Text }) {
|
|
445
|
-
if (!loop || (loop.state === 'off' && !loop.steps?.length)) return [];
|
|
446
|
-
const text = (value, style = {}) => Text({ ...style, children: [value] });
|
|
447
|
-
const mode =
|
|
448
|
-
loop.state === 'paused'
|
|
449
|
-
? { word: 'paused', color: 'yellow' }
|
|
450
|
-
: loop.state === 'off'
|
|
451
|
-
? { word: 'off', color: 'gray' }
|
|
452
|
-
: loop.state === 'done' || loop.state === 'stopped'
|
|
453
|
-
? { word: 'milestone done', color: 'green' }
|
|
454
|
-
: {
|
|
455
|
-
word:
|
|
456
|
-
loop.autonomy === 'propose'
|
|
457
|
-
? 'asks before each step'
|
|
458
|
-
: 'acts while the lead is idle',
|
|
459
|
-
color: 'green',
|
|
460
|
-
};
|
|
461
|
-
// The step running now has its own chip; the ones before it are what the loop did.
|
|
462
|
-
const steps = [...(loop.steps ?? [])].slice(0, loop.current ? -1 : undefined).slice(-4);
|
|
463
|
-
const chip = (key, value, color, extra = {}) =>
|
|
464
|
-
Box({
|
|
465
|
-
key,
|
|
466
|
-
borderStyle: 'single',
|
|
467
|
-
borderColor: color,
|
|
468
|
-
paddingX: 1,
|
|
469
|
-
children: [text(value, { wrap: 'truncate-end', ...extra })],
|
|
470
|
-
});
|
|
471
|
-
return [
|
|
472
|
-
Box({
|
|
473
|
-
key: 'loop-card',
|
|
474
|
-
flexDirection: 'column',
|
|
475
|
-
borderStyle: 'round',
|
|
476
|
-
borderColor: 'gray',
|
|
477
|
-
paddingX: 1,
|
|
478
|
-
children: [
|
|
479
|
-
Box({
|
|
480
|
-
flexDirection: 'row',
|
|
481
|
-
columnGap: 2,
|
|
482
|
-
children: [
|
|
483
|
-
text('loop', { bold: true, color: 'yellow' }),
|
|
484
|
-
text(mode.word, { color: mode.color }),
|
|
485
|
-
],
|
|
486
|
-
}),
|
|
487
|
-
Box({
|
|
488
|
-
flexDirection: 'row',
|
|
489
|
-
flexWrap: 'wrap',
|
|
490
|
-
columnGap: 1,
|
|
491
|
-
children: [
|
|
492
|
-
...steps.map((s, i) =>
|
|
493
|
-
chip(
|
|
494
|
-
`loop-step-${i}`,
|
|
495
|
-
`${ago(loop.now - s.at).replace(' ago', '')} ${s.kind} ${s.target}`,
|
|
496
|
-
'gray',
|
|
497
|
-
{ dimColor: true },
|
|
498
|
-
),
|
|
499
|
-
),
|
|
500
|
-
...(loop.nextText
|
|
501
|
-
? [chip('loop-next', `next: ${loop.nextText}`, 'cyan', { color: 'cyan' })]
|
|
502
|
-
: []),
|
|
503
|
-
],
|
|
504
|
-
}),
|
|
505
|
-
],
|
|
506
|
-
}),
|
|
507
|
-
];
|
|
508
|
-
}
|
|
509
|
-
|
|
510
136
|
/** How long ago, as a person reads it: now, 40s ago, 12m ago, 2h ago. */
|
|
511
137
|
export function ago(ms) {
|
|
512
138
|
const s = Math.max(0, Math.round(ms / 1000));
|
|
@@ -516,75 +142,6 @@ export function ago(ms) {
|
|
|
516
142
|
return `${Math.floor(s / 3600)}h ago`;
|
|
517
143
|
}
|
|
518
144
|
|
|
519
|
-
/** MQ-4: the merge queue in order, then what it merged or sent back lately. */
|
|
520
|
-
export function queueSection(loop, text, Box) {
|
|
521
|
-
const entries = loop?.queue ?? [];
|
|
522
|
-
if (!entries.length) return [];
|
|
523
|
-
const open = entries.filter((e) => ['waiting', 'merging'].includes(e.state));
|
|
524
|
-
const settled = entries
|
|
525
|
-
.filter((e) => !['waiting', 'merging'].includes(e.state))
|
|
526
|
-
.slice(-3)
|
|
527
|
-
.reverse();
|
|
528
|
-
const row = (e, label, style = {}) =>
|
|
529
|
-
Box({
|
|
530
|
-
key: `queue-${e.branch}-${e.state}`,
|
|
531
|
-
flexDirection: 'row',
|
|
532
|
-
columnGap: 2,
|
|
533
|
-
children: [
|
|
534
|
-
text(label.padEnd(3), { dimColor: true }),
|
|
535
|
-
text(e.branch),
|
|
536
|
-
text(e.state, style),
|
|
537
|
-
...(e.reason ? [text(e.reason, { dimColor: true })] : []),
|
|
538
|
-
],
|
|
539
|
-
});
|
|
540
|
-
return [
|
|
541
|
-
Box({
|
|
542
|
-
flexDirection: 'column',
|
|
543
|
-
children: [
|
|
544
|
-
text('Merge queue', { bold: true }),
|
|
545
|
-
...open.map((e, i) => row(e, `${i + 1}.`, { color: 'cyan' })),
|
|
546
|
-
...settled.map((e) => row(e, '·', { color: e.state === 'merged' ? 'green' : 'magenta' })),
|
|
547
|
-
],
|
|
548
|
-
}),
|
|
549
|
-
];
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/** REVW-1: each branch's background review, running with its clock, or what it found. */
|
|
553
|
-
export function reviewsSection(loop, text, Box) {
|
|
554
|
-
const reviews = loop?.reviews ?? [];
|
|
555
|
-
if (!reviews.length) return [];
|
|
556
|
-
const said = (r) =>
|
|
557
|
-
r.state === 'running'
|
|
558
|
-
? `running ${ago(loop.now - r.startedAt).replace(' ago', '')}`
|
|
559
|
-
: r.state === 'done'
|
|
560
|
-
? `done · ${r.summary}`
|
|
561
|
-
: r.state === 'skipped'
|
|
562
|
-
? `skipped: ${r.why}`
|
|
563
|
-
: `failed: ${r.error}`;
|
|
564
|
-
return [
|
|
565
|
-
Box({
|
|
566
|
-
flexDirection: 'column',
|
|
567
|
-
children: [
|
|
568
|
-
text('Reviews', { bold: true }),
|
|
569
|
-
...reviews.map((r) =>
|
|
570
|
-
Box({
|
|
571
|
-
key: `review-${r.branch}`,
|
|
572
|
-
flexDirection: 'row',
|
|
573
|
-
columnGap: 2,
|
|
574
|
-
children: [
|
|
575
|
-
text(r.branch),
|
|
576
|
-
text(said(r), {
|
|
577
|
-
color: r.blockers ? 'red' : r.state === 'running' ? 'blue' : undefined,
|
|
578
|
-
dimColor: r.state === 'skipped',
|
|
579
|
-
}),
|
|
580
|
-
],
|
|
581
|
-
}),
|
|
582
|
-
),
|
|
583
|
-
],
|
|
584
|
-
}),
|
|
585
|
-
];
|
|
586
|
-
}
|
|
587
|
-
|
|
588
145
|
/** USE-2: the plan's 5-hour use as a bar, each story's tokens, and the background agents' share. */
|
|
589
146
|
export function usageSection(usage, plan, text, Box) {
|
|
590
147
|
const lines = [];
|
|
@@ -597,7 +154,7 @@ export function usageSection(usage, plan, text, Box) {
|
|
|
597
154
|
children: [
|
|
598
155
|
text('Plan'),
|
|
599
156
|
text(planBar(plan.percent), { color: plan.paused ? 'red' : 'green' }),
|
|
600
|
-
text(`${plan.percent}% of the 5-hour window`, { dimColor: true }),
|
|
157
|
+
text(`${plan.percent}% of the 5-hour window`, { dimColor: true, wrap: 'wrap' }),
|
|
601
158
|
...(plan.paused ? [text('background agents paused', { color: 'red' })] : []),
|
|
602
159
|
],
|
|
603
160
|
}),
|
|
@@ -619,14 +176,24 @@ export function usageSection(usage, plan, text, Box) {
|
|
|
619
176
|
],
|
|
620
177
|
}),
|
|
621
178
|
);
|
|
179
|
+
// USE-1: each lane's share, the lead's own requests its own.
|
|
180
|
+
const lanes = Object.entries(usage.lanes ?? {}).filter(([, n]) => n > 0);
|
|
181
|
+
if (lanes.length)
|
|
182
|
+
lines.push(
|
|
183
|
+
text(`Lanes ${lanes.map(([lane, n]) => `${lane} ${tokens(n)}`).join(' · ')}`, {
|
|
184
|
+
dimColor: true,
|
|
185
|
+
}),
|
|
186
|
+
);
|
|
622
187
|
if (usage.background)
|
|
623
188
|
lines.push(
|
|
624
189
|
text(
|
|
625
190
|
`Background agents ${tokens(usage.background)} (${Math.round((usage.background / usage.total) * 100)}%)`,
|
|
626
|
-
{ dimColor: true },
|
|
191
|
+
{ dimColor: true, wrap: 'wrap' },
|
|
627
192
|
),
|
|
628
193
|
);
|
|
629
|
-
lines.push(
|
|
194
|
+
lines.push(
|
|
195
|
+
text(`This session ${tokens(usage.total)} tokens`, { dimColor: true, wrap: 'wrap' }),
|
|
196
|
+
);
|
|
630
197
|
}
|
|
631
198
|
return lines.length
|
|
632
199
|
? [Box({ flexDirection: 'column', children: [text('Usage', { bold: true }), ...lines] })]
|
|
@@ -734,11 +301,10 @@ export function bandLines({
|
|
|
734
301
|
task = null,
|
|
735
302
|
elsewhere = [],
|
|
736
303
|
}) {
|
|
304
|
+
// SESS-3: a working session's lines are only its own: no queue, reviews or team. The build's own
|
|
305
|
+
// progress, the loop's state and the agents at work are the Build panel's and the band's one line
|
|
306
|
+
// (spec 27, UI-2 and UI-9), not lines here.
|
|
737
307
|
const lines = [];
|
|
738
|
-
// MISSION-1: the goal, now, next and the agents at work, above what needs the person. SESS-3: a working
|
|
739
|
-
// session's band holds only its own: no mission, queue, reviews or team.
|
|
740
|
-
const mission = working ? [] : missionLines({ state, loop, leadBusy, live, nextStep, combined });
|
|
741
|
-
lines.push(...mission);
|
|
742
308
|
// SESS-4: a working session's task, or that it records one before changing code.
|
|
743
309
|
if (working)
|
|
744
310
|
lines.push({
|
|
@@ -923,17 +489,14 @@ export function bandLines({
|
|
|
923
489
|
worktrees,
|
|
924
490
|
actions: [{ id: 'openDecision', label: 'Look…' }],
|
|
925
491
|
});
|
|
926
|
-
// LOOP-7: the milestone is done;
|
|
492
|
+
// LOOP-7: the milestone is done; SESS-2: where the loop is led from, when it isn't this session.
|
|
927
493
|
if (loop?.state === 'done')
|
|
928
494
|
lines.push({
|
|
929
495
|
kind: 'done',
|
|
930
496
|
text: `Milestone done: ${plural(loop.doneCount, 'story', 'stories')} merged`,
|
|
931
497
|
actions: [{ id: 'dismissDone', label: 'Dismiss' }],
|
|
932
498
|
});
|
|
933
|
-
|
|
934
|
-
else if (mission.length) {
|
|
935
|
-
// nothing more
|
|
936
|
-
} else if (loop?.state === 'elsewhere' || loop?.state === 'unled')
|
|
499
|
+
else if (loop?.state === 'elsewhere' || loop?.state === 'unled')
|
|
937
500
|
// SESS-2: another session leads the project, or none does; this one never prompts its lead.
|
|
938
501
|
lines.push({
|
|
939
502
|
kind: 'loop',
|
|
@@ -943,14 +506,6 @@ export function bandLines({
|
|
|
943
506
|
: 'no session leads the project: the loop waits for one',
|
|
944
507
|
actions: [{ id: 'leadHere', label: 'Lead from here' }],
|
|
945
508
|
});
|
|
946
|
-
else if (loop?.state === 'paused')
|
|
947
|
-
lines.push({ kind: 'loop', text: 'loop paused', actions: [{ id: 'resume', label: 'Resume' }] });
|
|
948
|
-
else if (loop?.state === 'running' && loop.started)
|
|
949
|
-
lines.push({
|
|
950
|
-
kind: 'loop',
|
|
951
|
-
text: `loop on${loop.last ? ` · last: ${loop.last}` : ''}`,
|
|
952
|
-
actions: [{ id: 'pause', label: 'Pause' }],
|
|
953
|
-
});
|
|
954
509
|
// OWN-1: another session's decisions are answered there: here, only how many.
|
|
955
510
|
for (const e of elsewhere)
|
|
956
511
|
lines.push({
|
|
@@ -1008,134 +563,6 @@ export function waitingOf(waiting) {
|
|
|
1008
563
|
return null;
|
|
1009
564
|
}
|
|
1010
565
|
|
|
1011
|
-
/** The band, drawn with the elements `$.ui.resolve(e)` returned; `onAction(id, line)` acts. */
|
|
1012
|
-
export function band(lines, { Box, Text, Button }, onAction) {
|
|
1013
|
-
const COLOR = {
|
|
1014
|
-
notice: 'red',
|
|
1015
|
-
held: 'yellow',
|
|
1016
|
-
queue: 'blue',
|
|
1017
|
-
stalled: 'red',
|
|
1018
|
-
proposal: 'cyan',
|
|
1019
|
-
waiting: 'cyan',
|
|
1020
|
-
designing: 'blue',
|
|
1021
|
-
loop: 'green',
|
|
1022
|
-
done: 'green',
|
|
1023
|
-
approvals: 'yellow',
|
|
1024
|
-
review: 'blue',
|
|
1025
|
-
finish: 'red',
|
|
1026
|
-
usage: 'yellow',
|
|
1027
|
-
paused: 'yellow',
|
|
1028
|
-
facts: 'yellow',
|
|
1029
|
-
question: 'cyan',
|
|
1030
|
-
brief: 'cyan',
|
|
1031
|
-
report: 'magenta',
|
|
1032
|
-
stuck: 'yellow',
|
|
1033
|
-
};
|
|
1034
|
-
const LIVE = { quiet: 'yellow', stalled: 'red' };
|
|
1035
|
-
const LABEL = 8;
|
|
1036
|
-
// Two lines can share a kind or an action (two drift findings, each with Team): the second and later
|
|
1037
|
-
// get a number, so every row and button keeps its own key.
|
|
1038
|
-
const counter = () => {
|
|
1039
|
-
const seen = new Map();
|
|
1040
|
-
return (key) => {
|
|
1041
|
-
const n = (seen.get(key) ?? 0) + 1;
|
|
1042
|
-
seen.set(key, n);
|
|
1043
|
-
return n === 1 ? key : `${key}-${n}`;
|
|
1044
|
-
};
|
|
1045
|
-
};
|
|
1046
|
-
const uniqueButton = counter();
|
|
1047
|
-
const uniqueRow = counter();
|
|
1048
|
-
const buttons = (line) =>
|
|
1049
|
-
line.actions.map((a) =>
|
|
1050
|
-
Button({
|
|
1051
|
-
key: uniqueButton(`band-${a.id}`),
|
|
1052
|
-
label: a.hotkey ? `${a.hotkey} ${a.label}` : a.label,
|
|
1053
|
-
hotkey: a.hotkey,
|
|
1054
|
-
onPress: () => onAction(a.id, line),
|
|
1055
|
-
}),
|
|
1056
|
-
);
|
|
1057
|
-
// MISSION-2: what waits on the person is labelled "you", once, above its first line.
|
|
1058
|
-
let saidYou = false;
|
|
1059
|
-
const rows = lines.map((line) => {
|
|
1060
|
-
if (line.kind === 'agents')
|
|
1061
|
-
return Box({
|
|
1062
|
-
key: 'band-agents',
|
|
1063
|
-
flexDirection: 'column',
|
|
1064
|
-
children: [
|
|
1065
|
-
...line.agents.map((a) =>
|
|
1066
|
-
Box({
|
|
1067
|
-
key: `band-agent-${a.lane}`,
|
|
1068
|
-
flexDirection: 'row',
|
|
1069
|
-
columnGap: 1,
|
|
1070
|
-
children: [
|
|
1071
|
-
Text({
|
|
1072
|
-
dimColor: true,
|
|
1073
|
-
children: [(a === line.agents[0] ? line.label : '').padEnd(LABEL)],
|
|
1074
|
-
}),
|
|
1075
|
-
Text({ color: a.level ? LIVE[a.level] : 'green', children: ['●'] }),
|
|
1076
|
-
Text({ bold: true, children: [a.lane.padEnd(8)] }),
|
|
1077
|
-
Text({ wrap: 'truncate-end', children: [a.tool] }),
|
|
1078
|
-
Text({ dimColor: true, children: [a.ago] }),
|
|
1079
|
-
],
|
|
1080
|
-
}),
|
|
1081
|
-
),
|
|
1082
|
-
...(line.more
|
|
1083
|
-
? [Text({ dimColor: true, children: [`${''.padEnd(LABEL)} and ${line.more} more`] })]
|
|
1084
|
-
: []),
|
|
1085
|
-
],
|
|
1086
|
-
});
|
|
1087
|
-
// DECIDE-3: what needs the person is labelled "you", once; notes (usage, the plan's pause) are "note".
|
|
1088
|
-
const note = NOTE_KINDS.has(line.kind);
|
|
1089
|
-
const label = line.mission ? line.label : note ? 'note' : saidYou ? '' : 'you';
|
|
1090
|
-
if (!line.mission && !note) saidYou = true;
|
|
1091
|
-
return Box({
|
|
1092
|
-
key: uniqueRow(`band-${line.kind}`),
|
|
1093
|
-
flexDirection: 'row',
|
|
1094
|
-
columnGap: 1,
|
|
1095
|
-
children: [
|
|
1096
|
-
Text({
|
|
1097
|
-
...(line.mission ? { dimColor: true } : { color: COLOR[line.kind] ?? 'yellow' }),
|
|
1098
|
-
children: [label.padEnd(LABEL)],
|
|
1099
|
-
}),
|
|
1100
|
-
Text({
|
|
1101
|
-
wrap: 'truncate-end',
|
|
1102
|
-
...(line.kind === 'facts' ? { color: COLOR.facts } : {}),
|
|
1103
|
-
children: [line.text],
|
|
1104
|
-
}),
|
|
1105
|
-
// DECIDE-2: which story it's for, so it isn't a fragment.
|
|
1106
|
-
...(line.context
|
|
1107
|
-
? [Text({ dimColor: true, wrap: 'truncate-end', children: [line.context] })]
|
|
1108
|
-
: []),
|
|
1109
|
-
...buttons(line),
|
|
1110
|
-
],
|
|
1111
|
-
});
|
|
1112
|
-
});
|
|
1113
|
-
// DECIDE-3: one key opens the decisions as cards, each with its lineage and what each choice does.
|
|
1114
|
-
const first = lines.find((l) => !l.mission && !NOTE_KINDS.has(l.kind));
|
|
1115
|
-
if (first)
|
|
1116
|
-
rows.push(
|
|
1117
|
-
Box({
|
|
1118
|
-
key: 'band-why',
|
|
1119
|
-
flexDirection: 'row',
|
|
1120
|
-
columnGap: 1,
|
|
1121
|
-
children: [
|
|
1122
|
-
Text({ children: [''.padEnd(LABEL)] }),
|
|
1123
|
-
Button({
|
|
1124
|
-
key: 'band-decide',
|
|
1125
|
-
label: 'Why, and what each choice does',
|
|
1126
|
-
hotkey: 'd',
|
|
1127
|
-
plain: true,
|
|
1128
|
-
onPress: () => onAction('decide', first),
|
|
1129
|
-
}),
|
|
1130
|
-
],
|
|
1131
|
-
}),
|
|
1132
|
-
);
|
|
1133
|
-
return Box({ flexDirection: 'column', children: rows });
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
/** Band lines that inform rather than ask: they never need the person's answer. */
|
|
1137
|
-
const NOTE_KINDS = new Set(['usage', 'paused', 'finish', 'done', 'teamDown']);
|
|
1138
|
-
|
|
1139
566
|
/** The Approve… confirmation (ACT-1): what it grants, to whom, for how long, and the reason. */
|
|
1140
567
|
export function approvePane(
|
|
1141
568
|
approving,
|
|
@@ -1536,6 +963,7 @@ const CHOICES = {
|
|
|
1536
963
|
'agents.reviewer.model': ['', 'haiku', 'sonnet', 'opus'],
|
|
1537
964
|
'agents.lanes.model': ['', 'story', 'haiku', 'sonnet', 'opus'],
|
|
1538
965
|
'compact.milestone': ['ask', 'auto', 'off'],
|
|
966
|
+
motion: ['while-active', 'off'],
|
|
1539
967
|
};
|
|
1540
968
|
const shown = (v) =>
|
|
1541
969
|
v === null || v === ''
|