@mrciphersmith/roomyx 0.12.2 → 0.12.3

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 (44) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +84 -4
  3. package/package.json +11 -10
  4. package/src/bin/launch.mjs +1 -1
  5. package/src/bundled-personas/groups.md +3 -3
  6. package/src/bundled-skills/startup-room/reference/roomyx.md +5 -0
  7. package/src/cli/client.ts +12 -0
  8. package/src/cli/experiment.ts +67 -0
  9. package/src/cli/init.ts +149 -0
  10. package/src/cli/mcp.ts +54 -0
  11. package/src/cli/personas.ts +40 -0
  12. package/src/cli/room-append.ts +357 -0
  13. package/src/cli/room.ts +91 -0
  14. package/src/cli/rooms.ts +65 -0
  15. package/src/cli/serve.ts +84 -0
  16. package/src/cli/shared.ts +71 -0
  17. package/src/cli/skills.ts +58 -0
  18. package/src/cli/specs.ts +1 -0
  19. package/src/cli.ts +29 -884
  20. package/src/client/index.ts +16 -3
  21. package/src/client/mcp-client.ts +106 -7
  22. package/src/client/shutdown.ts +29 -6
  23. package/src/experiment/manifest.ts +151 -0
  24. package/src/installer/init-apply.ts +38 -7
  25. package/src/installer/init.ts +5 -2
  26. package/src/installer/registry.ts +38 -6
  27. package/src/installer/resolve-connection.ts +54 -8
  28. package/src/installer/room-tool.ts +6 -3
  29. package/src/installer/skill-sync.ts +86 -3
  30. package/src/installer/skill-targets.ts +7 -3
  31. package/src/lockfile.ts +13 -2
  32. package/src/log/schema.ts +108 -38
  33. package/src/log/store.ts +1 -0
  34. package/src/log/types.ts +8 -1
  35. package/src/log/write.ts +115 -6
  36. package/src/mcp-management/server.ts +30 -4
  37. package/src/room-token.ts +129 -0
  38. package/src/server/http-transport.ts +43 -0
  39. package/src/server/index.ts +76 -3
  40. package/src/server/log-watcher.ts +80 -0
  41. package/src/server/owner-queue.ts +7 -1
  42. package/src/server/serve.ts +112 -30
  43. package/src/server/shutdown.ts +33 -7
  44. package/src/writer-lease.ts +161 -14
package/CHANGELOG.md CHANGED
@@ -13,6 +13,97 @@ patch and never a minor. The rule, the reason, and an audit of the four of seven
13
13
  releases that followed it are in
14
14
  [`docs/roomyx/versioning.md`](docs/roomyx/versioning.md) and decision D-13.
15
15
 
