rvlib-shipkit 2.19.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 (158) hide show
  1. package/CHANGELOG.md +16 -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/checks/SK040-release-words.check.ts +43 -0
  6. package/src/checks/SK041-annex-links.check.ts +28 -0
  7. package/src/checks/SK042-post-kinds.check.ts +73 -0
  8. package/src/cli/cmd_Annex.ts +179 -0
  9. package/src/cli/cmd_Commands.ts +4 -1
  10. package/src/cli/cmd_Home.ts +3 -2
  11. package/src/cli/cmd_Messages.ts +155 -0
  12. package/src/cli/cmd_Releases.ts +48 -0
  13. package/src/cli/cmd_Review.ts +161 -6
  14. package/src/cli/cmd_Shot.ts +4 -4
  15. package/src/cli/cmd_Social.ts +143 -6
  16. package/src/cli/family-pages.ts +2 -0
  17. package/src/cli/kit/index.ts +1 -1
  18. package/src/cli/kit/verb.ts +11 -3
  19. package/src/cli/registry.ts +6 -1
  20. package/src/collections/collection-types.ts +8 -1
  21. package/src/collections/providers.ts +4 -1
  22. package/src/commands/model.ts +36 -0
  23. package/src/commands/registry.ts +49 -0
  24. package/src/commands/routes.ts +59 -0
  25. package/src/commands/runner.ts +35 -0
  26. package/src/commands/runs.ts +112 -0
  27. package/src/core/app-icon.ts +4 -3
  28. package/src/core/icon-type.ts +8 -0
  29. package/src/core/jobs.ts +4 -3
  30. package/src/core/layout.ts +5 -2
  31. package/src/core/squircle.ts +95 -0
  32. package/src/home/daemon-jobs.ts +26 -2
  33. package/src/home/global-units.ts +3 -0
  34. package/src/home/gui-app/ShipkitGui.swift +302 -5
  35. package/src/home/gui-app.ts +63 -33
  36. package/src/home/hmr-keep.ts +134 -0
  37. package/src/home/home-start.ts +2 -2
  38. package/src/home/lib-watch.ts +21 -11
  39. package/src/home/pm.ts +1 -1
  40. package/src/home/process-apps.ts +181 -0
  41. package/src/home/resources.ts +3 -3
  42. package/src/home/run-web.ts +7 -4
  43. package/src/home/serve-web.ts +64 -14
  44. package/src/identities/collection.ts +49 -0
  45. package/src/identities/identities.ts +110 -8
  46. package/src/identities/machine.ts +4 -3
  47. package/src/identities/rating.ts +33 -0
  48. package/src/identities/shown.ts +170 -0
  49. package/src/identities/steps.ts +5 -0
  50. package/src/media-store/purge.ts +15 -1
  51. package/src/media-store/remote.ts +22 -6
  52. package/src/messages/brief.ts +117 -0
  53. package/src/messages/collection.ts +40 -0
  54. package/src/messages/model.ts +171 -0
  55. package/src/messages/routes.ts +15 -0
  56. package/src/messages/score.ts +180 -0
  57. package/src/messages/tabs.ts +13 -0
  58. package/src/release/notes.ts +130 -0
  59. package/src/release/run-bump.ts +41 -18
  60. package/src/release/run-release.ts +22 -4
  61. package/src/release/run-releases.ts +17 -15
  62. package/src/release/unit-resolve.ts +9 -0
  63. package/src/releases/add.ts +66 -0
  64. package/src/releases/collection.ts +36 -0
  65. package/src/releases/from-card.ts +66 -0
  66. package/src/releases/model.ts +267 -0
  67. package/src/releases/pictures.ts +89 -0
  68. package/src/releases/routes.ts +36 -0
  69. package/src/releases/store.ts +71 -0
  70. package/src/repo-config.ts +5 -0
  71. package/src/review/cells.ts +0 -11
  72. package/src/review/format.ts +10 -6
  73. package/src/review/model.ts +92 -3
  74. package/src/review/notes.ts +2 -48
  75. package/src/review/routes.ts +28 -10
  76. package/src/review/stage-card.ts +197 -0
  77. package/src/review/stage-routes.ts +123 -0
  78. package/src/review/store.ts +36 -0
  79. package/src/review/trailer-card.ts +99 -0
  80. package/src/review/trailer-desk.ts +57 -4
  81. package/src/review/trailer-model.ts +41 -7
  82. package/src/review/trailer-notes.ts +45 -0
  83. package/src/review/trailer-routes.ts +22 -13
  84. package/src/serve/hub-app/app-bridge.ts +71 -0
  85. package/src/serve/hub-app/commands/commands-page.tsx +122 -0
  86. package/src/serve/hub-app/commands/commands-st.ts +177 -0
  87. package/src/serve/hub-app/commands.css +24 -0
  88. package/src/serve/hub-app/hash-route.ts +40 -1
  89. package/src/serve/hub-app/home-st.ts +11 -2
  90. package/src/serve/hub-app/home.html +3 -0
  91. package/src/serve/hub-app/hub-app.tsx +6 -0
  92. package/src/serve/hub-app/icons.tsx +5 -0
  93. package/src/serve/hub-app/identities-view.tsx +4 -1
  94. package/src/serve/hub-app/identities.css +1 -0
  95. package/src/serve/hub-app/index.html +3 -0
  96. package/src/serve/hub-app/keys.ts +2 -2
  97. package/src/serve/hub-app/machine-st.ts +41 -10
  98. package/src/serve/hub-app/messages/messages-page.tsx +354 -0
  99. package/src/serve/hub-app/messages/messages-st.ts +74 -0
  100. package/src/serve/hub-app/messages.css +35 -0
  101. package/src/serve/hub-app/releases/releases-page.tsx +94 -0
  102. package/src/serve/hub-app/releases/releases-st.ts +69 -0
  103. package/src/serve/hub-app/releases.css +25 -0
  104. package/src/serve/hub-app/repo-sections.ts +15 -1
  105. package/src/serve/hub-app/repo-st.ts +56 -5
  106. package/src/serve/hub-app/review/clip-st.ts +31 -3
  107. package/src/serve/hub-app/review/note-place.ts +31 -0
  108. package/src/serve/hub-app/review/review-cells.tsx +27 -3
  109. package/src/serve/hub-app/review/review-st.ts +77 -2
  110. package/src/serve/hub-app/review/review-thread.tsx +9 -31
  111. package/src/serve/hub-app/review/review-views.tsx +164 -58
  112. package/src/serve/hub-app/review/thread-st.ts +108 -41
  113. package/src/serve/hub-app/review/trailer-card.tsx +187 -0
  114. package/src/serve/hub-app/review/trailer-page.tsx +62 -31
  115. package/src/serve/hub-app/review/trailer-st.ts +138 -26
  116. package/src/serve/hub-app/review/trailer-timeline.tsx +39 -26
  117. package/src/serve/hub-app/review.css +49 -6
  118. package/src/serve/hub-app/social/comms-page.tsx +55 -23
  119. package/src/serve/hub-app/social/identity-pictures.ts +46 -8
  120. package/src/serve/hub-app/social/kit.tsx +9 -6
  121. package/src/serve/hub-app/social/post-card.tsx +10 -2
  122. package/src/serve/hub-app/social/social-model.ts +37 -3
  123. package/src/serve/hub-app/social/social-page.tsx +179 -65
  124. package/src/serve/hub-app/social/social-st.ts +79 -26
  125. package/src/serve/hub-app/social/stage-popup.tsx +268 -0
  126. package/src/serve/hub-app/social/stage-st.ts +310 -0
  127. package/src/serve/hub-app/social/step-layout.ts +42 -0
  128. package/src/serve/hub-app/social.css +60 -1
  129. package/src/serve/hub-app/tree-build.ts +38 -1
  130. package/src/serve/hub-app/tree-svc.ts +10 -3
  131. package/src/serve/project-gutter-route.ts +4 -2
  132. package/src/serve/same-origin.ts +24 -1
  133. package/src/serve/serve-hub.ts +15 -1
  134. package/src/shipkit-files.ts +9 -7
  135. package/src/shot/shooter.ts +3 -3
  136. package/src/shot/shot-ask.ts +14 -3
  137. package/src/shot/shot.shipkit.ts +1 -1
  138. package/src/social/discord-layout.ts +48 -5
  139. package/src/social/fit.ts +84 -0
  140. package/src/social/identity-words.ts +74 -0
  141. package/src/social/kind-pages.ts +41 -0
  142. package/src/social/kinds.ts +92 -0
  143. package/src/social/load.ts +105 -9
  144. package/src/social/media-limit.ts +63 -2
  145. package/src/social/presence.ts +1 -1
  146. package/src/social/publish/bluesky.ts +58 -19
  147. package/src/social/publish/index.ts +31 -5
  148. package/src/social/reach.ts +49 -0
  149. package/src/social/release-stage.ts +173 -0
  150. package/src/social/routes.ts +42 -7
  151. package/src/social/stage.ts +227 -0
  152. package/src/social/strip.ts +85 -0
  153. package/src/social/text.ts +6 -2
  154. package/src/social/unit.ts +57 -1
  155. package/src/social/writes.ts +11 -0
  156. package/src/trailer/build.ts +15 -2
  157. package/src/trailer/grammar.ts +14 -4
  158. package/src/trailer/public-words.ts +41 -0
