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
@@ -54,7 +54,9 @@ export class BackupCommand extends Command {
54
54
  for (const r of list) h.out(` refused ~/${r.path}: ${r.why}`)
55
55
  }
56
56
  if (this.check) {
57
- const c = await backupCheck(h.space, { home: h.home, repos: h.repos })
57
+ // a look only: the local files as the daemon's looks keep them, never each repo's git walk again
58
+ const { keptLocals } = await import('../media-store/backup/daemon.ts')
59
+ const c = await backupCheck(h.space, { home: h.home, repos: h.repos, locals: keptLocals() })
58
60
  h.out(`${c.files} files read; the last run: ${c.last ? `${c.last.at} (${c.last.key})` : 'none'}`)
59
61
  h.out(`${c.waiting.length} not in the Space yet (${mb(c.waiting.reduce((n, w) => n + w.size, 0))}), ${c.changed.length} changed since the last run, ${c.refused.length} refused`)
60
62
  for (const w of c.waiting.slice(0, 40)) h.out(` waiting ~/${w.path}`)
@@ -77,20 +79,26 @@ export class BackupCommand extends Command {
77
79
  }
78
80
  }
79
81
 
82
+ /** the runs `sk backup runs` prints without --all: a run every few minutes makes thousands */
83
+ const RUNS_SHOWN = 20
84
+
80
85
  export class BackupRunsCommand extends Command {
81
86
  static override paths = [['backup', 'runs']]
82
87
  static override usage = Command.Usage({
83
88
  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']],
89
+ description: 'the backup runs in the Space, newest first: the count per machine, then time, machine and key',
90
+ details: `${DETAILS}\n\nThe first line counts the runs per machine; the newest ${RUNS_SHOWN} follow, newest first. --all lists every run, oldest first.`,
91
+ examples: [['the latest runs', 'sk backup runs'], ['every run', 'sk backup runs --all']],
87
92
  })
93
+ all = Option.Boolean('--all', false, { description: 'every run, oldest first' })
88
94
  async execute(): Promise<number> {
89
95
  return run(this.context, async (h) => {
90
96
  const { runsOf } = await import('../media-store/backup/manifest.ts')
91
97
  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`)
98
+ const per = new Map<string, number>()
99
+ for (const r of runs) per.set(r.machine ?? '(host inside)', (per.get(r.machine ?? '(host inside)') ?? 0) + 1)
100
+ 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` : ''}`)
101
+ 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
102
  return 0
95
103
  })
96
104
  }
@@ -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
@@ -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,7 +91,7 @@ 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"'],
@@ -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
@@ -15,7 +15,7 @@ export class MvCommand extends Command {
15
15
  static override usage = Command.Usage({
16
16
  category: 'Refactor',
17
17
  description: 'rename a file, folder or md page and rewrite every reference (dry run by default)',
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. 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, an archived repro and a field note (.shipkit/plans/, repros/, reflections/), 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.',
19
19
  examples: [
20
20
  ['dry run, the default, shows what changes', 'sk mv docs/old-name.md docs/new-name.md'],
21
21
  ['apply it', 'sk mv docs/old-name.md docs/new-name.md --write'],
@@ -32,6 +32,7 @@ export class MvCommand extends Command {
32
32
  map = Option.String('--map', { description: 'md pages from a file, one `<old> <new>` per line, mv:after once at the end' })
33
33
  write = Option.Boolean('--write', false, { description: 'apply (default is a dry run)' })
34
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' })
35
36
 
36
37
  async execute(): Promise<number> {
37
38
  const write = this.write || this.commit
@@ -39,22 +40,20 @@ export class MvCommand extends Command {
39
40
  try {
40
41
  if (this.map != null) {
41
42
  if (this.oldPath != null) { io.printErr('FAIL: --map takes no paths'); return 1 }
42
- 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 })
43
44
  }
44
45
  if (this.oldPath == null || this.newPath == null) { io.printErr('FAIL: give <oldPath> <newPath>, or --map <file>'); return 1 }
45
46
  const isMd = this.oldPath.endsWith('.md') || this.newPath.endsWith('.md')
46
47
  if (!isMd) {
47
48
  if (this.commit) {
48
- 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`)
49
50
  return 1
50
51
  }
51
52
  // in-process: the rename lives HERE now, so `shipkit mv` can
52
53
  // never be a version behind the tool it delegates to
53
- const code = renameCli([this.oldPath, this.newPath, ...(write ? ['--apply'] : [])])
54
- if (!write && code === 0) this.context.stdout.write('note: dry run — pass --write to apply\n')
55
- return code
54
+ return renameCli([this.oldPath, this.newPath, ...(write ? ['--apply'] : []), ...(this.history ? ['--history'] : [])], '--write')
56
55
  }
57
- 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 })
58
57
  } catch (e) {
59
58
  this.context.stderr.write(`FAIL: ${e instanceof Error ? e.message : String(e)}\n`)
60
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
  }
@@ -100,6 +100,36 @@ export class ReleasesAddCommand extends Command {
100
100
  }
101
101
  }
102
102
 
103
+ export class ReleasesRemoveCommand extends Command {
104
+ static override paths = [['releases', 'remove']]
105
+
106
+ static override usage = Command.Usage({
107
+ category: 'Gate',
108
+ description: 'take one change out of .shipkit/releases/next.md, by its card id or its title',
109
+ details: 'the change the word names leaves .shipkit/releases/next.md, and the write is committed by pathspec, as `releases add` does. The word is the change\'s card id (whole, or the moment it starts with), else its title, whole or a part of it. Refused when it names no change or more than one. Its pictures stay where the store keeps them: they are kept by content, and another change may show the same one.',
110
+ examples: [
111
+ ['by the card it came from', 'sk releases remove 20250101-120000-new-toolbar'],
112
+ ['by its title', 'sk releases remove "A new toolbar"'],
113
+ ],
114
+ })
115
+
116
+ ref = Option.String({ required: true, name: 'card id | title' })
117
+
118
+ async execute(): Promise<number> {
119
+ try {
120
+ const { dropChange } = await import('../releases/store.ts')
121
+ const { commitPaths } = await import('../social/writes.ts')
122
+ const { file, title } = dropChange(process.cwd(), this.ref)
123
+ commitPaths([file], `releases: next.md loses ${title}`)
124
+ this.context.stdout.write(`ok: « ${title} » is out of ${file}\n`)
125
+ return 0
126
+ } catch (e) {
127
+ this.context.stderr.write(`FAIL: ${e instanceof Error ? e.message : String(e)}\n`)
128
+ return 1
129
+ }
130
+ }
131
+ }
132
+
103
133
  export class ReleasesRefreshCommand extends Command {
104
134
  static override paths = [['releases', 'refresh']]
105
135