@warren-dean/code-kit 0.25.0 → 0.26.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +16 -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 +17 -2
- package/hooks/lib/publish.mjs +144 -0
- package/hooks/lib/queue.mjs +36 -0
- package/hooks/lib/snapshot.mjs +33 -3
- 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 +473 -182
- 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
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
// The lane agents' characters, redrawn (docs/specs/27-the-mod-redesigned.md, UI-11): 12 by 12
|
|
2
|
+
// pixels, each lane its own shape as well as its tint so lanes read apart without colour, the lead's
|
|
3
|
+
// crowned. A pose is the agent's state or the kind of work it's doing; a move is a one-off at an
|
|
4
|
+
// event. Every frame is composed from layers (a head by shape, a face, a body, a prop), so each
|
|
5
|
+
// shape gets every pose. Pure: the mod draws the grids as half-block cells or SVG.
|
|
6
|
+
|
|
7
|
+
const SIZE = 12;
|
|
8
|
+
|
|
9
|
+
/** Each head, rows 0 to 6: H the tint, D its shade, K gold, P grey metal. */
|
|
10
|
+
const HEADS = {
|
|
11
|
+
crown: [
|
|
12
|
+
'...K.KK.K...',
|
|
13
|
+
'...KKKKKK...',
|
|
14
|
+
'....HHHH....',
|
|
15
|
+
'...HHHHHH...',
|
|
16
|
+
'...HHHHHH...',
|
|
17
|
+
'...HHHHHH...',
|
|
18
|
+
'....HHHH....',
|
|
19
|
+
],
|
|
20
|
+
antenna: [
|
|
21
|
+
'......K.....',
|
|
22
|
+
'......D.....',
|
|
23
|
+
'...HHHHHH...',
|
|
24
|
+
'...HHHHHH...',
|
|
25
|
+
'...HHHHHH...',
|
|
26
|
+
'...HHHHHH...',
|
|
27
|
+
'...HHHHHH...',
|
|
28
|
+
],
|
|
29
|
+
cat: [
|
|
30
|
+
'............',
|
|
31
|
+
'...D....D...',
|
|
32
|
+
'...HD..DH...',
|
|
33
|
+
'...HHHHHH...',
|
|
34
|
+
'...HHHHHH...',
|
|
35
|
+
'...HHHHHH...',
|
|
36
|
+
'....HHHH....',
|
|
37
|
+
],
|
|
38
|
+
cap: [
|
|
39
|
+
'............',
|
|
40
|
+
'...DDDDDD...',
|
|
41
|
+
'...DDDDDDDD.',
|
|
42
|
+
'...HHHHHH...',
|
|
43
|
+
'...HHHHHH...',
|
|
44
|
+
'...HHHHHH...',
|
|
45
|
+
'....HHHH....',
|
|
46
|
+
],
|
|
47
|
+
bunny: [
|
|
48
|
+
'....D..D....',
|
|
49
|
+
'....D..D....',
|
|
50
|
+
'....HHHH....',
|
|
51
|
+
'...HHHHHH...',
|
|
52
|
+
'...HHHHHH...',
|
|
53
|
+
'...HHHHHH...',
|
|
54
|
+
'....HHHH....',
|
|
55
|
+
],
|
|
56
|
+
bolts: [
|
|
57
|
+
'............',
|
|
58
|
+
'............',
|
|
59
|
+
'...HHHHHH...',
|
|
60
|
+
'..DHHHHHHD..',
|
|
61
|
+
'..DHHHHHHD..',
|
|
62
|
+
'...HHHHHH...',
|
|
63
|
+
'...DDDDDD...',
|
|
64
|
+
],
|
|
65
|
+
wizard: [
|
|
66
|
+
'.....DD.....',
|
|
67
|
+
'....DDDD....',
|
|
68
|
+
'..DDDDDDDD..',
|
|
69
|
+
'...HHHHHH...',
|
|
70
|
+
'...HHHHHH...',
|
|
71
|
+
'...HHHHHH...',
|
|
72
|
+
'....HHHH....',
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
/** The lanes' shapes, tints and marks: six shapes first, then a mark on each, so lanes differ without colour. */
|
|
76
|
+
const SHAPES = ['antenna', 'cat', 'cap', 'bunny', 'bolts', 'wizard'];
|
|
77
|
+
const MARKS = [null, 'glasses', 'scarf', 'belt'];
|
|
78
|
+
const TINTS = [0x4aa3ff, 0x5cc85c, 0xd070e0, 0x40c8c8, 0xff9a40, 0xff6070];
|
|
79
|
+
const LEAD_TINT = 0xd8a840;
|
|
80
|
+
|
|
81
|
+
/** A name's own number (FNV-1a), so a lane's look comes from its name, not its place. */
|
|
82
|
+
function hashOf(name) {
|
|
83
|
+
let h = 0x811c9dc5;
|
|
84
|
+
for (const ch of String(name)) {
|
|
85
|
+
h ^= ch.codePointAt(0);
|
|
86
|
+
h = Math.imul(h, 0x01000193) >>> 0;
|
|
87
|
+
}
|
|
88
|
+
return h;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Every lane's character (UI-11), for whatever lanes the project's config has: each look (a shape,
|
|
93
|
+
* then a mark) chosen from the lane's name and kept apart from the lanes before it in the config, so
|
|
94
|
+
* a lane added later never changes another's. Six lanes get six shapes; more get marks as well, up to
|
|
95
|
+
* 24 apart; past that, looks repeat and the tint still tells them apart.
|
|
96
|
+
*/
|
|
97
|
+
export function charactersOf(lanes) {
|
|
98
|
+
const out = { lead: { shape: 'crown', mark: null, tint: LEAD_TINT } };
|
|
99
|
+
const looks = new Set();
|
|
100
|
+
const tints = new Set();
|
|
101
|
+
const all = SHAPES.length * MARKS.length;
|
|
102
|
+
for (const lane of [...new Set(lanes)].filter((l) => l !== 'lead')) {
|
|
103
|
+
const h = hashOf(lane);
|
|
104
|
+
// Probe a mark at a time, every shape before the next mark, starting at the name's own shape.
|
|
105
|
+
let look = null;
|
|
106
|
+
for (let i = 0; i < all && look === null; i++) {
|
|
107
|
+
const mark = Math.floor(i / SHAPES.length);
|
|
108
|
+
const shape = (h + i) % SHAPES.length;
|
|
109
|
+
const id = mark * SHAPES.length + shape;
|
|
110
|
+
if (!looks.has(id)) look = id;
|
|
111
|
+
}
|
|
112
|
+
if (look === null) look = h % all;
|
|
113
|
+
looks.add(look);
|
|
114
|
+
if (tints.size >= TINTS.length) tints.clear();
|
|
115
|
+
let tint = (h >>> 8) % TINTS.length;
|
|
116
|
+
for (let i = 0; i < TINTS.length && tints.has(tint); i++) tint = (tint + 1) % TINTS.length;
|
|
117
|
+
tints.add(tint);
|
|
118
|
+
out[lane] = {
|
|
119
|
+
shape: SHAPES[look % SHAPES.length],
|
|
120
|
+
mark: MARKS[Math.floor(look / SHAPES.length)],
|
|
121
|
+
tint: TINTS[tint],
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** One lane's character, among the project's lanes. */
|
|
128
|
+
export function characterOf(lane, lanes) {
|
|
129
|
+
return charactersOf(lanes.includes(lane) ? lanes : [...lanes, lane])[lane];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** The body, rows 7 to 11, arms in columns 3 and 8. */
|
|
133
|
+
const BODY = ['....DDDD....', '...HHHHHH...', '...HHHHHH...', '....H..H....', '...HH..HH...'];
|
|
134
|
+
|
|
135
|
+
/** Each pose and move: its frames, how long each shows, and whether it loops. */
|
|
136
|
+
export const POSES = {
|
|
137
|
+
writing: { frames: 4, ms: 220, loop: true, glyph: '✎', words: 'writing' },
|
|
138
|
+
running: { frames: 4, ms: 180, loop: true, glyph: '⚙', words: 'running' },
|
|
139
|
+
reading: { frames: 4, ms: 320, loop: true, glyph: '◉', words: 'reading' },
|
|
140
|
+
thinking: { frames: 4, ms: 360, loop: true, glyph: '…', words: 'thinking' },
|
|
141
|
+
waiting: { frames: 1, ms: 0, loop: false, glyph: '?', words: 'waiting on you' },
|
|
142
|
+
quiet: { frames: 1, ms: 0, loop: false, glyph: '…', words: 'quiet' },
|
|
143
|
+
stalled: { frames: 1, ms: 0, loop: false, glyph: '✗', words: 'stalled' },
|
|
144
|
+
resting: { frames: 1, ms: 0, loop: false, glyph: '·', words: 'resting' },
|
|
145
|
+
arriving: { frames: 4, ms: 250, loop: false, glyph: '↓', words: 'arriving' },
|
|
146
|
+
'handed-back': { frames: 4, ms: 250, loop: false, glyph: '↑', words: 'handed back' },
|
|
147
|
+
'sent-back': { frames: 4, ms: 250, loop: false, glyph: '↺', words: 'sent back' },
|
|
148
|
+
merged: { frames: 4, ms: 250, loop: false, glyph: '✓', words: 'merged' },
|
|
149
|
+
};
|
|
150
|
+
export const WORK = ['writing', 'running', 'reading', 'thinking'];
|
|
151
|
+
export const STILL = ['waiting', 'quiet', 'stalled', 'resting'];
|
|
152
|
+
export const MOVES = ['arriving', 'handed-back', 'sent-back', 'merged'];
|
|
153
|
+
|
|
154
|
+
/** The kind of work an agent's current tool is (UI-11): no tool is a model turn, thinking. */
|
|
155
|
+
export function workOf(tool) {
|
|
156
|
+
if (!tool) return 'thinking';
|
|
157
|
+
if (/^(Edit|Write|MultiEdit|NotebookEdit)$/.test(tool)) return 'writing';
|
|
158
|
+
if (/^(Read|Grep|Glob|LS|WebFetch|WebSearch)$/.test(tool)) return 'reading';
|
|
159
|
+
return 'running';
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const blank = () => Array.from({ length: SIZE }, () => Array(SIZE).fill('.'));
|
|
163
|
+
function paint(grid, rows, { top = 0, dx = 0, dy = 0 } = {}) {
|
|
164
|
+
rows.forEach((row, r) =>
|
|
165
|
+
[...row].forEach((ch, c) => {
|
|
166
|
+
const y = top + r + dy;
|
|
167
|
+
const x = c + dx;
|
|
168
|
+
if (ch !== '.' && y >= 0 && y < SIZE && x >= 0 && x < SIZE) grid[y][x] = ch;
|
|
169
|
+
}),
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
const put = (grid, points, ch) => {
|
|
173
|
+
for (const [y, x] of points) if (y >= 0 && y < SIZE && x >= 0 && x < SIZE) grid[y][x] = ch;
|
|
174
|
+
};
|
|
175
|
+
const clear = (grid, points) => put(grid, points, '.');
|
|
176
|
+
|
|
177
|
+
/** The eyes and mouth: where the eyes look, and the face's mood. */
|
|
178
|
+
function face(grid, kind, dx = 0, dy = 0) {
|
|
179
|
+
const at = (points) => points.map(([y, x]) => [y + dy, x + dx]);
|
|
180
|
+
const eyes = {
|
|
181
|
+
open: [
|
|
182
|
+
[4, 4],
|
|
183
|
+
[4, 7],
|
|
184
|
+
],
|
|
185
|
+
down: [
|
|
186
|
+
[5, 4],
|
|
187
|
+
[5, 7],
|
|
188
|
+
],
|
|
189
|
+
up: [
|
|
190
|
+
[3, 4],
|
|
191
|
+
[3, 7],
|
|
192
|
+
],
|
|
193
|
+
scan: [
|
|
194
|
+
[5, 5],
|
|
195
|
+
[5, 8],
|
|
196
|
+
],
|
|
197
|
+
};
|
|
198
|
+
if (kind === 'closed') return put(grid, at(eyes.open), 'L');
|
|
199
|
+
if (kind === 'crossed') return put(grid, at(eyes.open), 'X');
|
|
200
|
+
put(grid, at(eyes[kind] ?? eyes.open), 'E');
|
|
201
|
+
if (kind === 'happy')
|
|
202
|
+
put(
|
|
203
|
+
grid,
|
|
204
|
+
at([
|
|
205
|
+
[5, 5],
|
|
206
|
+
[5, 6],
|
|
207
|
+
]),
|
|
208
|
+
'E',
|
|
209
|
+
);
|
|
210
|
+
if (kind === 'oops') {
|
|
211
|
+
put(grid, at([[5, 6]]), 'E');
|
|
212
|
+
put(grid, at([[3, 9]]), 'B');
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** A lane's mark, worn in every pose: glasses round the eyes, a scarf at the neck, a belt. */
|
|
217
|
+
function wear(grid, mark, mood, dx = 0, dy = 0) {
|
|
218
|
+
const at = (points) => points.map(([y, x]) => [y + dy, x + dx]);
|
|
219
|
+
const eyes = mood === 'down' || mood === 'scan' ? 5 : mood === 'up' ? 3 : 4;
|
|
220
|
+
if (mark === 'glasses')
|
|
221
|
+
put(
|
|
222
|
+
grid,
|
|
223
|
+
at([
|
|
224
|
+
[eyes, 3],
|
|
225
|
+
[eyes, 5],
|
|
226
|
+
[eyes, 6],
|
|
227
|
+
[eyes, 8],
|
|
228
|
+
]),
|
|
229
|
+
'P',
|
|
230
|
+
);
|
|
231
|
+
if (mark === 'scarf') put(grid, at([3, 4, 5, 6, 7, 8].map((x) => [7, x])), 'S');
|
|
232
|
+
if (mark === 'belt') put(grid, at([4, 5, 6, 7].map((x) => [9, x])), 'P');
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** A frame as a grid of letters, before colour. */
|
|
236
|
+
function compose({ shape, mark = null }, pose, frame) {
|
|
237
|
+
const g = blank();
|
|
238
|
+
const head = HEADS[shape] ?? HEADS.antenna;
|
|
239
|
+
const whole = (dx, dy, mood, body = BODY) => {
|
|
240
|
+
paint(g, head, { dx, dy });
|
|
241
|
+
paint(g, body, { top: 7, dx, dy });
|
|
242
|
+
face(g, mood, dx, dy);
|
|
243
|
+
wear(g, mark, mood, dx, dy);
|
|
244
|
+
};
|
|
245
|
+
const f = frame % (POSES[pose]?.frames ?? 1);
|
|
246
|
+
switch (pose) {
|
|
247
|
+
case 'writing': {
|
|
248
|
+
// At a sheet of paper on the right, the pencil moving and the lines filling.
|
|
249
|
+
whole(0, 0, 'down');
|
|
250
|
+
put(g, [[8, 9]], 'H');
|
|
251
|
+
paint(g, ['WWW', 'WWW'], { top: 10, dx: 9 });
|
|
252
|
+
const tip = [9, 10, 11, 10][f];
|
|
253
|
+
put(g, [[9, tip]], 'K');
|
|
254
|
+
put(g, [[8, Math.min(11, tip + 1)]], 'P');
|
|
255
|
+
put(
|
|
256
|
+
g,
|
|
257
|
+
[
|
|
258
|
+
[10, 9],
|
|
259
|
+
[10, 10],
|
|
260
|
+
[10, 11],
|
|
261
|
+
].slice(0, f),
|
|
262
|
+
'E',
|
|
263
|
+
);
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
case 'running': {
|
|
267
|
+
// Turning a crank on the left, its bar spinning a quarter a frame, bobbing as it works.
|
|
268
|
+
const bob = f % 2;
|
|
269
|
+
whole(0, bob, 'open');
|
|
270
|
+
const spin = [
|
|
271
|
+
['.P.', '.K.', '.P.'],
|
|
272
|
+
['..P', '.K.', 'P..'],
|
|
273
|
+
['...', 'PKP', '...'],
|
|
274
|
+
['P..', '.K.', '..P'],
|
|
275
|
+
];
|
|
276
|
+
paint(g, spin[f], { top: 7 });
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
case 'reading': {
|
|
280
|
+
// A book held open, eyes down, a page turning.
|
|
281
|
+
whole(0, 0, f === 1 ? 'scan' : 'down');
|
|
282
|
+
paint(g, ['WWWDDWWW', 'WWWDDWWW'], { top: 8, dx: 2 });
|
|
283
|
+
if (f === 2)
|
|
284
|
+
put(
|
|
285
|
+
g,
|
|
286
|
+
[
|
|
287
|
+
[7, 7],
|
|
288
|
+
[7, 8],
|
|
289
|
+
],
|
|
290
|
+
'W',
|
|
291
|
+
);
|
|
292
|
+
if (f === 3)
|
|
293
|
+
put(
|
|
294
|
+
g,
|
|
295
|
+
[
|
|
296
|
+
[7, 3],
|
|
297
|
+
[7, 4],
|
|
298
|
+
],
|
|
299
|
+
'W',
|
|
300
|
+
);
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
case 'thinking': {
|
|
304
|
+
// A hand to the chin, eyes up, a thought rising.
|
|
305
|
+
whole(0, 0, 'up');
|
|
306
|
+
clear(g, [[9, 8]]);
|
|
307
|
+
put(
|
|
308
|
+
g,
|
|
309
|
+
[
|
|
310
|
+
[8, 9],
|
|
311
|
+
[7, 9],
|
|
312
|
+
[6, 8],
|
|
313
|
+
],
|
|
314
|
+
'H',
|
|
315
|
+
);
|
|
316
|
+
if (f >= 1) put(g, [[5, 10]], 'S');
|
|
317
|
+
if (f >= 2) put(g, [[3, 11]], 'S');
|
|
318
|
+
if (f >= 3) paint(g, ['SSS', 'SSS'], { top: 0, dx: 9 });
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
case 'waiting': {
|
|
322
|
+
// A raised hand.
|
|
323
|
+
whole(0, 0, 'open');
|
|
324
|
+
clear(g, [[9, 8]]);
|
|
325
|
+
put(
|
|
326
|
+
g,
|
|
327
|
+
[
|
|
328
|
+
[8, 9],
|
|
329
|
+
[7, 9],
|
|
330
|
+
[6, 9],
|
|
331
|
+
[5, 9],
|
|
332
|
+
[4, 9],
|
|
333
|
+
],
|
|
334
|
+
'H',
|
|
335
|
+
);
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
case 'quiet': {
|
|
339
|
+
// Still, looking on, a trailing ellipsis.
|
|
340
|
+
whole(0, 0, 'open');
|
|
341
|
+
put(
|
|
342
|
+
g,
|
|
343
|
+
[
|
|
344
|
+
[1, 9],
|
|
345
|
+
[1, 10],
|
|
346
|
+
[1, 11],
|
|
347
|
+
],
|
|
348
|
+
'S',
|
|
349
|
+
);
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
case 'stalled': {
|
|
353
|
+
// Slumped: the head dropped and tilted, eyes crossed.
|
|
354
|
+
paint(g, BODY, { top: 7 });
|
|
355
|
+
paint(g, head, { dx: 1, dy: 1 });
|
|
356
|
+
face(g, 'crossed', 1, 1);
|
|
357
|
+
wear(g, mark, 'open', 1, 1);
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
case 'resting': {
|
|
361
|
+
// Eyes closed, a Z.
|
|
362
|
+
whole(0, 0, 'closed');
|
|
363
|
+
paint(g, ['SSS', '.S.', 'SSS'], { top: 0, dx: 9 });
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
case 'arriving': {
|
|
367
|
+
// Dropping into the lane.
|
|
368
|
+
whole(0, [-8, -4, -1, 0][f], 'open');
|
|
369
|
+
if (f < 2)
|
|
370
|
+
put(
|
|
371
|
+
g,
|
|
372
|
+
[
|
|
373
|
+
[0, 2],
|
|
374
|
+
[0, 9],
|
|
375
|
+
],
|
|
376
|
+
'S',
|
|
377
|
+
);
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
case 'handed-back': {
|
|
381
|
+
// Holding the work up and away to the lead.
|
|
382
|
+
whole(0, 0, f === 3 ? 'happy' : 'open');
|
|
383
|
+
const paper = [
|
|
384
|
+
[
|
|
385
|
+
[8, 9],
|
|
386
|
+
[8, 10],
|
|
387
|
+
],
|
|
388
|
+
[
|
|
389
|
+
[6, 10],
|
|
390
|
+
[6, 11],
|
|
391
|
+
],
|
|
392
|
+
[[4, 11]],
|
|
393
|
+
[],
|
|
394
|
+
][f];
|
|
395
|
+
if (f < 2) put(g, [[8, 9]], 'H');
|
|
396
|
+
put(g, paper, 'W');
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
case 'sent-back': {
|
|
400
|
+
// A stumble backwards.
|
|
401
|
+
whole([0, -1, -2, -1][f], [0, 0, 1, 0][f], 'oops');
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
case 'merged': {
|
|
405
|
+
// A cheer: arms up, a jump, sparkles.
|
|
406
|
+
const up = [0, -2, -1, 0][f];
|
|
407
|
+
const body = BODY.map((r, i) => (i === 1 || i === 2 ? '....HHHH....' : r));
|
|
408
|
+
whole(0, up, 'happy', body);
|
|
409
|
+
put(
|
|
410
|
+
g,
|
|
411
|
+
[
|
|
412
|
+
[7 + up, 2],
|
|
413
|
+
[6 + up, 2],
|
|
414
|
+
[5 + up, 2],
|
|
415
|
+
[7 + up, 9],
|
|
416
|
+
[6 + up, 9],
|
|
417
|
+
[5 + up, 9],
|
|
418
|
+
],
|
|
419
|
+
'H',
|
|
420
|
+
);
|
|
421
|
+
put(
|
|
422
|
+
g,
|
|
423
|
+
f % 2
|
|
424
|
+
? [
|
|
425
|
+
[0, 1],
|
|
426
|
+
[2, 11],
|
|
427
|
+
]
|
|
428
|
+
: [
|
|
429
|
+
[1, 0],
|
|
430
|
+
[0, 10],
|
|
431
|
+
],
|
|
432
|
+
'K',
|
|
433
|
+
);
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
default:
|
|
437
|
+
whole(0, 0, 'open');
|
|
438
|
+
}
|
|
439
|
+
return g;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
const shade = (rgb, by) =>
|
|
443
|
+
(Math.round(((rgb >> 16) & 0xff) * by) << 16) |
|
|
444
|
+
(Math.round(((rgb >> 8) & 0xff) * by) << 8) |
|
|
445
|
+
Math.round((rgb & 0xff) * by);
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* A pose's frame as a grid of colours (null for none), 12 by 12. Resting is drawn dimmed. With
|
|
449
|
+
* motion off, a loop shows its first frame and a move its last.
|
|
450
|
+
*/
|
|
451
|
+
export function characterFrame(pose, frame, character, { motion = 'while-active' } = {}) {
|
|
452
|
+
const { tint } = character;
|
|
453
|
+
const spec = POSES[pose] ?? POSES.resting;
|
|
454
|
+
const f = motion === 'off' ? (spec.loop ? 0 : spec.frames - 1) : frame;
|
|
455
|
+
const letters = compose(character, POSES[pose] ? pose : 'resting', f);
|
|
456
|
+
const body = pose === 'resting' ? shade(tint, 0.5) : tint;
|
|
457
|
+
const colour = {
|
|
458
|
+
H: body,
|
|
459
|
+
D: shade(body, 0.65),
|
|
460
|
+
E: 0x1a1a1a,
|
|
461
|
+
W: 0xf2f2f2,
|
|
462
|
+
P: 0x9aa4ae,
|
|
463
|
+
K: 0xffcc00,
|
|
464
|
+
X: 0xff3b3b,
|
|
465
|
+
L: 0x6a6a6a,
|
|
466
|
+
S: 0xcfd8e0,
|
|
467
|
+
B: 0x7cc4ff,
|
|
468
|
+
};
|
|
469
|
+
return letters.map((r) => r.map((c) => colour[c] ?? null));
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/** The frames of a pose, in order: one for a still pose. */
|
|
473
|
+
export function characterFrames(pose, character, options) {
|
|
474
|
+
const n = POSES[pose]?.frames ?? 1;
|
|
475
|
+
return Array.from({ length: n }, (_, f) => characterFrame(pose, f, character, options));
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const hex = (rgb) => `#${rgb.toString(16).padStart(6, '0')}`;
|
|
479
|
+
const rects = (grid, scale) =>
|
|
480
|
+
grid
|
|
481
|
+
.flatMap((row, y) =>
|
|
482
|
+
row.map((c, x) =>
|
|
483
|
+
c === null
|
|
484
|
+
? ''
|
|
485
|
+
: `<rect x="${x * scale}" y="${y * scale}" width="${scale}" height="${scale}" fill="${hex(c)}"/>`,
|
|
486
|
+
),
|
|
487
|
+
)
|
|
488
|
+
.join('');
|
|
489
|
+
|
|
490
|
+
/** The SVG for one pose on Desktop: a loop repeats, a move plays once and holds its last frame. */
|
|
491
|
+
export function characterSvg(pose, character, { scale = 3, motion = 'while-active' } = {}) {
|
|
492
|
+
const spec = POSES[pose] ?? POSES.resting;
|
|
493
|
+
const frames =
|
|
494
|
+
motion === 'off'
|
|
495
|
+
? [characterFrame(pose, 0, character, { motion })]
|
|
496
|
+
: characterFrames(pose, character);
|
|
497
|
+
const px = SIZE * scale;
|
|
498
|
+
const dur = (spec.ms * frames.length) / 1000;
|
|
499
|
+
const groups = frames.map((g, f) => {
|
|
500
|
+
if (frames.length === 1) return `<g>${rects(g, scale)}</g>`;
|
|
501
|
+
const values = frames.map((_, i) => (i === f ? 'visible' : 'hidden')).join(';');
|
|
502
|
+
const repeat = spec.loop ? ' repeatCount="indefinite"' : ' fill="freeze"';
|
|
503
|
+
return `<g visibility="${f ? 'hidden' : 'visible'}"><animate attributeName="visibility" values="${values}" dur="${dur}s"${repeat} calcMode="discrete"/>${rects(g, scale)}</g>`;
|
|
504
|
+
});
|
|
505
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${px}" height="${px}" viewBox="0 0 ${px} ${px}" shape-rendering="crispEdges">${groups.join('')}</svg>`;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/** The sheet (UI-11): every lane in every pose and move, the lead first. */
|
|
509
|
+
export function sheet(lanes) {
|
|
510
|
+
const names = ['lead', ...lanes.filter((l) => l !== 'lead')];
|
|
511
|
+
const characters = charactersOf(names);
|
|
512
|
+
return {
|
|
513
|
+
poses: [...WORK, ...STILL, ...MOVES],
|
|
514
|
+
rows: names.map((lane) => ({ lane, ...characters[lane] })),
|
|
515
|
+
};
|
|
516
|
+
}
|
package/hooks/mod/loop.mjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
/** The steps the loop hands the lead; the rest (spec-design, init, check) wait for the person. */
|
|
6
6
|
const LEAD_STEPS = new Set([
|
|
7
|
+
'reconcile',
|
|
7
8
|
'instructions',
|
|
8
9
|
'decide',
|
|
9
10
|
'dispatch',
|
|
@@ -146,6 +147,18 @@ export function leadPrompt(step, { cli = 'code-kit' } = {}) {
|
|
|
146
147
|
: `Run node "${cli}" instructions --write.`;
|
|
147
148
|
return `${step.why ?? "code-kit's instructions are behind."} ${how} Commit the change on a branch and merge it like your own stories, so new lane agents start with the current rules.`;
|
|
148
149
|
}
|
|
150
|
+
// DUR-4: an act an agent left open that git can't settle: the lead finds out, and records it.
|
|
151
|
+
if (step.step === 'reconcile') {
|
|
152
|
+
const acts = step.acts ?? [];
|
|
153
|
+
if (!acts.length) return null;
|
|
154
|
+
const each = acts
|
|
155
|
+
.map(
|
|
156
|
+
(a) =>
|
|
157
|
+
`${a.story}: ${a.kind} \`${a.target}\` (act ${a.act}); see node "${cli}" replay ${a.story}`,
|
|
158
|
+
)
|
|
159
|
+
.join('; ');
|
|
160
|
+
return `${step.why ?? 'An agent stopped mid-act.'} For each, check what happened (${each}). Never run it again just to be sure. Record what you found with node "${cli}" reconcile <story> --act <act> --found done|not-done --how "<how you know>". If finding out needs something you don't decide, such as a migration the person approves, ask them with code-kit ask.`;
|
|
161
|
+
}
|
|
149
162
|
// HELM-4: a lane waits on the lead's decision; the decide skill takes each request on its merits.
|
|
150
163
|
if (step.step === 'decide')
|
|
151
164
|
return ids.length
|
|
@@ -186,6 +199,7 @@ export function stepLabel(step) {
|
|
|
186
199
|
const ids = (step.args ?? '').split(/\s+/).filter(Boolean).join(', ');
|
|
187
200
|
const verb =
|
|
188
201
|
{
|
|
202
|
+
reconcile: 'Reconcile',
|
|
189
203
|
decide: 'Decide requests',
|
|
190
204
|
instructions: 'Update the instructions',
|
|
191
205
|
dispatch: 'Dispatch',
|
|
@@ -214,8 +228,8 @@ export function stallDue(quietMs, agent, restarts, stall) {
|
|
|
214
228
|
}
|
|
215
229
|
|
|
216
230
|
/** The lead's prompt to stop a stalled agent and dispatch its story again (LOOP-3). */
|
|
217
|
-
export function restartPrompt({ type, id, story, minutes }) {
|
|
218
|
-
return `${type} (agent ${id}) on ${story} has made no tool call for ${minutes} minutes. Stop it with TaskStop, then dispatch ${story} again with the same brief on the same branch: /code-kit:dispatch ${story}`;
|
|
231
|
+
export function restartPrompt({ type, id, story, minutes, cli = 'code-kit' }) {
|
|
232
|
+
return `${type} (agent ${id}) on ${story} has made no tool call for ${minutes} minutes. Stop it with TaskStop, then dispatch ${story} again with the same brief on the same branch, adding what node "${cli}" replay ${story} --brief prints (DUR-5: its last commit, tests and what it left open): /code-kit:dispatch ${story}`;
|
|
219
233
|
}
|
|
220
234
|
|
|
221
235
|
/**
|
|
@@ -374,5 +388,5 @@ export const wrapUpText = (limit) =>
|
|
|
374
388
|
|
|
375
389
|
/** LEAN-5, LEAN-6: the lead's prompt to carry a story on with a fresh agent once its agent handed back at the limit. */
|
|
376
390
|
export function continuePrompt({ type, story, branch, cli = 'code-kit' }) {
|
|
377
|
-
return `${type} handed ${story} back at its context limit, with its work committed${branch ? ` on ${branch}` : ''}. Carry the story on with a fresh agent: run node "${cli}" worktrees release ${branch ?? '<branch>'} (it keeps the commits and moves the report to the main checkout), then dispatch ${story} again with the same brief, adding "Read your earlier report first: .claude/state/reports/${(branch ?? '<branch>').replace(/[^\w.-]+/g, '_')}.md in the main checkout": /code-kit:dispatch ${story}`;
|
|
391
|
+
return `${type} handed ${story} back at its context limit, with its work committed${branch ? ` on ${branch}` : ''}. Carry the story on with a fresh agent: run node "${cli}" worktrees release ${branch ?? '<branch>'} (it keeps the commits and moves the report to the main checkout), then dispatch ${story} again with the same brief, adding "Read your earlier report first: .claude/state/reports/${(branch ?? '<branch>').replace(/[^\w.-]+/g, '_')}.md in the main checkout" and what node "${cli}" replay ${story} --brief prints: /code-kit:dispatch ${story}`;
|
|
378
392
|
}
|
package/hooks/mod/mission.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// The mission
|
|
2
|
-
//
|
|
3
|
-
// from another tool only when it has something to say. The band draws these above what needs the person.
|
|
1
|
+
// The mission (docs/specs/14-mission-and-maps.md, MISSION-1): the milestone being built, and the words
|
|
2
|
+
// for the loop's next step. The Build panel and the band's one line draw them (spec 27, UI-2 and UI-9).
|
|
4
3
|
import { stepLabel } from './loop.mjs';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -30,93 +29,3 @@ export function nextText(step) {
|
|
|
30
29
|
: stepLabel(step);
|
|
31
30
|
return `${label}${then.length ? `, then ${then.join(', ')}` : ''}`;
|
|
32
31
|
}
|
|
33
|
-
|
|
34
|
-
/** At most this many agents get a line of their own; the rest are counted. */
|
|
35
|
-
const AGENT_LINES = 5;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* MISSION-1 to MISSION-3: the band's mission rows, or none while nothing is happening (no lead turn,
|
|
39
|
-
* no agent at work, the loop not started). Each row is { kind, mission: true, label, text, ... }:
|
|
40
|
-
* goal; now (with Pause or Resume while the loop runs); next; agents, with one entry per lane at work
|
|
41
|
-
* ({ lane, tool, ago, level }); and a line per adapter fact worth the person's attention.
|
|
42
|
-
*/
|
|
43
|
-
export function missionLines({
|
|
44
|
-
state,
|
|
45
|
-
loop = null,
|
|
46
|
-
leadBusy = false,
|
|
47
|
-
live = {},
|
|
48
|
-
nextStep = null,
|
|
49
|
-
combined = null,
|
|
50
|
-
}) {
|
|
51
|
-
if (state?.kind !== 'ok') return [];
|
|
52
|
-
const working = state.lanes.filter((l) => l.name !== 'lead' && l.active && live[l.name]);
|
|
53
|
-
const away = ['elsewhere', 'unled'].includes(loop?.state);
|
|
54
|
-
const loopOn = Boolean(loop?.started) && !['off', 'stopped'].includes(loop?.state) && !away;
|
|
55
|
-
if (!leadBusy && !working.length && !loopOn) return [];
|
|
56
|
-
const rows = [];
|
|
57
|
-
const goal = goalOf(state.stories);
|
|
58
|
-
if (goal)
|
|
59
|
-
rows.push({
|
|
60
|
-
kind: 'goal',
|
|
61
|
-
label: 'goal',
|
|
62
|
-
text: `${goal.name} · ${goal.done} of ${goal.total} ${goal.total === 1 ? 'story' : 'stories'} done`,
|
|
63
|
-
});
|
|
64
|
-
const lead = leadBusy
|
|
65
|
-
? `lead ${live.lead?.tool ? `at work: ${live.lead.tool}` : 'at work'}`
|
|
66
|
-
: 'lead idle';
|
|
67
|
-
const loopWord =
|
|
68
|
-
loop?.state === 'elsewhere'
|
|
69
|
-
? 'the lead is in another session'
|
|
70
|
-
: loop?.state === 'unled'
|
|
71
|
-
? 'no session leads the project'
|
|
72
|
-
: loop?.state === 'paused'
|
|
73
|
-
? 'loop paused'
|
|
74
|
-
: loop?.state === 'off'
|
|
75
|
-
? 'loop off'
|
|
76
|
-
: loop?.state === 'done'
|
|
77
|
-
? 'milestone done'
|
|
78
|
-
: loopOn
|
|
79
|
-
? `loop ${loop.autonomy === 'propose' ? 'proposing' : 'on'}${loop.last ? ` · last: ${loop.last}` : ''}`
|
|
80
|
-
: null;
|
|
81
|
-
rows.push({
|
|
82
|
-
kind: 'now',
|
|
83
|
-
label: 'now',
|
|
84
|
-
text: [lead, loopWord].filter(Boolean).join(' · '),
|
|
85
|
-
actions: away
|
|
86
|
-
? [{ id: 'leadHere', label: 'Lead from here' }]
|
|
87
|
-
: loop?.state === 'paused'
|
|
88
|
-
? [{ id: 'resume', label: 'Resume' }]
|
|
89
|
-
: loopOn && loop?.state === 'running'
|
|
90
|
-
? [{ id: 'pause', label: 'Pause' }]
|
|
91
|
-
: [],
|
|
92
|
-
});
|
|
93
|
-
const next = nextText(nextStep);
|
|
94
|
-
if (next && loop?.state !== 'done') rows.push({ kind: 'next', label: 'next', text: next });
|
|
95
|
-
if (working.length)
|
|
96
|
-
rows.push({
|
|
97
|
-
kind: 'agents',
|
|
98
|
-
label: 'agents',
|
|
99
|
-
text: `${working.length} at work`,
|
|
100
|
-
agents: working.slice(0, AGENT_LINES).map((l) => ({
|
|
101
|
-
lane: l.name,
|
|
102
|
-
tool: live[l.name].tool,
|
|
103
|
-
ago: live[l.name].ago,
|
|
104
|
-
level: live[l.name].level ?? null,
|
|
105
|
-
})),
|
|
106
|
-
more: Math.max(0, working.length - AGENT_LINES),
|
|
107
|
-
});
|
|
108
|
-
// MISSION-3: another tool's line only when it isn't zero: edits made before the file was understood.
|
|
109
|
-
const unread = Object.entries(combined ?? {}).filter(([, f]) => f.without > 0);
|
|
110
|
-
if (unread.length)
|
|
111
|
-
rows.push({
|
|
112
|
-
kind: 'facts',
|
|
113
|
-
label: 'context',
|
|
114
|
-
text: unread
|
|
115
|
-
.map(
|
|
116
|
-
([lane, f]) =>
|
|
117
|
-
`${lane} edited ${f.without} file${f.without === 1 ? '' : 's'} without understanding ${f.without === 1 ? 'it' : 'them'}`,
|
|
118
|
-
)
|
|
119
|
-
.join(' · '),
|
|
120
|
-
});
|
|
121
|
-
return rows.map((r) => ({ actions: [], ...r, mission: true }));
|
|
122
|
-
}
|