16
+ ## [Unreleased]
17
+
18
+ ## [0.12.3] — 2026-11-30
19
+
20
+ ### Security
21
+
22
+ - **The room registry, which holds each room's token, is now written 0600.** It was
23
+ written with `writeFileSync`'s default (`0666 & ~umask`), so on a shared host
24
+ any local user could read the token and drive the room. The directory is 0700
25
+ when roomyx creates it, whether through `roomyx init` or by registering a room. A registry written by an older version stays loose until
26
+ its next write replaces it; `chmod 600` it by hand to close the window sooner.
27
+
28
+ ### Added
29
+
30
+ - **A room tells its clients when the log grows, instead of each client asking every second.**
31
+ The room server now advertises `resources.subscribe` and sends
32
+ `notifications/resources/updated` for a new resource, `room://log`, when the log
33
+ gets longer — however it got longer, including a message appended by another
34
+ process. `roomyx-client` subscribes and fetches the moment it is told; its polls
35
+ become a 15-second backstop. One file check per room replaces one
36
+ `room.get_transcript` per client per second. Against a room that cannot
37
+ subscribe (an older roomyx, or a refused subscription) the client polls exactly
38
+ as before. Decision D-23.
39
+
40
+ - **`roomyx experiment plan` / `roomyx experiment new`: an experiment manifest and a grid of rooms.**
41
+ A `.yaml` (or `.json`) manifest names the goal, roster, model, seed and
42
+ variables; every list-valued variable is a grid axis, `repeats` multiplies it,
43
+ and `{{name}}` in the goal takes the cell's value. `plan` prints the rooms
44
+ without writing; `new --out <dir>` creates one log per cell, each header
45
+ recording its variables, seed and the manifest's digest (`experiment`, an
46
+ optional header field, so older logs and readers are unaffected). roomyx still
47
+ does not run agents: a dispatcher runs each room. YAML needs Bun 1.2.21 or
48
+ newer (the floor in `engines` is unchanged; use `.json` below it). Decision D-22.
49
+
50
+ - **`roomyx room append --read-through <seq>`: refuse a message written without seeing the others.**
51
+ Parallel agents each answer the round they were shown while a sibling's message
52
+ lands, and integration fails. The dispatcher says how far the author had read;
53
+ if another participant wrote past that, the append is refused, names what was
54
+ missed, and writes nothing (`--allow-unread` writes anyway; the position is kept
55
+ in the message as `read_through`). Optional everywhere, so a dispatcher that
56
+ cannot say what it showed is unaffected. Decision D-21.
57
+
58
+ ### Fixed
59
+
60
+ - **`bun run soak` finishes again.** It built its client without the room token the
61
+ server has required since 0.12, so the client never connected, no state poll
62
+ ever counted, and the harness waited for ever (it was never wired into CI for
63
+ that reason). It now sends the token, and fails after 30 seconds without a poll
64
+ (`--stall-seconds`) instead of hanging. The nightly stress run now includes it.
65
+
66
+ ### Changed
67
+
68
+ - **CI and the stress workflow declare `permissions: contents: read`.** They ran PR code
69
+ with whatever the repository's default token scope was; the release workflow already
70
+ asked only for what it needs.
71
+ - **CI and the release workflow pin Bun instead of tracking `latest`.** `.bun-version`
72
+ names the Bun the project is developed with; CI also runs the lowest supported
73
+ Bun, so a Bun release can no longer break a tagged release with no code change.
74
+ - **`engines.bun` is now `>=1.2.15`, not `>=1.1.0`.** The old floor was never tested;
75
+ 1.2.0 and below fail the launcher tests. The range is advisory (npm does not enforce
76
+ it for Bun), and the launcher's missing-Bun message states the same floor.
77
+
78
+ - **CI now runs the log fuzzer and replays every archived room log on each PR,**
79
+ and the fuzzer again nightly on a fresh seed. They existed in `scripts/` but ran
80
+ nowhere.
81
+
82
+ - **Dependencies moved to the newest versions their ranges allow:** the MCP SDK
83
+ (1.30.0 to 1.32.2), zod (4.6.7), `@opentui/core` (0.5.17), eslint and
84
+ typescript-eslint. `@opentui/core` 0.9 and TypeScript 7 are major jumps and are
85
+ deliberately left out.
86
+
87
+ - **A test now pins the unauthenticated management endpoint to its two reporting
88
+ tools,** and checks that `roomyx.skills.sync` over it leaves every target exactly
89
+ as it was. The endpoint takes no credential, which holds only while nothing on it
90
+ acts; a new tool, or a `yes` flag, now fails a test instead of passing silently.
91
+
92
+ - **`bun run check` and CI fail when `CHANGELOG.md` has no entry for the version in
93
+ `package.json`,** so a version bump cannot ship without its notes.
94
+
95
+ - **`src/cli.ts` is split into one module per command under `src/cli/`.** An internal
96
+ refactor with no behaviour change: `src/cli.ts` keeps the dispatcher, the version
97
+ and the help, and every command's flags, output and exit codes are as before.
98
+
99
+ - **The project wiki now records why the writer lease, `seq` allocation and the
100
+ per-room token work the way they do,** and its `src/cli` page reflects the split.
101
+ Internal documentation under `.metaproject/wiki/`; nothing shipped changes.
102
+
103
+ - **`roomyx init` now says that room logs are committed with the repository,** when it
104
+ creates the logs directory, and how to keep them out. It still ignores only the
105
+ registry and lockfiles; the transcript is deliberately kept.
106
+
16
107
  ## [0.12.2] — 2026-09-12
17
108
 
18
109
  A documentation patch, and the defect it fixes was on the first screen anyone
package/README.md CHANGED
@@ -33,6 +33,23 @@ transcript where every message is intact and the discussion is nonsense. See
33
33
  D-01a, and `docs/roomyx/skill-review-2026-09-11.md` for why closing the gap
34
34
  needs a dispatcher identity that survives across processes.
35
35
 
36
+ ## What is in this repository
37
+
38
+ | | |
39
+ | --- | --- |
40
+ | `src/` | The package. `src/*.ts` is the shipped artefact — there is no build step. |
41
+ | `src/bundled-skills/` | The `startup-room` skill, as installed by `roomyx skills sync`. |
42
+ | `src/bundled-personas/` | The persona library and the 50-question interview script. |
43
+ | `test/` | 58 files. `bun test` runs them; `bun run test:e2e` adds the ones that start a real server. |
44
+ | `scripts/` | Three harnesses that are not unit tests: `soak`, `fuzz`, `replay`. See **Testing** below. |
45
+ | `docs/roomyx/decisions.md` | Every design decision, numbered, with the alternative that was rejected. |
46
+ | `docs/roomyx/ACTIONS.md` | What is outstanding, with evidence per item. |
47
+ | `docs/roomyx/rooms/` | Archived rooms — transcripts, logs and rendered frames. |
48
+ | `docs/roomyx/planning/` | The PRD, architecture and roadmap this was built from. |
49
+
50
+ `AGENTS.md` and `CLAUDE.md` are at the root because that is where coding agents
51
+ look for them; they are instructions for tooling, not documentation for readers.
52
+
36
53
  ## Requirements
