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
@@ -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 (.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.',
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
  }
@@ -135,6 +135,61 @@ export function takeViews(args: readonly string[]): { views: ViewInput[]; rest:
135
135
  return { views, rest }
136
136
  }
137
137
 
138
+ const ADD_VIEW_USAGE = 'add-view <id> "<label>" <a.png> [<b.png>] | --image <a.png> | --before <a.png> --after <b.png> | --video <clip> | --audio <sound> | --gallery <a.png> … [--label "<label>"] [--note "<text>"]'
139
+ const MEDIA_FILE = /\.(png|jpe?g|webp|gif|mp4|webm|mov|wav|mp3|flac|ogg|opus|m4a)$/i
140
+ const quoted = (a: string): string => (/^[\w./=,@:+-]+$/.test(a) ? a : `"${a.replace(/"/g, '\\"')}"`)
141
+
142
+ /** add-view's args: the positional form, or the view flags of add; a flag is never a label, `own` are the repo unit's flags */
143
+ export async function addViewArgs(args: readonly string[], own: readonly string[]): Promise<{ id: string; view: ViewInput; repoFlags: Record<string, string[]> }> {
144
+ const one: Record<string, string> = {}
145
+ const repoFlags: Record<string, string[]> = {}
146
+ const words: string[] = []
147
+ let gallery: string[] | null = null
148
+ for (let i = 0; i < args.length; i++) {
149
+ const a = args[i] ?? ''
150
+ if (!a.startsWith('--')) {
151
+ ;(gallery ?? words).push(a)
152
+ continue
153
+ }
154
+ const name = a.slice(2)
155
+ if (name === 'gallery') {
156
+ gallery = []
157
+ continue
158
+ }
159
+ if (name === 'what') throw new Error(`--what: a view takes no --what, a line on it is --note "<text>"; ${ADD_VIEW_USAGE}`)
160
+ if (!['label', 'note', 'image', 'video', 'audio', 'before', 'after', ...own].includes(name)) throw new Error(`${a}: add-view takes no such flag; ${ADD_VIEW_USAGE}`)
161
+ const v = args[i + 1]
162
+ if (v === undefined || v.startsWith('--')) throw new Error(`${a} needs its value; ${ADD_VIEW_USAGE}`)
163
+ i++
164
+ if (own.includes(name)) (repoFlags[name] ??= []).push(v)
165
+ else one[name] = v
166
+ }
167
+ const [id, ...rest] = words
168
+ if (!id) throw new Error(ADD_VIEW_USAGE)
169
+ let label = one.label
170
+ let files = rest
171
+ if (label === undefined && rest[0] !== undefined && !MEDIA_FILE.test(rest[0])) [label, ...files] = rest
172
+ if (label === undefined && gallery?.[0] !== undefined && !MEDIA_FILE.test(gallery[0]) && !gallery[0].includes('=')) label = gallery.shift()
173
+ const given = [files.length > 0 ? 'files' : '', one.image ? '--image' : '', one.video ? '--video' : '', one.audio ? '--audio' : '', one.before || one.after ? '--before --after' : '', gallery ? '--gallery' : ''].filter((x) => x !== '')
174
+ if (given.length !== 1) throw new Error(`${given.length === 0 ? 'no media' : `one media a view, not ${given.join(' and ')}`}; ${ADD_VIEW_USAGE}`)
175
+ if (!label?.trim()) throw new Error(`the view needs its label: sk review ${['add-view', id, '"<label>"', ...args.filter((a) => a !== id).map(quoted)].join(' ')}`)
176
+ if ((one.before === undefined) !== (one.after === undefined)) throw new Error(`--before and --after go together; ${ADD_VIEW_USAGE}`)
177
+ if (gallery?.length === 0) throw new Error(`--gallery needs its images; ${ADD_VIEW_USAGE}`)
178
+ const view: ViewInput = one.image
179
+ ? { label, image: one.image }
180
+ : one.video
181
+ ? { label, video: one.video }
182
+ : one.audio
183
+ ? { label, audio: one.audio }
184
+ : one.before && one.after
185
+ ? { label, before: one.before, after: one.after }
186
+ : gallery
187
+ ? { label, gallery: gallery.map(tileOf) }
188
+ : (await import('../review/store.ts')).filesView(label, files, `${files.length} files: one image, or a before and an after; ${ADD_VIEW_USAGE}`)
189
+ if (one.note !== undefined) view.note = one.note
190
+ return { id, view, repoFlags }
191
+ }
192
+
138
193
  /** the flags of `add`, parsed by name: a value flag repeats where it says so */
