@warren-dean/code-kit 0.26.1 → 0.26.2

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.
@@ -9,7 +9,7 @@
9
9
  "name": "code-kit",
10
10
  "source": "./",
11
11
  "description": "Keeps AI coding agents inside your project's rules, from idea to merged code: spec design, lanes, layer rules, protected paths with an approval log, spec-check and design gates, proof-before-finish checks, dispatch, review, build status and CI verification, configured per project from its docs",
12
- "version": "0.26.1",
12
+ "version": "0.26.2",
13
13
  "category": "development",
14
14
  "tags": ["guardrails", "architecture", "lanes", "layers", "spec-driven", "ci", "multi-agent"],
15
15
  "license": "MIT"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-kit",
3
- "version": "0.26.1",
3
+ "version": "0.26.2",
4
4
  "description": "Keeps AI coding agents inside your project's rules, from idea to merged code: spec design, lanes, layer rules, protected paths with an approval log, spec-check and design gates, proof-before-finish checks, dispatch, review, build status and CI verification, configured per project from its docs",
5
5
  "author": {
6
6
  "name": "Warren Langeveldt"
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  What changed in each release of code-kit, newest first. Versions follow the plugin manifest and the npm package `@warren-dean/code-kit`. Each release is also on [GitHub Releases](https://github.com/warrendeanlangeveldt/code-kit/releases).
4
4
 
5
+ ## 0.26.2 (2026-10-26)
6
+
7
+ The lanes pane tells the truth about what's being built, and is easier to read.
8
+
9
+ - A lane no longer says "building" when nothing is building it. A story whose branch had merged, but whose line in the plan hadn't moved on, read as in progress forever and held its lane, so nothing new was sent to it. Now a story is in progress only while an agent's claim names it or you have its branch checked out. One whose work has merged counts as done, and `code-kit next` lists the plan lines that are out of date. One whose agent stopped before its first commit is ready again, and `next` sends it to a fresh agent and says why.
10
+ - In a project with a long history, the plan's git reads no longer come back empty.
11
+ - The lane characters are smaller, 8 by 8 pixels (four rows), and every pose is redrawn. A resting lane shows a "z".
12
+ - The keys line shows each key once (`j: down · k: up · ⏎: open · f: filter · l: journal`), and a lane's action buttons no longer show their key twice.
13
+
5
14
  ## 0.26.1 (2026-10-26)
6
15
 
7
16
  `/lanes` opens in large projects again.
@@ -265,6 +265,13 @@ export function nextStep(root, base) {
265
265
  `The plan's status lines are out of date for ${status.drift.map((d) => d.story).join(', ')}.`,
266
266
  );
267
267
 
268
+ // A lane's story whose agent stopped before its first commit is ready again, for a fresh agent.
269
+ const stopped = status.stories.filter((s) => s.stopped).map((s) => s.id);
270
+ if (stopped.length)
271
+ attention.push(
272
+ `${stopped.join(', ')} ${stopped.length === 1 ? 'has its branch but no commits, and no agent on it' : 'have their branches but no commits, and no agent on them'}: ${stopped.length === 1 ? 'it goes' : 'they go'} to a fresh agent, on the same branch.`,
273
+ );
274
+
268
275
  // A branch already in the merge queue has passed its review: it isn't reviewed again.
269
276
  const queued = waiting(readQueue(root)).map((e) => e.branch);
270
277
  const ids = (state) =>
@@ -6,9 +6,11 @@
6
6
  // `**Requirements:** none` marks a story that delivers no requirement, such as a spike.
7
7
  import { execFileSync } from 'node:child_process';
8
8
  import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
9
- import { join } from 'node:path';
9
+ import { isAbsolute, join } from 'node:path';
10
+ import { laneClaims } from './laneclaims.mjs';
10
11
  import { waitingStories } from './questions.mjs';
11
12
  import { sentBack } from './reviews.mjs';
13
+ import { WORKTREES_DIR } from './worktrees.mjs';
12
14
 
13
15
  export const REQUIREMENT = /\b(?!ST-)([A-Z][A-Z0-9]*-\d+)\b/g;
14
16
  const STORY_HEADING = /^###\s+(ST-\d+)\b\s*(.*)$/;
@@ -155,6 +157,8 @@ const git = (root, ...args) => {
155
157
  return execFileSync('git', ['-C', root, ...args], {
156
158
  encoding: 'utf8',
157
159
  stdio: ['ignore', 'pipe', 'ignore'],
160
+ // A long-lived project's log runs to megabytes.
161
+ maxBuffer: 256 * 1024 * 1024,
158
162
  }).trim();
159
163
  } catch {
160
164
  return null;
@@ -180,6 +184,35 @@ export function branchRefs(root, base) {
180
184
  return refs;
181
185
  }
182
186
 
187
+ /**
188
+ * How each local branch was made, from its reflog's oldest entry: (branch) => { sha, at } (the commit
189
+ * it was made at, and when, in milliseconds), or null once the reflog is gone. Read from the file git
190
+ * keeps it in, or from git where there's no file (a reftable repository).
191
+ */
192
+ export function branchMaking(root) {
193
+ const common = git(root, 'rev-parse', '--git-common-dir');
194
+ const dir = common ? (isAbsolute(common) ? common : join(root, common)) : null;
195
+ return (branch) => {
196
+ if (!dir) return null;
197
+ try {
198
+ const first = readFileSync(join(dir, 'logs/refs/heads', branch), 'utf8').split('\n')[0];
199
+ const [head] = first.split('\t');
200
+ const sha = head.split(' ')[1];
201
+ const at = head.match(/> (\d+) [+-]\d{4}$/)?.[1];
202
+ return sha && at ? { sha, at: Number(at) * 1000 } : null;
203
+ } catch {
204
+ const oldest = (
205
+ git(root, 'reflog', 'show', '--date=unix', '--format=%H %gd', `refs/heads/${branch}`) ?? ''
206
+ )
207
+ .split('\n')
208
+ .filter(Boolean)
209
+ .at(-1)
210
+ ?.match(/^([0-9a-f]+) .*@\{(\d+)\}$/);
211
+ return oldest ? { sha: oldest[1], at: Number(oldest[2]) * 1000 } : null;
212
+ }
213
+ };
214
+ }
215
+
183
216
  /** The ref of a branch, local first, then on origin; null when neither exists. */
184
217
  function branchRef(refs, branch) {
185
218
  return [`refs/heads/${branch}`, `refs/remotes/origin/${branch}`].find((r) => refs[r]) ?? null;
@@ -201,16 +234,44 @@ function worktrees(root) {
201
234
  /**
202
235
  * Where each story is. The plan's `done` stands (the lead marks it after merging, and merged
203
236
  * branches are often deleted or squashed). Otherwise git decides: a branch with commits not in
204
- * `base` is in review; one level with it is in progress, or done once the plan had it in review.
205
- * A branch still at the commit a review sent back is `sent back`, waiting for its lane's fix.
206
- * Without a branch, the plan's status stands. A story is `blocked` while a story it depends on
207
- * isn't done, whatever its branch holds; a todo story whose dependencies are done is `ready`. A story
208
- * with an open question for the person that holds it (`code-kit ask --blocks`) is `waiting on you`.
237
+ * `base` is in review. A branch still at the commit a review sent back is `sent back`, waiting for
238
+ * its lane's fix. Without a branch, the plan's status stands. A story is `blocked` while a story it
239
+ * depends on isn't done, whatever its branch holds; a todo story whose dependencies are done is `ready`.
240
+ * A story with an open question for the person that holds it (`code-kit ask --blocks`) is `waiting on
241
+ * you`.
242
+ *
243
+ * A branch level with the base is in progress while something builds it: a live claim of its lane (an
244
+ * agent at work on it, SCHED-1), or the branch checked out where a person works (the main checkout, or a
245
+ * worktree of theirs). With nothing on it, it's done when its commits merged (the plan had it in review,
246
+ * the branch moved since it was made, or with no reflog, the base names the story or merged the branch),
247
+ * whatever the plan says yet. A lane's branch that never moved is `stopped`: its agent stopped before its
248
+ * first commit, and the story is ready again (or blocked) for a fresh agent, so its lane isn't held by
249
+ * nothing. A branch only on origin may be a teammate's, and stays in progress unless the base holds it.
209
250
  */
210
251
  export function storyStates(root, stories, base) {
211
252
  const trees = worktrees(root);
212
253
  const backs = sentBack(root);
213
254
  const refs = branchRefs(root, base);
255
+ const live = new Set(
256
+ laneClaims(root)
257
+ .filter((c) => !c.stale)
258
+ .map((c) => `${c.lane}|${c.story ?? ''}`),
259
+ );
260
+ // What the base already holds: the stories its commits name, and the story branches merged into it.
261
+ const onBase = { stories: new Set(), branches: new Set() };
262
+ for (const m of (git(root, 'log', base, '--format=%B%x1e') ?? '').matchAll(
263
+ /(?:^|[^A-Za-z0-9-])(ST-\d+)(?!\d)|([A-Za-z0-9_.-]+\/st-\d+)(?![\w-])/gim,
264
+ ))
265
+ if (m[1]) onBase.stories.add(m[1]);
266
+ else onBase.branches.add(m[2].toLowerCase());
267
+ const making = branchMaking(root);
268
+ const merged = (story, branch) =>
269
+ onBase.stories.has(story.id) || onBase.branches.has(branch.toLowerCase());
270
+ const agentTree = (path) => path?.split('\\').join('/').includes(`/${WORKTREES_DIR}/`);
271
+ const builtBy = (story, branch) =>
272
+ live.has(`${story.lane}|${story.id}`) ||
273
+ live.has(`${story.lane}|`) ||
274
+ (trees[branch] !== undefined && !agentTree(trees[branch]));
214
275
  const states = stories.map((story) => {
215
276
  const branch = storyBranch(story);
216
277
  const ref = story.lane ? branchRef(refs, branch) : null;
@@ -218,11 +279,24 @@ export function storyStates(root, stories, base) {
218
279
  ? 0
219
280
  : (refs[ref].ahead ?? Number(git(root, 'rev-list', '--count', `${base}..${ref}`) ?? 0));
220
281
  let state = story.status;
282
+ let stopped = false;
221
283
  if (ref && story.status !== 'done') {
222
284
  const head = backs[branch] ? refs[ref].sha : null;
223
285
  if (head && head === backs[branch].sha) state = 'sent back';
224
286
  else if (ahead > 0) state = 'review';
225
- else state = story.status === 'review' ? 'done' : 'in progress';
287
+ else if (story.status === 'review') state = 'done';
288
+ else if (builtBy(story, branch)) state = 'in progress';
289
+ else {
290
+ // Level with the base, and nothing on it: its commits merged (the plan may not say so yet), or
291
+ // none was made. A local branch's reflog says which: it moved from the commit it was made at only
292
+ // by being committed to. Without one, the base's own log says whether it holds the story's work.
293
+ const made = ref.startsWith('refs/heads/') ? making(branch) : null;
294
+ if (made ? made.sha !== refs[ref].sha : merged(story, branch)) state = 'done';
295
+ else if (made && ![LEAD, DESIGN].includes(story.lane)) {
296
+ state = 'todo';
297
+ stopped = true;
298
+ } else state = 'in progress';
299
+ }
226
300
  }
227
301
  return {
228
302
  ...story,
@@ -232,6 +306,7 @@ export function storyStates(root, stories, base) {
232
306
  ahead,
233
307
  worktree: trees[branch] ?? null,
234
308
  state,
309
+ stopped,
235
310
  waitingOn: [],
236
311
  };
237
312
  });
@@ -2,8 +2,7 @@
2
2
  // records: when its branch was made, its commits, its merge into the base, its send-backs and the
3
3
  // approvals its commits logged. The mod draws these as a bar per lane on a shared time axis.
4
4
  import { execFileSync } from 'node:child_process';
5
- import { readFileSync } from 'node:fs';
6
- import { isAbsolute, join } from 'node:path';
5
+ import { branchMaking } from './plan.mjs';
7
6
  import { APPROVAL_LOG } from './rules.mjs';
8
7
  import { sendBacks } from './reviews.mjs';
9
8
 
@@ -69,28 +68,12 @@ export function storyTimes(root, stories, base) {
69
68
  root,
70
69
  shown.filter((s) => s.branchExists).map((s) => `${refOf(s)}:${APPROVAL_LOG}`),
71
70
  );
72
- const common = git('rev-parse', '--git-common-dir');
73
- const reflogs = common ? (isAbsolute(common) ? common : join(root, common)) : null;
74
- // When a branch was made: its reflog's oldest entry, read from the file git keeps it in (or from git,
75
- // where the file isn't there), in milliseconds; null once the reflog is gone.
76
- const madeAt = (b) => {
77
- let first = null;
78
- try {
79
- first = readFileSync(join(reflogs, 'logs/refs/heads', b), 'utf8').split('\n')[0];
80
- } catch {
81
- const at = lines(git('reflog', 'show', '--date=unix', '--format=%gd', `refs/heads/${b}`))
82
- .at(-1)
83
- ?.match(/@\{(\d+)\}$/)?.[1];
84
- return at ? Number(at) * 1000 : null;
85
- }
86
- const at = first?.split('\t')[0].match(/> (\d+) [+-]\d{4}$/)?.[1];
87
- return at ? Number(at) * 1000 : null;
88
- };
71
+ const making = branchMaking(root);
89
72
  return shown.map((s) => {
90
73
  const b = s.branch;
91
74
  // A branch only on origin has no reflog here.
92
75
  const local = s.branchExists && refOf(s).startsWith('refs/heads/');
93
- const made = local && reflogs ? madeAt(b) : null;
76
+ const made = local ? (making(b)?.at ?? null) : null;
94
77
  // Only a branch ahead of the base has commits of its own.
95
78
  const commits =
96
79
  s.branchExists && s.ahead !== 0
@@ -3,7 +3,7 @@
3
3
  // built right?), Queue and Log, each with a status line first and no room taken when it has nothing to
4
4
  // say; the full views opened from a story or a command; three layouts. Pure functions from what the
5
5
  // mod already holds to elements, so they're tested with node at every width (UI-13).
6
- import { charactersOf, characterFrame, characterSvg, POSES, workOf } from './characters.mjs';
6
+ import { SIZE, charactersOf, characterFrame, characterSvg, POSES, workOf } from './characters.mjs';
7
7
  import { BAR, rasterCells, runs, timelineSvg } from './art.mjs';
8
8
  import { goalOf } from './mission.mjs';
9
9
  import { CELL, cellOf, laneActions, laneStories, storyToOpen } from './panes.mjs';
@@ -370,8 +370,8 @@ export function poseFor(lane, { live = null, waiting = false, stalled = false, q
370
370
  export const layoutOf = (placement, columns) =>
371
371
  placement === 'inline' ? 'inline' : columns >= 110 ? 'wide' : 'docked';
372
372
 
373
- /** The rows a lane card takes: a character's six, and its border. */
374
- export const CARD_ROWS = 8;
373
+ /** The rows a lane card takes: its five lines of words (the character's four beside them), and its border. */
374
+ export const CARD_ROWS = 7;
375
375
  /** The columns a lane card takes where cards sit side by side: its character, its words, its frame. */
376
376
  export const CARD_COLUMNS = 44;
377
377
  /** The fewest columns a card is drawn in. */
@@ -473,7 +473,10 @@ export function keysFor(sel, { acts = [], view = null, loop = null, story = fals
473
473
  ...(view === 'trail' ? [{ key: '←→', label: 'requirement' }] : []),
474
474
  { key: 'esc', label: 'back' },
475
475
  ];
476
- const keys = [{ key: 'j/k', label: 'move' }];
476
+ const keys = [
477
+ { key: 'j', label: 'down' },
478
+ { key: 'k', label: 'up' },
479
+ ];
477
480
  if (sel) keys.push({ key: '⏎', label: 'open' });
478
481
  if (sel?.kind === 'lane' && story) {
479
482
  keys.push({ key: 't', label: 'trail' }, { key: 'c', label: 'map' });
@@ -547,14 +550,19 @@ export function board(view, els, on) {
547
550
  const still = (name, pose) => {
548
551
  const grid = characterFrame(pose, 0, looks[name], { motion: 'off' });
549
552
  if (surface === 'terminal' && els.Raster)
550
- return els.Raster({ key: `char-${name}`, columns: 12, rows: 6, cells: rasterCells(grid) });
553
+ return els.Raster({
554
+ key: `char-${name}`,
555
+ columns: SIZE,
556
+ rows: SIZE / 2,
557
+ cells: rasterCells(grid),
558
+ });
551
559
  if (els.Svg)
552
560
  return els.Svg({
553
561
  key: `char-${name}`,
554
562
  source: characterSvg(pose, looks[name], { motion: 'off' }),
555
563
  alt: `${name}: ${POSES[pose]?.words ?? pose}`,
556
- width: 36,
557
- height: 36,
564
+ width: SIZE * 3,
565
+ height: SIZE * 3,
558
566
  });
559
567
  return text(POSES[pose]?.glyph ?? '·');
560
568
  };
@@ -566,16 +574,16 @@ export function board(view, els, on) {
566
574
  key: `char-${name}`,
567
575
  module: './surface/character.mjs',
568
576
  props: { look: looks[name], pose, move, motion },
569
- width: 12,
570
- height: 6,
577
+ width: SIZE,
578
+ height: SIZE / 2,
571
579
  });
572
580
  if (surface === 'desktop' && els.Svg && motion !== 'off' && !faulted)
573
581
  return els.Svg({
574
582
  key: `char-${name}-${move?.key ?? pose}`,
575
583
  source: characterSvg(move ? move.kind : pose, looks[name]),
576
584
  alt: `${name}: ${POSES[move?.kind ?? pose]?.words ?? pose}`,
577
- width: 36,
578
- height: 36,
585
+ width: SIZE * 3,
586
+ height: SIZE * 3,
579
587
  });
580
588
  return still(name, pose);
581
589
  };
@@ -832,7 +840,7 @@ export function board(view, els, on) {
832
840
  : []),
833
841
  ];
834
842
  };
835
- const cardRoom = Math.max(4, (layout === 'docked' ? columns : CARD_COLUMNS) - 19);
843
+ const cardRoom = Math.max(4, (layout === 'docked' ? columns : CARD_COLUMNS) - (SIZE + 7));
836
844
  const chips = (l, story) =>
837
845
  mapChips(view.maps?.[story?.id], view.trouble?.[l.name]).map((c, i) =>
838
846
  text(c.layer, {
@@ -1036,7 +1044,8 @@ export function board(view, els, on) {
1036
1044
  ...acts.map((a) =>
1037
1045
  Button({
1038
1046
  key: `act-${a.id}`,
1039
- label: `${a.label} ${ACT_KEY[a.id] ?? ''}`.trim(),
1047
+ // Drawn as "w: Watch": the hotkey shows once, before the word.
1048
+ label: a.label,
1040
1049
  ...(ACT_KEY[a.id] ? { hotkey: ACT_KEY[a.id] } : {}),
1041
1050
  plain: true,
1042
1051
  onPress: () => on.onLane(a.id, l),
@@ -1335,54 +1344,31 @@ export function board(view, els, on) {
1335
1344
  loop,
1336
1345
  story: Boolean(selectedLane && storyOf(selectedLane)),
1337
1346
  });
1347
+ // A key the pane answers itself is a Button, drawn as its hotkey and word; the rest are words alike.
1348
+ const bound = {
1349
+ j: ['move-next', () => on.onMove(1)],
1350
+ k: ['move-prev', () => on.onMove(-1)],
1351
+ f: ['filter-focus', () => on.onFocusSearch()],
1352
+ l: ['open-journal', () => on.onView('journal')],
1353
+ };
1338
1354
  const keysLine = Box({
1339
1355
  key: 'keys',
1340
1356
  flexDirection: 'row',
1341
1357
  columnGap: 1,
1342
1358
  flexWrap: 'wrap',
1343
- children: [
1344
- Button({
1345
- key: 'move-next',
1346
- label: 'j',
1347
- hotkey: 'j',
1348
- plain: true,
1349
- dimColor: true,
1350
- onPress: () => on.onMove(1),
1351
- }),
1352
- Button({
1353
- key: 'move-prev',
1354
- label: 'k',
1355
- hotkey: 'k',
1356
- plain: true,
1357
- dimColor: true,
1358
- onPress: () => on.onMove(-1),
1359
- }),
1360
- Button({
1361
- key: 'filter-focus',
1362
- label: 'f',
1363
- hotkey: 'f',
1364
- plain: true,
1365
- dimColor: true,
1366
- onPress: () => on.onFocusSearch(),
1367
- }),
1368
- Button({
1369
- key: 'open-journal',
1370
- label: 'l',
1371
- hotkey: 'l',
1372
- plain: true,
1373
- dimColor: true,
1374
- onPress: () => on.onView('journal'),
1375
- }),
1376
- Box({
1377
- flexShrink: 1,
1378
- children: [
1379
- text(keys.map((k) => `${k.key} ${k.label}`).join(' · '), {
1359
+ children: keys.flatMap((k, i) => [
1360
+ ...(i ? [text('·', { key: `keys-dot-${i}`, dimColor: true })] : []),
1361
+ bound[k.key]
1362
+ ? Button({
1363
+ key: bound[k.key][0],
1364
+ label: k.label,
1365
+ hotkey: k.key,
1366
+ plain: true,
1380
1367
  dimColor: true,
1381
- wrap: 'truncate-end',
1382
- }),
1383
- ],
1384
- }),
1385
- ],
1368
+ onPress: bound[k.key][1],
1369
+ })
1370
+ : text(`${k.key}: ${k.label}`, { key: `keys-${k.key}`, dimColor: true }),
1371
+ ]),
1386
1372
  });
1387
1373
 
1388
1374
  // --- the layouts (UI-10) ---
@@ -1666,8 +1652,8 @@ export function sheetView(lanes, els, { surface = 'terminal', motion = 'while-ac
1666
1652
  key: `sheet-${name}-${pose}`,
1667
1653
  source: characterSvg(pose, looks[name], { motion }),
1668
1654
  alt: `${name}: ${POSES[pose].words}`,
1669
- width: 36,
1670
- height: 36,
1655
+ width: SIZE * 3,
1656
+ height: SIZE * 3,
1671
1657
  });
1672
1658
  return text(POSES[pose].glyph);
1673
1659
  };
@@ -1724,7 +1710,7 @@ export function viewFrame(
1724
1710
  children: [
1725
1711
  ...(head ? [viewHead(title, els, on)] : []),
1726
1712
  ...(Array.isArray(body) ? body : [body]),
1727
- text(keys.map((k) => `${k.key} ${k.label}`).join(' · '), { dimColor: true }),
1713
+ text(keys.map((k) => `${k.key}: ${k.label}`).join(' · '), { dimColor: true }),
1728
1714
  ],
1729
1715
  });
1730
1716
  }
@@ -1,76 +1,24 @@
1
- // The lane agents' characters, redrawn (docs/specs/27-the-mod-redesigned.md, UI-11): 12 by 12
1
+ // The lane agents' characters, redrawn (docs/specs/27-the-mod-redesigned.md, UI-11): 8 by 8
2
2
  // pixels, each lane its own shape as well as its tint so lanes read apart without colour, the lead's
3
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
4
  // event. Every frame is composed from layers (a head by shape, a face, a body, a prop), so each
5
5
  // shape gets every pose. Pure: the mod draws the grids as half-block cells or SVG.
6
6
 
7
- const SIZE = 12;
7
+ /** Pixels a side: four terminal rows of half-blocks, eight columns. */
8
+ export const SIZE = 8;
8
9
 
9
- /** Each head, rows 0 to 6: H the tint, D its shade, K gold, P grey metal. */
10
+ /**
11
+ * Each head, rows 0 to 3, the face in columns 1 to 5 (row 0 what's on top of it): H the tint, D its
12
+ * shade, K gold.
13
+ */
10
14
  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
- ],
15
+ crown: ['.K.K.K..', '.KKKKK..', '.HHHHH..', '.HHHHH..'],
16
+ antenna: ['...K....', '.HHHHH..', '.HHHHH..', '.HHHHH..'],
17
+ cat: ['.D...D..', '.DHHHD..', '.HHHHH..', '.HHHHH..'],
18
+ cap: ['.DDDD...', '.DDDDDD.', '.HHHHH..', '.HHHHH..'],
19
+ bunny: ['..D.D...', '..D.D...', '.HHHHH..', '.HHHHH..'],
20
+ bolts: ['........', '.HHHHH..', 'DHHHHHD.', '.DDDDD..'],
21
+ wizard: ['...D....', 'DDDDDDD.', '.HHHHH..', '.HHHHH..'],
74
22
  };
75
23
  /** The lanes' shapes, tints and marks: six shapes first, then a mark on each, so lanes differ without colour. */
76
24
  const SHAPES = ['antenna', 'cat', 'cap', 'bunny', 'bolts', 'wizard'];
@@ -129,8 +77,9 @@ export function characterOf(lane, lanes) {
129
77
  return charactersOf(lanes.includes(lane) ? lanes : [...lanes, lane])[lane];
130
78
  }
131
79
 
132
- /** The body, rows 7 to 11, arms in columns 3 and 8. */
133
- const BODY = ['....DDDD....', '...HHHHHH...', '...HHHHHH...', '....H..H....', '...HH..HH...'];
80
+ /** The body, rows 4 to 7: a neck, arms out in columns 1 and 5, legs. */
81
+ const BODY = ['..DDD...', '.HHHHH..', '..HHH...', '..H.H...'];
82
+ const BODY_TOP = 4;
134
83
 
135
84
  /** Each pose and move: its frames, how long each shows, and whether it loops. */
136
85
  export const POSES = {
@@ -174,118 +123,95 @@ const put = (grid, points, ch) => {
174
123
  };
175
124
  const clear = (grid, points) => put(grid, points, '.');
176
125
 
177
- /** The eyes and mouth: where the eyes look, and the face's mood. */
126
+ /** The eyes and mouth: where the eyes look, and the face's mood. Eyes sit in columns 2 and 4. */
178
127
  function face(grid, kind, dx = 0, dy = 0) {
179
128
  const at = (points) => points.map(([y, x]) => [y + dy, x + dx]);
180
129
  const eyes = {
181
130
  open: [
182
- [4, 4],
183
- [4, 7],
131
+ [2, 2],
132
+ [2, 4],
184
133
  ],
185
134
  down: [
186
- [5, 4],
187
- [5, 7],
135
+ [3, 2],
136
+ [3, 4],
188
137
  ],
189
138
  up: [
190
- [3, 4],
191
- [3, 7],
139
+ [2, 1],
140
+ [2, 3],
192
141
  ],
193
142
  scan: [
194
- [5, 5],
195
- [5, 8],
143
+ [3, 3],
144
+ [3, 5],
196
145
  ],
197
146
  };
198
- if (kind === 'closed') return put(grid, at(eyes.open), 'L');
147
+ if (kind === 'closed') return put(grid, at(eyes.down), 'L');
199
148
  if (kind === 'crossed') return put(grid, at(eyes.open), 'X');
200
149
  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
- );
150
+ if (kind === 'happy') put(grid, at([[3, 3]]), 'E');
210
151
  if (kind === 'oops') {
211
- put(grid, at([[5, 6]]), 'E');
212
- put(grid, at([[3, 9]]), 'B');
152
+ put(grid, at([[3, 3]]), 'E');
153
+ put(grid, at([[1, 6]]), 'B');
213
154
  }
214
155
  }
215
156
 
216
157
  /** A lane's mark, worn in every pose: glasses round the eyes, a scarf at the neck, a belt. */
217
158
  function wear(grid, mark, mood, dx = 0, dy = 0) {
218
159
  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');
160
+ const eyes = mood === 'down' || mood === 'scan' || mood === 'closed' ? 3 : 2;
161
+ if (mark === 'glasses') put(grid, at([1, 3, 5].map((x) => [eyes, x])), 'P');
162
+ if (mark === 'scarf') put(grid, at([1, 2, 3, 4, 5].map((x) => [4, x])), 'S');
163
+ if (mark === 'belt') put(grid, at([2, 3, 4].map((x) => [6, x])), 'P');
233
164
  }
234
165
 
235
- /** A frame as a grid of letters, before colour. */
166
+ /** A frame as a grid of letters, before colour. Props sit in columns 6 and 7. */
236
167
  function compose({ shape, mark = null }, pose, frame) {
237
168
  const g = blank();
238
169
  const head = HEADS[shape] ?? HEADS.antenna;
239
170
  const whole = (dx, dy, mood, body = BODY) => {
240
171
  paint(g, head, { dx, dy });
241
- paint(g, body, { top: 7, dx, dy });
172
+ paint(g, body, { top: BODY_TOP, dx, dy });
242
173
  face(g, mood, dx, dy);
243
174
  wear(g, mark, mood, dx, dy);
244
175
  };
245
176
  const f = frame % (POSES[pose]?.frames ?? 1);
246
177
  switch (pose) {
247
178
  case 'writing': {
248
- // At a sheet of paper on the right, the pencil moving and the lines filling.
179
+ // At a sheet of paper on the right, the pencil moving and a line filling.
249
180
  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');
181
+ paint(g, ['WW', 'WW'], { top: 6, dx: 6 });
182
+ put(g, [[5, [6, 7, 7, 6][f]]], 'K');
255
183
  put(
256
184
  g,
257
185
  [
258
- [10, 9],
259
- [10, 10],
260
- [10, 11],
261
- ].slice(0, f),
186
+ [6, 6],
187
+ [6, 7],
188
+ ].slice(0, [0, 0, 1, 2][f]),
262
189
  'E',
263
190
  );
264
191
  break;
265
192
  }
266
193
  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');
194
+ // Turning a crank on the right, its bar spinning a quarter a frame, bobbing as it works.
195
+ whole(0, f % 2, 'open');
270
196
  const spin = [
271
197
  ['.P.', '.K.', '.P.'],
272
198
  ['..P', '.K.', 'P..'],
273
199
  ['...', 'PKP', '...'],
274
200
  ['P..', '.K.', '..P'],
275
201
  ];
276
- paint(g, spin[f], { top: 7 });
202
+ paint(g, spin[f], { top: 4, dx: 5 });
277
203
  break;
278
204
  }
279
205
  case 'reading': {
280
206
  // A book held open, eyes down, a page turning.
281
207
  whole(0, 0, f === 1 ? 'scan' : 'down');
282
- paint(g, ['WWWDDWWW', 'WWWDDWWW'], { top: 8, dx: 2 });
208
+ paint(g, ['WWDWW', 'WWDWW'], { top: 5, dx: 1 });
283
209
  if (f === 2)
284
210
  put(
285
211
  g,
286
212
  [
287
- [7, 7],
288
- [7, 8],
213
+ [4, 4],
214
+ [4, 5],
289
215
  ],
290
216
  'W',
291
217
  );
@@ -293,8 +219,8 @@ function compose({ shape, mark = null }, pose, frame) {
293
219
  put(
294
220
  g,
295
221
  [
296
- [7, 3],
297
- [7, 4],
222
+ [4, 1],
223
+ [4, 2],
298
224
  ],
299
225
  'W',
300
226
  );
@@ -303,47 +229,39 @@ function compose({ shape, mark = null }, pose, frame) {
303
229
  case 'thinking': {
304
230
  // A hand to the chin, eyes up, a thought rising.
305
231
  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 });
232
+ put(g, [[4, 5]], 'H');
233
+ if (f >= 1) put(g, [[2, 6]], 'S');
234
+ if (f >= 2) put(g, [[1, 7]], 'S');
235
+ if (f >= 3)
236
+ put(
237
+ g,
238
+ [
239
+ [0, 6],
240
+ [0, 7],
241
+ ],
242
+ 'S',
243
+ );
319
244
  break;
320
245
  }
321
246
  case 'waiting': {
322
- // A raised hand.
247
+ // A hand raised.
323
248
  whole(0, 0, 'open');
324
- clear(g, [[9, 8]]);
249
+ clear(g, [[5, 5]]);
325
250
  put(
326
251
  g,
327
- [
328
- [8, 9],
329
- [7, 9],
330
- [6, 9],
331
- [5, 9],
332
- [4, 9],
333
- ],
252
+ [1, 2, 3, 4].map((y) => [y, 6]),
334
253
  'H',
335
254
  );
336
255
  break;
337
256
  }
338
257
  case 'quiet': {
339
- // Still, looking on, a trailing ellipsis.
258
+ // Still, looking on, a trailing pair of dots.
340
259
  whole(0, 0, 'open');
341
260
  put(
342
261
  g,
343
262
  [
344
- [1, 9],
345
- [1, 10],
346
- [1, 11],
263
+ [1, 6],
264
+ [1, 7],
347
265
  ],
348
266
  'S',
349
267
  );
@@ -351,27 +269,34 @@ function compose({ shape, mark = null }, pose, frame) {
351
269
  }
352
270
  case 'stalled': {
353
271
  // Slumped: the head dropped and tilted, eyes crossed.
354
- paint(g, BODY, { top: 7 });
272
+ paint(g, BODY, { top: BODY_TOP });
355
273
  paint(g, head, { dx: 1, dy: 1 });
356
274
  face(g, 'crossed', 1, 1);
357
275
  wear(g, mark, 'open', 1, 1);
358
276
  break;
359
277
  }
360
278
  case 'resting': {
361
- // Eyes closed, a Z.
279
+ // Asleep: eyes shut, and a z rising.
362
280
  whole(0, 0, 'closed');
363
- paint(g, ['SSS', '.S.', 'SSS'], { top: 0, dx: 9 });
281
+ put(
282
+ g,
283
+ [
284
+ [2, 6],
285
+ [0, 7],
286
+ ],
287
+ 'S',
288
+ );
364
289
  break;
365
290
  }
366
291
  case 'arriving': {
367
292
  // Dropping into the lane.
368
- whole(0, [-8, -4, -1, 0][f], 'open');
293
+ whole(0, [-6, -3, -1, 0][f], 'open');
369
294
  if (f < 2)
370
295
  put(
371
296
  g,
372
297
  [
373
- [0, 2],
374
- [0, 9],
298
+ [0, 0],
299
+ [0, 6],
375
300
  ],
376
301
  'S',
377
302
  );
@@ -382,17 +307,16 @@ function compose({ shape, mark = null }, pose, frame) {
382
307
  whole(0, 0, f === 3 ? 'happy' : 'open');
383
308
  const paper = [
384
309
  [
385
- [8, 9],
386
- [8, 10],
310
+ [5, 6],
311
+ [5, 7],
387
312
  ],
388
313
  [
389
- [6, 10],
390
- [6, 11],
314
+ [3, 6],
315
+ [3, 7],
391
316
  ],
392
- [[4, 11]],
317
+ [[1, 7]],
393
318
  [],
394
319
  ][f];
395
- if (f < 2) put(g, [[8, 9]], 'H');
396
320
  put(g, paper, 'W');
397
321
  break;
398
322
  }
@@ -403,18 +327,16 @@ function compose({ shape, mark = null }, pose, frame) {
403
327
  }
404
328
  case 'merged': {
405
329
  // 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));
330
+ const up = [0, -1, -1, 0][f];
331
+ const body = BODY.map((r, i) => (i === 1 ? '..HHH...' : r));
408
332
  whole(0, up, 'happy', body);
409
333
  put(
410
334
  g,
411
335
  [
412
- [7 + up, 2],
413
- [6 + up, 2],
414
- [5 + up, 2],
415
- [7 + up, 9],
416
- [6 + up, 9],
417
- [5 + up, 9],
336
+ [4 + up, 0],
337
+ [3 + up, 0],
338
+ [4 + up, 6],
339
+ [3 + up, 6],
418
340
  ],
419
341
  'H',
420
342
  );
@@ -422,12 +344,12 @@ function compose({ shape, mark = null }, pose, frame) {
422
344
  g,
423
345
  f % 2
424
346
  ? [
425
- [0, 1],
426
- [2, 11],
347
+ [0, 0],
348
+ [1, 7],
427
349
  ]
428
350
  : [
429
351
  [1, 0],
430
- [0, 10],
352
+ [0, 7],
431
353
  ],
432
354
  'K',
433
355
  );
@@ -445,7 +367,7 @@ const shade = (rgb, by) =>
445
367
  Math.round((rgb & 0xff) * by);
446
368
 
447
369
  /**
448
- * A pose's frame as a grid of colours (null for none), 12 by 12. Resting is drawn dimmed. With
370
+ * A pose's frame as a grid of colours (null for none), SIZE by SIZE. Resting is drawn dimmed. With
449
371
  * motion off, a loop shows its first frame and a move its last.
450
372
  */
451
373
  export function characterFrame(pose, frame, character, { motion = 'while-active' } = {}) {
@@ -9,7 +9,7 @@ const hex = (rgb) => `#${rgb.toString(16).padStart(6, '0')}`;
9
9
  /** Each instance's timer and frame, by its surface (the same object across its calls). */
10
10
  const running = new WeakMap();
11
11
 
12
- /** A 12 by 12 grid as six rows of half-blocks: a run of cells sharing colours is one Text. */
12
+ /** A character's grid as half-block rows, two pixels a cell: a run of cells sharing colours is one Text. */
13
13
  export function halfBlocks(grid, { Box, Text }) {
14
14
  const rows = [];
15
15
  for (let y = 0; y < grid.length; y += 2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warren-dean/code-kit",
3
- "version": "0.26.1",
3
+ "version": "0.26.2",
4
4
  "description": "Keeps AI coding agents inside your project's rules: lanes, layer rules, protected paths and proof before finish, enforced by Claude Code hooks and in CI",
5
5
  "license": "MIT",
6
6
  "author": "Warren Langeveldt",