@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.
Files changed (41) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +24 -0
  4. package/README.md +70 -59
  5. package/bin/code-kit.mjs +113 -3
  6. package/hooks/act.mjs +96 -0
  7. package/hooks/guard-bash.mjs +27 -1
  8. package/hooks/hooks.json +42 -1
  9. package/hooks/lib/config.mjs +26 -2
  10. package/hooks/lib/events.mjs +626 -0
  11. package/hooks/lib/harness.mjs +8 -0
  12. package/hooks/lib/instructions.mjs +1 -1
  13. package/hooks/lib/next.mjs +22 -0
  14. package/hooks/lib/plan.mjs +45 -9
  15. package/hooks/lib/publish.mjs +144 -0
  16. package/hooks/lib/queue.mjs +36 -0
  17. package/hooks/lib/snapshot.mjs +33 -3
  18. package/hooks/lib/storymap.mjs +54 -17
  19. package/hooks/lib/timeline.mjs +94 -44
  20. package/hooks/lib/worktrees.mjs +19 -11
  21. package/hooks/mod/art.mjs +0 -81
  22. package/hooks/mod/board.mjs +1743 -0
  23. package/hooks/mod/characters.mjs +516 -0
  24. package/hooks/mod/loop.mjs +17 -3
  25. package/hooks/mod/mission.mjs +2 -93
  26. package/hooks/mod/panes.mjs +111 -422
  27. package/hooks/mod/register.mjs +482 -184
  28. package/hooks/mod/surface/character.mjs +79 -0
  29. package/hooks/mod/surface/clock.mjs +37 -0
  30. package/hooks/mod/surface/rail.mjs +33 -0
  31. package/hooks/mod/view.mjs +30 -602
  32. package/hooks/session.mjs +14 -11
  33. package/package.json +2 -1
  34. package/skills/decide/SKILL.md +1 -1
  35. package/skills/dispatch/SKILL.md +1 -1
  36. package/skills/init/SKILL.md +1 -1
  37. package/skills/next/SKILL.md +1 -1
  38. package/skills/review/SKILL.md +1 -1
  39. package/templates/agent.md +1 -1
  40. package/templates/claude-md.md +2 -2
  41. package/hooks/mod/register.test.ts +0 -4932
@@ -19,6 +19,7 @@ import {
19
19
  } from 'node:fs';
20
20
  import { tmpdir } from 'node:os';
21
21
  import { basename, dirname, join } from 'node:path';
22
+ import { pruneLogs } from './events.mjs';
22
23
  import { laneClaims } from './laneclaims.mjs';
23
24
  import { storyOfBranch } from './teamfacts.mjs';
24
25
 
@@ -45,14 +46,16 @@ const alive = (pid) => {
45
46
  }
46
47
  };
47
48
 
