rvlib-shipkit 2.18.0 → 2.20.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 (186) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/package.json +1 -1
  3. package/src/annex/annex.ts +227 -0
  4. package/src/annex/offload.ts +279 -0
  5. package/src/asks/asks-queue.ts +63 -10
  6. package/src/checks/SK040-release-words.check.ts +43 -0
  7. package/src/checks/SK041-annex-links.check.ts +28 -0
  8. package/src/checks/SK042-post-kinds.check.ts +73 -0
  9. package/src/cli/cmd_Annex.ts +179 -0
  10. package/src/cli/cmd_Asks.ts +3 -1
  11. package/src/cli/cmd_Commands.ts +4 -1
  12. package/src/cli/cmd_GlobalProcesses.ts +34 -11
  13. package/src/cli/cmd_Home.ts +41 -4
  14. package/src/cli/cmd_Messages.ts +155 -0
  15. package/src/cli/cmd_Releases.ts +48 -0
  16. package/src/cli/cmd_Review.ts +161 -6
  17. package/src/cli/cmd_Secret.ts +4 -30
  18. package/src/cli/cmd_Shot.ts +4 -4
  19. package/src/cli/cmd_Social.ts +179 -3
  20. package/src/cli/cmd_Trailer.ts +15 -3
  21. package/src/cli/family-pages.ts +2 -0
  22. package/src/cli/kit/index.ts +1 -1
  23. package/src/cli/kit/verb.ts +11 -3
  24. package/src/cli/registry.ts +8 -2
  25. package/src/collections/actions.ts +29 -1
  26. package/src/collections/collection-types.ts +10 -1
  27. package/src/collections/providers.ts +5 -2
  28. package/src/commands/model.ts +36 -0
  29. package/src/commands/registry.ts +49 -0
  30. package/src/commands/routes.ts +59 -0
  31. package/src/commands/runner.ts +35 -0
  32. package/src/commands/runs.ts +112 -0
  33. package/src/core/app-icon.ts +4 -3
  34. package/src/core/icon-type.ts +8 -0
  35. package/src/core/jobs.ts +4 -3
  36. package/src/core/layout.ts +5 -2
  37. package/src/core/squircle.ts +95 -0
  38. package/src/home/daemon-jobs.ts +26 -2
  39. package/src/home/global-units.ts +3 -0
  40. package/src/home/gui-app/ShipkitGui.swift +302 -5
  41. package/src/home/gui-app.ts +63 -33
  42. package/src/home/hmr-keep.ts +134 -0
  43. package/src/home/home-paths.ts +5 -1
  44. package/src/home/home-start.ts +14 -14
  45. package/src/home/lib-watch.ts +21 -11
  46. package/src/home/pm.ts +1 -1
  47. package/src/home/process-apps.ts +181 -0
  48. package/src/home/resources.ts +3 -3
  49. package/src/home/run-daemon.ts +11 -2
  50. package/src/home/run-pm.ts +9 -1
  51. package/src/home/run-web.ts +7 -4
  52. package/src/home/serve-web.ts +64 -14
  53. package/src/home/supervise.ts +3 -1
  54. package/src/identities/collection.ts +49 -0
  55. package/src/identities/identities.ts +130 -11
  56. package/src/identities/machine.ts +4 -3
  57. package/src/identities/rating.ts +33 -0
  58. package/src/identities/shown.ts +170 -0
  59. package/src/identities/steps.ts +5 -0
  60. package/src/media-store/purge.ts +15 -1
  61. package/src/media-store/remote.ts +22 -6
  62. package/src/messages/brief.ts +117 -0
  63. package/src/messages/collection.ts +40 -0
  64. package/src/messages/model.ts +171 -0
  65. package/src/messages/routes.ts +15 -0
  66. package/src/messages/score.ts +180 -0
  67. package/src/messages/tabs.ts +13 -0
  68. package/src/release/notes.ts +130 -0
  69. package/src/release/run-bump.ts +41 -18
  70. package/src/release/run-release.ts +22 -4
  71. package/src/release/run-releases.ts +17 -15
  72. package/src/release/unit-resolve.ts +9 -0
  73. package/src/releases/add.ts +66 -0
  74. package/src/releases/collection.ts +36 -0
  75. package/src/releases/from-card.ts +66 -0
  76. package/src/releases/model.ts +267 -0
  77. package/src/releases/pictures.ts +89 -0
  78. package/src/releases/routes.ts +36 -0
  79. package/src/releases/store.ts +71 -0
  80. package/src/repo-config.ts +5 -0
  81. package/src/review/cells.ts +0 -11
  82. package/src/review/format.ts +10 -6
  83. package/src/review/http.ts +7 -2
  84. package/src/review/model.ts +92 -3
  85. package/src/review/notes.ts +2 -48
  86. package/src/review/routes.ts +28 -10
  87. package/src/review/stage-card.ts +197 -0
  88. package/src/review/stage-routes.ts +123 -0
  89. package/src/review/store.ts +117 -19
  90. package/src/review/trailer-card.ts +99 -0
  91. package/src/review/trailer-desk.ts +57 -4
  92. package/src/review/trailer-model.ts +41 -7
  93. package/src/review/trailer-notes.ts +45 -0
  94. package/src/review/trailer-routes.ts +22 -13
  95. package/src/secrets/manager.ts +59 -0
  96. package/src/secrets/name.ts +2 -0
  97. package/src/serve/hub-app/app-bridge.ts +71 -0
  98. package/src/serve/hub-app/col-card.tsx +10 -0
  99. package/src/serve/hub-app/cols-svc.ts +37 -6
  100. package/src/serve/hub-app/commands/commands-page.tsx +122 -0
  101. package/src/serve/hub-app/commands/commands-st.ts +177 -0
  102. package/src/serve/hub-app/commands.css +24 -0
  103. package/src/serve/hub-app/hash-route.ts +40 -1
  104. package/src/serve/hub-app/home-st.ts +11 -2
  105. package/src/serve/hub-app/home.html +3 -0
  106. package/src/serve/hub-app/hub-app.tsx +6 -0
  107. package/src/serve/hub-app/hub.css +1 -0
  108. package/src/serve/hub-app/icons.tsx +5 -0
  109. package/src/serve/hub-app/identities-view.tsx +4 -1
  110. package/src/serve/hub-app/identities.css +1 -0
  111. package/src/serve/hub-app/index.html +3 -0
  112. package/src/serve/hub-app/keys.ts +2 -2
  113. package/src/serve/hub-app/machine-st.ts +41 -10
  114. package/src/serve/hub-app/messages/messages-page.tsx +354 -0
  115. package/src/serve/hub-app/messages/messages-st.ts +74 -0
  116. package/src/serve/hub-app/messages.css +35 -0
  117. package/src/serve/hub-app/releases/releases-page.tsx +94 -0
  118. package/src/serve/hub-app/releases/releases-st.ts +69 -0
  119. package/src/serve/hub-app/releases.css +25 -0
  120. package/src/serve/hub-app/repo-sections.ts +15 -1
  121. package/src/serve/hub-app/repo-st.ts +56 -5
  122. package/src/serve/hub-app/review/clip-st.ts +31 -3
  123. package/src/serve/hub-app/review/note-place.ts +31 -0
  124. package/src/serve/hub-app/review/review-cells.tsx +27 -3
  125. package/src/serve/hub-app/review/review-st.ts +77 -2
  126. package/src/serve/hub-app/review/review-thread.tsx +9 -31
  127. package/src/serve/hub-app/review/review-views.tsx +164 -58
  128. package/src/serve/hub-app/review/thread-st.ts +108 -41
  129. package/src/serve/hub-app/review/trailer-card.tsx +187 -0
  130. package/src/serve/hub-app/review/trailer-page.tsx +62 -31
  131. package/src/serve/hub-app/review/trailer-st.ts +138 -26
  132. package/src/serve/hub-app/review/trailer-timeline.tsx +39 -26
  133. package/src/serve/hub-app/review.css +49 -6
  134. package/src/serve/hub-app/social/comms-page.tsx +55 -23
  135. package/src/serve/hub-app/social/identity-pictures.ts +112 -0
  136. package/src/serve/hub-app/social/kit.tsx +9 -6
  137. package/src/serve/hub-app/social/post-card.tsx +10 -2
  138. package/src/serve/hub-app/social/social-model.ts +37 -3
  139. package/src/serve/hub-app/social/social-page.tsx +236 -82
  140. package/src/serve/hub-app/social/social-st.ts +79 -26
  141. package/src/serve/hub-app/social/stage-popup.tsx +268 -0
  142. package/src/serve/hub-app/social/stage-st.ts +310 -0
  143. package/src/serve/hub-app/social/step-layout.ts +42 -0
  144. package/src/serve/hub-app/social.css +68 -4
  145. package/src/serve/hub-app/tree-build.ts +38 -1
  146. package/src/serve/hub-app/tree-svc.ts +10 -3
  147. package/src/serve/project-gutter-route.ts +4 -2
  148. package/src/serve/same-origin.ts +24 -1
  149. package/src/serve/serve-hub.ts +27 -3
  150. package/src/shipkit-files.ts +9 -7
  151. package/src/shot/shooter.ts +3 -3
  152. package/src/shot/shot-ask.ts +14 -3
  153. package/src/shot/shot.shipkit.ts +1 -1
  154. package/src/social/discord-layout.ts +282 -0
  155. package/src/social/fit.ts +84 -0
  156. package/src/social/identity-words.ts +74 -0
  157. package/src/social/kind-pages.ts +41 -0
  158. package/src/social/kinds.ts +92 -0
  159. package/src/social/load.ts +105 -9
  160. package/src/social/md.ts +14 -6
  161. package/src/social/media-limit.ts +63 -2
  162. package/src/social/presence.ts +1 -1
  163. package/src/social/publish/bluesky.ts +58 -19
  164. package/src/social/publish/discord.ts +3 -2
  165. package/src/social/publish/index.ts +31 -5
  166. package/src/social/reach.ts +49 -0
  167. package/src/social/release-stage.ts +173 -0
  168. package/src/social/routes.ts +44 -9
  169. package/src/social/stage.ts +227 -0
  170. package/src/social/strip.ts +85 -0
  171. package/src/social/text.ts +6 -2
  172. package/src/social/unit.ts +57 -1
  173. package/src/social/writes.ts +11 -0
  174. package/src/stores/routes.ts +2 -2
  175. package/src/suite/judge-suites.ts +1 -1
  176. package/src/suite/suite-cli.ts +5 -5
  177. package/src/trailer/build.ts +90 -52
  178. package/src/trailer/draft.ts +28 -0
  179. package/src/trailer/footage.ts +4 -2
  180. package/src/trailer/grammar.ts +25 -13
  181. package/src/trailer/graph.ts +32 -9
  182. package/src/trailer/profile.ts +35 -0
  183. package/src/trailer/prune.ts +15 -10
  184. package/src/trailer/public-words.ts +41 -0
  185. package/src/trailer/stitch.ts +22 -10
  186. package/src/trailer/titles.ts +47 -2
