rvlib-shipkit 2.23.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 (150) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/package.json +1 -1
  3. package/src/agent-time/live.ts +153 -0
  4. package/src/agent-time/render.ts +28 -14
  5. package/src/agent-time/report.ts +46 -25
  6. package/src/agent-time/store.ts +30 -10
  7. package/src/agent-time/timeline.ts +43 -15
  8. package/src/annex/offload.ts +16 -7
  9. package/src/asks/asks-queue.ts +32 -11
  10. package/src/check.ts +3 -1
  11. package/src/checks/SK004-gitignore-policy.check.ts +32 -11
  12. package/src/checks/SK027-agent-wiki-links.check.ts +1 -1
  13. package/src/checks/SK033-global-contribution.check.ts +1 -1
  14. package/src/checks/SK036-draft-media-size.check.ts +1 -1
  15. package/src/checks/SK040-release-words.check.ts +1 -1
  16. package/src/checks/SK042-post-kinds.check.ts +1 -1
  17. package/src/checks/SK044-behind-upstream.check.ts +38 -0
  18. package/src/cli/cmd_Annex.ts +12 -7
  19. package/src/cli/cmd_Asks.ts +2 -0
  20. package/src/cli/cmd_Assets.ts +5 -5
  21. package/src/cli/cmd_Backup.ts +16 -8
  22. package/src/cli/cmd_Bump.ts +1 -0
  23. package/src/cli/cmd_Capacity.ts +30 -0
  24. package/src/cli/cmd_Check.ts +1 -0
  25. package/src/cli/cmd_Checks.ts +13 -1
  26. package/src/cli/cmd_Ci.ts +3 -2
  27. package/src/cli/cmd_Commands.ts +61 -16
  28. package/src/cli/cmd_ConfigKeys.ts +17 -0
  29. package/src/cli/cmd_Home.ts +1 -30
  30. package/src/cli/cmd_Hooks.ts +1 -0
  31. package/src/cli/cmd_Keys.ts +4 -1
  32. package/src/cli/cmd_Lanes.ts +35 -0
  33. package/src/cli/cmd_Mv.ts +7 -7
  34. package/src/cli/cmd_Rec.ts +22 -7
  35. package/src/cli/cmd_Reflect.ts +1 -0
  36. package/src/cli/cmd_Releases.ts +1 -0
  37. package/src/cli/cmd_Review.ts +200 -49
  38. package/src/cli/cmd_Secret.ts +41 -2
  39. package/src/cli/cmd_Shot.ts +16 -4
  40. package/src/cli/cmd_Status.ts +7 -5
  41. package/src/cli/cmd_Time.ts +13 -5
  42. package/src/cli/cmd_Tmp.ts +82 -0
  43. package/src/cli/cmd_Veille.ts +10 -6
  44. package/src/cli/cmd_Wiki.ts +1 -0
  45. package/src/cli/family-help.ts +136 -0
  46. package/src/cli/family-pages.ts +0 -19
  47. package/src/cli/kit/calls.ts +35 -0
  48. package/src/cli/kit/project-cli.ts +2 -12
  49. package/src/cli/registry.ts +52 -7
  50. package/src/cli.ts +8 -4
  51. package/src/collections/pings.ts +1 -1
  52. package/src/core/capacity.ts +127 -0
  53. package/src/core/check-runner.ts +91 -16
  54. package/src/core/floor-resolve.ts +6 -2
  55. package/src/core/floor.ts +6 -2
  56. package/src/core/history-files.ts +18 -0
  57. package/src/core/jobs.ts +35 -16
  58. package/src/core/layout.ts +2 -2
  59. package/src/core/motherhome.ts +67 -9
  60. package/src/core/nearest.ts +16 -0
  61. package/src/core/remove-tree.ts +19 -0
  62. package/src/core/runs.ts +12 -3
  63. package/src/core/slots.ts +49 -12
  64. package/src/core/throwaway-worktree.ts +22 -4
  65. package/src/core/trace-audit.ts +21 -5
  66. package/src/drill/run.ts +5 -2
  67. package/src/home/daemon-jobs.ts +41 -4
  68. package/src/home/gui-app/ShipkitGui.swift +1 -0
  69. package/src/home/home-launchd.ts +11 -3
  70. package/src/home/home-routes.ts +11 -4
  71. package/src/home/machine-host.ts +65 -0
  72. package/src/home/machine-stores.ts +19 -17
  73. package/src/home/machine-temp.ts +485 -0
  74. package/src/home/other-macs.ts +74 -0
  75. package/src/home/run-daemon.ts +10 -2
  76. package/src/home/serve-web.ts +2 -2
  77. package/src/home/via-hub.ts +6 -1
  78. package/src/init-repo.ts +7 -3
  79. package/src/ledger/gate-checks.ts +3 -2
  80. package/src/ledger/git-key.ts +25 -4
  81. package/src/ledger/git-scan.ts +10 -0
  82. package/src/ledger/ledger.ts +6 -0
  83. package/src/ledger/store.ts +6 -0
  84. package/src/media-store/backup/daemon.ts +92 -20
  85. package/src/media-store/backup/keys.ts +21 -6
  86. package/src/media-store/backup/manifest.ts +52 -11
  87. package/src/media-store/backup/restore.ts +17 -10
  88. package/src/media-store/backup/run.ts +26 -17
  89. package/src/media-store/backup/sources.ts +168 -22
  90. package/src/media-store/backup/watch.ts +106 -0
  91. package/src/media-store/daemon.ts +36 -8
  92. package/src/media-store/hand.ts +3 -1
  93. package/src/mv/mv-md.ts +167 -56
  94. package/src/pb/run-pb.ts +2 -10
  95. package/src/plan/repo-source.ts +25 -14
  96. package/src/recordings/model.ts +1 -1
  97. package/src/reflect/transcript.ts +56 -11
  98. package/src/release/run-bump.ts +3 -2
  99. package/src/release/run-release.ts +12 -4
  100. package/src/releases/from-card.ts +45 -3
  101. package/src/releases/model.ts +6 -0
  102. package/src/releases/store.ts +8 -1
  103. package/src/repo-config.ts +5 -3
  104. package/src/review/cells.ts +26 -4
  105. package/src/review/format.ts +34 -10
  106. package/src/review/media-kind.ts +14 -11
  107. package/src/review/media-read.ts +6 -5
  108. package/src/review/model.ts +85 -4
  109. package/src/review/paste.ts +2 -1
  110. package/src/review/previews.ts +123 -36
  111. package/src/review/routes.ts +29 -18
  112. package/src/review/store.ts +89 -19
  113. package/src/review/threads.ts +7 -5
  114. package/src/review/trailer-model.ts +2 -2
  115. package/src/secrets/copy.ts +110 -0
  116. package/src/secrets/list.ts +17 -7
  117. package/src/serve/hub-app/home-strip.css +5 -0
  118. package/src/serve/hub-app/home-strip.tsx +18 -0
  119. package/src/serve/hub-app/hub-app.tsx +2 -1
  120. package/src/serve/hub-app/hub.css +14 -0
  121. package/src/serve/hub-app/inbox.css +1 -0
  122. package/src/serve/hub-app/pull-refresh.tsx +88 -0
  123. package/src/serve/hub-app/review/review-cells.tsx +52 -13
  124. package/src/serve/hub-app/review/review-list.tsx +6 -1
  125. package/src/serve/hub-app/review/review-st.ts +6 -5
  126. package/src/serve/hub-app/review/review-thread.tsx +3 -1
  127. package/src/serve/hub-app/review/review-views.tsx +18 -11
  128. package/src/serve/hub-app/review/thread-st.ts +82 -14
  129. package/src/serve/hub-app/review.css +15 -2
  130. package/src/serve/hub-runtime.ts +2 -1
  131. package/src/serve/run-serve.ts +4 -2
  132. package/src/serve/serve-hub.ts +9 -2
  133. package/src/shot/client.ts +4 -2
  134. package/src/shot/serve-shot.ts +71 -2
  135. package/src/shot/shooter.ts +65 -11
  136. package/src/shot/shot-ask.ts +32 -9
  137. package/src/suite/child-tools.ts +45 -0
  138. package/src/suite/judge-suites.ts +10 -22
  139. package/src/suite/select.ts +95 -9
  140. package/src/suite/suite-cli.ts +38 -14
  141. package/src/suite/suite-cores.ts +68 -0
  142. package/src/suite/suite-reads-preload.ts +8 -6
  143. package/src/suite/test-units.ts +31 -12
  144. package/src/trailer/graph.ts +2 -1
  145. package/src/ts/config.ts +21 -0
  146. package/src/ts/rename.ts +37 -13
  147. package/src/ts/workspaces.ts +45 -0
  148. package/src/wiki/run-wiki.ts +7 -2
  149. package/src/wiki/scan-md.ts +2 -1
  150. package/src/home/claude-temp.ts +0 -139
