bareloop 0.46.1 → 0.47.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 CHANGED
@@ -5,6 +5,32 @@ All notable changes to bareloop are documented here. Format:
5
5
  [SemVer](https://semver.org/spec/v2.0.0.html). Pre-1.0: **minor** = a ladder rung or
6
6
  feature lands, **patch** = docs, fixes, scaffolding.
7
7
 
8
+ ## [0.47.1] - 2026-10-24
9
+
10
+ ### Fixed
11
+
12
+ - **The launcher no longer calls a loaded panel "not running".** The `GET /api/whoami` probe gave each port 300 ms; under machine load a live panel answered in 0.8 s, so `bareloop status` printed "panel not running" while it was up and `start` would have started a second one. Each port now gets 2000 ms per probe (all ports are still asked in parallel; a closed port refuses at once, so a quiet machine is as fast as before), and `start` waits about 10 seconds on a silent taken port (see the next entry).
13
+ - **`bareloop start` no longer opens a second panel next to a silent one.** A port that is taken but did not answer `whoami` in time was skipped, so a very loaded panel on 4700 got a second one on 4701 (two schedulers, double scheduled runs). `start` now asks such a port again for about 10 seconds: a bareloop answer means it is already running, any other reply moves on to the next port, and still silent stops with "Port 4700 is taken and not answering. If it's a stuck bareloop, stop it first." and starts nothing.
14
+ - **`bareloop stop` no longer says "Panel stopped." while the process is still alive.** It only watched the port go quiet; a panel that stopped answering but kept running read as stopped. `stop` now also checks each pid is gone (signal 0) within the deadline; one still alive is named ("The panel at ... (pid N) did not stop.", exit 1) and any that did stop are still named.
15
+ - **`whoami` (and the page topbar) report the version the panel runs, not the one on disk.** Both re-read `package.json` on every request, so a panel started on older code answered with the new version after an upgrade and the launcher's stop-and-start note could never fire. The version is now read once when the panel starts.
16
+ - **The Audit tab's folded rows show an open/closed arrow.** Every part row in the Grouped view and the "What the planner was told from earlier runs" box now lead with an open/closed arrow, flipping on each click; a live run's running part starts open.
17
+ - **The Audit fold arrows are the bigger ones fwdloop uses.** ▶ when folded and ▼ when open, faint, on the part rows, the learnings box and the schedule box alike; on a phone the gap after the arrow is smaller.
18
+ - **`bareloop stop` and `start` give up after the stated time, not many times it.** The wait-until-gone loop counted 100 ms per poll, but a poll against a panel that answers slowly can take up to 2 seconds, so a 10-second wait could run for minutes. The deadline is now real clock time.
19
+
20
+ ## [0.47.0] - 2026-10-24
21
+
22
+ ### Added
23
+
24
+ - **`bareloop` is a launcher (PANEL-BUILD.md addendum L, hamr 2026-10-24).** Bare `bareloop` shows a menu (`1 start 2 stop 3 status 4 install q quit`) under two header lines (installed or not, panel running or not, `runs: N running · N need you · N in all`); the same four work as `bareloop start | stop | status | install`. No pid file: the panel is found by asking ports 4700-4709 for the new read-only `GET /api/whoami`. `start` runs the panel detached on the first free port (log: `~/.config/bareloop/panel.log`) and opens the page; `stop` stops every panel it finds (one panel at a time; no `--port`, no which-one question), warns about open drafts summed over them and asks (`--yes` skips); `status` prints `Panel not running.` and exits 3 when no panel runs (0 from the menu); `install` creates only what is missing. The old `1 export / 2 run / 3 history` menu is gone (the sub-commands stay). `bareloop panel [--port N]` is unchanged. Coloured on a terminal (off when piped, `NO_COLOR` set or `TERM=dumb`). `status` and the header show the running panel's version, with a stop-and-start note when it differs from the CLI's. The header's `need you` count matches the panel's Needs-you list, schedules that gave up included. `GET /api/whoami` (app, version, pid, port, drafts, schedules) sits behind the Host guard and needs no token. The panel address has one owner (`panelUrl`); no address literal lives in the launcher, and the OS opener is shared with Settings.
25
+
26
+ ### Changed
27
+
28
+ - **A rubric run's lessons count at run end, like a deterministic run's (hamr 2026-10-24, option A).** `foldRunIntoLedger` no longer holds a `rubric` run's cards in `pending` until the human Accept: they go through `countLedger` now, FIXED and NEVER FIXED alike, with `trust: 'rubric'` kept on new rows; `held` is always 0. A hold already in a ledger file (written by v0.46.x) still releases on the door Accept. Reuse and bridge credit is unchanged and still waits for the Accept. Noise runs stay dropped.
29
+
30
+ ### Fixed
31
+
32
+ - **A resumed leg updates its own run's ledger row.** `countLedger` skipped a row that already held the run id, so a NEVER FIXED lesson from leg 1 stayed NEVER FIXED when leg 2 (same run id) fixed it. The row is now refreshed from the new card (sample, lesson, key, lastSeen, hash, place) while its count, model tally and run ids stay one per run; an older run's cards re-folded later never step a row back. Found by fwdloop.
33
+
8
34
  ## [0.46.1] - 2026-10-24
9
35
 
10
36
  ### Fixed
package/README.md CHANGED
@@ -68,6 +68,8 @@ building it.
68
68
  npm install bareloop
69
69
  ```
70
70
 
71
+ Quick start: `npm install -g bareloop`, then `bareloop` — a menu to start the panel, stop it, see its status, and set up `~/.config/bareloop/`.
72
+
71
73
  ## Usage
72
74
 
73
75
  A signed job spec goes in. A verdict comes out.
@@ -3291,16 +3291,35 @@ real key check is skipped entirely — a scripted provider *is* the run, the
3291
3291
  same seam `tests/planrun-*.test.js` uses. `deps` also accepts `env`, `stdout`, `stderr`, `cwd`,
3292
3292
  `now`, `stdin` — omit any of them and the real `process.*` equivalent is used.
3293
3293
 
3294
- Bare `bareloop` (no sub-command) prints a numbered menu — `1 export 2 run 3 history q
3295
- quit` — and asks each sub-command's arguments one line at a time over the SAME code paths
3296
- below. `run-u`, `interview` and `author` (below) are not on this menu (PANEL-BUILD.md P0
3297
- tasks 2/4-4/4): each one's own flag grammar is too wide for a line-at-a-time wizard, and the
3298
- menu's job is to ask the SAME questions the sub-command below already answers, never to
3299
- invent a new interview — this is doubly true for `interview`/`author`, which already ARE
3300
- interviews of their own. Choice `2 run` is handed the SAME resolved keys home `bareloop run <bundle>` gets, so the
3301
- monthly limit, your price and the key-row choice apply exactly as on the sub-command (before this it
3302
- got none, and a run started from the menu skipped the limit). All three are dispatched by name only: `bareloop run-u <flags…>`,
3303
- `bareloop interview <flags…>`, `bareloop author <flags…>`.
3294
+ Bare `bareloop` (no sub-command) is the **launcher menu** (PANEL-BUILD.md addendum L, `src/launcher.js`): two header lines, then
3295
+ `1 start 2 stop 3 status 4 install q quit`. The header is printed first by EVERY call (menu and each of
3296
+ `bareloop start | stop | status | install`), from one function:
3297
+
3298
+ ```
3299
+ bareloop 0.47.0 · installed ✓ · panel running at http://127.0.0.1:4701
3300
+ runs: 1 running · 2 need you · 375 in all
3301
+ ```
3302
+
3303
+ Colour (`src/tty-colour.js`): on only when stdout is a terminal, `NO_COLOR` is empty/unset and `TERM` is not `dumb`; it wraps words and never
3304
+ changes them, and a piped or `NO_COLOR` run prints the plain words above (the thin `─` rules around the header appear only with colour).
3305
+
3306
+ - `installed ✓` = `~/.config/bareloop/` exists, `config.json` is there and reads with no problem, `.env` exists with mode 600, node >= 22;
3307
+ otherwise `not installed — <first missing thing>, pick 4 install`. The run counts use the panel's own status words and Needs-you rule over the
3308
+ run list file ($0, works with the panel stopped).
3309
+ - **No pid file.** The panel is found by asking `127.0.0.1:4700..4709` for `GET /api/whoami` (2000 ms each, in parallel — a loaded panel answered in 0.8 s; 300 ms missed it); a reply with `app: "bareloop"` is a panel. `start` never opens a second panel next to a silent one: a port that is taken but did not answer is asked again for about 10 s; a late bareloop answer counts as "already running", another kind of reply moves on to the next port, and still silent makes `start` stop with `Port 4700 is taken and not answering. If it's a stuck bareloop, stop it first.` (exit 1, nothing started). `stop` also checks each pid is really gone (signal 0) before it says "Panel stopped."; a pid still alive at the deadline is named (`did not stop`, exit 1) and the ones that did stop are still named.
3310
+ `GET /api/whoami` → `{ app: "bareloop", version, pid, port, drafts, schedules }` (`version` is the version the panel STARTED with, read once at start, never re-read from package.json — so a panel on old code after a bump still reports the old one and the launcher's stop-and-start note can fire; the page topbar is the same) (open drafting sessions, jobs with a schedule), read-only, same Host guard as every
3311
+ route, no token.
3312
+ - **`bareloop start`** → already running: says so, opens the page, starts nothing (if the running panel's version differs from this bareloop's it adds `It is version X; this bareloop is Y. Run bareloop stop, then bareloop start, to use Y.`). Else starts `bareloop panel --port N` DETACHED (`setsid`; log appended to
3313
+ `~/.config/bareloop/panel.log`) on the first free port from 4700 (a taken port that replies as something else is skipped and named; one that stays silent for ~10 s stops `start` with `Port N is taken and not answering…`, nothing started), waits up to 10 s for it to answer, opens the page with
3314
+ `xdg-open`/`open` (no opener: prints the URL). `bareloop panel [--port N]` is unchanged (foreground, fixed port).
3315
+ - **`bareloop stop [--yes]`** → SIGTERM to the pid of EVERY panel the probe finds (one panel at a time; no which-one question), waits until each pid is gone (signal 0) and each port is quiet; a pid still alive at the 10 s deadline is named and exits 1, never `Panel stopped.`. Open drafts (in memory, summed over all found panels) are warned about and a y/N is asked;
3316
+ `--yes` skips it. Not running: `Panel not running.`, exit 0. Several found: all stopped, `N panels stopped.`. Any other option (e.g. `--port`) is refused in plain words. Runs are separate processes and keep going.
3317
+ - **`bareloop status`** → header plus `pid N · version X · N draft(s) open · N schedule(s) on`. Exit 0 running, 3 not running. A panel whose version differs from the CLI's shows `(version X — stop and start to use Y)` after its URL in the header (yellow on a terminal).
3318
+ - **`bareloop install`** → creates only what is missing (folder mode 700, `.env` with the keys-file comment lines, mode 600, `config.json`); never reads a key value;
3319
+ `Already installed, nothing to do.` when there is nothing to add. Needs node >= 22.
3320
+
3321
+ The old `1 export 2 run 3 history` menu is gone; `bareloop export|run|history` and the other sub-commands are unchanged. `run-u`, `interview` and `author` are dispatched
3322
+ by name only: `bareloop run-u <flags…>`, `bareloop interview <flags…>`, `bareloop author <flags…>`.
3304
3323
 
3305
3324
  When two key rows share one provider and endpoint, a CLI run uses the FIRST row in the keys list, so put the
3306
3325
  key you want first (the panel picks the row by the Model menu).
@@ -3890,7 +3909,7 @@ No model is called anywhere in learnings (a test walks the import closure). Pure
3890
3909
  - **Run end:** `execute` (`src/userrun.js`, shared by the panel, the CLI and the bundle runner) calls `learnAtRunEnd({ home, runid, events, auditFiles, spec, specHash, workdir, trust })` once, right after the claim settles, in its own try/catch: a failure prints one WARNING and never changes the verdict, exit code or spend. It writes nothing when the engine has no config home.
3891
3910
  - **Cards:** `buildCards({ runid, events, audit, workdir, spec, model, questions })` → `{ cards, suspect, thin, noise }`. FIXED = a check red then the same check passes later in the run; NEVER FIXED = still red at run end. Excluded and counted: noise runs (provider-red, close-crashed, worker-crash, no close spoke), CHECK-SUSPECT (a no-suppressions hit on a prose comment), TOO-THIN (no error kind and no fix files). Written files come from `attempt-diff` events and the gate audit's allow write/edit rows relative to the tree.
3892
3911
  - **Fold:** `cardsMatch` / `foldCards`: same job + check, a shared error kind, Jaccard >= 60% on flagged-text tokens (a fit on known cards, not a proof). Code-less cards (kind `other`) fold on the text rule alone, only when both token sets are non-empty (R1, 2026-10-23: UNTESTED on real data; the 60% was fitted on cards with codes). `kindAgrees` is the one kind test.
3893
- - **Ledger** `<config home>/learn/ledger.json` (mode 600, atomic, secrets masked): rows `{ id, lesson, count, sample, models, workflow, place, level, trust, runIds, firstSeen, lastSeen, specHash }`, plus `pending` (held rubric cards), `suspect`, `health`. There is no check-wide set-aside (R2, 2026-10-23): a lesson seen in several jobs climbs by the climb rules and is read at its level; all-jobs hints come last. `countLedger` (+1 per run per row), `holdPending` / `releasePending` (rubric cards count only after the human Accept; `releaseRun` is called from the door's accept path), `climb` (the level of a lesson, derived at read time by `readableRows` from the rows not decayed at that moment: it can go back down when siblings age past 56 days; the file stores `workflow` only and ignores an older stored level). The ledger keeps EVERY row (nothing is deleted, no `expired` flag is stored; hamr 2026-10-23). Memory is the filter: `readableRows` / `renderHints` skip a row last seen more than 56 days ago (`isDecayed`) and a workflow row of another signed hash (`otherJobVersion`); a lesson seen again counts +1 on its old row. Old files with `status`/`expiredBy` still load; the fields are ignored and dropped at the next write.
3912
+ - **Ledger** `<config home>/learn/ledger.json` (mode 600, atomic, secrets masked): rows `{ id, lesson, count, sample, models, workflow, place, level, trust, runIds, firstSeen, lastSeen, specHash }`, plus `pending` (holds an older version wrote for rubric runs; new runs write none), `suspect`, `health`. There is no check-wide set-aside (R2, 2026-10-23): a lesson seen in several jobs climbs by the climb rules and is read at its level; all-jobs hints come last. `countLedger` (+1 per run per row), `releasePending` (an OLD hold, written by v0.46.x, counts on the human Accept; `releaseRun` is called from the door's accept path; a rubric run's lessons now count at run end like a deterministic run's, trust `rubric` kept, and `foldRunIntoLedger` returns `held: 0`; reuse/bridge credit still waits for the Accept). A row already holding the run id (a resumed leg, one id) is refreshed from the new card (sample, lesson, key, lastSeen, hash, place) but its count, model tally and run ids do not move, `climb` (the level of a lesson, derived at read time by `readableRows` from the rows not decayed at that moment: it can go back down when siblings age past 56 days; the file stores `workflow` only and ignores an older stored level). The ledger keeps EVERY row (nothing is deleted, no `expired` flag is stored; hamr 2026-10-23). Memory is the filter: `readableRows` / `renderHints` skip a row last seen more than 56 days ago (`isDecayed`) and a workflow row of another signed hash (`otherJobVersion`); a lesson seen again counts +1 on its old row. Old files with `status`/`expiredBy` still load; the fields are ignored and dropped at the next write.
3894
3913
  - **Reading:** `hintsForRun({ home, spec, specHash })` renders once at run start; `runJob(..., { learnHints: { text, ids } })` → `runPlan` hands it to the PLANNER at the draft and the first replan only, and emits a `learnings` spine record with the exact text. `renderHints(ledger, { workflow, place, specHash, now })` is the one render (this job, then this place, then all-jobs, highest count first, 2,000 characters, a hint whole or not at all; all-jobs hints last); a FIXED hint adds `What changed:` (first 3 `+`/`-` lines of the stored diff, 150 chars each, then `(+N more)`; never on NEVER FIXED) and a repeated path in a hint reads as its basename (R3, R5, 2026-10-23); the spine's recorded text is byte-equal to a fresh `renderHints(...).text` from the ledger as it stood. The Audit run detail carries `learnings` (read-only); its header counts DISTINCT hints (the same ledger row handed at the draft and the first replan counts once).
3895
3914
 
3896
3915
  ### Settings — the keys file, `config.json`, the monthly $ limit, the Providers tab (PANEL-BUILD.md P4a, `src/keysfile.js`, `src/config.js`, `src/monthly.js`, `src/providerrows.js`, `src/panel/settingsroutes.js`)
@@ -4407,7 +4426,7 @@ A **Rubric** job whose first Input is the full path of a FILE (not a repo folder
4407
4426
  - **Panel wording.** `stageQuestionText` words a rubric-step stage "line N — does its output pass the line's checks?". The worker brief also tells the worker to copy every number, time and price in a claim exactly as the input writes it ("9:27 AM", not "09:27").
4408
4427
  - **Shown == run (run mv5bk400).** The plan card after drafting is built from the signed close (`checksOfClose`, code-written sentences), not from the confirm turn's prose. A countable part may list the confirmed checks it carries out in `covers` (the composer prompt numbers them `#n`); `reconcileRubricPlan` moves every confirmed check no part covers to Not checked ("... — nothing in this close counts it or checks it against a quote"). `signRun` calls `planMatchesClose(session.state.finalPlan.checkItems, closeDecl)` and refuses, spawning nothing, when the two differ. `minClaims` / `maxClaims` (parts with `value` + `source`) count the claims listed under an input: `flattenStep` takes the count from the file's own `cites.<label>` list as the field `claims:<label>` and bareguard's `min`/`max` compares it. A free-text note is never a check.
4409
4428
  - **Labels.** A text close carries `genre: "TEXT"` (`genreForLang`; `TYPES` is for code languages, and a genre must match its language); its spine records carry no `judgedCount` (no judge ran); the progress list words a file job's steps from `FILE_JOB_STEP_LABELS` ("copying input files", "reading input files").
4410
- - **Panel topbar.** `bareloop · v<version> · automate a job, verified`: the version is bareloop's own package.json, templated into the page at serve time (`__BARELOOP_PANEL_VERSION__`).
4429
+ - **Panel topbar.** `bareloop · v<version> · automate a job, verified`: the version is bareloop's own package.json, read once when the panel starts and templated into the page when it is served (`__BARELOOP_PANEL_VERSION__`), so it is the version the process runs, not what package.json says now.
4411
4430
  - **After drafting, the code-worded card is the only plan on screen (run mv5e1ktb).** The confirm turn's plan bubble is the drafter's own prose (written before any close existed) and used to stay in the thread above the code-worded card; when the rubric card is ready the earlier `kind:'plan'` messages are dropped. `partSentence` now reads "1 line" / "1 word" for a count of one.
4412
4431
  - **Each `~` guardrail is its own row on the plan card.** `planFromSpec` / `planFromConfirm` lines carry `rules: string[]` (the line's own `rules`, else the joined `rule` split on "; "); `renderJobPlan` draws one `~ rule` row per rule under its numbered line, in the plan card and the Job tab alike (one renderer). Gutter numbers stay on job lines only.
4413
4432
  - **The review door's held line is true for a no-judge close.** Credit is held by VERDICT CLASS (`quarantinesCredit`: soft-green), whether or not a judge ran; the door now says "this is a rubric (soft-green) job, so its green earns NO reuse and NO learning credit until you accept it, whether or not a judge ran". Wording only; `bridges.js`/`reuse.js`/the Reuse refusal still say "rendered by the judged floor".
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bareloop",
3
- "version": "0.46.1",
3
+ "version": "0.47.1",
4
4
  "description": "Workflows that earn their own design, with receipts — agent-authored workflows for repeated, long, verifiable jobs that improve across runs under an un-gameable gate.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/cli.js CHANGED
@@ -36,6 +36,8 @@ import { bundleMain } from './bundlerun.js';
36
36
  // rather than re-parsing argv a second time here keeps exactly one code
37
37
  // path for the flag grammar; `src/cli.js` only supplies the deps shape
38
38
  // (`out`/`err`/`env`) this command's own callers already use.
39
+ import { startCmd, stopCmd, statusCmd, installCmd, menuCmd } from './launcher.js';
40
+ import { makePaint } from './tty-colour.js';
39
41
  import { main as runUMain } from './userrun.js';
40
42
  // PANEL-BUILD.md P0 task 3/4 — `bareloop interview` and `bareloop author`
41
43
  // wrap the close-authoring interview and authoring-pipeline flows' own
@@ -272,50 +274,30 @@ function doRuns(args, { out, err, cwd }) {
272
274
  }
273
275
 
274
276
  /**
275
- * The bare `bareloop` menu: `1 export 2 run 3 history q quit`, then the
276
- * SAME code path as the sub-command, asking its args line by line. `run-u`,
277
- * `interview`, `author` and `replay` are NOT wizarded here — a line-at-a-time
278
- * prompt for `run-u`'s 13 flags (or the others' own argv shapes) would be
279
- * inventing new interactive UX, not wiring, and that judgement stands. This
280
- * menu is fixed instead: it now says those four commands exist and how to
281
- * reach them, rather than implying only three commands do at all.
282
- * `keysHome` is the home `main` already resolved (`keysForDoor`), handed on so choice 2 reads the
283
- * SAME config.json (monthly limit, price, key row) as `bareloop run <bundle>` — never resolved twice.
284
- * @param {any} deps @param {{ out: (s: string) => void, err: (s: string) => void, cwd: string, env: any, now: () => number }} ctx @param {string|undefined} keysHome
277
+ * The launcher doors (L, PANEL-BUILD.md addendum 2026-10-24): the bare `bareloop` menu and `start | stop | status | install`. All logic is
278
+ * `src/launcher.js`; this only supplies the home (the SAME one `main` resolved for the keys file and config.json) and the line reader.
279
+ * `deps.launcher` is the test seam for every OS touch (ports, spawn, kill, opener, clock).
280
+ * @param {string} cmd 'menu' | 'start' | 'stop' | 'status' | 'install' @param {string[]} rest
281
+ * @param {any} deps @param {{ out: (s: string) => void, err: (s: string) => void }} io @param {string|undefined} home
282
+ * @returns {Promise<number>}
285
283
  */
286
- async function runMenu(deps, ctx, keysHome) {
287
- const stdin = deps.stdin;
288
- const stdout = deps.stdout;
289
- const rl = createInterface({ input: stdin, output: stdout });
284
+ async function runLauncher(cmd, rest, deps, io, home) {
285
+ const rl = createInterface({ input: deps.stdin ?? process.stdin, output: deps.stdout ?? process.stdout });
286
+ let closed = false;
287
+ rl.once('close', () => { closed = true; });
288
+ // a closed stdin answers '' (= the safe default: quit / "no"), never hangs
289
+ const ask = (/** @type {string} */ q) => (closed ? Promise.resolve('') : Promise.race([
290
+ rl.question(q),
291
+ new Promise((resolve) => { rl.once('close', () => resolve('')); }),
292
+ ]).then(String));
293
+ const rawEnv = deps.processEnv ?? process.env;
294
+ const d = { home, ask, paint: makePaint(deps.stdout ?? process.stdout, rawEnv), paintErr: makePaint(deps.stderr ?? process.stderr, rawEnv), ...(deps.launcher ?? {}) };
290
295
  try {
291
- ctx.out('1 export 2 run 3 history q quit');
292
- ctx.out('(also on the command line, not wizarded here: run-u, interview, author, replay, runs, panel — run `bareloop <name>` with its own flags)');
293
- const choice = (await rl.question('> ')).trim().toLowerCase();
294
- if (choice === '' || choice === 'q' || choice === 'quit') return 0;
295
- if (choice === '1') {
296
- const specPath = (await rl.question('job spec path: ')).trim();
297
- const registry = (await rl.question('registry dir: ')).trim();
298
- const outDir = (await rl.question('out dir: ')).trim();
299
- return doExport([specPath, '--registry', registry, '--out', outDir], ctx);
300
- }
301
- if (choice === '2') {
302
- const bundleDir = (await rl.question('bundle dir: ')).trim();
303
- const repo = (await rl.question('repo path: ')).trim();
304
- const budget = (await rl.question('budget (blank to skip): ')).trim();
305
- const wall = (await rl.question('wall minutes (blank to skip): ')).trim();
306
- const approve = (await rl.question('approve hash (blank to skip): ')).trim();
307
- const args = [bundleDir, '--repo', repo];
308
- if (budget) args.push('--budget', budget);
309
- if (wall) args.push('--wall', wall);
310
- if (approve) args.push('--approve', approve);
311
- return await bundleMain(args, { ...ctx, deps, keysHome, parseFlags, printReds });
312
- }
313
- if (choice === '3') {
314
- const bundleDir = (await rl.question('bundle dir: ')).trim();
315
- return doHistory([bundleDir], ctx);
316
- }
317
- ctx.err(`unknown choice ${JSON.stringify(choice)} — one of: 1, 2, 3, q`);
318
- return 1;
296
+ if (cmd === 'start') return await startCmd(io, d);
297
+ if (cmd === 'stop') return await stopCmd(rest, io, d);
298
+ if (cmd === 'status') return await statusCmd(io, d);
299
+ if (cmd === 'install') return await installCmd(io, d);
300
+ return await menuCmd(io, d);
319
301
  } finally {
320
302
  rl.close();
321
303
  }
@@ -326,7 +308,7 @@ async function runMenu(deps, ctx, keysHome) {
326
308
  * code, so `bin/bareloop.mjs` can set `process.exitCode` and let node flush
327
309
  * queued stdout on its own (F-something: `process.exit()` can discard it).
328
310
  * @param {string[]} argv
329
- * @param {{ env?: Record<string,string|undefined>, stdout?: any, stderr?: any, cwd?: string, provider?: any, providerFor?: any, judgeProvider?: any, judgeModel?: string|null, now?: () => number, stdin?: any, runlistHome?: string, keysHome?: string }} deps
311
+ * @param {{ env?: Record<string,string|undefined>, stdout?: any, stderr?: any, cwd?: string, provider?: any, providerFor?: any, judgeProvider?: any, judgeModel?: string|null, now?: () => number, stdin?: any, runlistHome?: string, keysHome?: string, processEnv?: Record<string,string|undefined> }} deps
330
312
  * @returns {Promise<number>}
331
313
  */
332
314
  export async function main(argv, deps = {}) {
@@ -345,7 +327,9 @@ export async function main(argv, deps = {}) {
345
327
 
346
328
  const [cmd, ...rest] = argv;
347
329
  if (keys.warning && cmd && ['run', 'run-u', 'interview', 'author', 'panel'].includes(cmd)) err(`WARNING: ${keys.warning}`);
348
- if (!cmd) return runMenu({ ...deps, stdin: deps.stdin ?? process.stdin, stdout }, ctx, keys.home);
330
+ const launcherHome = keys.home ?? deps.runlistHome;
331
+ if (!cmd) return runLauncher('menu', [], { ...deps, stdout }, ctx, launcherHome);
332
+ if (cmd === 'start' || cmd === 'stop' || cmd === 'status' || cmd === 'install') return runLauncher(cmd, rest, { ...deps, stdout }, ctx, launcherHome);
349
333
  if (cmd === 'export') return doExport(rest, ctx);
350
334
  if (cmd === 'run') return bundleMain(rest, { ...ctx, keysHome: keys.home, parseFlags, printReds });
351
335
  if (cmd === 'history') return doHistory(rest, ctx);
@@ -388,6 +372,6 @@ export async function main(argv, deps = {}) {
388
372
  // and spine/gate-audit reads over `127.0.0.1` only. `deps.runlistHome`
389
373
  // rides through the same injectable seam `run`/`run-u` already use.
390
374
  if (cmd === 'panel') return panelMain(rest, { out, err, runlistHome: deps.runlistHome, env: deps.env });
391
- err(`unknown command ${JSON.stringify(cmd)} — one of: export, run, history, run-u, interview, author, replay, runs, panel`);
375
+ err(`unknown command ${JSON.stringify(cmd)} — one of: export, run, history, run-u, interview, author, replay, runs, panel, start, stop, status, install`);
392
376
  return 1;
393
377
  }