@@ -6,7 +6,9 @@ import { fileURLToPath } from 'url'
6
6
  import { basename } from 'path'
7
7
  import { markAutostart } from '../home/autostart.ts'
8
8
  import { installHome, uninstallHome } from '../home/home-launchd.ts'
9
- import { homeInstalled, houseCli, houseRootOf, openWindow, startHome } from '../home/home-start.ts'
9
+ import { homeInstalled, houseCli, houseRoot, houseRootOf, openWindow, startHome } from '../home/home-start.ts'
10
+ import { ROLES } from '../home/pm.ts'
11
+ import { pmSwitchDeps, switchProcess } from './cmd_GlobalProcesses.ts'
10
12
  import { homeUp, homeUrl, hubBase } from '../home/home-paths.ts'
11
13
  import { homeRepo, houseIndex } from '../serve/project-gutter.ts'
12
14
  import { homedir } from 'os'
@@ -88,9 +90,10 @@ export class DaemonJobCommand extends Command {
88
90
 
89
91
  static override usage = Command.Usage({
90
92
  category: 'Serve',
91
- description: 'a daemon background job now, in this process: backup, retention sweep, media store, global context',
92
- 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 when the stamp of its 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',
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',
93
95
  examples: [
96
+ ['every global process app in ~/Applications built and swept now', 'sk daemon job apps'],
94
97
  ['a retention sweep now', 'sk daemon job "retention sweep"'],
95
98
  ['one media store pass', 'sk daemon job "media store"'],
96
99
  ['the house\'s global context written now', 'sk daemon job "global context"'],
@@ -156,8 +159,42 @@ export class PmInstallCommand extends Command {
156
159
  })
157
160
 
158
161
  async execute(): Promise<number> {
162
+ const root = houseRoot(process.cwd())
163
+ if (root == null) {
164
+ io(this).printErr(`FAIL: ${process.cwd()} is in no house repo, and no pm agent names one: run \`sk pm install\` from any folder of a repo whose CLAUDE.md includes the house wiki`)
165
+ return 1
166
+ }
159
167
  markAutostart(true)
160
- return installHome({ root: process.cwd(), cli: houseCli(process.cwd(), OWN_CLI), print: io(this).print })
168
+ return installHome({ root, cli: houseCli(root, OWN_CLI), print: io(this).print })
169
+ }
170
+ }
171
+
172
+ export class PmRestartCommand extends Command {
173
+ static override paths = [['pm', 'restart']]
174
+
175
+ static override usage = Command.Usage({
176
+ category: 'Serve',
177
+ description: 'restart the daemon, the web or both through pm, and wait until each probe answers again',
178
+ details: 'restart pm\'s own roles in place, never a kill: pm stops the role, starts it again, and this waits until a new pid answers its probe (the same switch as `sk gp restart`, which takes `daemon` and `web` too). With no role, the daemon, then the web. Exit 0 once each is up on a new pid, 1 when pm does not answer, the role crashed, or it kept its old pid. pm itself restarts with `sk pm install`',
179
+ examples: [
180
+ ['the daemon reads every store and repo again', 'sk pm restart daemon'],
181
+ ['the daemon and the web', 'sk pm restart'],
182
+ ],
183
+ })
184
+
185
+ role = Option.String({ required: false, name: 'daemon|web' })
186
+
187
+ async execute(): Promise<number> {
188
+ if (this.role != null && !(ROLES as string[]).includes(this.role)) {
189
+ this.context.stderr.write(`FAIL: '${this.role}' is no pm role: ${ROLES.join(' or ')}; a global process restarts with \`sk gp restart <id>\`\n`)
190
+ return 2
191
+ }
192
+ const deps = pmSwitchDeps(io(this).print)
193
+ for (const role of this.role == null ? ROLES : [this.role]) {
194
+ const code = await switchProcess(role, 'restart', deps)
195
+ if (code !== 0) return code
196
+ }
197
+ return 0
161
198
  }
162
199
  }
163
200
 
@@ -0,0 +1,155 @@
1
+ // sk messages: the repo's messages store (messages/, wiki tools/shipkit/messages.md): its lint through the repo's own
2
+ // guard, a run's blind sheets, a sub-agent's brief, a run's matrix, a surface run's table. Every module loads inside
3
+ // execute: the cli registers this file on every `sk` call
4
+ import { Command, Option } from 'clipanion'
5
+
6
+ type Ctx = { stdout: NodeJS.WritableStream; stderr: NodeJS.WritableStream }
7
+ type Store = import('../messages/model.ts').Store
8
+
9
+ /** the store of the repo the command runs in, and its root */
10
+ async function run(context: Ctx, verb: string, body: (s: Store, root: string, out: (l: string) => void) => Promise<number>): Promise<number> {
11
+ const out = (l: string): void => void context.stdout.write(`${l}\n`)
12
+ try {
13
+ const { findRepoRoot } = await import('../ts/config.ts')
14
+ const { readStore } = await import('../messages/model.ts')
15
+ const root = findRepoRoot(process.cwd())
16
+ return await body(readStore(root), root, out)
17
+ } catch (e) {
18
+ context.stderr.write(`FAIL: messages ${verb}: ${e instanceof Error ? e.message : String(e)}\n`)
19
+ return 1
20
+ }
21
+ }
22
+
23
+ /** every problem of the store: its phrasings and its surfaces, each public text through the repo's guard */
24
+ async function problemsOf(s: Store, root: string): Promise<string[]> {
25
+ const { loadSocialUnit, guardWith } = await import('../social/unit.ts')
26
+ const { lint, lintSurfaces } = await import('../messages/model.ts')
27
+ const unit = await loadSocialUnit(root)
28
+ const guard = (i: { texts?: readonly string[]; shows?: readonly string[] }): string[] => guardWith(unit, i)
29
+ return [...lint(s.messages, guard), ...lintSurfaces(s.surfaces, guard)]
30
+ }
31
+
32
+ const runArg = (): string => Option.String({ name: 'run' })
33
+
34
+ export class MessagesLintCommand extends Command {
35
+ static override paths = [['messages'], ['messages', 'lint']]
36
+ static override usage = Command.Usage({
37
+ category: 'Messages',
38
+ description: "the messages store checked: each phrasing and page top through the repo's public guard",
39
+ details:
40
+ "Reads .shipkit/messages/: each message needs a meaning and a value and at least one phrasing, a phrasing id is used once, a surface option fits its budget. Every phrasing and option goes through the repo's public text guard (its social unit's guard, the one a staged post passes), and a surface's shot through what a picture may show. Page: wiki tools/shipkit/messages.md",
41
+ examples: [['the store checked', 'sk messages lint']],
42
+ })
43
+ async execute(): Promise<number> {
44
+ return run(this.context, 'lint', async (s, root, out) => {
45
+ const bad = await problemsOf(s, root)
46
+ if (bad.length) {
47
+ this.context.stderr.write(`messages: ${bad.length} problem(s):\n${bad.map((b) => ` ${b}`).join('\n')}\n`)
48
+ return 1
49
+ }
50
+ out(`messages: ${s.messages.length} messages, ${s.messages.reduce((a, m) => a + m.candidates.length, 0)} phrasings, ${s.personas.length} personas, all clean`)
51
+ return 0
52
+ })
53
+ }
54
+ }
55
+
56
+ export class MessagesPacketsCommand extends Command {
57
+ static override paths = [['messages', 'packets']]
58
+ static override usage = Command.Usage({
59
+ category: 'Messages',
60
+ description: "a run's blind sheets: each persona's sets and lines in its own order, no meaning, no source",
61
+ details: 'Writes runs/<run>/packets/<persona>.md and the empty folders the sub-agents write into (readings, verdicts, judged, notes). Refused while the lint finds a problem. Page: wiki tools/shipkit/messages.md, The loop',
62
+ examples: [['a new run', 'sk messages packets 20261108-r10']],
63
+ })
64
+ run = runArg()
65
+ async execute(): Promise<number> {
66
+ return run(this.context, 'packets', async (s, root, out) => {
67
+ const { mkdirSync, writeFileSync } = await import('node:fs')
68
+ const { join } = await import('node:path')
69
+ const { packetOf } = await import('../messages/score.ts')
70
+ const { lint } = await import('../messages/model.ts')
71
+ const { loadSocialUnit, guardWith } = await import('../social/unit.ts')
72
+ const unit = await loadSocialUnit(root)
73
+ const bad = lint(s.messages, (i) => guardWith(unit, i))
74
+ if (bad.length) throw new Error(`lint first:\n${bad.join('\n')}`)
75
+ const dir = join(s.dir, 'runs', this.run, 'packets')
76
+ for (const sub of ['packets', 'readings', 'verdicts', 'judged', 'notes']) mkdirSync(join(s.dir, 'runs', this.run, sub), { recursive: true })
77
+ for (const p of s.personas) writeFileSync(join(dir, `${p.id}.md`), packetOf(p, s.messages, this.run))
78
+ out(`messages: ${s.personas.length} packets in ${dir}`)
79
+ return 0
80
+ })
81
+ }
82
+ }
83
+
84
+ export class MessagesBriefCommand extends Command {
85
+ static override paths = [['messages', 'brief']]
86
+ static override usage = Command.Usage({
87
+ category: 'Messages',
88
+ description: "the prompt a run's sub-agent follows word for word: a reader, the gatekeepers, a judge",
89
+ details:
90
+ "Prints the brief, so a session never holds or retypes a prompt: each sub-agent runs this itself and follows what it prints. Kinds: reader <persona>, gatekeepers, judge <message,...>, surface <surface>:<persona>, surface-gatekeepers <surface>. What the product is comes from the store's brief.md. Page: wiki tools/shipkit/messages.md, The loop",
91
+ examples: [
92
+ ['a reader', 'sk messages brief 20261108-r10 reader tom'],
93
+ ['the judges of three messages', 'sk messages brief 20261108-r10 judge weight,touch,dress'],
94
+ ],
95
+ })
96
+ run = runArg()
97
+ kind = Option.String({ name: 'kind' })
98
+ who = Option.String({ name: 'who', required: false })
99
+ async execute(): Promise<number> {
100
+ return run(this.context, 'brief', async (s, _root, out) => {
101
+ const { briefOf } = await import('../messages/brief.ts')
102
+ out(briefOf(s, this.kind, this.run, this.who ?? ''))
103
+ return 0
104
+ })
105
+ }
106
+ }
107
+
108
+ export class MessagesMatrixCommand extends Command {
109
+ static override paths = [['messages', 'matrix']]
110
+ static override usage = Command.Usage({
111
+ category: 'Messages',
112
+ description: "a run's readings scored into its matrix.md: best per reader, value for its cost, every line",
113
+ details: 'A cell is 0 to 100: understood 40 %, the value landed 30 %, appeal 20 %, belief 10 %; a gatekeeper that refuses is a veto. The value for its cost ranks each message by its best score a second spoken. Page: wiki tools/shipkit/messages.md, The loop',
114
+ examples: [['a run scored', 'sk messages matrix 20261108-r5']],
115
+ })
116
+ run = runArg()
117
+ async execute(): Promise<number> {
118
+ return run(this.context, 'matrix', async (s, _root, out) => {
119
+ const { existsSync, writeFileSync } = await import('node:fs')
120
+ const { join } = await import('node:path')
121
+ const { matrix } = await import('../messages/score.ts')
122
+ const dir = join(s.dir, 'runs', this.run)
123
+ if (!existsSync(dir)) throw new Error(`no run ${this.run} in ${join(s.dir, 'runs')}`)
124
+ writeFileSync(join(dir, 'matrix.md'), matrix(s.messages, s.personas, dir))
125
+ out(`messages: ${join(dir, 'matrix.md')}`)
126
+ return 0
127
+ })
128
+ }
129
+ }
130
+
131
+ export class MessagesSurfaceCommand extends Command {
132
+ static override paths = [['messages', 'surface']]
133
+ static override usage = Command.Usage({
134
+ category: 'Messages',
135
+ description: "a surface run's options ranked into its surface.md: the headline alone, the whole, the takeaways",
136
+ details: "The headline alone 30 % (a link preview shows only it), the whole 30 %, the store's takeaways (brief.md) the other 40 %, minus 10 for each reader who saw a repeat; a gatekeeper's refusal vetoes an option. Page: wiki tools/shipkit/messages.md, The loop",
137
+ examples: [['a page top run', 'sk messages surface 20261108-r6']],
138
+ })
139
+ run = runArg()
140
+ async execute(): Promise<number> {
141
+ return run(this.context, 'surface', async (s, _root, out) => {
142
+ const { existsSync, writeFileSync } = await import('node:fs')
143
+ const { join } = await import('node:path')
144
+ const { surfaceTable } = await import('../messages/score.ts')
145
+ const dir = join(s.dir, 'runs', this.run)
146
+ if (!existsSync(dir)) throw new Error(`no run ${this.run} in ${join(s.dir, 'runs')}`)
147
+ const table = surfaceTable(dir, s.brief.takeaways)
148
+ writeFileSync(join(dir, 'surface.md'), `# Surface run: ${this.run}\n\n${table}\n`)
149
+ out(table)
150
+ return 0
151
+ })
152
+ }
153
+ }
154
+
155
+ export const MESSAGES_COMMANDS = [MessagesLintCommand, MessagesPacketsCommand, MessagesBriefCommand, MessagesMatrixCommand, MessagesSurfaceCommand]
@@ -41,3 +41,51 @@ export class ReleasesCommand extends Command {
41
41
  }
42
42
  }
43
43
  }
