show-me-the-env 0.93.0 → 0.93.2

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/README.md CHANGED
@@ -1,29 +1,46 @@
1
1
  # show-me-the-env
2
2
 
3
- `agenv` saves the agent and coding environment of one machine (the tools a person relies on and their settings files) into a folder they keep in git, and restores it on another machine. Every change is shown first as a plan with a digest, and nothing is written until the person approves that exact digest.
3
+ ### Show me the env: `agenv` shows what your AI coding environment is made of, keeps it in a git repository you own, and brings it back on the next machine.
4
4
 
5
- Status: versioned from its first commit, with a tag and a GitHub Release for every version, and published to npm with provenance from the first npm release on; the commands below may still change. This page states only what has been run and checked; [references/support.md](references/support.md) holds the support state of every tool and platform.
5
+ `agenv` sets up a new Windows or Linux machine with the agent CLIs, settings, plugins and skills your last one had. Every change is shown first as a plan with a short hash, its digest, and nothing is written until you approve that digest.
6
+
7
+ Status: 0.x and still changing; every version is tagged, released and published to npm as `show-me-the-env`, verified on fresh Windows 11 and Ubuntu 24.04 virtual machines, not yet verified on macOS.
6
8
 
7
9
  ![The agenv window on the This machine view, showing the profile folder and Secrets: not included](references/window.jpg)
8
10
 
9
- The capture above is the window as `agenv ui` draws it with its default settings, where secrets are left out of save and load. It is produced and checked by `node scripts/qa.mjs --case release-docs --variant happy`, which also starts the window and reads the same state back from it.
11
+ The capture is the window `agenv ui` opens with its default settings.
10
12
 
11
- ## Platforms
13
+ ## Install
12
14
 
13
- | Platform | State |
14
- | --- | --- |
15
- | Windows 11 x64 | verified on a clean guest restored from its base snapshot (Windows 11 Enterprise evaluation, build 26300) |
16
- | Linux x64 | verified on a clean guest restored from its base snapshot (Ubuntu 24.04.5 LTS); the native binary needs the `libatomic1` package first |
17
- | macOS | unverified: macOS may only be virtualized on Apple hardware under Apple's license, and the validation lab is Hyper-V on a Windows host, so no macOS guest exists |
15
+ ```sh
16
+ npx show-me-the-env doctor --gaps
17
+ ```
18
18
 
19
- Verified here means each of these journeys passed on both guests from the installed release candidate, with no Node, Git or checkout on the guest: init, save, load, update from an older candidate, a repeated load that changes nothing, a refused approval, a follow conflict and a contribution preview (`node scripts/qa.mjs --case journey-<name> --live <guest>`).
19
+ That runs the package's one command, `agenv`, with Node 22 or newer, and changes nothing.
20
20
 
21
- ## Install
21
+ - `npm install -g show-me-the-env` keeps `agenv` on your PATH for the Quickstart below.
22
+ - `npx -y skills@latest add LilMGenius/show-me-the-env --global --agent '*' --skill '*' -y` (bash or PowerShell) copies the skills below into the global skill folder of every coding agent the skills CLI finds, Claude Code and Codex among them.
23
+ - [references/install.md](references/install.md) lists the native binaries and every other route, or hand your agent `https://github.com/LilMGenius/show-me-the-env` and ask it to set this up.
24
+
25
+ ## Skills
22
26
 
