show-me-the-env 0.94.0 → 0.95.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "show-me-the-env",
3
- "version": "0.94.0",
3
+ "version": "0.95.1",
4
4
  "description": "Save and restore your whole agent and coding environment as one versioned .agenv repository.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -8,6 +8,8 @@
8
8
  // runner-<domain> that is not past its re-judge date replaces the omo rung, only with a model the omo file names.
9
9
  // 4. On top: a visual unit (visual: true, model fable, or a skill naming uiux, frontend, video, brand or design) runs on the newest
10
10
  // Fable in the model routes (models.routes), at high effort or above; heldVisual is the launch preflight that holds it otherwise.
11
+ // Fable goes only to work whose quality needs it, the direction, creative and design work its queue owner marks that way; no
12
+ // unit moves to Fable to use up its quota, since Fable's use counts against the same weekly share (the owner's rule, 2026-12-04).
11
13
  // The two skills are hard dependencies: a pick fails when either is missing from the skills folder (models.skills).
12
14
  import { spawnSync } from 'node:child_process';
13
15
  import fs from 'node:fs';
@@ -123,8 +125,8 @@ function resolveEffort(effort, omoReasoning) {
123
125
  return EFFORTS[Math.min(want, ceiling)];
124
126
  }
125
127
 
126
- // pick(u, settings, { claudeShareLeft, effortPin, throttled, now }) -> { model, effort, held, basis }; throttled maps a model to the
127
- // time a session of it ended on a 429.
128
+ // pick(u, settings, { claudeShareLeft, effortPin, throttled, now }) -> { model, effort, held, why, basis }; throttled maps a model
129
+ // to the time a session of it ended on a 429, and why says what holds a held unit.
128
130
  export function pick(u, settings, { claudeShareLeft = Infinity, effortPin = null, throttled = {}, now = Date.now() } = {}) {
129
131
  const agents = readOmo(settings.omo);
130
132
  const allowed = new Set(Object.values(agents).map((a) => a.model));
@@ -138,23 +140,31 @@ export function pick(u, settings, { claudeShareLeft = Infinity, effortPin = null
138
140
  let extra = '';
139
141
  const hot = (m) => now - (throttled[m] ?? 0) < THROTTLE_MS;
140
142
  let held = false;
143
+ let why = '';
141
144
  const elsewhere = settings.whenThrottled[model];
145
+ // A fallback that ended a session on a 429 within 30 min takes no unit (2026-12-04 11:1x: coggs-module-audit-1204 and both
146
+ // relaunches went to the reserve's model while its one account cooled down, and each ended on a 429 within seconds).
147
+ const fallbackHot = Boolean(elsewhere) && hot(elsewhere);
142
148
  if (isVisual(u)) {
143
149
  model = newestFable(settings.routes);
144
150
  if (EFFORTS.indexOf(effort) < EFFORTS.indexOf('high')) effort = 'high';
145
151
  extra = '; visual unit, forced to ' + model + ' (newest Fable in ' + settings.routes.replaceAll('\\', '/') + ')';
146
- if (hot(model)) { held = true; extra += '; ' + model + ' ended a session on 429 within 30 min, held'; }
152
+ if (hot(model)) { held = true; why = model + ' ended a session on 429 within 30 min'; extra += '; ' + why + ', held'; }
147
153
  } else if (claudeShareLeft <= 0 && elsewhere) {
148
- extra = '; no Claude share left at the account guard, ' + model + ' runs as ' + elsewhere;
149
- model = elsewhere;
154
+ if (fallbackHot) { held = true; why = 'no Claude share left and ' + elsewhere + ' ended a session on 429 within 30 min'; extra = '; ' + why + ', held'; }
155
+ else { extra = '; no Claude share left at the account guard, ' + model + ' runs as ' + elsewhere; model = elsewhere; }
150
156
  } else if (claudeShareLeft < settings.claudeReserve && elsewhere && (chk.domain === 'knowledge' || chk.domain === 'writing')) {
151
- extra = '; Claude share ' + claudeShareLeft + ' under the reserve ' + settings.claudeReserve + ', a ' + chk.domain + ' unit runs as ' + elsewhere;
152
- model = elsewhere;
157
+ if (fallbackHot) {
158
+ held = hot(model);
159
+ why = model + ' and ' + elsewhere + ' each ended a session on 429 within 30 min';
160
+ extra = '; Claude share ' + claudeShareLeft + ' under the reserve ' + settings.claudeReserve + ', but ' + elsewhere + ' ended a session on 429 within 30 min, so the ' + chk.domain + ' unit stays on ' + model + (held ? ', which did too, held' : '');
161
+ } else { extra = '; Claude share ' + claudeShareLeft + ' under the reserve ' + settings.claudeReserve + ', a ' + chk.domain + ' unit runs as ' + elsewhere; model = elsewhere; }
153
162
  } else if (hot(model) && elsewhere) {
154
- extra = '; ' + model + ' ended a session on 429 within 30 min, runs as ' + elsewhere;
155
- model = elsewhere;
163
+ if (fallbackHot) { held = true; why = model + ' and ' + elsewhere + ' each ended a session on 429 within 30 min'; extra = '; ' + why + ', held'; }
164
+ else { extra = '; ' + model + ' ended a session on 429 within 30 min, runs as ' + elsewhere; model = elsewhere; }
156
165
  }
157
166
  if (effortPin) effort = effortPin;
158
167
  const basis = 'omo.jsonc [codex].agents.' + key + ' = ' + omoRow.model + ' ' + omoRow.reasoning + '; model-ladder: ' + lad.line + '; modelchk: ' + chk.tier + ' + ' + chk.effort + ', ' + chk.domain + ' (' + chk.why + ')' + extra + (effortPin ? '; effort pinned ' + effortPin : '');
159
- return { model, effort, held: held || heldVisual(u, model), basis };
168
+ if (!held && heldVisual(u, model)) { held = true; why = 'a visual unit would start on ' + model + ', not Fable'; }
169
+ return { model, effort, held, why, basis };
160
170
  }
@@ -87,7 +87,9 @@ export function readFleet(file, { queueFile, home = os.homedir(), hostname = os.
87
87
  need(typeof raw.workspace === 'string' && raw.workspace, 'workspace, the folder on this machine that holds repository checkouts by name');
88
88
  need(typeof raw.agentCli === 'string' && raw.agentCli, 'agentCli, the agent CLI on the runners');
89
89
  need(typeof raw.routes?.claude === 'string', 'routes.claude, the model route a runner session reaches');
90
- need(raw.preflight === undefined || (Array.isArray(raw.preflight?.command) && raw.preflight.command.length && raw.preflight.command.every((a) => typeof a === 'string') && (raw.preflight.command[0] === 'node' || path.isAbsolute(raw.preflight.command[0]))), 'preflight.command, a list of arguments whose first is node or an absolute program');
90
+ const isCommand = (c) => Array.isArray(c) && c.length && c.every((a) => typeof a === 'string') && (c[0] === 'node' || path.isAbsolute(c[0]));
91
+ need(raw.preflight === undefined || isCommand(raw.preflight?.command), 'preflight.command, a list of arguments whose first is node or an absolute program');
92
+ need(raw.preflight?.also === undefined || (Array.isArray(raw.preflight.also) && raw.preflight.also.every(isCommand)), 'preflight.also, a list of further checks, each a list of arguments whose first is node or an absolute program');
91
93
  const isPort = (p) => Number.isInteger(p) && p > 0 && p < 65536;
92
94
  // A relay puts a key in, so its proxy is on this machine and the key never crosses a network.
93
95
  need(raw.relays === undefined || (Array.isArray(raw.relays) && raw.relays.every((r) => isPort(r?.port) && /^http:\/\/(127\.0\.0\.1|localhost):\d+\/?$/.test(r.upstream ?? '') && (r.key === undefined || r.key === 'cli-proxy-api'))), 'relays, each with a port, an upstream http address on this machine and key cli-proxy-api or none');
@@ -308,14 +310,25 @@ export async function chooseUnits({ units, state, runners, loads, cap, minFreeGB
308
310
  return { picks, free, skillHeld, preflightHeld, noCheckout, leaderRefused, notes };
309
311
  }
310
312
 
311
- // The person's dispatch check (preflight.command in the settings), run for one unit about to start. Exit 0 lets it start, and the block
312
- // its JSON answer carries joins the prompt; any other exit holds it, with the faults the answer names or what it printed. Placeholders:
313
- // {ledgerEntry}, {repository}, {workspace}, {files} (the unit's paths joined by ", "), {id} and {name}. An argument that is only a
314
- // placeholder with no value is left out with the flag before it, so a unit naming no path runs the check without that flag.
313
+ // The person's dispatch check (preflight.command in the settings), run for one unit about to start, then each further check in
314
+ // preflight.also once it passes. Exit 0 lets it start, and the first block a JSON answer carries joins the prompt; any other exit holds
315
+ // it, with the faults the answer names or what it printed. Placeholders: {ledgerEntry}, {repository}, {workspace}, {files} (the unit's
316
+ // paths joined by ", "), {prompt} (the unit's prompt file), {id} and {name}. An argument that is only a placeholder with no value is left
317
+ // out with the flag before it, so a unit naming no path runs the check without that flag.
315
318
  export async function runPreflight(fleet, u, home = os.homedir()) {
316
- const values = { ledgerEntry: ledgerKey(u), repository: String(u.repository ?? ''), workspace: fleet.workspace, files: touched(u).join(', '), id: u.id, name: u.name };
319
+ const values = { ledgerEntry: ledgerKey(u), repository: String(u.repository ?? ''), workspace: fleet.workspace, files: touched(u).join(', '), prompt: u.prompt ? path.resolve(fleet.inputsRoot ?? fleet.workspace, u.prompt) : '', id: u.id, name: u.name };
320
+ let block = null;
321
+ for (const command of [fleet.preflight.command, ...(fleet.preflight.also ?? [])]) {
322
+ const r = await runCheck(command, values, home);
323
+ if (!r.ok) return r;
324
+ block ??= r.block;
325
+ }
326
+ return { ok: true, block };
327
+ }
328
+
329
+ async function runCheck(command, values, home) {
317
330
  const args = [];
318
- for (const a of fleet.preflight.command) {
331
+ for (const a of command) {
319
332
  const only = /^\{(\w+)\}$/.exec(a);
320
333
  if (only && !values[only[1]]) { if (args.at(-1)?.startsWith('--')) args.pop(); continue; }
321
334
  args.push(a.replace(/\{(\w+)\}/g, (m, k) => values[k] ?? m).replace(/^~(?=[\\/])/, home));
@@ -325,7 +338,7 @@ export async function runPreflight(fleet, u, home = os.homedir()) {
325
338
  let answer = null;
326
339
  try { answer = JSON.parse(r.stdout.text); } catch {}
327
340
  if (r.exit === 0) return { ok: true, block: answer?.block ?? null };
328
- const said = Array.isArray(answer?.faults) && answer.faults.length ? answer.faults.join('; ') : r.stderr.text.trim() || (r.timedOut ? 'no answer in 60 s' : 'no output');
341
+ const said = Array.isArray(answer?.faults) && answer.faults.length ? answer.faults.join('; ') : r.stderr.text.trim() || r.stdout.text.trim() || (r.timedOut ? 'no answer in 60 s' : 'no output');
329
342
  return { ok: false, why: 'exit ' + (r.exit ?? r.error) + ', ' + said.replace(/\s+/g, ' ').slice(0, 400) };
330
343
  }
331
344
 
@@ -395,12 +408,30 @@ function saveState(file, state) {
395
408
  fs.renameSync(tmp, file);
396
409
  }
397
410
 
411
+ // The lists a person changes while the watcher runs, by editing the state file between passes. A pass works on the copy it read at its
412
+ // start, so an edit made while it ran was written over at its next save: on 2026-12-04 09:33 a pass that had read the state before six
413
+ // units were held launched them and saved the state without their holds. A save takes the additions and removals made on disk since the
414
+ // pass last read or wrote the lists (base), and a launch reads the lists on disk once more just before it starts its session.
415
+ const PERSON_LISTS = ['hold', 'skip'];
416
+ const listsOf = (state) => Object.fromEntries(PERSON_LISTS.map((k) => [k, new Set(state[k] ?? [])]));
417
+ function mergePersonLists(st, disk, base) {
418
+ for (const k of PERSON_LISTS) {
419
+ const now = new Set(disk[k] ?? []);
420
+ const added = [...now].filter((x) => !base[k].has(x));
421
+ const removed = new Set([...base[k]].filter((x) => !now.has(x)));
422
+ st[k] = [...new Set([...(st[k] ?? []), ...added])].filter((x) => !removed.has(x));
423
+ base[k] = new Set(st[k]);
424
+ }
425
+ }
426
+
398
427
  // One pass. io is the runner side (session.mjs) and git; a test passes its own. Returns what the pass did, or in shadow mode what it would.
399
428
  export async function fillPass({ fleet, queueFile, options = {}, shadow = false, io, onLine = () => {} }) {
400
429
  const say = (s) => { const line = stamp() + ' ' + (shadow ? 'shadow ' : '') + s; if (!shadow) fs.appendFileSync(fleet.log, line + '\n'); onLine(line); };
401
430
  const q = JSON.parse(fs.readFileSync(queueFile, 'utf8'));
402
- const st = applyOptions(loadState(fleet.state), { skip: list(options.skip), hold: list(options.hold), release: list(options.release), retry: list(options.retry) });
403
- const save = () => { if (!shadow) saveState(fleet.state, st); };
431
+ const loaded = loadState(fleet.state);
432
+ const base = listsOf(loaded);
433
+ const st = applyOptions(loaded, { skip: list(options.skip), hold: list(options.hold), release: list(options.release), retry: list(options.retry) });
434
+ const save = () => { if (shadow) return; mergePersonLists(st, loadState(fleet.state), base); saveState(fleet.state, st); };
404
435
  const unitOf = Object.fromEntries(q.units.map((u) => [u.id, u]));
405
436
  const runnerOf = (id) => fleet.runners.find((r) => r.id === id);
406
437
  const place = Object.fromEntries(list(options.place).map((x) => x.split('=')));
@@ -543,9 +574,11 @@ export async function fillPass({ fleet, queueFile, options = {}, shadow = false,
543
574
  const { unit: u, runner } = p;
544
575
  const name = names[u.id], minutes = u.minutes ?? 60;
545
576
  if (p.inputs.shared.some((rel) => !sharedAt[runner + ' ' + rel])) { say('launch HELD ' + u.id + ': its shared input could not be placed on ' + runner); return; }
577
+ const onDisk = listsOf(loadState(fleet.state));
578
+ if (onDisk.hold.has(u.id) || onDisk.skip.has(u.id)) { say('launch HELD ' + u.id + ': ' + (onDisk.hold.has(u.id) ? 'held' : 'skipped') + ' in the state file while this pass ran'); return; }
546
579
  const chosen = pickModel(u, fleet.models, { claudeShareLeft: shareLeft(fleet.models.shareFile), effortPin: pins[u.id] ?? u.effort ?? null, throttled: st.throttled ?? {} });
547
580
  say('pick ' + u.id + ' -> ' + chosen.model + ' ' + chosen.effort + ': ' + chosen.basis);
548
- if (chosen.held) { say('launch HELD ' + u.id + ': a visual unit would start on ' + chosen.model + ', not Fable'); return; }
581
+ if (chosen.held) { say('launch HELD ' + u.id + ': ' + chosen.why); return; }
549
582
  const started = await io.startSession(fleet, runnerOf(runner), {
550
583
  name, promptFile: p.prompt, repoDir: path.join(fleet.workspace, p.repo), sha: p.sha, mode: 'write', model: chosen.model, effort: chosen.effort, minutes,
551
584
  branch: 'fleet/' + name, cap: capOverride ?? runnerOf(runner).cap, inputsDir: p.inputs.bytes > 0 || p.inputs.skipped || p.inputs.shared.length ? p.inputs.dir : null,