44
+
45
+ export class ReleasesAddCommand extends Command {
46
+ static override paths = [['releases', 'add']]
47
+
48
+ static override usage = Command.Usage({
49
+ category: 'Gate',
50
+ description: 'a change of .shipkit/releases/next.md by hand: its line, text, picture, bullets',
51
+ details:
52
+ "one change of the release being filled. With --card, the card's changelog line and after picture (what his approval adds, run again by hand when it failed); a category and a title given beside it win. A change of the same card, else of the same title, is replaced, its description, bullets and picture kept unless given. A picture goes to the Space private; `sk bump` makes it public. The repo's guard reads every word first. Committed by pathspec",
53
+ examples: [
54
+ ['the change of an approved card, again', 'sk releases add --card 20261108-115317-move-her'],
55
+ ['a change by hand', 'sk releases add Studio "Move the body anywhere on the floor" --text "Drag the ring at the feet." --bullet "double tap: back to the middle" --image shot.webp'],
56
+ ['the next release is a minor one', 'sk releases add --kind minor'],
57
+ ],
58
+ })
59
+
60
+ category = Option.String({ required: false })
61
+ title = Option.String({ required: false })
62
+ text = Option.String('--text', { description: 'its description, markdown' })
63
+ bullets = Option.Array('--bullet', { description: 'a bullet under it (repeat it)' })
64
+ image = Option.String('--image', { description: 'its picture: a png, jpg, webp or a clip' })
65
+ card = Option.String('--card', { description: 'the review card it comes from: its line and after picture' })
66
+ commit = Option.String('--commit', { description: 'the commit it ships' })
67
+ kind = Option.String('--kind', { description: 'what kind of release next is: major, minor or patch' })
68
+ heading = Option.String('--release-title', { description: "the release's own title, its # heading" })
69
+
70
+ async execute(): Promise<number> {
71
+ try {
72
+ const { addByHand } = await import('../releases/add.ts')
73
+ const file = await addByHand(process.cwd(), {
74
+ ...(this.category !== undefined ? { category: this.category } : {}),
75
+ ...(this.title !== undefined ? { title: this.title } : {}),
76
+ ...(this.text !== undefined ? { text: this.text } : {}),
77
+ ...(this.bullets !== undefined ? { bullets: this.bullets } : {}),
78
+ ...(this.image !== undefined ? { image: this.image } : {}),
79
+ ...(this.card !== undefined ? { card: this.card } : {}),
80
+ ...(this.commit !== undefined ? { commit: this.commit } : {}),
81
+ ...(this.kind !== undefined ? { kind: this.kind } : {}),
82
+ ...(this.heading !== undefined ? { heading: this.heading } : {}),
83
+ })
84
+ this.context.stdout.write(`ok: ${file}\n`)
85
+ return 0
86
+ } catch (e) {
87
+ this.context.stderr.write(`FAIL: ${e instanceof Error ? e.message : String(e)}\n`)
88
+ return 1
89
+ }
90
+ }
91
+ }
@@ -155,14 +155,21 @@ function flagsOf(args: readonly string[], values: readonly string[], repeat: rea
155
155
  const ADD_FLAGS = `flags:
156
156
  --title "<title>" one short line: what he looks at
157
157
  --what "<what>" what changed and why, short markdown: one line, then - bullets
158
- --image <a.png> the subject; a clip (webm, mp4) goes anywhere an image goes
158
+ --post "<line>" the public line for a post of it, what a user gets (the repo's guard reads it)
159
+ --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)
160
+ --image <a.png> the subject; a clip (webm, mp4) goes anywhere an image goes
159
161
  --video <clip.mp4> a clip
160
162
  --audio <sound.wav> a sound: a waveform and a player (wav, mp3, flac, ogg, opus, m4a)
161
163
  --before <a.png> --after <b.png> a before and after: two images, two clips of one size, or two sounds
162
164
  --label "<label>" the first view's label
163
165
  --view "<label>" <a.png> [<b.png>] another view of the same subject (repeat it); --note "<text>" right after it: a line on that view
164
166
  --choice every view is an option he scores and picks one of (two --view or more)
167
+ --pick <view> with --choice: the option you suggest, by its letter (B) or its label; the hub pills it « my pick » (later: sk review pick <id> <view>)
165
168
  --gallery "<label>" <a.png> … a grid he rates tile by tile (stars, OK, fix or no, a word), alone or beside other views; a tile is "[<row>/]<label>=[<before>,]<after>": a redraw carries its before, a row holds one asset's variants
169
+ --trailer <cut.trailer> a trailer cut, played in the card by the trailer entry's player, never a compiled clip; his notes land on its shots
170
+ --version v<n> with --trailer: a kept version of that cut, else the cut's own render
171
+ --before v<m> | <cut> with --trailer: the render he switches to on the same shot
172
+ --shots <a,b> with --trailer: the shots the change touched (else, with --before, the shots whose block differs)
166
173
  --topic <topic> what part of the project it is about (sk review topics)
167
174
  --subject <kind> what is judged (default shot; the repo's unit names its kinds)
168
175
  --commit <sha> the commit it shows
@@ -185,6 +192,33 @@ async function helpWithUnit(context: Ctx, usage: string, kinds: boolean): Promis
185
192
  return 0
186
193
  }
187
194
 
195
+ /** --trailer and its flags as a card: its cut, pinned renders and shots, the image it keeps (a still cut into a temp
196
+ * folder `drop` removes); null without --trailer, which then refuses its own flags */
197
+ export async function trailerOfFlags(o: Record<string, string>, others: boolean): Promise<{ card: import('../review/model.ts').TrailerCard; image: string; drop: () => void } | null> {
198
+ if (o.trailer === undefined) {
199
+ for (const k of ['version', 'shots']) if (o[k] !== undefined) throw new Error(`--${k}: only with --trailer <cut.trailer>`)
200
+ return null
201
+ }
202
+ const clash = ['image', 'video', 'audio', 'after', 'live'].filter((k) => o[k] !== undefined)
203
+ if (clash.length > 0 || others) throw new Error(`--trailer: the card plays the cut; no ${clash.length > 0 ? clash.map((k) => `--${k}`).join(', ') : '--view, --gallery, --choice or --wip'} beside it`)
204
+ const { mkdtempSync, rmSync } = await import('node:fs')
205
+ const { tmpdir } = await import('node:os')
206
+ const { join } = await import('node:path')
207
+ const { findRepoRoot } = await import('../ts/config.ts')
208
+ const { trailerCardOf } = await import('../review/trailer-card.ts')
209
+ const tmp = mkdtempSync(join(tmpdir(), 'trailer-card-'))
210
+ const drop = (): void => rmSync(tmp, { recursive: true, force: true })
211
+ try {
212
+ const shots = o.shots?.split(',').map((s) => s.trim()).filter((s) => s !== '')
213
+ const input = { file: o.trailer, ...(o.version ? { version: o.version } : {}), ...(o.before ? { before: o.before } : {}), ...(shots ? { shots } : {}) }
214
+ const r = await trailerCardOf(findRepoRoot(process.cwd()), process.cwd(), input, join(tmp, 'still.png'))
215
+ return { ...r, drop }
216
+ } catch (e) {
217
+ drop()
218
+ throw e
219
+ }
220
+ }
221
+
188
222
  export class ReviewAddCommand extends Command {
189
223
  static override paths = [['review', 'add']]
190
224
  static override usage = Command.Usage({
@@ -195,8 +229,9 @@ export class ReviewAddCommand extends Command {
195
229
  ['one image', 'sk review add --title "the new menu" --what "the menu, bigger" --image shots/menu.png'],
196
230
  ['a before and after', 'sk review add --title "lamps lit" --what "..." --before a.png --after b.png'],
197
231
  ['a second version after his answer', 'sk review add --title "lamps lit" --what "..." --image c.png --supersedes <id>'],
198
- ['a pick among three voices', 'sk review add --choice --title "the narrator" --what "..." --view "voice 0" a.flac --note "low, breathy" --view "voice 1" b.flac --view "voice 2" c.flac'],
232
+ ['a pick among three voices, yours on the second', 'sk review add --choice --pick B --title "the narrator" --what "..." --view "voice 0" a.flac --note "low, breathy" --view "voice 1" b.flac --view "voice 2" c.flac'],
199
233
  ['icons he rates one by one', 'sk review add --title "buff icons" --what "..." --gallery "icons" vitality=a.png haste=b.png greed=c.png'],
234
+ ['a trailer cut against its last kept version', 'sk review add --trailer trailer/demo/main.trailer --version v4 --before v3 --title "the drop, recut" --what "..."'],
200
235
  ],
201
236
  })
202
237
  args = Option.Proxy()
@@ -212,9 +247,10 @@ export class ReviewAddCommand extends Command {
212
247
  const kindName = rest[rest.indexOf('--subject') + 1]
213
248
  const kind = rest.includes('--subject') && kindName ? h.unit?.kinds?.[kindName] : undefined
214
249
  const own = [...Object.keys(kind?.flags ?? {}), ...Object.keys(h.unit?.flags ?? {})]
215
- const f = flagsOf(rest, ['title', 'what', 'image', 'video', 'audio', 'before', 'after', 'label', 'topic', 'subject', 'commit', 'lane', 'supersedes', 'keeps', 'why', 'live'], ['answers', ...own], ['new', 'wip', 'choice'])
250
+ const f = flagsOf(rest, ['title', 'what', 'post', 'changelog', 'image', 'video', 'audio', 'before', 'after', 'label', 'topic', 'subject', 'commit', 'lane', 'supersedes', 'keeps', 'why', 'live', 'trailer', 'version', 'shots', 'pick'], ['answers', ...own], ['new', 'wip', 'choice'])
216
251
  if (f.positionals.length > 0) throw new Error(`unexpected ${f.positionals.join(' ')}`)
217
252
  const o = f.one
253
+ const trailer = await trailerOfFlags(o, views.length > 0 || f.on.has('wip') || f.on.has('choice'))
218
254
  const repoFlags = Object.fromEntries(own.flatMap((k) => (f.many[k] ? [[k, f.many[k]]] : [])))
219
255
  const parsed = kind?.parse ? kind.parse(Object.fromEntries(Object.keys(kind.flags ?? {}).map((k) => [k, f.many[k] ?? []]))) : null
220
256
  if (f.on.has('wip') !== (o.live !== undefined)) throw new Error('--wip --live <name>: a draft card names its live shot, and a live shot makes a draft card')
@@ -226,16 +262,40 @@ export class ReviewAddCommand extends Command {
226
262
  wipViews = [{ label: '', image: fr.image }, ...(fr.history.length > 0 ? [{ label: 'history', gallery: fr.history }] : [])]
227
263
  }
228
264
  const answers = await Promise.all((f.many.answers ?? []).map((a) => idOf(h.dir, a)))
265
+ if (o.post !== undefined) {
266
+ // a public line: the repo's guard reads it before the card holds it
267
+ const { dirname } = await import('node:path')
268
+ const { loadSocialUnit } = await import('../social/unit.ts')
269
+ const unit = await loadSocialUnit(dirname(dirname(h.dir)))
270
+ const problems = unit?.guard ? [...unit.guard({ title: '', alt: '', texts: [o.post], files: [] })] : []
271
+ if (problems.length > 0) throw new Error(`--post: the repo's guard refuses it: ${problems.join('; ')}`)
272
+ }
273
+ let changelog: import('../review/model.ts').CardChangelog | undefined
274
+ if (o.changelog !== undefined) {
275
+ // its category and line are public words: the repo's guard reads them before the card holds them
276
+ const { dirname } = await import('node:path')
277
+ const { changelogOfFlag } = await import('../review/model.ts')
278
+ const { publicProblems } = await import('../social/unit.ts')
279
+ const { undeclaredReleases } = await import('../releases/store.ts')
280
+ changelog = changelogOfFlag(o.changelog)
281
+ const why = await undeclaredReleases(dirname(dirname(h.dir)))
282
+ if (why) throw new Error(`--changelog: ${why}`)
283
+ const problems = await publicProblems(dirname(dirname(h.dir)), { texts: [changelog.category, changelog.line] })
284
+ if (problems.length > 0) throw new Error(`--changelog: the repo's guard refuses it: ${problems.join('; ')}`)
285
+ }
229
286
  const topic = o.topic ?? parsed?.topic
