rvlib-shipkit 2.24.0 → 2.25.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 (81) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +1 -1
  3. package/src/agent-time/live.ts +153 -0
  4. package/src/annex/offload.ts +16 -7
  5. package/src/check.ts +3 -1
  6. package/src/checks/SK004-gitignore-policy.check.ts +32 -11
  7. package/src/checks/SK027-agent-wiki-links.check.ts +1 -1
  8. package/src/checks/SK033-global-contribution.check.ts +1 -1
  9. package/src/checks/SK036-draft-media-size.check.ts +1 -1
  10. package/src/checks/SK040-release-words.check.ts +1 -1
  11. package/src/checks/SK042-post-kinds.check.ts +1 -1
  12. package/src/cli/cmd_Annex.ts +12 -7
  13. package/src/cli/cmd_Assets.ts +5 -5
  14. package/src/cli/cmd_Backup.ts +11 -5
  15. package/src/cli/cmd_Capacity.ts +10 -6
  16. package/src/cli/cmd_Checks.ts +12 -1
  17. package/src/cli/cmd_Ci.ts +2 -2
  18. package/src/cli/cmd_Commands.ts +11 -2
  19. package/src/cli/cmd_ConfigKeys.ts +17 -0
  20. package/src/cli/cmd_Home.ts +1 -1
  21. package/src/cli/cmd_Keys.ts +4 -1
  22. package/src/cli/cmd_Lanes.ts +35 -0
  23. package/src/cli/cmd_Mv.ts +6 -7
  24. package/src/cli/cmd_Rec.ts +22 -7
  25. package/src/cli/cmd_Review.ts +107 -39
  26. package/src/cli/cmd_Shot.ts +15 -4
  27. package/src/cli/cmd_Status.ts +6 -5
  28. package/src/cli/cmd_Time.ts +10 -4
  29. package/src/cli/cmd_Veille.ts +10 -6
  30. package/src/cli/family-help.ts +136 -0
  31. package/src/cli/family-pages.ts +0 -19
  32. package/src/cli/kit/calls.ts +35 -0
  33. package/src/cli/kit/project-cli.ts +2 -12
  34. package/src/cli/registry.ts +39 -6
  35. package/src/cli.ts +8 -4
  36. package/src/core/capacity.ts +89 -33
  37. package/src/core/check-runner.ts +5 -1
  38. package/src/core/floor-resolve.ts +6 -2
  39. package/src/core/floor.ts +6 -2
  40. package/src/core/history-files.ts +18 -0
  41. package/src/core/jobs.ts +35 -16
  42. package/src/core/layout.ts +2 -2
  43. package/src/core/nearest.ts +16 -0
  44. package/src/core/remove-tree.ts +19 -0
  45. package/src/core/runs.ts +12 -3
  46. package/src/core/throwaway-worktree.ts +22 -4
  47. package/src/core/trace-audit.ts +17 -4
  48. package/src/home/daemon-jobs.ts +41 -4
  49. package/src/home/machine-temp.ts +2 -10
  50. package/src/ledger/gate-checks.ts +3 -2
  51. package/src/ledger/git-key.ts +25 -4
  52. package/src/ledger/git-scan.ts +10 -0
  53. package/src/media-store/backup/daemon.ts +92 -20
  54. package/src/media-store/backup/run.ts +21 -15
  55. package/src/media-store/backup/sources.ts +166 -21
  56. package/src/media-store/backup/watch.ts +106 -0
  57. package/src/media-store/daemon.ts +36 -8
  58. package/src/media-store/hand.ts +3 -1
  59. package/src/mv/mv-md.ts +50 -18
  60. package/src/pb/run-pb.ts +2 -10
  61. package/src/plan/repo-source.ts +25 -14
  62. package/src/recordings/model.ts +1 -1
  63. package/src/release/run-bump.ts +3 -2
  64. package/src/release/run-release.ts +12 -4
  65. package/src/review/cells.ts +2 -1
  66. package/src/review/format.ts +1 -1
  67. package/src/review/model.ts +14 -1
  68. package/src/review/store.ts +15 -7
  69. package/src/review/trailer-model.ts +2 -2
  70. package/src/shot/client.ts +4 -2
  71. package/src/shot/serve-shot.ts +71 -2
  72. package/src/shot/shooter.ts +65 -11
  73. package/src/shot/shot-ask.ts +32 -9
  74. package/src/suite/select.ts +13 -2
  75. package/src/suite/test-units.ts +31 -12
  76. package/src/trailer/graph.ts +2 -1
  77. package/src/ts/config.ts +12 -35
  78. package/src/ts/rename.ts +31 -17
  79. package/src/ts/workspaces.ts +45 -0
  80. package/src/wiki/run-wiki.ts +7 -2
  81. package/src/wiki/scan-md.ts +2 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## 2.25.0