@@ -0,0 +1,73 @@
1
+ // SK042 post kinds (tools/shipkit/built-in-checks-contracts-and-visibility.md): every draft of `.shipkit/social/drafts/`
2
+ // names what it is for, a kind of the closed set or of the social unit's own `kinds` (wiki guides/post-kinds/index.md),
3
+ // through the load's one check, kinds.ts kindProblem. A word of the old words table only warns: each repo moves its own
4
+ // drafts. Keyed on the social folder, the unit file's text and whether each page its text names is a file: kinds a
5
+ // module the unit imports declares keep a stale green until one of those moves
6
+ import { existsSync, readdirSync, readFileSync } from 'node:fs'
7
+ import { join } from 'node:path'
8
+ import { check } from '../check.ts'
9
+ import { LAYOUT } from '../core/layout.ts'
10
+ import { unitFilesDeclaring } from '../core/unit-files.ts'
11
+ import { ownPageMissing } from '../social/kind-pages.ts'
12
+ import { kindOfMeta, kindProblem } from '../social/kinds.ts'
13
+ import { parseFrontmatter } from '../social/md.ts'
14
+ import { loadSocialUnit, type SocialUnit } from '../social/unit.ts'
15
+
16
+ /** a unit file's text, and whether each `.md` path it names is a file: a kind's page deleted asks the question again */
17
+ export function unitKey(root: string, file: string): string {
18
+ const text = readFileSync(file, 'utf8')
19
+ const pages = [...new Set([...text.matchAll(/['"`]([^'"`\s]+\.md)['"`]/g)].map((m) => m[1]!))].map((p) => `${p}:${existsSync(join(root, p))}`)
20
+ return `${file}:${Bun.hash(text)}:${pages.join(',')}`
21
+ }
22
+
23
+ const FIX ='set the kind to one of wiki guides/post-kinds/index.md (a custom one with its kindWhy), or declare the project kind in its social unit, then sk ci --only SK042'
24
+ const FIX_OLD = "move each draft to the kind its intent reads as (wiki guides/post-kinds/index.md, The old words): the repo's own step, never a blind replace"
25
+
26
+ export const postKinds = check({
27
+ id: 'SK042',
28
+ blocking: true,
29
+ title: 'post kinds',
30
+ description: 'every social draft names its kind: one of the closed set or of the social unit',
31
+ owner: 'tools/shipkit/built-in-checks-contracts-and-visibility.md',
32
+ runs: { onPreCommit: false, onCi: true, onFull: true, onRelease: true, onHealth: true, onSave: 'moved', onClock: false },
33
+ // the social folder, the text of the social unit files that declare its own kinds, and each page they name
34
+ cache: { by: 'files', inputs: [LAYOUT.social], key: (env) => unitFilesDeclaring(env.root, 'social').map((f) => unitKey(env.root, f)).join('\n') },
35
+ fix: 'none',
36
+ applies: 'always',
37
+ run: async (c) => {
38
+ const dir = join(c.root, LAYOUT.social, 'drafts')
39
+ const slugs = existsSync(dir) ? readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith('.')).map((e) => e.name).sort() : []
40
+ if (slugs.length === 0) return c.ok(`no draft in ${LAYOUT.social}/drafts/: no kind to read`)
41
+ let unit: SocialUnit | null
42
+ try {
43
+ unit = await loadSocialUnit(c.root)
44
+ } catch (e) {
45
+ return c.fail(`the social unit does not load: ${(e as Error).message}`, 'fix the unit file it names, then sk ci --only SK042')
46
+ }
47
+ const own = unit?.kinds ?? []
48
+ for (const k of own) if (!existsSync(join(c.root, k.page))) c.fail(ownPageMissing(k), `write its rules page, in the shape of a page of wiki guides/post-kinds/`)
49
+ let bad = 0
50
+ let old = 0
51
+ for (const slug of slugs) {
52
+ const rel = `${LAYOUT.social}/drafts/${slug}/draft.md`
53
+ const raw = c.read(rel)
54
+ if (raw == null) continue
55
+ const { meta } = parseFrontmatter(raw)
56
+ const { kind, why } = kindOfMeta(meta)
57
+ const p = kindProblem(kind, why, own)
58
+ if (p == null) continue
59
+ if (p.old) {
60
+ old++
61
+ c.lines.push({ kind: 'warn', text: `${rel}: ${p.text}` })
62
+ } else {
63
+ bad++
64
+ c.lines.push({ kind: 'fail', text: `${rel}: ${p.text}` })
65
+ }
66
+ }
67
+ if (bad > 0) c.fail(`${bad} draft${bad === 1 ? '' : 's'} with no kind of the set`, FIX)
68
+ if (old > 0) c.warn(`${old} draft${old === 1 ? '' : 's'} on an old kind word`, FIX_OLD)
69
+ if (bad === 0 && old === 0 && !c.failed) c.ok(`${slugs.length} draft${slugs.length === 1 ? '' : 's'}, each names its kind`)
70
+ },
71
+ })
72
+
73
+ export default postKinds
@@ -0,0 +1,179 @@
1
+ // sk annex: the machine's external drives for heavy files, never a db (annex/, wiki tools/shipkit/annex.md): where
2
+ // each annex stands, its marker written once, a repo's scratch offloaded behind a symlink and back, the media trimmed
3
+ // to the cap. Every module loads inside execute: the cli registers this file on every `sk` call
4
+ import { Command, Option } from 'clipanion'
5
+
6
+ const DETAILS = `an annex is a folder on an external drive the house config lists (serve.annexes in the house repo config), present only while its root holds the marker sk annex init wrote. A media purge moves each file there before the Mac lets it go, a fetch back reads it before the Space, and sk annex offload moves a repo's .shipkit/cache or .shipkit/tmp folders there behind a symlink. No db, lock, worktree or backed up file ever goes. Page: wiki tools/shipkit/annex.md`
7
+
8
+ type Ctx = { stdout: NodeJS.WritableStream; stderr: NodeJS.WritableStream }
9
+
10
+ async function run(context: Ctx, body: (out: (l: string) => void) => Promise<number>): Promise<number> {
11
+ const out = (l: string): void => void context.stdout.write(`${l}\n`)
12
+ try {
13
+ return await body(out)
14
+ } catch (e) {
15
+ context.stderr.write(`FAIL: annex: ${e instanceof Error ? e.message : String(e)}\n`)
16
+ return 1
17
+ }
18
+ }
19
+
20
+ const gb = (n: number): string => `${(n / 1e9).toFixed(1)} GB`
21
+
22
+ async function repoAndRel(arg: string): Promise<{ root: string; rel: string }> {
23
+ const { findRepoRoot } = await import('../ts/config.ts')
24
+ const { relative, resolve } = await import('node:path')
25
+ const abs = resolve(process.cwd(), arg).replace(/\/+$/, '')
26
+ const root = findRepoRoot(process.cwd())
27
+ return { root, rel: relative(root, abs) }
28
+ }
29
+
30
+ export class AnnexCommand extends Command {
31
+ static override paths = [['annex']]
32
+ static override usage = Command.Usage({
33
+ category: 'Annex',
34
+ description: 'each annex: present or not, free space, its media, every offloaded folder and its link',
35
+ details: `${DETAILS}\n\nA folder with no marker where an annex should be is named: the drive is unplugged, or a phantom folder took its place.`,
36
+ examples: [['where the annexes stand', 'sk annex']],
37
+ })
38
+ async execute(): Promise<number> {
39
+ return run(this.context, async (out) => {
40
+ const { annexSpecs, driveFree, isPresent, mediaFiles } = await import('../annex/annex.ts')
41
+ const { drift, offloads } = await import('../annex/offload.ts')
42
+ const { existsSync } = await import('node:fs')
43
+ const specs = await annexSpecs()
44
+ if (specs.length === 0) out('no annex: the house config lists none (serve.annexes)')
45
+ for (const a of specs) {
46
+ if (!isPresent(a)) {
47
+ out(`${a.path} ABSENT${existsSync(a.path) ? ': the folder is there with no marker (a phantom, or sk annex init never ran)' : ': the drive is unplugged'}`)
48
+ continue
49
+ }
50
+ const m = mediaFiles(a)
51
+ const bytes = m.reduce((s, f) => s + f.size, 0)
52
+ out(`${a.path} present free ${gb(driveFree(a.path))} media ${m.length} files ${gb(bytes)}${a.maxGb !== undefined ? ` of ${a.maxGb} GB` : ''}`)
53
+ }
54
+ const list = offloads()
55
+ for (const repo of [...new Set(list.map((x) => x.repo))]) {
56
+ const bad = new Map((await drift(repo)).map((d) => [d.path, d] as const))
57
+ for (const x of list.filter((y) => y.repo === repo)) {
58
+ const d = bad.get(`${x.repo}/${x.rel}`)
59
+ out(` ${repo}/${x.rel} ${gb(x.bytes)} ${d ? `${d.kind.toUpperCase()}: ${d.why}` : 'link holds'}`)
60
+ }
61
+ for (const d of bad.values()) if (d.kind === 'orphan') out(` ORPHAN ${d.path}: ${d.why}`)
62
+ for (const d of bad.values()) out(` → ${d.fix}`)
63
+ }
64
+ return 0
65
+ })
66
+ }
67
+ }
68
+
69
+ export class AnnexInitCommand extends Command {
70
+ static override paths = [['annex', 'init']]
71
+ static override usage = Command.Usage({
72
+ category: 'Annex',
73
+ description: 'mark a folder of an external drive as an annex: its parent mounted, never the home disk',
74
+ details: `${DETAILS}\n\nThe folder is made only when its parent exists, never with its parents, and is refused on the home disk or a Time Machine volume. List it in serve.annexes of the house config.`,
75
+ examples: [['the T7', 'sk annex init /Volumes/T7/shipkit']],
76
+ })
77
+ root = Option.String({ required: true })
78
+ async execute(): Promise<number> {
79
+ return run(this.context, async (out) => {
80
+ const { initAnnex } = await import('../annex/annex.ts')
81
+ out(`annex marked: ${initAnnex(this.root)}`)
82
+ return 0
83
+ })
84
+ }
85
+ }
86
+
87
+ export class AnnexOffloadCommand extends Command {
88
+ static override paths = [['annex', 'offload']]
89
+ static override usage = Command.Usage({
90
+ category: 'Annex',
91
+ description: "a repo's .shipkit/cache or .shipkit/tmp folders to the annex, a symlink in their place",
92
+ details: `${DETAILS}\n\nEach path is checked first: inside .shipkit/cache or .shipkit/tmp, ignored by git, no db, lock or git worktree inside, nothing the backup holds or the media store indexes, nothing a process holds open. The copy is checked by its file count and bytes before the swap.`,
93
+ examples: [['two scratch folders', 'sk annex offload .shipkit/tmp/anatomy-data .shipkit/cache'], ['what would move', 'sk annex offload --dry .shipkit/tmp/*']],
94
+ })
95
+ dry = Option.Boolean('--dry', false, { description: 'check and print, move nothing' })
96
+ folders = Option.Rest({ required: 1 })
97
+ async execute(): Promise<number> {
98
+ return run(this.context, async (out) => {
99
+ const { offload } = await import('../annex/offload.ts')
100
+ let failed = 0
101
+ let total = 0
102
+ for (const p of this.folders) {
103
+ const { root, rel } = await repoAndRel(p)
104
+ try {
105
+ const m = await offload(root, rel, { dry: this.dry })
106
+ total += m.bytes
107
+ out(`${this.dry ? 'would move' : 'moved'} ${rel} ${m.files} files ${gb(m.bytes)} → ${m.target}`)
108
+ } catch (e) {
109
+ failed++
110
+ out(`refused ${rel}: ${(e as Error).message}`)
111
+ }
112
+ }
113
+ out(`${this.dry ? 'would free' : 'freed'} ${gb(total)}${failed > 0 ? `, ${failed} refused` : ''}`)
114
+ return failed > 0 ? 1 : 0
115
+ })
116
+ }
117
+ }
118
+
119
+ export class AnnexBackCommand extends Command {
120
+ static override paths = [['annex', 'back']]
121
+ static override usage = Command.Usage({
122
+ category: 'Annex',
123
+ description: "an offloaded folder back on the Mac's disk, its link replaced, when the disk has room",
124
+ details: `${DETAILS}\n\nThe disk must keep 10 GB free beyond the folder. The copy is checked by its file count and bytes before the link goes.`,
125
+ examples: [['bring one back', 'sk annex back .shipkit/tmp/anatomy-data']],
126
+ })
127
+ folder = Option.String({ required: true })
128
+ async execute(): Promise<number> {
129
+ return run(this.context, async (out) => {
130
+ const { back } = await import('../annex/offload.ts')
131
+ const { root, rel } = await repoAndRel(this.folder)
132
+ const m = back(root, rel)
133
+ out(`back ${rel} ${m.files} files ${gb(m.bytes)}`)
134
+ return 0
135
+ })
136
+ }
137
+ }
138
+
139
+ export class AnnexForgetCommand extends Command {
140
+ static override paths = [['annex', 'forget']]
141
+ static override usage = Command.Usage({
142
+ category: 'Annex',
143
+ description: 'drop an offload record the Mac no longer needs: a split, a dead link, or nothing left',
144
+ details: `${DETAILS}\n\nA split (a real folder where the link was, after a cache reset) keeps the Mac folder and deletes the stale annex copy. A dangling link (the drive gone for good) loses the link and its record. Refused while the link holds (sk annex back brings a folder home), and when the link is gone while the annex copy is there (relink it).`,
145
+ examples: [['settle a split', 'sk annex forget .shipkit/cache']],
146
+ })
147
+ folder = Option.String({ required: true })
148
+ async execute(): Promise<number> {
149
+ return run(this.context, async (out) => {
150
+ const { forget } = await import('../annex/offload.ts')
151
+ const { root, rel } = await repoAndRel(this.folder)
152
+ out(`forgot ${rel}: ${forget(root, rel).did}`)
153
+ return 0
154
+ })
155
+ }
156
+ }
157
+
158
+ export class AnnexSweepCommand extends Command {
159
+ static override paths = [['annex', 'sweep']]
160
+ static override usage = Command.Usage({
161
+ category: 'Annex',
162
+ description: "trim each annex's media to its cap, used longest ago first: the Space holds every one",
163
+ details: `${DETAILS}\n\nThe purge runs it after each pass that kept a file on an annex. Offloaded folders never count and never leave.`,
164
+ examples: [['what would go', 'sk annex sweep --dry']],
165
+ })
166
+ dry = Option.Boolean('--dry', false, { description: 'print what would go, delete nothing' })
167
+ async execute(): Promise<number> {
168
+ return run(this.context, async (out) => {
169
+ const { annexSweep, presentAnnexes } = await import('../annex/annex.ts')
170
+ for (const a of await presentAnnexes()) {
171
+ const s = annexSweep(a, { dry: this.dry })
172
+ out(`${a.path} ${s.files} files ${gb(s.bytes)} ${this.dry ? 'would free' : 'freed'} ${s.freed.files} files ${gb(s.freed.bytes)}`)
173
+ }
174
+ return 0
175
+ })
176
+ }
177
+ }
178
+
179
+ export const ANNEX_COMMANDS = [AnnexCommand, AnnexInitCommand, AnnexOffloadCommand, AnnexBackCommand, AnnexForgetCommand, AnnexSweepCommand]
@@ -6,7 +6,7 @@
6
6
  import { Command, Option } from 'clipanion'
7
7
  import { spliceMarkedBlock } from '../core/doc-block.ts'
8
8
  import { FAMILY_PAGES } from './family-pages.ts'
9
- import { type Essential, type Film, marksOf, ROW_OF, runText } from './kit/verb.ts'
9
+ import { type Effect, type Essential, type Film, marksOf, ROW_OF, runText } from './kit/verb.ts'
10
10
 
11
11
  export type CommandOption = { definition: string; description: string }
12
12
  export type CommandRow = {
@@ -25,6 +25,8 @@ export type CommandRow = {
25
25
  stamp?: string[]
26
26
  /** listed on the essentials page */
27
27
  essential?: Essential
28
+ /** acts beyond this machine or spends money: the hub asks before it runs (cli/kit/verb.ts) */
29
+ effect?: Effect
28
30
  /** what a kit row runs */
29
31
  runs?: string
30
32
  }
@@ -87,6 +89,7 @@ export function commandRows(plain: Definition[], detailed: Definition[] = [], bi
87
89
  if (m.words != null) row.words = m.words
88
90
  if (m.stamp != null) row.stamp = m.stamp
89
91
  if (m.essential != null) row.essential = m.essential
92
+ if (m.effect != null) row.effect = m.effect
90
93
  const v = ROW_OF.get(c)
91
94
  if (v != null) row.runs = runText(v.run)
92
95
  }
@@ -90,9 +90,10 @@ export class DaemonJobCommand extends Command {
90
90
 
91
91
  static override usage = Command.Usage({
92
92
  category: 'Serve',
93
- description: 'a daemon background job now, in this process: backup, retention sweep, media store, global context',
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 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',
95
95
  examples: [
96
+ ['every global process app in ~/Applications built and swept now', 'sk daemon job apps'],
96
97
  ['a retention sweep now', 'sk daemon job "retention sweep"'],
97
98
  ['one media store pass', 'sk daemon job "media store"'],
98
99
  ['the house\'s global context written now', 'sk daemon job "global context"'],
@@ -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
+ }