rvlib-shipkit 2.24.0 → 2.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 (99) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/package.json +2 -2
  3. package/src/agent-time/hooks.ts +329 -0
  4. package/src/agent-time/live.ts +153 -0
  5. package/src/agent-time/render.ts +14 -2
  6. package/src/agent-time/report.ts +56 -4
  7. package/src/agent-time/store.ts +59 -5
  8. package/src/annex/offload.ts +16 -7
  9. package/src/check.ts +3 -1
  10. package/src/checks/SK004-gitignore-policy.check.ts +32 -11
  11. package/src/checks/SK027-agent-wiki-links.check.ts +1 -1
  12. package/src/checks/SK033-global-contribution.check.ts +1 -1
  13. package/src/checks/SK036-draft-media-size.check.ts +1 -1
  14. package/src/checks/SK040-release-words.check.ts +1 -1
  15. package/src/checks/SK042-post-kinds.check.ts +1 -1
  16. package/src/checks/SK045-slow-hooks.check.ts +47 -0
  17. package/src/checks/SK046-hook-records.check.ts +76 -0
  18. package/src/cli/cmd_Annex.ts +12 -7
  19. package/src/cli/cmd_Assets.ts +5 -5
  20. package/src/cli/cmd_Backup.ts +14 -6
  21. package/src/cli/cmd_Capacity.ts +10 -6
  22. package/src/cli/cmd_Checks.ts +12 -1
  23. package/src/cli/cmd_Ci.ts +2 -2
  24. package/src/cli/cmd_Commands.ts +11 -2
  25. package/src/cli/cmd_ConfigKeys.ts +17 -0
  26. package/src/cli/cmd_Home.ts +1 -1
  27. package/src/cli/cmd_Keys.ts +4 -1
  28. package/src/cli/cmd_Lanes.ts +35 -0
  29. package/src/cli/cmd_Mv.ts +6 -7
  30. package/src/cli/cmd_Rec.ts +22 -7
  31. package/src/cli/cmd_Releases.ts +30 -0
  32. package/src/cli/cmd_Review.ts +130 -43
  33. package/src/cli/cmd_Shot.ts +15 -4
  34. package/src/cli/cmd_Status.ts +6 -5
  35. package/src/cli/cmd_Time.ts +18 -6
  36. package/src/cli/cmd_Veille.ts +10 -6
  37. package/src/cli/family-help.ts +136 -0
  38. package/src/cli/family-pages.ts +0 -19
  39. package/src/cli/kit/calls.ts +35 -0
  40. package/src/cli/kit/project-cli.ts +2 -12
  41. package/src/cli/registry.ts +41 -7
  42. package/src/cli.ts +8 -4
  43. package/src/commands/runner.ts +5 -1
  44. package/src/core/capacity.ts +89 -33
  45. package/src/core/check-runner.ts +5 -1
  46. package/src/core/floor-resolve.ts +6 -2
  47. package/src/core/floor.ts +6 -2
  48. package/src/core/history-files.ts +22 -0
  49. package/src/core/jobs.ts +35 -16
  50. package/src/core/layout.ts +2 -2
  51. package/src/core/nearest.ts +16 -0
  52. package/src/core/remove-tree.ts +19 -0
  53. package/src/core/runs.ts +12 -3
  54. package/src/core/signal-name.ts +6 -0
  55. package/src/core/throwaway-worktree.ts +22 -4
  56. package/src/core/trace-audit.ts +22 -4
  57. package/src/core/transient.ts +6 -0
  58. package/src/drill/run.ts +1 -1
  59. package/src/home/daemon-jobs.ts +41 -4
  60. package/src/home/machine-temp.ts +2 -10
  61. package/src/ledger/gate-checks.ts +26 -4
  62. package/src/ledger/git-key.ts +25 -4
  63. package/src/ledger/git-scan.ts +59 -7
  64. package/src/media-store/backup/daemon.ts +103 -20
  65. package/src/media-store/backup/run.ts +21 -15
  66. package/src/media-store/backup/sources.ts +163 -21
  67. package/src/media-store/backup/watch.ts +106 -0
  68. package/src/media-store/daemon.ts +36 -8
  69. package/src/media-store/hand.ts +3 -1
  70. package/src/mv/mv-md.ts +50 -18
  71. package/src/pb/run-pb.ts +2 -10
  72. package/src/plan/repo-source.ts +25 -14
  73. package/src/recordings/model.ts +1 -1
  74. package/src/reflect/transcript.ts +21 -3
  75. package/src/release/run-bump.ts +3 -2
  76. package/src/release/run-release.ts +12 -4
  77. package/src/releases/model.ts +18 -0
  78. package/src/releases/store.ts +13 -1
  79. package/src/repo-config.ts +11 -1
  80. package/src/review/cells.ts +2 -1
  81. package/src/review/format.ts +1 -1
  82. package/src/review/inbox-hook.ts +35 -0
  83. package/src/review/model.ts +26 -7
  84. package/src/review/store.ts +15 -7
  85. package/src/review/trailer-model.ts +2 -2
  86. package/src/shot/client.ts +4 -2
  87. package/src/shot/serve-shot.ts +71 -2
  88. package/src/shot/shooter.ts +65 -11
  89. package/src/shot/shot-ask.ts +32 -9
  90. package/src/suite/judge-suites.ts +77 -10
  91. package/src/suite/select.ts +13 -2
  92. package/src/suite/suite-cli.ts +72 -31
  93. package/src/suite/test-units.ts +31 -12
  94. package/src/trailer/graph.ts +2 -1
  95. package/src/ts/config.ts +12 -35
  96. package/src/ts/rename.ts +31 -17
  97. package/src/ts/workspaces.ts +45 -0
  98. package/src/wiki/run-wiki.ts +8 -2
  99. package/src/wiki/scan-md.ts +42 -1
package/src/mv/mv-md.ts CHANGED
@@ -6,13 +6,15 @@
6
6
  // script it runs after the moves (repo-specific re-stamps). TS module moves
7
7
  // are a different concern (a TS-aware renamer owns import graphs).
8
8
  import { execSync } from 'child_process'
9
+ import { isHistoryFile } from '../core/history-files.ts'
9
10
  import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'fs'
11
+ import { homedir } from 'os'
10
12
  import { basename, dirname, join, relative } from 'path'