230
287
  let input: import('../review/store.ts').AddInput = {
231
288
  title: o.title ?? '',
232
289
  what: o.what ?? '',
233
- ...(parsed ? { subject: parsed.subject } : o.subject ? { subject: { kind: o.subject } } : {}),
290
+ ...(o.post ? { post: o.post } : {}),
291
+ ...(changelog ? { changelog } : {}),
292
+ ...(parsed ? { subject: parsed.subject } : o.subject ? { subject: { kind: o.subject } } : trailer ? { subject: { kind: 'trailer' } } : {}),
234
293
  ...(topic ? { topic } : {}),
294
+ ...(trailer ? { image: trailer.image, trailer: trailer.card } : {}),
235
295
  ...(o.image ? { image: o.image } : {}),
236
296
  ...(o.video ? { video: o.video } : {}),
237
297
  ...(o.audio ? { audio: o.audio } : {}),
238
- ...(o.before ? { before: o.before } : {}),
298
+ ...(o.before && !trailer ? { before: o.before } : {}),
239
299
  ...(o.after ? { after: o.after } : {}),
240
300
  ...(o.label ? { label: o.label } : {}),
241
301
  ...(o.commit ? { commit: o.commit } : {}),
@@ -246,12 +306,15 @@ export class ReviewAddCommand extends Command {
246
306
  ...(answers.length > 0 ? { answers } : {}),
247
307
  ...(f.on.has('new') ? { fresh: true } : {}),
248
308
  ...(f.on.has('choice') ? { choice: true } : {}),
309
+ ...(o.pick !== undefined ? { agentPick: o.pick } : {}),
249
310
  ...(o.live !== undefined ? { image: wipViews[0]?.image ?? '', views: wipViews.slice(1), wip: { live: o.live } } : { views }),
250
311
  }
251
312
  if (h.unit?.add) input = await h.unit.add(input, repoFlags)
252
- const item = await addItem(h.dir, input)
313
+ const item = await addItem(h.dir, input).finally(() => trailer?.drop())
253
314
  h.out(item.id)
315
+ if (item.trailer) h.out(`trailer card: ${item.trailer.trailer}/${item.trailer.after.cut}${item.trailer.before ? ` against ${item.trailer.before.cut}` : ''}${item.trailer.shots.length > 0 ? `, shots ${item.trailer.shots.join(', ')}` : ''}`)
254
316
  if (item.origin.by === 'agent' && !item.origin.lane) h.err('no lane on the card: pass --lane <id> (or SK_AGENT), so the hub colours it')
317
+ if (item.choice && item.agentPick === undefined) h.err(`a choice with no pick of yours: every question carries one, sk review pick ${item.id} <view> (or --pick on add)`)
255
318
  const { unheardLine } = await import('../review/model.ts')
256
319
  const { liveWatchers } = await import('../review/watchers.ts')
257
320
  const unheard = unheardLine(item, liveWatchers(h.dir))
@@ -553,6 +616,29 @@ export class ReviewReopenCommand extends Command {
553
616
  }
554
617
  }