37
54
 
38
55
  **[Bun](https://bun.sh) 1.1 or newer must be on your `PATH`.** roomyx ships
@@ -178,6 +195,7 @@ Creates a room log, and appends messages to one.
178
195
  | `--roster id:Name,...` | Participants. `id` is what `room.get_agent_detail` takes. |
179
196
  | `--from <id>` / `--body <s>` | Required by `append`. |
180
197
  | `--kind <k>` / `--in-reply-to <n>` | Optional message structure. |
198
+ | `--read-through <n>` / `--allow-unread` | The highest `seq` the author had seen; the append is refused if another participant wrote past it (D-21). |
181
199
  | `--take-over` | Write when the room is live but its writer is provably gone. |
182
200
 
183
201
  `new` refuses to overwrite an existing log — it is append-only, and clobbering
@@ -194,6 +212,29 @@ stop it.
194
212
  stopped, or the lease it left has expired without being refreshed. It records
195
213
  the take-over in the log, naming whose lease it took.
196
214
 
215
+ ### `roomyx experiment plan <manifest>` / `roomyx experiment new <manifest> --out <dir>`
216
+
217
+ Expands an experiment manifest into rooms — one per cell of the variable grid.
218
+
219
+ ```yaml
220
+ name: pricing
221
+ goal: "Pick a price for the {{tier}} tier"
222
+ roster: [ada:Ada, ben]
223
+ model: sonnet # recorded, never called
224
+ seed: 10 # a cell's seed is seed + its repeat
225
+ repeats: 2
226
+ variables:
227
+ tier: [free, pro] # a list is a grid axis
228
+ region: eu # a scalar is held constant
229
+ ```
230
+
231
+ `plan` prints the cells and writes nothing; `new` writes one log per cell into
232
+ `--out` and refuses, writing nothing, if any of them exists. Each log's header
233
+ records the cell's variables, seed and the manifest's SHA-256 (`experiment`),
234
+ which is what makes a finished room comparable with its siblings. roomyx does
235
+ not run agents — a dispatcher runs each room. A grid over 500 cells is refused.
236
+ YAML needs Bun 1.2.21 or newer; a `.json` manifest works everywhere.
237
+
197
238
  ### `roomyx room delta <log> --for <id>` / `roomyx room commands <log>` / `roomyx room ack <log> <id>`
198
239
 
199
240
  What a dispatcher needs from a room that is already running. All three read the
@@ -230,6 +271,28 @@ Multiple independent MCP client sessions against one `serve` process are
230
271
  supported: each new session gets its own transport and server instance, keyed by
231
272
  `mcp-session-id`.
232
273
 
274
+ **Every request must present the room's token.** `serve` mints one per room, per
275
+ process start, and writes it into the room's registry entry beside the port —
276
+ never to stdout, because stdout is a scrollback and a CI log. A request without
277
+ it, or with the wrong one, is refused with `401` before the MCP layer sees it;
278
+ the refusal never quotes the expected value. Present it as a standard
279
+ `Authorization: Bearer <token>` header:
280
+
281
+ ```bash
282
+ TOKEN=$(jq -r '.rooms[0].token' .roomyx/rooms/registry.json)
283
+ curl -H "authorization: Bearer $TOKEN" ... http://127.0.0.1:4319/mcp
284
+ ```
285
+
286
+ Every in-tree caller — the TUI, `roomyx room delta|commands|ack`, `rooms list`'s
287
+ liveness probe — reads it from that entry and needs no flag. **This is not
288
+ authentication of a person.** Nobody signs in, and it records nothing about who
289
+ called. What it does is stop a process that knows only the port from driving the
290
+ room: reaching the endpoint means reading the transcript *and* queueing owner
291
+ commands to an agent that is holding tools, so knowing the port is no longer
292
+ enough. A process that can read the registry file is still inside the boundary.
293
+ `roomyx mcp`, the management server, has no token — a different surface, no
294
+ owner-command queue, and its tools report rather than act.
295
+
233
296
  ### `roomyx rooms list`
234
297
 
235
298
  Lists rooms that are **confirmed live**, not merely present in the registry —
@@ -362,7 +425,8 @@ lifetime from `serve`/`mcp`.
362
425
  | Flag | Meaning |
363
426
  | --- | --- |
364
427
  | `--room <id>` | Attach to a specific live room by id. |
365
- | `--connect <url>` | Attach to an explicit MCP URL. Wins outright; the registry is not consulted. |
428
+ | `--connect <url>` | Attach to an explicit MCP URL. The address wins outright; the registry is consulted only to find that port's token. |
429
+ | `--token <token>` | The room's token, when `--connect` names a room this registry does not know. |
366
430
  | `--registry <path>` | Registry file to resolve rooms from. |
367
431
  | `--archive` | Pick a closed room from the history index and open it read-only. |
368
432
  | `--open <logPath>` | Reread one closed room directly, read-only. No server needed. |
@@ -370,6 +434,22 @@ lifetime from `serve`/`mcp`.
370
434
  With no flags it auto-attaches when exactly one room is live, and refuses with a
371
435
  list of candidate ids when more than one is.
372
436
 
437
+ **The room's token.** A room requires the per-room token `roomyx serve` mints for
438
+ it, presented as `Authorization: Bearer <token>`. It is recorded in the room's
439
+ registry entry beside its port and is never printed, so `--room <id>` and
440
+ auto-attach find it for you and need no extra flag. `--token` exists for the one
441
+ case that cannot be looked up: `--connect` against a room registered somewhere
442
+ this client cannot read. Without a token the room answers 401, which the client
443
+ reports as `disconnected` — so it says so in one line rather than leaving that to
444
+ look like a room that is not running.
445
+
446
+ **Live updates.** A running room tells the client when its log grows (an MCP
447
+ resource subscription to `room://log`, D-23), and the client fetches at once; its
448
+ polls drop to one every 15 seconds as a backstop. Against a room that cannot
449
+ subscribe — an older roomyx — the client polls every second, as before. The
450
+ notification carries no message text, so nothing a subscriber learns is more than
451
+ `room.get_transcript` would have told it.
452
+
373
453
  **Read-only mode.** `--open` and `--archive` load a finished log once — no
374
454
  server, no polling, no reconnect. Scrolling, per-participant filtering, search,
375
455
  export and help behave exactly as in a live room; the owner command does not
@@ -399,7 +479,7 @@ and skill-sync — to any MCP client.
399
479
 
400
480
  | Tool | Input | Returns |
401
481
  | --- | --- | --- |
402
- | `roomyx.rooms.list` | — | Live, liveness-checked rooms. |
482
+ | `roomyx.rooms.list` | — | Live, liveness-checked rooms — id, port, log path, pid and start time. Never a room's token: this server takes no credential of its own, so echoing them here would hand every room's credential to the caller the token bounds. |
403
483
  | `roomyx.skills.sync` | `target: claude \| codex \| keryx \| all`, `dryRun?: boolean`, `yes?: boolean` | One result per target: whether it would write, whether it did, and where the backup went. |
404
484
 
405
485
  **Named targets only, deliberately.** This tool once accepted a literal
@@ -517,7 +597,7 @@ a whole. It is documented here because the tests in this package assume it.
517
597
 
518
598
  ```bash
519
599
  bun install
520
- bun run check # lint + typecheck + test
600
+ bun run check # lint + typecheck + changelog entry + test
521
601
  ```
522
602
 
523
603
  Releases are cut by pushing a `v*` tag whose version matches `package.json`; the
@@ -557,7 +637,7 @@ seconds and asserts a state.
557
637
 
558
638
  `scripts/soak.ts` compresses the clock by poll count rather than by wall time —
559
639
  the 2.7-hour death is 3275 state polls, which at a 20 ms interval is sixty-five
560
- seconds — and drives a real `ChatView` and a real `RoomClient` against a real
640
+ seconds — and drives a real `ChatView` and a real `RoomClient` (polling only — `subscribe: false`, since the poll count is what it compresses) against a real
561
641
  `roomyx serve`, through a proxy that counts every request. It reports **trends**,
562
642
  not thresholds: a threshold has to be guessed and is wrong on someone else's
563
643
  machine, while "the renderable count grew with the transcript and not with the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrciphersmith/roomyx",
3
- "version": "0.12.2",
3
+ "version": "0.12.3",
4
4
  "description": "MCP server + terminal UI for startup-room: live room status, chat, per-agent modal, an installable room registry, and skill-sync.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -38,23 +38,24 @@
38
38
  "test:e2e": "ROOMYX_E2E=1 bun test test/cli-room-tools.test.ts",
39
39
  "typecheck": "tsc --noEmit",
40
40
  "lint": "eslint src test",
41
- "check": "bun run lint && bun run typecheck && bun test",
41
+ "check:changelog": "bun scripts/check-changelog.ts",
42
+ "check": "bun run lint && bun run typecheck && bun test && bun run check:changelog",
42
43
  "soak": "bun scripts/soak.ts",
43
44
  "fuzz": "bun scripts/fuzz-log.ts",
44
45
  "replay": "bun scripts/replay.ts"
45
46
  },