2
+
3
+ - **A repo adjusts its own lane count.** `sk capacity` answers how many lanes this repo runs now from the cores, the 1 minute load and the agents at work: never zero, `--max <n>` is the count the owner gave, and only a machine at twice its cores of load stops a lane. `sk lanes` shows each live session and lane, since when, and what it does.
4
+ - **A mistyped command answers in two lines** with the close command, the words after the slip kept (`did you mean sk review inbox ?`), where the parser printed every registered command. A family name (`sk gate --help`) lists its family, a word several commands start with lists them, and a known command on a line that does not fit answers with its usage.
5
+ - **`--help` typed after a command's arguments gives its help**, and help read through a pipe carries no colour codes.
6
+ - **`sk status <id> --wait`** holds until the detached gate has a verdict and prints it first: one call in place of a poll. With no id, status reads the latest run `--detach` started, never a job of the daemon. An unknown check id names the close ones.
7
+ - **`sk checks <word>` and `sk config-keys <word>`** keep the rows a word names.
8
+ - **The cache**: a stale lock a killed git left on the scan's index no longer costs a repo its whole cache. A check can mark an input `optional`, and a missing one keys as absent, so the built-in checks that read an optional file replay again. A workspace package a unit imports joins its keys, and another unit's run config no longer reruns every suite.
9
+ - **The daemon's plan** runs a check with no key when its reason changes or a tracked input moved, never at each save whatever moved: its own run wrote files, which was a loop.
10
+ - **The backup's look costs nothing while no source moves.** The daemon watches the sources; a look reads only what moved, a run reads only the files whose size or time moved, and a full walk runs every 30 min as a safety net. A review rule's log is no source.
11
+ - **The media store job** asks a stat before it starts a child: a pass that found nothing waits 5 min unless a store folder moves.
12
+ - **`sk shot`**: a page that navigates while it loads is shot where it lands, `--full` shoots the whole page, a file path is taken, a request the app refused prints its own line, and the warm shot service runs its new code once idle.
13
+ - **`sk mv`**: a longer path that only ends with the moved one is another file and stays; a page moved into a folder that already holds files no longer leaves the tree half moved; a plan, a changelog and a journal stay as written (`--history` rewrites them too), and `sk wiki lint` lets one name a path git once held.
14
+ - **`sk wiki lint`** sees a link with an anchor or a title.
15
+ - **Review**: `add-view` takes `add`'s view flags and never stores a flag as a label; a refusal names a step that works; `withdraw` and `done` on a card already closed say so and exit 0; a short id works in every verb; `withdraw` takes `--note` too; a media field reads on any `ReviewView`, and `'files' in view` still narrows.
16
+ - **`sk annex`** lists in well under a second with one line per repo (`--all` for every link); `sk backup runs` and `sk rec` answer with a count, then the newest.
17
+ - **`sk time`** finds its repo from a subfolder or a worktree, and its first line is the answer; `sk calls` names the command each run was.
18
+ - **The release gate's throwaway checkout** cleans a read only folder a check left in it.
19
+ - **`sk assets fill|add|gen`**: the help says a roll of a comfy asset is a job on the GPU box.
20
+
1
21
  ## 2.24.0
2
22
 
3
23
  - **A slot of the machine pool is one core.** A suite run holds one slot per worker it starts, by its kept suite time (one worker per 4 s, at most half the cores), and gives the slots back when its parallel phase ends. One gate used to start 8 workers per suite whatever its size, and the load that followed closed the pool to one check for the whole machine.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rvlib-shipkit",
3
- "version": "2.24.0",
3
+ "version": "2.25.0",
4
4
  "funding": "https://github.com/sponsors/rvion",
5
5
  "description": "All-in-one repo companion: ci gate (task DAG), auto-discovered health checks, release-contract fulfillness, asks queue, md-wiki tools, asset atelier, live tui",
6
6
  "license": "MIT",
