@warren-dean/code-kit 0.24.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.
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 +25 -0
  4. package/README.md +74 -60
  5. package/bin/code-kit.mjs +188 -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/ci.mjs +407 -0
  10. package/hooks/lib/config.mjs +26 -2
  11. package/hooks/lib/events.mjs +626 -0
  12. package/hooks/lib/harness.mjs +8 -0
  13. package/hooks/lib/instructions.mjs +1 -1
  14. package/hooks/lib/next.mjs +31 -0
  15. package/hooks/lib/plan.mjs +17 -2
  16. package/hooks/lib/publish.mjs +144 -0
  17. package/hooks/lib/queue.mjs +36 -0
  18. package/hooks/lib/snapshot.mjs +33 -3
  19. package/hooks/lib/worktrees.mjs +19 -11
  20. package/hooks/mod/art.mjs +0 -81
  21. package/hooks/mod/board.mjs +1743 -0
  22. package/hooks/mod/characters.mjs +516 -0
  23. package/hooks/mod/loop.mjs +17 -3
  24. package/hooks/mod/mission.mjs +2 -93
  25. package/hooks/mod/panes.mjs +111 -422
  26. package/hooks/mod/register.mjs +473 -182
  27. package/hooks/mod/surface/character.mjs +79 -0
  28. package/hooks/mod/surface/clock.mjs +37 -0
  29. package/hooks/mod/surface/rail.mjs +33 -0
  30. package/hooks/mod/view.mjs +30 -602
  31. package/hooks/session.mjs +14 -11
  32. package/package.json +2 -1
  33. package/skills/decide/SKILL.md +1 -1
  34. package/skills/dispatch/SKILL.md +1 -1
  35. package/skills/init/SKILL.md +4 -3
  36. package/skills/next/SKILL.md +1 -1
  37. package/skills/review/SKILL.md +1 -1
  38. package/templates/agent.md +1 -1
  39. package/templates/claude-md.md +3 -1
  40. package/templates/github-workflow.yml +10 -3
  41. package/hooks/mod/register.test.ts +0 -4932
@@ -1,6 +1,7 @@
1
- // Panes v2 (docs/specs/11-panes.md): the Lanes pane's frame. A counts header, tabs, what needs the
2
- // person, the tab's body and the keys, as pure functions of what the mod already holds. The Lanes
3
- // tab's body is view.mjs's lanesPane; the Queue and Usage tabs reuse its sections.
1
+ // The full views the pane opens over its panels (docs/specs/27-the-mod-redesigned.md, UI-6): a story's
2
+ // drill-down (VIEW-7), the Trail (TRAIL-1, spec 10's map), the Code map (MAP-1 to MAP-5), the
3
+ // decisions with their lineage (DECIDE-2) and the Journal (JOURNAL-1), and a lane's acts and liveness,
4
+ // as pure functions of what the mod already holds.
4
5
  import { trailRows as trailRowsDrawn, trailSvg } from './trail.mjs';