11
13
  import { isVendored } from '../core/vendored.ts'
12
14
  import { vendoredAround } from '../core/vendored-read.ts'
13
15
 
14
16
  export type MvIo = { print: (l: string) => void; printErr: (l: string) => void }
15
- export type MvOpts = { write?: boolean; commit?: boolean; /** run the repo's `mv:after` script (a batch runs it once, at the end) */ after?: boolean }
17
+ export type MvOpts = { write?: boolean; commit?: boolean; /** run the repo's `mv:after` script (a batch runs it once, at the end) */ after?: boolean; /** rewrite the plans, changelogs and journals too: by default they stay as written */ history?: boolean }
16
18
 
17
19
  const sh = (cmd: string, cwd: string): string => execSync(cmd, { cwd }).toString()
18
20
 
@@ -32,15 +34,8 @@ const dirOf = (p: string): string => { const d = dirname(p); return d === '.' ?
32
34
  // were confined to one directory. A move between directories invalidates both
33
35
  // directions at once: the links the page carries out, and the links other
34
36
  // pages aim at it. This pass runs FIRST so the token sweep finds those already
35
- // rewritten.
36
- //
37
- // KNOWN RESIDUAL, do not read this as closed: the token sweep below is a
38
- // substring replace, so a path that merely ENDS with the old path
39
- // ('other/doc/bun.md' referenced as '../doc/bun.md' from a file that is not
40
- // moving) is still rewritten to a path that does not exist. This pass declines
41
- // that case on purpose, because neither the target nor the carrier moved.
42
- // Closing it means teaching the sweep which character spans were already
43
- // resolved here.
37
+ // rewritten. A path that merely ENDS with the old path is the sweep's to judge
38
+ // (`namesMoved`), never this pass's.
44
39
  //
45
40
  // A target must resolve to a FILE. Directories are excluded because the arrow
46
41
  // form appears in prose ('→ shipkit ci'), and a bare word that happens to name
@@ -98,6 +93,19 @@ export function retargetRelativeRefs(
98
93
  return out
99
94
  }
100
95
 
96
+ /** whether the token at `at` names the moved path `full`, judged by the path characters right before it: none, a
97
+ * relative path that resolves to it from the carrier's folder, the repo's own absolute root, or a url's path. Any
98
+ * other longer path (`packages/p/agent/index.md` for `agent/index.md`) names another file */
99
+ export function namesMoved(text: string, at: number, tok: string, full: string, carrierDir: string, root: string): boolean {
100
+ let s = at
101
+ while (s > 0 && /[\w.\/~-]/.test(text[s - 1]!)) s--
102
+ const p = text.slice(s, at)
103
+ // `${root}/agent/x.md`: the folder is an expression, read as the root
104
+ if (p === '' || p.startsWith('//') || (p === '/' && s > 0 && /[})]/.test(text[s - 1]!))) return true
105
+ if (p.startsWith('/') || p.startsWith('~/')) return (p.startsWith('~/') ? join(homedir(), p.slice(2)) : p).replace(/\/+$/, '') === root.replace(/\/+$/, '')
106
+ return posix(join(carrierDir, p + tok)) === full
107
+ }
108
+
101
109
  /** where a move reads and writes. Applied, it is the disk and git; a dry run is
102
110
  * an overlay on them, so the dry run walks the very same steps, and a map's
103
111
  * next line sees what the line before it moved */