139
194
  function flagsOf(args: readonly string[], values: readonly string[], repeat: readonly string[], bools: readonly string[]): { one: Record<string, string>; many: Record<string, string[]>; on: Set<string>; positionals: string[] } {
140
195
  const one: Record<string, string> = {}
@@ -163,7 +218,7 @@ function flagsOf(args: readonly string[], values: readonly string[], repeat: rea
163
218
  }
164
219
 
165
220
  const ADD_FLAGS = `flags:
166
- --title "<title>" one short line: what he looks at
221
+ --title "<title>" one short line: what he looks at (a lone "<title>" after add is the same)
167
222
  --what "<what>" what changed and why, short markdown: one line, then - bullets
168
223
  --post "<line>" the public line for a post of it, what a user gets (the repo's guard reads it)
169
224
  --changelog "<category>: <line>" its change in the release being filled: on his approval it lands in .shipkit/releases/next.md with the card's after picture (the repo's guard reads it)
@@ -268,8 +323,11 @@ export class ReviewAddCommand extends Command {
268
323
  const kind = rest.includes('--subject') && kindName ? h.unit?.kinds?.[kindName] : undefined
269
324
  const own = [...Object.keys(kind?.flags ?? {}), ...Object.keys(h.unit?.flags ?? {})]
270
325
  const f = flagsOf(rest, ['title', 'what', 'post', 'changelog', 'rating', 'image', 'video', 'audio', 'before', 'after', 'label', 'topic', 'subject', 'commit', 'lane', 'supersedes', 'keeps', 'why', 'live', 'trailer', 'version', 'shots', 'pick'], ['answers', ...own], ['new', 'wip', 'choice'])
271
- if (f.positionals.length > 0) throw new Error(`unexpected ${f.positionals.join(' ')}`)
272
326
  const o = f.one
327
+ // a lone word is the title, as `sk ask <title>` takes it; a media file never is
328
+ const [lone, ...more] = f.positionals
329
+ if (lone !== undefined && more.length === 0 && o.title === undefined && !MEDIA_FILE.test(lone)) o.title = lone
330
+ else if (lone !== undefined) throw new Error(`unexpected ${f.positionals.map(quoted).join(' ')}: the title is --title "<title>", the subject --image <a.png> (sk review add --help)`)
273
331
  const trailer = await trailerOfFlags(o, views.length > 0 || f.on.has('wip') || f.on.has('choice'))
274
332
  const repoFlags = Object.fromEntries(own.flatMap((k) => (f.many[k] ? [[k, f.many[k]]] : [])))
275
333
  const parsed = kind?.parse ? kind.parse(Object.fromEntries(Object.keys(kind.flags ?? {}).map((k) => [k, f.many[k] ?? []]))) : null
@@ -365,8 +423,11 @@ export class ReviewAddViewCommand extends Command {
365
423
  static override usage = Command.Usage({
366
424
  category: 'Review',
367
425
  description: 'another angle on a card he has not answered yet: an image, a pair, a clip or a gallery',
368
- details: `${DETAILS}\n\nsk review add-view <id> "<label>" <a.png> [<b.png>] | --video <clip.mp4> | --audio <sound.wav> | --gallery <a.png> <b.png> … [--note "<a line on that view>"]`,
369
- examples: [['a view from above', 'sk review add-view <id> "from above" top.png']],
426
+ details: `${DETAILS}\n\nsk ${ADD_VIEW_USAGE}. The view flags are add's; the id may be its moment alone (<YYYYMMDD-HHMMSS>).`,
427
+ examples: [
428
+ ['a view from above', 'sk review add-view <id> "from above" top.png'],
429
+ ['a before and after', 'sk review add-view <id> --label "on a phone" --before a.png --after b.png'],
430
+ ],
370
431
  })
371
432
  args = Option.Proxy()
372
433
 
@@ -375,34 +436,14 @@ export class ReviewAddViewCommand extends Command {
375
436
  return helpWithUnit(this.context, this.cli.usage(ReviewAddViewCommand, { detailed: true }), false)
376
437
  }