@@ -0,0 +1,153 @@
1
+ // WHO IS AT WORK ON THE MACHINE NOW, read from the transcripts every agent
2
+ // already writes: one row per live session and per live lane (a sub-agent),
3
+ // with what it does this second. No agent reports anything: the view costs
4
+ // no turn.
5
+ //
6
+ // The one constraint a reader breaks first: a transcript is read at its two
7
+ // ends only. A session's file reaches hundreds of megabytes, and this runs
8
+ // each time someone looks.
9
+ import { closeSync, openSync, readFileSync, readSync, statSync } from 'fs'
10
+ import type { TranscriptFile } from './store.ts'
11
+
12
+ const HEAD_BYTES = 64 * 1024
13
+ const TAIL_BYTES = 256 * 1024
14
+ /** a lane's file is read whole to count its calls up to this size; a larger one shows no count */
15
+ const COUNT_MAX_BYTES = 16 * 1024 * 1024
16
+
17
+ export type LiveState =
18
+ | { kind: 'tool'; what: string }
19
+ /** its request to the model is in flight */
20
+ | { kind: 'model' }
21
+ /** its turn ended: a lane is done, a session waits for its user */
22
+ | { kind: 'ended' }
23
+ | { kind: 'unknown' }
24
+
25
+ export type LiveRow = {
26
+ project: string
27
+ /** the folder it works in, as its first entry says: the repo's name comes from it */
28
+ cwd: string
29
+ session: string
30
+ /** '' for a session, the sub-agent's id for a lane */
31
+ agent: string
32
+ /** a lane's description as its orchestrator gave it, '' when none is kept */
33
+ name: string
34
+ model: string
35
+ startedAt: number | null
36
+ /** when its last entry was written, and what that entry says it does */
37
+ at: number
38
+ state: LiveState
39
+ /** tool calls so far, null when the file is too large to count */
40
+ calls: number | null
41
+ }
42
+
43
+ type Entry = { type?: string; timestamp?: string; message?: { content?: unknown } }
44
+ type Part = { type?: string; name?: string; input?: Record<string, unknown> }
45
+
46
+ const parts = (e: Entry): Part[] => (Array.isArray(e.message?.content) ? (e.message.content as Part[]) : [])
47
+
48
+ /** a tool call in a few words: the command's head, the file's name, a sub-agent's description */
49
+ export function callWords(p: Part): string {
50
+ const i = p.input ?? {}
51
+ const text = (v: unknown): string => (typeof v === 'string' ? v : '')
52
+ const head = text(i.command) || text(i.description) || (text(i.file_path).split('/').at(-1) ?? '') || text(i.pattern) || text(i.query) || text(i.skill)
53
+ const one = head.replace(/\s+/g, ' ').trim()
54
+ return `${p.name ?? 'tool'}${one === '' ? '' : `: ${one.length > 70 ? `${one.slice(0, 69)}…` : one}`}`
55
+ }
56
+
57
+ /** the call a sub-agent ends on: its report handed back to the session that started it */
58
+ const HAND_BACK = 'SubagentHandback'
59
+
60
+ /** what the last entries of a transcript say the agent does now. `lines` are its last lines, oldest first */
61
+ export function stateOf(lines: readonly string[]): { state: LiveState; at: number } {
62
+ // a result just came back, or a request is in flight: a model turn, unless the call before it was the hand back
63
+ let waiting: number | null = null
64
+ for (let n = lines.length - 1; n >= 0; n--) {
65
+ let e: Entry
66
+ try { e = JSON.parse(lines[n]!) as Entry } catch { continue }
67
+ const at = e.timestamp == null ? NaN : Date.parse(e.timestamp)
68
+ if (!Number.isFinite(at)) continue
69
+ if (e.type === 'api-request' || e.type === 'user') { waiting ??= at; continue }
70
+ if (e.type !== 'assistant') continue
71
+ const calls = parts(e).filter((p) => p.type === 'tool_use')
72
+ if (calls.some((p) => p.name === HAND_BACK)) return { state: { kind: 'ended' }, at: waiting ?? at }
73
+ if (waiting != null) return { state: { kind: 'model' }, at: waiting }
74
+ return calls.length > 0 ? { state: { kind: 'tool', what: calls.map(callWords).join(' + ') }, at } : { state: { kind: 'ended' }, at }
75
+ }
76
+ return waiting != null ? { state: { kind: 'model' }, at: waiting } : { state: { kind: 'unknown' }, at: 0 }
77
+ }
78
+
79
+ const slice = (path: string, from: number, bytes: number): string => {
80
+ const fd = openSync(path, 'r')
81
+ try {
82
+ const buf = Buffer.alloc(bytes)
83
+ return buf.subarray(0, readSync(fd, buf, 0, bytes, from)).toString('utf8')
84
+ } finally { closeSync(fd) }
85
+ }
86
+
87
+ /** one live transcript read at its two ends. `calls: false` skips the count, the one read of the whole file */
88
+ export function liveRow(f: TranscriptFile, o: { calls?: boolean } = {}): LiveRow {
89
+ const size = statSync(f.path).size
90
+ const tail = slice(f.path, Math.max(0, size - TAIL_BYTES), Math.min(size, TAIL_BYTES)).split('\n').filter((l) => l !== '')
91
+ // the first line of a tail cut mid file is a fragment
92
+ const { state, at } = stateOf(size > TAIL_BYTES ? tail.slice(1) : tail)
93
+ const head = slice(f.path, 0, Math.min(size, HEAD_BYTES))
94
+ const stamp = /"timestamp":"([^"]+)"/.exec(head)
95
+ const startedAt = stamp == null ? null : Date.parse(stamp[1]!)
96
+ const cwd = /"cwd":"([^"]+)"/.exec(head)?.[1] ?? ''
97
+ let name = ''
98
+ let model = ''
99
+ if (f.agent !== '') {
100
+ try {
101
+ const meta = JSON.parse(readFileSync(f.path.replace(/\.jsonl$/, '.meta.json'), 'utf8')) as { description?: unknown; model?: unknown; agentType?: unknown }
102
+ name = typeof meta.description === 'string' ? meta.description : typeof meta.agentType === 'string' ? meta.agentType : ''
103
+ model = typeof meta.model === 'string' ? meta.model : ''
104
+ } catch { /* an agent with no meta file keeps its id as its name */ }
105
+ }
106
+ const calls = o.calls === false || size > COUNT_MAX_BYTES ? null : (readFileSync(f.path, 'utf8').match(/"type":"tool_use"/g) ?? []).length
107
+ return { project: f.project, cwd, session: f.session, agent: f.agent, name, model, startedAt: startedAt != null && Number.isFinite(startedAt) ? startedAt : null, at: at > 0 ? at : f.mtime, state, calls }
108
+ }
109
+
110
+ const span = (ms: number): string => {
111
+ const s = Math.max(0, Math.round(ms / 1000))
112
+ return s < 60 ? `${s}s` : s < 3600 ? `${Math.floor(s / 60)}m` : `${Math.floor(s / 3600)}h${String(Math.floor((s % 3600) / 60)).padStart(2, '0')}`
113
+ }
114
+
115
+ const doing = (r: LiveRow, now: number): string => {
116
+ const age = span(now - r.at)
117
+ return r.state.kind === 'tool' ? `${r.state.what} (${age})`
118
+ : r.state.kind === 'model' ? `model turn (${age})`
119
+ : r.state.kind === 'ended' ? `${r.agent === '' ? 'waits for its user' : 'ended'} (${age})`
120
+ : `last wrote ${age} ago`
121
+ }
122
+
123
+ /** the repo a row belongs to: the name of the folder it works in, a linked worktree counted with its repo */
124
+ export const repoOf = (r: { cwd: string; project: string }): string =>
125
+ r.cwd === '' ? r.project : r.cwd.replace(/\/\.claude\/worktrees\/.*$/, '').split('/').filter((w) => w !== '').at(-1) ?? r.project
126
+
127
+ /** one row an agent: a session resumed from another folder writes the same transcript under both, the newest stands */
128
+ export function oneRowAnAgent<T extends { session: string; agent: string; mtime: number }>(files: readonly T[]): T[] {
129
+ const by = new Map<string, T>()
130
+ for (const f of files) {
131
+ const k = `${f.session}/${f.agent}`
132
+ const seen = by.get(k)
133
+ if (seen == null || f.mtime > seen.mtime) by.set(k, f)
134
+ }
135
+ return [...by.values()]
136
+ }
137
+
138
+ /** the rows as a table, repos in name order, a session before its lanes */
139
+ export function liveTable(rows: readonly LiveRow[], now: number): string[] {
140
+ if (rows.length === 0) return ['no agent wrote in the window']
141
+ const sorted = [...rows].sort((a, b) => repoOf(a).localeCompare(repoOf(b)) || a.session.localeCompare(b.session) || (a.agent === '' ? -1 : b.agent === '' ? 1 : (a.startedAt ?? 0) - (b.startedAt ?? 0)))
142
+ const cells = sorted.map((r) => [
143
+ repoOf(r),
144
+ r.agent === '' ? `session ${r.session.slice(0, 8)}` : ` ${r.name === '' ? r.agent.slice(0, 12) : r.name}${r.model === '' ? '' : ` [${r.model}]`}`,
145
+ r.startedAt == null ? '?' : span(now - r.startedAt),
146
+ r.calls == null ? '-' : String(r.calls),
147
+ doing(r, now),
148
+ ])
149
+ const head = ['repo', 'who', 'since', 'calls', 'now']
150
+ const w = head.map((h, i) => Math.max(h.length, ...cells.map((c) => c[i]!.length)))
151
+ const line = (c: string[]): string => c.map((x, i) => (i === c.length - 1 ? x : i === 3 ? x.padStart(w[i]!) : x.padEnd(w[i]!))).join(' ').trimEnd()
152
+ return [line(head), ...cells.map(line)]
153
+ }
@@ -397,16 +397,25 @@ export async function drift(root: string): Promise<Drift[]> {
397
397
  }
398
398
  }
399
399
  const targets = offloads().map((x) => x.target)
