rvlib-shipkit 2.18.0 → 2.19.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 +15 -0
- package/package.json +1 -1
- package/src/asks/asks-queue.ts +63 -10
- package/src/cli/cmd_Asks.ts +3 -1
- package/src/cli/cmd_GlobalProcesses.ts +34 -11
- package/src/cli/cmd_Home.ts +38 -2
- package/src/cli/cmd_Secret.ts +4 -30
- package/src/cli/cmd_Social.ts +40 -1
- package/src/cli/cmd_Trailer.ts +15 -3
- package/src/cli/registry.ts +2 -1
- package/src/collections/actions.ts +29 -1
- package/src/collections/collection-types.ts +2 -0
- package/src/collections/providers.ts +1 -1
- package/src/home/home-paths.ts +5 -1
- package/src/home/home-start.ts +12 -12
- package/src/home/run-daemon.ts +11 -2
- package/src/home/run-pm.ts +9 -1
- package/src/home/supervise.ts +3 -1
- package/src/identities/identities.ts +22 -5
- package/src/review/http.ts +7 -2
- package/src/review/store.ts +81 -19
- package/src/secrets/manager.ts +59 -0
- package/src/secrets/name.ts +2 -0
- package/src/serve/hub-app/col-card.tsx +10 -0
- package/src/serve/hub-app/cols-svc.ts +37 -6
- package/src/serve/hub-app/hub.css +1 -0
- package/src/serve/hub-app/social/identity-pictures.ts +74 -0
- package/src/serve/hub-app/social/social-page.tsx +77 -37
- package/src/serve/hub-app/social.css +8 -3
- package/src/serve/serve-hub.ts +12 -2
- package/src/social/discord-layout.ts +239 -0
- package/src/social/md.ts +14 -6
- package/src/social/publish/discord.ts +3 -2
- package/src/social/routes.ts +3 -3
- package/src/stores/routes.ts +2 -2
- package/src/suite/judge-suites.ts +1 -1
- package/src/suite/suite-cli.ts +5 -5
- package/src/trailer/build.ts +75 -50
- package/src/trailer/draft.ts +28 -0
- package/src/trailer/footage.ts +4 -2
- package/src/trailer/grammar.ts +11 -9
- package/src/trailer/graph.ts +32 -9
- package/src/trailer/profile.ts +35 -0
- package/src/trailer/prune.ts +15 -10
- package/src/trailer/stitch.ts +22 -10
- package/src/trailer/titles.ts +47 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## 2.19.0
|
|
2
|
+
|
|
3
|
+
- **`sk trailer --draft`: a quick cut to judge the beats.** Half the size, `out/<name>-draft.mp4`, the cut's own mix, no strip (`--strip` draws one), no shelf. It reads every take the cut has filmed; a take the cut lacks films as a draft take under its own key, its row told by `SK_TRAILER_DRAFT=1` and the draft's size, so no full build or `keep` ever reads it. The prune keeps a cut's draft renders beside its own.
|
|
4
|
+
- **The trailer's sound is mixed while the takes film.** It reads no take, so it no longer waits for the filming nor runs beside the sections.
|
|
5
|
+
- **The mix lands on its `master` in two or three passes.** A pass counts what its trim takes off the loudness and what a dB of gain moved it last time, and a gap measured on the 0.3 LU tolerance holds (a float difference of 0.30000000000000071 used to run four more passes). A mix that never holds keeps its pass under the ceiling nearest its master, not its last one. Measured on a 74 s cut: 5, 6, 2 and 6 passes at four masters became 2, 2, 3 and 3. A cut whose mix is cached mixes again once, and lands within the same 0.3 LU, at a slightly different level.
|
|
6
|
+
- **`sk trailer --profile`** prints every phase of a build, with its start, its seconds and its share of the run.
|
|
7
|
+
- **A big title can stand in the middle.** `place middle` joins top and bottom and centres the title's block on the frame. `sub` draws the lines after the first break smaller, at that share of the size. `shade` lays a soft dark scrim round the words, so they read over a busy picture. A title without these words draws as before.
|
|
8
|
+
- **`sk social discord apply [identity]`: an identity's Discord server is data.** `layout.md` beside the identity's discord `account.md` holds a `## Roles` table, one `##` heading per category with its channels (emoji, topic, read only, voice, age restricted, the roles it is only for), and a `## Members` table that gives roles to members by username. The parser names every bad row at once. The apply writes only what differs, compares each channel by name, category, topic, nsfw flag and permission overwrites, and only gives roles, never takes them. With no guild yet, it names the servers the bot is in.
|
|
9
|
+
- **A credential ask takes the token on its hub page.** An ask that names `secret: <name> [<name>…]` in its front matter shows a password field and a store button per secret. The hub stores the value through the repo's `credsCommand` (the same argv as `sk secret set`, value on stdin), runs that ask's check, and archives the ask when it passes.
|
|
10
|
+
- **`sk pm restart [daemon|web]`** restarts the daemon, the web or both through pm and waits until each probe answers.
|
|
11
|
+
- **pm runs from the house wherever it starts.** `sk pm install` typed in a subfolder of a repo wrote that folder as the LaunchAgent's working directory, and the daemon died at boot with no `repo.config.ts` there. Install now writes the house root of the folder, and pm and the daemon each resolve the house from the wiki index they read, so a hand run inside any folder runs from the house too.
|
|
12
|
+
- **The full test tier runs in parallel workers**, as the quick tier does: the slow suites included, the serial ones alone after, with the full tier's own timeout. Measured on this package: 339 files in 20.2 s on 8 workers, against 44.1 s one suite at a time.
|
|
13
|
+
- **An identity's hub page shows every picture.** The hub serves `.svg` as `image/svg+xml`, so an svg avatar draws. A profile row with a note in parentheses shows its files as tiles and the note under them. The identity's own `pictures/` folder is always listed, one tile per picture with its other formats as downloads, avatars and banners grouped by venue.
|
|
14
|
+
- **The review list can no longer go stale.** It refreshed from file watch events alone, so a watch that went silent under load froze it until the daemon restarted. The watch is now a fast path, and every request also checks the store folder on disk.
|
|
15
|
+
|
|
1
16
|
## 2.18.0
|
|
2
17
|
|
|
3
18
|
- **SK039: VS Code watches none of shipkit's generated folders.** `.vscode/settings.json` excludes `**/.shipkit/cache/**`, `**/.shipkit/tmp/**`, `**/.shipkit/review/**` and `**/trailer/**/out/**` from `files.watcherExclude`, so the files a build, a film or a test writes never wake the extension host. It warns, and the fix pass of every `sk ci` inserts the missing globs into the hand written jsonc, every other byte kept, or writes a settings file holding the exclusion alone. A glob set to `false` stays; a root published to npm or a linked `.vscode/` is left alone. The scaffold's template carries the block.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rvlib-shipkit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0",
|
|
4
4
|
"funding": "https://github.com/sponsors/rvion",
|
|
5
5
|
"description": "All-in-one repo companion: ci gate (task DAG), auto-discovered health checks, release-contract fulfillness, asks queue, md-wiki tools, asset atelier, live tui",
|
|
6
6
|
"license": "MIT",
|
package/src/asks/asks-queue.ts
CHANGED
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync } from 'fs'
|
|
9
9
|
import { atomicWrite, mutateLease, withMutateLease } from '../core/locked-write.ts'
|
|
10
10
|
import { join } from 'path'
|
|
11
|
+
import { SECRET_NAME } from '../secrets/name.ts'
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
export type
|
|
13
|
+
/** `secrets`: the names a credential ask stores, from its `secret:` line (space or comma separated), [] for none */
|
|
14
|
+
export type Ask = { file: string; status: string; kind: string; created: string; closed: string | null; blocks: string; check: string | null; secrets: string[]; title: string }
|
|
15
|
+
export type CreateOpts = { kind?: string; blocks?: string; check?: string; why?: string; secrets?: string[] }
|
|
14
16
|
|
|
15
17
|
/** filename slug: kebab, truncated at a WORD boundary (never mid-word — a
|
|
16
18
|
* `…-rvlib-` stub reads as broken). Falls back to a hard cut only when the
|
|
@@ -34,6 +36,7 @@ const parse = (dir: string, file: string): Ask => {
|
|
|
34
36
|
closed: fm('closed'),
|
|
35
37
|
blocks: fm('blocks') ?? '-',
|
|
36
38
|
check: fm('check'),
|
|
39
|
+
secrets: (fm('secret') ?? '').split(/[\s,]+/).filter((n) => n !== ''),
|
|
37
40
|
title: md.match(/^# (.+)$/m)?.[1] ?? file,
|
|
38
41
|
}
|
|
39
42
|
}
|
|
@@ -74,12 +77,7 @@ function checkAsksBody(dir: string, print: (line: string) => void): { closed: nu
|
|
|
74
77
|
for (const a of listAsks(dir)) {
|
|
75
78
|
if (a.status === 'done') { renameSync(join(dir, a.file), join(done, a.file)); print(`archived ${a.file} → done/`); continue }
|
|
76
79
|
if (a.check == null) { print(`still ${a.status.padEnd(8)} ${a.file} (manual — no probe)`); continue }
|
|
77
|
-
|
|
78
|
-
const p = Bun.spawnSync(['bash', '-lc', a.check], { env: process.env })
|
|
79
|
-
if (p.exitCode === 0) {
|
|
80
|
-
const md = readFileSync(join(dir, a.file), 'utf8').replace(/^status:.*$/m, `status: done\nclosed: ${new Date().toISOString().slice(0, 10)}`)
|
|
81
|
-
atomicWrite(join(dir, a.file), md)
|
|
82
|
-
renameSync(join(dir, a.file), join(done, a.file))
|
|
80
|
+
if (probeAsk(dir, a, a.check).passed) {
|
|
83
81
|
print(`closed + archived ${a.file}`)
|
|
84
82
|
closed++
|
|
85
83
|
} else {
|
|
@@ -90,6 +88,37 @@ function checkAsksBody(dir: string, print: (line: string) => void): { closed: nu
|
|
|
90
88
|
return { closed }
|
|
91
89
|
}
|
|
92
90
|
|
|
91
|
+
/** one ask's probe: when it exits 0 the ask is stamped done and archived; else
|
|
92
|
+
* the probe's last stderr line says why */
|
|
93
|
+
function probeAsk(dir: string, a: Ask, check: string): { passed: true } | { passed: false; why: string } {
|
|
94
|
+
// env named: bun's default is the env the process started with, blind to a later process.env write
|
|
95
|
+
const p = Bun.spawnSync(['bash', '-lc', check], { env: process.env, stdout: 'ignore', stderr: 'pipe' })
|
|
96
|
+
if (p.exitCode !== 0) {
|
|
97
|
+
const tail = p.stderr.toString().trim().split('\n').at(-1) ?? ''
|
|
98
|
+
return { passed: false, why: `exit ${p.exitCode}${tail !== '' ? `: ${tail}` : ''}` }
|
|
99
|
+
}
|
|
100
|
+
const done = join(dir, 'done')
|
|
101
|
+
mkdirSync(done, { recursive: true })
|
|
102
|
+
const md = readFileSync(join(dir, a.file), 'utf8').replace(/^status:.*$/m, `status: done\nclosed: ${new Date().toISOString().slice(0, 10)}`)
|
|
103
|
+
atomicWrite(join(dir, a.file), md)
|
|
104
|
+
renameSync(join(dir, a.file), join(done, a.file))
|
|
105
|
+
return { passed: true }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type OneCheck = { check: 'none' } | { check: 'passed' } | { check: 'failed'; why: string }
|
|
109
|
+
|
|
110
|
+
/** `checkAsks` for one open ask: its probe alone, under the same lease */
|
|
111
|
+
export async function checkAsk(root: string, dir: string, file: string): Promise<OneCheck> {
|
|
112
|
+
const leased = await withMutateLease(mutateLease(root, 'asks'), { label: 'asks archive', print: () => {}, maxWaitMs: 45_000 }, (): OneCheck => {
|
|
113
|
+
const a = openAsks(dir).find((x) => x.file === file)
|
|
114
|
+
if (a == null) return { check: 'failed', why: `${file} is no longer an open ask` }
|
|
115
|
+
if (a.check == null) return { check: 'none' }
|
|
116
|
+
const r = probeAsk(dir, a, a.check)
|
|
117
|
+
return r.passed ? { check: 'passed' } : { check: 'failed', why: r.why }
|
|
118
|
+
})
|
|
119
|
+
return leased.ok ? leased.value : { check: 'failed', why: `the check did not run: ${leased.warn}` }
|
|
120
|
+
}
|
|
121
|
+
|
|
93
122
|
// the hub renders ask markdown, so a new ask starts as the page the human
|
|
94
123
|
// follows: one section per step, a link that opens the exact page, values
|
|
95
124
|
// to copy. Every {{placeholder}} is the author's to fill (braces, since markdown hides an unknown <tag>) before the ask ships
|
|
@@ -116,7 +145,31 @@ const DECISION_BODY = `<!-- a decision: numbered options, the recommended one fi
|
|
|
116
145
|
Reply with the number.
|
|
117
146
|
`
|
|
118
147
|
|
|
148
|
+
// a credential ask: the human mints the value, then pastes it into the field
|
|
149
|
+
// the hub draws under the ask, or into the store command's silent prompt
|
|
150
|
+
const credentialBody = (names: string[]): string => `<!-- a credential: the steps that mint the value, then the store step as written. Values in the table, buttons in bold. -->
|
|
151
|
+
|
|
152
|
+
## 1. {{verb}} {{thing}}
|
|
153
|
+
|
|
154
|
+
Open **[{{page name}}]({{url, ids filled in}})**, then click **{{button}}**, and copy the value it shows.
|
|
155
|
+
|
|
156
|
+
## 2. Store it
|
|
157
|
+
|
|
158
|
+
Paste it in the field below and click **store**. Or type ${names.length > 1 ? 'these lines' : 'this line'} in Claude Code and paste it at the silent prompt:
|
|
159
|
+
|
|
160
|
+
\`\`\`
|
|
161
|
+
${names.map((n) => `! sk secret set ${n}`).join('\n')}
|
|
162
|
+
\`\`\`
|
|
163
|
+
|
|
164
|
+
The check below then closes this ask.
|
|
165
|
+
`
|
|
166
|
+
|
|
119
167
|
export function createAsk(dir: string, title: string, opts?: CreateOpts): string {
|
|
168
|
+
const secrets = opts?.secrets ?? []
|
|
169
|
+
const bad = secrets.find((s) => !SECRET_NAME.test(s))
|
|
170
|
+
if (bad != null) throw new Error(`refusing secret name '${bad}': letters, digits and . _ @ / - only, never a leading dash`)
|
|
171
|
+
if (secrets.length > 0 && (opts?.kind ?? 'credential') !== 'credential') throw new Error(`a secret is stored by a credential ask, not a ${opts?.kind} one`)
|
|
172
|
+
opts = secrets.length > 0 ? { ...opts, kind: 'credential', check: opts?.check ?? secrets.map((s) => `sk secret get ${s} >/dev/null`).join(' && ') } : opts
|
|
120
173
|
mkdirSync(dir, { recursive: true })
|
|
121
174
|
// max numeric prefix across BOTH live and archived asks — numbers are never reused
|
|
122
175
|
const done = join(dir, 'done')
|
|
@@ -135,12 +188,12 @@ export function createAsk(dir: string, title: string, opts?: CreateOpts): string
|
|
|
135
188
|
status: open
|
|
136
189
|
kind: ${opts?.kind ?? 'action'}
|
|
137
190
|
created: ${new Date().toISOString().slice(0, 10)}
|
|
138
|
-
blocks: ${opts?.blocks ?? '-'}${check != null ? `\ncheck: ${check}` : ''}
|
|
191
|
+
blocks: ${opts?.blocks ?? '-'}${check != null ? `\ncheck: ${check}` : ''}${secrets.length > 0 ? `\nsecret: ${secrets.join(' ')}` : ''}
|
|
139
192
|
---
|
|
140
193
|
|
|
141
194
|
# ${title}
|
|
142
195
|
|
|
143
|
-
${whyBlock}${opts?.kind === 'decision' ? DECISION_BODY : STEPS_BODY}
|
|
196
|
+
${whyBlock}${opts?.kind === 'decision' ? DECISION_BODY : secrets.length > 0 ? credentialBody(secrets) : STEPS_BODY}
|
|
144
197
|
**Answer**: _(fill in / check off, or just do it — the check probe auto-closes when it passes)_
|
|
145
198
|
|
|
146
199
|
**Done when**: ${doneWhen}
|
package/src/cli/cmd_Asks.ts
CHANGED
|
@@ -62,6 +62,7 @@ export class AskNewCommand extends Command {
|
|
|
62
62
|
['minimal', 'sk ask "rotate the API token"'],
|
|
63
63
|
['with a reason', 'sk ask "buy the domain" --why "landing page is blocked on it"'],
|
|
64
64
|
['with metadata', 'sk ask "buy the domain" --kind action --blocks deploy --check "dig +short example.com"'],
|
|
65
|
+
['a token he pastes in the hub', 'sk ask "mint the npm token" --secret rv/npm/token'],
|
|
65
66
|
],
|
|
66
67
|
})
|
|
67
68
|
|
|
@@ -70,11 +71,12 @@ export class AskNewCommand extends Command {
|
|
|
70
71
|
blocks = Option.String('--blocks', { required: false, description: 'what this ask blocks (task id, page, plain words)' })
|
|
71
72
|
check = Option.String('--check', { required: false, description: 'shell probe that exits 0 once the ask is done (enables auto-close)' })
|
|
72
73
|
why = Option.String('--why', { required: false, description: 'one line of context: why this is worth a human interrupt' })
|
|
74
|
+
secret = Option.Array('--secret', { required: false, description: 'a secret name the human stores (repeat for more): a credential ask whose page takes the pasted value' })
|
|
73
75
|
|
|
74
76
|
async execute(): Promise<number> {
|
|
75
77
|
try {
|
|
76
78
|
const dir = await asksDir(process.cwd())
|
|
77
|
-
const file = createAsk(dir, this.title, { kind: this.kind, blocks: this.blocks, check: this.check, why: this.why })
|
|
79
|
+
const file = createAsk(dir, this.title, { kind: this.kind, blocks: this.blocks, check: this.check, why: this.why, secrets: this.secret ?? [] })
|
|
78
80
|
this.context.stdout.write(`created ${dir}/${file}\nfill every {{placeholder}} in it: the hub shows the body as written\n`)
|
|
79
81
|
return 0
|
|
80
82
|
} catch (e) {
|
|
@@ -8,7 +8,7 @@ import { homedir } from 'os'
|
|
|
8
8
|
import { Command, Option } from 'clipanion'
|
|
9
9
|
import { daemonPort, daemonUrl, homePort, pmPort, pmUrl } from '../home/home-paths.ts'
|
|
10
10
|
import { houseRootOf } from '../home/home-start.ts'
|
|
11
|
-
import type
|
|
11
|
+
import { ROLES, type PmAnswer, type Role } from '../home/pm.ts'
|
|
12
12
|
import type { ResourceView } from '../home/resources.ts'
|
|
13
13
|
import { coreGroup, declaredRow, groupRows, processGroups, stateWords, type ProcessGroup } from '../home/process-rows.ts'
|
|
14
14
|
import type { PmConfig } from '../home/pm-config.ts'
|
|
@@ -159,11 +159,14 @@ export class GlobalProcessesCommand extends Command {
|
|
|
159
159
|
|
|
160
160
|
export type SwitchAct = 'start' | 'stop' | 'restart'
|
|
161
161
|
|
|
162
|
+
/** what a switch follows, the same on a global process and on one of pm's own roles (the daemon, the web) */
|
|
163
|
+
export type SwitchView = Pick<ResourceView, 'status' | 'pid' | 'want' | 'note' | 'tail'>
|
|
164
|
+
|
|
162
165
|
export type SwitchDeps = {
|
|
163
166
|
/** pm's answer to the switch: null when it took it, else why not */
|
|
164
167
|
post: (id: string, act: SwitchAct | 'open' | 'chrome' | 'app') => Promise<string | null>
|
|
165
168
|
/** the process as pm sees it now, null when pm does not answer */
|
|
166
|
-
view: (id: string) => Promise<
|
|
169
|
+
view: (id: string) => Promise<SwitchView | null>
|
|
167
170
|
sleep: (ms: number) => Promise<void>
|
|
168
171
|
now: () => number
|
|
169
172
|
log: (line: string) => void
|
|
@@ -175,10 +178,13 @@ const SWITCH_POLL_MS = 1_000
|
|
|
175
178
|
/** how long the state the switch left counts as pm not having acted yet */
|
|
176
179
|
export const SWITCH_GRACE_MS = 30_000
|
|
177
180
|
|
|
178
|
-
/** flip a global process
|
|
179
|
-
* settles it: 0 once it is up (or down for stop),
|
|
180
|
-
*
|
|
181
|
+
/** flip a global process, or one of pm's own roles, through pm, then follow
|
|
182
|
+
* pm's state until its probe settles it: 0 once it is up (or down for stop),
|
|
183
|
+
* 1 otherwise. A restart is up only on a new pid: the old one still answers
|
|
184
|
+
* until pm stops it (pm stops the web after its answer is out). The
|
|
185
|
+
* launcher's exit code proves nothing, pm's probe does */
|
|
181
186
|
export async function switchProcess(id: string, act: SwitchAct, d: SwitchDeps, waitMs = SWITCH_WAIT_MS): Promise<number> {
|
|
187
|
+
const before = act === 'restart' ? ((await d.view(id))?.pid ?? null) : null
|
|
182
188
|
const refused = await d.post(id, act)
|
|
183
189
|
if (refused != null) {
|
|
184
190
|
d.log(`FAIL ${act} ${id}: ${refused}`)
|
|
@@ -199,9 +205,15 @@ export async function switchProcess(id: string, act: SwitchAct, d: SwitchDeps, w
|
|
|
199
205
|
d.log(`${id}: ${v.status}`)
|
|
200
206
|
}
|
|
201
207
|
// the state it is leaving, read just after the switch, is pm not there yet
|
|
202
|
-
const
|
|
203
|
-
const
|
|
208
|
+
const graced = d.now() - start < SWITCH_GRACE_MS
|
|
209
|
+
const leaving = v.status === (want === 'up' ? 'down' : 'up') && graced
|
|
210
|
+
const old = before != null && v.pid === before
|
|
211
|
+
const moving = v.status === 'starting' || v.status === 'stopping' || v.want !== want || leaving || (old && graced)
|
|
204
212
|
if (!moving) {
|
|
213
|
+
if (old && v.status === 'up') {
|
|
214
|
+
d.log(`FAIL ${id} still runs pid ${before} ${Math.round(SWITCH_GRACE_MS / 1000)}s after the restart: pm did not restart it`)
|
|
215
|
+
return 1
|
|
216
|
+
}
|
|
205
217
|
if (v.status === want) return 0
|
|
206
218
|
d.log(`FAIL ${id} is ${v.status}, not ${want}${v.note == null ? '' : `: ${v.note}`}`)
|
|
207
219
|
for (const l of v.tail.slice(-10)) d.log(` log: ${l}`)
|
|
@@ -215,17 +227,24 @@ export async function switchProcess(id: string, act: SwitchAct, d: SwitchDeps, w
|
|
|
215
227
|
}
|
|
216
228
|
}
|
|
217
229
|
|
|
218
|
-
|
|
230
|
+
const isRole = (id: string): id is Role => (ROLES as string[]).includes(id)
|
|
231
|
+
|
|
232
|
+
/** the switch against the running pm: pm's own roles (the daemon, the web) through its child api, every other id a
|
|
233
|
+
* global process */
|
|
219
234
|
export const pmSwitchDeps = (log: (line: string) => void, url = pmUrl()): SwitchDeps => ({
|
|
220
235
|
post: async (id, act) => {
|
|
221
236
|
try {
|
|
222
|
-
const r = await fetch(`${url}/api/pm
|
|
237
|
+
const r = await fetch(`${url}/api/pm/${isRole(id) ? 'child' : 'resource'}`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id, act }), signal: AbortSignal.timeout(5_000) })
|
|
223
238
|
return r.ok ? null : await r.text()
|
|
224
239
|
} catch (e) {
|
|
225
240
|
return `pm does not answer on ${url} (${(e as Error).message}): shipkit pm install`
|
|
226
241
|
}
|
|
227
242
|
},
|
|
228
|
-
view: async (id) =>
|
|
243
|
+
view: async (id) => {
|
|
244
|
+
const a = await askPm(url)
|
|
245
|
+
if (a == null) return null
|
|
246
|
+
return (isRole(id) ? a.children.find((c) => c.id === id) : a.resources.find((r) => r.id === id)) ?? null
|
|
247
|
+
},
|
|
229
248
|
sleep: (ms) => Bun.sleep(ms),
|
|
230
249
|
now: () => Date.now(),
|
|
231
250
|
log,
|
|
@@ -268,7 +287,11 @@ export class GlobalProcessRestartCommand extends SwitchCommand {
|
|
|
268
287
|
static override usage = Command.Usage({
|
|
269
288
|
category: 'Home',
|
|
270
289
|
description: 'restart a global process through pm and wait until its probe answers again. Exit 0 once it is up',
|
|
271
|
-
|
|
290
|
+
details: 'restart a global process, or one of pm\'s own roles (`daemon`, `web`: the same as `sk pm restart <role>`), through pm, and wait until its probe answers again. A process pm holds a pid for is up only on a new pid. Exit 0 once it is up, 1 when it crashed, kept its old pid or pm refused',
|
|
291
|
+
examples: [
|
|
292
|
+
['restart ComfyUI, so it rescans its models', 'sk gp restart comfyui'],
|
|
293
|
+
['restart the home daemon in place', 'sk gp restart daemon'],
|
|
294
|
+
],
|
|
272
295
|
})
|
|
273
296
|
}
|
|
274
297
|
|
package/src/cli/cmd_Home.ts
CHANGED
|
@@ -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'
|
|
@@ -156,8 +158,42 @@ export class PmInstallCommand extends Command {
|
|
|
156
158
|
})
|
|
157
159
|
|
|
158
160
|
async execute(): Promise<number> {
|
|
161
|
+
const root = houseRoot(process.cwd())
|
|
162
|
+
if (root == null) {
|
|
163
|
+
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`)
|
|
164
|
+
return 1
|
|
165
|
+
}
|
|
159
166
|
markAutostart(true)
|
|
160
|
-
return installHome({ root
|
|
167
|
+
return installHome({ root, cli: houseCli(root, OWN_CLI), print: io(this).print })
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export class PmRestartCommand extends Command {
|
|
172
|
+
static override paths = [['pm', 'restart']]
|
|
173
|
+
|
|
174
|
+
static override usage = Command.Usage({
|
|
175
|
+
category: 'Serve',
|
|
176
|
+
description: 'restart the daemon, the web or both through pm, and wait until each probe answers again',
|
|
177
|
+
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`',
|
|
178
|
+
examples: [
|
|
179
|
+
['the daemon reads every store and repo again', 'sk pm restart daemon'],
|
|
180
|
+
['the daemon and the web', 'sk pm restart'],
|
|
181
|
+
],
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
role = Option.String({ required: false, name: 'daemon|web' })
|
|
185
|
+
|
|
186
|
+
async execute(): Promise<number> {
|
|
187
|
+
if (this.role != null && !(ROLES as string[]).includes(this.role)) {
|
|
188
|
+
this.context.stderr.write(`FAIL: '${this.role}' is no pm role: ${ROLES.join(' or ')}; a global process restarts with \`sk gp restart <id>\`\n`)
|
|
189
|
+
return 2
|
|
190
|
+
}
|
|
191
|
+
const deps = pmSwitchDeps(io(this).print)
|
|
192
|
+
for (const role of this.role == null ? ROLES : [this.role]) {
|
|
193
|
+
const code = await switchProcess(role, 'restart', deps)
|
|
194
|
+
if (code !== 0) return code
|
|
195
|
+
}
|
|
196
|
+
return 0
|
|
161
197
|
}
|
|
162
198
|
}
|
|
163
199
|
|
package/src/cli/cmd_Secret.ts
CHANGED
|
@@ -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
|
|
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 =
|
|
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
|
}
|
package/src/cli/cmd_Social.ts
CHANGED
|
@@ -187,6 +187,45 @@ class SocialMigrateCommand extends Command {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
class SocialDiscordApplyCommand extends Command {
|
|
191
|
+
static override paths = [['social', 'discord', 'apply']]
|
|
192
|
+
static override usage = Command.Usage({
|
|
193
|
+
category: 'Social',
|
|
194
|
+
description: "an identity's Discord server made to match its layout.md through its bot: roles, channels",
|
|
195
|
+
details:
|
|
196
|
+
"The layout is `layout.md` beside the identity's discord `account.md`, which names the server (`guild`) and the bot's token (`secret`). It creates, renames, moves, sets topics, read only, age restricted and role only channels; a server that matches gets no write. It never deletes but with --prune, and then only an empty text channel the layout lacks. With no guild yet, it names the servers the bot is in. Page: wiki tools/shipkit/social-identities.md, The server's layout",
|
|
197
|
+
examples: [
|
|
198
|
+
['what would change', 'sk social discord apply studio --dry'],
|
|
199
|
+
['as this repo speaks', 'sk social discord apply'],
|
|
200
|
+
['and delete the empty channels it lacks', 'sk social discord apply studio --prune'],
|
|
201
|
+
],
|
|
202
|
+
})
|
|
203
|
+
identity = Option.String({ required: false })
|
|
204
|
+
dry = Option.Boolean('--dry', false, { description: 'print what would change, write nothing' })
|
|
205
|
+
prune = Option.Boolean('--prune', false, { description: 'delete an empty text channel the layout lacks' })
|
|
206
|
+
override async execute(): Promise<number> {
|
|
207
|
+
return guarded(this.context, async () => {
|
|
208
|
+
const { loadIdentities, identityOf, speakerOf } = await import('../identities/identities.ts')
|
|
209
|
+
const { applyLayout } = await import('../social/discord-layout.ts')
|
|
210
|
+
const ids = await loadIdentities()
|
|
211
|
+
let id = this.identity
|
|
212
|
+
if (id == null) {
|
|
213
|
+
const { findRepoRoot } = await import('../ts/config.ts')
|
|
214
|
+
const { loadRepoConfig } = await import('../repo-config.ts')
|
|
215
|
+
id = speakerOf((await loadRepoConfig(findRepoRoot(process.cwd()))).speaksAs, ids)?.id
|
|
216
|
+
if (id == null) throw new Error('no identity named and none this repo speaks as')
|
|
217
|
+
}
|
|
218
|
+
const a = identityOf(id, ids).accounts.find((x) => x.id === 'discord')
|
|
219
|
+
if (a == null) throw new Error(`${id} has no discord account (accounts/discord/account.md)`)
|
|
220
|
+
const r = await applyLayout(a, { dry: this.dry, prune: this.prune })
|
|
221
|
+
for (const l of r.changes) say(this.context)(l)
|
|
222
|
+
if (r.changes.length === 0) say(this.context)(`ok: the server of ${id} matches its layout`)
|
|
223
|
+
for (const l of r.left) say(this.context)(`left alone: ${l}`)
|
|
224
|
+
return 0
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
190
229
|
class IdentitiesCommand extends Command {
|
|
191
230
|
static override paths = [['identities']]
|
|
192
231
|
static override usage = Command.Usage({
|
|
@@ -233,4 +272,4 @@ class IdentitiesCommand extends Command {
|
|
|
233
272
|
}
|
|
234
273
|
}
|
|
235
274
|
|
|
236
|
-
export const SOCIAL_COMMANDS = [SocialCommand, SocialTimelineCommand, SocialCoverageCommand, SocialPostCommand, SocialPlanCommand, SocialStateCommand, SocialMigrateCommand, IdentitiesCommand]
|
|
275
|
+
export const SOCIAL_COMMANDS = [SocialCommand, SocialTimelineCommand, SocialCoverageCommand, SocialPostCommand, SocialPlanCommand, SocialStateCommand, SocialMigrateCommand, SocialDiscordApplyCommand, IdentitiesCommand]
|
package/src/cli/cmd_Trailer.ts
CHANGED
|
@@ -36,6 +36,8 @@ export class TrailerCommand extends Command {
|
|
|
36
36
|
['film again the takes of two shots', 'sk trailer --refilm intro,menu'],
|
|
37
37
|
['encoded by x264 for a release', 'sk trailer --final'],
|
|
38
38
|
['the music variant b on the same picture', 'sk trailer --variant b'],
|
|
39
|
+
['a quick draft to judge the beats', 'sk trailer --draft'],
|
|
40
|
+
['where the build spends its time', 'sk trailer --profile'],
|
|
39
41
|
],
|
|
40
42
|
})
|
|
41
43
|
|
|
@@ -43,13 +45,23 @@ export class TrailerCommand extends Command {
|
|
|
43
45
|
refilm = Option.String('--refilm', { tolerateBoolean: true, description: 'film again: every stale take, or the named shots (a,b)' })
|
|
44
46
|
final = Option.Boolean('--final', false, { description: 'encode with x264 for a release (default: the fast draft encoder)' })
|
|
45
47
|
variant = Option.String('--variant', { description: 'a music variant the cut names (music … variant <name>): out/<name>-<variant>.mp4' })
|
|
48
|
+
draft = Option.Boolean('--draft', false, { description: 'a quick draft at half the size: out/<name>-draft.mp4, the cut\'s takes read as they are, a missing one filmed small, no strip' })
|
|
49
|
+
strip = Option.Boolean('--strip', false, { description: 'with --draft: its strip too' })
|
|
50
|
+
profile = Option.Boolean('--profile', false, { description: 'print every phase of the build with its start, seconds and share' })
|
|
46
51
|
|
|
47
52
|
async execute(): Promise<number> {
|
|
48
53
|
return run(this.context, async (say, root, cwd) => {
|
|
49
|
-
const
|
|
50
|
-
|
|
54
|
+
const { span, timed, profileLines } = await import('../trailer/profile.ts')
|
|
55
|
+
span('start: bun, sk, the cli', 0, performance.now())
|
|
56
|
+
const b = await timed('load: build modules', () => import('../trailer/build.ts'))
|
|
57
|
+
const l = await timed('load: parse and check', () => b.load(b.trailerFile(this.file, root, cwd), root, this.variant !== undefined ? { variant: this.variant } : {}))
|
|
51
58
|
if (!b.sayErrors(l, say, cwd)) return 1
|
|
52
|
-
|
|
59
|
+
try {
|
|
60
|
+
const draft = this.draft ? { draft: (await import('../trailer/draft.ts')).DRAFT, strip: this.strip } : {}
|
|
61
|
+
await b.build(l, { refilm: refilmOf(this.refilm), final: this.final, say, cwd, ...draft })
|
|
62
|
+
} finally {
|
|
63
|
+
if (this.profile) for (const line of profileLines()) say(line)
|
|
64
|
+
}
|
|
53
65
|
return 0
|
|
54
66
|
})
|
|
55
67
|
}
|
package/src/cli/registry.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { CiCommand } from './cmd_Ci.ts'
|
|
|
24
24
|
import { ContractsCommand } from './cmd_Contracts.ts'
|
|
25
25
|
import { FleetCommand } from './cmd_Fleet.ts'
|
|
26
26
|
import { FleetPushCommand } from './cmd_FleetPush.ts'
|
|
27
|
-
import { DaemonCommand, DaemonJobCommand, GuiCommand, PmCommand, PmInstallCommand, PmUninstallCommand, WebCommand } from './cmd_Home.ts'
|
|
27
|
+
import { DaemonCommand, DaemonJobCommand, GuiCommand, PmCommand, PmInstallCommand, PmRestartCommand, PmUninstallCommand, WebCommand } from './cmd_Home.ts'
|
|
28
28
|
import { HooksCommitMsgCommand, HooksInstallCommand, HooksListCommand, HooksPreCommitCommand } from './cmd_Hooks.ts'
|
|
29
29
|
import { InitCommand } from './cmd_Init.ts'
|
|
30
30
|
import { KeysCommand } from './cmd_Keys.ts'
|
|
@@ -102,6 +102,7 @@ export function buildCli(): Cli {
|
|
|
102
102
|
cli.register(WebCommand)
|
|
103
103
|
cli.register(PmInstallCommand)
|
|
104
104
|
cli.register(PmUninstallCommand)
|
|
105
|
+
cli.register(PmRestartCommand)
|
|
105
106
|
cli.register(GuiCommand)
|
|
106
107
|
cli.register(ContractsCommand)
|
|
107
108
|
cli.register(AsksCommand)
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
// repo's diff shows it; Feedback appends are append-only, never destructive).
|
|
4
4
|
import { existsSync, readFileSync, writeFileSync } from 'fs'
|
|
5
5
|
import { join } from 'path'
|
|
6
|
-
import { archiveAsk, proofAsk } from '../asks/asks-queue.ts'
|
|
6
|
+
import { archiveAsk, checkAsk, openAsks, proofAsk, type OneCheck } from '../asks/asks-queue.ts'
|
|
7
|
+
import { redact, type SecretStore } from '../secrets/manager.ts'
|
|
8
|
+
import { SECRET_NAME } from '../secrets/name.ts'
|
|
7
9
|
|
|
8
10
|
const today = (): string => new Date().toISOString().slice(0, 10)
|
|
9
11
|
|
|
@@ -35,3 +37,29 @@ export function askProof(root: string, asksDir: string, file: string, url: strin
|
|
|
35
37
|
if (file.includes('/') || file.includes('..')) throw new Error('bad path')
|
|
36
38
|
proofAsk(join(root, asksDir), file, url)
|
|
37
39
|
}
|
|
40
|
+
|
|
41
|
+
export type SecretAnswer = { stored: string } & OneCheck
|
|
42
|
+
|
|
43
|
+
/** a value pasted under a credential ask: stored under a name that open ask
|
|
44
|
+
* declares, then that ask's check alone. Its truth is the keychain, never a
|
|
45
|
+
* file: the value is not written, logged or answered, and a failure line has
|
|
46
|
+
* it replaced by ‹value› */
|
|
47
|
+
export async function askSecret(o: { root: string; asksDir: string; file: string; name: string; value: string; store: SecretStore }): Promise<SecretAnswer> {
|
|
48
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*\.md$/.test(o.file)) throw new Error('bad path')
|
|
49
|
+
const dir = join(o.root, o.asksDir)
|
|
50
|
+
const ask = openAsks(dir).find((a) => a.file === o.file)
|
|
51
|
+
if (ask == null) throw new Error(`no open ask ${o.file}`)
|
|
52
|
+
if (ask.kind !== 'credential') throw new Error(`${o.file} is a ${ask.kind} ask: only a credential ask stores a secret`)
|
|
53
|
+
if (!SECRET_NAME.test(o.name) || !ask.secrets.includes(o.name)) throw new Error(`${o.file} declares no secret named ${o.name}`)
|
|
54
|
+
const value = o.value.trim()
|
|
55
|
+
if (value === '') throw new Error('empty value: nothing stored')
|
|
56
|
+
let c: OneCheck
|
|
57
|
+
try {
|
|
58
|
+
const r = await o.store(o.name, value)
|
|
59
|
+
if (!r.ok) throw new Error(`${o.name} not stored: ${r.why}`)
|
|
60
|
+
c = await checkAsk(o.root, dir, o.file)
|
|
61
|
+
} catch (e) {
|
|
62
|
+
throw new Error(redact((e as Error).message, value))
|
|
63
|
+
}
|
|
64
|
+
return c.check === 'failed' ? { stored: o.name, check: 'failed', why: redact(c.why, value) } : { stored: o.name, ...c }
|
|
65
|
+
}
|
|
@@ -187,6 +187,8 @@ export type AskFacts = {
|
|
|
187
187
|
blocks: string
|
|
188
188
|
/** the shell probe that closes it once it exits 0, null for a manual ask */
|
|
189
189
|
probe: string | null
|
|
190
|
+
/** the secret names a credential ask stores: its page takes each pasted value */
|
|
191
|
+
secrets: string[]
|
|
190
192
|
}
|
|
191
193
|
|
|
192
194
|
/** one test file, as its row and its page read it */
|
|
@@ -121,7 +121,7 @@ const slug = (t: string): string => t.toLowerCase().replace(/[^a-z0-9]+/g, '-').
|
|
|
121
121
|
/** wire lines re-rendered as a fenced block for an instance's md */
|
|
122
122
|
const wireMd = (lines: string[]): string => `\`\`\`\n${lines.join('\n')}\n\`\`\``
|
|
123
123
|
|
|
124
|
-
const askFacts = (a: Ask): AskFacts => ({ kind: a.kind, created: a.created, closed: a.closed, blocks: a.blocks, probe: a.check })
|
|
124
|
+
const askFacts = (a: Ask): AskFacts => ({ kind: a.kind, created: a.created, closed: a.closed, blocks: a.blocks, probe: a.check, secrets: a.kind === 'credential' ? a.secrets : [] })
|
|
125
125
|
|
|
126
126
|
export function asksCollection(root: string, c: RepoConfig): Collection {
|
|
127
127
|
return {
|
package/src/home/home-paths.ts
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
// Nothing here lives in a repo: the home is per machine, and a repo that is
|
|
3
3
|
// cloned elsewhere carries none of it.
|
|
4
4
|
import { homedir } from 'os'
|
|
5
|
-
import { join } from 'path'
|
|
5
|
+
import { dirname, join } from 'path'
|
|
6
|
+
import { gitRoot } from '../core/git-root.ts'
|
|
7
|
+
|
|
8
|
+
/** the house repo: the checkout that holds the house wiki index, the one root pm and the daemon run from */
|
|
9
|
+
export const houseOfIndex = (index: string): string | null => gitRoot(dirname(index))?.top ?? null
|
|
6
10
|
|
|
7
11
|
/** just below the hashed hub range (4800-4979), so no repo hub can hash onto it */
|
|
8
12
|
export const DEFAULT_HOME_PORT = 4799
|
package/src/home/home-start.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
// serve handoff both come through here.
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync } from 'fs'
|
|
5
5
|
import { homedir } from 'os'
|
|
6
|
-
import {
|
|
7
|
-
import { gitRoot } from '../core/git-root.ts'
|
|
6
|
+
import { join, resolve } from 'path'
|
|
8
7
|
import { homeRepo, houseIndex } from '../serve/project-gutter.ts'
|
|
9
8
|
import type { WrapperOf } from './gui-app.ts'
|
|
10
9
|
|
|
@@ -12,7 +11,7 @@ import type { WrapperOf } from './gui-app.ts'
|
|
|
12
11
|
// at the startup of every command that imports this module
|
|
13
12
|
const gui = (): Promise<typeof import('./gui-app.ts')> => import('./gui-app.ts')
|
|
14
13
|
import { installedHouseRoot, LABEL, plistPath } from './home-launchd.ts'
|
|
15
|
-
import { childLog, daemonPort, daemonUp, homeDir, homePort, homeUp, pmLog } from './home-paths.ts'
|
|
14
|
+
import { childLog, daemonPort, daemonUp, homeDir, homePort, homeUp, houseOfIndex, pmLog } from './home-paths.ts'
|
|
16
15
|
|
|
17
16
|
/** the pm LaunchAgent is installed: on this machine no hub runs outside the home */
|
|
18
17
|
export const homeInstalled = (): boolean => existsSync(plistPath())
|
|
@@ -62,16 +61,17 @@ export function houseCli(root: string, own: string): string {
|
|
|
62
61
|
return own
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
/** the repo that hosts the house wiki, seen from any house repo, or null */
|
|
66
|
-
export function houseRootOf(cwd: string): string | null {
|
|
67
|
-
const index = houseIndex(homeRepo(cwd),
|
|
68
|
-
|
|
69
|
-
return gitRoot(dirname(index))?.top ?? null
|
|
64
|
+
/** the repo that hosts the house wiki, seen from any folder of any house repo, or null */
|
|
65
|
+
export function houseRootOf(cwd: string, home = homedir()): string | null {
|
|
66
|
+
const index = houseIndex(homeRepo(cwd), home)
|
|
67
|
+
return index == null ? null : houseOfIndex(index)
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
/** the house
|
|
73
|
-
*
|
|
74
|
-
|
|
70
|
+
/** the house this machine runs: the one cwd sits in, else the one the
|
|
71
|
+
* installed pm runs from. Never cwd itself: a daemon run from a folder
|
|
72
|
+
* inside a repo finds no repo config there and never boots. The pm agent's
|
|
73
|
+
* root and the shipkit app's mark */
|
|
74
|
+
export const houseRoot = (cwd: string, o: { plist?: string; home?: string } = {}): string | null => houseRootOf(cwd, o.home) ?? installedHouseRoot(o.plist ?? plistPath())
|
|
75
75
|
|
|
76
76
|
export const CHROME =process.env.CHROME ?? '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
|
|
77
77
|
/** the window's own Chrome profile: its own dock icon and cookies, apart from the everyday browser */
|
|
@@ -96,7 +96,7 @@ export async function openWindow(url: string, o: { root?: string | null; version
|
|
|
96
96
|
const { BUNDLE_ID, canBuildGui, ensureGuiApp, quitCmd } = await gui()
|
|
97
97
|
if (canBuildGui()) {
|
|
98
98
|
try {
|
|
99
|
-
const { app, rebuilt } = await ensureGuiApp({ root: o.root ??
|
|
99
|
+
const { app, rebuilt } = await ensureGuiApp({ root: o.root ?? houseRoot(process.cwd()), version: o.version ?? '0' })
|
|
100
100
|
// a running copy is the old build: it quits, and the new one opens the window
|
|
101
101
|
if (rebuilt) Bun.spawnSync(quitCmd(BUNDLE_ID), { stdout: 'ignore', stderr: 'ignore' })
|
|
102
102
|
const cmd = ['open', '-a', app, url]
|