377
438
  return run(this.context, async (h) => {
378
- const { addView, filesView } = await import('../review/store.ts')
379
- const own = Object.keys(h.unit?.flags ?? {})
380
- const repoFlags: Record<string, string[]> = {}
381
- const args: string[] = []
382
- let note: string | undefined
383
- for (let i = 0; i < this.args.length; i++) {
384
- const a = this.args[i] ?? ''
385
- const name = a.startsWith('--') ? a.slice(2) : ''
386
- if (own.includes(name)) (repoFlags[name] ??= []).push(this.args[++i] ?? '')
387
- else if (name === 'note') note = this.args[++i]
388
- else args.push(a)
389
- }
390
- if (this.args.includes('--note') && (note === undefined || note.startsWith('--'))) throw new Error('--note "<text>": a line on that view')
391
- const [id, label, ...rest] = args
392
- if (!id || !label) throw new Error('add-view <id> "<label>" <media>')
393
- const v: ViewInput =
394
- rest[0] === '--video' && rest[1]
395
- ? { label, video: rest[1] }
396
- : rest[0] === '--audio' && rest[1]
397
- ? { label, audio: rest[1] }
398
- : rest[0] === '--gallery'
399
- ? { label, gallery: rest.slice(1).map(tileOf) }
400
- : filesView(label, rest, 'add-view <id> "<label>" <a.png> [<b.png>] | --video <clip> | --gallery <a.png> …')
401
- if (note !== undefined) v.note = note
402
- const extra = h.unit?.addView ? await h.unit.addView(v, repoFlags) : {}
439
+ const { addView } = await import('../review/store.ts')
440
+ const a = await addViewArgs(this.args, Object.keys(h.unit?.flags ?? {}))
441
+ const v = a.view
442
+ const id = await idOf(h.dir, a.id)
443
+ const extra = h.unit?.addView ? await h.unit.addView(v, a.repoFlags) : {}
403
444
  const item = await addView(h.dir, id, v, extra)
404
445
  const { viewLetter } = await import('../review/model.ts')
405
- h.out(`${id}: view ${viewLetter(item.views.length - 1)} "${label}" added`)
446
+ h.out(`${id}: view ${viewLetter(item.views.length - 1)} "${v.label}" added`)
406
447
  for (const line of await (await import('../review/previews.ts')).playCopies(h.dir, item, item.views.length - 1)) h.err(line)
407
448
  return 0
408
449
  })
