show-me-the-env 0.93.3 → 0.95.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "show-me-the-env",
3
- "version": "0.93.3",
3
+ "version": "0.95.0",
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';
@@ -40,6 +42,9 @@ export function modelSettings(models = {}, home = os.homedir()) {
40
42
  tiers: { fast: 'lazycodex-worker-low', standard: 'lazycodex-worker-medium', frontier: 'lazycodex-worker-high', ...models.tiers },
41
43
  whenThrottled: models.whenThrottled ?? {},
42
44
  shareFile: models.shareFile ? expandHome(models.shareFile, home) : null,
45
+ // Points of the Claude weekly share summed over the accounts (the share file's unit); under it a read-only or markdown unit runs
46
+ // on the model whenThrottled names. No default: without it nothing moves before the share is gone.
47
+ claudeReserve: Number.isFinite(models.claudeReserve) ? models.claudeReserve : 0,
43
48
  };
44
49
  }
45
50
 
@@ -144,6 +149,9 @@ export function pick(u, settings, { claudeShareLeft = Infinity, effortPin = null
144
149
  } else if (claudeShareLeft <= 0 && elsewhere) {
145
150
  extra = '; no Claude share left at the account guard, ' + model + ' runs as ' + elsewhere;
146
151
  model = elsewhere;
152
+ } else if (claudeShareLeft < settings.claudeReserve && elsewhere && (chk.domain === 'knowledge' || chk.domain === 'writing')) {
153
+ extra = '; Claude share ' + claudeShareLeft + ' under the reserve ' + settings.claudeReserve + ', a ' + chk.domain + ' unit runs as ' + elsewhere;
154
+ model = elsewhere;
147
155
  } else if (hot(model) && elsewhere) {
148
156
  extra = '; ' + model + ' ended a session on 429 within 30 min, runs as ' + elsewhere;
149
157
  model = elsewhere;
@@ -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,6 +574,8 @@ 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
581
  if (chosen.held) { say('launch HELD ' + u.id + ': a visual unit would start on ' + chosen.model + ', not Fable'); return; }