@@ -124,6 +132,14 @@ class MvTree {
124
132
  exists = (rel: string): boolean =>
125
133
  this.isFile(rel) || (!this.live && this.files().some((f) => f.startsWith(`${rel}/`))) || (!this.isGone(rel) && existsSync(this.real(rel)))
126
134
  read = (rel: string): string => this.text.get(rel) ?? readFileSync(this.real(rel), 'utf8')
135
+ /** false for a binary (a NUL in its first 8 KB, git's own test) and for a text without `needle`: no decode, no
136
+ * regex, ten times faster over a repo's tracked files */
137
+ holds(rel: string, needle: string): boolean {
138
+ const t = this.text.get(rel)
139
+ if (t !== undefined) return t.includes(needle)
140
+ const b = readFileSync(this.real(rel))
141
+ return !b.subarray(0, 8192).includes(0) && b.includes(needle)
142
+ }
127
143
  write(rel: string, text: string): void {
128
144
  if (this.live) writeFileSync(this.real(rel), text)
129
145
  else this.text.set(rel, text)
@@ -179,11 +195,14 @@ export function movePage(root: string, oldRel: string, newRel: string, io: MvIo,
179
195
  // asset dir BECOMES that folder instead of sitting beside the page
180
196
  const indexForm = basename(newRel) === 'index.md' && basename(oldRel) !== 'index.md'
181
197
  const oldBase = oldRel.slice(0, -3) // full path sans .md, the sibling dir
182
- const newBase = indexForm ? dirOf(newRel) : newRel.slice(0, -3)
183
- // in place: the page moves into its own asset dir, which already is the topic folder
184
- const inPlace = indexForm && newBase === oldBase
198
+ // in place: the page moves into its own asset dir (`x.md` to `x/index.md` or `x/x.md`), which stays the topic folder
199
+ const inPlace = dirOf(newRel) === oldBase
200
+ const newBase = indexForm || inPlace ? dirOf(newRel) : newRel.slice(0, -3)
201
+ // git cannot move a folder into itself, and the sweep would already have run
202
+ if (!inPlace && newRel.startsWith(`${oldBase}/`) && tree.exists(oldBase))
203
+ return die(`${newRel} sits deeper inside ${oldBase}/, the page's own folder, which git cannot move into itself. Two steps: sk mv ${oldRel} ${oldBase}/${basename(newRel)} --write, then sk mv ${oldBase}/${basename(newRel)} ${newRel} --write`)
185
204
  if (indexForm && !inPlace && tree.exists(newBase)) return die(`${newBase}/ already exists: a topic folder is created by its move, never merged into`)
186
- if (!indexForm && tree.exists(oldBase) && tree.exists(newBase))
205
+ if (!indexForm && !inPlace && tree.exists(oldBase) && tree.exists(newBase))
187
206
  return die(`${newBase}/ already exists, and ${oldBase}/ would be nested inside it rather than become it: move or merge it by hand first`)
188
207
 
189
208
  const write = tree.live
@@ -193,6 +212,7 @@ export function movePage(root: string, oldRel: string, newRel: string, io: MvIo,
193
212
  // (`build/state`, not `wiki/build/state`), so the sweep takes both forms
194
213
  const tail = (p: string): string | null => { const seg = p.split('/'); return seg.length >= 3 ? seg.slice(1).join('/') : null }
195
214
  const oldId = tail(oldBase)
215
+ const top = oldBase.split('/')[0]!
196
216
  const newId = tail(newBase)
197
217
  const newPageId = tail(newRel.slice(0, -3))
198
218
 
@@ -242,14 +262,25 @@ export function movePage(root: string, oldRel: string, newRel: string, io: MvIo,
242
262
  }
243
263
 
244
264
  let touched = 0
265
+ let left = 0
245
266
  for (const f of [...tracked]) {
246
267
  // a submodule is one ls-files entry and a directory: nothing to read
247
268
  if (!tree.isFile(f)) continue
269
+ // every token and every relative path that reaches a moved file names the page's stem
270
+ if (!moves.has(f) && !tree.holds(f, oldName)) continue
248
271
  const before = tree.read(f)
249
272
  let refs = 0
250
273
  const linked = retargetRelativeRefs(root, before, dirOf(f), dirOf(moves.get(f) ?? f), moves, tree.isFile)
251
274
  if (linked !== before) { const lines = before.split('\n'); refs += linked.split('\n').filter((l, i) => l !== lines[i]).length }
252
- const after = linked.replace(sweep, (m) => { const next = to.get(m)!; if (next !== m) refs++; return next })
275
+ const after = linked.replace(sweep, (m: string, at: number) => {
276
+ // a docs-root-relative id names the path under the repo's top folder
277
+ if (!namesMoved(linked, at, m, m.startsWith(oldBase) ? m : `${top}/${m}`, dirOf(f), root)) return m
278
+ const next = to.get(m)!
279
+ if (next !== m) refs++
280
+ return next
281
+ })
282
+ // a record of what was true stays as written, unless it is itself what moves
283
+ if (after !== before && o.history !== true && isHistoryFile(f) && !moves.has(f)) { left++; continue }
253
284
  if (after !== before) {
254
285
  io.print(` ${f}: ${refs} ref(s)`)
255
286
  io.print(` ${firstChanged(before, after)}`)
@@ -265,7 +296,7 @@ export function movePage(root: string, oldRel: string, newRel: string, io: MvIo,
265
296
  if (indexForm && hasDir && !inPlace) tree.mv(oldBase, newBase)
266
297
  tree.mv(oldRel, newRel)
267
298
  if (hasDir) {
268
- if (!indexForm) tree.mv(oldBase, newBase)
299
+ if (!indexForm && !inPlace) tree.mv(oldBase, newBase)
269
300
  // the probe is named after its page, so it only moves when the NAME
270
301
  // changed. A move that keeps the name and changes the directory takes
271
302
  // the probe along inside the dir, and `git mv X X` is a fatal
@@ -274,7 +305,8 @@ export function movePage(root: string, oldRel: string, newRel: string, io: MvIo,
274
305
  if (oldName !== newName && tree.exists(oldProbe)) tree.mv(oldProbe, `${newBase}/${newName}${sfx}`)
275
306
  }
276
307
  }
277
- io.print(`${write ? 'renamed' : 'DRY RUN'}: ${oldBase} → ${newBase}, refs in ${touched} file(s)`)
308
+ if (left > 0) io.print(` left as written: ${left} plan, changelog or journal file(s) that name it (--history rewrites them too)`)
309
+ io.print(`${write ? 'renamed' : 'DRY RUN'}: ${oldRel} → ${newRel}, refs in ${touched} file(s)`)
278
310
  if (!write) { io.print('re-run with --write (or --commit) to apply'); return 0 }
279
311
 
280
312
  if (o.after !== false && !runAfter(root)) return die('mv:after failed, fix before committing')
@@ -284,7 +316,7 @@ export function movePage(root: string, oldRel: string, newRel: string, io: MvIo,
284
316
  execSync(`git commit -m ${JSON.stringify(`docs: rename ${oldBase} → ${newBase}`)}`, { cwd: root, stdio: 'inherit' })
285
317
  } catch { return die('commit failed (pre-commit gate?). The rename is applied, fix and commit yourself') }
286
318
  }
287
- io.print(`ok: ${oldBase} → ${newBase}${o.commit === true ? ' (committed)' : ''}`)
319
+ io.print(`ok: ${oldRel} → ${newRel}${o.commit === true ? ' (committed)' : ''}`)
288
320
  return 0
289
321
  }
290
322
 
package/src/pb/run-pb.ts CHANGED
@@ -10,6 +10,7 @@
10
10
  // the failure mode is a runtime throw rather than a compile error.
11
11
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'
12
12
  import { dirname, join } from 'path'
13
+ import { nearest } from '../core/nearest.ts'
13
14
  import { scaffoldCollectionUI, type ScaffoldedFile } from './collection-scaffold.ts'
14
15
  import { isSystemCollection, parsePbTypes, type PbCollection } from './pb-types.ts'
15
16
 
@@ -35,15 +36,6 @@ const REGISTRY_HEADER = [
35
36
  '',
36
37
  ].join('\n')
37
38
 
38
- /** names close enough to be the one that was meant */
39
- function nearest(want: string, have: string[]): string[] {
40
- const w = want.toLowerCase().replace(/[_-]/g, '')
41
- return have.filter((n) => {
42
- const h = n.toLowerCase().replace(/[_-]/g, '')
43
- return h === w || h.startsWith(w) || w.startsWith(h)
44
- })
45
- }
46
-
47
39
  export type PbCollectionOpts = { dryRun: boolean }
48
40
 
49
41
  export function runPbCollection(root: string, name: string, io: PbIo, opts: PbCollectionOpts): number {
@@ -70,7 +62,7 @@ export function runPbCollection(root: string, name: string, io: PbIo, opts: PbCo
70
62
  // pocketbase's own `_`-prefixed collections are never an app surface, so
71
63
  // offering them as choices sends the reader somewhere they cannot go
72
64
  const names = collections.filter((c) => !isSystemCollection(c.name)).map((c) => c.name)
73
- const close = nearest(name, names)
65
+ const close = nearest(name, names, Infinity)
74
66
  io.printErr(`FAIL: no collection '${name}' in ${typesRel}`)
75
67
  if (close.length > 0) io.printErr(` fix: did you mean ${close.join(', ')} ?`)
76
68
  io.printErr(` fix: known collections: ${names.join(', ')}`)
@@ -4,11 +4,12 @@
4
4
  //
5
5
  // the one constraint a reader breaks first: `changed` asks the ledger, never
6
6
  // the file event. A check is changed when its answer would not replay: a key
7
- // that moved, a read set that drifted, no stored green, or no key at all for
8
- // a gate check. A red keyed on content counts only once its key moves, so a
9
- // save elsewhere never re-runs it.
7
+ // that moved, a read set that drifted, no stored green. A red keyed on content
8
+ // counts only once its key moves, so a save elsewhere never re-runs it. A
9
+ // check with no key counts when a declared input of the repo moved (saveMoved).
10
10
  import { gateInventory, type CheckRow } from '../ledger/gate-checks.ts'
11
11
  import { Ledger } from '../ledger/ledger.ts'
12
+ import type { CheckKey } from '../ledger/git-key.ts'
12
13
  import { answersDb } from '../ledger/store.ts'
13
14
  import { hasWorld, worldKeyOf, type WorldCache } from '../ledger/world-cache.ts'
14
15
  import { FOREVER, FOREVER_MS } from '../core/wire.ts'
@@ -36,7 +37,7 @@ export function planGap(row: CheckRow): string | null {
36
37
  if (row.runs.onSave !== 'moved') return null
37
38
  const pop = populationOf(row.decl)
38
39
  if (pop === 'content' || pop === 'reads' || isForever(row)) return null
39
- return `onSave 'moved' but nothing keys it (${row.decl.uncacheable ?? row.decl.declError ?? 'no key'}), so every save moves it`
40
+ return `onSave 'moved' but nothing keys it (${row.decl.uncacheable ?? row.decl.declError ?? 'no key'}), so a save runs it whenever any declared input of the repo moved`
40
41
  }
41
42
 
42
43
  /** one inventory row as a plan check, straight from its declared axes:
@@ -103,6 +104,25 @@ export function lastStarted(path: string, o: { asked?: boolean } = {}): number |
103
104
  }
104
105
  }
105
106
 
107
+ /** whether a save moved one check, given the key it had at the last question (`seen`, updated here). A check with
108
+ * no key (an input git cannot name, a toolchain nobody can describe, a scan that failed) is due when its reason
109
+ * changes or when `tree` moved: what the scan saw of every declared input of the repo that git does not ignore,
110
+ * null when the scan failed.
111
+ * Never at each save whatever moved: the run it starts writes files of its own, so that is a loop. With no tree
112
+ * to compare (the scan failed) it is due once for the reason */
113
+ export function saveMoved(seen: Map<string, string>, id: string, k: Pick<CheckKey, 'key' | 'population' | 'reason'>, replays: () => boolean, tree: string | null = null): boolean {
114
+ const before = seen.get(id)
115
+ if (k.key == null) {
116
+ // long runs of digits out: a reason that names a pid or a time is the same reason, a file name keeps its number
117
+ const mark = `no key: ${(k.reason ?? '').replace(/\d{4,}/g, '#')} @ ${tree ?? ''}`
118
+ seen.set(id, mark)
119
+ return before !== mark
120
+ }
121
+ seen.set(id, k.key)
122
+ if (replays()) return false
123
+ return !(k.population === 'content' && before === k.key)
124
+ }
125
+
106
126
  export type RepoSourceDeps = {
107
127
  repo: string
108
128
  root: string
@@ -179,16 +199,7 @@ export function repoSource(d: RepoSourceDeps): PlanSource {
179
199
  }
180
200
  // 'burst': every quiet save burst, whatever moved
181
201
  if (r.runs.onSave === 'burst') { out.push(c.id); continue }
182
- const k = ledger.layer.keyFor(c.id)
183
- if (k.key == null) {
184
- out.push(c.id)
185
- continue
186
- }
187
- const before = seen.get(c.id)
188
- seen.set(c.id, k.key)
189
- if (ledger.replay(c.id) != null) continue
190
- if (k.population === 'content' && before === k.key) continue
191
- out.push(c.id)
202
+ if (saveMoved(seen, c.id, ledger.layer.keyFor(c.id), () => ledger.replay(c.id) != null, ledger.layer.treeStamp())) out.push(c.id)
192
203
  }
193
204
  return out
194
205
  },
@@ -128,7 +128,7 @@ export async function findRecording(ref: string, o: { repo?: string } = {}): Pro
128
128
  const hits = all.filter((r) => r.name === word || r.id === word)
129
129
  if (hits.length === 1) return hits[0]!
130
130
  if (hits.length > 1) throw new Error(`${ref}: ${hits.length} recordings answer to it (${hits.map((r) => `${r.repo}/${r.name}`).join(', ')}); name the repo`)
131
- throw new Error(`${ref}: no recording of that name${repo ? ` in ${repo}` : ''} (sk rec ls lists them)`)
131
+ throw new Error(`${ref}: no recording of that name${repo ? ` in ${repo}` : ''} (sk rec lists them)`)
132
132
  }
133
133
 
134
134
  /** the name given, checked free in the repo folder */
@@ -53,6 +53,10 @@ export type TranscriptEvent =
53
53
  /** the text block that ends the turn (stop_reason end_turn): the agent
54
54
  * stopped, and what follows is a wait until something wakes it */
55
55
  | { kind: 'end'; at: number }
56
+ /** a hook run the harness timed: written only when the hook printed
57
+ * something, so a silent hook leaves none. `tool` is '' on an event of no
58
+ * tool (a prompt, a turn end); `id` is the call it ran on, or the hook's own id */
59
+ | { kind: 'hook'; at: number; id: string; event: string; tool: string; command: string; ms: number; code: number | null; error: boolean }
56
60
 
57
61
  // wrappers the harness injects as user-role entries: none of them are typed
58
62
  const NOISE_PREFIXES = [
@@ -95,7 +99,7 @@ export type RawEntry = {
95
99
  * a plain turn in a main session, a meta turn in a sub-agent */
96
100
  origin?: { kind?: unknown }
97
101
  /** attachment entries: a notification delivered mid-turn is a `queued_command` */
98
- attachment?: { type?: unknown; prompt?: unknown }
102
+ attachment?: { type?: unknown; prompt?: unknown; hookName?: unknown; hookEvent?: unknown; command?: unknown; durationMs?: unknown; exitCode?: unknown; toolUseID?: unknown }
99
103
  /** queue-operation entries only */
100
104
  operation?: unknown
101
105
  content?: unknown
@@ -240,7 +244,7 @@ const resultText = (content: unknown): string => {
240
244
  // the entry types that carry nothing a reader wants and make most of the
241
245
  // bytes (api-request alone is about 80 percent of a long session): a line
242
246
  // that starts with one of these is skipped before JSON.parse
243
- const KEPT_TYPE_PREFIXES = ['{"type":"user"', '{"type":"assistant"', '{"type":"queue-operation"']
247
+ const KEPT_TYPE_PREFIXES = ['{"type":"user"', '{"type":"assistant"', '{"type":"queue-operation"', '{"type":"attachment"']
244
248
 
245
249
  /** every event one transcript line holds; [] for anything else, a truncated
246
250
  * tail line of a live session included */
@@ -263,7 +267,11 @@ export function eventsOf(entry: RawEntry): TranscriptEvent[] {
263
267
  }
264
268
  if (Number.isNaN(at) && entry.type !== 'user') return []
265
269
  // a notification that arrives while the agent works is attached to its next turn
266
- if (entry.type === 'attachment') return entry.attachment?.type === 'queued_command' && typeof entry.attachment.prompt === 'string' ? bgEndsOf(entry.attachment.prompt, at) : []
270
+ if (entry.type === 'attachment') {
271
+ const a = entry.attachment
272
+ if (a?.type === 'hook_success' || a?.type === 'hook_non_blocking_error') return hookOf(a, at)
273
+ return a?.type === 'queued_command' && typeof a.prompt === 'string' ? bgEndsOf(a.prompt, at) : []
274
+ }
267
275
  if (entry.type === 'assistant') {
268
276
  const blocks = Array.isArray(entry.message?.content) ? (entry.message.content as Block[]) : []
269
277
  const out: TranscriptEvent[] = []
@@ -301,6 +309,16 @@ export function eventsOf(entry: RawEntry): TranscriptEvent[] {
301
309
  return out
302
310
  }
303
311
 
312
+ /** a timed hook record: its event, the tool from `PostToolUse:Edit`, its
313
+ * command as the settings name it, its duration */
314
+ function hookOf(a: NonNullable<RawEntry['attachment']>, at: number): TranscriptEvent[] {
315
+ if (typeof a.durationMs !== 'number' || typeof a.hookEvent !== 'string' || typeof a.command !== 'string') return []
316
+ const name = typeof a.hookName === 'string' ? a.hookName : ''
317
+ const tool = name.startsWith(`${a.hookEvent}:`) ? name.slice(a.hookEvent.length + 1) : ''
318
+ const id = typeof a.toolUseID === 'string' ? a.toolUseID : ''
319
+ return [{ kind: 'hook', at, id, event: a.hookEvent, tool, command: a.command, ms: a.durationMs, code: typeof a.exitCode === 'number' ? a.exitCode : null, error: a.type === 'hook_non_blocking_error' }]
320
+ }
321
+
304
322
  const NOTICE = /<task-notification>([\s\S]*?)<\/task-notification>/g
305
323
  const tagOf = (body: string, name: string): string | null => new RegExp(`<${name}>([^<]*)</${name}>`).exec(body)?.[1]?.trim() ?? null
306
324
 
@@ -40,7 +40,7 @@ import { unitBlockers } from './unit-gate.ts'
40
40
  import { publicCleanBlockers } from './public-clean.ts'
41
41
  import { releaseScope } from './release-scope.ts'
42
42
  import { formatUnitError, releaseOrder, renderTag, resolveUnits, unitById, unitPrepublishScripts, unknownUnit, type ReleaseUnit } from './units.ts'
43
- import { environmentBlockers, runReleaseGate, releaseUnit } from './run-release.ts'
43
+ import { environmentBlockers, gateStop, runReleaseGate, releaseUnit } from './run-release.ts'
44
44
  import type { RepoConfig } from '../repo-config.ts'
45
45
  import { nestedIn, nestedRefusal } from '../core/nesting.ts'
46
46
  import { LAYOUT } from '../core/layout.ts'
@@ -492,7 +492,8 @@ export async function runBump(root: string, config: RepoConfig, kind: BumpKind |
492
492
  // same thing. Frozen, and fatal on non-blocking failures when the repo
493
493
  // declared requireHealthy. releaseUnit then skips it, because bump
494
494
  // already proved this exact commit.
495
- if ((await runReleaseGate(root, print, { units: picked, allowDirty: o.allowDirty })) !== 0) return fail('ci gate is red on HEAD (the merged result) — fix it, commit, then bump')
495
+ const gate = await runReleaseGate(root, print, { units: picked, allowDirty: o.allowDirty })
496
+ if (gate !== 0) return fail(gateStop(gate, 'bump'))
496
497
  print('ok: ci gate green')
497
498
 
498
499
  for (const s of selected) {
@@ -124,8 +124,11 @@ export type ReleaseOpts = {
124
124
  * classifying severity from one config while the rules ran from another
125
125
  * downgrades a blocking failure to a warning.
126
126
  *
127
- * it also runs the FULL test tier, which `shipkit ci` skips while you work. */
128
- export async function runReleaseGate(root: string, print: (l: string) => void, o: { units?: ReleaseUnit[]; allowDirty?: boolean } = {}): Promise<number> {
127
+ * it also runs the FULL test tier, which `shipkit ci` skips while you work.
128
+ *
129
+ * 'not run' when the checkout could not be made ready (its FAIL line says why): nothing was judged, so a caller
130
+ * never reports it as a red gate. */
131
+ export async function runReleaseGate(root: string, print: (l: string) => void, o: { units?: ReleaseUnit[]; allowDirty?: boolean } = {}): Promise<number | 'not run'> {
129
132
  const r = await withHeadCheckout(root, async (dir, sha) => {
130
133
  print(`note: gating HEAD ${sha.slice(0, 8)} in a clean checkout (${dir}): uncommitted work here is in no tag, so the gate never reads it`)
131
134
  let config: RepoConfig
@@ -178,9 +181,13 @@ export async function runReleaseGate(root: string, print: (l: string) => void, o
178
181
  })
179
182
  if (typeof r === 'number') return r
180
183
  print(`FAIL: ${r.error}`)
181
- return 1
184
+ return 'not run'
182
185
  }
183
186
 
187
+ /** the line a release or a bump stops on when the gate did not pass: a gate that never ran is not a red one */
188
+ export const gateStop = (gate: number | 'not run', what: 'release' | 'bump'): string =>
189
+ gate === 'not run' ? `the ci gate did not run, so nothing was judged red: fix what the FAIL line above names, then ${what} again` : `ci gate is red on HEAD${what === 'bump' ? ' (the merged result)' : ''} — fix it, commit, then ${what}`
190
+
184
191
  /** the test checks of every sub-unit this release does not ship. No list
185
192
  * given means the caller did not say, and every unit's suite runs. The root
186
193
  * depends on what it contains, so a release that ships it runs them all. A
@@ -307,7 +314,8 @@ export async function releaseUnit(root: string, config: RepoConfig, unit: Releas
307
314
  if (o.skipGate === true)
308
315
  print(o.skipGateReason != null ? `ok: ci gate ${o.skipGateReason}` : 'WARN ci gate SKIPPED by --skip-gate — publishing unverified')
309
316
  else {
310
- if ((await runReleaseGate(root, print, { units: [unit], allowDirty: o.allowDirty })) !== 0) { print('FAIL: ci gate is red on HEAD — fix it, commit, then release'); return 1 }
317
+ const gate = await runReleaseGate(root, print, { units: [unit], allowDirty: o.allowDirty })
318
+ if (gate !== 0) { print(`FAIL: ${gateStop(gate, 'release')}`); return 1 }
311
319
  print('ok: ci gate green')
312
320
  }
313
321
 
@@ -274,6 +274,24 @@ export const withoutCard = (r: Release, card: string): Release => ({
274
274
 
275
275
  export const changesOf = (r: Release): Change[] => r.categories.flatMap((c) => c.changes)
276
276
 
277
+ /** the changes a word names: by its card (the whole id, or the moment it starts with), else by its title, whole
278
+ * before a part of it */
279
+ export function changesNamed(r: Release, ref: string): Change[] {
280
+ const all = changesOf(r)
281
+ const w = ref.trim().toLowerCase()
282
+ if (w === '') return []
283
+ const byCard = all.filter((c) => c.card != null && (c.card.toLowerCase() === w || c.card.toLowerCase().startsWith(`${w}-`)))
284
+ if (byCard.length > 0) return byCard
285
+ const whole = all.filter((c) => c.title.toLowerCase() === w)
286
+ return whole.length > 0 ? whole : all.filter((c) => c.title.toLowerCase().includes(w))
287
+ }
288
+
289
+ /** the release without that one change; a category left empty goes with it */
290
+ export const withoutChange = (r: Release, change: Change): Release => ({
291
+ ...r,
292
+ categories: r.categories.map((c) => ({ ...c, changes: c.changes.filter((x) => x !== change) })).filter((c) => c.changes.length > 0),
293
+ })
294
+
277
295
  /** a change's key on a page: its card, else its title */
278
296
  export const changeKey = (ch: Pick<Change, 'card' | 'title'>): string => `${ch.card ?? ''}${ch.title}`
279
297
 
@@ -4,7 +4,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync } from 'node:f
4
4
  import { join } from 'node:path'
5
5
  import { atomicWrite } from '../core/locked-write.ts'
6
6
  import { LAYOUT } from '../core/layout.ts'
7
- import { byVersion, emptyRelease, fileOf, NEXT, parseRelease, renderRelease, upsertChange, withoutCard, type Change, type Release } from './model.ts'
7
+ import { byVersion, emptyRelease, fileOf, NEXT, parseRelease, renderRelease, upsertChange, withoutCard, type Change, type Release, changesNamed, changesOf, withoutChange } from './model.ts'
8
8
 
9
9
  const FILE = /^(next|\d+\.\d+\.\d+)\.md$/
10
10
 
@@ -37,6 +37,18 @@ export function dropCardChange(root: string, card: string): string | null {
37
37
  return writeRelease(root, withoutCard(r, card))
38
38
  }
39
39
 
40
+ /** next without the one change `ref` names (its card id, or its title), written. Refused when it names none or
41
+ * several: a change is taken out by a name that is its own */
42
+ export function dropChange(root: string, ref: string): { file: string; title: string } {
43
+ const r = readRelease(root, NEXT)
44
+ if (r == null) throw new Error(`${LAYOUT.releases}/${fileOf(NEXT)} does not exist: there is no change to take out`)
45
+ const hits = changesNamed(r, ref)
46
+ const titles = (list: readonly { title: string }[]): string => list.map((c) => `« ${c.title} »`).join(', ')
47
+ if (hits.length === 0) throw new Error(`no change of ${fileOf(NEXT)} has « ${ref} » as its card or in its title; it holds ${titles(changesOf(r)) || 'none'}`)
48
+ if (hits.length > 1) throw new Error(`« ${ref} » names ${hits.length} changes (${titles(hits)}): give the card id or the whole title`)
49
+ return { file: writeRelease(root, withoutChange(r, hits[0]!)), title: hits[0]!.title }
50
+ }
51
+
40
52
  /** one release file, parsed; null when there is none */
41
53
  export function readRelease(root: string, version: string): Release | null {
42
54
  const f = releaseFile(root, version)
@@ -238,6 +238,12 @@ export type RepoConfig = {
238
238
  * for its kind (core/budget.ts). An id no check carries fails the run,
239
239
  * the same as an `off` entry. */
240
240
  budgets?: Record<string, number>
241
+ /** AGENT HOOKS THE GATE CANNOT TIME, each one's command exactly as
242
+ * `.claude/settings.json` writes it → why it answers at once. SK045 runs
243
+ * a hook on every tool call only when it takes a Bash call, so a hook on
244
+ * a save fails the gate unless it is named here; SK046 then warns on the
245
+ * runs the harness recorded. `defineRepo` throws on a blank reason */
246
+ instantHooks?: Record<string, string>
241
247
  /** RETIRED, read as `off` while SK029 ports it there: rule id → the reason
242
248
  * this repo breaks that invariant on purpose. An exempted rule does not
243
249
  * lint and prints a skip line carrying the reason. `defineRepo` throws on
@@ -384,7 +390,7 @@ export type RepoConfig = {
384
390
  logDir?: string
385
391
  }
386
392
 
387
- const KNOWN_KEYS = new Set(['name', 'venues', 'social', 'speaksAs', 'backup', 'annex','docsBase', 'defaults', 'tasks', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'when', 'budgets', 'ruleExempt', 'visibility', 'archived', 'reviewer', 'oneWayIn', 'rules', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'checkDefaults', 'tui', 'serve', 'recorder', 'identity', 'logDir', 'smoke', 'tests', 'browsers', 'start'])
393
+ const KNOWN_KEYS = new Set(['name', 'venues', 'social', 'speaksAs', 'backup', 'annex','docsBase', 'defaults', 'tasks', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'when', 'budgets', 'instantHooks', 'ruleExempt', 'visibility', 'archived', 'reviewer', 'oneWayIn', 'rules', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'checkDefaults', 'tui', 'serve', 'recorder', 'identity', 'logDir', 'smoke', 'tests', 'browsers', 'start'])
388
394
 
389
395
  export function defineRepo(c: RepoConfig): RepoConfig {
390
396
  if (typeof c.name !== 'string' || c.name === '') throw new Error('defineRepo: name is required')
@@ -479,6 +485,10 @@ export function defineRepo(c: RepoConfig): RepoConfig {
479
485
  if (RULE_ID_RE.test(id) && !builtinCheckIds().includes(id) && !(c.rules ?? []).some((r) => r.id === id))
480
486
  throw new Error(`defineRepo: off.${id} names no rule, the ids are in \`shipkit checks\``)
481
487
  }
488
+ for (const [command, reason] of Object.entries(c.instantHooks ?? {})) {
489
+ if (command.trim() === '') throw new Error(`defineRepo: instantHooks has an entry with no command`)
490
+ if (typeof reason !== 'string' || reason.trim() === '') throw new Error(`defineRepo: instantHooks entry \`${command}\` needs a reason: why it answers at once`)
491
+ }
482
492
  // the retired `when`: only its `off:<why>` word still means something
483
493
  for (const [id, raw] of Object.entries(c.when ?? {})) {
484
494
  const w = parseWhen(raw)
@@ -297,7 +297,8 @@ export function cellsOf(t: Thread, items: readonly ReviewItem[]): Cell[] {
297
297
  cells.sort((a, b) => a.at.localeCompare(b.at) || rank[a.kind] - rank[b.kind] || a.id.localeCompare(b.id))
298
298
  const last = t.head.item.id
299
299
  const latest = cells.find((c) => c.id === last)
300
- const answer = cells.findLast((c) => c.party === 'owner' && c.kind !== 'event' && c.id !== last)
300
+ // no findLast: a consumer's own typecheck reads this source, under whatever lib its tsconfig names
301
+ const answer = [...cells].reverse().find((c) => c.party === 'owner' && c.kind !== 'event' && c.id !== last)
301
302
  const unreadIds = new Set(membersOf(t).flatMap((x) => unreadBy(x, 'owner').map((m) => `${x.item.id}/${m.id}`)))
302
303
  for (const c of cells) {
303
304
  if (c.kind === 'event') continue
@@ -150,7 +150,7 @@ export function detail(x: ReviewItem, dir: string, full = false, followed = fals
150
150
  const words = full ? x.thread.filter((m) => (m.text !== undefined || m.op !== undefined) && m.op !== 'seen') : said.filter((m) => m.text !== undefined && m.op === undefined)
151
151
  const pins = said.filter((m) => m.rects !== undefined).at(-1)
152
152
  const first = r.views[0]
153
- const image = first && 'files' in first ? Object.values(first.files) : []
153
+ const image = first && !isGallery(first) ? Object.values(first.files) : []
154
154
  return [
155
155
  `${r.id} ${st.state.toUpperCase()}${st.why ? ` (${st.why})` : ''} raised by ${raisedBy(r.origin)} ${r.created}${r.commit ? ` at ${r.commit}` : ''}`,
156
156
  head,
@@ -0,0 +1,35 @@
1
+ // `sk review inbox --hook`: the inbox as a Claude Code hook, so the owner's answers reach a session that holds no
2
+ // watch. On a prompt (UserPromptSubmit) the unseen answers join the turn as context; at a turn's end (Stop) the turn
3
+ // is refused while one is unseen. An answer is seen once `sk review seen <id>` ran, after the session acted on it.
4
+ // the one constraint a reader breaks first: a Stop the hook already refused once (`stop_hook_active`) passes, else
5
+ // a session that cannot mark an answer seen never ends its turn
6
+
7
+ /** what Claude Code hands a hook on stdin, the two fields read here */
8
+ export type HookInput = { hook_event_name?: string; stop_hook_active?: boolean }
9
+
10
+ export function parseHookInput(text: string): HookInput {
11
+ try {
12
+ const v = JSON.parse(text === '' ? '{}' : text) as unknown
13
+ return typeof v === 'object' && v !== null ? (v as HookInput) : {}
14
+ } catch {
15
+ return {}
16
+ }
17
+ }
18
+
19
+ /** true when the hook answers nothing and the inbox need not be read at all */
20
+ export const hookPasses = (input: HookInput): boolean => input.hook_event_name === 'Stop' && input.stop_hook_active === true
21
+
22
+ /** the one json line the hook prints, or null for none. `unseen`: the answers not marked seen, as the inbox prints
23
+ * them; `owed`: the ids of the answers read and not closed */
24
+ export function hookAnswer(input: HookInput, unseen: string, owed: readonly string[], bin = 'sk'): string | null {
25
+ if (hookPasses(input)) return null
26
+ if (input.hook_event_name === 'Stop') {
27
+ if (unseen === '') return null
28
+ return JSON.stringify({ decision: 'block', reason: `Review answers of the owner are not marked seen. Read each, act on it (relay it to its lane, answer it), then \`${bin} review seen <id>\`:\n${unseen}` })
29
+ }
30
+ const parts = [
31
+ unseen === '' ? '' : `Unseen review answers of the owner (act on each, then \`${bin} review seen <id>\`):\n${unseen}`,
32
+ owed.length === 0 ? '' : `Answers read but not closed (done or wontfix): ${owed.join(', ')}`,
33
+ ].filter((p) => p !== '')
34
+ return parts.length === 0 ? null : JSON.stringify({ hookSpecificOutput: { hookEventName: 'UserPromptSubmit', additionalContext: parts.join('\n\n') } })
35
+ }
@@ -166,6 +166,12 @@ export const tileName = (t: GalleryTile): string => (t.group ? `${t.group}/${t.l
166
166
  export interface GalleryView {
167
167
  label: string
168
168
  gallery: GalleryTile[]
169
+ // a media view's optional fields, absent: `view.marks` reads on any ReviewView. `files` and `size` stay off
170
+ // this type: a consumer narrows with `'files' in view`, which an optional key here would stop
171
+ clip?: undefined
172
+ audio?: undefined
173
+ marks?: undefined
174
+ note?: undefined
169
175
  }
170
176
 
171
177
  export type ReviewView = MediaView | GalleryView
@@ -652,7 +658,8 @@ export function stateOf(x: ReviewItem, superseded: boolean): ItemState {
652
658
  s = i.origin.by === 'agent' ? given : { ...keep, state: 'open' }
653
659
  break
654
660
  case 'blocked':
655
- s = { ...keep, state: 'blocked' }
661
+ // it keeps who blocked it: that worker takes it back or closes it once the owner answered elsewhere
662
+ s = { ...keep, state: 'blocked', worker: m.who }
656
663
  break
657
664
  case 'ready':
658
665
  if (s.state === 'draft') s = { ...keep, state: 'asks' }
@@ -696,12 +703,12 @@ const FROM: Record<Exclude<Op, 'seen'>, readonly State[]> = {
696
703
  answer: ['question'],
697
704
  reassign: ['open', 'claimed'],
698
705
  drop: ['new', 'question', 'open', 'blocked'],
699
- claim: ['open', 'claimed', 'closed'],
706
+ claim: ['open', 'claimed', 'closed', 'blocked'],
700
707
  release: ['claimed'],
701
708
  blocked: ['claimed'],
702
- fixed: ['open', 'claimed'],
709
+ fixed: ['open', 'claimed', 'blocked'],
703
710
  done: ['claimed'],
704
- wontfix: ['open', 'claimed'],
711
+ wontfix: ['open', 'claimed', 'blocked'],
705
712
  withdraw: ['draft', 'asks'],
706
713
  reopen: ['closed', 'claimed'],
707
714
  ready: ['draft'],
@@ -724,6 +731,7 @@ export function allowed(s: ItemState, op: Op, who: string, dispatcher: string |
724
731
  if (op === 'claim' && (who === 'owner' || who === dispatcher)) return `a worker claims, never ${who === 'owner' ? 'the owner' : 'the dispatcher'}`
725
732
  if (WORKER_OPS.has(op) && who !== 'owner' && s.worker !== undefined && s.worker !== who) return `claimed by ${s.worker}, not by ${who}`
726
733
  if (op === 'claim' && s.state === 'claimed' && s.since !== undefined && s.worker !== who) return `already claimed by ${s.worker}: release it first (--as ${s.worker})`
734
+ if (op === 'claim' && s.state === 'blocked' && s.worker !== undefined && s.worker !== who) return `blocked by ${s.worker}, who takes it back (--as ${s.worker}); the dispatcher routes it to another`
727
735
  if (op === 'claim' && s.state === 'closed' && s.why !== 'rejected' && s.why !== 'approved-with-fix')
728
736
  return `claim needs open, or a card he answered « fix » or « no », it is closed (${s.why})`
729
737
  if (!FROM[op].includes(s.state)) {
@@ -775,14 +783,25 @@ export const coversCard = (f: WatchFilter, x: ReviewItem): boolean =>
775
783
  /** who answers an agent's card, its reply or its seen: the worker of a live claim on it, else the lane that made it,
776
784
  * else (a card with no lane) the session that sent it. null when `me` is that one, else why not and the way out.
777
785
  * Another session hearing the verdict (a bare watch) is refused, so it never answers over the maker; a plain approval,
778
- * which owes nothing, anyone marks seen. An item he raised, a player's or an auto one: the claim rules decide */
779
- export function notAnswererOf(x: ReviewItem, me: { lane: string | null; session: string | null }, op: 'reply' | 'seen'): string | null {
786
+ * which owes nothing, anyone marks seen. So does anyone once the maker stopped listening: `heardBy` is the live
787
+ * watches of the store, and when none of a lane or of a session covers the card (the lane ended), whoever reads the
788
+ * answer marks it seen; a reply stays the maker's. An item he raised, a player's or an auto one: the claim rules decide */
789
+ export function notAnswererOf(x: ReviewItem, me: { lane: string | null; session: string | null }, op: 'reply' | 'seen', heardBy?: readonly WatchFilter[]): string | null {
780
790
  const o = x.item.origin
781
791
  if (o.by !== 'agent') return null
782
792
  const s = stateOf(x, false)
783
793
  if (op === 'seen' && s.state === 'closed' && s.why === 'approved') return null
794
+ // a bare watch hears every card and is nobody's own: only a watch of a lane or of a session says the maker listens
795
+ if (op === 'seen' && heardBy !== undefined && !heardBy.some((w) => (w.lane !== null || w.session !== null) && coversCard(w, x))) return null
784
796
  const id = x.item.id
785
- const takeOver = `another lane takes it over with sk review claim ${id} --as <lane>`
797
+ // the way out names claim only where claim takes it
798
+ const noClaim = allowed(s, 'claim', me.lane ?? 'agent', null, false)
799
+ const takeOver =
800
+ noClaim === null
801
+ ? `another lane takes it over with sk review claim ${id} --as <lane>`
802
+ : s.state === 'asks' || s.state === 'draft'
803
+ ? 'no other lane takes it over before the verdict'
804
+ : `no takeover: ${noClaim}`
786
805
  const claimed = s.state === 'claimed' && s.since !== undefined ? s.worker : undefined
787
806
  const lane = claimed ?? o.lane
788
807
  if (lane) return me.lane === lane ? null : `${id} is answered by lane ${lane} (${claimed ? 'its claim' : 'it made the card'}): as that lane, SK_AGENT=${lane} or --as ${lane}; ${takeOver}`