23
- With Node 22 or newer, `npx show-me-the-env doctor --gaps` runs `agenv` without installing it, and `npm install -g show-me-the-env` puts `agenv` on your PATH. [references/install.md](references/install.md) is the one place that says how to get `agenv`, the native binaries included.
27
+ A skill is a set of instructions your coding agent loads; each of these drives `agenv` for you, so you can ask in plain words instead of typing commands.
28
+
29
+ | Skill | What it does |
30
+ | --- | --- |
31
+ | `agenv:init` | Starts a profile, or lists what this machine lacks with a suggested tool per role |
32
+ | `agenv:save` | Previews what a save would change and writes only the plan whose digest you approve |
33
+ | `agenv:load` | Brings this machine to your profile, previewing every change first |
34
+ | `agenv:contribute` | Turns what `agenv` could not install, configure or detect into an issue or pull request, sent once you approve its preview |
35
+ | `agenv:attach` | Attaches another computer you own so it can take this machine's long jobs; see [docs/MACHINES.md](docs/MACHINES.md) |
36
+ | `/show-me-the-env:patch` | Repairs Claude Code and Codex plugin hooks that fail on Windows, from the [plugin below](#plugin-hooks-on-windows) |
37
+
38
+ The command is `agenv`, and the five profile skills install under its name, `agenv:*`.
24
39
 
25
40
  ## Quickstart
26
41
 
42
+ These lines assume `npm install -g show-me-the-env`; with npx, write `npx show-me-the-env` where they say `agenv`.
43
+
27
44
  ```sh
28
45
  agenv doctor --gaps
29
46
  agenv init --data-root ~/my-env --select codex
@@ -34,83 +51,90 @@ agenv load --data-root ~/my-env --approve <digest>
34
51
  agenv ui --data-root ~/my-env
35
52
  ```
36
53
 
37
- 1. `doctor --gaps` lists every tool `agenv` knows and what it finds on this machine. It changes nothing.
38
- 2. `init --data-root <folder>` creates `manifest.json` there. `--select <ids>` records tools from that list together with the settings files `agenv` knows for them; for `codex` that includes `~/.codex/config.toml`.
39
- 3. `save` prints what it would write into the folder and a digest, and exits 3. Run it again with `--approve <digest>` to write exactly that. When nothing differs it says so and exits 0, and there is nothing to approve.
40
- 4. Keep a folder you named with `--data-root` in git yourself. Without `--data-root` or `AGENV_DATA_ROOT`, `save` uses the snapshot repository `~/.agenv` (`save --create` makes it, private on GitHub) and commits and pushes each approved save itself, staging only the paths it wrote. On the other machine, `load` prints the plan for that machine and its digest, and `--approve <digest>` applies it. A digest from an older plan is refused with exit 3 and nothing is written.
41
- 5. `ui` opens the same steps in a window served on 127.0.0.1.
54
+ 1. `doctor --gaps` lists every tool `agenv` knows and what it finds here. `init --data-root <folder>` creates `manifest.json` there, and `--select <ids>` records the tools you name by the ids `doctor` prints, with the settings files `agenv` knows for them (for `codex`, `~/.codex/config.toml`).
55
+ 2. `save` and `load` print a plan and its digest, then exit 3, which means they wait for your approval. The same command with `--approve <digest>` applies exactly that plan; a digest from an older plan is refused.
56
+ 3. Keep the `--data-root` folder in git yourself and clone it on the other machine, then run the two `load` lines there. Leave `--data-root` out and `save` uses `~/.agenv` instead, committing and pushing each approved save; `save --create` makes it a private GitHub repository in your account.
57
+ 4. `ui` opens the same steps in a window served on 127.0.0.1.
58
+
59
+ `agenv --help` lists every command with its options and exit codes, catalog, adopt, follow, contribute, ignored, run and machine among them. [docs/MACHINES.md](docs/MACHINES.md) explains run and machine, [docs/QUEUE.md](docs/QUEUE.md) the queued agent sessions of run, and [docs/IGNORED.md](docs/IGNORED.md) ignored.
60
+
61
+ ## Supported programs
62
+
63
+ ✅ Full: settings and lists are saved, restored and checked against the machine. 🟡 Partial: some of the program's state is saved. 👀 Detected: found on the maintainer's reference machine, nothing saved yet. 🗓️ Planned: not built yet. A blank cell is zero. Each category links to its rows in [the support matrix](docs/SUPPORT-MATRIX.md), and [references/support.md](references/support.md) says which operations a fresh machine verified on each platform.
64
+
65
+ <!-- support-summary:start -->
66
+
67
+ | Category | ✅ Full | 🟡 Partial | 👀 Detected | 🗓️ Planned |
68
+ | --- | ---: | ---: | ---: | ---: |
69
+ | [Agent CLI](docs/SUPPORT-MATRIX.md#agent-cli) | 2 | 7 | 2 | 8 |
70
+ | [AI desktop app](docs/SUPPORT-MATRIX.md#ai-desktop-app) | 1 | | 1 | 5 |
71
+ | [Proxy](docs/SUPPORT-MATRIX.md#proxy) | 2 | | | 1 |
72
+ | [Local model runner](docs/SUPPORT-MATRIX.md#local-model-runner) | | | | 9 |
73
+ | [Editor agent extension](docs/SUPPORT-MATRIX.md#editor-agent-extension) | 2 | | | 5 |
74
+ | [IDE](docs/SUPPORT-MATRIX.md#ide) | 1 | 1 | 2 | 8 |
75
+ | [Agent workspace](docs/SUPPORT-MATRIX.md#agent-workspace) | | | | 2 |
76
+ | [Editor](docs/SUPPORT-MATRIX.md#editor) | | | 3 | 5 |
77
+ | [Terminal](docs/SUPPORT-MATRIX.md#terminal) | 1 | | | 10 |
78
+ | [Shell and prompt](docs/SUPPORT-MATRIX.md#shell-and-prompt) | 1 | | | 7 |
79
+ | [Runtime and package manager](docs/SUPPORT-MATRIX.md#runtime-and-package-manager) | 4 | 1 | 7 | 10 |
80
+ | [Tooling](docs/SUPPORT-MATRIX.md#tooling) | 2 | 2 | 6 | 13 |
81
+ | [Cloud CLI](docs/SUPPORT-MATRIX.md#cloud-cli) | | 1 | | 10 |
82
+ | [Secret manager](docs/SUPPORT-MATRIX.md#secret-manager) | | | | 2 |
83
+ | [API and database client](docs/SUPPORT-MATRIX.md#api-and-database-client) | | | | 7 |
84
+ | [Browser](docs/SUPPORT-MATRIX.md#browser) | | | 4 | 6 |
85
+ | [Collaboration](docs/SUPPORT-MATRIX.md#collaboration) | | 2 | 1 | 2 |
86
+ | [Desktop utility](docs/SUPPORT-MATRIX.md#desktop-utility) | | | 1 | 5 |
87
+ | [Creative tool](docs/SUPPORT-MATRIX.md#creative-tool) | | 1 | 2 | 2 |
88
+ | [Game engine](docs/SUPPORT-MATRIX.md#game-engine) | | | 5 | 1 |
89
+
90
+ <!-- support-summary:end -->
42
91
 
43
- Each line is run, with Codex and one Codex settings file in the first home and a second home without the settings file standing in for the other machine, by `node scripts/qa.mjs --case release-docs --variant happy` in an empty home, by the package's own `bin/agenv.mjs` or, with `--param rc=<candidate folder>`, by a release candidate's binary.
92
+ | Platform | State |
93
+ | --- | --- |
94
+ | Windows 11 x64 | verified on a fresh virtual machine restored from its base snapshot (Windows 11 Enterprise evaluation, build 26300) |
95
+ | Linux x64 | verified on a fresh virtual machine restored from its base snapshot (Ubuntu 24.04.5 LTS); the native binary needs the `libatomic1` package first |
96
+ | macOS | unverified: macOS may only be virtualized on Apple hardware under Apple's license, and the validation lab is Hyper-V on a Windows host, so no macOS virtual machine exists to verify on |
44
97
 
45
- ## Commands
98
+ Verified means init, save, load, an update, a repeated load, a refused approval, a conflict while following a catalog profile and a contribution preview each passed on both virtual machines from the installed release candidate, with no Node, Git or checkout there.
46
99
 
47
- | Command | What it does |
48
- | --- | --- |
49
- | `init` | Starts a profile in `--data-root`, or lists missing prerequisites when none is given |
50
- | `save` | Shows what would be saved from this machine; `--approve <digest>` writes it |
51
- | `load` | Shows what this machine lacks from the profile; `--approve <digest>` applies it |
52
- | `doctor` | Reports tools, orphaned installers, commit signing and pending saves; changes nothing |
53
- | `catalog` | Lists the creator profiles `agenv` ships, with what each installs and the permissions it asks for |
54
- | `adopt` | Shows what adopting a catalog profile would change; `--approve <digest>` applies it |
55
- | `follow` | Checks an adopted profile for a newer revision; a setting you changed since is kept and reported as a conflict (exit 4) |
56
- | `contribute` | Drafts an issue or pull request from a finding with home paths and tokens redacted; only `--send <id> --approve <preview>` sends it |
57
- | `ignored` | Copies the ledgers, evidence and notes your repositories ignore into your private profile, and puts them back on another machine; see [docs/IGNORED.md](docs/IGNORED.md) |
58
- | `ui` | Opens a local window for status, recommendations, save, load, history, profiles and contributions |
59
- | `run` | Runs a command at your commit on another machine you can reach over SSH and keeps a receipt; see [docs/MACHINES.md](docs/MACHINES.md). With `--queue` it starts queued agent sessions on your runners whenever a slot is free there; see [docs/QUEUE.md](docs/QUEUE.md) |
60
- | `machine` | Attaches another computer so it can take work: `bootstrap` writes its setup script and `serve` hands it over on your network for a bounded time, and `specs` and `register` read the machine and keep its row in your own register of machines; see [docs/MACHINES.md](docs/MACHINES.md) |
61
-
62
- Exit codes: 0 done or nothing to do, 2 invalid input, 3 your approval is needed, 4 something changed since the plan, 5 a step failed, 130 cancelled.
63
-
64
- ## Secrets and private data
100
+ ## Safe defaults
65
101
 
102
+ - Nothing is written until you approve the digest of the plan you saw, and every install `load` runs is an action in that plan (`node scripts/qa.mjs --case journey-denied-consent`).
66
103
  - Entries under `secrets/` in a profile are left out of save and load unless `--include-secrets` is given (`node scripts/qa.mjs --case save`).
67
- - A save stops when a file it would write carries a token, a private key or a planted canary, and writes nothing (`node scripts/qa.mjs --case leak-canary`).
68
- - A contribution draft is stored on the machine and sent nothing until `--send` with the exact preview digest (`node scripts/qa.mjs --case journey-contribution-preview`).
104
+ - A save stops when a file it would write carries a token, a private key or a planted test secret, and writes nothing (`node scripts/qa.mjs --case leak-canary`).
105
+ - A contribution draft stays on the machine until `--send <id> --approve <preview>` names its exact preview (`node scripts/qa.mjs --case journey-contribution-preview`).
69
106
  - The window listens on 127.0.0.1 only, requires a per-launch secret on every request and refuses requests from other origins (`node scripts/qa.mjs --case desktop-ui`).
70
107
 
71
- ## Measured timings
72
-
73
- From [packaging/benchmark-decision.json](packaging/benchmark-decision.json): a full init, save and load journey over a 24-file profile, 30 runs per cohort on each clean guest. Median on Ubuntu 24.04.5 (2 vCPU) was 2647 ms cold and 2988 ms warm; on Windows 11 (4 vCPU) 7968 ms cold and 6924 ms warm. Running four independent changes at once was not faster on every cohort, so `--jobs` stays 1 by default. Launch time, memory and size of the native binary are in [references/architecture.md](references/architecture.md), measured as recorded in [packaging/architecture-decision.json](packaging/architecture-decision.json).
108
+ ## Plugin hooks on Windows
74
109
 
75
- ## Limitations
76
-
77
- - macOS is unverified (see Platforms).
78
- - Most tool cells are unverified or experimental; [references/support.md](references/support.md) lists them per tool, operation and platform.
79
- - On Windows the first launch of the native binary unpacks its payload and is slower than later launches (measured in [references/architecture.md](references/architecture.md)).
80
- - The native Linux binary needs `libatomic1`, which Ubuntu cloud images leave out.
81
- - `load` installs a missing tool only at the version the profile pins. `init --select` pins a tool that is not installed at the version its adapter names; where an adapter names none, `init` says so, and `load` reports that install as unsupported (exit 5) until a version is added to `manifest.json`.
82
- - There is no rollback command yet; the window's History view is read-only.
83
- - A follow conflict is detected for tool settings a profile sets; profile files are not compared against the adopted revision.
84
-
85
- ## Milestones
86
-
87
- Each milestone is a set of functional gates. None of them is a version number yet, and none has a date or a target count.
88
-
89
- | Milestone | Gates | State |
90
- | --- | --- | --- |
91
- | v0.1 | private data boundary, the creator's own profile, one action contract for CLI and window, a measured timing baseline, source links kept | built and exercised on Windows and Linux; whether it is 0.1 is the founder's review |
92
- | v0.2 | checkout-free install with PATH on clean Windows and macOS, parallel changes, recovery after an interruption | install and PATH verified on Windows and Linux; macOS unverified; parallel changes measured and kept off by default; recovery tested on fixtures only |
93
- | v0.3 | support matrix per tool, operation and platform, inventory-to-gap contributions, verification per revision | built; contributions are drafted and sent only on approval |
94
- | v0.5 | a desktop window over the same actions, browse, adopt and contribute, a measured decision on a native rewrite | window built in the browser; rewrite decided against on measurement |
95
- | v1.0 | stable contracts, update and rollback, signed distribution where possible, owned support | not met: no rollback command, no signed distribution |
96
- | Sustained | compatibility kept, a support load the maintainers can carry, adapters from contributors | not started |
97
-
98
- ## How adoption will be counted
99
-
100
- Five counts are kept apart and never added together: profile views, adoption attempts, working installs, repeat use and contributions. A repeated view is not a reach or an install. None is collected yet, and none has a source built into `agenv`.
101
-
102
- ## win-hooks
103
-
104
- win-hooks, the repair for Claude Code and Codex plugin hooks that cannot run on Windows, ships from this repository as the plugin in [plugins/win-hooks](plugins/win-hooks/README.md). Its marketplace and plugin are named `show-me-the-env`:
110
+ The show-me-the-env plugin repairs Claude Code and Codex plugin hooks that cannot run on Windows; it was published as win-hooks until that repository merged into this one.
105
111
 
106
112
  ```bash
107
113
  claude plugin marketplace add LilMGenius/show-me-the-env && claude plugin install show-me-the-env@show-me-the-env
108
114
  codex plugin marketplace add LilMGenius/show-me-the-env && codex plugin add show-me-the-env@show-me-the-env
109
115
  ```
110
116
 
111
- An install made as `win-hooks@win-hooks` before the two repositories merged keeps working: the Claude Code marketplace still lists `win-hooks` for it, so it keeps updating from here, and Codex keeps running the version it installed. To move it to the new name, run `claude plugin uninstall win-hooks@win-hooks && claude plugin marketplace remove win-hooks` or `codex plugin remove win-hooks@win-hooks && codex plugin marketplace remove win-hooks`, then the line above; with both installed, every repair runs twice.
117
+ If you already have `win-hooks@win-hooks`, it keeps working; [plugins/win-hooks](plugins/win-hooks/README.md) says what the plugin fixes and how to move that install to the new name.
118
+
119
+ ## Limitations
120
+
121
+ - Most tool cells are unverified or experimental; [references/support.md](references/support.md) lists them per tool, operation and platform.
122
+ - On Windows the native binary's first launch unpacks its payload and is slower than later launches, as [references/architecture.md](references/architecture.md) measures.
123
+ - `load` installs a missing tool only at the version the profile pins. `init --select` pins a tool that is not installed at the version its adapter (the module that knows that tool) names; where the adapter names none, `init` says so and `load` reports that install as unsupported (exit 5) until `manifest.json` names a version.
124
+ - There is no rollback command yet, and while you follow a catalog profile, a conflict is found only for the tool settings that profile sets.
125
+
126
+ ## Source of truth
127
+
128
+ - [manifest.json](manifest.json): the product manifest, its profile layout and the tools `agenv` knows
129
+ - [support.json](support.json): every program and its support level, rendered into [docs/SUPPORT-MATRIX.md](docs/SUPPORT-MATRIX.md) and the table above
130
+ - [references/support.md](references/support.md): verified, experimental and unsupported cells per adapter and platform
131
+ - [references/install.md](references/install.md): every way to get `agenv`
132
+ - [docs/CONTRACT.md](docs/CONTRACT.md): the restore, snapshot and verification procedure
133
+ - [docs/ROADMAP.md](docs/ROADMAP.md): restore levels, coverage, milestones and how adoption is counted
134
+ - [test/cases/release-docs.mjs](test/cases/release-docs.mjs): runs this page's Quickstart in an empty home and retakes the capture (`node scripts/qa.mjs --case release-docs --variant happy`, or on a release candidate's binary with `--param rc=<candidate folder>`); the journeys behind "verified" run with `node scripts/qa.mjs --case journey-<name> --live <guest>`
135
+ - [AGENTS.md](AGENTS.md): the contract for agents working in this repository
112
136
 
113
137
  ## Author and license
114
138
 
115
- Created by [LilMGenius](https://github.com/LilMGenius). MIT license, as `package.json` declares.
139
+ Created by [LilMGenius](https://github.com/LilMGenius). [MIT](LICENSE).
116
140
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "show-me-the-env",
3
- "version": "0.93.0",
3
+ "version": "0.93.2",
4
4
  "description": "Save and restore your whole agent and coding environment as one versioned .agenv repository.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -34,6 +34,10 @@ The founder's order is the web frontend first, so agenv opens its window in the
34
34
 
35
35
  Tauri's binary is a hundredth of Electron's and its slowest start is a quarter of Electron's, while memory and median start are close because both draw with a Chromium engine (WebView2 on Windows). Tauri v2 is therefore where a shell starts, with the Node engine as its sidecar. It was not measured on Linux, where it needs WebKitGTK development headers this build host lacks, so the Linux side of that choice stays open until a Linux Tauri build is measured on the Ubuntu guest.
36
36
 
37
+ ## Journey timings
38
+
39
+ From [packaging/benchmark-decision.json](../packaging/benchmark-decision.json): a full init, save and load journey over a 24-file profile, 30 runs per cohort on each clean guest. Median on Ubuntu 24.04.5 (2 vCPU) was 2647 ms cold and 2988 ms warm; on Windows 11 (4 vCPU) 7968 ms cold and 6924 ms warm. Running four independent changes at once was not faster on every cohort, so `--jobs` stays 1 by default.
40
+
37
41
  ## How the numbers were taken
38
42
 
39
43
  `bench/measure.mjs` runs on each guest after a restore from its base snapshot, under the pinned Node used only as the timer. Launch time is wall clock from process start to the first complete line of output (cold empties the extraction cache first). Memory is the resident set of the process and every descendant after 10 seconds idle (Windows working set, Linux RSS). Window start is from process start to the page's load event. On Windows the windows open in the guest's signed-in desktop session through an interactive scheduled task, because a remote session has no desktop; on Ubuntu they open under a virtual X display with Electron's setuid sandbox installed as its package would install it.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- // Renders support.json as docs/SUPPORT-MATRIX.md and the roadmap's coverage
3
- // counts, and checks that
2
+ // Renders support.json as docs/SUPPORT-MATRIX.md, the README's counts per category
3
+ // and the roadmap's coverage counts, and checks that
4
4
  // every captures entry names something the product manifest really declares (a
5
5
  // profile layout file, directory or key, or a product key such as a task), so the
6
6
  // table cannot claim support the scripts do not give.
@@ -13,6 +13,8 @@ const START = '<!-- support-table:start -->';
13
13
  const END = '<!-- support-table:end -->';
14
14
  const PROGRESS_START = '<!-- support-progress:start -->';
15
15
  const PROGRESS_END = '<!-- support-progress:end -->';
16
+ const SUMMARY_START = '<!-- support-summary:start -->';
17
+ const SUMMARY_END = '<!-- support-summary:end -->';
16
18
  const LABEL = { full: '✅ Full', partial: '🟡 Partial', detect: '👀 Detected', planned: '🗓️ Planned' };
17
19
 
18
20
  function lookup(obj, dotted) {
@@ -79,6 +81,16 @@ export function progress(registry) {
79
81
  '| ' + registry.levels.map(count).join(' | ') + ' | ' + count('full') + ' of ' + installed + ' (' + share + '%) |'].join('\n');
80
82
  }
81
83
 
84
+ // One row per category with its count at each level (blank for none), each category linked to its section of the matrix.
85
+ export function summary(registry) {
86
+ const anchor = (category) => category.toLowerCase().replace(/[^a-z0-9 -]/g, '').replaceAll(' ', '-');
87
+ const rows = registry.categories.map((category) => {
88
+ const counts = registry.levels.map((l) => registry.programs.filter((p) => p.category === category && p.level === l).length);
89
+ return '| [' + category + '](docs/SUPPORT-MATRIX.md#' + anchor(category) + ') | ' + counts.map((n) => (n ? String(n) : '')).join(' | ') + ' |';
90
+ });
91
+ return ['| Category | ' + registry.levels.map((l) => LABEL[l]).join(' | ') + ' |', '| --- | ' + registry.levels.map(() => '---:').join(' | ') + ' |', ...rows].join('\n');
92
+ }
93
+
82
94
  function fill(text, start, end, body, name) {
83
95
  const a = text.indexOf(start);
84
96
  const b = text.indexOf(end);
@@ -88,12 +100,13 @@ function fill(text, start, end, body, name) {
88
100
 
89
101
  export const render = (doc, registry) => fill(doc, START, END, table(registry), 'docs/SUPPORT-MATRIX.md');
90
102
  export const renderProgress = (roadmap, registry) => fill(roadmap, PROGRESS_START, PROGRESS_END, progress(registry), 'docs/ROADMAP.md');
103
+ export const renderSummary = (readme, registry) => fill(readme, SUMMARY_START, SUMMARY_END, summary(registry), 'README.md');
91
104
 
92
105
  if (realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))) {
93
106
  const registry = JSON.parse(readFileSync(join(root, 'support.json'), 'utf8'));
94
107
  const product = JSON.parse(readFileSync(join(root, 'manifest.json'), 'utf8'));
95
108
  const found = problems(registry, product);
96
- for (const [rel, draw] of [['docs/SUPPORT-MATRIX.md', render], ['docs/ROADMAP.md', renderProgress]]) {
109
+ for (const [rel, draw] of [['docs/SUPPORT-MATRIX.md', render], ['docs/ROADMAP.md', renderProgress], ['README.md', renderSummary]]) {
97
110
  const path = join(root, rel);
98
111
  const current = readFileSync(path, 'utf8');
99
112
  const next = draw(current, registry);
@@ -1,6 +1,6 @@
1
1
  import { test } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
- import { problems, progress, render } from './support-table.mjs';
3
+ import { problems, progress, render, renderSummary } from './support-table.mjs';
4
4
 
5
5
  const manifest = { profileLayout: { files: [{ repo: 'configs/a.json' }], dirs: [], keys: ['vscodeExtensions', 'git'] }, tasks: { omoShims: {} } };
6
6
  const reg = (programs) => ({ levels: ['full', 'partial', 'detect', 'planned'], categories: ['IDE'], programs });
@@ -52,3 +52,15 @@ test('progress counts each level and the full share among installed programs', (
52
52
  ]));
53
53
  assert.match(out, /\| 1 \| 0 \| 1 \| 1 \| 1 of 2 \(50%\) \|$/);
54
54
  });
55
+
56
+ test('the README summary counts each level per category, links the matrix section and leaves a zero blank', () => {
57
+ const two = { levels: ['full', 'partial', 'detect', 'planned'], categories: ['IDE', 'Shell and prompt'], programs: [
58
+ { name: 'A', category: 'IDE', level: 'full', what: '', captures: [] },
59
+ { name: 'B', category: 'IDE', level: 'full', what: '', captures: [] },
60
+ { name: 'C', category: 'Shell and prompt', level: 'planned', what: '', captures: [] },
61
+ ] };
62
+ const out = renderSummary('a\n<!-- support-summary:start -->\nold\n<!-- support-summary:end -->\nb\n', two);
63
+ assert.match(out, /\| \[IDE\]\(docs\/SUPPORT-MATRIX\.md#ide\) \| 2 \| \| \| \|/);
64
+ assert.match(out, /\| \[Shell and prompt\]\(docs\/SUPPORT-MATRIX\.md#shell-and-prompt\) \| \| \| \| 1 \|/);
65
+ assert.doesNotMatch(out, /old/);
66
+ });
@@ -409,7 +409,7 @@ if ($Mode -eq 'Live') {
409
409
  $default = (& wsl.exe --list --quiet 2>$null | ForEach-Object { ($_ -replace "`0", '').Trim() } | Where-Object { $_ -and $_ -notmatch '^docker-desktop' } | Select-Object -First 1)
410
410
  $route = if ($default) { & wsl.exe -d $default --exec /bin/sh -c 'ip route show default' 2>$null } else { '' }
411
411
  Write-Info "distribution=$default route=$route"
412
- Test-Check ([bool]$route) 'the WSL guest has a default route under mirrored networking; when it has only loopback, read docs/CONTRACT.md#windows-hosted-provider-from-wsl for the 4095-port reservation'
412
+ Test-Check ([bool]$route) 'the WSL guest has a default route under mirrored networking; when it has only loopback, read docs/RUNTIME-PREFLIGHT.md#windows-hosted-provider-from-wsl for the 4095-port reservation'
413
413
  }
414
414
 
415
415
  Write-Step 'Live tooling'
@@ -47,6 +47,30 @@ export function runnerLimits(runner, row, defaults) {
47
47
  return limits;
48
48
  }
49
49
 
50
+ // The leader is the person's own machine, the one that runs this queue: no unit starts there. On 2026-12-04 the founder's laptop froze in a
51
+ // game while about 80 agent node and chrome processes ran on it at 60-100% CPU (leader 04:4x). A machine is the leader when its register
52
+ // row's role, or its runner entry's role in the settings, says leader.
53
+ export const LEADER_ROLE = /\bleader\b/i;
54
+ // An ssh host that is this machine itself.
55
+ const LOCAL_HOSTS = new Set(['local', 'localhost', '127.0.0.1']);
56
+ const same = (a, b) => String(a ?? '').toLowerCase() === String(b ?? '').toLowerCase();
57
+ // A machine name as a word of a note: not a part of a longer name.
58
+ const namesWord = (text, name) => new RegExp('(?<![\\w-])' + String(name).replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '(?![\\w-])', 'i').test(String(text ?? ''));
59
+
60
+ // Why a runner is the leader, or null: its register row's role or its settings role says leader, its machine or its ssh host is a leader
61
+ // the register names (a row's host is what agenv machine register --host was given), or it is this machine (its ssh host is localhost,
62
+ // or its machine is this machine's name) while this machine is the leader.
63
+ export function leaderOf(runner, row, { leaders = [], hostname = os.hostname() } = {}) {
64
+ const machine = runner.machine ?? runner.id;
65
+ if (LEADER_ROLE.test(String(row?.role ?? ''))) return 'its register row ' + (row.id ?? machine) + ' has role ' + JSON.stringify(row.role);
66
+ if (LEADER_ROLE.test(String(runner.role ?? ''))) return 'its settings role is ' + JSON.stringify(runner.role);
67
+ if (leaders.some((n) => same(n, machine))) return 'its machine ' + machine + ' is the leader in the register';
68
+ if (leaders.some((n) => same(n, runner.host))) return 'its ssh host ' + runner.host + ' is the leader in the register';
69
+ const local = LOCAL_HOSTS.has(String(runner.host).toLowerCase()) || same(machine, hostname);
70
+ if (local && leaders.some((n) => same(n, hostname))) return 'it is this machine (' + hostname + '), the leader in the register';
71
+ return null;
72
+ }
73
+
50
74
  function registerRows(file) {
51
75
  if (!file) return [];
52
76
  try { return JSON.parse(fs.readFileSync(file, 'utf8')).machines ?? []; } catch (e) { throw new Error('The register of machines ' + file + ' could not be read (' + (e.code ?? e.message) + ').'); }
@@ -54,7 +78,7 @@ function registerRows(file) {
54
78
 
55
79
  // The fleet settings, from the person's own file: their runners, the folders on this machine and on the runners, the model routes and
56
80
  // what every launched prompt carries. Everything a household or company would recognise lives there, never in this code.
57
- export function readFleet(file, { queueFile, home = os.homedir() } = {}) {
81
+ export function readFleet(file, { queueFile, home = os.homedir(), hostname = os.hostname() } = {}) {
58
82
  let raw;
59
83
  try { raw = JSON.parse(fs.readFileSync(file, 'utf8')); } catch (e) { throw new Error('The fleet settings ' + file + ' could not be read (' + (e.code ?? e.message) + '). Its shape is in docs/MACHINES.md.'); }
60
84
  const need = (ok, what) => { if (!ok) throw new Error('The fleet settings ' + file + ' need ' + what + '. Its shape is in docs/MACHINES.md.'); };
@@ -76,8 +100,17 @@ export function readFleet(file, { queueFile, home = os.homedir() } = {}) {
76
100
  const register = raw.register ? raw.register.replace(/^~(?=[\\/]|$)/, home) : null;
77
101
  const rows = registerRows(register);
78
102
  const rowOf = (machine) => rows.find((row) => String(row.host ?? '').toLowerCase() === String(machine).toLowerCase());
103
+ // The leader's machine names: each register row whose role says leader (a row registered with --host local is this machine), and each
104
+ // runner whose settings role does. The word leader itself is no machine name, since a start note says "not on the leader" of any unit.
105
+ const leaders = [...new Set([...rows.filter((row) => LEADER_ROLE.test(String(row.role ?? ''))).map((row) => (LOCAL_HOSTS.has(String(row.host ?? '').toLowerCase()) ? hostname : row.host)), ...raw.runners.filter((r) => LEADER_ROLE.test(String(r.role ?? ''))).map((r) => r.machine ?? r.id)].filter((n) => n && !LEADER_ROLE.test(String(n))).map(String))];
106
+ const runners = raw.runners.map((r) => {
107
+ const leader = leaderOf(r, rowOf(r.machine ?? r.id), { leaders, hostname });
108
+ // A leader runner has no session slot, so no pass and no --runner auto picks it.
109
+ return { id: r.id, host: r.host, machine: r.machine ?? r.id, gpu: r.gpu === true, ...runnerLimits(r, rowOf(r.machine ?? r.id), defaults), ...(leader ? { cap: 0, leader } : { leader: null }) };
110
+ });
79
111
  return {
80
- runners: raw.runners.map((r) => ({ id: r.id, host: r.host, machine: r.machine ?? r.id, gpu: r.gpu === true, ...runnerLimits(r, rowOf(r.machine ?? r.id), defaults) })),
112
+ runners,
113
+ leaders,
81
114
  root,
82
115
  ...defaults,
83
116
  register,
@@ -131,9 +164,23 @@ export function overlaps(a, b) {
131
164
  return ta.some((x) => !x.startsWith('out/') && tb.some((y) => !y.startsWith('out/') && (x.startsWith(y) || y.startsWith(x))));
132
165
  }
133
166
 
134
- // A unit the queue keeps for the person's own machine (its class is leader, or it starts in the leader lane) never goes to a runner.
167
+ // A unit the queue keeps for the person's own machine (its class is leader, or it starts in the leader lane) never goes to a runner, and
168
+ // the queue never starts it on the leader either: it stays unlaunched for the person.
135
169
  export const forRunners = (u) => u.machineClass !== 'leader' && !/leader lane/.test(u.startNow ?? '');
136
170
 
171
+ // Why a unit's placement resolves to the leader, or null: --place names a leader runner, or its class or start note names a leader's
172
+ // machine or a leader runner. Such a unit is refused, never moved to another runner, since whoever wrote the name meant that machine.
173
+ export function leaderPlacement(u, runners, place = {}, leaders = []) {
174
+ const placed = runners.find((r) => r.id === place[u.id]);
175
+ if (placed?.leader) return '--place names ' + placed.id + ', the leader (' + placed.leader + ')';
176
+ const names = [...new Set([...leaders, ...runners.filter((r) => r.leader).flatMap((r) => [r.id, r.machine])])].filter((n) => n && !LEADER_ROLE.test(String(n)));
177
+ for (const [field, what] of [['machineClass', 'its machineClass'], ['startNow', 'its start note']]) {
178
+ const hit = names.find((n) => namesWord(u[field], n));
179
+ if (hit) return what + ' names ' + hit + ', the leader';
180
+ }
181
+ return null;
182
+ }
183
+
137
184
  // The status line session.mjs gives when ssh never reached the runner (exit 255): the session's state is unknown, never "no session".
138
185
  export const UNREACHABLE = '(runner unreachable';
139
186
 
@@ -179,10 +226,11 @@ export function namedSkills(text, roster) {
179
226
  // runner; the runner its start note names while that one has a free slot; else every runner, most free slots first. A runner that avoids
180
227
  // visual work (a person plays or draws on it) takes no visual and no GPU unit, unless --place names it.
181
228
  export function candidatesFor(u, runners, free, place = {}) {
182
- if (place[u.id]) return [place[u.id]];
229
+ if (place[u.id]) return runners.find((r) => r.id === place[u.id])?.leader ? [] : [place[u.id]];
183
230
  const cls = u.machineClass ?? '';
184
231
  const gpuUnit = /GPU/.test(cls) || runners.some((r) => r.gpu && cls.includes(r.id));
185
- const open = runners.filter((r) => !(r.avoidVisual && (gpuUnit || isVisual(u))));
232
+ // The leader is never a candidate (leaderOf).
233
+ const open = runners.filter((r) => !r.leader && !(r.avoidVisual && (gpuUnit || isVisual(u))));
186
234
  if (gpuUnit) return open.filter((r) => r.gpu).map((r) => r.id);
187
235
  const named = open.find((r) => (u.startNow ?? '').includes(r.machine));
188
236
  if (named && free[named.id] > 0) return [named.id];
@@ -199,16 +247,25 @@ export function candidatesFor(u, runners, free, place = {}) {
199
247
  // preflightOf, when the settings name a dispatch check, runs for a unit that has a runner, before it takes the slot: a unit it holds
200
248
  // keeps the slot free for the next unit, and its reason is logged once. A batch whose files name no path gives the check no surface to
201
249
  // compare, so it is passed over with a log line and the batch rule of overlaps decides what runs beside it (leader, 2026-12-02).
202
- export async function chooseUnits({ units, state, runners, loads, cap, minFreeGB, capOverride = null, only = null, place = {}, running = [], hasCheckout, commitOf, wantsOf, preflightOf = null }) {
250
+ export async function chooseUnits({ units, state, runners, loads, cap, minFreeGB, capOverride = null, only = null, place = {}, running = [], hasCheckout, commitOf, wantsOf, preflightOf = null, leaders = [] }) {
203
251
  const byId = Object.fromEntries(units.map((u) => [u.id, u]));
204
- const free = Object.fromEntries(runners.map((r) => [r.id, loads[r.id] && loads[r.id].freeGB >= (r.minFreeGB ?? minFreeGB) ? Math.max(0, (capOverride ?? r.cap ?? cap) - loads[r.id].running) : 0]));
252
+ // A leader runner has no free slot, whatever --cap says.
253
+ const free = Object.fromEntries(runners.map((r) => [r.id, !r.leader && loads[r.id] && loads[r.id].freeGB >= (r.minFreeGB ?? minFreeGB) ? Math.max(0, (capOverride ?? r.cap ?? cap) - loads[r.id].running) : 0]));
205
254
  const picks = [], notes = [];
206
- const skillHeld = { ...(state.skillHeld ?? {}) }, preflightHeld = { ...(state.preflightHeld ?? {}) }, noCheckout = [...(state.noCheckout ?? [])];
255
+ const skillHeld = { ...(state.skillHeld ?? {}) }, preflightHeld = { ...(state.preflightHeld ?? {}) }, noCheckout = [...(state.noCheckout ?? [])], leaderRefused = { ...(state.leaderRefused ?? {}) };
207
256
  const entryOf = ledgerKey;
208
257
  for (const u of units) {
209
258
  if (only && !only.includes(u.id)) continue;
210
259
  if (state.launched[u.id] || (state.skip ?? []).includes(u.id) || (state.hold ?? []).includes(u.id)) continue;
211
260
  if (!forRunners(u)) continue;
261
+ // A unit whose placement resolves to the leader is refused with one log line, and stays waiting until its placement changes.
262
+ const toLeader = leaderPlacement(u, runners, place, leaders);
263
+ if (toLeader) {
264
+ if (leaderRefused[u.id] !== toLeader) notes.push('launch REFUSED ' + u.id + ': ' + toLeader + '; the queue starts no unit on the leader');
265
+ leaderRefused[u.id] = toLeader;
266
+ continue;
267
+ }
268
+ delete leaderRefused[u.id];
212
269
  const [repo, ref] = String(u.base).split('@');
213
270
  if (!hasCheckout(repo)) {
214
271
  if (!noCheckout.includes(u.id)) { notes.push('skip ' + u.id + ': repository ' + repo + ' has no checkout in the workspace'); noCheckout.push(u.id); }
@@ -248,7 +305,7 @@ export async function chooseUnits({ units, state, runners, loads, cap, minFreeGB
248
305
  picks.push({ unit: u, runner, repo, sha, block });
249
306
  free[runner] -= 1;
250
307
  }
251
- return { picks, free, skillHeld, preflightHeld, noCheckout, notes };
308
+ return { picks, free, skillHeld, preflightHeld, noCheckout, leaderRefused, notes };
252
309
  }
253
310
 
254
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
@@ -440,7 +497,7 @@ export async function fillPass({ fleet, queueFile, options = {}, shadow = false,
440
497
  save();
441
498
  }
442
499
  const names = Object.fromEntries(q.units.map((u) => [u.id, runNameOf(u, st)]));
443
- say('pass: running ' + (running.join(',') || 'none') + ' | ' + fleet.runners.map((r) => { const l = loads[r.id]; return r.id + ' ' + (l ? l.running + '/' + (capOverride ?? r.cap) + ' sessions (' + (l.names.join(',') || '-') + '), ' + l.freeGB + ' GB free' : 'unread'); }).join(' | '));
500
+ say('pass: running ' + (running.join(',') || 'none') + ' | ' + fleet.runners.map((r) => { const l = loads[r.id]; return r.id + ' ' + (r.leader ? 'leader, takes no unit (' + r.leader + ')' + (l ? ', ' + l.running + ' sessions (' + (l.names.join(',') || '-') + ')' : '') : l ? l.running + '/' + (capOverride ?? r.cap) + ' sessions (' + (l.names.join(',') || '-') + '), ' + l.freeGB + ' GB free' : 'unread'); }).join(' | '));
444
501
  // The commit a unit's base names in its checkout here, after this pass's fetch: origin/main when it names main, else the ref or commit it
445
502
  // pins. A pinned full commit id the checkout lacks (a cut session's work sits on a rescue ref) is fetched once by its id; still none is null.
446
503
  const commitOf = async (repo, ref) => {
@@ -453,8 +510,9 @@ export async function fillPass({ fleet, queueFile, options = {}, shadow = false,
453
510
  return /^[0-9a-f]{40}$/.test(sha) ? sha : null;
454
511
  };
455
512
  const preflightOf = fleet.preflight ? (u) => (io.preflight ?? runPreflight)(fleet, u) : null;
456
- const choice = await chooseUnits({ units: q.units, state: st, runners: fleet.runners, loads, cap: fleet.cap, minFreeGB: fleet.minFreeGB, capOverride, only: options.only ? list(options.only) : null, place, running, hasCheckout, commitOf, wantsOf, preflightOf });
513
+ const choice = await chooseUnits({ units: q.units, state: st, runners: fleet.runners, loads, cap: fleet.cap, minFreeGB: fleet.minFreeGB, capOverride, only: options.only ? list(options.only) : null, place, running, hasCheckout, commitOf, wantsOf, preflightOf, leaders: fleet.leaders ?? [] });
457
514
  for (const n of choice.notes) say(n);
515
+ st.leaderRefused = choice.leaderRefused;
458
516
  st.skillHeld = choice.skillHeld;
459
517
  st.preflightHeld = choice.preflightHeld;
460
518
  st.noCheckout = choice.noCheckout;
@@ -155,11 +155,22 @@ export function startScript(cmd, cwd, priority = null) {
155
155
  return startup + '$r = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{ CommandLine = ' + q(cmd) + '; CurrentDirectory = ' + q(cwd) + (startup ? '; ProcessStartupInformation = [ciminstance]$si' : '') + " }; 'rc ' + $r.ReturnValue + ' pid ' + $r.ProcessId";
156
156
  }
157
157
 
158
+ // The start check's first step: the machine ssh reached answers with its own name, and one the register names as the leader refuses, so
159
+ // an ssh alias that resolves to the leader (a LAN or tailnet alias, localhost) starts nothing there. Empty when no leader is known.
160
+ export function leaderCheck(leaders = []) {
161
+ const names = leaders.filter((n) => /^[\w.-]+$/.test(String(n)));
162
+ return names.length ? 'if (@(' + names.map(q).join(',') + ") -contains $env:COMPUTERNAME) { 'leader ' + $env:COMPUTERNAME } else" : '';
163
+ }
164
+
158
165
  // Starts one session: checks the runner can take it, makes its folder, sends the prompt, the launch settings and the wrapper, checks the
159
166
  // commit out on a branch of its own clone, copies or links its inputs and starts the wrapper detached. { ok, message, exists }: exists is
160
- // live or cut when a folder of that name is already there, by whether the wrapper its pid.txt names still runs.
161
- export async function startSession(fleet, tools, runner, { name, promptFile, repoDir = null, sha = null, mode = 'write', model, effort = null, minutes = 60, branch = null, inputsDir = null, links = [], cap = runner.cap ?? fleet.cap }) {
167
+ // live or cut when a folder of that name is already there, by whether the wrapper its pid.txt names still runs. A runner that is the leader
168
+ // (queue.mjs leaderOf), or whose ssh answers from a machine the register names as the leader, is refused before anything is sent, whoever
169
+ // starts it: the queue, agenv run --session --runner <id> or --runner auto. io holds this function's own runner calls (the checkout keeps its
170
+ // own), so a test can stand in for the runner.
171
+ export async function startSession(fleet, tools, runner, { name, promptFile, repoDir = null, sha = null, mode = 'write', model, effort = null, minutes = 60, branch = null, inputsDir = null, links = [], cap = runner.cap ?? fleet.cap }, io = { ps, scp }) {
162
172
  const fail = (message) => ({ ok: false, message });
173
+ if (runner.leader) return fail(runner.id + ' is the leader (' + runner.leader + '); no session starts there');
163
174
  if (!/^[a-z0-9][a-z0-9-]{0,47}$/.test(name)) return fail('a session name is lowercase letters, digits and dashes, at most 48');
164
175
  if (!/^[A-Za-z0-9._:-]+$/.test(model ?? '') || !(minutes > 0 && minutes <= 240)) return fail('a session takes a model name and 1 to 240 minutes');
165
176
  if (branch && !/^[A-Za-z0-9][A-Za-z0-9._\/-]{0,79}$/.test(branch)) return fail('a branch name was expected, got ' + branch);
@@ -168,26 +179,29 @@ export async function startSession(fleet, tools, runner, { name, promptFile, rep
168
179
  const route = (/^gpt-/i.test(model) && fleet.routes.gpt ? fleet.routes.gpt : fleet.routes.claude).replace(/\/$/, '');
169
180
  const cliName = path.basename(fleet.agentCli);
170
181
  // The runner can take it: the name is free, the CLI is installed, the runner is under its cap and the model route answers.
171
- const pre = await ps(tools, runner.host, 'if (Test-Path ' + q(D) + ') { $w = if (Test-Path ' + q(D + '/pid.txt') + ') { (Get-Content ' + q(D + '/pid.txt') + ").Split(' ')[0] } else { '' }; if ($w -and (Get-Process -Id $w -ErrorAction SilentlyContinue)) { 'exists live' } else { 'exists cut' } } elseif (-not (Test-Path " + q(fleet.agentCli) + ")) { 'no cli' } else { $n = " + cliCount(fleet.root, cliName) + '; if ($n -ge ' + Number(cap) + ") { 'full ' + $n } else { try { 'relay ' + (Invoke-WebRequest -UseBasicParsing -TimeoutSec 20 " + q(route + '/v1/models') + ' -Headers @{ authorization = ' + q('Bearer ' + fleet.token) + " }).StatusCode } catch { 'relay down' } } }");
182
+ const lead = leaderCheck(fleet.leaders);
183
+ // lead ends with "else", so the check below continues it as elseif.
184
+ const pre = await io.ps(tools, runner.host, lead + 'if (Test-Path ' + q(D) + ') { $w = if (Test-Path ' + q(D + '/pid.txt') + ') { (Get-Content ' + q(D + '/pid.txt') + ").Split(' ')[0] } else { '' }; if ($w -and (Get-Process -Id $w -ErrorAction SilentlyContinue)) { 'exists live' } else { 'exists cut' } } elseif (-not (Test-Path " + q(fleet.agentCli) + ")) { 'no cli' } else { $n = " + cliCount(fleet.root, cliName) + '; if ($n -ge ' + Number(cap) + ") { 'full ' + $n } else { try { 'relay ' + (Invoke-WebRequest -UseBasicParsing -TimeoutSec 20 " + q(route + '/v1/models') + ' -Headers @{ authorization = ' + q('Bearer ' + fleet.token) + " }).StatusCode } catch { 'relay down' } } }");
172
185
  const said = pre.out.trim();
186
+ if (said.startsWith('leader ')) return fail(runner.id + ' (' + runner.host + ') answers as ' + said.slice(7) + ', the leader in the register; no session starts there');
173
187
  if (said.startsWith('exists')) return { ...fail('a session named ' + name + ' already exists on ' + runner.id + (said === 'exists live' ? ', its wrapper running' : ', no wrapper running')), exists: said.slice(7) };
174
188
  if (said === 'no cli') return fail(runner.id + ' has no agent CLI at ' + fleet.agentCli);
175
189
  if (said.startsWith('full')) return fail(runner.id + ' is full: ' + said.slice(5) + ' sessions running, cap ' + cap);
176
190
  if (said !== 'relay 200') return fail(runner.id + ' cannot reach the model route ' + route + ' (' + (said || pre.err || 'no answer') + ')');
177
- const mk = await ps(tools, runner.host, 'New-Item -ItemType Directory -Force ' + ['work', 'out', 'config', 'tmp'].map((d) => q(D + '/' + d)).join(',') + ' | Out-Null; [IO.File]::WriteAllText(' + q(D + '/launch.json') + ', [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String(' + q(b64(JSON.stringify(launchFile(fleet, { mode, model, minutes, effort }), null, 1) + '\n')) + "))); 'ok'");
191
+ const mk = await io.ps(tools, runner.host, 'New-Item -ItemType Directory -Force ' + ['work', 'out', 'config', 'tmp'].map((d) => q(D + '/' + d)).join(',') + ' | Out-Null; [IO.File]::WriteAllText(' + q(D + '/launch.json') + ', [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String(' + q(b64(JSON.stringify(launchFile(fleet, { mode, model, minutes, effort }), null, 1) + '\n')) + "))); 'ok'");
178
192
  if (!mk.out.includes('ok')) return fail('could not make ' + D + ' on ' + runner.id + ': ' + mk.err.slice(0, 200));
179
- if (!(await scp(tools, [promptFile, runner.host + ':' + D + '/prompt.txt'])).ok) return fail('the prompt copy to ' + runner.id + ' failed');
193
+ if (!(await io.scp(tools, [promptFile, runner.host + ':' + D + '/prompt.txt'])).ok) return fail('the prompt copy to ' + runner.id + ' failed');
180
194
  // The wrapper and the bash guard are copied only when the runner's copy differs, and then by a rename, so a launch beside other launches
181
195
  // never truncates a file under a session that is starting.
182
196
  for (const [file, fileName, what] of [[WRAPPER, WRAPPER_NAME, 'session wrapper'], [GUARD, GUARD_NAME, 'bash guard']]) {
183
197
  const want = createHash('sha256').update(fs.readFileSync(file)).digest('hex').toUpperCase();
184
198
  const target = fleet.root + '/bin/' + fileName;
185
- const have = (await ps(tools, runner.host, 'if (Test-Path ' + q(target) + ') { (Get-FileHash -Algorithm SHA256 -LiteralPath ' + q(target) + ").Hash } else { 'none' }")).out.trim();
199
+ const have = (await io.ps(tools, runner.host, 'if (Test-Path ' + q(target) + ') { (Get-FileHash -Algorithm SHA256 -LiteralPath ' + q(target) + ").Hash } else { 'none' }")).out.trim();
186
200
  if (have === want) continue;
187
201
  const tmp = target + '.' + name + '.tmp';
188
- await ps(tools, runner.host, 'New-Item -ItemType Directory -Force ' + q(fleet.root + '/bin') + ' | Out-Null');
189
- if (!(await scp(tools, [file, runner.host + ':' + tmp])).ok) return fail('the ' + what + ' copy to ' + runner.id + ' failed');
190
- if (!(await ps(tools, runner.host, 'Move-Item -Force -LiteralPath ' + q(tmp) + ' -Destination ' + q(target) + "; 'moved'")).out.includes('moved')) return fail('the ' + what + ' rename on ' + runner.id + ' failed');
202
+ await io.ps(tools, runner.host, 'New-Item -ItemType Directory -Force ' + q(fleet.root + '/bin') + ' | Out-Null');
203
+ if (!(await io.scp(tools, [file, runner.host + ':' + tmp])).ok) return fail('the ' + what + ' copy to ' + runner.id + ' failed');
204
+ if (!(await io.ps(tools, runner.host, 'Move-Item -Force -LiteralPath ' + q(tmp) + ' -Destination ' + q(target) + "; 'moved'")).out.includes('moved')) return fail('the ' + what + ' rename on ' + runner.id + ' failed');
191
205
  }
192
206
  if (repoDir) {
193
207
  const checkedOut = await checkout(fleet, tools, runner, { D, name, repoDir, sha, branch: branch ?? 'fleet/' + name });
@@ -197,7 +211,7 @@ export async function startSession(fleet, tools, runner, { name, promptFile, rep
197
211
  const bad = secretFiles(inputsDir);
198
212
  if (bad.length) return fail('these input files look like credentials and stay here: ' + bad.slice(0, 10).join(', '));
199
213
  // Into an inputs folder that does not exist yet, so the folder's contents land flat in it.
200
- const c = await scp(tools, [path.resolve(inputsDir), runner.host + ':' + D + '/work/inputs']);
214
+ const c = await io.scp(tools, [path.resolve(inputsDir), runner.host + ':' + D + '/work/inputs']);
201
215
  if (!c.ok) return fail('the inputs copy to ' + runner.id + ' failed: ' + c.err.slice(0, 200));
202
216
  }
203
217
  // A large input is one read-only copy per runner under <root>/shared, linked into the session's inputs as a junction. Removing a session
@@ -205,11 +219,11 @@ export async function startSession(fleet, tools, runner, { name, promptFile, rep
205
219
  for (const { rel, target } of links) {
206
220
  if (!/^[A-Za-z0-9._][A-Za-z0-9._\/-]*$/.test(rel) || rel.split('/').includes('..') || !target?.startsWith(fleet.root + '/shared/')) return fail('a link takes a path under inputs and a shared copy under ' + fleet.root + '/shared');
207
221
  const at = D + '/work/inputs/' + rel;
208
- const o = await ps(tools, runner.host, 'if (-not (Test-Path ' + q(target + '/.shared-stamp') + ")) { 'no shared copy' } else { New-Item -ItemType Directory -Force (Split-Path " + q(at) + ') | Out-Null; if (-not (Test-Path ' + q(at) + ')) { New-Item -ItemType Junction -Path ' + q(at) + ' -Target ' + q(win(target)) + ' | Out-Null }; (Get-Item ' + q(at) + ').LinkType }');
222
+ const o = await io.ps(tools, runner.host, 'if (-not (Test-Path ' + q(target + '/.shared-stamp') + ")) { 'no shared copy' } else { New-Item -ItemType Directory -Force (Split-Path " + q(at) + ') | Out-Null; if (-not (Test-Path ' + q(at) + ')) { New-Item -ItemType Junction -Path ' + q(at) + ' -Target ' + q(win(target)) + ' | Out-Null }; (Get-Item ' + q(at) + ').LinkType }');
209
223
  if (o.out.trim() !== 'Junction') return fail('link ' + rel + ' failed: ' + (o.out + o.err).trim().slice(0, 200));
210
224
  }
211
225
  const cmd = '"' + win(fleet.runnerNode) + '" ' + win(fleet.root + '/bin/' + WRAPPER_NAME) + ' ' + win(D);
212
- const st = await ps(tools, runner.host, startScript(cmd, win(D), runner.priority));
226
+ const st = await io.ps(tools, runner.host, startScript(cmd, win(D), runner.priority));
213
227
  if (!/rc 0 pid \d+/.test(st.out)) return fail('start failed: ' + (st.out + st.err).trim().slice(0, 200));
214
228
  return { ok: true, message: name + ' started on ' + runner.id + ' (' + st.out.trim() + (runner.priority ? ', ' + runner.priority : '') + '), ' + mode + ' mode, model ' + model + ', at most ' + minutes + ' min, folder ' + D };
215
229
  }