@@ -0,0 +1,30 @@
1
+ // sk capacity: how many lanes this repo runs now. Report only, exit 0 always: the orchestrator decides.
2
+ import { Command, Option } from 'clipanion'
3
+ import { capacityLines, readCapacity } from '../core/capacity.ts'
4
+
5
+ export class CapacityCommand extends Command {
6
+ static override paths = [['capacity']]
7
+ static essential = {}
8
+
9
+ static override usage = Command.Usage({
10
+ category: 'Health',
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
+ examples: [
14
+ ['before a lane starts', 'sk capacity'],
15
+ ['with the maximum the owner gave', 'sk capacity --max 5'],
16
+ ['machine readable', 'sk capacity --json'],
17
+ ],
18
+ })
19
+
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' })
22
+
23
+ async execute(): Promise<number> {
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`)
28
+ return 0
29
+ }
30
+ }
@@ -11,6 +11,7 @@ import { runFix } from '../core/run-fix.ts'
11
11
 
12
12
  export class CheckCommand extends Command {
13
13
  static override paths = [['check'], ['doctor']]
14
+ static essential = {}
14
15
 
15
16
  static override usage = Command.Usage({
16
17
  category: 'Health',
@@ -17,14 +17,16 @@ import { classify } from '../ledger/git-key.ts'
17
17
 
18
18
  export class ChecksCommand extends Command {
19
19
  static override paths = [['checks']]
20
+ static essential = {}
20
21
 
21
22
  // widened so the hidden alias below can drop it: no usage, no help entry
22
23
  static override usage: Usage | undefined = Command.Usage({
23
24
  category: 'Health',
24
25
  description: 'every gate check on one table: source, blocking or warning, cache',
25
- 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',
26
27
  examples: [
27
28
  ['the whole inventory', 'sk checks'],
29
+ ['only the checks whose id or title holds a word', 'sk checks test'],
28
30
  ['the big markdown table, written to a file', 'sk checks --out STATUS.full.md'],
29
31
  ['only the ones the gate never runs', 'sk checks --proactive'],
30
32
  ['everything that repairs itself, with its owner', 'sk checks --fixable'],
@@ -39,6 +41,7 @@ export class ChecksCommand extends Command {
39
41
  proactive = Option.Boolean('--proactive', false, { description: 'only checks the gate never runs (`shipkit check` reports them)' })
40
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' })
41
43
  full = Option.Boolean('--full', false, { description: 'resolve every check the way a FULL-tier run resolves it' })
44
+ word = Option.String({ required: false })
42
45
 
43
46
  async execute(): Promise<number> {
44
47
  const root = process.cwd()
@@ -48,6 +51,15 @@ export class ChecksCommand extends Command {
48
51
  if (this.blocking) rows = rows.filter((r) => r.blocking !== false)
49
52
  if (this.proactive) rows = rows.filter((r) => r.when.at !== 'always')
50
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
+ }
51
63
 
52
64
  if (this.json) {
53
65
  this.context.stdout.write(`${JSON.stringify(rows.map((r) => ({ ...r, population: classify(r.decl).population })))}\n`)
package/src/cli/cmd_Ci.ts CHANGED
@@ -11,6 +11,7 @@ import { listFlag } from './list-flag.ts'
11
11
 
12
12
  export class CiCommand extends Command {
13
13
  static override paths = [['ci']]
14
+ static essential = { examples: 1 }
14
15
 
15
16
  static override usage = Command.Usage({
16
17
  category: 'Gate',
@@ -23,7 +24,7 @@ export class CiCommand extends Command {
23
24
  ['every check declaring one group', 'sk ci --only wiki'],
24
25
  ['run everything, take nothing from the cache', 'sk ci --fresh'],
25
26
  ['include an opt in check', 'sk ci --with up:itch'],
26
- ['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'],
27
28
  ['every line, the ones nobody acts on included', 'sk ci --verbose'],
28
29
  ],
29
30
  })
@@ -43,7 +44,7 @@ export class CiCommand extends Command {
43
44
 
44
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' })
45
46
 
46
- 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' })
47
48
  job = Option.String('--job', { hidden: true })
48
49
 
49
50
  async execute(): Promise<number> {
@@ -128,12 +128,51 @@ 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
+
142
+ /** one essential command's lines: its words with the arguments an agent types, its description, its examples */
143
+ const essentialLines = (r: CommandRow, bin: string, sep: string): string[] => {
144
+ const e = r.essential!
145
+ return [`- \`${bin} ${r.path}${e.args != null ? ` ${e.args}` : ''}\`${sep}${r.description}`, ...r.examples.slice(0, e.examples ?? 0).map(([label, cmd]) => ` - \`${cmd}\`: ${label}`)]
146
+ }
147
+
148
+ /** how to list the commands of a family the page does not show: one `--help` per first word, with its count */
149
+ const restOf = (all: CommandRow[], bin: string): string[] => {
150
+ const first = (r: CommandRow): string => r.path.split(' ')[0]!
151
+ return [...new Set(all.map(first))]
152
+ .map((w) => [w, all.filter((r) => first(r) === w && r.essential == null).length] as const)
153
+ .filter(([, n]) => n > 0)
154
+ .map(([w, n]) => `\`${bin} ${w} --help\` (${n})`)
155
+ }
156
+
157
+ /** the block of a page every session loads: the commands marked essential, then how to list the rest of each
158
+ * family, then every other family on one line with its owner page. The whole list is one command away */
159
+ export function renderEveryday(rows: CommandRow[], bin = 'sk', pages: Readonly<Record<string, string>> | null = null): string {
160
+ const out: string[] = []
161
+ const quiet: string[] = []
162
+ for (const category of [...new Set(rows.map((r) => r.category))]) {
163
+ const all = rows.filter((r) => r.category === category)
164
+ const mine = all.filter((r) => r.essential != null)
165
+ const page = pages?.[category] != null ? ` → ${pages[category]}` : ''
166
+ const rest = restOf(all, bin)
167
+ if (mine.length === 0) { quiet.push(`- ${category}${page}: ${rest.join(', ')}`); continue }
168
+ out.push(`\n### ${category}${page}\n`)
169
+ for (const r of mine) out.push(...essentialLines(r, bin, ' — '))
170
+ if (rest.length > 0) out.push(`- more: ${rest.join(', ')}`)
171
+ }
172
+ if (quiet.length > 0) out.push('\n### The other families, each with the command that lists it and how many it holds\n', ...quiet)
173
+ return out.join('\n').trim()
174
+ }
175
+
137
176
  /** the page every session loads: per category its everyday commands, a few
138
177
  * examples, and how to list the rest. Generated whole */