400
- const reached = (p: string): boolean => targets.some((t) => p === t || p.startsWith(`${t}/`) || t.startsWith(`${p}/`))
401
400
  for (const a of await presentAnnexes()) {
402
401
  const dir = join(a.path, 'offload', basename(root))
403
402
  if (!existsSync(dir)) continue
404
- for (const e of entries(dir)) {
405
- const p = join(dir, e.rel)
406
- if (e.dir || reached(p) || /\.\d+\.part(\/|$)/.test(p)) continue
407
- out.push({ kind: 'orphan', path: p, why: 'on the annex, and no recorded offload of any repo reaches it', fix: `nothing on the Mac reaches it: delete ${p}` })
408
- break
409
- }
403
+ const p = firstOrphan(dir, targets)
404
+ if (p !== undefined) out.push({ kind: 'orphan', path: p, why: 'on the annex, and no recorded offload of any repo reaches it', fix: `nothing on the Mac reaches it: delete ${p}` })
410
405
  }
411
406
  return out
412
407
  }
408
+
409
+ /** the first file under `dir` no target reaches, depth first; a folder a target reaches, or a copy in flight
410
+ * (`<name>.<n>.part`), is never read: the drive holds hundreds of thousands of files under the targets */
411
+ function firstOrphan(dir: string, targets: readonly string[]): string | undefined {
412
+ for (const e of readdirSync(dir, { withFileTypes: true })) {
413
+ if (/\.\d+\.part$/.test(e.name)) continue
414
+ const p = join(dir, e.name)
415
+ if (targets.some((t) => p === t || p.startsWith(`${t}/`))) continue
416
+ if (!e.isDirectory()) return p
417
+ const found = firstOrphan(p, targets)
418
+ if (found !== undefined) return found
419
+ }
420
+ return undefined
421
+ }
package/src/check.ts CHANGED
@@ -90,7 +90,9 @@ export type CheckDef = {
90
90
  * not own OFF with `off` in repo.config.ts, never elsewhere. */
91
91
  runs: Runs
92
92
  /** HOW ITS ANSWER IS KEPT, one variant, every parameter explicit:
93
- * `files` (keyed on these paths), `reads` (keyed on what the body read),
93
+ * `files` (keyed on these paths; `optional` names the ones a repo may
94
+ * lack, keyed as absent, and any other missing path refuses the key),
95
+ * `reads` (keyed on what the body read),
94
96
  * `ttl` (a world answer that keeps a span), `fact` (a decided value, once
95
97
  * per key), `never` (with the reason). The file's own path joins every
96
98
  * key automatically, so nothing declares its own code. */
@@ -32,12 +32,11 @@ const CONTRIB = '# repo-contributed lines (repo.config.ts gitignore:)'
32
32
 
33
33
  const DRAFTS_BACK = '!.comfy-ts/drafts/'
34
34
  const SOCIAL_BACK = `!${LAYOUT.social}/`
35
- const VOICE_BACK = `!${LAYOUT.voice}/`
36
35
 
37
36
  /** re-includes a private repo carries and a declared public one drops: a
38
37
  * draft names private loras, a plan or a board quotes the owner, a social
39
- * draft carries his angles and notes, a take is his own voice */
40
- const PRIVATE_ONLY: ReadonlySet<string> = new Set([DRAFTS_BACK, `!${LAYOUT.plans}/`, SOCIAL_BACK, VOICE_BACK])
38
+ * draft carries his angles and notes */
39
+ const PRIVATE_ONLY: ReadonlySet<string> = new Set([DRAFTS_BACK, `!${LAYOUT.plans}/`, SOCIAL_BACK])
41
40
 
42
41
  export const POLICY_LINES = [
43
42
  // everything shipkit keeps lives under .shipkit/ (core/layout.ts). Local
@@ -51,9 +50,11 @@ export const POLICY_LINES = [
51
50
  // desks date posts from. A rendered trailer is made again by its command
52
51
  SOCIAL_BACK,
53
52
  `${LAYOUT.social}/drafts/**/*-trailer.mp4`,
54
- // his takes of a trailer's lines: a recording is never made again
55
- VOICE_BACK,
56
53
  `${LAYOUT.assets}/out/`,
54
+ // recordings of a person's own voice never go to git, in any repo: covered
55
+ // by `.shipkit/*` and spelled out so this check asks git about it (the
56
+ // backup keeps the files)
57
+ `${LAYOUT.voice}/takes/`,
57
58
  // already covered by the line above, and spelled out anyway so this check
58
59
  // asks git about it: a negation below the block that exposed the keyword
59
60
  // list would otherwise pass as a venue override
@@ -165,12 +166,12 @@ async function trackedGenerated(d: Disk): Promise<string[]> {
165
166
  return GENERATED_TRACKED_PATHS.filter((p) => listed.has(p))
166
167
  }
167
168
 
168
- /** a declared public repo's files under the private only folders git still tracks: the block ignores what git does
169
- * not hold yet, never a file tracked before the flip */
169
+ /** files git still tracks under a folder this repo keeps local: the private only folders of a declared public repo,
170
+ * and recorded voice in any repo. The block ignores what git does not hold yet, never a file tracked before */
170
171
  async function trackedPrivate(d: Disk, config: RepoConfig): Promise<Map<string, number>> {
171
172
  const out = new Map<string, number>()
172
- if (!declaredPublic(config) || !d.exists('.git')) return out
173
- const dirs = [LAYOUT.plans, LAYOUT.social, LAYOUT.voice]
173
+ if (!d.exists('.git')) return out
174
+ const dirs = [...(declaredPublic(config) ? [LAYOUT.plans, LAYOUT.social] : []), LAYOUT.voice]
174
175
  const r = await d.exec([gitBin(), 'ls-files', '-z', '--', ...dirs], { cwd: d.root })
175
176
  if (r.code !== 0) return out
176
177
  for (const f of r.out.split('\0')) {
@@ -203,6 +204,17 @@ function blockState(d: Disk, config: RepoConfig, legacy: boolean): BlockState {
203
204
  return f.lines.slice(f.b, f.e + 1).join('\n') === expectedBlock(config, legacy) ? 'current' : 'stale'
204
205
  }
205
206
 
207
+ /** the lines of a well-formed block the current one no longer holds: a line a repo wrote inside it, or one the policy
208
+ * retired. Only the repair removes them, and it names each */
209
+ export function removedLines(text: string | null, config: RepoConfig, legacy = false): string[] {
210
+ const f = parseText(text)
211
+ if (f == null || f.b === -1 || f.e === -1 || f.e < f.b) return []
212
+ const kept = new Set([...expectedBlock(config, legacy).split('\n'), CONTRIB, LEGACY])
213
+ return f.lines.slice(f.b + 1, f.e).filter((l) => l.trim() !== '' && !kept.has(l))
214
+ }
215
+
216
+ const REMOVED_FIX = 'a line of the repo goes below the block, or in repo.config.ts gitignore:'
217
+
206
218
  function writeBlock(d: Disk, config: RepoConfig, legacy: boolean): void {
207
219
  d.write('.gitignore', withBlock(d.read('.gitignore'), config, legacy))
208
220
  }
@@ -263,6 +275,12 @@ export const gitignorePolicy = check({
263
275
  // every run that may write renders it in place, so a policy change never
264
276
  // turns the whole fleet red until each repo runs its gate
265
277
  if (s === 'stale') {
278
+ const removed = removedLines(c.read('.gitignore'), c.config, legacy)
279
+ if (removed.length > 0) {
280
+ c.warn(`.gitignore policy block is stale, and its rewrite removes ${removed.join(', ')}: left for the repair, which names each line`)
281
+ c.lines.push({ kind: 'fix-warn', text: `${REMOVED_FIX}; sk ci (or check --fix SK004) rewrites it` })
282
+ return
283
+ }
266
284
  if (c.frozen) {
267
285
  c.warn('.gitignore policy block is stale: the policy moved, and a frozen run rewrites nothing')
268
286
  c.lines.push({ kind: 'fix-warn', text: 'any run that is not frozen rewrites it in place (sk check, sk ci)' })
@@ -324,7 +342,8 @@ export const gitignorePolicy = check({
324
342
  }
325
343
  c.ok(`.gitignore policy block current, ${claimed.length + backProbes.size} patterns verified against git`)
326
344
  for (const [dir, n] of await trackedPrivate(c, c.config)) {
327
- c.warn(`a public repo still tracks ${n} file${n === 1 ? '' : 's'} under ${dir}/: strangers read them, and the block keeps only new ones local`)
345
+ const files = `${n} file${n === 1 ? '' : 's'} under ${dir}/`
346
+ c.warn(dir === LAYOUT.voice ? `this repo still tracks ${files}: recorded voice, and the block keeps only new ones local` : `a public repo still tracks ${files}: strangers read them, and the block keeps only new ones local`)
328
347
  c.lines.push({ kind: 'fix-warn', text: `git rm -r --cached -q ${dir} && git commit -m "untrack ${dir}" -- ${dir} (the files stay on the disk)` })
329
348
  }
330
349
  },
@@ -344,12 +363,14 @@ export const gitignorePolicy = check({
344
363
  c.write('.gitignore', `${c.read('.gitignore') ?? ''}\n`)
345
364
  terminated = '.gitignore terminated with a newline (the next append would have fused onto its last line)'
346
365
  }
366
+ const removed = before === 'stale' ? removedLines(c.read('.gitignore'), c.config, legacy) : []
347
367
  const blockSummary = before === 'current'
348
368
  ? null
349
369
  : before === 'missing-file' ? '.gitignore created with the policy block'
350
370
  : before === 'missing-block' ? 'policy block appended (repo lines untouched)'
351
371
  : before === 'corrupted' ? 'policy block rebuilt (stray markers dropped, repo lines kept visible)'
352
- : 'policy block rewritten in place (repo lines untouched)'
372
+ : removed.length > 0 ? `policy block rewritten in place, removed from it: ${removed.join(', ')} (${REMOVED_FIX})`
373
+ : 'policy block rewritten in place (repo lines outside it untouched)'
353
374
  if (blockSummary != null) writeBlock(c, c.config, legacy)
354
375
  // the block must be written FIRST: untracking a path the ignore list
355
376
  // does not yet carry leaves it staged for re-add on the next `git add`.
@@ -23,7 +23,7 @@ export const agentWikiLinks = check({
23
23
  owner: 'meta/agent-folder/index.md',
24
24
  runs: { onPreCommit: false, onCi: true, onFull: true, onRelease: true, onHealth: true, onSave: 'moved', onClock: false },
25
25
  // the md lint walks agent/ on disk rather than through `c`; the loaded context starts at CLAUDE.md
26
- cache: { by: 'files', inputs: ['agent', 'CLAUDE.md', 'CLAUDE.local.md'], key: null },
26
+ cache: { by: 'files', inputs: ['agent', 'CLAUDE.md', 'CLAUDE.local.md'], optional: ['agent', 'CLAUDE.md', 'CLAUDE.local.md'], key: null },
27
27
  fix: 'none',
28
28
  applies: 'always',
29
29
  run: (c) => {
@@ -31,7 +31,7 @@ export const globalContribution = check({
31
31
  owner: 'meta/agent-folder/index.md',
32
32
  runs: { onPreCommit: false, onCi: true, onFull: true, onRelease: true, onHealth: true, onSave: 'moved', onClock: false },
33
33
  // the file sits in the agent folder CLAUDE.md names: agent/, or a folder of the repo's wiki/
34
- cache: { by: 'files', inputs: ['CLAUDE.md', 'agent/global-contribution.md', 'wiki'], key: null },
34
+ cache: { by: 'files', inputs: ['CLAUDE.md', 'agent/global-contribution.md', 'wiki'], optional: ['CLAUDE.md', 'agent/global-contribution.md', 'wiki'], key: null },
35
35
  fix: 'ci',
36
36
  applies: (env) => notHouse(env.root),
37
37
  run: (c) => {
@@ -13,7 +13,7 @@ export const draftMediaSize = check({
13
13
  owner: 'tools/shipkit/social.md',
14
14
  runs: { onPreCommit: { budgetMs: 60 }, onCi: true, onFull: true, onRelease: true, onHealth: true, onSave: 'moved', onClock: false },
15
15
  // the folder's files; the hook runs it raw on the index, so a file staged since a cached green is still seen there
16
- cache: { by: 'files', inputs: [LAYOUT.social], key: null },
16
+ cache: { by: 'files', inputs: [LAYOUT.social], optional: [LAYOUT.social], key: null },
17
17
  fix: 'none',
18
18
  applies: 'always',
19
19
  run: (c) => {
@@ -20,7 +20,7 @@ export const releaseWords = check({
20
20
  owner: 'tools/shipkit/units.md',
21
21
  runs: { onPreCommit: false, onCi: true, onFull: true, onRelease: true, onHealth: true, onSave: 'moved', onClock: false },
22
22
  // the release files and the messages store the guard reads, and the text of the social unit files that declare it
23
- cache: { by: 'files', inputs: [LAYOUT.releases, '.shipkit/messages'], key: (env) => unitFilesDeclaring(env.root, 'social').map((f) => `${f}:${Bun.hash(readFileSync(f, 'utf8'))}`).join('\n') },
23
+ cache: { by: 'files', inputs: [LAYOUT.releases, '.shipkit/messages'], optional: [LAYOUT.releases, '.shipkit/messages'], key: (env) => unitFilesDeclaring(env.root, 'social').map((f) => `${f}:${Bun.hash(readFileSync(f, 'utf8'))}`).join('\n') },
24
24
  fix: 'none',
25
25
  applies: 'always',
26
26
  run: async (c) => {
@@ -31,7 +31,7 @@ export const postKinds = check({
31
31
  owner: 'tools/shipkit/built-in-checks-contracts-and-visibility.md',
32
32
  runs: { onPreCommit: false, onCi: true, onFull: true, onRelease: true, onHealth: true, onSave: 'moved', onClock: false },
33
33
  // the social folder, the text of the social unit files that declare its own kinds, and each page they name
34
- cache: { by: 'files', inputs: [LAYOUT.social], key: (env) => unitFilesDeclaring(env.root, 'social').map((f) => unitKey(env.root, f)).join('\n') },
34
+ cache: { by: 'files', inputs: [LAYOUT.social], optional: [LAYOUT.social], key: (env) => unitFilesDeclaring(env.root, 'social').map((f) => unitKey(env.root, f)).join('\n') },
35
35
  fix: 'none',
36
36
  applies: 'always',
37
37
  run: async (c) => {
@@ -31,10 +31,11 @@ export class AnnexCommand extends Command {
31
31
  static override paths = [['annex']]
32
32
  static override usage = Command.Usage({
33
33
  category: 'Annex',
34
- description: 'each annex: present or not, free space, its media, every offloaded folder and its link',
35
- details: `${DETAILS}\n\nA folder with no marker where an annex should be is named: the drive is unplugged, or a phantom folder took its place.`,
36
- examples: [['where the annexes stand', 'sk annex']],
34
+ description: 'each annex: present or not, free space, its media, the offloaded folders, each link that fails',
35
+ details: `${DETAILS}\n\nA folder with no marker where an annex should be is named: the drive is unplugged, or a phantom folder took its place. Each repo with offloaded folders takes one line; a folder whose link does not hold is named under it with the command that settles it. --all lists every folder.`,
36
+ examples: [['where the annexes stand', 'sk annex'], ['every offloaded folder', 'sk annex --all']],
37
37
  })
38
+ all = Option.Boolean('--all', false, { description: 'list every offloaded folder, its links that hold included' })
38
39
  async execute(): Promise<number> {
39
40
  return run(this.context, async (out) => {
40
41
  const { annexSpecs, driveFree, isPresent, mediaFiles } = await import('../annex/annex.ts')
@@ -66,12 +67,16 @@ export class AnnexCommand extends Command {
66
67
  for (const l of waitingBorn()) out(` waits: ${l.replace(/^WARN annex: /, '')}`)
67
68
  for (const repo of [...new Set(list.map((x) => x.repo))]) {
68
69
  const bad = new Map((await drift(repo)).map((d) => [d.path, d] as const))
69
- for (const x of list.filter((y) => y.repo === repo)) {
70
+ const mine = list.filter((y) => y.repo === repo)
71
+ const born = mine.filter((x) => x.born).length
72
+ const moved = mine.reduce((s, x) => s + (x.born ? 0 : x.bytes), 0)
73
+ out(` ${repo} ${mine.length} ${mine.length === 1 ? 'folder' : 'folders'} (${born} born, ${gb(moved)} moved) ${bad.size === 0 ? 'every link holds' : `${bad.size} ${bad.size === 1 ? 'needs' : 'need'} a hand`}`)
74
+ for (const x of mine) {
70
75
  const d = bad.get(`${x.repo}/${x.rel}`)
71
- out(` ${repo}/${x.rel} ${x.born ? 'born' : `${gb(x.bytes)} moved`} ${d ? `${d.kind.toUpperCase()}: ${d.why}` : 'link holds'}`)
76
+ if (d || this.all) out(` ${x.rel} ${x.born ? 'born' : `${gb(x.bytes)} moved`} ${d ? `${d.kind.toUpperCase()}: ${d.why}` : 'link holds'}`)
72
77
  }
73
- for (const d of bad.values()) if (d.kind === 'orphan' || !list.some((x) => `${x.repo}/${x.rel}` === d.path)) out(` ${d.kind.toUpperCase()} ${d.path}: ${d.why}`)
74
- for (const d of bad.values()) out(` → ${d.fix}`)
78
+ for (const d of bad.values()) if (d.kind === 'orphan' || !list.some((x) => `${x.repo}/${x.rel}` === d.path)) out(` ${d.kind.toUpperCase()} ${d.path}: ${d.why}`)
79
+ for (const d of bad.values()) out(` → ${d.fix}`)
75
80
  }
76
81
  const { readdirSync } = await import('node:fs')
77
82
  const { join } = await import('node:path')
@@ -21,10 +21,10 @@ export class AssetsFillCommand extends Command {
21
21
 
22
22
  static override usage = Command.Usage({
23
23
  category: 'Assets',
24
- description: 'top rolls up to N per asset (canvas or comfy), sparsest-first',
24
+ description: 'top rolls up to N per asset, sparsest first; a comfy asset renders on the GPU box, a job a roll',
25
25
  examples: [
26
- ['every asset up to 8 rolls', 'sk assets fill 8'],
27
26
  ['only two categories', 'sk assets fill 8 icons sprites'],
27
+ ['every asset up to 8 rolls: one GPU job for each roll missing', 'sk assets fill 8'],
28
28
  ],
29
29
  })
30
30
 
@@ -46,8 +46,8 @@ export class AssetsAddCommand extends Command {
46
46
 
47
47
  static override usage = Command.Usage({
48
48
  category: 'Assets',
49
- description: 'N more rolls per asset (canvas or comfy), regardless of what it has',
50
- examples: [['3 fresh rolls everywhere', 'sk assets add 3']],
49
+ description: 'N more rolls per asset, whatever it has; a comfy asset renders on the GPU box, a job a roll',
50
+ examples: [['3 fresh rolls for one category', 'sk assets add 3 icons'], ['3 fresh rolls everywhere: 3 GPU jobs for each comfy asset', 'sk assets add 3']],
51
51
  })
52
52
 
53
53
  n = Option.String({ required: true })
@@ -68,7 +68,7 @@ export class AssetsGenCommand extends Command {
68
68
 
69
69
  static override usage = Command.Usage({
70
70
  category: 'Assets',
71
- description: 'one-shot rolls for a single asset (canvas or comfy)',
71
+ description: 'rolls for one asset now; a comfy asset renders on the GPU box, a job a roll',
72
72
  examples: [
73
73
  ['one roll', 'sk assets gen hero'],
74
74
  ['five rolls', 'sk assets gen hero --n 5'],
@@ -77,20 +77,26 @@ export class BackupCommand extends Command {
77
77
  }
78
78
  }
79
79
 
80
+ /** the runs `sk backup runs` prints without --all: a run every few minutes makes thousands */
81
+ const RUNS_SHOWN = 20
82
+
80
83
  export class BackupRunsCommand extends Command {
81
84
  static override paths = [['backup', 'runs']]
82
85
  static override usage = Command.Usage({
83
86
  category: 'Media',
84
- description: 'every backup run the Space holds, oldest first: its time, machine and manifest key',
85
- details: DETAILS,
86
- examples: [['the runs', 'sk backup runs']],
87
+ description: 'the backup runs in the Space, newest first: the count per machine, then time, machine and key',
88
+ details: `${DETAILS}\n\nThe first line counts the runs per machine; the newest ${RUNS_SHOWN} follow, newest first. --all lists every run, oldest first.`,
89
+ examples: [['the latest runs', 'sk backup runs'], ['every run', 'sk backup runs --all']],
87
90
  })
91
+ all = Option.Boolean('--all', false, { description: 'every run, oldest first' })
88
92
  async execute(): Promise<number> {
89
93
  return run(this.context, async (h) => {
90
94
  const { runsOf } = await import('../media-store/backup/manifest.ts')
91
95
  const runs = await runsOf(h.space)
92
- for (const r of runs) h.out(`${r.at.toISOString()} ${r.machine ?? '(host inside)'} ${r.key} ${(r.size / 1e3).toFixed(0)} kB`)
93
- h.out(`${runs.length} runs`)
96
+ const per = new Map<string, number>()
97
+ for (const r of runs) per.set(r.machine ?? '(host inside)', (per.get(r.machine ?? '(host inside)') ?? 0) + 1)
98
+ h.out(`${runs.length} runs: ${[...per].map(([m, n]) => `${n} of ${m}`).join(', ')}${!this.all && runs.length > RUNS_SHOWN ? `; the newest ${RUNS_SHOWN} below, --all for every one` : ''}`)
99
+ for (const r of this.all ? runs : runs.slice(-RUNS_SHOWN).reverse()) h.out(`${r.at.toISOString()} ${r.machine ?? '(host inside)'} ${r.key} ${(r.size / 1e3).toFixed(0)} kB`)
94
100
  return 0
95
101
  })
96
102
  }
@@ -1,4 +1,4 @@
1
- // sk capacity: how many more lanes the machine can take now. Report only, exit 0 always: the orchestrator decides.
1
+ // sk capacity: how many lanes this repo runs now. Report only, exit 0 always: the orchestrator decides.
2
2
  import { Command, Option } from 'clipanion'
3
3
  import { capacityLines, readCapacity } from '../core/capacity.ts'
4
4
 
@@ -8,19 +8,23 @@ export class CapacityCommand extends Command {
8
8
 
9
9
  static override usage = Command.Usage({
10
10
  category: 'Health',
11
- description: 'how many more lanes the machine can take now: its cores, its load, the agents live on it',
12
- details: 'reads the cores, the 1 and 5 minute load and the agents whose transcript moved in the last 3 minutes, every account and repo. A lane counts for the load the live agents share, never under one core. Run it before a lane starts: no room means the lane waits on the board. Report only, exit 0 always.',
11
+ description: 'how many lanes this repo runs now: the machine\'s cores, its load, the lanes live on it',
12
+ details: 'reads the cores, the 1 minute load and the agents whose transcript moved in the last 3 minutes, every account and repo. The answer is this repo\'s live lanes plus one a free core, never under one. --max <n> is the maximum the owner gave: it replaces the number. Only a dying machine (a load of twice its cores) stops a lane, the maximum included. Run it before a lane starts. Report only, exit 0 always.',
13
13
  examples: [
14
14
  ['before a lane starts', 'sk capacity'],
15
+ ['with the maximum the owner gave', 'sk capacity --max 5'],
15
16
  ['machine readable', 'sk capacity --json'],
16
17
  ],
17
18
  })
18
19
 
19
- json = Option.Boolean('--json', false, { description: 'the measure and the room as json' })
20
+ max = Option.String('--max', { description: 'the maximum the owner gave: the lanes to run, whatever the load, short of a dying machine' })
21
+ json = Option.Boolean('--json', false, { description: 'the measure and the answer as json' })
20
22
 
21
23
  async execute(): Promise<number> {
22
- const { capacity, live } = readCapacity()
23
- this.context.stdout.write(this.json ? `${JSON.stringify({ ...capacity, live })}\n` : `${capacityLines(capacity, live).join('\n')}\n`)
24
+ const max = this.max == null ? null : Number(this.max)
25
+ if (max != null && !(Number.isInteger(max) && max >= 1)) { this.context.stdout.write(`FAIL: --max takes a whole number of lanes, 1 or more, got ${this.max}\n`); return 2 }
26
+ const { capacity, live, repo } = readCapacity(process.cwd(), max)
27
+ this.context.stdout.write(this.json ? `${JSON.stringify({ ...capacity, repo, live })}\n` : `${capacityLines(capacity, live, repo).join('\n')}\n`)
24
28
  return 0
25
29
  }
26
30
  }
@@ -23,9 +23,10 @@ export class ChecksCommand extends Command {
23
23
  static override usage: Usage | undefined = Command.Usage({
24
24
  category: 'Health',
25
25
  description: 'every gate check on one table: source, blocking or warning, cache',
26
- details: 'every gate check on one table: where it comes from, whether it blocks or only warns, whether the gate runs it or only `shipkit check`, and how it caches. Reports, never gates',
26
+ details: 'every gate check on one table: where it comes from, whether it blocks or only warns, whether the gate runs it or only `shipkit check`, and how it caches. A word keeps the checks whose id or title holds it. Reports, never gates',
27
27
  examples: [
28
28
  ['the whole inventory', 'sk checks'],
29
+ ['only the checks whose id or title holds a word', 'sk checks test'],
29
30
  ['the big markdown table, written to a file', 'sk checks --out STATUS.full.md'],
30
31
  ['only the ones the gate never runs', 'sk checks --proactive'],
31
32
  ['everything that repairs itself, with its owner', 'sk checks --fixable'],
@@ -40,6 +41,7 @@ export class ChecksCommand extends Command {
40
41
  proactive = Option.Boolean('--proactive', false, { description: 'only checks the gate never runs (`shipkit check` reports them)' })
41
42
  fixable = Option.Boolean('--fixable', false, { description: 'only checks that carry an autofix, with the page that owns the invariant — `shipkit check --fix <id>` applies one' })
42
43
  full = Option.Boolean('--full', false, { description: 'resolve every check the way a FULL-tier run resolves it' })
44
+ word = Option.String({ required: false })
43
45
 
44
46
  async execute(): Promise<number> {
45
47
  const root = process.cwd()
@@ -49,6 +51,15 @@ export class ChecksCommand extends Command {
49
51
  if (this.blocking) rows = rows.filter((r) => r.blocking !== false)
50
52
  if (this.proactive) rows = rows.filter((r) => r.when.at !== 'always')
51
53
  if (this.fixable) rows = rows.filter((r) => r.fixable)
54
+ if (this.word != null) {
55
+ const w = this.word.toLowerCase()
56
+ const all = rows
57
+ rows = rows.filter((r) => r.decl.id.toLowerCase().includes(w) || r.title.toLowerCase().includes(w))
58
+ if (rows.length === 0) {
59
+ this.context.stdout.write(`FAIL: no check of this repo has « ${this.word} » in its id or title (${all.length} looked at)\n fix: shipkit checks lists every one\n`)
60
+ return 1
61
+ }
62
+ }
52
63
 
53
64
  if (this.json) {
54
65
  this.context.stdout.write(`${JSON.stringify(rows.map((r) => ({ ...r, population: classify(r.decl).population })))}\n`)
package/src/cli/cmd_Ci.ts CHANGED
@@ -24,7 +24,7 @@ export class CiCommand extends Command {
24
24
  ['every check declaring one group', 'sk ci --only wiki'],
25
25
  ['run everything, take nothing from the cache', 'sk ci --fresh'],
26
26
  ['include an opt in check', 'sk ci --with up:itch'],
27
- ['in the background, read it back with shipkit status', 'sk ci --detach'],
27
+ ['in the background, read back with `sk status <id> --wait`', 'sk ci --detach'],
28
28
  ['every line, the ones nobody acts on included', 'sk ci --verbose'],
29
29
  ],
30
30
  })
@@ -44,7 +44,7 @@ export class CiCommand extends Command {
44
44
 
45
45
  verbose = Option.Boolean('--verbose', false, { description: 'print every line, the ones nobody acts on included: a clean fix pass, the machine pool, the test tier, the cache declarations, the checks not in this run, the cache counts' })
46
46
 
47
- detach = Option.Boolean('--detach', false, { description: 'start this gate in the background and return at once with a run id. `shipkit status <id>` prints it. The gate is an ordinary one: same cache, same run record' })
47
+ detach = Option.Boolean('--detach', false, { description: 'start this gate in the background and return at once with a run id. `shipkit status <id> --wait` returns its verdict when it ends. The gate is an ordinary one: same cache, same run record' })
48
48
  job = Option.String('--job', { hidden: true })
49
49
 
50
50
  async execute(): Promise<number> {
@@ -128,12 +128,17 @@ export function renderCompact(rows: CommandRow[], bin = 'sk', pages: Readonly<Re
128
128
  let cat = ''
129
129
  for (const r of rows) {
130
130
  if (r.category !== cat) { cat = r.category; out.push(`\n### ${cat}${pages?.[cat] != null ? ` → ${pages[cat]}` : ''}\n`) }
131
- const sig = r.usage.replace(/^\$0/, bin).replace(/\s+\[(?:-|<\w+>)[^\]]*\]/g, '').trim() || `${bin} ${r.path}`
132
- out.push(`- \`${sig}\` — ${r.description}`)
131
+ out.push(compactLine(r, bin))
133
132
  }
134
133
  return out.join('\n').trim()
135
134
  }
136
135
 
136
+ /** one command on one line: its words with its positional arguments, then its description */
137
+ export function compactLine(r: CommandRow, bin: string): string {
138
+ const sig = r.usage.replace(/^\$0/, bin).replace(/\s+\[(?:-|<\w+>)[^\]]*\]/g, '').trim() || `${bin} ${r.path}`
139
+ return `- \`${sig}\` — ${r.description}`
140
+ }
141
+
137
142
  /** one essential command's lines: its words with the arguments an agent types, its description, its examples */
138
143
  const essentialLines = (r: CommandRow, bin: string, sep: string): string[] => {
139
144
  const e = r.essential!
@@ -279,6 +284,10 @@ export class CommandsCommand extends Command {
279
284
  const pages = (this.constructor as typeof CommandsCommand).familyPages
280
285
  // --everyday is a compact form: it never falls back to the full markdown
281
286
  const render = (): string => (this.everyday ? renderEveryday(rows, bin, pages) : this.compact ? renderCompact(rows, bin, pages) : renderMarkdown(rows, bin))
287
+ if (this.check && this.out == null && this.essentials == null) {
288
+ write(`FAIL: --check compares a page with the binary: name the page with --out <file> or --essentials <file>\n`)
289
+ return 2
290
+ }
282
291
  if (this.out == null && this.essentials == null) {
283
292
  write(this.json ? `${JSON.stringify(rows)}\n` : `${render()}\n`)
284
293
  return 0