46
47
  "dependencies": {
47
- "@modelcontextprotocol/sdk": "^1.25.0",
48
- "@opentui/core": "^0.5.11",
49
- "zod": "^4.5.4"
48
+ "@modelcontextprotocol/sdk": "^1.32.2",
49
+ "@opentui/core": "^0.5.17",
50
+ "zod": "^4.6.7"
50
51
  },
51
52
  "devDependencies": {
52
- "@types/bun": "^1.4.2",
53
- "eslint": "^10.10.0",
54
- "typescript": "^5.6.0",
55
- "typescript-eslint": "^8.0.0"
53
+ "@types/bun": "^1.4.5",
54
+ "eslint": "^10.16.0",
55
+ "typescript": "^5.9.3",
56
+ "typescript-eslint": "^8.74.0"
56
57
  },
57
58
  "engines": {
58
- "bun": ">=1.1.0"
59
+ "bun": ">=1.2.15"
59
60
  }
60
61
  }
@@ -24,7 +24,7 @@ import { fileURLToPath } from "node:url";
24
24
  * exactly the install-time network fetch that installer D-01 exists to refuse.
25
25
  */
26
26
 
27
- const MISSING_BUN = `roomyx needs Bun 1.1+ on your PATH.
27
+ const MISSING_BUN = `roomyx needs Bun 1.2.15+ on your PATH.
28
28
 
