rvlib-shipkit 2.16.0 → 2.17.1
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 +21 -0
- package/package.json +1 -1
- package/src/assets/kit-config.ts +19 -1
- package/src/assets/run-assets.ts +18 -0
- package/src/cli/cmd_Review.ts +26 -7
- package/src/cli/cmd_Secret.ts +127 -0
- package/src/cli/cmd_Wiki.ts +4 -4
- package/src/cli/family-pages.ts +1 -0
- package/src/cli/registry.ts +4 -0
- package/src/core/discover-checks.ts +18 -5
- package/src/core/scope.ts +42 -0
- package/src/home/beat.ts +30 -0
- package/src/home/home-paths.ts +1 -0
- package/src/home/pm.ts +3 -1
- package/src/home/run-daemon.ts +5 -2
- package/src/home/run-web.ts +4 -2
- package/src/home/supervise.ts +18 -1
- package/src/repo-config.ts +3 -0
- package/src/review/auto.ts +7 -2
- package/src/review/cells.ts +1 -1
- package/src/review/format.ts +2 -2
- package/src/review/model.ts +57 -13
- package/src/review/previews.ts +1 -1
- package/src/review/routes.ts +11 -0
- package/src/review/store.ts +18 -10
- package/src/secrets/list.ts +40 -0
- package/src/serve/hub-app/hub-app.tsx +28 -2
- package/src/serve/hub-app/icons.tsx +1 -0
- package/src/serve/hub-app/identities-view.tsx +1 -1
- package/src/serve/hub-app/kept-cols.tsx +47 -8
- package/src/serve/hub-app/layout-st.ts +37 -3
- package/src/serve/hub-app/review/review-kit.ts +12 -0
- package/src/serve/hub-app/review/review-page.tsx +1 -1
- package/src/serve/hub-app/review/review-st.ts +63 -4
- package/src/serve/hub-app/review/review-thread.tsx +1 -0
- package/src/serve/hub-app/review/review-views.tsx +215 -63
- package/src/serve/hub-app/review/thread-st.ts +82 -16
- package/src/serve/hub-app/review/trailer-page.tsx +1 -1
- package/src/serve/hub-app/review.css +41 -2
- package/src/serve/hub-app/social/comms-page.tsx +1 -1
- package/src/serve/hub-app/social/social-page.tsx +1 -1
- package/src/serve/hub-app/stores/stores-page.tsx +1 -1
- package/src/serve/hub-app/veille/veille-page.tsx +1 -1
- package/src/shipkit.ts +1 -1
- package/src/shot/box.ts +9 -1
- package/src/shot/shooter.ts +24 -2
- package/src/social/load.ts +3 -1
- package/src/trailer/grammar.ts +2 -0
- package/src/trailer/sound/presets.ts +3 -3
- package/src/trailer/sound/run.ts +22 -14
- package/src/trailer/titles.ts +1 -1
- package/src/wiki/lint-md.ts +4 -2
- package/src/wiki/run-wiki.ts +22 -6
- package/src/wiki/scan-md.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## 2.17.1
|
|
2
|
+
|
|
3
|
+
- **A `big` title keeps the cut's line breaks.** Each `\n` starts a line, and a line wider than the frame still wraps; the lines used to be joined and wrapped wherever the width fell.
|
|
4
|
+
- **A sound made on another machine never waits on the local load.** A `SoundRun` says `remote: true` when its work runs elsewhere; the voice, sfx and music presets set it, so an ElevenLabs line or a comfy box generation starts at once. FluidSynth and a hand written run still wait while the load is over 16.
|
|
5
|
+
- **A sign in survives the warm shooter's context swaps.** The cookies of a closed context (another viewport, a clip, the idle close) pass to the next one, in memory only.
|
|
6
|
+
- **The md scan skips a link to nothing** instead of crashing `sk wiki lint`.
|
|
7
|
+
- **`sk wiki lint` no longer calls `agent/global-contribution.md` an orphan**: the house index lists it.
|
|
8
|
+
- **A draft for an identity with no account yet loads.** `## short` and `## vertical` are always valid headings; the draft waits and posts nowhere.
|
|
9
|
+
- **`sk review add` warns when no watch hears the new card**, and names the one that would (`--mine`, `--lane <id>`). Only a watch of the card's own session or lane counts.
|
|
10
|
+
|
|
11
|
+
## 2.17.0
|
|
12
|
+
|
|
13
|
+
- **`sk secret` lists the secrets of the repo you stand in.** `sk secret list` reads the house's creds and the repo's own, keeps the ones whose new `for` scope (`{ repos, identities }`, absent for every repo) names this repo, by its config name or its folder, or the identity it speaks as, and marks each `ok` or `MISS` through `credsReadCommand`, never printing a value; `--all` keeps the rest, marked `out`. `sk secret get|account <name>` and `sk secret set <name> [account]` go through the same `credsReadCommand` and `credsCommand` templates. A list, not an access control.
|
|
14
|
+
- **A review card can be a gallery rated tile by tile.** `sk review add --gallery "<label>" <name>=a.png …` draws one tile an image at one size for the whole card; a tile carries its before (`<name>=old.png,new.png`), variants draw as rows (`<asset>/<variant>=a.png`), a filter narrows the tiles, and a spot can be circled on any tile.
|
|
15
|
+
- **A card's downloads copy a public link.** Each file gets a « copy link » button that keeps it in the media store's public folder by its content and copies the URL.
|
|
16
|
+
- **A clip pair never decodes as an image.** The pixel diff mode applies to image pairs only; a clip pair draws side by side, where WebKit used to stall decoding an mp4 as an image.
|
|
17
|
+
- **`sk wiki lint` and `sk wiki serve` with no `--root` take the repo's wiki** (`wiki/`, else the agent folder, else the cwd), so refs written relative to the wiki folder resolve.
|
|
18
|
+
- **A `brand.ts` that throws blocks the identity outputs, never the hub.**
|
|
19
|
+
- **`svg(file)` makes a hand drawn svg file an asset or identity mark.** `mark: svg(new URL('./mark.svg', import.meta.url))` renders the file as a vector, fitted and centred, never stretched, with no box and no canvas copy of the shape; a relative path fails at declaration and a missing file fails at render, each naming the fix.
|
|
20
|
+
- **A review auto rule never writes into a repo that moved away.** After a rename, the old hub's timer raised a card into the old path and recreated its folder; a run now refuses when the store's repo folder is gone, and its timer stops.
|
|
21
|
+
|
|
1
22
|
## 2.16.0
|
|
2
23
|
|
|
3
24
|
- **A drill runs cold in a sealed copy.** `sk drill clone <task folder>` makes a copy of the repo with no way back to it and prints the headless command that runs it, `sk drill finish <copy>` records the run (patch, report, leaks, done command) and trashes the copy, `sk drill calibrate` proves the card's done command fails on the base and passes on the reference, and `sk drill compare` says keep or revert, never keeping an unjudged or worse run.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rvlib-shipkit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.1",
|
|
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/assets/kit-config.ts
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
// everything else. STRUCTURE lives here (git-reviewed TS); studio-edited
|
|
4
4
|
// state lives in the workspace overlays (pick.json, prompt.json, *.rect.json).
|
|
5
5
|
// Kit edits need a studio restart; prompt tweaks don't (overlay).
|
|
6
|
+
import type { SKRSContext2D } from '@napi-rs/canvas'
|
|
6
7
|
import { existsSync } from 'fs'
|
|
7
|
-
import { join } from 'path'
|
|
8
|
+
import { isAbsolute, join } from 'path'
|
|
9
|
+
import { fileURLToPath } from 'url'
|
|
8
10
|
import type { alphaHeight, toPng } from './image-ops.ts'
|
|
9
11
|
import type { GroundRect } from './panels/geometry-rects.ts'
|
|
10
12
|
|
|
@@ -34,6 +36,22 @@ export type GeminiGen = { backend: 'gemini'; model?: 'flash' | 'pro' }
|
|
|
34
36
|
export type GeneratorSpec = ComfyGen | CanvasGen | ManualGen | GeminiGen
|
|
35
37
|
export const comfy = (p?: { workflow?: string; vars?: Record<string, unknown> }): ComfyGen => ({ backend: 'comfy', workflow: p?.workflow, vars: p?.vars })
|
|
36
38
|
export const canvas = (draw: CanvasGen['draw']): CanvasGen => ({ backend: 'canvas', draw })
|
|
39
|
+
/** a hand-drawn svg file as a canvas kind: vector, fitted and centred in the target, never stretched.
|
|
40
|
+
* `svg(new URL('./icon.svg', import.meta.url))` resolves beside the kit file, never against the cwd */
|
|
41
|
+
export const svg = (file: URL | string): CanvasGen => {
|
|
42
|
+
const path = file instanceof URL ? fileURLToPath(file) : file
|
|
43
|
+
if (!isAbsolute(path)) throw new Error(`svg('${path}'): give an absolute path or new URL('./<file>.svg', import.meta.url)`)
|
|
44
|
+
return canvas(async (ctx) => {
|
|
45
|
+
if (!existsSync(path)) throw new Error(`svg mark: ${path} not found`)
|
|
46
|
+
const { loadImage } = await import('@napi-rs/canvas')
|
|
47
|
+
const c = ctx as SKRSContext2D
|
|
48
|
+
const img = await loadImage(path)
|
|
49
|
+
const k = Math.min(c.canvas.width / img.width, c.canvas.height / img.height)
|
|
50
|
+
const w = img.width * k
|
|
51
|
+
const h = img.height * k
|
|
52
|
+
c.drawImage(img, (c.canvas.width - w) / 2, (c.canvas.height - h) / 2, w, h)
|
|
53
|
+
})
|
|
54
|
+
}
|
|
37
55
|
export const manual = (): ManualGen => ({ backend: 'manual' })
|
|
38
56
|
export const gemini = (p?: { model?: 'flash' | 'pro' }): GeminiGen => ({ backend: 'gemini', model: p?.model })
|
|
39
57
|
|
package/src/assets/run-assets.ts
CHANGED
|
@@ -140,7 +140,25 @@ export async function identityLogo(root: string): Promise<string | null> {
|
|
|
140
140
|
return existsSync(join(root, file)) ? file : null
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
/** the repo's own brand.ts threw (an import, a draw): its identity is
|
|
144
|
+
* blocked, never a fault of the hub that listed it */
|
|
143
145
|
export async function renderIdentityNow(root: string): Promise<IdentityRender> {
|
|
146
|
+
try {
|
|
147
|
+
return await renderBrand(root)
|
|
148
|
+
} catch (e) {
|
|
149
|
+
return { blocked: `.shipkit/identity/brand.ts failed: ${brandFault(e)}` }
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** @napi-rs/canvas loadImage takes a path it cannot find for a remote url,
|
|
154
|
+
* so a deleted image reads as 'Invalid URL' */
|
|
155
|
+
const brandFault = (e: unknown): string => {
|
|
156
|
+
const err = e as { code?: string; input?: string; message?: string }
|
|
157
|
+
if (err.code === 'ERR_INVALID_URL' && typeof err.input === 'string' && !/^[a-z]+:/i.test(err.input)) return `an image it loads is missing: ${err.input}`
|
|
158
|
+
return err.message ?? String(e)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function renderBrand(root: string): Promise<IdentityRender> {
|
|
144
162
|
const brand = await loadBrand(root)
|
|
145
163
|
if (brand == null) return { blocked: 'no .shipkit/identity/brand.ts — create one exporting a Brand (name, palette, mark)' }
|
|
146
164
|
if (typeof brand === 'string') return { blocked: brand }
|
package/src/cli/cmd_Review.ts
CHANGED
|
@@ -74,17 +74,29 @@ async function pull(h: Here): Promise<void> {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/** a gallery tile as given: `<label>=<file>`, or a file labelled by its name */
|
|
77
|
-
|
|
77
|
+
/** one tile of `--gallery`: `[<row>/]<label>=[<before>,]<after>`, or a bare file named by its own name */
|
|
78
|
+
export function tileOf(arg: string): { file: string; label: string; before?: string; group?: string } {
|
|
78
79
|
const eq = arg.lastIndexOf('=')
|
|
79
|
-
if (eq
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
if (eq <= 0) {
|
|
81
|
+
const name = arg.split('/').pop() ?? arg
|
|
82
|
+
return { file: arg, label: name.replace(/\.[a-z0-9]+$/i, '') }
|
|
83
|
+
}
|
|
84
|
+
const name = arg.slice(0, eq)
|
|
85
|
+
const files = arg.slice(eq + 1).split(',')
|
|
86
|
+
if (files.length > 2 || files.some((f) => f === '')) throw new Error(`--gallery tile ${arg}: <label>=<after.png>, or <label>=<before.png>,<after.png>`)
|
|
87
|
+
const slash = name.indexOf('/')
|
|
88
|
+
return {
|
|
89
|
+
label: slash > 0 ? name.slice(slash + 1) : name,
|
|
90
|
+
file: files.at(-1) ?? '',
|
|
91
|
+
...(files.length === 2 ? { before: files[0] } : {}),
|
|
92
|
+
...(slash > 0 ? { group: name.slice(0, slash) } : {}),
|
|
93
|
+
}
|
|
82
94
|
}
|
|
83
95
|
|
|
84
96
|
type ViewInput = import('../review/store.ts').ViewInput
|
|
85
97
|
|
|
86
98
|
/** `--view "<label>" a.png [b.png] [--note "<text>"]` and `--gallery "<label>" a.png b.png …` out of the args */
|
|
87
|
-
function takeViews(args: readonly string[]): { views: ViewInput[]; rest: string[] } {
|
|
99
|
+
export function takeViews(args: readonly string[]): { views: ViewInput[]; rest: string[] } {
|
|
88
100
|
const views: ViewInput[] = []
|
|
89
101
|
const rest: string[] = []
|
|
90
102
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -96,7 +108,9 @@ function takeViews(args: readonly string[]): { views: ViewInput[]; rest: string[
|
|
|
96
108
|
const label = args[i + 1]
|
|
97
109
|
const files: string[] = []
|
|
98
110
|
for (let j = i + 2; j < args.length && (a === '--gallery' || files.length < 2) && !(args[j] ?? '').startsWith('--'); j++) files.push(args[j] ?? '')
|
|
99
|
-
|
|
111
|
+
// a label that names a media file is a forgotten label: the first image would silently become it
|
|
112
|
+
const fileLike = label !== undefined && /\.(png|jpe?g|webp|gif|mp4|webm|wav|mp3|flac|ogg|opus|m4a)$/i.test(label)
|
|
113
|
+
if (label === undefined || label.startsWith('--') || fileLike || files.length === 0) throw new Error(a === '--gallery' ? '--gallery "<label>" a.png b.png …: a label, then its images' : '--view "<label>" a.png [b.png]: a label, then an image or a before and an after')
|
|
100
114
|
if (a === '--gallery') views.push({ label, gallery: files.map(tileOf) })
|
|
101
115
|
else views.push(files.length === 1 ? { label, image: files[0] } : { label, before: files[0], after: files[1] })
|
|
102
116
|
i += 1 + files.length
|
|
@@ -148,7 +162,7 @@ const ADD_FLAGS = `flags:
|
|
|
148
162
|
--label "<label>" the first view's label
|
|
149
163
|
--view "<label>" <a.png> [<b.png>] another view of the same subject (repeat it); --note "<text>" right after it: a line on that view
|
|
150
164
|
--choice every view is an option he scores and picks one of (two --view or more)
|
|
151
|
-
--gallery "<label>" <a.png> … a grid
|
|
165
|
+
--gallery "<label>" <a.png> … a grid he rates tile by tile (stars, OK, fix or no, a word), alone or beside other views; a tile is "[<row>/]<label>=[<before>,]<after>": a redraw carries its before, a row holds one asset's variants
|
|
152
166
|
--topic <topic> what part of the project it is about (sk review topics)
|
|
153
167
|
--subject <kind> what is judged (default shot; the repo's unit names its kinds)
|
|
154
168
|
--commit <sha> the commit it shows
|
|
@@ -182,6 +196,7 @@ export class ReviewAddCommand extends Command {
|
|
|
182
196
|
['a before and after', 'sk review add --title "lamps lit" --what "..." --before a.png --after b.png'],
|
|
183
197
|
['a second version after his answer', 'sk review add --title "lamps lit" --what "..." --image c.png --supersedes <id>'],
|
|
184
198
|
['a pick among three voices', 'sk review add --choice --title "the narrator" --what "..." --view "voice 0" a.flac --note "low, breathy" --view "voice 1" b.flac --view "voice 2" c.flac'],
|
|
199
|
+
['icons he rates one by one', 'sk review add --title "buff icons" --what "..." --gallery "icons" vitality=a.png haste=b.png greed=c.png'],
|
|
185
200
|
],
|
|
186
201
|
})
|
|
187
202
|
args = Option.Proxy()
|
|
@@ -237,6 +252,10 @@ export class ReviewAddCommand extends Command {
|
|
|
237
252
|
const item = await addItem(h.dir, input)
|
|
238
253
|
h.out(item.id)
|
|
239
254
|
if (item.origin.by === 'agent' && !item.origin.lane) h.err('no lane on the card: pass --lane <id> (or SK_AGENT), so the hub colours it')
|
|
255
|
+
const { unheardLine } = await import('../review/model.ts')
|
|
256
|
+
const { liveWatchers } = await import('../review/watchers.ts')
|
|
257
|
+
const unheard = unheardLine(item, liveWatchers(h.dir))
|
|
258
|
+
if (unheard) h.err(unheard)
|
|
240
259
|
return 0
|
|
241
260
|
})
|
|
242
261
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// shipkit secret — the secrets of the repo you stand in, and the reads and
|
|
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`.
|
|
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
|
+
import { presence, secretsFor } from '../secrets/list.ts'
|
|
12
|
+
import { secretArgv } from '../smoke/run-smoke.ts'
|
|
13
|
+
|
|
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
|
+
/** runs a verb, printing a refusal as its one line */
|
|
36
|
+
async function refusing(stderr: NodeJS.WritableStream, run: () => Promise<number>): Promise<number> {
|
|
37
|
+
try {
|
|
38
|
+
return await run()
|
|
39
|
+
} catch (e) {
|
|
40
|
+
if (!(e instanceof Refused)) throw e
|
|
41
|
+
stderr.write(`${e.message}\n`)
|
|
42
|
+
return 1
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class SecretListCommand extends Command {
|
|
47
|
+
static override paths = [['secret', 'list'], ['secret']]
|
|
48
|
+
|
|
49
|
+
static override usage = Command.Usage({
|
|
50
|
+
category: 'Secrets',
|
|
51
|
+
description: "the secrets for this repo: its own, its identity's, then those for every repo",
|
|
52
|
+
examples: [
|
|
53
|
+
['the secrets for this repo, and which are missing', 'sk secret list'],
|
|
54
|
+
['every row of the registry, with its scope', 'sk secret list --all'],
|
|
55
|
+
],
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
all = Option.Boolean('--all', false, { description: 'every registry row, the ones out of scope marked' })
|
|
59
|
+
json = Option.Boolean('--json', false, { description: 'one json array, no presence read' })
|
|
60
|
+
|
|
61
|
+
async execute(): Promise<number> {
|
|
62
|
+
return refusing(this.context.stderr, () => this.list())
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private async list(): Promise<number> {
|
|
66
|
+
const w = await where(process.cwd())
|
|
67
|
+
// in the house repo its own creds ARE the registry, each row with the scope it declares
|
|
68
|
+
const inHouse = w.house != null && w.house === w.own
|
|
69
|
+
const rows = secretsFor({ asker: w, own: inHouse ? [] : (w.own?.creds ?? []), house: w.house?.creds ?? [], all: this.all })
|
|
70
|
+
if (this.json) {
|
|
71
|
+
this.context.stdout.write(`${JSON.stringify(rows)}\n`)
|
|
72
|
+
return 0
|
|
73
|
+
}
|
|
74
|
+
const has = await presence(template(w, 'credsReadCommand'), rows.filter((r) => r.inScope).map((r) => r.name))
|
|
75
|
+
const say = (l: string): void => void this.context.stdout.write(`${l}\n`)
|
|
76
|
+
const mine = rows.filter((r) => r.mine).length
|
|
77
|
+
say(`${w.repos[0]} speaks as ${w.identity ?? 'no identity'}: ${rows.filter((r) => r.inScope).length} secrets, ${mine} for this repo or identity`)
|
|
78
|
+
const pad = (k: 'name' | 'for'): number => Math.max(...rows.map((r) => r[k].length))
|
|
79
|
+
for (const r of rows) {
|
|
80
|
+
const p = has.get(r.name)
|
|
81
|
+
const mark = !r.inScope ? 'out ' : p === true ? 'ok ' : 'MISS'
|
|
82
|
+
const fix = p === false ? ` → sk secret set ${r.name}` : ''
|
|
83
|
+
say(`${mark} ${r.name.padEnd(pad('name'))} ${r.level.padEnd(5)} ${r.for.padEnd(pad('for'))} ${(r.service ?? '').slice(0, 40)}${fix}`)
|
|
84
|
+
}
|
|
85
|
+
return 0
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class SecretReadCommand extends Command {
|
|
90
|
+
static override paths = [['secret', 'get'], ['secret', 'account']]
|
|
91
|
+
|
|
92
|
+
static override usage = Command.Usage({
|
|
93
|
+
category: 'Secrets',
|
|
94
|
+
description: 'print a secret (get) or the account stored with it (account), through the house secret manager',
|
|
95
|
+
examples: [['a token', 'sk secret get rv/cloudflare/api-token'], ['the login stored with it', 'sk secret account rv/pockethost/account']],
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
name = Option.String()
|
|
99
|
+
|
|
100
|
+
async execute(): Promise<number> {
|
|
101
|
+
const field = this.path[1] === 'account' ? 'account' : 'get'
|
|
102
|
+
return refusing(this.context.stderr, async () => {
|
|
103
|
+
const argv = secretArgv(template(await where(process.cwd()), 'credsReadCommand'), this.name, field)
|
|
104
|
+
return Bun.spawnSync(argv, { stdout: 'inherit', stderr: 'inherit' }).exitCode ?? 1
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export class SecretSetCommand extends Command {
|
|
110
|
+
static override paths = [['secret', 'set']]
|
|
111
|
+
|
|
112
|
+
static override usage = Command.Usage({
|
|
113
|
+
category: 'Secrets',
|
|
114
|
+
description: 'store a secret and its account through the house secret manager: it prompts, or reads stdin',
|
|
115
|
+
examples: [['store a token', 'sk secret set rv/npm/token'], ['with its login', 'sk secret set rv/pockethost/account me@example.com']],
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
name = Option.String()
|
|
119
|
+
account = Option.String({ required: false })
|
|
120
|
+
|
|
121
|
+
async execute(): Promise<number> {
|
|
122
|
+
return refusing(this.context.stderr, async () => {
|
|
123
|
+
const argv = [...template(await where(process.cwd()), 'credsCommand').trim().split(/\s+/).map((x) => x.replaceAll('{name}', this.name)), ...(this.account != null ? [this.account] : [])]
|
|
124
|
+
return Bun.spawnSync(argv, { stdin: 'inherit', stdout: 'inherit', stderr: 'inherit' }).exitCode ?? 1
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
}
|
package/src/cli/cmd_Wiki.ts
CHANGED
|
@@ -10,12 +10,12 @@ export class WikiServeCommand extends Command {
|
|
|
10
10
|
category: 'Wiki',
|
|
11
11
|
description: 'live md link-graph server — reload = rescan',
|
|
12
12
|
examples: [
|
|
13
|
-
['serve the
|
|
13
|
+
['serve the repo wiki', 'sk wiki serve'],
|
|
14
14
|
['serve a subtree on a port', 'sk wiki serve --root agent --index process.md --port 6162'],
|
|
15
15
|
],
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
-
root = Option.String('--root',
|
|
18
|
+
root = Option.String('--root', { required: false, description: 'wiki root directory (default: wiki/, else the agent folder, else the cwd)' })
|
|
19
19
|
port = Option.String('--port', '6161', { description: 'server port' })
|
|
20
20
|
title = Option.String('--title', { required: false, description: 'page title shown in the graph header' })
|
|
21
21
|
index = Option.String('--index', { required: false, description: 'entrypoint page (default: index.md AND README.md)' })
|
|
@@ -38,12 +38,12 @@ export class WikiLintCommand extends Command {
|
|
|
38
38
|
category: 'Wiki',
|
|
39
39
|
description: 'fail on orphan pages and dangling refs (exit 1)',
|
|
40
40
|
examples: [
|
|
41
|
-
['lint the
|
|
41
|
+
['lint the repo wiki', 'sk wiki lint'],
|
|
42
42
|
['lint a subtree', 'sk wiki lint --root agent --index process.md'],
|
|
43
43
|
],
|
|
44
44
|
})
|
|
45
45
|
|
|
46
|
-
root = Option.String('--root',
|
|
46
|
+
root = Option.String('--root', { required: false, description: 'wiki root directory (default: wiki/, else the agent folder, else the cwd)' })
|
|
47
47
|
index = Option.String('--index', { required: false, description: 'entrypoint page (default: index.md AND README.md)' })
|
|
48
48
|
skip = Option.String('--skip', { required: false, description: 'comma-separated dir names to exclude from the scan' })
|
|
49
49
|
|
package/src/cli/family-pages.ts
CHANGED
|
@@ -15,6 +15,7 @@ export const FAMILY_PAGES: Readonly<Record<string, string>> = {
|
|
|
15
15
|
Refactor: 'patterns/typescript/index.md',
|
|
16
16
|
Review: 'tools/shipkit/review.md',
|
|
17
17
|
Scaffold: 'patterns/pocketbase/index.md',
|
|
18
|
+
Secrets: 'services/secrets/index.md',
|
|
18
19
|
Serve: 'tools/shipkit/home.md',
|
|
19
20
|
Setup: 'patterns/rv-conventions/index.md',
|
|
20
21
|
Social: 'tools/shipkit/social.md',
|
package/src/cli/registry.ts
CHANGED
|
@@ -51,6 +51,7 @@ import { MEDIA_COMMANDS } from './cmd_Media.ts'
|
|
|
51
51
|
import { BACKUP_COMMANDS } from './cmd_Backup.ts'
|
|
52
52
|
import { VEILLE_COMMANDS } from './cmd_Veille.ts'
|
|
53
53
|
import { TuiCommand } from './cmd_Tui.ts'
|
|
54
|
+
import { SecretListCommand, SecretReadCommand, SecretSetCommand } from './cmd_Secret.ts'
|
|
54
55
|
import { WikiLintCommand, WikiServeCommand } from './cmd_Wiki.ts'
|
|
55
56
|
|
|
56
57
|
|
|
@@ -108,6 +109,9 @@ export function buildCli(): Cli {
|
|
|
108
109
|
cli.register(AskNewCommand)
|
|
109
110
|
cli.register(WikiServeCommand)
|
|
110
111
|
cli.register(WikiLintCommand)
|
|
112
|
+
cli.register(SecretListCommand)
|
|
113
|
+
cli.register(SecretReadCommand)
|
|
114
|
+
cli.register(SecretSetCommand)
|
|
111
115
|
cli.register(AssetsFillCommand)
|
|
112
116
|
cli.register(AssetsAddCommand)
|
|
113
117
|
cli.register(AssetsGenCommand)
|
|
@@ -25,6 +25,8 @@ import { check, type CheckDef, type CheckFrom } from '../check.ts'
|
|
|
25
25
|
import { CHECK_SUFFIX as SUFFIX, fallbackNames, isLegacyCheckSource, SKIPPED_DIRS as IGNORED_DIRS, UNIT_SUFFIX, unitBase } from './check-file-names.ts'
|
|
26
26
|
import { unitKind } from '../shipkit-files.ts'
|
|
27
27
|
import { readVendored } from './vendored-read.ts'
|
|
28
|
+
import { gitBin } from './git-bin.ts'
|
|
29
|
+
import { keptOnTree } from './tree-rev.ts'
|
|
28
30
|
|
|
29
31
|
export { fallbackNames, isLegacyCheckSource } from './check-file-names.ts'
|
|
30
32
|
|
|
@@ -101,15 +103,26 @@ function walkKept(dir: string, out: string[], suffix: string, dirs: string[] | u
|
|
|
101
103
|
dirs?.push(...seen)
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
/** the absolute
|
|
105
|
-
|
|
106
|
+
/** the absolute dirs no repo walk enters: the vendored ones, and every one git ignores. A folder of captures or a
|
|
107
|
+
* build output holds thousands of dirs, and a walk through them holds the daemon's loop for seconds */
|
|
108
|
+
const prunedDirs = (root: string): ReadonlySet<string> => new Set([...readVendored(root).map((d) => join(root, d)), ...ignoredDirs(root)])
|
|
109
|
+
|
|
110
|
+
/** the dirs git ignores under `root`, absolute, read again once the tree moved (one git spawn); none outside git */
|
|
111
|
+
function ignoredDirs(root: string): string[] {
|
|
112
|
+
return keptOnTree(ignoredLists, root, () => {
|
|
113
|
+
const p = Bun.spawnSync([gitBin(), 'ls-files', '--others', '--ignored', '--exclude-standard', '--directory', '-z'], { cwd: root, stdout: 'pipe', stderr: 'ignore' })
|
|
114
|
+
if (p.exitCode !== 0) return []
|
|
115
|
+
return p.stdout.toString().split('\0').filter((f) => f.endsWith('/')).map((f) => join(root, f.slice(0, -1)))
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
const ignoredLists = new Map<string, { rev: number; value: string[] }>()
|
|
106
119
|
|
|
107
120
|
/** every `*.shipkit.ts` file under a repo root, by the same walk. Sorted.
|
|
108
121
|
* `dirs` collects every dir the walk read: a file added to one moves its
|
|
109
122
|
* mtime, which is how a reader tells the list moved without walking again */
|
|
110
123
|
export function repoUnitFiles(root: string, dirs?: string[]): string[] {
|
|
111
124
|
const out: string[] = []
|
|
112
|
-
walkKept(root, out, UNIT_SUFFIX, dirs,
|
|
125
|
+
walkKept(root, out, UNIT_SUFFIX, dirs, prunedDirs(root))
|
|
113
126
|
return out.sort()
|
|
114
127
|
}
|
|
115
128
|
|
|
@@ -134,7 +147,7 @@ export async function importFresh(path: string): Promise<unknown> {
|
|
|
134
147
|
* Sorted. */
|
|
135
148
|
export function repoCheckFiles(root: string): string[] {
|
|
136
149
|
const out: string[] = []
|
|
137
|
-
walkKept(root, out, SUFFIX, undefined,
|
|
150
|
+
walkKept(root, out, SUFFIX, undefined, prunedDirs(root))
|
|
138
151
|
return out.sort()
|
|
139
152
|
}
|
|
140
153
|
|
|
@@ -229,7 +242,7 @@ export async function discoverChecks(root: string, o: DiscoverOpts = {}): Promis
|
|
|
229
242
|
const builtins: string[] = []
|
|
230
243
|
walk(builtinDir, builtins)
|
|
231
244
|
const found: string[] = []
|
|
232
|
-
walkKept(root, found, SUFFIX, undefined,
|
|
245
|
+
walkKept(root, found, SUFFIX, undefined, prunedDirs(root))
|
|
233
246
|
const units = repoUnitFiles(root)
|
|
234
247
|
// the repo that HOSTS the toolkit walks over `src/checks/` too, and a file
|
|
235
248
|
// discovered twice is a duplicate id rather than a second check. Real paths,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// who a house resource is for: some repos, some identities, or every repo.
|
|
2
|
+
// One type and one reader, so a secret and anything scoped later answer alike.
|
|
3
|
+
// The md form, one cell: `all`, or `repo:<name>` and `identity:<id>` joined by commas.
|
|
4
|
+
|
|
5
|
+
/** absent or empty = every repo */
|
|
6
|
+
export type Scope = {
|
|
7
|
+
/** repo names, as `repo.config.ts` names them or as their folder is called */
|
|
8
|
+
repos?: string[]
|
|
9
|
+
/** identity ids, as `speaksAs` names them */
|
|
10
|
+
identities?: string[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** the repo asking: every name it answers to (its config name, its folder), and the identity it speaks as */
|
|
14
|
+
export type Asker = { repos: string[]; identity: string | null }
|
|
15
|
+
|
|
16
|
+
const listed = (xs: string[] | undefined): boolean => (xs ?? []).length > 0
|
|
17
|
+
|
|
18
|
+
export const scopesAll = (s: Scope | undefined): boolean => s == null || (!listed(s.repos) && !listed(s.identities))
|
|
19
|
+
|
|
20
|
+
/** in scope when the scope is for all, names the repo, or names its identity */
|
|
21
|
+
export function inScope(s: Scope | undefined, a: Asker): boolean {
|
|
22
|
+
if (scopesAll(s)) return true
|
|
23
|
+
return (s!.repos ?? []).some((r) => a.repos.includes(r)) || (a.identity != null && (s!.identities ?? []).includes(a.identity))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** the md cell as a scope; throws on a token that is neither `all`, `repo:` nor `identity:` */
|
|
27
|
+
export function parseScope(cell: string): Scope {
|
|
28
|
+
const text = cell.replaceAll('`', '').trim()
|
|
29
|
+
if (text === '' || text === 'all') return {}
|
|
30
|
+
const s: Scope = {}
|
|
31
|
+
for (const raw of text.split(',')) {
|
|
32
|
+
const t = raw.trim()
|
|
33
|
+
const m = /^(repo|identity):([a-z0-9][a-z0-9._-]*)$/.exec(t)
|
|
34
|
+
if (m == null) throw new Error(`scope "${cell}": "${t}" is not repo:<name> or identity:<id> (or all)`)
|
|
35
|
+
const key = m[1] === 'repo' ? 'repos' : 'identities'
|
|
36
|
+
;(s[key] ??= []).push(m[2]!)
|
|
37
|
+
}
|
|
38
|
+
return s
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const scopeText = (s: Scope | undefined): string =>
|
|
42
|
+
scopesAll(s) ? 'all' : [...(s!.repos ?? []).map((r) => `repo:${r}`), ...(s!.identities ?? []).map((i) => `identity:${i}`)].join(', ')
|
package/src/home/beat.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// a child's heartbeat on disk: its loop touches `<role>.beat` once a second, the file holding its pid. pm reads it
|
|
2
|
+
// before it kills a child that does not answer its probe: a beat this young says the loop still turns between long
|
|
3
|
+
// steps (a starved child on a loaded machine), where a hung one never turns again (home/supervise.ts, killIfHung)
|
|
4
|
+
import { readFileSync, statSync, utimesSync, writeFileSync } from 'fs'
|
|
5
|
+
|
|
6
|
+
export const BEAT_EVERY_MS = 1_000
|
|
7
|
+
|
|
8
|
+
/** starts the beat of this process; the function it returns stops it */
|
|
9
|
+
export function startBeat(file: string, pid = process.pid): () => void {
|
|
10
|
+
const write = (): void => {
|
|
11
|
+
try { writeFileSync(file, String(pid)) } catch { /* a read only home: pm then kills on the probe alone */ }
|
|
12
|
+
}
|
|
13
|
+
write()
|
|
14
|
+
const t = setInterval(() => {
|
|
15
|
+
const now = new Date()
|
|
16
|
+
try { utimesSync(file, now, now) } catch { write() }
|
|
17
|
+
}, BEAT_EVERY_MS)
|
|
18
|
+
t.unref?.()
|
|
19
|
+
return () => clearInterval(t)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** the last beat a file holds: its pid and when, or null when there is none */
|
|
23
|
+
export function readBeat(file: string): { pid: number; at: number } | null {
|
|
24
|
+
try {
|
|
25
|
+
const pid = Number(readFileSync(file, 'utf8').trim())
|
|
26
|
+
return Number.isInteger(pid) && pid > 0 ? { pid, at: statSync(file).mtimeMs } : null
|
|
27
|
+
} catch {
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/home/home-paths.ts
CHANGED
|
@@ -67,6 +67,7 @@ export const pmLog = (dir = homeDir()): string => join(dir, 'pm.log')
|
|
|
67
67
|
* the pid record the next pm adopts (supervise.ts pidKey) */
|
|
68
68
|
export const childLog = (dir: string, role: string): string => join(dir, `${role}.log`)
|
|
69
69
|
export const childPid = (dir: string, role: string): string => join(dir, `${role}.pid`)
|
|
70
|
+
export const childBeat = (dir: string, role: string): string => join(dir, `${role}.beat`)
|
|
70
71
|
export const resourceLog = (dir: string, id: string): string => join(dir, 'resources', `${id}.log`)
|
|
71
72
|
export const resourcePid = (dir: string, id: string): string => join(dir, 'resources', `${id}.pid`)
|
|
72
73
|
export const stateFile = (dir: string): string => join(dir, 'state.json')
|
package/src/home/pm.ts
CHANGED
|
@@ -12,7 +12,8 @@ import { join } from 'path'
|
|
|
12
12
|
import { LIB_VERSION } from '../core/lib-version.ts'
|
|
13
13
|
import { iconImageType } from '../shipkit-files.ts'
|
|
14
14
|
import { sameOrigin } from '../serve/same-origin.ts'
|
|
15
|
-
import {
|
|
15
|
+
import { readBeat } from './beat.ts'
|
|
16
|
+
import { childBeat, childLog, childPid, daemonPort, homePort, pmLog, pmPort } from './home-paths.ts'
|
|
16
17
|
import type { Resources, ResourceView } from './resources.ts'
|
|
17
18
|
import { capLog, Proc, realDeps, tailLines, type ProcView, type SuperviseDeps } from './supervise.ts'
|
|
18
19
|
|
|
@@ -86,6 +87,7 @@ export class Pm {
|
|
|
86
87
|
// a crash loop while its code is being edited heals itself
|
|
87
88
|
neverGiveUp: true,
|
|
88
89
|
hangMs: CHILD_HANG_MS,
|
|
90
|
+
beat: () => readBeat(childBeat(d.dir, role)),
|
|
89
91
|
say: d.say,
|
|
90
92
|
}, d.deps ?? realDeps)]))
|
|
91
93
|
}
|
package/src/home/run-daemon.ts
CHANGED
|
@@ -19,7 +19,8 @@ import { loadRepoConfig } from '../repo-config.ts'
|
|
|
19
19
|
import { ensureIdentity } from '../core/identity.ts'
|
|
20
20
|
import { homedir } from 'os'
|
|
21
21
|
import { join } from 'path'
|
|
22
|
-
import {
|
|
22
|
+
import { startBeat } from './beat.ts'
|
|
23
|
+
import { childBeat, childLog, daemonPort, homeDir, homePort, homeUp, hubBase, publicHome, WORKER_ENV } from './home-paths.ts'
|
|
23
24
|
import { inboxAddress } from './inbox-shape.ts'
|
|
24
25
|
import { HomeState } from './home-state.ts'
|
|
25
26
|
import { Hubs } from './hubs.ts'
|
|
@@ -120,9 +121,11 @@ export async function runDaemon(root: string, io: HomeIo, o: { port?: number } =
|
|
|
120
121
|
const jobs = onlyRepos() == null ? startJobs({ cli: CLI, cwd: root, dir: join(dir, 'jobs'), log: childLog(dir, 'daemon'), printErr: io.printErr }) : null
|
|
121
122
|
// a job that holds the loop holds every page: each stall is said with the work that overlapped it
|
|
122
123
|
const stalls = loopWatch.start(io.printErr)
|
|
124
|
+
// pm tells a starved daemon from a hung one by this beat: it turns with the loop
|
|
125
|
+
const beat = startBeat(childBeat(dir, 'daemon'))
|
|
123
126
|
// its memory as a trend: a line only when it moved by a tenth, at most every 10 minutes
|
|
124
127
|
const memory = new MemoryWatch().start(io.print)
|
|
125
|
-
const code = reloadOnOwnCode({ role: 'daemon', entry: fileURLToPath(import.meta.url), busy: () => hubs.busy(), before: () => { stalls(); memory(); jobs?.stop(); home.stop() }, keep: true, io })
|
|
128
|
+
const code = reloadOnOwnCode({ role: 'daemon', entry: fileURLToPath(import.meta.url), busy: () => hubs.busy(), before: () => { stalls(); beat(); memory(); jobs?.stop(); home.stop() }, keep: true, io })
|
|
126
129
|
io.print(` ${house.repos.length} repos, state in ${dir}, reloads on ${code.files} lib files`)
|
|
127
130
|
for (const sig of ['SIGINT', 'SIGTERM'] as const)
|
|
128
131
|
process.on(sig, () => {
|
package/src/home/run-web.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// its own code, the page included, restarts it in place (lib-watch.ts).
|
|
5
5
|
import homePage from '../serve/hub-app/home.html'
|
|
6
6
|
import { fileURLToPath } from 'url'
|
|
7
|
-
import {
|
|
7
|
+
import { startBeat } from './beat.ts'
|
|
8
|
+
import { childBeat, daemonPort, daemonUrl, homeDir, homePort, homeUp, pmUrl } from './home-paths.ts'
|
|
8
9
|
import { reloadOnOwnCode } from './lib-watch.ts'
|
|
9
10
|
import { serveWeb } from './serve-web.ts'
|
|
10
11
|
import type { HomeIo } from './run-daemon.ts'
|
|
@@ -13,7 +14,8 @@ export async function runWeb(io: HomeIo, o: { port?: number } = {}): Promise<num
|
|
|
13
14
|
const port = o.port ?? homePort()
|
|
14
15
|
try {
|
|
15
16
|
const web = serveWeb({ port, daemon: daemonUrl(daemonPort()), pm: pmUrl(), page: homePage })
|
|
16
|
-
const
|
|
17
|
+
const beat = startBeat(childBeat(homeDir(), 'web'))
|
|
18
|
+
const code = reloadOnOwnCode({ role: 'web', entry: fileURLToPath(import.meta.url), bundles: true, before: () => { beat(); web.stop() }, io })
|
|
17
19
|
io.print(`home → http://localhost:${web.server.port} (the daemon: ${daemonUrl()}, pm: ${pmUrl()}), reloads on ${code.files} lib files`)
|
|
18
20
|
for (const sig of ['SIGINT', 'SIGTERM'] as const)
|
|
19
21
|
process.on(sig, () => {
|
package/src/home/supervise.ts
CHANGED
|
@@ -33,6 +33,9 @@ export type ProcSpec = {
|
|
|
33
33
|
* (a main thread stuck in one synchronous step still holds its port):
|
|
34
34
|
* killed, then started again after the crash backoff. None = never */
|
|
35
35
|
hangMs?: number
|
|
36
|
+
/** the child's last heartbeat: its loop touches a file while it turns (home/beat.ts). One of this pid newer than
|
|
37
|
+
* hangMs says the child is starved (slow steps on a loaded machine), not hung: it is kept, up to STARVED_MAX_MS */
|
|
38
|
+
beat?: () => { pid: number; at: number } | null
|
|
36
39
|
/** a line for every act the supervisor takes on its own */
|
|
37
40
|
say?: (line: string) => void
|
|
38
41
|
}
|
|
@@ -72,6 +75,9 @@ export const CRASH_LIMIT = 5
|
|
|
72
75
|
export const CRASH_WINDOW_MS = 5 * 60_000
|
|
73
76
|
/** a stop that SIGTERM did not end becomes a SIGKILL after this */
|
|
74
77
|
export const KILL_AFTER_MS = 5_000
|
|
78
|
+
/** how long a starved child is kept without an answer: past it, a loop that beats but never answers (a wedged
|
|
79
|
+
* server) is killed all the same */
|
|
80
|
+
export const STARVED_MAX_MS = 10 * 60_000
|
|
75
81
|
|
|
76
82
|
/** the process is started by a shell that exits at once: it belongs to init
|
|
77
83
|
* from its first moment, so a supervisor that restarts in place (execve)
|
|
@@ -145,6 +151,8 @@ export class Proc {
|
|
|
145
151
|
private probing = false
|
|
146
152
|
/** why the kill in flight was a hang kill, for the crash note */
|
|
147
153
|
private hung: string | null = null
|
|
154
|
+
/** the start of the probe silence already said to be starvation, so it is said once */
|
|
155
|
+
private starvedSince: number | null = null
|
|
148
156
|
/** a restart: start again once the stop landed */
|
|
149
157
|
private again = false
|
|
150
158
|
/** it answers its probe with no pid of ours behind it */
|
|
@@ -336,7 +344,16 @@ export class Proc {
|
|
|
336
344
|
private killIfHung(now: number): void {
|
|
337
345
|
const hang = this.spec.hangMs
|
|
338
346
|
if (hang == null || this.status !== 'starting' || this.pid == null || this.want !== 'up' || now - this.since < hang) return
|
|
339
|
-
|
|
347
|
+
const silent = Math.round((now - this.since) / 1000)
|
|
348
|
+
const beat = this.spec.beat?.() ?? null
|
|
349
|
+
if (beat != null && beat.pid === this.pid && now - beat.at < hang && now - this.since < STARVED_MAX_MS) {
|
|
350
|
+
if (this.starvedSince !== this.since) {
|
|
351
|
+
this.starvedSince = this.since
|
|
352
|
+
this.spec.say?.(`WARN ${this.spec.id} (pid ${this.pid}) did not answer its probe for ${silent}s, but its loop beat ${Math.round((now - beat.at) / 1000)}s ago: starved, not hung, kept (killed past ${STARVED_MAX_MS / 60_000} min)`)
|
|
353
|
+
}
|
|
354
|
+
return
|
|
355
|
+
}
|
|
356
|
+
this.hung = `did not answer its probe for ${silent}s${beat != null && beat.pid === this.pid && now - beat.at < hang ? ', though its loop beats' : ''}`
|
|
340
357
|
this.spec.say?.(`WARN ${this.spec.id} (pid ${this.pid}) ${this.hung}: killed, it starts again`)
|
|
341
358
|
this.d.kill(this.pid, 'SIGTERM')
|
|
342
359
|
this.killAt = now + KILL_AFTER_MS
|
package/src/repo-config.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// a slot that can't fill emits a visible reason, and one turned off with
|
|
9
9
|
// `off: { x: '<why>' }` prints a skipped-by-config line, never silence.
|
|
10
10
|
// The `contracts` task is always present when any contract applies.
|
|
11
|
+
import type { Scope } from './core/scope.ts'
|
|
11
12
|
import { existsSync, readFileSync } from 'fs'
|
|
12
13
|
import { isAbsolute, join, normalize } from 'path'
|
|
13
14
|
import { ROUTED_SCRIPTS } from './core/canonical-scripts.ts'
|
|
@@ -155,6 +156,8 @@ export type RepoConfig = {
|
|
|
155
156
|
* for something nothing uses yet, so it is dim and stays out of
|
|
156
157
|
* `shipkit needs`. Default `used` */
|
|
157
158
|
level?: 'core' | 'used' | 'minor'
|
|
159
|
+
/** the repos and identities it is for (`sk secret list` shows a repo only its own). Absent: every repo */
|
|
160
|
+
for?: Scope
|
|
158
161
|
}[]
|
|
159
162
|
/** store-command template for a missing secret tile, `{name}` substituted, as in your secret manager's set command */
|
|
160
163
|
credsCommand?: string
|