rvlib-shipkit 2.23.0 → 2.24.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.
- package/CHANGELOG.md +25 -0
- package/package.json +1 -1
- package/src/agent-time/render.ts +28 -14
- package/src/agent-time/report.ts +46 -25
- package/src/agent-time/store.ts +30 -10
- package/src/agent-time/timeline.ts +43 -15
- package/src/asks/asks-queue.ts +32 -11
- package/src/checks/SK044-behind-upstream.check.ts +38 -0
- package/src/cli/cmd_Asks.ts +2 -0
- package/src/cli/cmd_Backup.ts +7 -5
- package/src/cli/cmd_Bump.ts +1 -0
- package/src/cli/cmd_Capacity.ts +26 -0
- package/src/cli/cmd_Check.ts +1 -0
- package/src/cli/cmd_Checks.ts +1 -0
- package/src/cli/cmd_Ci.ts +1 -0
- package/src/cli/cmd_Commands.ts +50 -14
- package/src/cli/cmd_Home.ts +0 -29
- package/src/cli/cmd_Hooks.ts +1 -0
- package/src/cli/cmd_Mv.ts +1 -0
- package/src/cli/cmd_Reflect.ts +1 -0
- package/src/cli/cmd_Releases.ts +1 -0
- package/src/cli/cmd_Review.ts +97 -14
- package/src/cli/cmd_Secret.ts +41 -2
- package/src/cli/cmd_Shot.ts +1 -0
- package/src/cli/cmd_Status.ts +1 -0
- package/src/cli/cmd_Time.ts +3 -1
- package/src/cli/cmd_Tmp.ts +82 -0
- package/src/cli/cmd_Wiki.ts +1 -0
- package/src/cli/registry.ts +13 -1
- package/src/collections/pings.ts +1 -1
- package/src/core/capacity.ts +71 -0
- package/src/core/check-runner.ts +86 -15
- package/src/core/motherhome.ts +67 -9
- package/src/core/slots.ts +49 -12
- package/src/core/trace-audit.ts +4 -1
- package/src/drill/run.ts +5 -2
- package/src/home/gui-app/ShipkitGui.swift +1 -0
- package/src/home/home-launchd.ts +11 -3
- package/src/home/home-routes.ts +11 -4
- package/src/home/machine-host.ts +65 -0
- package/src/home/machine-stores.ts +19 -17
- package/src/home/machine-temp.ts +493 -0
- package/src/home/other-macs.ts +74 -0
- package/src/home/run-daemon.ts +10 -2
- package/src/home/serve-web.ts +2 -2
- package/src/home/via-hub.ts +6 -1
- package/src/init-repo.ts +7 -3
- package/src/ledger/ledger.ts +6 -0
- package/src/ledger/store.ts +6 -0
- package/src/media-store/backup/keys.ts +21 -6
- package/src/media-store/backup/manifest.ts +52 -11
- package/src/media-store/backup/restore.ts +17 -10
- package/src/media-store/backup/run.ts +5 -2
- package/src/media-store/backup/sources.ts +2 -1
- package/src/mv/mv-md.ts +121 -42
- package/src/reflect/transcript.ts +56 -11
- package/src/releases/from-card.ts +45 -3
- package/src/releases/model.ts +6 -0
- package/src/releases/store.ts +8 -1
- package/src/repo-config.ts +5 -3
- package/src/review/cells.ts +24 -3
- package/src/review/format.ts +33 -9
- package/src/review/media-kind.ts +14 -11
- package/src/review/media-read.ts +6 -5
- package/src/review/model.ts +71 -3
- package/src/review/paste.ts +2 -1
- package/src/review/previews.ts +123 -36
- package/src/review/routes.ts +29 -18
- package/src/review/store.ts +74 -12
- package/src/review/threads.ts +7 -5
- package/src/secrets/copy.ts +110 -0
- package/src/secrets/list.ts +17 -7
- package/src/serve/hub-app/home-strip.css +5 -0
- package/src/serve/hub-app/home-strip.tsx +18 -0
- package/src/serve/hub-app/hub-app.tsx +2 -1
- package/src/serve/hub-app/hub.css +14 -0
- package/src/serve/hub-app/inbox.css +1 -0
- package/src/serve/hub-app/pull-refresh.tsx +88 -0
- package/src/serve/hub-app/review/review-cells.tsx +52 -13
- package/src/serve/hub-app/review/review-list.tsx +6 -1
- package/src/serve/hub-app/review/review-st.ts +6 -5
- package/src/serve/hub-app/review/review-thread.tsx +3 -1
- package/src/serve/hub-app/review/review-views.tsx +18 -11
- package/src/serve/hub-app/review/thread-st.ts +82 -14
- package/src/serve/hub-app/review.css +15 -2
- package/src/serve/hub-runtime.ts +2 -1
- package/src/serve/run-serve.ts +4 -2
- package/src/serve/serve-hub.ts +9 -2
- package/src/suite/child-tools.ts +45 -0
- package/src/suite/judge-suites.ts +10 -22
- package/src/suite/select.ts +83 -8
- package/src/suite/suite-cli.ts +38 -14
- package/src/suite/suite-cores.ts +68 -0
- package/src/suite/suite-reads-preload.ts +8 -6
- package/src/ts/config.ts +44 -0
- package/src/ts/rename.ts +11 -1
- package/src/home/claude-temp.ts +0 -139
package/src/asks/asks-queue.ts
CHANGED
|
@@ -25,9 +25,34 @@ export function slugify(title: string, max = 40): string {
|
|
|
25
25
|
return (lastDash > 0 ? cut.slice(0, lastDash) : cut).replace(/-+$/, '')
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/** the front matter block, between the first two `---` lines: the only place
|
|
29
|
+
* a key lives. A body line that starts with `check:` is prose, and read as a
|
|
30
|
+
* key it would run as shell */
|
|
31
|
+
const splitFront = (md: string): { head: string[]; body: string[] } | null => {
|
|
32
|
+
const lines = md.split(/\r?\n/)
|
|
33
|
+
const end = lines[0]?.trim() === '---' ? lines.findIndex((l, i) => i > 0 && l.trim() === '---') : -1
|
|
34
|
+
return end === -1 ? null : { head: lines.slice(1, end), body: lines.slice(end + 1) }
|
|
35
|
+
}
|
|
36
|
+
const frontMatter = (md: string): string => splitFront(md)?.head.join('\n') ?? ''
|
|
37
|
+
|
|
38
|
+
/** the ask with these keys set in its front matter, where parse reads them; an
|
|
39
|
+
* ask with no block gets one */
|
|
40
|
+
const withKeys = (md: string, keys: [string, string][]): string => {
|
|
41
|
+
const f = splitFront(md) ?? { head: [], body: ['', ...md.split(/\r?\n/)] }
|
|
42
|
+
const head = [...f.head]
|
|
43
|
+
for (const [k, v] of keys) {
|
|
44
|
+
const at = head.findIndex((l) => l.startsWith(`${k}:`))
|
|
45
|
+
if (at === -1) head.push(`${k}: ${v}`)
|
|
46
|
+
else head[at] = `${k}: ${v}`
|
|
47
|
+
}
|
|
48
|
+
return ['---', ...head, '---', ...f.body].join('\n')
|
|
49
|
+
}
|
|
50
|
+
const closedKeys = (): [string, string][] => [['status', 'done'], ['closed', new Date().toISOString().slice(0, 10)]]
|
|
51
|
+
|
|
28
52
|
const parse = (dir: string, file: string): Ask => {
|
|
29
53
|
const md = readFileSync(join(dir, file), 'utf8')
|
|
30
|
-
const
|
|
54
|
+
const head = frontMatter(md)
|
|
55
|
+
const fm = (key: string): string | null => head.match(new RegExp(`^${key}:\\s*(.+)$`, 'm'))?.[1]?.trim() ?? null
|
|
31
56
|
return {
|
|
32
57
|
file,
|
|
33
58
|
status: fm('status') ?? 'open',
|
|
@@ -100,8 +125,7 @@ function probeAsk(root: string, dir: string, a: Ask, check: string): { passed: t
|
|
|
100
125
|
}
|
|
101
126
|
const done = join(dir, 'done')
|
|
102
127
|
mkdirSync(done, { recursive: true })
|
|
103
|
-
|
|
104
|
-
atomicWrite(join(dir, a.file), md)
|
|
128
|
+
atomicWrite(join(dir, a.file), withKeys(readFileSync(join(dir, a.file), 'utf8'), closedKeys()))
|
|
105
129
|
renameSync(join(dir, a.file), join(done, a.file))
|
|
106
130
|
return { passed: true }
|
|
107
131
|
}
|
|
@@ -206,8 +230,7 @@ ${whyBlock}${opts?.kind === 'decision' ? DECISION_BODY : secrets.length > 0 ? cr
|
|
|
206
230
|
export function archiveAsk(dir: string, file: string): void {
|
|
207
231
|
const p = join(dir, file)
|
|
208
232
|
if (!existsSync(p)) throw new Error(`no such ask: ${file}`)
|
|
209
|
-
|
|
210
|
-
writeFileSync(p, md)
|
|
233
|
+
writeFileSync(p, withKeys(readFileSync(p, 'utf8'), closedKeys()))
|
|
211
234
|
const done = join(dir, 'done')
|
|
212
235
|
mkdirSync(done, { recursive: true })
|
|
213
236
|
renameSync(p, join(done, file))
|
|
@@ -227,12 +250,10 @@ export function markPinged(dir: string, file: string): boolean {
|
|
|
227
250
|
const p = join(dir, file)
|
|
228
251
|
if (!existsSync(p)) return false
|
|
229
252
|
const md = readFileSync(p, 'utf8')
|
|
230
|
-
if (/^pinged:/m.test(md)) return false
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
// no-op write here would re-fire the ping every tick forever
|
|
235
|
-
writeFileSync(p, withMark !== md ? withMark : `${line}\n${md}`)
|
|
253
|
+
if (/^pinged:/m.test(frontMatter(md))) return false
|
|
254
|
+
// in the front matter, where it is read: a marker parse misses re-fires
|
|
255
|
+
// the ping every tick forever
|
|
256
|
+
writeFileSync(p, withKeys(md, [['pinged', new Date().toISOString().slice(0, 10)]]))
|
|
236
257
|
return true
|
|
237
258
|
}
|
|
238
259
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// SK044 behind upstream: after a fetch, the branch holds every commit its upstream has. Two Macs work one repo through
|
|
2
|
+
// git alone (tools/shipkit/home.md, Two machines), so a session on one Mac must learn that the other pushed. It warns
|
|
3
|
+
// and never pulls: a pull moves the tree under every session working in it. No git, no upstream, a fetch that fails:
|
|
4
|
+
// a skip, never red, since it reports the world.
|
|
5
|
+
import { check } from '../check.ts'
|
|
6
|
+
import { probeGitRoot } from '../core/git-root.ts'
|
|
7
|
+
|
|
8
|
+
const firstLine = (text: string): string => text.trim().split('\n')[0] ?? ''
|
|
9
|
+
|
|
10
|
+
export const behindUpstream = check({
|
|
11
|
+
id: 'SK044',
|
|
12
|
+
blocking: false,
|
|
13
|
+
title: 'behind upstream',
|
|
14
|
+
description: 'the branch holds every commit its upstream has, after a fetch',
|
|
15
|
+
owner: 'tools/shipkit/home.md',
|
|
16
|
+
runs: { onPreCommit: false, onCi: false, onFull: false, onRelease: false, onHealth: true, onSave: false, onClock: { every: '30m', inactive: 'wait' } },
|
|
17
|
+
cache: { by: 'never', why: 'it asks the remote what it holds now' },
|
|
18
|
+
fix: 'none',
|
|
19
|
+
applies: 'always',
|
|
20
|
+
run: async (c) => {
|
|
21
|
+
const skip = (why: string): void => void c.lines.push({ kind: 'skip', text: `behind upstream unverified: ${why}` })
|
|
22
|
+
if (probeGitRoot(c.root).root == null) return skip('no git')
|
|
23
|
+
const up = await c.exec(['git', 'rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'], { cwd: c.root })
|
|
24
|
+
if (up.code !== 0) return skip('the branch has no upstream')
|
|
25
|
+
const upstream = up.out.trim()
|
|
26
|
+
// with no remote named, git fetches the branch's own remote
|
|
27
|
+
const fetched = await c.exec(['git', 'fetch', '--quiet'], { cwd: c.root, timeoutMs: 20_000 })
|
|
28
|
+
if (fetched.code !== 0) return skip(`git fetch failed (${firstLine(fetched.out) || `exit ${fetched.code}`})`)
|
|
29
|
+
const count = await c.exec(['git', 'rev-list', '--left-right', '--count', 'HEAD...@{u}'], { cwd: c.root })
|
|
30
|
+
if (count.code !== 0) return skip(`git rev-list says ${firstLine(count.out)}`)
|
|
31
|
+
const [ahead, behind] = count.out.trim().split(/\s+/).map(Number) as [number, number]
|
|
32
|
+
if (behind === 0) return c.ok(`the branch holds every commit of ${upstream}`)
|
|
33
|
+
const how = ahead === 0 ? 'git pull --ff-only' : `git pull, a merge: the branch also holds ${ahead} commit(s) ${upstream} lacks`
|
|
34
|
+
c.warn(`${behind} commit(s) on ${upstream} that this branch lacks: another Mac or session pushed. Pull before you work: ${how}`)
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
export default behindUpstream
|
package/src/cli/cmd_Asks.ts
CHANGED
|
@@ -11,6 +11,7 @@ const asksDir = async (root: string): Promise<string> => join(root, (await loadR
|
|
|
11
11
|
|
|
12
12
|
export class AsksCommand extends Command {
|
|
13
13
|
static override paths = [['asks']]
|
|
14
|
+
static essential = {}
|
|
14
15
|
|
|
15
16
|
static override usage = Command.Usage({
|
|
16
17
|
category: 'Asks',
|
|
@@ -54,6 +55,7 @@ export class AsksCheckCommand extends Command {
|
|
|
54
55
|
|
|
55
56
|
export class AskNewCommand extends Command {
|
|
56
57
|
static override paths = [['ask'], ['asks', 'new']]
|
|
58
|
+
static essential = { args: '<title>' }
|
|
57
59
|
|
|
58
60
|
static override usage = Command.Usage({
|
|
59
61
|
category: 'Asks',
|
package/src/cli/cmd_Backup.ts
CHANGED
|
@@ -81,7 +81,7 @@ export class BackupRunsCommand extends Command {
|
|
|
81
81
|
static override paths = [['backup', 'runs']]
|
|
82
82
|
static override usage = Command.Usage({
|
|
83
83
|
category: 'Media',
|
|
84
|
-
description: 'every backup run the Space holds, oldest first: its time and manifest key',
|
|
84
|
+
description: 'every backup run the Space holds, oldest first: its time, machine and manifest key',
|
|
85
85
|
details: DETAILS,
|
|
86
86
|
examples: [['the runs', 'sk backup runs']],
|
|
87
87
|
})
|
|
@@ -89,7 +89,7 @@ export class BackupRunsCommand extends Command {
|
|
|
89
89
|
return run(this.context, async (h) => {
|
|
90
90
|
const { runsOf } = await import('../media-store/backup/manifest.ts')
|
|
91
91
|
const runs = await runsOf(h.space)
|
|
92
|
-
for (const r of runs) h.out(`${r.at.toISOString()} ${r.key} ${(r.size / 1e3).toFixed(0)} kB`)
|
|
92
|
+
for (const r of runs) h.out(`${r.at.toISOString()} ${r.machine ?? '(host inside)'} ${r.key} ${(r.size / 1e3).toFixed(0)} kB`)
|
|
93
93
|
h.out(`${runs.length} runs`)
|
|
94
94
|
return 0
|
|
95
95
|
})
|
|
@@ -101,18 +101,19 @@ export class BackupRestoreCommand extends Command {
|
|
|
101
101
|
static override usage = Command.Usage({
|
|
102
102
|
category: 'Media',
|
|
103
103
|
description: 'a backup run written back, every sha checked: to an empty folder, or in place',
|
|
104
|
-
details: `${DETAILS}\n\nThe run is
|
|
104
|
+
details: `${DETAILS}\n\nThe run is this Mac's last one at or before --at (the last one when it is left out); --host reads another Mac's runs, as a new Mac restoring the one it replaces. --to writes every file under the folder, at its path under the home (the folder must be empty or new). --in-place writes over the live files: a live file with other bytes is copied to ~/.shipkit/backup-replaced/<time>/ first, and a sqlite lands beside its live file as <file>.restored (stop pm, then move it). --path keeps the files under one path of the home.`,
|
|
105
105
|
examples: [['the last run into a folder', 'sk backup restore --to ~/restore-1'], ['the veille logs as they were on a day, in place', 'sk backup restore --at 2026-11-04 --in-place --path .config/shipkit/home/veille']],
|
|
106
106
|
})
|
|
107
107
|
to = Option.String('--to', { description: 'an empty or new folder the files land under' })
|
|
108
108
|
inPlace = Option.Boolean('--in-place', false, { description: 'over the live files, each one replaced copied aside first' })
|
|
109
109
|
at = Option.String('--at', { description: 'the last run at or before this time: 2026-11-04T13:50Z, 2026-11-04 or 20261104T135000Z' })
|
|
110
110
|
under = Option.String('--path', { description: 'only the files under this path of the home: .config/shipkit/home/veille' })
|
|
111
|
+
host = Option.String('--host', { description: "another Mac's runs, by the name `sk backup runs` prints: this Mac's when absent" })
|
|
111
112
|
async execute(): Promise<number> {
|
|
112
113
|
return run(this.context, async (h) => {
|
|
113
114
|
const { restore } = await import('../media-store/backup/restore.ts')
|
|
114
115
|
const { parseAt } = await import('../media-store/backup/keys.ts')
|
|
115
|
-
const r = await restore(h.space, { home: h.home, ...(this.to !== undefined ? { to: this.to } : {}), inPlace: this.inPlace, ...(this.at ? { at: parseAt(this.at) } : {}), ...(this.under ? { only: this.under } : {}) })
|
|
116
|
+
const r = await restore(h.space, { home: h.home, ...(this.to !== undefined ? { to: this.to } : {}), inPlace: this.inPlace, ...(this.at ? { at: parseAt(this.at) } : {}), ...(this.under ? { only: this.under } : {}), ...(this.host ? { machine: this.host } : {}) })
|
|
116
117
|
h.out(`run ${r.at} (${r.run}): ${r.files} files, ${r.written} written (${mb(r.bytes)})${this.inPlace ? `, ${r.same} already the same` : ''}`)
|
|
117
118
|
if (r.aside.n > 0) h.out(`${r.aside.n} live files copied aside first, into ${r.aside.dir}`)
|
|
118
119
|
for (const b of r.beside) h.out(` a sqlite landed beside its live file: ${b} (stop pm, then move it over)`)
|
|
@@ -132,12 +133,13 @@ export class BackupDrillCommand extends Command {
|
|
|
132
133
|
})
|
|
133
134
|
to = Option.String('--to', { description: 'restore into this empty or new folder, and keep it' })
|
|
134
135
|
at = Option.String('--at', { description: 'the last run at or before this time, an older run: 2026-11-04T13:50Z or 20261104T135000Z' })
|
|
136
|
+
host = Option.String('--host', { description: "another Mac's runs, by the name `sk backup runs` prints: this Mac's when absent" })
|
|
135
137
|
async execute(): Promise<number> {
|
|
136
138
|
return run(this.context, async (h) => {
|
|
137
139
|
const { drill } = await import('../media-store/backup/restore.ts')
|
|
138
140
|
const { parseAt } = await import('../media-store/backup/keys.ts')
|
|
139
141
|
const t0 = Date.now()
|
|
140
|
-
const d = await drill(h.space, { home: h.home, ...(this.to !== undefined ? { to: this.to } : {}), ...(this.at ? { at: parseAt(this.at) } : {}) })
|
|
142
|
+
const d = await drill(h.space, { home: h.home, ...(this.to !== undefined ? { to: this.to } : {}), ...(this.at ? { at: parseAt(this.at) } : {}), ...(this.host ? { machine: this.host } : {}) })
|
|
141
143
|
h.out(`run ${d.at} (${d.run}, version ${d.v}): ${d.files} files (${mb(d.bytes)}), ${d.restored} restored with their sha, in ${((Date.now() - t0) / 1000).toFixed(1)} s`)
|
|
142
144
|
h.out(`against the live files: ${d.sameAsLive} the same, ${d.liveMoved.length} moved since the run, ${d.liveGone.length} gone from the disk, ${d.failed.length} failed`)
|
|
143
145
|
for (const s of d.sqlite) h.out(` sqlite ~/${s.path}: restored ${JSON.stringify(s.restored)}, live now ${JSON.stringify(s.live)}`)
|
package/src/cli/cmd_Bump.ts
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// sk capacity: how many more lanes the machine can take now. Report only, exit 0 always: the orchestrator decides.
|
|
2
|
+
import { Command, Option } from 'clipanion'
|
|
3
|
+
import { capacityLines, readCapacity } from '../core/capacity.ts'
|
|
4
|
+
|
|
5
|
+
export class CapacityCommand extends Command {
|
|
6
|
+
static override paths = [['capacity']]
|
|
7
|
+
static essential = {}
|
|
8
|
+
|
|
9
|
+
static override usage = Command.Usage({
|
|
10
|
+
category: 'Health',
|
|
11
|
+
description: 'how many more lanes the machine can take now: its cores, its load, the agents live on it',
|
|
12
|
+
details: 'reads the cores, the 1 and 5 minute load and the agents whose transcript moved in the last 3 minutes, every account and repo. A lane counts for the load the live agents share, never under one core. Run it before a lane starts: no room means the lane waits on the board. Report only, exit 0 always.',
|
|
13
|
+
examples: [
|
|
14
|
+
['before a lane starts', 'sk capacity'],
|
|
15
|
+
['machine readable', 'sk capacity --json'],
|
|
16
|
+
],
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
json = Option.Boolean('--json', false, { description: 'the measure and the room as json' })
|
|
20
|
+
|
|
21
|
+
async execute(): Promise<number> {
|
|
22
|
+
const { capacity, live } = readCapacity()
|
|
23
|
+
this.context.stdout.write(this.json ? `${JSON.stringify({ ...capacity, live })}\n` : `${capacityLines(capacity, live).join('\n')}\n`)
|
|
24
|
+
return 0
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/cli/cmd_Check.ts
CHANGED
package/src/cli/cmd_Checks.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { classify } from '../ledger/git-key.ts'
|
|
|
17
17
|
|
|
18
18
|
export class ChecksCommand extends Command {
|
|
19
19
|
static override paths = [['checks']]
|
|
20
|
+
static essential = {}
|
|
20
21
|
|
|
21
22
|
// widened so the hidden alias below can drop it: no usage, no help entry
|
|
22
23
|
static override usage: Usage | undefined = Command.Usage({
|
package/src/cli/cmd_Ci.ts
CHANGED
package/src/cli/cmd_Commands.ts
CHANGED
|
@@ -134,6 +134,40 @@ export function renderCompact(rows: CommandRow[], bin = 'sk', pages: Readonly<Re
|
|
|
134
134
|
return out.join('\n').trim()
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/** one essential command's lines: its words with the arguments an agent types, its description, its examples */
|
|
138
|
+
const essentialLines = (r: CommandRow, bin: string, sep: string): string[] => {
|
|
139
|
+
const e = r.essential!
|
|
140
|
+
return [`- \`${bin} ${r.path}${e.args != null ? ` ${e.args}` : ''}\`${sep}${r.description}`, ...r.examples.slice(0, e.examples ?? 0).map(([label, cmd]) => ` - \`${cmd}\`: ${label}`)]
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** how to list the commands of a family the page does not show: one `--help` per first word, with its count */
|
|
144
|
+
const restOf = (all: CommandRow[], bin: string): string[] => {
|
|
145
|
+
const first = (r: CommandRow): string => r.path.split(' ')[0]!
|
|
146
|
+
return [...new Set(all.map(first))]
|
|
147
|
+
.map((w) => [w, all.filter((r) => first(r) === w && r.essential == null).length] as const)
|
|
148
|
+
.filter(([, n]) => n > 0)
|
|
149
|
+
.map(([w, n]) => `\`${bin} ${w} --help\` (${n})`)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** the block of a page every session loads: the commands marked essential, then how to list the rest of each
|
|
153
|
+
* family, then every other family on one line with its owner page. The whole list is one command away */
|
|
154
|
+
export function renderEveryday(rows: CommandRow[], bin = 'sk', pages: Readonly<Record<string, string>> | null = null): string {
|
|
155
|
+
const out: string[] = []
|
|
156
|
+
const quiet: string[] = []
|
|
157
|
+
for (const category of [...new Set(rows.map((r) => r.category))]) {
|
|
158
|
+
const all = rows.filter((r) => r.category === category)
|
|
159
|
+
const mine = all.filter((r) => r.essential != null)
|
|
160
|
+
const page = pages?.[category] != null ? ` → ${pages[category]}` : ''
|
|
161
|
+
const rest = restOf(all, bin)
|
|
162
|
+
if (mine.length === 0) { quiet.push(`- ${category}${page}: ${rest.join(', ')}`); continue }
|
|
163
|
+
out.push(`\n### ${category}${page}\n`)
|
|
164
|
+
for (const r of mine) out.push(...essentialLines(r, bin, ' — '))
|
|
165
|
+
if (rest.length > 0) out.push(`- more: ${rest.join(', ')}`)
|
|
166
|
+
}
|
|
167
|
+
if (quiet.length > 0) out.push('\n### The other families, each with the command that lists it and how many it holds\n', ...quiet)
|
|
168
|
+
return out.join('\n').trim()
|
|
169
|
+
}
|
|
170
|
+
|
|
137
171
|
/** the page every session loads: per category its everyday commands, a few
|
|
138
172
|
* examples, and how to list the rest. Generated whole */
|
|
139
173
|
export function renderEssentials(rows: CommandRow[], bin: string, command: string): string {
|
|
@@ -149,11 +183,7 @@ export function renderEssentials(rows: CommandRow[], bin: string, command: strin
|
|
|
149
183
|
const mine = all.filter((r) => r.essential != null)
|
|
150
184
|
if (mine.length === 0) { quiet.push(...rest); continue }
|
|
151
185
|
out.push('', `## ${category}${rest.length > 0 ? ` (more: ${rest.join(', ')})` : ''}`, '')
|
|
152
|
-
for (const r of mine)
|
|
153
|
-
const e = r.essential!
|
|
154
|
-
out.push(`- \`${bin} ${r.path}${e.args != null ? ` ${e.args}` : ''}\`: ${r.description}`)
|
|
155
|
-
for (const [label, cmd] of r.examples.slice(0, e.examples ?? 0)) out.push(` - \`${cmd}\`: ${label}`)
|
|
156
|
-
}
|
|
186
|
+
for (const r of mine) out.push(...essentialLines(r, bin, ': '))
|
|
157
187
|
}
|
|
158
188
|
if (quiet.length > 0) out.push('', `## The other families: ${quiet.join(', ')}`)
|
|
159
189
|
return `${out.join('\n')}\n`
|
|
@@ -214,14 +244,17 @@ export class CommandsCommand extends Command {
|
|
|
214
244
|
['markdown index', 'sk commands'],
|
|
215
245
|
['machine-readable', 'sk commands --json'],
|
|
216
246
|
['write into a docs page between the markers', 'sk commands --out docs/commands.md'],
|
|
217
|
-
['
|
|
218
|
-
['
|
|
247
|
+
['the everyday commands, for a page every session loads', 'sk commands --everyday --out wiki/tools/shipkit/commands.md'],
|
|
248
|
+
['every command, one line each, on demand', 'sk commands --compact'],
|
|
249
|
+
['fail if that page is stale (lint mode)', 'sk commands --everyday --out wiki/tools/shipkit/commands.md --check'],
|
|
219
250
|
],
|
|
220
251
|
})
|
|
221
252
|
|
|
222
253
|
/** a project CLI holds its rows to shapeProblems (--out and --check fail on
|
|
223
254
|
* a breach), and its --out creates a missing page */
|
|
224
255
|
static shapeRule = false
|
|
256
|
+
/** the classes of the cli this command is registered in, set by its registry: their marks (essential, film) */
|
|
257
|
+
static registered: readonly { paths?: string[][] }[] = []
|
|
225
258
|
|
|
226
259
|
/** each family's owner page, named in the compact page's headings; a project CLI has none */
|
|
227
260
|
static familyPages: Readonly<Record<string, string>> | null = FAMILY_PAGES
|
|
@@ -230,11 +263,12 @@ export class CommandsCommand extends Command {
|
|
|
230
263
|
out = Option.String('--out', { description: 'host file carrying the <bin>:commands markers. The block between them is rewritten' })
|
|
231
264
|
check = Option.Boolean('--check', false, { description: 'with --out or --essentials: exit 1 if a page is stale, write nothing' })
|
|
232
265
|
compact = Option.Boolean('--compact', false, { description: 'one line per command: no flags, no examples (they are `<bin> <command> --help`)' })
|
|
266
|
+
everyday = Option.Boolean('--everyday', false, { description: 'the compact form of a page every session loads: only the commands marked essential, then every other family on one line' })
|
|
233
267
|
essentials = Option.String('--essentials', { description: 'the everyday commands page, rewritten whole from the commands marked essential' })
|
|
234
268
|
|
|
235
269
|
async execute(): Promise<number> {
|
|
236
270
|
const bin = this.cli.binaryName
|
|
237
|
-
const classes = (this.context as { classes?: { paths?: string[][] }[] }).classes ??
|
|
271
|
+
const classes = (this.context as { classes?: { paths?: string[][] }[] }).classes ?? (this.constructor as typeof CommandsCommand).registered
|
|
238
272
|
const rows = commandRows(
|
|
239
273
|
this.cli.definitions() as Definition[],
|
|
240
274
|
(this.cli.definitions as (o?: { detailed?: boolean }) => Definition[])({ detailed: true }),
|
|
@@ -243,12 +277,13 @@ export class CommandsCommand extends Command {
|
|
|
243
277
|
)
|
|
244
278
|
const write = (s: string): void => void this.context.stdout.write(s)
|
|
245
279
|
const pages = (this.constructor as typeof CommandsCommand).familyPages
|
|
246
|
-
|
|
280
|
+
// --everyday is a compact form: it never falls back to the full markdown
|
|
281
|
+
const render = (): string => (this.everyday ? renderEveryday(rows, bin, pages) : this.compact ? renderCompact(rows, bin, pages) : renderMarkdown(rows, bin))
|
|
247
282
|
if (this.out == null && this.essentials == null) {
|
|
248
283
|
write(this.json ? `${JSON.stringify(rows)}\n` : `${render()}\n`)
|
|
249
284
|
return 0
|
|
250
285
|
}
|
|
251
|
-
if (this.out != null && this.compact && pages != null) {
|
|
286
|
+
if (this.out != null && (this.compact || this.everyday) && pages != null) {
|
|
252
287
|
const bad = familyProblems(rows, pages)
|
|
253
288
|
for (const b of bad) write(`FAIL: ${b}\n`)
|
|
254
289
|
if (bad.length > 0) { write(' fix: one row per family in src/cli/family-pages.ts, the wiki page that owns it\n'); return 1 }
|
|
@@ -276,14 +311,15 @@ export class CommandsCommand extends Command {
|
|
|
276
311
|
const host = existsSync(this.out) ? readFileSync(this.out, 'utf8') : newCommandsPage(bin, this.out)
|
|
277
312
|
const next = spliceBlock(host, render(), bin)
|
|
278
313
|
if (next == null) { write(`FAIL: ${this.out} has no ${begin} / ${end} markers\n`); return 1 }
|
|
279
|
-
|
|
314
|
+
const shown = this.everyday ? `${rows.filter((r) => r.essential != null).length} everyday commands of ${rows.length}` : `${rows.length} commands`
|
|
315
|
+
if (next === host) { write(`ok: ${this.out} command index current (${shown})\n`); return code }
|
|
280
316
|
if (this.check) {
|
|
281
|
-
write(`FAIL: ${this.out} command index is STALE — the binary registers commands the page does not list\n`)
|
|
282
|
-
write(` fix: ${bin === 'sk' ? 'shipkit' : bin} commands${this.compact ? ' --compact' : ''} --out ${this.out}\n`)
|
|
317
|
+
write(`FAIL: ${this.out} command index is STALE — ${this.everyday ? 'the everyday commands, a description or a family count moved in the binary' : 'the binary registers commands the page does not list'}\n`)
|
|
318
|
+
write(` fix: ${bin === 'sk' ? 'shipkit' : bin} commands${this.everyday ? ' --everyday' : this.compact ? ' --compact' : ''} --out ${this.out}\n`)
|
|
283
319
|
return 1
|
|
284
320
|
}
|
|
285
321
|
writeFileSync(this.out, next)
|
|
286
|
-
write(`ok: ${this.out} command index rewritten (${
|
|
322
|
+
write(`ok: ${this.out} command index rewritten (${shown})\n`)
|
|
287
323
|
return code
|
|
288
324
|
}
|
|
289
325
|
}
|
package/src/cli/cmd_Home.ts
CHANGED
|
@@ -97,45 +97,16 @@ export class DaemonJobCommand extends Command {
|
|
|
97
97
|
['a retention sweep now', 'sk daemon job "retention sweep"'],
|
|
98
98
|
['one media store pass', 'sk daemon job "media store"'],
|
|
99
99
|
['the house\'s global context written now', 'sk daemon job "global context"'],
|
|
100
|
-
['what the sweep\'s claude temp pass would delete', 'sk daemon job "retention sweep" --dry'],
|
|
101
|
-
['the sweep trims claude temp from now on', 'sk daemon job "retention sweep" --claude-temp on'],
|
|
102
100
|
],
|
|
103
101
|
})
|
|
104
102
|
|
|
105
103
|
id = Option.String({ required: true, name: 'id' })
|
|
106
|
-
dry = Option.Boolean('--dry', false, { description: 'retention sweep only: print each claude temp folder the pass would delete (idle age, size) and the total, delete nothing, sweep no other store' })
|
|
107
|
-
claudeTemp = Option.String('--claude-temp', { description: 'retention sweep only: on, the sweep trims claude code\'s session temp folders (sessions idle 24 h or more past 5 GB, oldest first); off stops it (off until the owner turns it on)' })
|
|
108
|
-
|
|
109
104
|
async execute(): Promise<number> {
|
|
110
105
|
const { isJobId, DAEMON_JOBS, runJobBody } = await import('../home/daemon-jobs.ts')
|
|
111
106
|
if (!isJobId(this.id)) {
|
|
112
107
|
this.context.stderr.write(`FAIL: no daemon job ${JSON.stringify(this.id)}: ${DAEMON_JOBS.map((j) => j.id).join(', ')}\n`)
|
|
113
108
|
return 1
|
|
114
109
|
}
|
|
115
|
-
if (this.dry || this.claudeTemp !== undefined) {
|
|
116
|
-
if (this.id !== 'retention sweep') {
|
|
117
|
-
this.context.stderr.write(`FAIL: --dry and --claude-temp belong to the retention sweep, not ${this.id}\n`)
|
|
118
|
-
return 1
|
|
119
|
-
}
|
|
120
|
-
const t = await import('../home/claude-temp.ts')
|
|
121
|
-
const out = (l: string): void => void this.context.stdout.write(`${l}\n`)
|
|
122
|
-
const err = (l: string): void => void this.context.stderr.write(`${l}\n`)
|
|
123
|
-
if (this.claudeTemp !== undefined) {
|
|
124
|
-
if (this.claudeTemp !== 'on' && this.claudeTemp !== 'off') { err(`FAIL: --claude-temp takes on or off, not ${this.claudeTemp}`); return 1 }
|
|
125
|
-
if (!t.setClaudeTempAuto(this.claudeTemp === 'on')) { err('FAIL: the machine db does not open: the switch is not set'); return 1 }
|
|
126
|
-
}
|
|
127
|
-
out(`the sweep's claude temp pass: ${t.claudeTempAuto() ? 'on' : 'off (sk daemon job "retention sweep" --claude-temp on turns it on)'}`)
|
|
128
|
-
if (!this.dry) return 0
|
|
129
|
-
const root = t.claudeTempRoot()
|
|
130
|
-
if (root == null) { err('FAIL: no uid on this platform'); return 1 }
|
|
131
|
-
try {
|
|
132
|
-
t.trimClaudeTemp(root, { now: Date.now(), dry: true, print: out, printErr: err })
|
|
133
|
-
return 0
|
|
134
|
-
} catch (e) {
|
|
135
|
-
err(`FAIL: ${(e as Error).message}`)
|
|
136
|
-
return 1
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
110
|
const { homedir } = await import('node:os')
|
|
140
111
|
const { findRepoRoot } = await import('../ts/config.ts')
|
|
141
112
|
// its lines land in the daemon's log: each one stamped and named
|
package/src/cli/cmd_Hooks.ts
CHANGED
|
@@ -58,6 +58,7 @@ export class HooksCommitMsgCommand extends Command {
|
|
|
58
58
|
|
|
59
59
|
export class HooksListCommand extends Command {
|
|
60
60
|
static override paths = [['hooks', 'list']]
|
|
61
|
+
static essential = {}
|
|
61
62
|
static override usage = Command.Usage({
|
|
62
63
|
category: 'Gate',
|
|
63
64
|
description: 'what blocks a commit in this repo, built-ins and repo-declared',
|
package/src/cli/cmd_Mv.ts
CHANGED
package/src/cli/cmd_Reflect.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type RepoDoc = { repo: string; prompts: PromptEntry[]; error?: string }
|
|
|
14
14
|
|
|
15
15
|
export class ReflectCommand extends Command {
|
|
16
16
|
static override paths = [['reflect']]
|
|
17
|
+
static essential = {}
|
|
17
18
|
|
|
18
19
|
static override usage = Command.Usage({
|
|
19
20
|
category: 'Health',
|
package/src/cli/cmd_Releases.ts
CHANGED