5
6
  import {
6
7
  MAP_LEGEND,
@@ -12,67 +13,7 @@ import {
12
13
  mapSvg,
13
14
  neighboursOf,
14
15
  } from './codemap.mjs';
15
- import {
16
- NOT_CODE_KIT,
17
- STATE_COLOR,
18
- ago,
19
- lanesPane,
20
- queueSection,
21
- shownState,
22
- tokens,
23
- usageSection,
24
- } from './view.mjs';
25
-
26
- export const TABS = [
27
- { id: 'lanes', label: 'Lanes', hotkey: '1' },
28
- { id: 'decisions', label: 'Decisions', hotkey: '2' },
29
- { id: 'journal', label: 'Journal', hotkey: '3' },
30
- { id: 'code', label: 'Code map', hotkey: '4' },
31
- { id: 'map', label: 'Trail', hotkey: '5' },
32
- { id: 'queue', label: 'Queue', hotkey: '6' },
33
- { id: 'usage', label: 'Usage', hotkey: '7' },
34
- ];
35
-
36
- /** The pane's own state, kept by the mod between draws. */
37
- export const DEFAULT_UI = { tab: 'lanes', selected: null, filter: null, search: '', cell: null };
38
-
39
- /** The glyph each state carries besides its colour (spec 11's quality target). */
40
- const GLYPH = {
41
- building: '●',
42
- working: '▶',
43
- 'in review': '◐',
44
- queued: '◆',
45
- 'sent back': '↩',
46
- 'waiting on you': '?',
47
- blocked: '■',
48
- idle: '·',
49
- ready: '○',
50
- merged: '✓',
51
- };
52
-
53
- /**
54
- * VIEW-1: the stories counted by state, in the order a build moves through them, only those there
55
- * are: [{ state, n, glyph }]. Lanes give building, in review, queued, sent back and blocked; the plan
56
- * gives ready and merged.
57
- */
58
- export function countsOf(state, queue = []) {
59
- if (state?.kind !== 'ok') return [];
60
- const lanes = state.lanes.map((l) => shownState(l, queue));
61
- const n = (s) => lanes.filter((x) => x === s).length;
62
- const counts = [
63
- ['building', n('building')],
64
- ['working', n('working')],
65
- ['in review', n('in review')],
66
- ['queued', n('queued')],
67
- ['sent back', n('sent back')],
68
- ['waiting on you', n('waiting on you')],
69
- ['blocked', n('blocked')],
70
- ['ready', state.ready.length],
71
- ['merged', (state.stories ?? []).filter((s) => s.state === 'done').length],
72
- ['idle', n('idle')],
73
- ];
74
- return counts.filter(([, k]) => k > 0).map(([s, k]) => ({ state: s, n: k, glyph: GLYPH[s] }));
75
- }
16
+ import { ago, shownState, tokens } from './view.mjs';
76
17
 
77
18
  /** A lane's stories in plan order. */
78
19
  export const laneStories = (lane, state) =>
@@ -85,27 +26,6 @@ export function storyToOpen(lane, state) {
85
26
  return own.find((s) => s.state !== 'done') ?? own.at(-1) ?? null;
86
27
  }
87
28
 
88
- /** VIEW-1: how much of the plan is done, as words: "3 of 25 stories done". */
89
- export function planProgress(state) {
90
- const all = state?.stories ?? [];
91
- return all.length
92
- ? `${all.filter((s) => s.state === 'done').length} of ${all.length} stories done`
93
- : null;
94
- }
95
-
96
- /** VIEW-6's letters for the band's actions, as the needs-you strip draws them. */
97
- const LETTER = {
98
- approve: 'a',
99
- approveHeld: 'a',
100
- review: 'r',
101
- merge: 'm',
102
- mergeQueue: 'm',
103
- go: 'g',
104
- keepGoing: 'g',
105
- pause: 'p',
106
- resume: 'p',
107
- };
108
-
109
29
  /** The selected lane's own acts (VIEW-6), as its state allows them: [{ id, label, hotkey }]. */
110
30
  export function laneActions(lane, { queue = [], held = [], requests = [] } = {}) {
111
31
  if (!lane) return [];
@@ -128,296 +48,6 @@ export function laneActions(lane, { queue = [], held = [], requests = [] } = {})
128
48
  return acts;
129
49
  }
130
50
 
131
- /**
132
- * The Lanes pane (spec 11). `view` holds what to draw: { state, usage, plan, loop, needs, live,
133
- * held, requests, ui, placement }; `needs` are the band's lines (VIEW-5). `on` acts: onTab(id),
134
- * onFilter(state), onMove(step), onNeed(id, line), onLane(id, lane), onSearch(text).
135
- */
136
- export function lanesFrame(view, els, on) {
137
- const { Box, Text, Button, Input } = els;
138
- const text = (value, style = {}) => Text({ ...style, children: [value] });
139
- const { state, ui = DEFAULT_UI, loop = null, plan = null } = view;
140
- if (!state || state.kind === 'none') return text(NOT_CODE_KIT, { dimColor: true });
141
- if (state.kind === 'invalid')
142
- return text('The config is invalid: run code-kit check.', { color: 'red' });
143
- const queue = loop?.queue ?? [];
144
-
145
- // VIEW-1: the counts, each a filter; the loop's state and the plan's use.
146
- const loopWord =
147
- loop?.state === 'off'
148
- ? 'loop off'
149
- : loop?.state === 'paused'
150
- ? 'loop paused'
151
- : loop?.state === 'done'
152
- ? 'milestone done'
153
- : 'loop on';
154
- const header = Box({
155
- key: 'header',
156
- flexDirection: 'row',
157
- columnGap: 2,
158
- flexWrap: 'wrap',
159
- children: [
160
- ...countsOf(state, queue).map((c) =>
161
- Button({
162
- key: `count-${c.state}`,
163
- label: `${c.glyph} ${c.n} ${c.state}`,
164
- plain: true,
165
- ...(ui.filter && ui.filter !== c.state ? { dimColor: true } : {}),
166
- onPress: () => on.onFilter(c.state),
167
- }),
168
- ),
169
- ...(planProgress(state) ? [text(planProgress(state), { dimColor: true })] : []),
170
- text(loopWord, { color: loop?.state === 'paused' ? 'yellow' : 'green' }),
171
- ...(plan?.percent != null
172
- ? [
173
- text(`plan ${plan.percent}%`, {
174
- color: plan.paused ? 'red' : undefined,
175
- dimColor: !plan.paused,
176
- }),
177
- ]
178
- : []),
179
- ],
180
- });
181
-
182
- // VIEW-5: what waits on the person, pinned at the top with VIEW-6's letters.
183
- const used = new Set();
184
- const needs = (view.needs ?? []).map((line) => {
185
- const actions = line.actions.filter((a) => a.id !== 'lanes');
186
- return Box({
187
- key: `need-${line.kind}`,
188
- flexDirection: 'row',
189
- columnGap: 2,
190
- children: [
191
- text('!', { color: 'yellow', bold: true }),
192
- text(line.text, { bold: true }),
193
- // DECIDE-2: which story it's for.
194
- ...(line.context ? [text(line.context, { dimColor: true, wrap: 'truncate-end' })] : []),
195
- ...actions.map((a) => {
196
- const letter = LETTER[a.id] && !used.has(LETTER[a.id]) ? LETTER[a.id] : undefined;
197
- if (letter) used.add(letter);
198
- return Button({
199
- key: `need-${a.id}`,
200
- label: a.label,
201
- ...(letter ? { hotkey: letter } : {}),
202
- variant: 'primary',
203
- onPress: () => on.onNeed(a.id, line),
204
- });
205
- }),
206
- ],
207
- });
208
- });
209
-
210
- // VIEW-8: inline, the header, what needs the person and one line per lane.
211
- if (view.placement === 'inline')
212
- return Box({
213
- flexDirection: 'column',
214
- children: [
215
- header,
216
- ...needs,
217
- ...state.lanes.map((l) => {
218
- const live = view.live?.[l.name];
219
- const s = shownState(l, queue);
220
- return Box({
221
- key: `lane-${l.name}`,
222
- flexDirection: 'row',
223
- columnGap: 1,
224
- children: [
225
- text(l.name, { bold: true }),
226
- text(s, STATE_COLOR[s] ? { color: STATE_COLOR[s] } : { dimColor: true }),
227
- ...(l.story ? [text(l.story.id, { dimColor: true })] : []),
228
- ...(live
229
- ? [
230
- text(`${live.tool} · ${live.ago}`, {
231
- wrap: 'truncate-end',
232
- ...(live.level === 'stalled'
233
- ? { color: 'red' }
234
- : live.level === 'quiet'
235
- ? { color: 'yellow' }
236
- : { dimColor: true }),
237
- }),
238
- ]
239
- : []),
240
- ],
241
- });
242
- }),
243
- ],
244
- });
245
-
246
- // VIEW-6: the tabs, on 1 to 4.
247
- const tabs = Box({
248
- key: 'tabs',
249
- flexDirection: 'row',
250
- columnGap: 1,
251
- children: TABS.map((t) =>
252
- Button({
253
- key: `tab-${t.id}`,
254
- label: t.label,
255
- hotkey: t.hotkey,
256
- ...(ui.tab === t.id ? { variant: 'primary' } : { dimColor: true }),
257
- onPress: () => on.onTab(t.id),
258
- }),
259
- ),
260
- });
261
-
262
- // VIEW-7: a story's drill-down takes the tabs' place; Back (b, or Escape) returns.
263
- if (ui.story && view.story)
264
- return Box({
265
- flexDirection: 'column',
266
- rowGap: 1,
267
- children: [
268
- header,
269
- ...(needs.length ? [Box({ key: 'needs', flexDirection: 'column', children: needs })] : []),
270
- storyPane(view.story, els, on.story),
271
- ],
272
- });
273
-
274
- const selected = state.lanes.find((l) => l.name === ui.selected) ?? null;
275
- const body =
276
- ui.tab === 'decisions'
277
- ? decisionsTab(view.cards ?? [], ui, els, on)
278
- : ui.tab === 'journal'
279
- ? journalTab(view.journal ?? [], els, view.now)
280
- : ui.tab === 'code'
281
- ? codeTab(view, els, on)
282
- : ui.tab === 'map'
283
- ? mapTab(view.status, ui.cell, els, on, view.trail, {
284
- surface: view.surface,
285
- columns: view.columns,
286
- })
287
- : ui.tab === 'queue'
288
- ? queueSection(loop, text, Box)
289
- : ui.tab === 'usage'
290
- ? usageSection(view.usage, plan, text, Box)
291
- : [
292
- lanesPane(state, els, view.usage, plan, loop, {
293
- filter: ui.filter,
294
- search: ui.search,
295
- selected: ui.selected,
296
- live: view.live ?? {},
297
- art: view.art ?? null,
298
- detail: selected
299
- ? {
300
- agent: selected.agent ?? null,
301
- owns: view.paths?.[selected.name] ?? [],
302
- stories: laneStories(selected, state),
303
- }
304
- : null,
305
- combined: view.combined ?? null,
306
- }),
307
- ];
308
- const empty =
309
- ui.tab === 'decisions'
310
- ? 'Nothing needs you. The lead is handling the build.'
311
- : ui.tab === 'journal'
312
- ? 'Nothing recorded yet: the journal starts with the brief.'
313
- : ui.tab === 'queue'
314
- ? 'The merge queue is empty.'
315
- : ui.tab === 'usage'
316
- ? 'No usage measured yet this session.'
317
- : null;
318
-
319
- // VIEW-6: j/k move between lanes; the selected lane's acts; f filters.
320
- const opening = selected ? storyToOpen(selected, state) : null;
321
- const keys =
322
- ui.tab === 'lanes'
323
- ? [
324
- Box({
325
- key: 'keys',
326
- flexDirection: 'row',
327
- columnGap: 1,
328
- flexWrap: 'wrap',
329
- children: [
330
- ...(opening
331
- ? [
332
- Button({
333
- key: 'open-story',
334
- label: `Open ${opening.id}`,
335
- hotkey: 'o',
336
- variant: 'primary',
337
- autoFocus: true,
338
- onPress: () => on.onOpen({ ...selected, story: opening }),
339
- }),
340
- ]
341
- : []),
342
- Button({
343
- key: 'lane-next',
344
- label: 'Next lane',
345
- hotkey: 'j',
346
- plain: true,
347
- onPress: () => on.onMove(1),
348
- }),
349
- Button({
350
- key: 'lane-prev',
351
- label: 'Previous',
352
- hotkey: 'k',
353
- plain: true,
354
- onPress: () => on.onMove(-1),
355
- }),
356
- ...(selected
357
- ? laneActions(selected, { queue, held: view.held, requests: view.requests }).map(
358
- (a) =>
359
- Button({
360
- key: `act-${a.id}`,
361
- label: `${a.label} ${selected.name}`,
362
- hotkey: used.has(a.hotkey) ? undefined : a.hotkey,
363
- plain: true,
364
- onPress: () => on.onLane(a.id, selected),
365
- }),
366
- )
367
- : []),
368
- ...(!used.has('p') && loop?.state !== 'off' && loop?.state !== 'done'
369
- ? [
370
- Button({
371
- key: 'loop-toggle',
372
- label: loop?.state === 'paused' ? 'Resume loop' : 'Pause loop',
373
- hotkey: 'p',
374
- plain: true,
375
- onPress: () => on.onNeed(loop?.state === 'paused' ? 'resume' : 'pause', null),
376
- }),
377
- ]
378
- : []),
379
- ],
380
- }),
381
- // One row: f puts the keys in the filter.
382
- Box({
383
- key: 'filter-row',
384
- flexDirection: 'row',
385
- columnGap: 1,
386
- children: [
387
- Button({
388
- key: 'filter-focus',
389
- label: 'Filter',
390
- hotkey: 'f',
391
- plain: true,
392
- onPress: () => on.onFocusSearch(),
393
- }),
394
- Input({
395
- key: 'filter',
396
- label: '',
397
- value: ui.search,
398
- placeholder: 'lane, agent or story',
399
- submitLabel: 'Filter',
400
- onInput: (v) => on.onSearch(v),
401
- onSubmit: (v) => on.onSearch(v),
402
- }),
403
- ],
404
- }),
405
- ]
406
- : [];
407
-
408
- return Box({
409
- flexDirection: 'column',
410
- rowGap: 1,
411
- children: [
412
- header,
413
- ...(needs.length ? [Box({ key: 'needs', flexDirection: 'column', children: needs })] : []),
414
- tabs,
415
- ...(body.length ? body : [text(empty, { dimColor: true })]),
416
- ...keys,
417
- ],
418
- });
419
- }
420
-
421
51
  /** A tool call as the liveness column reads it (VIEW-4): "Bash npm test", "Edit apps/web/a.ts". */
422
52
  export function toolLine(call) {
423
53
  const tool = call?.tool ?? 'tool';
@@ -511,12 +141,30 @@ const SEVERITY_TITLE = { blocker: 'Blockers', concern: 'Concerns', nit: 'Nits' }
511
141
  * it; `actions` the lane's acts. `on`: onBack(), onFile(path), onAct(id).
512
142
  */
513
143
  export function storyPane(
514
- { story, review, tokens: usedTokens, outlier, steps, actions, file, now, understanding = null },
144
+ {
145
+ story,
146
+ review,
147
+ tokens: usedTokens,
148
+ outlier,
149
+ steps,
150
+ actions,
151
+ file,
152
+ now,
153
+ understanding = null,
154
+ columns = 100,
155
+ },
515
156
  els,
516
157
  on,
517
158
  ) {
518
159
  const { Box, Text, Button, Code } = els;
519
- const text = (value, style = {}) => Text({ ...style, children: [value] });
160
+ // UI-13: words wrap rather than spill, unless they say otherwise.
161
+ const text = (value, style = {}) => Text({ wrap: 'wrap', ...style, children: [value] });
162
+ /** A path that fits on a button: its last parts, where the whole won't. */
163
+ const fitPath = (path, room) => {
164
+ if (path.length <= room) return path;
165
+ const tail = path.split('/').slice(-2).join('/');
166
+ return tail.length + 2 <= room ? `…/${tail}` : `…/${path.split('/').pop()}`;
167
+ };
520
168
  const section = (key, title, children) =>
521
169
  Box({ key, flexDirection: 'column', children: [text(title, { bold: true }), ...children] });
522
170
  const d = story.data;
@@ -524,6 +172,7 @@ export function storyPane(
524
172
  key: 'story-head',
525
173
  flexDirection: 'row',
526
174
  columnGap: 2,
175
+ flexWrap: 'wrap',
527
176
  children: [
528
177
  Button({
529
178
  key: 'story-back',
@@ -639,7 +288,7 @@ export function storyPane(
639
288
  children: d.diff.files.map((f, i) =>
640
289
  Button({
641
290
  key: `file-${i}`,
642
- label: `${f.path} +${f.added} -${f.removed}`,
291
+ label: `${fitPath(f.path, columns - 12)} +${f.added} -${f.removed}`,
643
292
  plain: true,
644
293
  ...(shown?.path === f.path ? {} : { dimColor: true }),
645
294
  onPress: () => on.onFile(f.path),
@@ -793,10 +442,6 @@ export function storyPane(
793
442
  });
794
443
  }
795
444
 
796
- /** VIEW-6: the person's Escape on an open story goes back to the lanes instead of closing the pane. */
797
- export const closeGoesBack = (e, paneId, ui) =>
798
- e.id === paneId && e.origin?.kind === 'person' && Boolean(ui.story);
799
-
800
445
  // --- the traceability map (spec 10) ------------------------------------------------------------
801
446
 
802
447
  /** Each cell state's glyph, colour and words (TRACE-1, TRACE-4: the glyph reads without colour). */
@@ -874,7 +519,8 @@ export function mapTab(
874
519
  trail = null,
875
520
  { surface = 'terminal', columns = 100 } = {},
876
521
  ) {
877
- const text = (value, style = {}) => Text({ ...style, children: [value] });
522
+ // UI-13: words wrap rather than spill, unless they say otherwise.
523
+ const text = (value, style = {}) => Text({ wrap: 'wrap', ...style, children: [value] });
878
524
  const requirements = status?.requirements ?? [];
879
525
  if (!requirements.length)
880
526
  return [
@@ -904,19 +550,24 @@ export function mapTab(
904
550
  flexDirection: 'row',
905
551
  columnGap: 1,
906
552
  children: [
907
- text(label(row.spec).padEnd(width), { dimColor: true }),
908
- ...row.requirements.map((r) => {
909
- const c = CELL[cellOf(r)];
910
- // Keyed by its Box: a Text keeps no key of its own.
911
- return Box({
912
- key: `cell-${r.id}`,
913
- children: [
914
- text(c.glyph, {
915
- ...(c.color ? { color: c.color } : { dimColor: cellOf(r) === 'removed' }),
916
- ...(r.id === selected.id ? { inverse: true, bold: true } : {}),
917
- }),
918
- ],
919
- });
553
+ text(label(row.spec).padEnd(width), { dimColor: true, wrap: 'truncate-end' }),
554
+ Box({
555
+ flexDirection: 'row',
556
+ flexWrap: 'wrap',
557
+ flexShrink: 1,
558
+ children: row.requirements.map((r) => {
559
+ const c = CELL[cellOf(r)];
560
+ // Keyed by its Box: a Text keeps no key of its own.
561
+ return Box({
562
+ key: `cell-${r.id}`,
563
+ children: [
564
+ text(c.glyph, {
565
+ ...(c.color ? { color: c.color } : { dimColor: cellOf(r) === 'removed' }),
566
+ ...(r.id === selected.id ? { inverse: true, bold: true } : {}),
567
+ }),
568
+ ],
569
+ });
570
+ }),
920
571
  }),
921
572
  ],
922
573
  }),
@@ -926,6 +577,7 @@ export function mapTab(
926
577
  key: 'map-keys',
927
578
  flexDirection: 'row',
928
579
  columnGap: 1,
580
+ flexWrap: 'wrap',
929
581
  children: [
930
582
  Button({
931
583
  key: 'cell-prev',
@@ -1047,19 +699,32 @@ export function mapTab(
1047
699
  Box({
1048
700
  key: `trail-${trailRows[i].id}`,
1049
701
  flexDirection: 'row',
1050
- children: runs.map((r) => text(r.text, TONE[r.style] ?? {})),
702
+ // The links keep their places; the last (the test that names it) is cut to fit.
703
+ children: runs.map((r, j) =>
704
+ j === runs.length - 1
705
+ ? Box({
706
+ flexShrink: 1,
707
+ children: [
708
+ text(r.text, { ...(TONE[r.style] ?? {}), wrap: 'truncate-end' }),
709
+ ],
710
+ })
711
+ : text(r.text, { ...(TONE[r.style] ?? {}), wrap: undefined }),
712
+ ),
1051
713
  }),
1052
714
  ),
1053
715
  });
1054
- const trailBox = trailRows.length
1055
- ? [
1056
- Box({
1057
- key: 'trail',
1058
- flexDirection: 'column',
1059
- children: [text(`Trail · ${label(spec)}`, { bold: true }), flow],
1060
- }),
1061
- ]
1062
- : [];
716
+ // The flow's columns need the room: in a narrower pane the detail below gives the same links.
717
+ const flowFits = surface !== 'terminal' || columns >= 64;
718
+ const trailBox =
719
+ trailRows.length && flowFits
720
+ ? [
721
+ Box({
722
+ key: 'trail',
723
+ flexDirection: 'column',
724
+ children: [text(`Trail · ${label(spec)}`, { bold: true }), flow],
725
+ }),
726
+ ]
727
+ : [];
1063
728
  return [legend, grid, keys, ...trailBox, detail];
1064
729
  }
1065
730
 
@@ -1102,7 +767,7 @@ const RUN_STYLE = {
1102
767
  */
1103
768
  export function codeTab(view, { Box, Text, Button, Svg }, on) {
1104
769
  const text = (value, style = {}) => Text({ ...style, children: [value] });
1105
- const { state, ui = DEFAULT_UI, codeMap: map = null, art = null } = view;
770
+ const { state, ui = {}, codeMap: map = null, art = null } = view;
1106
771
  let glow = view.glow ?? {};
1107
772
  const storyId = mapStoryOf(state, ui.selected, ui.mapStory);
1108
773
  const project = { id: PROJECT, title: 'Whole project' };
@@ -1120,7 +785,8 @@ export function codeTab(view, { Box, Text, Button, Svg }, on) {
1120
785
  children: choices.map((s) =>
1121
786
  Button({
1122
787
  key: `map-story-${s.id}`,
1123
- label: s.id === PROJECT ? s.title : `${s.id} ${s.title}`,
788
+ // The story's title where the pane has room for it; its id alone in a narrow one.
789
+ label: s.id === PROJECT ? s.title : view.columns >= 90 ? `${s.id} ${s.title}` : s.id,
1124
790
  ...(s.id === storyId ? { variant: 'primary' } : { plain: true }),
1125
791
  onPress: () => on.onMapStory(s.id),
1126
792
  }),
@@ -1169,6 +835,8 @@ export function codeTab(view, { Box, Text, Button, Svg }, on) {
1169
835
  : Box({
1170
836
  key: 'code-map',
1171
837
  flexDirection: 'column',
838
+ // UI-13: a drawing wider than the pane is cut at its edge, not spilled past it.
839
+ overflow: 'hidden',
1172
840
  children: codeRows(map, { glow, selected, width }).map((runs, y) =>
1173
841
  Box({
1174
842
  key: `code-row-${y}`,
@@ -1189,8 +857,11 @@ export function codeTab(view, { Box, Text, Button, Svg }, on) {
1189
857
  borderColor: 'gray',
1190
858
  paddingX: 1,
1191
859
  children: [
1192
- text(selected, { bold: true }),
1193
- text(`${file.layer}${file.lane ? ` · ${file.lane} lane` : ''}`, { dimColor: true }),
860
+ text(selected, { bold: true, wrap: 'wrap' }),
861
+ text(`${file.layer}${file.lane ? ` · ${file.lane} lane` : ''}`, {
862
+ dimColor: true,
863
+ wrap: 'wrap',
864
+ }),
1194
865
  ...(card
1195
866
  ? [
1196
867
  text(
@@ -1200,15 +871,25 @@ export function codeTab(view, { Box, Text, Button, Svg }, on) {
1200
871
  card.state === 'current' ? {} : { color: 'yellow' },
1201
872
  ),
1202
873
  ...(card.state === 'stale'
1203
- ? [text('The file changed since its why was written.', { dimColor: true })]
874
+ ? [
875
+ text('The file changed since its why was written.', {
876
+ dimColor: true,
877
+ wrap: 'wrap',
878
+ }),
879
+ ]
1204
880
  : []),
1205
881
  ]
1206
882
  : []),
1207
883
  ...(near.imports.length
1208
- ? [text(`imports ${near.imports.map(short).join(', ')}`, { dimColor: true })]
884
+ ? [text(`imports ${near.imports.map(short).join(', ')}`, { dimColor: true, wrap: 'wrap' })]
1209
885
  : []),
1210
886
  ...(near.importers.length
1211
- ? [text(`imported by ${near.importers.map(short).join(', ')}`, { dimColor: true })]
887
+ ? [
888
+ text(`imported by ${near.importers.map(short).join(', ')}`, {
889
+ dimColor: true,
890
+ wrap: 'wrap',
891
+ }),
892
+ ]
1212
893
  : []),
1213
894
  ],
1214
895
  });
@@ -1250,10 +931,12 @@ export function codeTab(view, { Box, Text, Button, Svg }, on) {
1250
931
  columnGap: 2,
1251
932
  flexWrap: 'wrap',
1252
933
  children: MAP_LEGEND.map((l) =>
1253
- text(
1254
- l.text,
1255
- l.style === 'glow' ? { color: tints[file.lane] ?? 'cyan' } : (RUN_STYLE[l.style] ?? {}),
1256
- ),
934
+ text(l.text, {
935
+ wrap: 'wrap',
936
+ ...(l.style === 'glow'
937
+ ? { color: tints[file.lane] ?? 'cyan' }
938
+ : (RUN_STYLE[l.style] ?? {})),
939
+ }),
1257
940
  ),
1258
941
  });
1259
942
  return [picker, drawing, legend, detail, keys];
@@ -1302,17 +985,23 @@ export function decisionsTab(cards, ui, { Box, Text, Button }, on) {
1302
985
  borderColor: i === at ? 'yellow' : 'gray',
1303
986
  paddingX: 1,
1304
987
  children: [
988
+ // UI-7: its kind in sentence case, pressed to choose it; then the headline, cut to fit.
1305
989
  Box({
990
+ key: `decision-head-${i}`,
1306
991
  flexDirection: 'row',
1307
992
  columnGap: 1,
1308
993
  children: [
1309
- text(c.tag.toUpperCase(), { color: i === at ? 'yellow' : 'cyan', bold: true }),
1310
994
  Button({
1311
995
  key: `decision-pick-${i}`,
1312
- label: c.headline,
996
+ label: c.tag,
1313
997
  plain: true,
998
+ ...(i === at ? {} : { dimColor: true }),
1314
999
  onPress: () => on.onDecision(i),
1315
1000
  }),
1001
+ Box({
1002
+ flexShrink: 1,
1003
+ children: [text(c.headline, { bold: i === at, wrap: 'truncate-end' })],
1004
+ }),
1316
1005
  ],
1317
1006
  }),
1318
1007
  ...(c.sub ? [text(c.sub, { dimColor: true, wrap: 'truncate-end' })] : []),
@@ -1423,7 +1112,7 @@ export function decisionsTab(cards, ui, { Box, Text, Button }, on) {
1423
1112
  return [
1424
1113
  text(
1425
1114
  `${cards.length} decision${cards.length === 1 ? '' : 's'} need${cards.length === 1 ? 's' : ''} you. Everything else is the lead's.`,
1426
- { bold: true },
1115
+ { bold: true, wrap: 'wrap' },
1427
1116
  ),
1428
1117
  Box({
1429
1118
  key: 'decision-kinds',
@@ -1432,7 +1121,7 @@ export function decisionsTab(cards, ui, { Box, Text, Button }, on) {
1432
1121
  [...kinds]
1433
1122
  .map(([tag, n]) => `${n} ${tag}${n === 1 || tag.endsWith('brief') ? '' : 's'}`)
1434
1123
  .join(' · '),
1435
- { dimColor: true },
1124
+ { dimColor: true, wrap: 'wrap' },
1436
1125
  ),
1437
1126
  ],
1438
1127
  }),
@@ -1498,7 +1187,7 @@ export function journalTab(events, { Box, Text }, now = Date.now()) {
1498
1187
  return [
1499
1188
  text(
1500
1189
  `From your request to now: ${events.length} event${events.length === 1 ? '' : 's'}${events.length > shown.length ? `, the latest ${shown.length} shown` : ''}. Yours are in yellow.`,
1501
- { dimColor: true },
1190
+ { dimColor: true, wrap: 'wrap' },
1502
1191
  ),
1503
1192
  Box({ key: 'journal', flexDirection: 'column', children: rows }),
1504
1193
  ];