@mrciphersmith/roomyx 0.3.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 +173 -0
- package/README.md +53 -13
- package/package.json +5 -4
- package/src/bin/launch.mjs +68 -0
- package/src/bin/roomyx-client.mjs +8 -0
- package/src/bin/roomyx.mjs +4 -0
- package/src/bundled-skills/startup-room/SKILL.md +177 -47
- package/src/cli/args.ts +155 -0
- package/src/cli/specs.ts +16 -0
- package/src/cli.ts +313 -150
- package/src/client/components/status-bar.ts +12 -0
- package/src/client/index.ts +78 -24
- package/src/client/mcp-client.ts +9 -0
- package/src/client/owner-prompt.ts +92 -0
- package/src/log/write.ts +80 -0
- package/src/mcp-management/server.ts +38 -97
- package/src/server/http-transport.ts +149 -0
- package/src/server/serve.ts +13 -86
- package/src/cli/seed.ts +0 -73
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
|
-
|
|
11
|
-
`room.post_owner_command` takes a veto, constraint, added
|
|
12
|
-
edit — but the tool only forwards them to the dispatcher
|
|
13
|
-
|
|
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`.**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
36
|
-
roomyx
|
|
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/
|
|
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
|
|
|
@@ -51,7 +59,10 @@ roomyx-client --room r-a1b2c3
|
|
|
51
59
|
```
|
|
52
60
|
|
|
53
61
|
In the TUI: `↑`/`↓` move through the roster, `Enter` opens the selected agent's
|
|
54
|
-
modal, `Esc` closes it, `q` or `Ctrl-C` quits.
|
|
62
|
+
modal, `Esc` closes it, `q` or `Ctrl-C` quits. `o` opens an owner command —
|
|
63
|
+
pick `v`eto, `c`onstraint, `a`dd participant or `g`oal edit, type the body,
|
|
64
|
+
`Enter` sends. While the prompt is open it owns the keyboard, so a `q` in a
|
|
65
|
+
veto is text rather than a quit.
|
|
55
66
|
|
|
56
67
|
## Commands
|
|
57
68
|
|
|
@@ -68,6 +79,24 @@ registry, and a staged copy of the bundled `startup-room` skill. It never
|
|
|
68
79
|
clobbers a registry that already has rooms in it, and never overwrites an
|
|
69
80
|
existing `config.json`.
|
|
70
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
|
+
|
|
71
100
|
### `roomyx serve <logPath> [flags]`
|
|
72
101
|
|
|
73
102
|
Serves one room log as an MCP server over StreamableHTTP, and registers the room
|
|
@@ -162,7 +191,14 @@ and skill-sync — to any MCP client.
|
|
|
162
191
|
| Tool | Input | Returns |
|
|
163
192
|
| --- | --- | --- |
|
|
164
193
|
| `roomyx.rooms.list` | — | Live, liveness-checked rooms. |
|
|
165
|
-
| `roomyx.skills.sync` | `target
|
|
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.
|
|
166
202
|
|
|
167
203
|
Start it with `roomyx mcp` (default port `4320`, so it does not collide with
|
|
168
204
|
`roomyx serve`'s `4319`). Same loopback / `--acknowledge-non-loopback` rules as
|
|
@@ -249,6 +285,10 @@ provenance via trusted publishing.
|
|
|
249
285
|
|
|
250
286
|
## Further reading
|
|
251
287
|
|
|
288
|
+
- [`docs/roomyx/testing-story.md`](https://github.com/MrCipherSmith/roomyx/blob/main/docs/roomyx/testing-story.md)
|
|
289
|
+
— a verified end-to-end walkthrough, from `npm install` to driving a live
|
|
290
|
+
room, including what keryx shell can and cannot do with roomyx.
|
|
291
|
+
|
|
252
292
|
Full architecture and the reasoning behind each decision:
|
|
253
293
|
|
|
254
294
|
- [`docs/roomyx/specification.md`](https://github.com/MrCipherSmith/roomyx/blob/main/docs/roomyx/specification.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrciphersmith/roomyx",
|
|
3
|
-
"version": "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/
|
|
27
|
-
"roomyx-client": "./src/client
|
|
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.
|
|
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");
|