555
618
 
619
+ export class ReviewPickCommand extends Command {
620
+ static override paths = [['review', 'pick']]
621
+ static override usage = Command.Usage({
622
+ category: 'Review',
623
+ description: "the option you suggest on a choice card he has not answered: the hub's « my pick » pill on it",
624
+ details: `${DETAILS}\n\nsk review pick <id> <view>: the view by its letter (B) or its label; one pick a card, a new one replaces it. On add: --choice … --pick <view>.`,
625
+ examples: [['suggest the second option', 'sk review pick <id> B'], ['by its label', 'sk review pick <id> "Zen Garden"']],
626
+ })
627
+ id = Option.String({ required: true })
628
+ view = Option.String({ required: true })
629
+
630
+ async execute(): Promise<number> {
631
+ return run(this.context, async (h) => {
632
+ const { setAgentPick } = await import('../review/store.ts')
633
+ const { viewLetter, viewName } = await import('../review/model.ts')
634
+ const item = setAgentPick(h.dir, this.id, this.view)
635
+ const n = item.agentPick ?? 0
636
+ h.out(`${this.id}: my pick ${viewLetter(n)} "${viewName(item.views[n], n)}"`)
637
+ return 0
638
+ })
639
+ }
640
+ }
641
+
556
642
  type ActOp = 'fixed' | 'wontfix' | 'claim' | 'release' | 'blocked' | 'done' | 'dispatch' | 'ask' | 'drop' | 'reassign'