29
29
  It ships TypeScript and runs it directly — there is no build step, so Bun is
30
30
  the interpreter rather than a build-time dependency.
@@ -21,7 +21,7 @@ A registry of named groups for quickly launching a startup-room without re-expla
21
21
 
22
22
  **Known lineup limitation:** 4 of the 6 original participants (Viktor, Aigerim, Dmitry, Pavel) have a regulatory/compliance-heavy background — this systematically pulls the discussion toward "document workflow/registries/compliance" even after the topic is explicitly banned. When re-running for a genuinely different angle — keep these four in "comment only" mode, don't let them propose first, and explicitly ask Rohan/Wei/new participants to take the initiative.
23
23
 
24
- **Protocol:** `arena/brainstorm/startup-room-cis-asia-it.md`
24
+ **Protocol:** a transcript from an earlier run of this group (`startup-room-cis-asia-it`), kept in the project this library came from and not shipped here
25
25
 
26
26
  ---
27
27
 
@@ -38,7 +38,7 @@ A registry of named groups for quickly launching a startup-room without re-expla
38
38
  6. Vanessa Cruz — venture-backed, thesis of aggressive growth through AI agents (`founders/04-vanessa-blitzscaler-sf.md`) — reused
39
39
  7. David Kim — VC partner, scans funding rounds for AI startups (`panel/03-david-vc-financier.md`) — reused
40
40
 
41
- **Protocol:** `arena/brainstorm/startup-room-ai-trends.md` (paused — see goal contract v2 in the file header).
41
+ **Protocol:** a transcript from an earlier run of this group (`startup-room-ai-trends`), kept in the project this library came from and not shipped here (paused — see goal contract v2 in the file header).
42
42
 
43
43
  ---
44
44
 
@@ -60,7 +60,7 @@ A registry of named groups for quickly launching a startup-room without re-expla
60
60
  9. Elena Kovaleva — engineering manager, a real-world devtools buyer (`tech/09-elena-engineering-manager-buyer.md`)
61
61
  10. David Mbeki — competitive market analyst for AI devtools (`tech/10-david-competitive-analyst.md`)
62
62
 
63
- **Protocol:** `arena/brainstorm/tech-room-new-ux.md` (search for a new idea, until 2026-09-08) → `arena/reviews/keryx/product-review-transcript.md` (keryx product review, from 2026-09-08).
63
+ **Protocol:** a transcript from an earlier run of this group (`tech-room-new-ux`), kept in the project this library came from and not shipped here — first a search for a new idea, then a product review, both from 2026-09-08.
64
64
 
65
65
  ---
66
66
 
@@ -67,6 +67,11 @@ not understand.
67
67
  `research`; `--in-reply-to <seq>` records who was being answered. Both are
68
68
  optional and both make the transcript far easier to read later.
69
69
 
70
+ `--read-through <seq>` says how far the author had read when it wrote. If another
71
+ participant has written past that point, the append is refused and names what was
72
+ missed, so the agent can be shown it and write again. Use it when agents answer in
73
+ parallel; `--allow-unread` writes anyway, and the gap stays in the log.
74
+
70
75
  `--port 0` takes an ephemeral port, so several rooms can run at once without
71
76
  colliding. It prints the bound URL and a short room ID:
72
77
 
