clearotron 0.5.0 → 0.5.1-beta.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.
Files changed (123) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/INSTALL.md +334 -302
  3. package/QUICKSTART.md +12 -4
  4. package/README.md +12 -7
  5. package/THIRD-PARTY-NOTICES.md +4 -4
  6. package/bin/README.md +14 -11
  7. package/bin/clearotron.mjs +1 -1
  8. package/bin/connect.mjs +73 -25
  9. package/bin/example.mjs +4 -2
  10. package/bin/onboard.mjs +562 -336
  11. package/bin/start.mjs +184 -36
  12. package/bin/update.mjs +26 -13
  13. package/build-info.json +2 -2
  14. package/docs/PORTAL.md +2 -2
  15. package/docs/architecture/02-architecture.md +3 -3
  16. package/docs/architecture/04-configuration-reference.md +1 -2
  17. package/docs/architecture/05-config-governance.md +1 -1
  18. package/docs/architecture/06-operations-runbook.md +1 -1
  19. package/driver/CHANGELOG.md +77 -0
  20. package/driver/README.md +2 -2
  21. package/driver/config-inventory.mjs +20 -11
  22. package/driver/contract-e3-backlog.mjs +27 -27
  23. package/driver/contract-e3-baseline.json +2 -2
  24. package/driver/contract-vocabulary.mjs +1 -1
  25. package/driver/degraded-parts.mjs +67 -3
  26. package/driver/dev-portal.mjs +1 -1
  27. package/driver/digest-queue.mjs +5 -5
  28. package/driver/driver.config.mjs +9 -9
  29. package/driver/engine/CONTRACT.md +1 -1
  30. package/driver/engine/anthropic-agent.mjs +4 -2
  31. package/driver/engine/mcp/band-server.mjs +1 -21
  32. package/driver/engine/mcp/clarivate-propose-tool.mjs +26 -0
  33. package/driver/engine/mcp/clarivate-server.mjs +2 -18
  34. package/driver/engine/mcp/fixture-register-server.mjs +33 -0
  35. package/driver/engine/mcp/gather-config.mjs +48 -7
  36. package/driver/engine/mcp/recording-server.mjs +206 -14
  37. package/driver/engine/mcp/supplemental.mjs +4 -2
  38. package/driver/engine/openai-agent.mjs +3 -1
  39. package/driver/engine/probe.mjs +10 -0
  40. package/driver/filing-goods.mjs +95 -0
  41. package/driver/findings-model.mjs +3 -0
  42. package/driver/gateway.mjs +42 -40
  43. package/driver/knockout-assess-record.mjs +54 -4
  44. package/driver/knockout-correction-record.mjs +342 -0
  45. package/driver/knockout-frame-record.mjs +4 -2
  46. package/driver/knockout-register-read.mjs +705 -0
  47. package/driver/knockout-register-record.mjs +222 -0
  48. package/driver/knockout-review-record.mjs +96 -25
  49. package/driver/narrative-refutation-record.mjs +87 -1
  50. package/driver/order-tables.mjs +23 -0
  51. package/driver/owner-use-check.mjs +5 -2
  52. package/driver/package.json +1 -1
  53. package/driver/partial-payload-baseline.json +8 -0
  54. package/driver/pipeline-knockout.mjs +506 -313
  55. package/driver/pipeline.mjs +179 -86
  56. package/driver/portal-local-auth.mjs +7 -1
  57. package/driver/portal-service.mjs +62 -6
  58. package/driver/progress.mjs +2 -2
  59. package/driver/publish/index.mjs +18 -21
  60. package/driver/publish/knockout.mjs +40 -18
  61. package/driver/publish/render-knockout.mjs +40 -27
  62. package/driver/publish/report-dates.mjs +43 -0
  63. package/driver/recall-reconciliation.mjs +2 -2
  64. package/driver/record-goods.mjs +50 -9
  65. package/driver/register-count.mjs +12 -59
  66. package/driver/register-fixture-marker.mjs +22 -0
  67. package/driver/register-plan.mjs +48 -0
  68. package/driver/register-records.mjs +84 -266
  69. package/driver/register-taint.mjs +2 -2
  70. package/driver/repair-composers.mjs +15 -8
  71. package/driver/result-noun-fields.mjs +6 -2
  72. package/driver/run-requirements.mjs +54 -4
  73. package/driver/runner.mjs +4 -13
  74. package/driver/skills/clearance-register/providers/clarivate.md +2 -2
  75. package/driver/skills/knockout-assess/SKILL.md +101 -100
  76. package/driver/skills/knockout-frame/SKILL.md +3 -1
  77. package/driver/skills/knockout-register-read/SKILL.md +77 -0
  78. package/driver/stages-knockout.mjs +159 -98
  79. package/driver/stages.mjs +4 -2
  80. package/driver/suite-census.json +389 -71
  81. package/driver/systemd/README.md +2 -2
  82. package/driver/verify-knockout.mjs +175 -39
  83. package/driver/verify.mjs +10 -9
  84. package/mcp-server/CHANGELOG.md +4 -0
  85. package/mcp-server/CONNECT.md +4 -0
  86. package/mcp-server/demo-mode.mjs +6 -0
  87. package/mcp-server/lib/demo-texts.mjs +38 -0
  88. package/mcp-server/lib/http-handler.mjs +7 -1
  89. package/mcp-server/lib/knockout.mjs +3 -2
  90. package/mcp-server/lib/options.mjs +3 -1
  91. package/mcp-server/lib/plan.mjs +6 -1
  92. package/mcp-server/mint-token.mjs +1 -1
  93. package/mcp-server/package.json +1 -1
  94. package/mcp-server/serve.mjs +11 -0
  95. package/mcp-server/server.mjs +13 -5
  96. package/package.json +1 -1
  97. package/portal-ui/dist/assets/{index-D2wrw9cH.css → index-AtB9ZpDH.css} +29 -0
  98. package/portal-ui/dist/assets/{index-DcLbvFmQ.js → index-C1oE78Wk.js} +161 -195
  99. package/portal-ui/dist/index.html +2 -2
  100. package/portal-ui/package.json +4 -4
  101. package/providers/README.md +4 -4
  102. package/providers/_shared/execute-plan.mjs +45 -1
  103. package/providers/_shared/term-shape.mjs +1 -1
  104. package/providers/clarivate/src/capabilities.js +7 -6
  105. package/providers/clarivate/src/core.js +11 -7
  106. package/providers/clarivate/src/wider-list.js +104 -0
  107. package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
  108. package/providers/oauth-mcp-bridge/package.json +1 -1
  109. package/providers/signa/src/capabilities.js +0 -9
  110. package/scripts/e2e-first-time.mjs +8 -7
  111. package/scripts/freeze-example-run.mjs +2 -2
  112. package/scripts/settings-render-check.mjs +5 -3
  113. package/scripts/test-run.mjs +8 -2
  114. package/shared/client-door.mjs +11 -8
  115. package/shared/connect-clients.mjs +10 -4
  116. package/shared/demo-connection.mjs +43 -0
  117. package/shared/demo-start-args.mjs +7 -2
  118. package/shared/invocation.mjs +18 -3
  119. package/shared/permanent-install.mjs +14 -0
  120. package/shared/scope.mjs +8 -1
  121. package/shared/stdio-connect.mjs +43 -21
  122. package/shared/trigger-lane.mjs +7 -0
  123. package/shared/tty-style.mjs +21 -5