48
- /** The base branch's ref a worktree's branch is merged into: the first protected branch, or its remote. */
49
- export function baseRef(root, config) {
49
+ /**
50
+ * The base branch's refs a worktree's branch is merged into: the first protected branch here and on its
51
+ * remote, each that exists. A local base can fall weeks behind the remote's where the base only moves
52
+ * through pull requests, so a branch merged into either counts as merged.
53
+ */
54
+ export function baseRefs(root, config) {
50
55
  const name = config.branches?.protected?.[0];
51
- if (!name) return null;
52
- return (
53
- [name, `origin/${name}`].find(
54
- (r) => git(root, 'rev-parse', '--verify', '--quiet', r).status === 0,
55
- ) ?? null
56
+ if (!name) return [];
57
+ return [name, `origin/${name}`].filter(
58
+ (r) => git(root, 'rev-parse', '--verify', '--quiet', r).status === 0,
56
59
  );
57
60
  }
58
61
 
@@ -80,7 +83,7 @@ export function worktrees(root, config, now = Date.now()) {
80
83
  if (list.status !== 0) return [];
81
84
  const main = list.stdout.split('\n\n')[0];
82
85
  const mainPath = /^worktree (.+)$/m.exec(main)?.[1] ?? root;
83
- const from = baseRef(root, config);
86
+ const from = baseRefs(root, config);
84
87
  const claims = laneClaims(mainPath, now).filter((c) => !c.stale);
85
88
  const agents = real(join(mainPath, WORKTREES_DIR));
86
89
  const temp = real(tmpdir());
@@ -103,9 +106,11 @@ export function worktrees(root, config, now = Date.now()) {
103
106
  const story = branch ? storyOfBranch(branch) : null;
104
107
  const merged = Boolean(
105
108
  branch &&
106
- from &&
107
- spawnSync('git', ['merge-base', '--is-ancestor', branch, from], { cwd: root }).status ===
108
- 0 &&
109
+ from.some(
110
+ (ref) =>
111
+ spawnSync('git', ['merge-base', '--is-ancestor', branch, ref], { cwd: root }).status ===
112
+ 0,
113
+ ) &&
109
114
  hasOwnCommits(root, branch),
110
115
  );
111
116
  // Read only where it decides anything: an unmerged worktree stays whatever it holds.
@@ -246,6 +251,9 @@ export function pruneWorktrees(root, config, now = Date.now()) {
246
251
  rmSync(p, { recursive: true, force: true });
247
252
  removed.push(`${p.slice(root.length + 1)} (left behind, not a worktree)`);
248
253
  }
254
+ // DUR-6: the event logs of stories merged more than 30 days ago go with them.
255
+ for (const base of baseRefs(root, config))
256
+ for (const story of pruneLogs(root, { base, now })) removed.push(`${story}'s event log`);
249
257
  return { removed, kept };
250
258
  }
251
259
 
package/hooks/mod/art.mjs CHANGED
@@ -5,49 +5,6 @@
5
5
 
6
6
  // --- the characters (VIEW-3) ---------------------------------------------------------------------
7
7
 
8
- /** Each pose, 6 by 6 pixels: H the lane's tint, E eyes, X stalled eyes, L closed eyes, C a crown. */
9
- const POSES = {
10
- working: [
11
- ['..HH..', '.HEEH.', '..HH..', '.HHHH.', 'H.HH.H', '.H..H.'],
12
- ['..HH..', '.HEEH.', '..HH..', 'HHHHHH', '..HH..', '..HH..'],
13
- ],
14
- waiting: [['..HH.H', '.HEEHH', '..HH..', '.HHH..', '..HH..', '.H..H.']],
15
- quiet: [['......', '..HH..', '.HLLH.', '..HH..', '.HHHH.', '.H..H.']],
16
- stalled: [['..HH..', '.HXXH.', '..HH..', '.HHHH.', '..HH..', '.H..H.']],
17
- done: [['H.HH.H', 'HHEEHH', '..HH..', '..HH..', '..HH..', '.H..H.']],
18
- idle: [['......', '..HH..', '.HLLH.', '..HH..', '.HHHH.', '.H..H.']],
19
- };
20
- /** What a pose reads as without its picture, and in words. */
21
- export const POSE_GLYPH = {
22
- working: '⚙',
23
- waiting: '?',
24
- quiet: '…',
25
- stalled: '✗',
26
- done: '✓',
27
- idle: '·',
28
- };
29
-
30
- /** Each lane's tint, fixed by its place in the config so the person learns them; the lead's is gold. */
31
- const TINTS = [0x4aa3ff, 0x5cc85c, 0xd070e0, 0x40c8c8, 0xff9a40, 0xff6070, 0xa0a0ff];
32
- export function tintOf(lane, lanes) {
33
- if (lane === 'lead') return 0xd8a840;
34
- const i = lanes.filter((l) => l !== 'lead').indexOf(lane);
35
- return TINTS[(i < 0 ? 0 : i) % TINTS.length];
36
- }
37
-
38
- const dim = (rgb) =>
39
- (((rgb >> 16) & 0xff) >> 1) * 0x10000 + (((rgb >> 8) & 0xff) >> 1) * 0x100 + ((rgb & 0xff) >> 1);
40
-
41
- /** The pose's frame as a grid of colours (null for none), the lead crowned. */
42
- export function sprite(pose, frame, tint, { lead = false } = {}) {
43
- const frames = POSES[pose] ?? POSES.idle;
44
- const rows = frames[frame % frames.length].map((r) => [...r]);
45
- if (lead) rows[0] = [...'C.CC.C'];
46
- const body = pose === 'quiet' || pose === 'idle' ? dim(tint) : tint;
47
- const colour = { H: body, E: 0x202020, X: 0xff3030, L: 0x707070, C: 0xffcc00 };
48
- return rows.map((r) => r.map((c) => colour[c] ?? null));
49
- }
50
-
51
8
  const DEFAULT = 0x01000000;
52
9
  const B64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
53
10
  function base64(bytes) {
@@ -84,44 +41,6 @@ export function rasterCells(grid) {
84
41
 
85
42
  const hex = (rgb) => `#${rgb.toString(16).padStart(6, '0')}`;
86
43
 
87
- /** A sprite as SVG for Desktop, the working pose's frames alternating (SMIL), 4 px a pixel. */
88
- export function spriteSvg(pose, tint, { lead = false } = {}) {
89
- const frames = (POSES[pose] ?? POSES.idle).map((_, f) => sprite(pose, f, tint, { lead }));
90
- const rects = (grid) =>
91
- grid
92
- .flatMap((row, y) =>
93
- row.map((c, x) =>
94
- c === null
95
- ? ''
96
- : `<rect x="${x * 4}" y="${y * 4}" width="4" height="4" fill="${hex(c)}"/>`,
97
- ),
98
- )
99
- .join('');
100
- const groups = frames.map((g, f) =>
101
- frames.length > 1
102
- ? `<g visibility="${f ? 'hidden' : 'visible'}"><animate attributeName="visibility" values="${f ? 'hidden;visible' : 'visible;hidden'}" dur="0.8s" repeatCount="indefinite" calcMode="discrete"/>${rects(g)}</g>`
103
- : `<g>${rects(g)}</g>`,
104
- );
105
- return `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" shape-rendering="crispEdges">${groups.join('')}</svg>`;
106
- }
107
-
108
- /**
109
- * A lane's pose (VIEW-3): stalled when flagged or quiet past the restart time, waiting while a call
110
- * of its is held, its request is open or its story waits on the person's answer, working while its agent is at work, quiet when it has
111
- * gone quiet, done once its branch is finished, idle otherwise.
112
- */
113
- export function poseOf(
114
- lane,
115
- { live = null, waiting = false, flagged = false, shown = lane.state } = {},
116
- ) {
117
- if (flagged || live?.level === 'stalled') return 'stalled';
118
- if (waiting || shown === 'waiting on you') return 'waiting';
119
- if (live?.level === 'quiet') return 'quiet';
120
- if (lane.active) return 'working';
121
- if (['in review', 'queued'].includes(shown)) return 'done';
122
- return 'idle';
123
- }
124
-
125
44
  // --- the timelines (VIEW-2) ----------------------------------------------------------------------
126
45
 
127
46
  /** Each cell kind's glyph and colour: the glyph alone reads in a terminal without colour. */