@mrciphersmith/roomyx 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,173 @@
1
+ # Changelog
2
+
3
+ Notable changes to `@mrciphersmith/roomyx`. Generated release notes say what
4
+ changed; this file exists for the two things they cannot say — **why**, and
5
+ **what to do if you were relying on the old behaviour**.
6
+
7
+ Format loosely follows [Keep a Changelog](https://keepachangelog.com). Versions
8
+ are [semantic](https://semver.org), with the `0.x` convention that breaking
9
+ changes land in the minor position.
10
+
11
+ ## [0.5.0] — 2026-09-09
12
+
13
+ The security release. Every item here came out of a review of the published
14
+ 0.4.0 that reproduced each finding before recording it; the full list is in
15
+ [`docs/roomyx/improvement-backlog.md`](docs/roomyx/improvement-backlog.md).
16
+
17
+ ### Added
18
+
19
+ - **`roomyx room new` and `roomyx room append`.** There was no supported way to
20
+ create the file `roomyx serve` takes. The only tool that made one was
21
+ `src/cli/seed.ts` — shipped in the package, absent from `bin` and the README,
22
+ and documented only as a call through an absolute path into the global
23
+ `node_modules`. Time-to-first-room is this product's central number and that
24
+ was the path to it.
25
+
26
+ `new` refuses to overwrite an existing log. `append` refuses when the
27
+ registry shows a live room serving that path, because that room's dispatcher
28
+ is the log's single writer; `--force` overrides. Recorded as **D-01a**: D-01
29
+ constrains the server, not the package, and the invariant is one writer per
30
+ *live* room.
31
+
32
+ `src/cli/seed.ts` is removed, superseded by these.
33
+
34
+ - **The `bin` entries are Node launchers.** They used to be the TypeScript
35
+ files themselves, carrying a `#!/usr/bin/env bun` shebang. On a machine
36
+ without Bun that failed as `/usr/bin/env: 'bun': No such file or directory` —
37
+ a kernel message with no roomyx text in it, and no way to add any, because a
38
+ shebang is an `execve` dispatch with no slot for a diagnostic.
39
+
40
+ `engines.bun` was not protecting anyone either: npm's engine check only ever
41
+ knew `node` and `npm`, so a package declaring `bun: ">=99.0.0"` installs
42
+ cleanly under `--engine-strict`.
43
+
44
+ roomyx now says what is missing and where to get it, and exits 1. **It does
45
+ not install Bun** — an install-time network fetch is what installer D-01
46
+ exists to refuse. Nothing is transpiled and `src/*.ts` is still the shipped
47
+ artifact. As a side effect, npm's generated Windows `.cmd` shim now has a
48
+ Node script to wrap rather than a `.ts` file.
49
+
50
+ - **One argument grammar, and a real `--help` for every command.** The CLI had
51
+ two hand-rolled argv scanners with different semantics and no notion of what
52
+ a flag *is*, so it could not tell a value from a positional, a typo from an
53
+ option, or a number from a switch. Measured against 0.4.0:
54
+
55
+ | | did |
56
+ | --- | --- |
57
+ | `serve --port 0 room.jsonl` | served a file literally named `--port`, on the default port |
58
+ | `serve --help` | **started a server** and minted a room ID |
59
+ | `serve room.jsonl --port` | listened on port 1, via `Number(true)` |
60
+ | `serve room.jsonl --port abc` | `NaN`, so a silent ephemeral port |
61
+ | `skills sync … --dryrun` | ignored the typo and did the opposite of the ask |
62
+ | `roomyx --help` | printed usage to stderr and exited 1 |
63
+ | `rooms list --registry X` | read the default registry and reported on it |
64
+
65
+ Flags are declared per command now. Unknown ones are refused with a
66
+ did-you-mean, missing and non-numeric values are refused, `--help` exits 0 on
67
+ stdout, a bad command exits 1 on stderr, and `--` ends flag parsing.
68
+
69
+ ### Removed — breaking
70
+
71
+ - **`roomyx.skills.sync` no longer accepts `targetPath`.** The MCP tool took a
72
+ literal path and passed it to the writer, which made it an arbitrary-path
73
+ file writer on an unauthenticated loopback port. Reproduced: a cross-origin
74
+ request wrote the bundled skill over a file of the caller's choosing, with
75
+ the directory created for it.
76
+
77
+ **If you were using it:** pass `target` instead — `claude`, `codex`, `keryx`
78
+ or `all`. If you were embedding `serveManagement()` and relied on a literal
79
+ path, note that `keryx` resolves project-locally and `ManagementOptions` now
80
+ takes a `cwd` to control what "project" means. The **CLI** keeps its
81
+ literal-path escape hatch (`roomyx skills sync --target /some/path`), because
82
+ that is the operator on their own machine. The network surface does not get
83
+ one.
84
+
85
+ ### Security
86
+
87
+ - **DNS-rebinding protection is on for both servers.** Before this, an
88
+ `initialize` carrying `Origin: https://evil.example` and
89
+ `Host: roomyx.attacker.test` completed the handshake and could call tools —
90
+ so any page in a tab the operator had open could reach `roomyx serve` and
91
+ `roomyx mcp` cross-origin. D-06 reasoned that loopback binding made the
92
+ threat local; it does not constrain a browser. Recorded as **D-06a**.
93
+
94
+ This is not authentication, and D-06's no-token decision stands. The guard
95
+ stops browsers. A local process sends no `Origin` and passes, which is the
96
+ trust boundary D-06 drew on purpose.
97
+
98
+ - **`@modelcontextprotocol/sdk` floor raised to `>=1.25.0`,** as part of the
99
+ guard rather than as dependency hygiene. Measured across thirty releases: the
100
+ guard appears in 1.13.3, but before 1.24.0 it rejects requests with no
101
+ `Origin` header — which is every request roomyx's own client and liveness
102
+ probe make. Option forwarding to this transport begins at 1.25.0. Leaving the
103
+ range at `^1.0.0` would have shipped a guard that silently does nothing on a
104
+ fresh install.
105
+
106
+ ### Fixed
107
+
108
+ - **The release job installs with `--frozen-lockfile`,** matching CI. It used to
109
+ resolve freely, so a release could ship a dependency version CI never tested —
110
+ with provenance attached to a tree nobody verified.
111
+
112
+ - **The release smoke test can now fail.** It ran
113
+ `roomyx --help > /dev/null 2>&1 || true`, discarding the output, the exit code
114
+ and then any remaining signal. It passed every release while `--help` was
115
+ exiting 1 — reporting success on a defect it was standing next to. It now
116
+ asserts that the packed, installed artifact runs `--help` with exit 0 and
117
+ reports a version equal to the tag. The second half is stricter than the
118
+ manifest check beside it: that one compares what the repository says, this
119
+ compares what the artifact says when it runs.
120
+
121
+ - **The management server closes its sessions on shutdown.** The HTTP transport
122
+ had been written twice and the copies had drifted; one of them skipped this.
123
+ Both servers now share `src/server/http-transport.ts` (**D-07**).
124
+
125
+ ### Changed
126
+
127
+ - `ManagementOptions` gains `cwd`, which is what project-scoped skill targets
128
+ resolve against. It defaults to `process.cwd()` — right for `roomyx mcp`,
129
+ wrong for a long-lived server embedded in a host whose working directory
130
+ belongs to someone else.
131
+
132
+ ## [0.4.0] — 2026-09-09
133
+
134
+ - Owner commands reach the TUI: `o` opens a prompt for veto / constraint /
135
+ add-participant / goal-edit. Against a room served by bare `roomyx serve` the
136
+ answer is an honest refusal — no dispatcher is attached, and accepting a
137
+ command nothing will act on would be a lie.
138
+ - The bundled `startup-room` skill is the real methodology with roomyx's steps
139
+ folded in, rather than a placeholder.
140
+ - `roomyx --version`.
141
+ - `docs/roomyx/testing-story.md`: a walkthrough where every command was run
142
+ against the packed build.
143
+
144
+ ## [0.3.0] — 2026-09-09
145
+
146
+ - `roomyx skills sync` on the CLI, with named targets (`claude`, `codex`,
147
+ `keryx`, `all`) resolving to each runtime's real skill location.
148
+ - `room.post_owner_command` on the server: it forwards to a dispatcher-supplied
149
+ handler and never writes to the log (**D-01**).
150
+ - The registry stores an absolute `logPath`. It always claimed to; the code
151
+ stored whatever argv held, so `roomyx serve ./room.jsonl` left a path
152
+ meaningless to a client started elsewhere.
153
+ - `roomyx client` and `roomyx mcp` subcommands.
154
+
155
+ ## [0.2.1] — 2026-09-09
156
+
157
+ - Stop crashing in a project that was never `roomyx init`-ed. `rooms list`
158
+ printed a bare `ENOENT` and `roomyx-client` printed a stack trace, both for
159
+ the ordinary case of "no room has been started here yet". `roomyx serve` was
160
+ worse: it bound its port and only then died registering itself.
161
+
162
+ ## [0.2.0] — 2026-09-09
163
+
164
+ - `roomyx-client` ships as a binary. The README had promised `roomyx client`
165
+ and a running server printed the same, but no such command existed — the TUI
166
+ was unreachable in 0.1.0.
167
+ - README documents the commands, both MCP servers' tools, the `.roomyx` layout
168
+ and the skill-sync refusals, and states that Bun must be on `PATH`.
169
+
170
+ ## [0.1.0] — 2026-09-09
171
+
172
+ First publish. MCP server over a room log, terminal UI, room registry with
173
+ liveness checking, skill-sync, and a management MCP server.
package/README.md CHANGED
@@ -7,18 +7,25 @@ run at once and be found by id, and a skill-sync path that installs the bundled
7
7
  `startup-room` skill into a project without ever silently overwriting local
8
8
  edits.
9
9
 
10
- roomyx never writes to a room log. Owner commands do exist —
11
- `room.post_owner_command` takes a veto, constraint, added participant or goal
12
- edit — but the tool only forwards them to the dispatcher that runs the room.
13
- The log keeps exactly one writer, which is what the room's consistency rests
10
+ **A live room has exactly one writer, and it is never roomyx's server.** Owner
11
+ commands exist — `room.post_owner_command` takes a veto, constraint, added
12
+ participant or goal edit — but the tool only forwards them to the dispatcher
13
+ running the room. That single-writer rule is what the room's consistency rests
14
14
  on.
15
15
 
16
+ `roomyx room new` and `roomyx room append` do write, and that is not an
17
+ exception to the rule: creating a log nobody serves takes the writer count from
18
+ zero to one, and `append` refuses outright when the registry shows a live room
19
+ serving that path. See D-01a.
20
+
16
21
  ## Requirements
17
22
 
18
- **[Bun](https://bun.sh) 1.1 or newer must be on your `PATH`.** Both binaries are
19
- shipped as TypeScript with a `#!/usr/bin/env bun` shebang and are executed by
20
- Bun directly — there is no compiled or transpiled build step. Installing with
21
- npm works fine, but the commands will not run on a machine that has only Node.
23
+ **[Bun](https://bun.sh) 1.1 or newer must be on your `PATH`.** roomyx ships
24
+ TypeScript and runs it directly — there is no build step, so Bun is the
25
+ interpreter rather than a build-time dependency.
26
+
27
+ Installing on a machine without Bun succeeds, and the commands then tell you so
28
+ and point at https://bun.sh. They will not install it for you.
22
29
 
23
30
  ## Install
24
31
 
@@ -32,14 +39,15 @@ bun install -g @mrciphersmith/roomyx
32
39
 
33
40
  ```bash
34
41
  cd your-project
35
- roomyx init # scaffold .roomyx/
36
- roomyx serve path/to/room.jsonl # serve one room log over MCP
42
+ roomyx init # scaffold .roomyx/
43
+ roomyx room new room.jsonl --goal "Pick a database" # create a room log
44
+ roomyx serve room.jsonl # serve it over MCP
37
45
  ```
38
46
 
39
47
  `serve` prints the room's URL and its generated id:
40
48
 
41
49
  ```
42
- roomyx serving path/to/room.jsonl at http://127.0.0.1:4319/mcp
50
+ roomyx serving /abs/path/room.jsonl at http://127.0.0.1:4319/mcp
43
51
  room ID: r-a1b2c3 — attach with `roomyx-client --room r-a1b2c3`
44
52
  ```
45
53
 
@@ -71,6 +79,24 @@ registry, and a staged copy of the bundled `startup-room` skill. It never
71
79
  clobbers a registry that already has rooms in it, and never overwrites an
72
80
  existing `config.json`.
73
81
 
82
+ ### `roomyx room new <path> [flags]` / `roomyx room append <path> [flags]`
83
+
84
+ Creates a room log, and appends messages to one.
85
+
86
+ | Flag | Meaning |
87
+ | --- | --- |
88
+ | `--goal <s>` | Required by `new`. A room without a stated goal has nothing to converge on. |
89
+ | `--criteria <s>` | The success criteria, stored in the goal contract. |
90
+ | `--roster id:Name,...` | Participants. `id` is what `room.get_agent_detail` takes. |
91
+ | `--from <id>` / `--body <s>` | Required by `append`. |
92
+ | `--kind <k>` / `--in-reply-to <n>` | Optional message structure. |
93
+ | `--force` | Append anyway when a live room is serving that log. |
94
+
95
+ `new` refuses to overwrite an existing log — it is append-only, and clobbering
96
+ one loses a session. `append` refuses when the registry shows a live room
97
+ serving that path, because that room's dispatcher is the log's single writer
98
+ (D-01a). `--force` is for when you know the room is gone.
99
+
74
100
  ### `roomyx serve <logPath> [flags]`
75
101
 
76
102
  Serves one room log as an MCP server over StreamableHTTP, and registers the room
@@ -165,7 +191,14 @@ and skill-sync — to any MCP client.
165
191
  | Tool | Input | Returns |
166
192
  | --- | --- | --- |
167
193
  | `roomyx.rooms.list` | — | Live, liveness-checked rooms. |
168
- | `roomyx.skills.sync` | `target?: claude \| codex \| keryx \| all` or `targetPath?: string`, `dryRun?: boolean`, `yes?: boolean` | One result per target: whether it would write, whether it did, and where the backup went. |
194
+ | `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. |
195
+
196
+ **Named targets only, deliberately.** This tool once accepted a literal
197
+ `targetPath`, which made it an arbitrary-path file writer on an unauthenticated
198
+ loopback port — a page in any browser tab could drive it cross-origin. The CLI
199
+ keeps its literal-path escape hatch, because that is the operator on their own
200
+ machine. The network surface does not get one. `keryx` resolves project-locally
201
+ against the server's `cwd` option, which defaults to the process's.
169
202
 
170
203
  Start it with `roomyx mcp` (default port `4320`, so it does not collide with
171
204
  `roomyx serve`'s `4319`). Same loopback / `--acknowledge-non-loopback` rules as
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrciphersmith/roomyx",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
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"
@@ -23,11 +23,12 @@
23
23
  "cli"
24
24
  ],
25
25
  "bin": {
26
- "roomyx": "./src/cli.ts",
27
- "roomyx-client": "./src/client/index.ts"
26
+ "roomyx": "./src/bin/roomyx.mjs",
27
+ "roomyx-client": "./src/bin/roomyx-client.mjs"
28
28
  },
29
29
  "files": [
30
30
  "src",
31
+ "CHANGELOG.md",
31
32
  "LICENSE",
32
33
  "README.md",
33
34
  "package.json"
@@ -39,7 +40,7 @@
39
40
  "check": "bun run lint && bun run typecheck && bun test"
40
41
  },
41
42
  "dependencies": {
42
- "@modelcontextprotocol/sdk": "^1.0.0",
43
+ "@modelcontextprotocol/sdk": "^1.25.0",
43
44
  "@opentui/core": "^0.5.11",
44
45
  "zod": "^4.5.4"
45
46
  },
@@ -0,0 +1,68 @@
1
+ import { spawn } from "node:child_process";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ /**
6
+ * The launcher that stands between npm's `bin` and roomyx's TypeScript.
7
+ *
8
+ * `bin` used to point straight at a `.ts` file with a `#!/usr/bin/env bun`
9
+ * shebang. On a machine without Bun that fails as
10
+ * `/usr/bin/env: 'bun': No such file or directory` — not one byte of it from
11
+ * roomyx, and there is no way to make it so: a shebang is an `execve` dispatch
12
+ * handled by the kernel, with no slot for a diagnostic and no fallback. When
13
+ * the interpreter is not guaranteed present, the `bin` entry has to be a
14
+ * launcher rather than the program. Node is guaranteed present; npm just ran.
15
+ *
16
+ * `package.json`'s `engines.bun` does not help. npm's engine check only ever
17
+ * knew `node` and `npm` — a package declaring `bun: ">=99.0.0"` installs
18
+ * cleanly under `--engine-strict`. It is a comment that looks like a
19
+ * constraint.
20
+ *
21
+ * This does not transpile anything, and `src/*.ts` remains the shipped
22
+ * artifact. **It also never fetches, installs or bootstraps Bun.** Making an
23
+ * error message nicer by downloading a runtime at first use would reintroduce
24
+ * exactly the install-time network fetch that installer D-01 exists to refuse.
25
+ */
26
+
27
+ const MISSING_BUN = `roomyx needs Bun 1.1+ on your PATH.
28
+
29
+ It ships TypeScript and runs it directly — there is no build step, so Bun is
30
+ the interpreter rather than a build-time dependency.
31
+
32
+ Install: curl -fsSL https://bun.sh/install | bash
33
+ Docs: https://bun.sh
34
+ `;
35
+
36
+ /**
37
+ * @param {string} entryRelativeToBin - the TypeScript entry point, e.g. "../cli.ts"
38
+ */
39
+ export function launch(entryRelativeToBin) {
40
+ const entry = join(dirname(fileURLToPath(import.meta.url)), entryRelativeToBin);
41
+ const child = spawn("bun", [entry, ...process.argv.slice(2)], { stdio: "inherit" });
42
+
43
+ // Forwarded rather than relied upon. `roomyx serve` deregisters its room on
44
+ // SIGTERM, and a launcher that swallowed the signal would leave a registry
45
+ // entry pointing at a process that is gone — the failure this package
46
+ // already had once, from the other direction.
47
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
48
+ process.on(signal, () => child.kill(signal));
49
+ }
50
+
51
+ child.on("error", (error) => {
52
+ if (error.code === "ENOENT") {
53
+ process.stderr.write(MISSING_BUN);
54
+ process.exit(1);
55
+ }
56
+ throw error;
57
+ });
58
+
59
+ child.on("exit", (code, signal) => {
60
+ if (signal) {
61
+ // Report death-by-signal the way a shell expects, rather than
62
+ // flattening it into an exit code the caller cannot distinguish.
63
+ process.kill(process.pid, signal);
64
+ return;
65
+ }
66
+ process.exit(code ?? 1);
67
+ });
68
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import { launch } from "./launch.mjs";
3
+
4
+ // The TUI's own entry, not `cli.ts client`. `client/index.ts` decides whether
5
+ // it was run directly via `import.meta.main`, and `cli.ts`'s `client`
6
+ // subcommand depends on that being false when it does `await import()`. A
7
+ // launcher pointed at the wrong one would run the client twice.
8
+ launch("../client/index.ts");
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { launch } from "./launch.mjs";
3
+
4
+ launch("../cli.ts");
@@ -0,0 +1,155 @@
1
+ /**
2
+ * One argument grammar for the whole CLI.
3
+ *
4
+ * There were two hand-rolled scanners with different semantics, and between
5
+ * them they produced this, measured against the published 0.4.0:
6
+ *
7
+ * roomyx serve --port 0 room.jsonl → served a file literally named "--port"
8
+ * roomyx serve --help → STARTED A SERVER
9
+ * roomyx serve room.jsonl --port → port 1, because Number(true) === 1
10
+ * roomyx serve room.jsonl --port abc → NaN, so a silent ephemeral port
11
+ * roomyx skills sync --dryrun → unknown flag, silently ignored
12
+ * roomyx --help → usage on stderr, exit 1
13
+ *
14
+ * Every one of those is the same defect: a scanner that never decided what a
15
+ * flag *is*, so it could not tell a value from a positional, a typo from an
16
+ * option, or a number from a boolean. Declaring the flags fixes the whole
17
+ * class, which is why this is a spec-driven parser rather than six patches.
18
+ *
19
+ * It matters beyond tidiness because an agent is a first-class user of this
20
+ * CLI, and the first thing an agent does with an unknown command is ask for
21
+ * `--help`.
22
+ */
23
+
24
+ export type FlagType = "string" | "number" | "boolean";
25
+
26
+ export interface FlagSpec {
27
+ type: FlagType;
28
+ describe: string;
29
+ }
30
+
31
+ export type FlagSpecs = Record<string, FlagSpec>;
32
+
33
+ export type FlagValues = Record<string, string | number | boolean>;
34
+
35
+ export interface ParsedArgs {
36
+ positionals: string[];
37
+ flags: FlagValues;
38
+ /** True when `--help`/`-h` appeared. Callers print help and exit 0. */
39
+ help: boolean;
40
+ }
41
+
42
+ /** Thrown for anything the caller should report and exit 1 on. */
43
+ export class ArgError extends Error {}
44
+
45
+ /** Levenshtein, for "unknown flag --dryrun; did you mean --dry-run?". */
46
+ function distance(a: string, b: string): number {
47
+ const rows = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array<number>(b.length).fill(0)]);
48
+ for (let j = 0; j <= b.length; j++) rows[0]![j] = j;
49
+ for (let i = 1; i <= a.length; i++) {
50
+ for (let j = 1; j <= b.length; j++) {
51
+ const substitution = rows[i - 1]![j - 1]! + (a[i - 1] === b[j - 1] ? 0 : 1);
52
+ rows[i]![j] = Math.min(rows[i - 1]![j]! + 1, rows[i]![j - 1]! + 1, substitution);
53
+ }
54
+ }
55
+ return rows[a.length]![b.length]!;
56
+ }
57
+
58
+ function suggest(unknown: string, known: string[]): string | undefined {
59
+ let best: { name: string; d: number } | undefined;
60
+ for (const name of known) {
61
+ const d = distance(unknown, name);
62
+ if (!best || d < best.d) best = { name, d };
63
+ }
64
+ // Two edits is close enough to be a typo and far enough not to be noise.
65
+ return best && best.d <= 2 ? best.name : undefined;
66
+ }
67
+
68
+ export function parseArgs(argv: string[], specs: FlagSpecs): ParsedArgs {
69
+ const positionals: string[] = [];
70
+ const flags: FlagValues = {};
71
+ const known = Object.keys(specs);
72
+ let help = false;
73
+ let sawTerminator = false;
74
+
75
+ for (let i = 0; i < argv.length; i++) {
76
+ const arg = argv[i] as string;
77
+
78
+ if (sawTerminator || !arg.startsWith("--")) {
79
+ if (arg === "-h" && !sawTerminator) {
80
+ help = true;
81
+ continue;
82
+ }
83
+ positionals.push(arg);
84
+ continue;
85
+ }
86
+
87
+ if (arg === "--") {
88
+ sawTerminator = true;
89
+ continue;
90
+ }
91
+
92
+ const eq = arg.indexOf("=");
93
+ const name = (eq === -1 ? arg.slice(2) : arg.slice(2, eq)).trim();
94
+ const inlineValue = eq === -1 ? undefined : arg.slice(eq + 1);
95
+
96
+ if (name === "help") {
97
+ help = true;
98
+ continue;
99
+ }
100
+
101
+ const spec = specs[name];
102
+ if (!spec) {
103
+ const hint = suggest(name, known);
104
+ throw new ArgError(
105
+ `Unknown flag --${name}${hint ? `. Did you mean --${hint}?` : "."}` +
106
+ (known.length > 0 ? `\nKnown flags: ${known.map((f) => `--${f}`).join(", ")}` : ""),
107
+ );
108
+ }
109
+
110
+ if (spec.type === "boolean") {
111
+ if (inlineValue !== undefined && inlineValue !== "true" && inlineValue !== "false") {
112
+ throw new ArgError(`--${name} is a switch and takes no value (got "${inlineValue}").`);
113
+ }
114
+ flags[name] = inlineValue !== "false";
115
+ continue;
116
+ }
117
+
118
+ // A value is required, and the next argv entry is only a value if it does
119
+ // not look like a flag. `--port --host x` must fail rather than quietly
120
+ // read `--host` as the port.
121
+ let raw = inlineValue;
122
+ if (raw === undefined) {
123
+ const next = argv[i + 1];
124
+ if (next === undefined || next.startsWith("--")) {
125
+ throw new ArgError(`--${name} needs a value.`);
126
+ }
127
+ raw = next;
128
+ i++;
129
+ }
130
+ if (raw === "") {
131
+ throw new ArgError(`--${name} needs a value.`);
132
+ }
133
+
134
+ if (spec.type === "number") {
135
+ const value = Number(raw);
136
+ if (!Number.isFinite(value)) {
137
+ throw new ArgError(`--${name} needs a number (got "${raw}").`);
138
+ }
139
+ flags[name] = value;
140
+ continue;
141
+ }
142
+
143
+ flags[name] = raw;
144
+ }
145
+
146
+ return { positionals, flags, help };
147
+ }
148
+
149
+ /** Renders a spec as the flag table a `--help` prints. */
150
+ export function renderFlags(specs: FlagSpecs): string {
151
+ const names = Object.keys(specs);
152
+ if (names.length === 0) return "";
153
+ const width = Math.max(...names.map((n) => n.length));
154
+ return names.map((n) => ` --${n.padEnd(width)} ${specs[n]!.describe}`).join("\n");
155
+ }
@@ -0,0 +1,16 @@
1
+ import type { FlagSpecs } from "./args";
2
+
3
+ /**
4
+ * The client's flags, in one place because two entry points take them: the
5
+ * `roomyx-client` binary and `roomyx client`. They were two hand-rolled
6
+ * scanners with different semantics, which is how a bare `--registry` came to
7
+ * resolve to the empty string in one of them and to `true` in the other.
8
+ *
9
+ * This module deliberately imports nothing but a type, so `roomyx --version`
10
+ * does not pay for loading the TUI renderer.
11
+ */
12
+ export const CLIENT_FLAGS: FlagSpecs = {
13
+ room: { type: "string", describe: "Attach to a specific live room by id" },
14
+ connect: { type: "string", describe: "Attach to an explicit MCP URL; the registry is not consulted" },
15
+ registry: { type: "string", describe: "Registry file (default .roomyx/rooms/registry.json)" },
16
+ };