package/QUICKSTART.md CHANGED
@@ -12,7 +12,11 @@ of its own and calls nothing on your behalf.
12
12
  |---|---|---|
13
13
  | A reasoning program | Every stage runs as a headless turn of it | [Claude Code](https://claude.com/claude-code) (`claude`) or the Codex CLI (`codex`). Setup installs it if the machine has none. Sign in with the program setup installed (doctor prints its path), or with `claude` or `codex login` if the machine has its own |
14
14
  | A register | Sets what the search reaches, and what it costs | [Signa](https://signa.so) — one key, self-serve, US + EU + WIPO and ten more offices |
15
- | Web research | Covers the open web and the marketplaces | [Perplexity](https://www.perplexity.ai) |
15
+ | Web research | Covers the open web and the marketplaces. The three clearance searches need it; a Knockout search runs without it | [Perplexity](https://www.perplexity.ai) |
16
+
17
+ Only the native-language investigation of China, Hong Kong, Taiwan or Macau uses a fourth,
18
+ [SerpAPI](https://serpapi.com): it searches the Chinese marketplaces through Baidu. Without its key,
19
+ `SERPAPI_API_KEY`, those marketplaces come back as a disclosed gap.
16
20
 
17
21
  The register is the one with a real choice in it. EUIPO and a local USPTO index cost nothing and
18
22
  reach one office each; Signa is the recommended paid route and the fastest to a real clearance.
@@ -36,6 +40,9 @@ clearotron doctor --probe-engine
36
40
  `clearotron` it installed. If `~/.local/bin` is not on your `PATH` yet, type `~/.local/bin/clearotron`. Installing with npm's own global form
37
41
  instead is covered in [INSTALL.md](INSTALL.md) §2.
38
42
 
43
+ That installs the stable release. For the newest beta, run `npx clearotron@beta install` instead;
44
+ [docs/RELEASES.md](docs/RELEASES.md) says what each one promises.
45
+
39
46
  `doctor` is the one to read. It checks that the reasoning program is there, on `PATH` or as the copy
40
47
  setup installed; that it is signed in, by running a turn rather than by finding the executable; and
41
48
  that your register credential resolves. An executable that is signed out passes every other check and
@@ -66,13 +73,14 @@ prove the install works. Delete that line and the territories decide instead —
66
73
  you a full country search, the deepest of the four, with case law on. Narrowing the scope orders
67
74
  **more** work, not less.
68
75
 
69
- **A knockout search takes 5 to 10 minutes. The other three take 1.5 to 2.5 hours.** Every finished
76
+ **Clearotron quotes 5 to 10 minutes for a knockout search, and 1.5 to 2.5 hours for the other three.** Every finished
70
77
  stage stays on disk, so a run survives interruption and a resume re-runs only what is missing.
71
78
 
72
79
  ## Then
73
80
 
74
81
  - See it before you buy anything: `npx clearotron demo` replays a finished clearance with no account, no
75
- key and no network.
76
- - The four searches, and what each reaches: [README.md](README.md).
82
+ key and no network. `npx clearotron@beta demo` replays the beta's.
83
+ - What the four searches are, and what each promises:
84
+ [docs/architecture/01-product-overview.md](docs/architecture/01-product-overview.md#what-it-does).
77
85
  - Everything else — configuration, the config store, the portal, access control:
78
86
  [INSTALL.md](INSTALL.md).
package/README.md CHANGED
@@ -28,15 +28,17 @@ machine: no gateway, no platform, and nothing about the names you are clearing r
28
28
  npx clearotron demo
29
29
  ```
30
30
 
31
- That fetches the published package — it will ask once before downloading — then replays finished
31
+ That fetches the published package — npx asks before it downloads it — then replays finished
32
32
  clearances into a local portal and prints the portal's address and the passphrase to sign in with. Open
33
- the address in your browser. No sign-up, no credentials, no network calls to us.
33
+ the address in your browser. No sign-up, no credentials, no network calls to us. The demo opens three
34
+ ports, 18860, 18861 and 18862; `npx clearotron demo --port <n>` opens n, n+1 and n+2 instead.
34
35
 
35
36
  The demo runs for as long as that window stays open, and removes everything it made when you close it —
36
- nothing of it is left on the machine, and running it again later starts clean. If you want to keep the
37
- sample reports after closing the window, run `npx clearotron demo --keep`; it prints the one command
38
- that removes the folder when you are done with it. `npx clearotron demo --once` publishes the reports and
39
- exits, and keeps the folder the same way.
37
+ only npm's own copy of the package stays, in its cache, and running it again later starts clean. If you
38
+ want to keep the sample reports after closing the window, run `npx clearotron demo --keep`; it prints the
39
+ one command that removes the folder when you are done with it. `npx clearotron demo --once` publishes the
40
+ reports and exits, and keeps the folder the same way. A demo started over a folder either of those left
41
+ keeps it too, and says how to remove it.
40
42
 
41
43
  **Then install it.**
42
44
 
@@ -63,6 +65,9 @@ something worth testing:
63
65
  npx clearotron@beta install
64
66
  ```
65
67
 
68
+ The same form shows the beta's demo, `npx clearotron@beta demo`; plain `npx clearotron demo` shows the
69
+ stable's.
70
+
66
71
  What each channel promises, and when a stable is cut: [docs/RELEASES.md](docs/RELEASES.md). If you are not
67
72
  sure, the first command is the one you want.
68
73
 
@@ -110,7 +115,7 @@ clearotron run --job my-job.json
110
115
 
111
116
  - **A reasoning CLI does the thinking.** Every stage runs as a headless turn of the [Claude CLI](https://claude.com/claude-code) (`claude`) or the Codex CLI (`codex`); setup installs it if the machine has none. `CLEAROTRON_AI_BILLING` chooses what pays: your signed-in subscription, an API key, or your own Google, Microsoft or Amazon cloud account. Whichever pays, the CLI is what runs — there is no path that calls the model directly.
112
117
  - **One register credential sets coverage and cost.** `CLEAROTRON_DATABASE` has no default — a run refuses rather than picking a vendor for you. EUIPO and a local USPTO index cost nothing; Clarivate, Signa and Corsearch are subscriptions. [The six, and what each reaches](providers/README.md).
113
- - **One research key.** `PERPLEXITY_API_KEY` covers the open web and the marketplaces. A clearance refuses without it at the door, before a register stage has spent.
118
+ - **One research key, and one more for Chinese marketplaces.** `PERPLEXITY_API_KEY` covers the open web and the marketplaces. The three clearance searches refuse without it at the door, before a register stage has spent. A Knockout search runs without it and states on the report that the open-web half did not run. Only the native-language investigation of China, Hong Kong, Taiwan or Macau uses `SERPAPI_API_KEY`: it searches the Chinese marketplaces through Baidu. Without it, those marketplaces come back as a disclosed gap.
114
119
  - **A run takes hours, and survives interruption.** Every finished stage stays on disk; a resume re-runs only what is missing, and a run parked on a provider cap continues by itself.
115
120
  - **A finished run is queryable.** An MCP server lets Claude, ChatGPT or your editor read and question
116
121
  any completed run in plain language: a trusted local **stdio** face, and an authenticated
@@ -173,7 +173,7 @@ will be liable to anyone for any damages related to this
173
173
  software or this license, under any kind of legal claim.***
174
174
  ```
175
175
 
176
- ## @modelcontextprotocol/sdk@1.32.1
176
+ ## @modelcontextprotocol/sdk@1.32.2
177
177
 
178
178
  - **Licence declared:** `MIT`
179
179
  - **Repository:** https://github.com/modelcontextprotocol/typescript-sdk
@@ -2781,7 +2781,7 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
2781
2781
  IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2782
2782
  ```
2783
2783
 
2784
- ## jose@6.2.12
2784
+ ## jose@6.2.14
2785
2785
 
2786
2786
  - **Licence declared:** `MIT`
2787
2787
  - **Repository:** panva/jose
@@ -5085,7 +5085,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5085
5085
  THE SOFTWARE.
5086
5086
  ```
5087
5087
 
5088
- ## react@19.3.0
5088
+ ## react@19.3.1
5089
5089
 
5090
5090
  - **Licence declared:** `MIT`
5091
5091
  - **Repository:** https://github.com/react/react
@@ -5115,7 +5115,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5115
5115
  SOFTWARE.
5116
5116
  ```
5117
5117
 
5118
- ## react-dom@19.3.0
5118
+ ## react-dom@19.3.1
5119
5119
 
5120
5120
  - **Licence declared:** `MIT`
5121
5121
  - **Repository:** https://github.com/react/react
package/bin/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # bin/
2
2
 
3
- The five commands that take an install from a fresh clone to a running product. They are not the only
3
+ The five commands that take an install from nothing to a running product. They are not the only
4
4
  runnable files in the tree — `driver/runner.mjs` drains the queue, and `scripts/` holds the guards and
5
5
  probes CI runs — but they are the ones to start from.
6
6
 
@@ -20,20 +20,23 @@ and is what you want when you are working in this tree.
20
20
  | `signa-sync.mjs` | — | `node bin/signa-sync.mjs` | One vendor read (`GET /v1/offices`, paged). Needs `SIGNA_API_KEY`. |
21
21
 
22
22
  `example.mjs` replays `demo` through the ordinary publisher into `~/trademark-demo/pool` and
23
- serves it on `127.0.0.1:18860`. Every path the demo pool could collide with is checked by realpath and by
24
- containment before anything is written, because a demo runs on deployed machines too.
23
+ serves it on `127.0.0.1:18860`, with its engine door and client door on 18861 and 18862. Every path
24
+ the demo pool could collide with is checked by realpath and by containment before anything is written,
25
+ because a demo runs on deployed machines too.
25
26
 
26
27
  `onboard.mjs` validates each answer through the door the engine itself uses before it persists anything,
27
28
  and the engine check is a real turn through the adapter's own spawn path. `--check` is the free half: it
28
29
  reports what this machine is configured for and writes nothing. Add `--probe-engine` to spend the turn
29
30
  deliberately.
30
31
 
31
- `start.mjs` is a supervisor. It starts exactly two children — `driver/portal-service.mjs` (the portal,
32
- default port 18802) and `mcp-server/http-server.mjs` (the engine door the portal's Start button calls,
33
- default 18790) — and if either exits it says which and stops the other. Since it also starts a
34
- third child, `driver/runner.mjs --watch`, which drains the queue, so ordering a clearance from the portal
35
- runs it. That child is **non-fatal**: an install with no worker is a supported state (`--no-worker`), so a
36
- worker that dies leaves the portal serving and says what to restart, rather than taking the install down.
32
+ `start.mjs` is a supervisor. It starts four children. `driver/portal-service.mjs` (the portal, default
33
+ port 18802) and `mcp-server/http-server.mjs` (the engine door the portal's Start button calls, default
34
+ 18790) are fatal: if either exits, it says which and stops the rest. `mcp-server/http-server-client.mjs`
35
+ (the client door an assistant connects to, default 18811) is non-fatal, and is left to its own unit when
36
+ that unit is already up. The fourth, `driver/runner.mjs --watch`, drains the queue, so ordering a
37
+ clearance from the portal runs it. That child is **non-fatal** too: an install with no worker is a
38
+ supported state (`--no-worker`), so a worker that dies leaves the portal serving and says what to
39
+ restart, rather than taking the install down.
37
40
 
38
41
  That is where hours of model time and vendor calls are spent, and the consent for it is the portal's own
39
42
  review dialog — which prices the run and takes the confirmation — not this file.
@@ -52,8 +55,8 @@ each office's own `status`, and a failed sync exits non-zero with the existing s
52
55
  ## Where to start
53
56
 
54
57
  `example.mjs` (172 lines) is the shortest complete path through the system: frozen example, ordinary
55
- publisher, local pool, loopback server. Then read the header of `start.mjs` for why the real product is
56
- two processes and what each of its two doors demands of a caller.
58
+ publisher, local pool, loopback server. Then read the header of `start.mjs` for why the portal and the
59
+ engine door are separate processes, and what each of those two doors demands of a caller.
57
60
 
58
61
  The long install path is in [`../INSTALL.md`](../INSTALL.md), and the index `uspto-sync` builds is in
59
62
  [`../providers/uspto-local/README.md`](../providers/uspto-local/README.md).
@@ -72,7 +72,7 @@ export const SUMMARY = {
72
72
  install: "configure this install — one question at a time, nothing written until each answer checks out",
73
73
  doctor: "report what this machine is configured for. Writes nothing, calls nobody",
74
74
  demo: "replay a finished example clearance and serve it. No keys, no model, no account",
75
- start: "start the product — the portal and the engine door — and print one address to open",
75
+ start: "start the product — the portal, the engine door, the client door and the worker — and print one address to open",
76
76
  stop: "stop the background product and give the box back — connect's door is not touched",
77
77
  status: "is the product up, and on which ports. Reads; changes nothing",
78
78
  connect: "connect the assistant you already use — pick it by name and get the one thing it needs",
package/bin/connect.mjs CHANGED
@@ -47,9 +47,12 @@ import { execFileSync } from "node:child_process";
47
47
  import { createServer } from "node:net";
48
48
  import { CONNECT_CLIENTS, WHERE_FLAG, clientById, leadRouteFor, plainStep, whatItNeeds } from "../shared/connect-clients.mjs";
49
49
  import { stdioConnectFor, STDIO_SHAPES } from "../shared/stdio-connect.mjs";
50
+ import { claudeNamer } from "../driver/engine/probe.mjs"; // names the copy setup installed, which is not on PATH
50
51
  import { isWsl, wslTarget } from "../shared/wsl.mjs"; // — and which distribution a row should start the server in
51
52
  import { defaultDenylistPath, clientDoorAddress, clientDoorPort, clientDoorState, enablePlan, applyEnablePlan, describeChange, recordConnectKey, CLIENT_DOOR_UNIT, demoTokenSecretPath, keyPurposeLine, demoConnectCommand } from "../shared/client-door.mjs";
52
53
  import { readRunning } from "../shared/running-start.mjs";
54
+ import { installPaths } from "./start.mjs"; // — one owner for a demo's layout, as `key` reads it
55
+ import { demoProgramPlan } from "../shared/permanent-install.mjs";
53
56
  import { readLocalCredential, passphraseResetCommand, INSTALL_CREDENTIAL_FILE } from "../driver/portal-local-auth.mjs";
54
57
  import { invocationPrefix } from "../shared/invocation.mjs";
55
58
  import { BRAND } from "../shared/brand.mjs";
@@ -212,6 +215,7 @@ function deploymentHas(env = process.env) {
212
215
  stdioRoutes: Object.fromEntries(Object.keys(STDIO_SHAPES).map((shape) =>
213
216
  [shape, stdioConnectFor(shape, { workDir: env.CLEAROTRON_WORK_DIR || null, reportsDir: env.CLEAROTRON_REPORTS_DIR || null, wsl: wslTarget({ env }) })])),
214
217
  wsl: isWsl({ env }),
218
+ nameClaude: claudeNamer(env),
215
219
  // WHERE THE DOOR BINDS — not an address handed to any assistant. It is the loopback address the
216
220
  // unit listens on, and `enablePlan` needs it to write the unit. It used to be passed to the
217
221
  // resolver as `localAddress` and served to Cowork as somewhere to connect, which is the false
@@ -658,6 +662,41 @@ function printSteps(offer, key) {
658
662
  }
659
663
  }
660
664
 
665
+ /**
666
+ * What a demo has to offer an assistant on this machine: every stdio shape, resolved once against the demo's own folders and
667
+ * flag. The program is the demo's own copy where it has one, as the demo's start names it; otherwise the one running this.
668
+ */
669
+ function demoHave(at) {
670
+ const paths = installPaths(at);
671
+ const plan = demoProgramPlan({ base: at });
672
+ const program = plan?.current ? { installRoot: plan.root } : {};
673
+ return {
674
+ stdioRoutes: Object.fromEntries(Object.keys(STDIO_SHAPES).map((shape) =>
675
+ [shape, stdioConnectFor(shape, { ...program, workDir: paths.workspace, reportsDir: paths.pool, wsl: wslTarget(), demo: true })])),
676
+ wsl: isWsl(),
677
+ nameClaude: claudeNamer(),
678
+ demo: true,
679
+ };
680
+ }
681
+
682
+ /** THE QUESTION, IN THE READER'S WORDS: which assistant they want to use, the one thing they know for certain. */
683
+ async function askWhichAssistant() {
684
+ say("");
685
+ say(" Which assistant do you want to use?");
686
+ say("");
687
+ CONNECT_CLIENTS.forEach((c, n) => say(` ${n + 1}) ${c.name}`));
688
+ say("");
689
+ requireInteractive({ verb: "connect" });
690
+ const rl = createInterface({ input: stdin, output: stdout });
691
+ let chosen = null;
692
+ try {
693
+ const answer = (await rl.question(` 1-${CONNECT_CLIENTS.length}: `)).trim();
694
+ chosen = CONNECT_CLIENTS[Number(answer) - 1] ?? clientById(answer);
695
+ } finally { rl.close(); }
696
+ if (!chosen) { console.error("connect: not one of the listed assistants."); process.exit(2); }
697
+ return chosen;
698
+ }
699
+
661
700
  /**
662
701
  * ── A RUNNING DEMO, NAMED BY ITS FOLDER (owner, 2026-09-19) ─────────────────────────────────────────
663
702
  *
@@ -671,17 +710,30 @@ function printSteps(offer, key) {
671
710
  * The address route's steps are not printed. They are written for a door behind a sign-in service,
672
711
  * reached over the web, and a demo's door is on this machine and takes the key instead.
673
712
  */
674
- async function connectDemo({ base, dryRun, clientName = null, running = readRunning() } = {}) {
713
+ async function connectDemo({ base, dryRun, client = null, route = null, running = readRunning(), ask = askWhichAssistant } = {}) {
675
714
  const at = resolve(base);
676
715
  const prefix = invocationPrefix();
677
- say("");
678
- if (clientName) { say(` ${clientName}`); say(""); }
679
716
  const demo = running.find((r) => r.demo && resolve(String(r.base ?? "")) === at);
680
717
  if (!demo) {
718
+ say("");
681
719
  say(` Not available here — no demo is running from ${at}.`);
682
720
  say(` What would change it: start it with \`${prefix}clearotron demo --base ${/\s/.test(at) ? `"${at}"` : at}\`, then run this again.`);
683
721
  return 1;
684
722
  }
723
+ // ── EACH ASSISTANT ITS OWN FORM, BOUND TO THE DEMO (design, 2026-11-05) ─────────────────────────────
724
+ //
725
+ // The demo's start names Claude Code's line only, so a reader with another assistant had nothing to run.
726
+ // This asks which assistant, as the plain command does, and hands it the form its row already has, bound
727
+ // to the demo: its own program, work folder, reports folder and demo flag, under the demo's own server
728
+ // name, so a real install's connection beside it is left as it is. The key route above is `--where
729
+ // elsewhere`, which the demo's client-door line names.
730
+ if (route !== "public-http") {
731
+ const chosen = client ?? await ask();
732
+ const have = demoHave(at);
733
+ return await render(whatItNeeds(chosen, have, "disk"), have, { dryRun, running: { env: {}, known: false } });
734
+ }
735
+ say("");
736
+ if (client) { say(` ${client.name}`); say(""); }
685
737
  if (!demo.ports?.client) {
686
738
  say(` Not available here — the demo running from ${at} has no client door open.`);
687
739
  say(" What would change it: stop the demo and start it again; its output says why the door did not start.");
@@ -731,7 +783,8 @@ async function main() {
731
783
  say(" internet, with a key made for you now");
732
784
  say(" --list the assistants this build knows");
733
785
  say(" --dry-run say what would change, change nothing");
734
- say(" --base <dir> a running demo's folder: mint a key for its client door, and print both");
786
+ say(" --base <dir> a running demo's folder: connect your assistant to that demo. With");
787
+ say(" --where elsewhere, mint a key for its client door, and print both");
735
788
  say(" --allow-checkout-move");
736
789
  say(" write this checkout's path even though services are running from");
737
790
  say(" another one. Every unit's ExecStart follows that value, so the ones");
@@ -747,19 +800,26 @@ async function main() {
747
800
  process.exit(2);
748
801
  }
749
802
  const dryRun = argv.includes("--dry-run");
750
- const b = argv.indexOf("--base");
751
- if (b >= 0) {
752
- const base = argv[b + 1];
753
- if (!base || base.startsWith("--")) { console.error("connect: --base needs the demo's folder."); process.exit(2); }
754
- const c = argv.indexOf("--client");
755
- return await connectDemo({ base, dryRun, clientName: c >= 0 ? clientById(argv[c + 1])?.name ?? null : null });
756
- }
757
803
  const w = argv.indexOf("--where");
758
804
  if (w >= 0 && !Object.hasOwn(WHERE_FLAG, argv[w + 1] ?? "")) {
759
805
  console.error(`connect: --where takes one of: ${Object.keys(WHERE_FLAG).join(", ")}`);
760
806
  process.exit(2);
761
807
  }
762
808
  let route = w >= 0 ? WHERE_FLAG[argv[w + 1]] : null;
809
+ const b = argv.indexOf("--base");
810
+ if (b >= 0) {
811
+ const base = argv[b + 1];
812
+ if (!base || base.startsWith("--")) { console.error("connect: --base needs the demo's folder."); process.exit(2); }
813
+ // `--list` NEEDS NO ANSWER, as the refusal for a missing terminal says, so it is answered here too.
814
+ if (argv.includes("--list")) { for (const x of CONNECT_CLIENTS) say(` ${x.id.padEnd(16)} ${x.name}`); return 0; }
815
+ const c = argv.indexOf("--client");
816
+ const named = c >= 0 ? clientById(argv[c + 1]) : null;
817
+ if (c >= 0 && !named) {
818
+ console.error(`connect: no such assistant "${argv[c + 1]}". One of: ${CONNECT_CLIENTS.map((x) => x.id).join(", ")}`);
819
+ process.exit(2);
820
+ }
821
+ return await connectDemo({ base, dryRun, client: named, route });
822
+ }
763
823
  // F40 — reason about the RUNNING product from the units' own environment, not this CLI's env file.
764
824
  const running = runningEnv();
765
825
  const have = deploymentHas(running.env);
@@ -787,20 +847,8 @@ async function main() {
787
847
  }
788
848
 
789
849
  if (!chosen) {
790
- // THE QUESTION, IN THE READER'S WORDS. Not "which transport", not "is this deployment hosted" —
791
- // which assistant they want to use, which is the only thing they know for certain.
792
- say("");
793
- say(" Which assistant do you want to use?");
794
- say("");
795
- CONNECT_CLIENTS.forEach((c, n) => say(` ${n + 1}) ${c.name}`));
796
- say("");
797
- requireInteractive({ verb: "connect" });
798
- const rl = createInterface({ input: stdin, output: stdout });
799
- try {
800
- const answer = (await rl.question(` 1-${CONNECT_CLIENTS.length}: `)).trim();
801
- chosen = CONNECT_CLIENTS[Number(answer) - 1] ?? clientById(answer);
802
- } finally { rl.close(); }
803
- if (!chosen) { console.error("connect: not one of the listed assistants."); process.exit(2); }
850
+ // Not "which transport", not "is this deployment hosted": which assistant (askWhichAssistant).
851
+ chosen = await askWhichAssistant();
804
852
  // THE SECOND QUESTION, ASKED ONLY WHEN IT HAS TWO ANSWERS — the page's own, in the terminal's words.
805
853
  // Where only one route is served here, asking would offer a choice whose other half cannot work.
806
854
  const both = ["disk", "public-http"].filter((r) => whatItNeeds(chosen, have, r)?.served);
package/bin/example.mjs CHANGED
@@ -211,6 +211,8 @@ const contains = (parent, child) => parent === child || child.startsWith(parent.
211
211
  // path, and is REFUSED with the portal, because publishing into one directory while serving another is
212
212
  // a demo that shows a reader an empty archive and says nothing about why.
213
213
  const demoBase = resolve(flag("--base") ?? join(homedir(), "trademark-demo"));
214
+ // READ BEFORE ANYTHING BELOW MAKES IT: a folder an earlier `--once` or `--keep` left is kept on exit.
215
+ const baseExisted = existsSync(demoBase);
214
216
  if (flag("--pool") && !has("--once")) die(
215
217
  "demo: --pool is for --once, which publishes and exits.",
216
218
  "",
@@ -422,12 +424,12 @@ function strayFromAnOlderDemo() {
422
424
  // control greyed with the reason at it. Re-implementing that here is how there came to be two portals
423
425
  // in the first place, so this hands over rather than copies. The dev cockpit keeps its job as a
424
426
  // contributor tool; it simply stops being what `demo` opens.
425
- const startArgs = demoStartArgs({ demoBase, readerBase: flag("--base") != null, keep: has("--keep"),
427
+ const startArgs = demoStartArgs({ demoBase, readerBase: flag("--base") != null, baseExisted, keep: has("--keep"),
426
428
  port: flag("--port"), noOpen: has("--no-open") });
427
429
 
428
430
  // ONLY WHEN THE FOLDER WILL OUTLIVE THE WINDOW. The demo removes what it made when it stops, and the
429
431
  // supervisor's banner says so; printing a removal command here as well told the reader the opposite.
430
- if (flag("--base") != null || has("--keep")) console.log(` Removing this demo later is one directory: ${removeDirectory(demoBase)}`);
432
+ if (flag("--base") != null || has("--keep") || baseExisted) console.log(` Removing this demo later is one directory: ${removeDirectory(demoBase)}`);
431
433
  strayFromAnOlderDemo();
432
434
  console.log("");
433
435