139
178
  export function renderEssentials(rows: CommandRow[], bin: string, command: string): string {
@@ -149,11 +188,7 @@ export function renderEssentials(rows: CommandRow[], bin: string, command: strin
149
188
  const mine = all.filter((r) => r.essential != null)
150
189
  if (mine.length === 0) { quiet.push(...rest); continue }
151
190
  out.push('', `## ${category}${rest.length > 0 ? ` (more: ${rest.join(', ')})` : ''}`, '')
152
- for (const r of mine) {
153
- const e = r.essential!
154
- out.push(`- \`${bin} ${r.path}${e.args != null ? ` ${e.args}` : ''}\`: ${r.description}`)
155
- for (const [label, cmd] of r.examples.slice(0, e.examples ?? 0)) out.push(` - \`${cmd}\`: ${label}`)
156
- }
191
+ for (const r of mine) out.push(...essentialLines(r, bin, ': '))
157
192
  }
158
193
  if (quiet.length > 0) out.push('', `## The other families: ${quiet.join(', ')}`)
159
194
  return `${out.join('\n')}\n`
@@ -214,14 +249,17 @@ export class CommandsCommand extends Command {
214
249
  ['markdown index', 'sk commands'],
215
250
  ['machine-readable', 'sk commands --json'],
216
251
  ['write into a docs page between the markers', 'sk commands --out docs/commands.md'],
217
- ['one line per command, for a page every session loads', 'sk commands --compact --out wiki/tools/shipkit/commands.md'],
218
- ['fail if that page is stale (lint mode)', 'sk commands --compact --out wiki/tools/shipkit/commands.md --check'],
252
+ ['the everyday commands, for a page every session loads', 'sk commands --everyday --out wiki/tools/shipkit/commands.md'],
253
+ ['every command, one line each, on demand', 'sk commands --compact'],
254
+ ['fail if that page is stale (lint mode)', 'sk commands --everyday --out wiki/tools/shipkit/commands.md --check'],
219
255
  ],
220
256
  })