@@ -430,7 +471,12 @@ export class ReviewLsCommand extends Command {
430
471
  return run(this.context, async (h) => {
431
472
  const verbs = h.unit?.verbs ?? {}
432
473
  const v = verbs[verb]
433
- if (!v) throw new Error(`no verb « ${verb} »: sk review --help lists sk's own; the repo's unit declares ${Object.keys(verbs).join(', ') || 'none'}`)
474
+ if (!v) {
475
+ const { typoOf } = await import('./family-help.ts')
476
+ const own = this.cli.definitions().map((d) => d.path.split(' ')).filter((w) => w[1] === 'review' && w.length === 3).map((w) => w[2]!)
477
+ const close = typoOf(verb, [...own, ...Object.keys(verbs)], 2)
478
+ throw new Error(`no verb « ${verb} »: ${close.length > 0 ? `did you mean ${close.map((c) => `sk review ${c}`).join(', ')} ? ` : ''}sk review --help lists sk's own; the repo's unit declares ${Object.keys(verbs).join(', ') || 'none'}`)
479
+ }
434
480
  const { dirname } = await import('node:path')
435
481
  return v.run(rest, { dir: h.dir, root: dirname(dirname(h.dir)), say: h.out, err: h.err })
436
482
  })
@@ -689,13 +735,17 @@ export class ReviewWithdrawCommand extends Command {
689
735
  static override paths = [['review', 'withdraw']]
690
736
  static override usage = Command.Usage({ category: 'Review', description: 'take an unanswered card back, with the reason', details: DETAILS })
691
737
  ids = Option.Rest({ required: 1 })
692
- why = Option.String('--why', { required: true, description: 'why it goes' })
738
+ why = Option.String('--why,--note', { required: true, description: 'why it goes (--note says the same, as on fixed, wontfix, blocked and drop)' })
693
739
 
694
740
  async execute(): Promise<number> {
695
741
  return run(this.context, async (h) => {
696
742
  const { withdraw } = await import('../review/store.ts')
697
- for (const id of this.ids) if (!withdraw(h.dir, id, this.why)) throw new Error(`${id}: no such card, or he answered it already`)
698
- h.out(`review: ${this.ids.length} withdrawn`)
743
+ const ids = await Promise.all(this.ids.map((ref) => idOf(h.dir, ref)))
744
+ for (const id of ids) {
745
+ const r = withdraw(h.dir, id, this.why)
746
+ if ('refused' in r) throw new Error(r.refused)
747
+ h.out(r.already ? `${id}: withdrawn already (${r.already}), nothing to do` : `${id}: withdrawn`)
748
+ }
699
749
  return 0
700
750
  })
701
751
  }
@@ -711,7 +761,8 @@ export class ReviewReopenCommand extends Command {
711
761
  const { reopen } = await import('../review/store.ts')
712
762
  const { followAnswer } = await import('../releases/from-card.ts')
713
763
  const { dirname } = await import('node:path')
714
- for (const id of this.ids) {
764
+ for (const ref of this.ids) {
765
+ const id = await idOf(h.dir, ref)
715
766
  const v = reopen(h.dir, id)
716
767
  if (!v) throw new Error(`${id}: no such card, or no answer to reopen`)
717
768
  await followAnswer(dirname(dirname(h.dir)), id, v.status)
@@ -737,9 +788,10 @@ export class ReviewPickCommand extends Command {
737
788
  return run(this.context, async (h) => {
738
789
  const { setAgentPick } = await import('../review/store.ts')
739
790
  const { viewLetter, viewName } = await import('../review/model.ts')
740
- const item = setAgentPick(h.dir, this.id, this.view)
791
+ const id = await idOf(h.dir, this.id)
792
+ const item = setAgentPick(h.dir, id, this.view)
741
793
  const n = item.agentPick ?? 0
742
- h.out(`${this.id}: my pick ${viewLetter(n)} "${viewName(item.views[n], n)}"`)
794
+ h.out(`${id}: my pick ${viewLetter(n)} "${viewName(item.views[n], n)}"`)
743
795
  return 0
744
796
  })
745
797
  }
@@ -769,6 +821,21 @@ function actCommand(op: ActOp, description: string, o: { note?: 'required' | 'op
769
821
  if (o.topic === 'required' && !this.words) throw new Error(`${op} <id> <topic> (sk review topics)`)
770
822
  const id = await idOf(h.dir, this.id)
771
823
  const who = actor(this.as, o.named, op)
824
+ if (op === 'done') {
825
+ // done is asked of a card he answered « fix »: closed already is the goal reached, unanswered is withdraw's
826
+ const { readAll } = await import('../review/store.ts')
827
+ const { followedIds } = await import('../review/threads.ts')
828
+ const was = readItem(h.dir, id)
829
+ const followed = followedIds(readAll(h.dir).items).has(id)
830
+ const st = was ? stateOf(was, followed) : null
831
+ if (st?.state === 'closed') {
832
+ h.out(`${id}: closed already (${st.why ?? 'closed'}${followed ? ', a newer card follows it' : ''}), nothing to close`)
833
+ if (this.words || this.note) h.err(`your words are not posted: sk review reply ${id} "<text>"`)
834
+ return 0
835
+ }
836
+ if (st?.state === 'asks' || st?.state === 'draft')
837
+ throw new Error(`${id}: done closes a card the owner answered « fix »; this one ${st.state === 'asks' ? "waits on the owner's verdict" : 'is in progress'}: sk review withdraw ${id} --why "<why>" takes it back`)
838
+ }
772
839
  act(h.dir, id, op, who, {
773
840
  ...(this.note ? { note: this.note } : {}),
774
841
  ...(op === 'ask' && this.words ? { text: this.words } : {}),
@@ -921,8 +988,9 @@ export class ReviewReadyCommand extends Command {
921
988
  async execute(): Promise<number> {
922
989
  return run(this.context, async (h) => {
923
990
  const { readItem, readyItem } = await import('../review/store.ts')
924
- const live = readItem(h.dir, this.id)?.item.wip?.live
925
- const r = await readyItem(h.dir, this.id, this.image ? { image: this.image } : {})
991
+ const id = await idOf(h.dir, this.id)
992
+ const live = readItem(h.dir, id)?.item.wip?.live
993
+ const r = await readyItem(h.dir, id, this.image ? { image: this.image } : {})
926
994
  if (live !== undefined) h.unit?.live?.stop?.(live, 'ready')
927
995
  h.out(`${r.id} ready: he can answer it`)
928
996
  return 0
@@ -1,7 +1,9 @@
1
1
  // sk shot: a still of any url (webp by default), or a clip with --video, through the machine's
2
2
  // one warm browser (shot/client.ts). A repo's own CLI wraps it with its setup
3
3
  // flags; the trailer's `url` film calls the same functions.
4
- import { relative } from 'path'
4
+ import { statSync } from 'fs'
5
+ import { relative, resolve } from 'path'
6
+ import { pathToFileURL } from 'url'
5
7
  import { Command, Option } from 'clipanion'
6
8
  import { clipUrl, shotUrl, type ShotResult } from '../shot/client.ts'
7
9
  import { askOf, isClip } from '../shot/shot-ask.ts'
@@ -17,6 +19,13 @@ export const renderShot = (r: ShotResult, cwd: string): string[] => {
17
19
  return lines
18
20
  }
19
21
 
22
+ /** the path of a file on this machine as its file url; anything else as typed */
23
+ export const fileUrlOf = (s: string, cwd: string): string => {
24
+ if (/^[a-z]+:\/\//i.test(s)) return s
25
+ const p = resolve(cwd, s)
26
+ return statSync(p, { throwIfNoEntry: false })?.isFile() ? pathToFileURL(p).href : s
27
+ }
28
+
20
29
  export class ShotCommand extends Command {
21
30
  static override paths = [['shot']]
22
31
  static essential = { args: '<url>' }
@@ -25,9 +34,10 @@ export class ShotCommand extends Command {
25
34
  category: 'Serve',
26
35
  description: 'a webp of any url through the warm browser (a png with --out x.png), or an mp4 clip with --video',
27
36
  details:
28
- 'one warm headless chromium for the whole machine (the `shot` global process, started when down). A still reuses the warm page when it already shows the url, so a warm shot answers in about 0.1 s. A page with `<meta name="shot-ready" content="wait">` is shot once it sets content="ready"; any other page --wait ms after its load. --video films a page that is a canvas through its WebCodecs encoder (H.264 muxed with no second encode), and any other page as chromium paints it (its screencast, encoded by ffmpeg as the frames arrive); --dom films the page even when a canvas fills it. --step <hook> films frame by frame: before each frame the page draws its time t (seconds) in `await window[hook](t)`, then its ready mark, so a slow page films smooth at its fps; a canvas page is encoded by its own WebCodecs at the exact time n / fps, any other page a screenshot a frame. A still with --step is the page drawn at --at s',
37
+ 'one warm headless chromium for the whole machine (the `shot` global process, started when down). A still reuses the warm page when it already shows the url, so a warm shot answers in about 0.1 s. A page with `<meta name="shot-ready" content="wait">` is shot once it sets content="ready"; any other page --wait ms after its load; a page that navigates while it loads (a sign in that redirects) gets its wait again where it lands. --full shoots the whole page at the width of the viewport. A file of this machine is a url too (its path, or file://). --video films a page that is a canvas through its WebCodecs encoder (H.264 muxed with no second encode), and any other page as chromium paints it (its screencast, encoded by ffmpeg as the frames arrive); --dom films the page even when a canvas fills it. --step <hook> films frame by frame: before each frame the page draws its time t (seconds) in `await window[hook](t)`, then its ready mark, so a slow page films smooth at its fps; a canvas page is encoded by its own WebCodecs at the exact time n / fps, any other page a screenshot a frame. A still with --step is the page drawn at --at s. A session: cookies follow every shot (one jar in memory for the whole machine), the local storage of a page does not: a shot at another viewport, a clip and the idle close (60 s) each start with an empty one, as two browser contexts do. So when an app keeps its session in local storage, open its sign in at the viewport you shoot at; a request the page sees answered 401 or 403 prints its own WARN line',
29
38
  examples: [
30
39
  ['a still of a running dev server', 'sk shot localhost:5173/'],
40
+ ['a whole tall page at a phone width', 'sk shot :5173/guest --viewport 390,844 --full --out shots/guest.png'],
31
41
  ['a phone screen, at the pixel ratio of a phone', 'sk shot :5173/play --viewport 390,844 --dpr 3 --out shots/phone.png'],
32
42
  ['a 3 s clip', 'sk shot :4808/ --video 3 --out clips/walk.mp4'],
33
43
  ['a clip of a whole web app page, canvas or not', 'sk shot :5173/settings --video 3 --dom'],
@@ -40,7 +50,8 @@ export class ShotCommand extends Command {
40
50
  dpr = Option.String('--dpr', { description: 'device pixel ratio (default 1)' })
41
51
  out = Option.String('--out', { description: 'the file (default .shipkit/tmp/shots/<url>.webp, or .mp4 with --video); its extension picks the still: .webp and .jpg at quality 90, .png lossless' })
42
52
  reload = Option.Boolean('--reload', false, { description: 'load the page again even when the warm page shows this url' })
43
- wait = Option.String('--wait', { description: 'ms after load for a page with no ready mark (default 300)' })
53
+ wait = Option.String('--wait', { description: 'ms after load for a page with no ready mark (default 300, at most 60000)' })
54
+ full = Option.Boolean('--full', false, { description: 'the whole page, past the viewport height (a still only)' })
44
55
  video = Option.String('--video', { description: 'seconds of clip: an mp4 of the page (its canvas when a canvas fills it)' })
45
56
  fps = Option.String('--fps', { description: 'clip frames per second (default 30)' })
46
57
  long = Option.Boolean('--long', false, { description: 'allow a clip past 30 s' })
@@ -53,7 +64,7 @@ export class ShotCommand extends Command {
53
64
  const cwd = process.cwd()
54
65
  const err = (l: string) => this.context.stderr.write(`${l}\n`)
55
66
  try {
56
- const a = askOf({ url: this.url, viewport: this.viewport, dpr: this.dpr, out: this.out, reload: this.reload, wait: this.wait, video: this.video, fps: this.fps, long: this.long, dom: this.dom, step: this.step, at: this.at }, cwd)
67
+ const a = askOf({ url: fileUrlOf(this.url, cwd), full: this.full, viewport: this.viewport, dpr: this.dpr, out: this.out, reload: this.reload, wait: this.wait, video: this.video, fps: this.fps, long: this.long, dom: this.dom, step: this.step, at: this.at }, cwd)
57
68
  const r = isClip(a) ? await clipUrl(a, err) : await shotUrl(a, err)
58
69
  if (this.json) this.context.stdout.write(`${JSON.stringify(r)}\n`)
59
70
  else for (const l of renderShot(r, cwd)) this.context.stdout.write(`${l}\n`)
@@ -1,7 +1,7 @@
1
1
  // shipkit status — read back a gate started with `shipkit ci --detach`. Thin
2
2
  // clipanion surface; logic in core/jobs.ts.
3
3
  import { Command, Option } from 'clipanion'
4
- import { jobStatus, STILL_RUNNING } from '../core/jobs.ts'
4
+ import { jobStatus, STILL_RUNNING, waitStatus } from '../core/jobs.ts'
5
5
 
6
6
  export class StatusCommand extends Command {
7
7
  static override paths = [['status']]
@@ -10,17 +10,18 @@ export class StatusCommand extends Command {
10
10
  static override usage = Command.Usage({
11
11
  category: 'Gate',
12
12
  description: 'the output and verdict of a gate started with `sk ci --detach`',
13
- details: `a gate started with \`shipkit ci --detach\`: its wire lines so far, then its verdict. Exit code = the gate's own once it finished, ${STILL_RUNNING} while it still runs, 1 when it died without one`,
13
+ details: `a gate started with \`shipkit ci --detach\`: its verdict on the first line (finished green, finished red, still running, died), then its wire lines so far. Exit code = the gate's own once it finished, ${STILL_RUNNING} while it still runs, 1 when it died without one. --wait holds until the run has a verdict (10 minutes at most): one call from a backgrounded shell in place of a poll every few seconds. With no id: the latest run \`--detach\` started here, never a job of the daemon`,
14
14
  examples: [
15
- ['the latest detached run of this checkout', 'sk status'],
16
- ['one run by id', 'sk status ci-mf3k2a-1x2y'],
15
+ ['hold until the run ends, then its verdict', 'sk status ci-mf3k2a-1x2y --wait'],
16
+ ['the latest detached run of this checkout, as it stands', 'sk status'],
17
17
  ],
18
18
  })
19
19
 
20
20
  id = Option.String({ required: false })
21
+ wait = Option.Boolean('--wait', false, { description: 'hold until the run has a verdict, 10 minutes at most, then print it' })
21
22
 
22
23
  async execute(): Promise<number> {
23
- const r = jobStatus(process.cwd(), this.id)
24
+ const r = this.wait ? await waitStatus(process.cwd(), this.id) : jobStatus(process.cwd(), this.id)
24
25
  for (const l of r.lines) this.context.stdout.write(`${l}\n`)
25
26
  return r.code
26
27
  }
@@ -3,7 +3,7 @@
3
3
  // through the agent time index (agent-time/store.ts). REPORT ONLY: exit 0 with
4
4
  // a report, 1 when nothing matched, 2 on a bad flag.
5
5
  import { Command, Option } from 'clipanion'
6
- import { resolve } from 'path'
6
+ import { dirname, resolve } from 'path'
7
7
 
8
8
  const BIG_BYTES = 50 * 1024 * 1024
9
9
 
@@ -70,7 +70,10 @@ export class TimeCommand extends Command {
70
70
  const { buildReport } = await import('../agent-time/report.ts')
71
71
  const { loadMasker } = await import('../agent-time/mask.ts')
72
72
 
73
- const repos = repoArgs.length > 0 ? repoArgs.map((r) => resolve(r)) : [process.cwd()]
73
+ // with no repo named: the repo this folder is in, by its main work tree, where its sessions are filed
74
+ const { gitRoot } = await import('../core/git-root.ts')
75
+ const here = gitRoot(process.cwd())
76
+ const repos = repoArgs.length > 0 ? repoArgs.map((r) => resolve(r)) : [here == null ? process.cwd() : dirname(here.commonDir)]
74
77
  const slugs = repos.map(projectSlug)
75
78
  const keep = this.all ? () => true : (p: string) => slugs.some((s) => p === s || p.startsWith(`${s}--claude-worktrees-`))
76
79
  const roots = discoverConfigRoots()
@@ -88,12 +91,14 @@ export class TimeCommand extends Command {
88
91
  try { (require('os') as typeof import('os')).setPriority(0, 15) } catch { /* not allowed: index at the normal priority */ }
89
92
  }
90
93
  const t = performance.now()
91
- if (t - lastPrint < (tty ? 200 : 10_000) && p.done < p.files) return
94
+ // off a terminal the first line is the answer: a progress line only for an index that runs long
95
+ if (tty ? t - lastPrint < 200 && p.done < p.files : t - Math.max(lastPrint, tIndex) < 10_000) return
92
96
  lastPrint = t
93
97
  const line = `index: ${p.done}/${p.files} files, ${(p.doneBytes / 1e9).toFixed(1)}/${(p.bytes / 1e9).toFixed(1)} GB, ${Math.round((t - tIndex) / 1000)}s`
94
98
  err.write(tty ? `\r${line}` : `${line}\n`)
95
99
  })
96
- if (res.bytes >= BIG_BYTES) err.write(`${tty ? '\n' : ''}index: read ${res.read} of ${pending} files, ${(res.bytes / 1e9).toFixed(2)} GB in ${(res.ms / 1000).toFixed(1)}s (${agentTimeDbPath()})\n`)
100
+ const indexed = res.bytes >= BIG_BYTES ? `index: read ${res.read} of ${pending} files, ${(res.bytes / 1e9).toFixed(2)} GB in ${(res.ms / 1000).toFixed(1)}s (${agentTimeDbPath()})\n` : ''
101
+ if (tty && indexed !== '') err.write(`\n${indexed}`)
97
102
  markGone(db, files, keep)
98
103
  const loaded = loadWindow(db, keep, from ?? 0, now)
99
104
  const labels = this.all ? [...new Set(loaded.files.map((f) => repoOfProject(f.project)))].sort() : slugs.map((s) => repoOfProject(s))
@@ -106,6 +111,7 @@ export class TimeCommand extends Command {
106
111
  const report = buildReport(loaded, { repos: labels, from, to: now, repoOf: (p) => repoOfProject(p) }, loadMasker(repos[0] ?? null))
107
112
  if (this.json) this.context.stdout.write(`${JSON.stringify(report)}\n`)
108
113
  else this.context.stdout.write(render(report, view, top))
114
+ if (!tty) err.write(indexed)
109
115
  return 0
110
116
  } finally {
111
117
  db.close()