557
643
 
558
644
  /** one state change: by a worker on its claim, or by the dispatcher on what it routes; the item, then the new state */
@@ -847,6 +933,73 @@ export class ReviewAnimCommand extends Command {
847
933
  }
848
934
  }
849
935
 
936
+ export class ReviewStageCommand extends Command {
937
+ static override paths = [['review', 'stage']]
938
+ static override usage = Command.Usage({
939
+ category: 'Review',
940
+ description: "one media of a card staged as a post: a draft in .shipkit/social/drafts/, never posted",
941
+ details: `${DETAILS}\n\nThe media copied in with its metadata left out, the repo's guard run first, the draft committed by its paths. Without --view, the newest version's first media. --dry prints what the draft would be: each account, its place, its count, what it skips. It never publishes: Publish stays his, in Communications. Page: wiki tools/shipkit/review-raised-items.md, A post staged from a card`,
942
+ examples: [
943
+ ['the first media, a safe post', 'sk review stage <id> --text "Hands now pinch and lift." --rating safe'],
944
+ ["the second view's wipe, polished by an agent", 'sk review stage <id> --view B --side wipe --text "…" --rating mild --polish'],
945
+ ['what it would be', 'sk review stage <id> --text "…" --rating safe --dry'],
946
+ ],
947
+ })
948
+ id = Option.String({ required: true })
949
+ view = Option.String('--view', { description: 'the view by its letter (A, B…) of the newest version, or <n>.<letter> of an older one' })
950
+ side = Option.String('--side', { description: 'a pair: after (default), before or wipe' })
951
+ tile = Option.String('--tile', { description: 'a gallery: the tile by its label' })
952
+ text = Option.String('--text', { required: true, description: 'the post' })
953
+ rating = Option.String('--rating', { required: true, description: 'safe, mild or explicit' })
954
+ kind = Option.String('--kind', { description: 'what the post is for, a kind of the set or the unit (default feature)' })
955
+ kindWhy = Option.String('--kind-why', { description: 'with --kind custom: one line on why no kind fits' })
956
+ alt = Option.String('--alt', { description: 'what the media shows' })
957
+ slot = Option.String('--slot', { description: '<YYYY-MM-DD> <tag>, a slot of the rhythm' })
958
+ tags = Option.String('--tags', { description: '#a #b' })
959
+ polish = Option.Boolean('--polish', false, { description: "an agent rewrites it in the identity's voice" })
960
+ from = Option.String('--from', { description: "a clip's passage: its in, in seconds" })
961
+ to = Option.String('--to', { description: "a clip's passage: its out, in seconds" })
962
+ fit = Option.Boolean('--fit', false, { description: 'one copy within the tightest limits of the venues it reaches' })
963
+ dry = Option.Boolean('--dry', false, { description: 'write nothing: print the draft as it would load' })
964
+
965
+ async execute(): Promise<number> {
966
+ return run(this.context, async (h) => {
967
+ const { dirname, join } = await import('node:path')
968
+ const { isPostRating, POST_RATINGS } = await import('../identities/rating.ts')
969
+ const { stageInputOf, stageOfCard } = await import('../review/stage-card.ts')
970
+ const { askPolish, fitStage, stageDraft, stageDry } = await import('../social/stage.ts')
971
+ const { loadSocialUnit } = await import('../social/unit.ts')
972
+ if (!isPostRating(this.rating)) throw new Error(`--rating ${this.rating}: one of ${POST_RATINGS.join(', ')}`)
973
+ const root = dirname(dirname(h.dir))
974
+ const id = await idOf(h.dir, this.id)
975
+ const s = stageOfCard(h.dir, id)
976
+ let pick: string | undefined
977
+ if (this.view) {
978
+ const m = /^(?:(\d+)\.)?([A-Z]+)$/i.exec(this.view)
979
+ if (m == null) throw new Error(`--view ${this.view}: a letter, or <n>.<letter>`)
980
+ const tag = `${m[1] ?? Math.max(...s.media.map((x) => Number(x.label.split('.')[0])))}.${m[2]!.toUpperCase()}`
981
+ const of = s.media.filter((x) => x.label.startsWith(`${tag} `))
982
+ const tile = this.tile
983
+ const hit = tile ? of.find((x) => x.tile !== undefined && (x.label.endsWith(`/${tile}`) || x.label.endsWith(` ${tile}`))) : of.find((x) => (x.side ?? 'after') === (this.side ?? 'after'))
984
+ if (hit == null) throw new Error(`no media ${tag}${this.side ? ` ${this.side}` : ''}${this.tile ? ` tile ${this.tile}` : ''}: ${s.media.map((x) => x.label).join(', ')}`)
985
+ pick = hit.key
986
+ }
987
+ const font = h.unit?.anim?.font ? join(root, h.unit.anim.font) : undefined
988
+ if ((this.from === undefined) !== (this.to === undefined)) throw new Error('a passage takes --from and --to')
989
+ const passage = this.from !== undefined && this.to !== undefined ? { from: Number(this.from), to: Number(this.to) } : null
990
+ const { input } = await stageInputOf(h.dir, id, { ...(pick ? { pick } : {}), text: this.text, rating: this.rating, ...(this.kind ? { kind: this.kind } : {}), ...(this.kindWhy ? { kindWhy: this.kindWhy } : {}), ...(this.alt ? { alt: this.alt } : {}), ...(this.slot ? { slot: this.slot } : {}), ...(this.tags ? { tags: this.tags } : {}), ...(passage ? { passage } : {}) }, font)
991
+ const unit = await loadSocialUnit(root)
992
+ const r = this.dry ? await stageDry(root, input, { unit }) : await stageDraft(root, this.fit ? await fitStage(root, input, { unit }) : input, { unit })
993
+ h.out(`${this.dry ? 'would stage' : 'staged'} ${r.slug}${input.media ? `: ${input.media.name}` : ''}, ${input.rating}`)
994
+ for (const p of r.draft?.posts ?? []) h.out(` ${p.key}${p.place ? ` #${p.place}` : ''} ${p.length}${p.refused ? ` refused: ${p.refused}` : ''}`)
995
+ for (const k of r.draft?.skipped ?? []) h.out(` ${k.account} skipped: ${k.why}`)
996
+ for (const e of r.errors) h.err(`WARN ${e}`)
997
+ if (this.polish && !this.dry) h.out(`polish asked: ${(await askPolish(root, r.slug, input.title, unit)).id}`)
998
+ return 0
999
+ })
1000
+ }
1001
+ }
1002
+
850
1003
  export class ReviewAutoCommand extends Command {
851
1004
  static override paths = [['review', 'auto']]
852
1005
  static override usage = Command.Usage({
@@ -1000,6 +1153,7 @@ export const REVIEW_COMMANDS = [
1000
1153
  ReviewReplyCommand,
1001
1154
  ReviewWithdrawCommand,
1002
1155
  ReviewReopenCommand,
1156
+ ReviewPickCommand,
1003
1157
  ReviewFixedCommand,
1004
1158
  ReviewWontfixCommand,
1005
1159
  ReviewClaimCommand,
@@ -1018,6 +1172,7 @@ export const REVIEW_COMMANDS = [
1018
1172
  ReviewDeleteCommand,
1019
1173
  ReviewMarksCommand,
1020
1174
  ReviewAnimCommand,
1175
+ ReviewStageCommand,
1021
1176
  ReviewAutoCommand,
1022
1177
  ReviewWatchCommand,
1023
1178
  ]
@@ -1,43 +1,17 @@
1
1
  // shipkit secret — the secrets of the repo you stand in, and the reads and
2
2
  // writes through the house's secret manager (`credsReadCommand`, `credsCommand`).
3
- // Logic in secrets/list.ts. A value only ever goes to stdout of `get`/`account`.
3
+ // Logic in secrets/list.ts and secrets/manager.ts. A value only ever goes to stdout of `get`/`account`.
4
4
  import { Command, Option } from 'clipanion'
5
- import { existsSync } from 'fs'
6
- import { basename, join } from 'path'
7
- import { gitRoot } from '../core/git-root.ts'
8
- import { houseRootOf } from '../home/home-start.ts'
9
- import { loadIdentities, speakerOf } from '../identities/identities.ts'
10
- import { loadRepoConfig, type RepoConfig } from '../repo-config.ts'
11
5
  import { presence, secretsFor } from '../secrets/list.ts'
6
+ import { managerTemplate as template, NoManager, secretsWhere as where, storeArgv } from '../secrets/manager.ts'
12
7
  import { secretArgv } from '../smoke/run-smoke.ts'
13
8
 
14
- type Where = { repos: string[]; identity: string | null; own: RepoConfig | null; house: RepoConfig | null }
15
-
16
- async function where(cwd: string): Promise<Where> {
17
- const root = gitRoot(cwd)?.top ?? cwd
18
- const own = existsSync(join(root, 'repo.config.ts')) ? await loadRepoConfig(root) : null
19
- const houseRoot = houseRootOf(cwd)
20
- const house = houseRoot == null ? null : houseRoot === root ? own : await loadRepoConfig(houseRoot).catch(() => null)
21
- const identity = speakerOf(own?.speaksAs, await loadIdentities({ cwd }))?.id ?? null
22
- return { repos: [...new Set([own?.name ?? basename(root), basename(root)])], identity, own, house }
23
- }
24
-
25
- /** a refusal the command prints as one line and exits 1 on, never a stack */
26
- class Refused extends Error {}
27
-
28
- const template = (w: Where, key: 'credsReadCommand' | 'credsCommand'): string => {
29
- const t = w.own?.[key] ?? w.house?.[key]
30
- if (w.own == null && w.house == null) throw new Refused('FAIL not inside a house repo: run it from a repo that loads the house wiki')
31
- if (t == null || t.trim() === '') throw new Refused(`FAIL no ${key} in this repo's repo.config.ts nor the house's: nothing knows how to reach the secret manager`)
32
- return t
33
- }
34
-
35
9
  /** runs a verb, printing a refusal as its one line */
36
10
  async function refusing(stderr: NodeJS.WritableStream, run: () => Promise<number>): Promise<number> {
37
11
  try {
38
12
  return await run()
39
13
  } catch (e) {
40
- if (!(e instanceof Refused)) throw e
14
+ if (!(e instanceof NoManager)) throw e
41
15
  stderr.write(`${e.message}\n`)
42
16
  return 1
43
17
  }
@@ -120,7 +94,7 @@ export class SecretSetCommand extends Command {
120
94
 
121
95
  async execute(): Promise<number> {
122
96
  return refusing(this.context.stderr, async () => {
123
- const argv = [...template(await where(process.cwd()), 'credsCommand').trim().split(/\s+/).map((x) => x.replaceAll('{name}', this.name)), ...(this.account != null ? [this.account] : [])]
97
+ const argv = storeArgv(template(await where(process.cwd()), 'credsCommand'), this.name, this.account)
124
98
  return Bun.spawnSync(argv, { stdin: 'inherit', stdout: 'inherit', stderr: 'inherit' }).exitCode ?? 1
125
99
  })
126
100
  }
@@ -1,4 +1,4 @@
1
- // sk shot: a png of any url, or a clip with --video, through the machine's
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
4
  import { relative } from 'path'
@@ -22,11 +22,11 @@ export class ShotCommand extends Command {
22
22
 
23
23
  static override usage = Command.Usage({
24
24
  category: 'Serve',
25
- description: 'a png of any url through the warm browser, or an mp4 clip with --video',
25
+ description: 'a webp of any url through the warm browser (a png with --out x.png), or an mp4 clip with --video',
26
26
  details:
27
27
  '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',
28
28
  examples: [
29
- ['a png of a running dev server', 'sk shot localhost:5173/'],
29
+ ['a still of a running dev server', 'sk shot localhost:5173/'],
30
30
  ['a phone screen, at the pixel ratio of a phone', 'sk shot :5173/play --viewport 390,844 --dpr 3 --out shots/phone.png'],
31
31
  ['a 3 s clip', 'sk shot :4808/ --video 3 --out clips/walk.mp4'],
32
32
  ['a clip of a whole web app page, canvas or not', 'sk shot :5173/settings --video 3 --dom'],
@@ -37,7 +37,7 @@ export class ShotCommand extends Command {
37
37
  url = Option.String({ required: true, name: 'url' })
38
38
  viewport = Option.String('--viewport', { description: 'w,h in css pixels (default 1280,720)' })
39
39
  dpr = Option.String('--dpr', { description: 'device pixel ratio (default 1)' })
40
- out = Option.String('--out', { description: 'the file (default .shipkit/tmp/shots/<url>.png, or .mp4 with --video)' })
40
+ 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' })
41
41
  reload = Option.Boolean('--reload', false, { description: 'load the page again even when the warm page shows this url' })
42
42
  wait = Option.String('--wait', { description: 'ms after load for a page with no ready mark (default 300)' })
43
43
  video = Option.String('--video', { description: 'seconds of clip: an mp4 of the page (its canvas when a canvas fills it)' })