221
257
 
222
258
  /** a project CLI holds its rows to shapeProblems (--out and --check fail on
223
259
  * a breach), and its --out creates a missing page */
224
260
  static shapeRule = false
261
+ /** the classes of the cli this command is registered in, set by its registry: their marks (essential, film) */
262
+ static registered: readonly { paths?: string[][] }[] = []
225
263
 
226
264
  /** each family's owner page, named in the compact page's headings; a project CLI has none */
227
265
  static familyPages: Readonly<Record<string, string>> | null = FAMILY_PAGES
@@ -230,11 +268,12 @@ export class CommandsCommand extends Command {
230
268
  out = Option.String('--out', { description: 'host file carrying the <bin>:commands markers. The block between them is rewritten' })
231
269
  check = Option.Boolean('--check', false, { description: 'with --out or --essentials: exit 1 if a page is stale, write nothing' })
232
270
  compact = Option.Boolean('--compact', false, { description: 'one line per command: no flags, no examples (they are `<bin> <command> --help`)' })
271
+ everyday = Option.Boolean('--everyday', false, { description: 'the compact form of a page every session loads: only the commands marked essential, then every other family on one line' })
233
272
  essentials = Option.String('--essentials', { description: 'the everyday commands page, rewritten whole from the commands marked essential' })
234
273
 
235
274
  async execute(): Promise<number> {
236
275
  const bin = this.cli.binaryName
237
- const classes = (this.context as { classes?: { paths?: string[][] }[] }).classes ?? []
276
+ const classes = (this.context as { classes?: { paths?: string[][] }[] }).classes ?? (this.constructor as typeof CommandsCommand).registered
238
277
  const rows = commandRows(
239
278
  this.cli.definitions() as Definition[],
240
279
  (this.cli.definitions as (o?: { detailed?: boolean }) => Definition[])({ detailed: true }),
@@ -243,12 +282,17 @@ export class CommandsCommand extends Command {
243
282
  )
244
283
  const write = (s: string): void => void this.context.stdout.write(s)
245
284
  const pages = (this.constructor as typeof CommandsCommand).familyPages
246
- const render = (): string => (this.compact ? renderCompact(rows, bin, pages) : renderMarkdown(rows, bin))
285
+ // --everyday is a compact form: it never falls back to the full markdown
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
+ }
247
291
  if (this.out == null && this.essentials == null) {
248
292
  write(this.json ? `${JSON.stringify(rows)}\n` : `${render()}\n`)
249
293
  return 0
250
294
  }
251
- if (this.out != null && this.compact && pages != null) {
295
+ if (this.out != null && (this.compact || this.everyday) && pages != null) {
252
296
  const bad = familyProblems(rows, pages)
253
297
  for (const b of bad) write(`FAIL: ${b}\n`)
254
298
  if (bad.length > 0) { write(' fix: one row per family in src/cli/family-pages.ts, the wiki page that owns it\n'); return 1 }
@@ -276,14 +320,15 @@ export class CommandsCommand extends Command {
276
320
  const host = existsSync(this.out) ? readFileSync(this.out, 'utf8') : newCommandsPage(bin, this.out)
277
321
  const next = spliceBlock(host, render(), bin)
278
322
  if (next == null) { write(`FAIL: ${this.out} has no ${begin} / ${end} markers\n`); return 1 }
279
- if (next === host) { write(`ok: ${this.out} command index current (${rows.length} commands)\n`); return code }
323
+ const shown = this.everyday ? `${rows.filter((r) => r.essential != null).length} everyday commands of ${rows.length}` : `${rows.length} commands`
324
+ if (next === host) { write(`ok: ${this.out} command index current (${shown})\n`); return code }
280
325
  if (this.check) {
281
- write(`FAIL: ${this.out} command index is STALE — the binary registers commands the page does not list\n`)
282
- write(` fix: ${bin === 'sk' ? 'shipkit' : bin} commands${this.compact ? ' --compact' : ''} --out ${this.out}\n`)
326
+ write(`FAIL: ${this.out} command index is STALE — ${this.everyday ? 'the everyday commands, a description or a family count moved in the binary' : 'the binary registers commands the page does not list'}\n`)
327
+ write(` fix: ${bin === 'sk' ? 'shipkit' : bin} commands${this.everyday ? ' --everyday' : this.compact ? ' --compact' : ''} --out ${this.out}\n`)
283
328
  return 1
284
329
  }
285
330
  writeFileSync(this.out, next)
286
- write(`ok: ${this.out} command index rewritten (${rows.length} commands)\n`)
331
+ write(`ok: ${this.out} command index rewritten (${shown})\n`)
287
332
  return code
288
333
  }
289
334
  }
@@ -23,6 +23,7 @@ export class ConfigKeysCommand extends Command {
23
23
  details: 'every repo.config.ts key and every check field with its doc, read from the types — the source a config reference page is generated FROM',
24
24
  examples: [
25
25
  ['markdown reference', 'sk config-keys'],
26
+ ['only the keys whose path holds a word (their doc, when no path does)', 'sk config-keys port'],
26
27
  ['machine-readable', 'sk config-keys --json'],
27
28
  ['write into a docs page between the markers', 'sk config-keys --out wiki/tools/shipkit/config-keys.md'],
28
29
  ['fail if that page is stale (lint mode)', 'sk config-keys --out wiki/tools/shipkit/config-keys.md --check'],
@@ -34,6 +35,7 @@ export class ConfigKeysCommand extends Command {
34
35
  out = Option.String('--out', { description: 'host file carrying the shipkit:config-keys and shipkit:check-keys markers. Both blocks are rewritten' })
35
36
  check = Option.Boolean('--check', false, { description: 'with --out: exit 1 if the block is stale, write nothing' })
36
37
  undocumented = Option.Boolean('--undocumented', false, { description: 'list the keys with no doc comment in the source, and exit 1 if there are any' })
38
+ word = Option.String({ required: false })
37
39
 
38
40
  async execute(): Promise<number> {
39
41
  const keys = configKeys(configSourceFile(), CONFIG_TYPE)
@@ -45,6 +47,21 @@ export class ConfigKeysCommand extends Command {
45
47
  for (const p of missing) this.context.stdout.write(` ${p}\n`)
46
48
  return 1
47
49
  }
50
+ if (this.word != null) {
51
+ const w = this.word.toLowerCase()
52
+ // a word in a path names the key: the docs are searched only when no path holds it
53
+ const both = [...keys.map((k) => ({ k, of: CONFIG_TYPE })), ...checkKeys.map((k) => ({ k, of: CHECK_TYPE }))]
54
+ const named = both.filter(({ k }) => k.path.toLowerCase().includes(w))
55
+ const found = named.length > 0 ? named : both.filter(({ k }) => k.doc.toLowerCase().includes(w))
56
+ if (this.json) { this.context.stdout.write(`${JSON.stringify(found.map((f) => ({ ...f.k, of: f.of })))}\n`); return found.length > 0 ? 0 : 1 }
57
+ if (found.length === 0) {
58
+ this.context.stdout.write(`FAIL: no key has « ${this.word} » in its path or doc (${keys.length + checkKeys.length} looked at)\n fix: shipkit config-keys lists every one\n`)
59
+ return 1
60
+ }
61
+ // a key alone has no parent above it: its whole path stands in for the indent
62
+ for (const { k, of } of found) this.context.stdout.write(`- \`${k.path}${k.optional ? '?' : ''}: ${k.type}\` (${of}) — ${k.doc === '' ? 'undocumented in the source' : k.doc}\n`)
63
+ return 0
64
+ }
48
65
  if (this.out == null) {
49
66
  this.context.stdout.write(this.json ? `${JSON.stringify({ config: keys, check: checkKeys })}\n` : `${renderKeys(keys)}\n\n${renderKeys(checkKeys)}\n`)
50
67
  return 0
@@ -91,51 +91,22 @@ export class DaemonJobCommand extends Command {
91
91
  static override usage = Command.Usage({
92
92
  category: 'Serve',
93
93
  description: 'a daemon job now, in this process: backup, retention sweep, media store, global context, apps',
94
- details: 'what the daemon runs off its loop: it starts each job as this command in a child process, niced, its lines appended to the daemon\'s log, and never runs a job\'s body itself, so a walk, a VACUUM or a hash pass never holds a page. The backup looks every 2 min and runs when its sources moved and held still, the retention sweep runs hourly, the media store passes every 30 s, the global context is written and the apps in ~/Applications are built and swept when the stamp of their sources moved. What a job remembers between two runs lives in the machine db. Page: wiki tools/shipkit/home.md, Nothing heavy on the daemon\'s loop',
94
+ details: 'what the daemon runs off its loop: it starts each job as this command in a child process, niced, its lines appended to the daemon\'s log, and never runs a job\'s body itself, so a walk, a VACUUM or a hash pass never holds a page. The backup holds a watch of its sources in the daemon: its child starts only when the watch heard a path that could be a source, a run waits, or every 30 min for a full walk; a look reads only the heard paths again, it runs when they moved and held still, and a run reads only the files whose size or time moved (every byte every 6 h). the retention sweep runs hourly, the media store passes every 30 s while it has work and every 5 min once a pass found none (sooner when a store folder moves), the global context is written and the apps in ~/Applications are built and swept when the stamp of their sources moved. What a job remembers between two runs lives in the machine db. Page: wiki tools/shipkit/home.md, Nothing heavy on the daemon\'s loop',
95
95
  examples: [
96
96
  ['every global process app in ~/Applications built and swept now', 'sk daemon job apps'],
97
97
  ['a retention sweep now', 'sk daemon job "retention sweep"'],
98
98
  ['one media store pass', 'sk daemon job "media store"'],
99
99
  ['the house\'s global context written now', 'sk daemon job "global context"'],
100
- ['what the sweep\'s claude temp pass would delete', 'sk daemon job "retention sweep" --dry'],
101
- ['the sweep trims claude temp from now on', 'sk daemon job "retention sweep" --claude-temp on'],
102
100
  ],
103
101
  })
104
102
 
105
103
  id = Option.String({ required: true, name: 'id' })
106
- dry = Option.Boolean('--dry', false, { description: 'retention sweep only: print each claude temp folder the pass would delete (idle age, size) and the total, delete nothing, sweep no other store' })
107
- claudeTemp = Option.String('--claude-temp', { description: 'retention sweep only: on, the sweep trims claude code\'s session temp folders (sessions idle 24 h or more past 5 GB, oldest first); off stops it (off until the owner turns it on)' })
108
-
109
104
  async execute(): Promise<number> {
110
105
  const { isJobId, DAEMON_JOBS, runJobBody } = await import('../home/daemon-jobs.ts')
111
106
  if (!isJobId(this.id)) {
112
107
  this.context.stderr.write(`FAIL: no daemon job ${JSON.stringify(this.id)}: ${DAEMON_JOBS.map((j) => j.id).join(', ')}\n`)
113
108
  return 1
114
109
  }
115
- if (this.dry || this.claudeTemp !== undefined) {
116
- if (this.id !== 'retention sweep') {
117
- this.context.stderr.write(`FAIL: --dry and --claude-temp belong to the retention sweep, not ${this.id}\n`)
118
- return 1
119
- }
120
- const t = await import('../home/claude-temp.ts')
121
- const out = (l: string): void => void this.context.stdout.write(`${l}\n`)
122
- const err = (l: string): void => void this.context.stderr.write(`${l}\n`)
123
- if (this.claudeTemp !== undefined) {
124
- if (this.claudeTemp !== 'on' && this.claudeTemp !== 'off') { err(`FAIL: --claude-temp takes on or off, not ${this.claudeTemp}`); return 1 }
125
- if (!t.setClaudeTempAuto(this.claudeTemp === 'on')) { err('FAIL: the machine db does not open: the switch is not set'); return 1 }
126
- }
127
- out(`the sweep's claude temp pass: ${t.claudeTempAuto() ? 'on' : 'off (sk daemon job "retention sweep" --claude-temp on turns it on)'}`)
128
- if (!this.dry) return 0
129
- const root = t.claudeTempRoot()
130
- if (root == null) { err('FAIL: no uid on this platform'); return 1 }
131
- try {
132
- t.trimClaudeTemp(root, { now: Date.now(), dry: true, print: out, printErr: err })
133
- return 0
134
- } catch (e) {
135
- err(`FAIL: ${(e as Error).message}`)
136
- return 1
137
- }
138
- }
139
110
  const { homedir } = await import('node:os')
140
111
  const { findRepoRoot } = await import('../ts/config.ts')
141
112
  // its lines land in the daemon's log: each one stamped and named
@@ -58,6 +58,7 @@ export class HooksCommitMsgCommand extends Command {
58
58
 
59
59
  export class HooksListCommand extends Command {
60
60
  static override paths = [['hooks', 'list']]
61
+ static essential = {}
61
62
  static override usage = Command.Usage({
62
63
  category: 'Gate',
63
64
  description: 'what blocks a commit in this repo, built-ins and repo-declared',
@@ -13,6 +13,7 @@ import { planGap, plannable } from '../plan/repo-source.ts'
13
13
  import { KeyLayer } from '../ledger/git-key.ts'
14
14
  import { Ledger } from '../ledger/ledger.ts'
15
15
  import { gateBinary } from '../ledger/toolchain-identity.ts'
16
+ import { nearest } from '../core/nearest.ts'
16
17
 
17
18
  export class KeysCommand extends Command {
18
19
  static override paths = [['keys']]
@@ -66,7 +67,9 @@ export class KeysCommand extends Command {
66
67
  if (this.why != null) {
67
68
  const k = keys.find((u) => u.id.toLowerCase() === this.why!.toLowerCase())
68
69
  if (k == null) {
69
- out(`FAIL: no gate check '${this.why}' — run \`shipkit keys\` for the list`)
70
+ const close = nearest(this.why, keys.map((u) => u.id))
71
+ out(`FAIL: no gate check '${this.why}'`)
72
+ out(` fix: ${close.length > 0 ? `did you mean ${close.map((id) => `shipkit keys --why ${id}`).join(', ')} ?` : '`shipkit keys` lists every id'}`)
70
73
  return 1
71
74
  }
72
75
  out(`${k.id} — ${k.population}`)
@@ -0,0 +1,35 @@
1
+ // sk lanes: who is at work on the machine now, one row per live session and lane. Report only.
2
+ import { Command, Option } from 'clipanion'
3
+ import { liveRow, liveTable, oneRowAnAgent } from '../agent-time/live.ts'
4
+ import { listTranscripts } from '../agent-time/store.ts'
5
+ import { capacityLines, LIVE_WINDOW_MS, readCapacity } from '../core/capacity.ts'
6
+
7
+ export class LanesCommand extends Command {
8
+ static override paths = [['lanes']]
9
+ static essential = {}
10
+
11
+ static override usage = Command.Usage({
12
+ category: 'Health',
13
+ description: 'who is at work on the machine now: each live session and lane, since when, its calls, what it does',
14
+ details: 'one row per agent whose transcript moved in the last 3 minutes, every account and repo, read from the transcripts agents already write: no agent reports anything. A lane shows the description its orchestrator gave it and its model. `now` is its last entry: the tool call in flight, a model turn, or an ended turn, with how long ago. --all widens the window to an hour. The first line is the machine, the last what `sk capacity` says for this repo. Report only, exit 0 always.',
15
+ examples: [
16
+ ['who works now', 'sk lanes'],
17
+ ['the last hour, ended lanes included', 'sk lanes --all'],
18
+ ['machine readable', 'sk lanes --json'],
19
+ ],
20
+ })
21
+
22
+ all = Option.Boolean('--all', false, { description: 'every agent that wrote in the last hour, ended ones included' })
23
+ json = Option.Boolean('--json', false, { description: 'the rows as json' })
24
+
25
+ async execute(): Promise<number> {
26
+ const now = Date.now()
27
+ const windowMs = this.all ? 60 * 60 * 1000 : LIVE_WINDOW_MS
28
+ const rows = oneRowAnAgent(listTranscripts().filter((f) => now - f.mtime <= windowMs)).map((f) => liveRow(f))
29
+ const { capacity, live, repo } = readCapacity(process.cwd(), null, now)
30
+ const [machine = '', , verdict = ''] = capacityLines(capacity, live, repo)
31
+ if (this.json) { this.context.stdout.write(`${JSON.stringify({ capacity, rows })}\n`); return 0 }
32
+ this.context.stdout.write(`${[machine, '', ...liveTable(rows, now), '', `${repo}: ${verdict}`].join('\n')}\n`)
33
+ return 0
34
+ }
35
+ }
package/src/cli/cmd_Mv.ts CHANGED
@@ -10,11 +10,12 @@ import { renameCli } from '../ts/rename.ts'
10
10
 
11
11
  export class MvCommand extends Command {
12
12
  static override paths = [['mv']]
13
+ static essential = { args: '<old> <new>' }
13
14
 
14
15
  static override usage = Command.Usage({
15
16
  category: 'Refactor',
16
17
  description: 'rename a file, folder or md page and rewrite every reference (dry run by default)',
17
- details: 'rename anything and sweep every reference: an md page (plus its sibling dir and its check file) or a code file or folder. Dry run by default. Renames must be CHEAP',
18
+ details: 'rename anything and sweep every reference: an md page (plus its sibling dir and its check file) or a code file or folder. Dry run by default: it lists each file and its first rewritten line. A reference is the path written bare, from the repo root (absolute or ~), or relative to the file that holds it; a longer path that only ends with it (packages/p/agent/index.md for agent/index.md) names another file and stays. A page moved into its own folder (x.md to x/index.md or x/x.md) keeps that folder where it is. A map line sees what the lines before it moved, in a dry run too. A plan (.shipkit/plans/), a changelog and a journal record what was true when they were written: they stay as written, the run says how many name the path, and --history rewrites them too.',
18
19
  examples: [
19
20
  ['dry run, the default, shows what changes', 'sk mv docs/old-name.md docs/new-name.md'],
20
21
  ['apply it', 'sk mv docs/old-name.md docs/new-name.md --write'],
@@ -31,6 +32,7 @@ export class MvCommand extends Command {
31
32
  map = Option.String('--map', { description: 'md pages from a file, one `<old> <new>` per line, mv:after once at the end' })
32
33
  write = Option.Boolean('--write', false, { description: 'apply (default is a dry run)' })
33
34
  commit = Option.Boolean('--commit', false, { description: 'apply + git commit, md pages only (the pre-commit gate still runs)' })
35
+ history = Option.Boolean('--history', false, { description: 'rewrite the plans, changelogs and journals too: by default they stay as written, and the run says how many' })
34
36
 
35
37
  async execute(): Promise<number> {
36
38
  const write = this.write || this.commit
@@ -38,22 +40,20 @@ export class MvCommand extends Command {
38
40
  try {
39
41
  if (this.map != null) {
40
42
  if (this.oldPath != null) { io.printErr('FAIL: --map takes no paths'); return 1 }
41
- return movePages(process.cwd(), parseMoveMap(readFileSync(this.map, 'utf8')), io, { write: this.write, commit: this.commit })
43
+ return movePages(process.cwd(), parseMoveMap(readFileSync(this.map, 'utf8')), io, { write: this.write, commit: this.commit, history: this.history })
42
44
  }
43
45
  if (this.oldPath == null || this.newPath == null) { io.printErr('FAIL: give <oldPath> <newPath>, or --map <file>'); return 1 }
44
46
  const isMd = this.oldPath.endsWith('.md') || this.newPath.endsWith('.md')
45
47
  if (!isMd) {
46
48
  if (this.commit) {
47
- this.context.stderr.write('FAIL: --commit is md-only for now — run with --write, then commit\n')
49
+ this.context.stderr.write(`FAIL: --commit takes md pages only: sk mv ${this.oldPath} ${this.newPath} --write, then commit what you own\n`)
48
50
  return 1
49
51
  }
50
52
  // in-process: the rename lives HERE now, so `shipkit mv` can
51
53
  // never be a version behind the tool it delegates to
52
- const code = renameCli([this.oldPath, this.newPath, ...(write ? ['--apply'] : [])])
53
- if (!write && code === 0) this.context.stdout.write('note: dry run — pass --write to apply\n')
54
- return code
54
+ return renameCli([this.oldPath, this.newPath, ...(write ? ['--apply'] : []), ...(this.history ? ['--history'] : [])], '--write')
55
55
  }
56
- return movePage(process.cwd(), this.oldPath, this.newPath, io, { write: this.write, commit: this.commit })
56
+ return movePage(process.cwd(), this.oldPath, this.newPath, io, { write: this.write, commit: this.commit, history: this.history })
57
57
  } catch (e) {
58
58
  this.context.stderr.write(`FAIL: ${e instanceof Error ? e.message : String(e)}\n`)
59
59
  return 1
@@ -44,24 +44,39 @@ const line = (r: Rec): string => `${r.repo}/${r.name} ${r.still ? 'still' : tim
44
44
 
45
45
  const repoOpt = (): string | undefined => Option.String('--repo', { description: 'the repo it belongs to, by name (this one when absent)' })
46
46
 
47
+ /** the recordings `sk rec` prints without --all */
48
+ const REC_SHOWN = 30
49
+
47
50
  export class RecCommand extends Command {
48
51
  static override paths = [['rec']]
49
52
  static override usage = Command.Usage({
50
53
  category: 'Record',
51
- description: 'every recording, newest first: repo/name, length, size, where it sits',
52
- details: DETAILS,
53
- examples: [['every recording of the machine', 'sk rec'], ['one repo, as json', 'sk rec --repo my-game --json']],
54
+ description: 'the recordings, newest first: their count, then repo/name, length, size, where it sits',
55
+ details: `${DETAILS}\n\nThe first line counts them per repo; the newest ${REC_SHOWN} follow. --all prints every one, --json every one as a json line.`,
56
+ examples: [['the newest recordings of the machine', 'sk rec'], ['one repo, every take', 'sk rec --repo my-game --all'], ['one repo, as json', 'sk rec --repo my-game --json']],
54
57
  })
55
- repo = repoOpt()
56
- json = Option.Boolean('--json', false, { description: 'one json line a recording' })
58
+ repo = Option.String('--repo', { description: 'one repo, by name (every repo when absent)' })
59
+ all = Option.Boolean('--all', false, { description: 'every recording, not only the newest' })
60
+ json = Option.Boolean('--json', false, { description: 'one json line a recording, every one' })
57
61
  async execute(): Promise<number> {
58
62
  return run(this.context, async (io) => {
59
63
  const { listRecordings } = await import('../recordings/model.ts')
60
64
  const { webpPath } = await import('../recordings/share.ts')
61
65
  const all = await listRecordings(this.repo === undefined ? {} : { repo: this.repo })
62
66
  // webp: where the app keeps the WebP a copy makes of what plays
63
- for (const r of all) io.out(this.json ? JSON.stringify({ ...r, webp: webpPath(r) }) : line(r))
64
- if (!this.json && all.length === 0) io.out('no recording yet: a hotkey of the menu bar app records one (sk rec presets lists them)')
67
+ if (this.json) {
68
+ for (const r of all) io.out(JSON.stringify({ ...r, webp: webpPath(r) }))
69
+ return 0
70
+ }
71
+ if (all.length === 0) {
72
+ io.out('no recording yet: a hotkey of the menu bar app records one (sk rec presets lists them)')
73
+ return 0
74
+ }
75
+ const per = new Map<string, number>()
76
+ for (const r of all) per.set(r.repo, (per.get(r.repo) ?? 0) + 1)
77
+ const cut = !this.all && all.length > REC_SHOWN
78
+ io.out(`${all.length} recordings: ${[...per].map(([repo, n]) => `${n} ${repo}`).join(', ')}${cut ? `; the newest ${REC_SHOWN} below, --all for every one` : ''}`)
79
+ for (const r of cut ? all.slice(0, REC_SHOWN) : all) io.out(line(r))
65
80
  return 0
66
81
  })
67
82
  }
@@ -14,6 +14,7 @@ export type RepoDoc = { repo: string; prompts: PromptEntry[]; error?: string }
14
14
 
15
15
  export class ReflectCommand extends Command {
16
16
  static override paths = [['reflect']]
17
+ static essential = {}
17
18
 
18
19
  static override usage = Command.Usage({
19
20
  category: 'Health',
@@ -44,6 +44,7 @@ export class ReleasesCommand extends Command {
44
44
 
45
45
  export class ReleasesAddCommand extends Command {
46
46
  static override paths = [['releases', 'add']]
47
+ static essential = {}
47
48
 
48
49
  static override usage = Command.Usage({
49
50
  category: 'Gate',