@@ -0,0 +1,12 @@
1
+ import { CLIENT_FLAGS } from "./specs";
2
+ import type { Command } from "./shared";
3
+
4
+ export const clientCommand: Command = {
5
+ usage: "roomyx client [flags]",
6
+ summary: "attach the terminal UI (same as the roomyx-client binary)",
7
+ flags: CLIENT_FLAGS,
8
+ run: async ({ flags }) => {
9
+ const { runClient } = await import("../client/index");
10
+ await runClient(flags);
11
+ },
12
+ };
@@ -0,0 +1,67 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join, resolve } from "node:path";
3
+ import { expand, loadManifest, ManifestError } from "../experiment/manifest";
4
+ import { createRoomLog } from "../log/write";
5
+ import { ArgError } from "./args";
6
+ import type { Command } from "./shared";
7
+
8
+ function plan(path: string) {
9
+ try {
10
+ const { manifest, digest } = loadManifest(resolve(path));
11
+ return { manifest, cells: expand(manifest, digest) };
12
+ } catch (error) {
13
+ if (error instanceof ManifestError) throw new ArgError(error.message);
14
+ throw error;
15
+ }
16
+ }
17
+
18
+ const NOTES =
19
+ "roomyx does not run agents. `new` makes the rooms; a dispatcher runs them, one per cell.\n Every cell's header records its variables, seed and manifest digest.";
20
+
21
+ export const experimentPlan: Command = {
22
+ usage: "roomyx experiment plan <manifest> [flags]",
23
+ summary: "list the rooms an experiment manifest expands to, writing nothing",
24
+ notes: NOTES,
25
+ flags: { json: { type: "boolean", describe: "Print the cells as JSON" } },
26
+ run: async ({ positionals, flags }) => {
27
+ const path = positionals[0];
28
+ if (!path) throw new ArgError("Missing <manifest> (.yaml, .yml or .json).");
29
+ const { cells } = plan(path);
30
+ if (flags.json === true) {
31
+ console.log(JSON.stringify(cells.map((c) => ({ id: c.id, goal: c.goal, ...c.header })), null, 2));
32
+ return;
33
+ }
34
+ for (const cell of cells) console.log(`${cell.id} ${JSON.stringify(cell.header.variables)}${cell.header.seed === undefined ? "" : ` seed=${cell.header.seed}`}`);
35
+ console.log(`${cells.length} room${cells.length === 1 ? "" : "s"}`);
36
+ },
37
+ };
38
+
39
+ export const experimentNew: Command = {
40
+ usage: "roomyx experiment new <manifest> --out <dir>",
41
+ summary: "create one room log per cell of an experiment manifest",
42
+ notes: `${NOTES}\n Refuses to overwrite: if any cell's log exists, nothing is written.`,
43
+ flags: { out: { type: "string", describe: "Required. Directory for the room logs" } },
44
+ run: async ({ positionals, flags }) => {
45
+ const path = positionals[0];
46
+ if (!path) throw new ArgError("Missing <manifest> (.yaml, .yml or .json).");
47
+ if (typeof flags.out !== "string" || flags.out === "") throw new ArgError("Missing --out <dir>.");
48
+ const { manifest, cells } = plan(path);
49
+ const out = resolve(flags.out);
50
+ const targets = cells.map((cell) => ({ cell, file: join(out, `${cell.id}.jsonl`) }));
51
+
52
+ const existing = targets.filter(({ file }) => existsSync(file));
53
+ if (existing.length > 0) {
54
+ throw new ArgError(`${existing[0]!.file} already exists${existing.length > 1 ? ` (and ${existing.length - 1} more)` : ""}. A room log is append-only; nothing was written.`);
55
+ }
56
+ for (const { cell, file } of targets) {
57
+ createRoomLog(file, {
58
+ goalStatement: cell.goal,
59
+ criteria: cell.criteria,
60
+ roster: manifest.roster,
61
+ experiment: cell.header,
62
+ });
63
+ console.log(`Created ${file}`);
64
+ }
65
+ console.log(`${cells.length} room${cells.length === 1 ? "" : "s"}; serve each with \`roomyx serve <file>\``);
66
+ },
67
+ };
@@ -0,0 +1,149 @@
1
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { init } from "../installer/init";
5
+ import { personaCount } from "../installer/personas";
6
+ import { bundledPersonasPath, bundledSkillPath } from "./shared";
7
+ import type { Command } from "./shared";
8
+
9
+ export const initCommand: Command = {
10
+ usage: "roomyx init [flags]",
11
+ summary: "scaffold .roomyx/, then set up skills, MCP and git for this project",
12
+ notes:
13
+ "Interactive when the terminal allows it: tick what you want, see every\n path before agreeing to it, and nothing is written until you submit.\n Through a pipe or in CI it scaffolds .roomyx/ and asks nothing, so it can\n never hang waiting for a keypress nobody is there to make.",
14
+ flags: {
15
+ yes: { type: "boolean", describe: "Apply the default selection without asking" },
16
+ "no-interactive": { type: "boolean", describe: "Scaffold .roomyx/ only" },
17
+ },
18
+ run: async ({ flags }) => {
19
+ const cwd = process.cwd();
20
+ const result = init({ cwd, bundledSkillPath: bundledSkillPath() });
21
+ console.log(result.created ? `Created ${result.roomyxDir}` : `${result.roomyxDir} already initialized`);
22
+ for (const warning of result.skillWarnings ?? []) {
23
+ // Said out loud rather than swallowed: the staged copy is now known to
24
+ // differ from the bundled skill, and whoever sees this decides what to
25
+ // do about it.
26
+ console.log(` ! ${warning}`);
27
+ }
28
+
29
+ const { buildPlan, selectedItems } = await import("../installer/init-plan");
30
+ const { applyPlan } = await import("../installer/init-apply");
31
+
32
+ const plan = buildPlan({ cwd, personaFiles: personaCount(bundledPersonasPath()) });
33
+ // A terminal on both ends or nothing to ask. `--yes` overrides, because
34
+ // a script that has decided already should not be refused for lacking a
35
+ // tty — but the default must never block a pipeline on a prompt.
36
+ const interactive = process.stdout.isTTY === true && process.stdin.isTTY === true;
37
+ if (flags["no-interactive"] === true || (!interactive && flags.yes !== true)) {
38
+ console.log("");
39
+ console.log("Nothing else was written. To install the skill and register the MCP server:");
40
+ console.log(" roomyx init --yes # the default selection, no prompt");
41
+ console.log(" roomyx init # pick, in a terminal");
42
+ return;
43
+ }
44
+
45
+ let chosen = plan;
46
+ if (flags.yes !== true) {
47
+ const { runInitPicker } = await import("../client/init-screen");
48
+ const picked = await runInitPicker(plan);
49
+ if (picked === null) {
50
+ console.log("Cancelled — nothing else was written.");
51
+ return;
52
+ }
53
+ chosen = picked;
54
+ }
55
+
56
+ const results = applyPlan(selectedItems(chosen), {
57
+ cwd,
58
+ bundledSkillPath: bundledSkillPath(),
59
+ bundledPersonasPath: bundledPersonasPath(),
60
+ configPath: join(cwd, ".roomyx", "config.json"),
61
+ });
62
+
63
+ console.log("");
64
+ for (const line of results) {
65
+ console.log(`${line.ok ? " ok " : " !! "} ${line.label}`);
66
+ console.log(` ${line.path} — ${line.message}`);
67
+ }
68
+
69
+ const failed = results.filter((line) => !line.ok).length;
70
+ if (failed > 0) console.log(`\n${failed} item(s) failed. Everything else was applied.`);
71
+ if (results.some((line) => line.ok && line.id.startsWith("skill:"))) {
72
+ // The one thing an operator reliably forgets, and the symptom is
73
+ // "roomyx installed the skill and my agent still cannot see it".
74
+ console.log("\nRestart your agent — skills are discovered at startup.");
75
+ }
76
+ console.log("\nNext: roomyx room new .roomyx/rooms/logs/<name>.jsonl --goal \"<what the room is for>\"");
77
+ },
78
+ };
79
+
80
+ export const setupCommand: Command = {
81
+ usage: "roomyx setup [flags]",
82
+ summary: "set this machine up, without touching the current project",
83
+ notes:
84
+ "The same picker `roomyx init` shows, narrowed to the rows that land on\n the machine: the skill for each agent runtime you use, and the persona\n library under ~/.roomyx. Nothing is created in the current directory, so\n this is what to run right after installing from npm — an npm lifecycle\n script cannot ask, because npm runs one with no terminal (CI, `npm ci`,\n Docker) and skips it entirely under --ignore-scripts.",
85
+ flags: {
86
+ yes: { type: "boolean", describe: "Apply the default selection without asking" },
87
+ },
88
+ run: async ({ flags }) => {
89
+ const home = homedir();
90
+ const cwd = process.cwd();
91
+ // Its own config, under the home directory: `syncSkill` records the hash
92
+ // of what it wrote so a later sync can tell "unchanged since we wrote it"
93
+ // from "edited by someone", and a machine-wide install has no project
94
+ // config to record into. Created here rather than demanded, because the
95
+ // whole point of this command is that there is no project yet.
96
+ const configPath = join(home, ".roomyx", "config.json");
97
+ if (!existsSync(configPath)) {
98
+ mkdirSync(join(home, ".roomyx"), { recursive: true });
99
+ writeFileSync(configPath, JSON.stringify({ schemaVersion: 1 }, null, 2));
100
+ }
101
+
102
+ const { buildPlan, machineItems, selectedItems } = await import("../installer/init-plan");
103
+ const { applyPlan } = await import("../installer/init-apply");
104
+ const plan = machineItems(buildPlan({ cwd, personaFiles: personaCount(bundledPersonasPath()) }));
105
+ // Ticked here, unticked in `init`, and the difference is the point. In a
106
+ // project the machine-wide library is a second copy of one the project
107
+ // already gets and the skill prefers. Here there is no project copy — so
108
+ // leaving it off would set a machine up with a skill that casts its room
109
+ // from personas that are nowhere on disk, which is the unfinished
110
+ // installer this whole command exists to avoid.
111
+ for (const item of plan) {
112
+ if (item.id === "personas:user" && item.done === undefined) item.selected = true;
113
+ }
114
+
115
+ const interactive = process.stdout.isTTY === true && process.stdin.isTTY === true;
116
+ if (!interactive && flags.yes !== true) {
117
+ console.log("Not a terminal, so nothing was asked and nothing was written.");
118
+ console.log(" roomyx setup --yes # the default selection, no prompt");
119
+ return;
120
+ }
121
+
122
+ let chosen = plan;
123
+ if (flags.yes !== true) {
124
+ const { runInitPicker } = await import("../client/init-screen");
125
+ const picked = await runInitPicker(plan);
126
+ if (picked === null) {
127
+ console.log("Cancelled — nothing was written.");
128
+ return;
129
+ }
130
+ chosen = picked;
131
+ }
132
+
133
+ const results = applyPlan(selectedItems(chosen), {
134
+ cwd,
135
+ bundledSkillPath: bundledSkillPath(),
136
+ bundledPersonasPath: bundledPersonasPath(),
137
+ configPath,
138
+ });
139
+
140
+ for (const line of results) {
141
+ console.log(`${line.ok ? " ok " : " !! "} ${line.label}`);
142
+ console.log(` ${line.path} — ${line.message}`);
143
+ }
144
+ if (results.some((line) => line.ok)) {
145
+ console.log("\nRestart your agent — skills are discovered at startup.");
146
+ }
147
+ console.log("\nNext, in a project: roomyx init");
148
+ },
149
+ };
package/src/cli/mcp.ts ADDED
@@ -0,0 +1,54 @@
1
+ import { serveManagement } from "../mcp-management/server";
2
+ import { REGISTRY_FLAG, bundledSkillPath, defaultConfigPath, defaultRegistryPath, runUntilSignal } from "./shared";
3
+ import type { Command } from "./shared";
4
+
5
+ export const mcpCommand: Command = {
6
+ usage: "roomyx mcp [flags]",
7
+ summary: "start the management MCP server",
8
+ notes: "Default port 4320, so it does not collide with `roomyx serve`.",
9
+ flags: {
10
+ stdio: { type: "boolean", describe: "Speak MCP over stdin/stdout instead of HTTP (what an MCP client spawns)" },
11
+ port: { type: "number", describe: "Listen port (default 4320; 0 picks an ephemeral one)" },
12
+ host: { type: "string", describe: "Bind address (default 127.0.0.1)" },
13
+ "acknowledge-non-loopback": { type: "boolean", describe: "Required to bind a non-loopback host" },
14
+ registry: REGISTRY_FLAG,
15
+ config: { type: "string", describe: "Config file (default .roomyx/config.json)" },
16
+ },
17
+ run: async ({ flags }) => {
18
+ const managementOptions = {
19
+ registryPath: typeof flags.registry === "string" ? flags.registry : defaultRegistryPath(),
20
+ bundledSkillPath: bundledSkillPath(),
21
+ configPath: typeof flags.config === "string" ? flags.config : defaultConfigPath(),
22
+ };
23
+
24
+ if (flags.stdio === true) {
25
+ // The transport an MCP client actually wants: it spawns the process and
26
+ // owns its lifetime, so there is no port to pick, nothing to leave
27
+ // running, and no registration that points at something not started
28
+ // yet. This is what `roomyx init` writes into `.mcp.json`.
29
+ //
30
+ // **Nothing may be printed to stdout here** — stdout is the protocol
31
+ // channel, and one stray line of greeting is a parse error at the far
32
+ // end. The HTTP branch below prints because it has a stdout to itself.
33
+ const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
34
+ const { createManagementMcpServer } = await import("../mcp-management/server");
35
+ const server = createManagementMcpServer(managementOptions);
36
+ await server.connect(new StdioServerTransport());
37
+ // The client closes the pipe when it is done; there is no port to
38
+ // release, so the signal handlers the HTTP branch installs would have
39
+ // nothing to do.
40
+ return;
41
+ }
42
+
43
+ const handle = await serveManagement(managementOptions, {
44
+ port: typeof flags.port === "number" ? flags.port : undefined,
45
+ host: typeof flags.host === "string" ? flags.host : undefined,
46
+ acknowledgeNonLoopback: flags["acknowledge-non-loopback"] === true,
47
+ });
48
+
49
+ console.log(`roomyx mcp listening at ${handle.url}`);
50
+ console.log("tools: roomyx.rooms.list, roomyx.skills.sync");
51
+
52
+ runUntilSignal(() => handle.close());
53
+ },
54
+ };