@mrciphersmith/roomyx 0.6.3 → 0.7.1
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 +81 -0
- package/README.md +60 -8
- package/package.json +1 -1
- package/src/bundled-skills/startup-room/SKILL.md +42 -4
- package/src/cli.ts +91 -18
- package/src/client/init-screen.ts +66 -0
- package/src/client/screens/init-picker.ts +198 -0
- package/src/installer/init-apply.ts +142 -0
- package/src/installer/init-plan.ts +148 -0
- package/src/installer/skill-targets.ts +105 -35
- package/src/log/store.ts +13 -1
- package/src/mcp-management/server.ts +3 -1
- package/src/server/serve.ts +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,87 @@ 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
|
+
## [0.7.1] — 2026-09-10
|
|
17
|
+
|
|
18
|
+
A patch. Found while writing setup prompts for an operator: following the
|
|
19
|
+
bundled skill produced a room that could not be attached to, and nothing said
|
|
20
|
+
why.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- **`roomyx serve` refuses a log it cannot read, instead of becoming an
|
|
25
|
+
invisible room.** It used to bind a port, print a room ID and an attach
|
|
26
|
+
command, and only then fail on every tool call. Because the liveness probe
|
|
27
|
+
reads a throwing `room.get_state` as "not this room", `roomyx rooms list`
|
|
28
|
+
answered **"No live rooms"** about a server that was running, and the client
|
|
29
|
+
refused to attach to the id it had just been handed. The log is now read once
|
|
30
|
+
before anything is bound, so the failure is a sentence naming the file and the
|
|
31
|
+
line.
|
|
32
|
+
- **A missing log is a sentence, not a stack trace.** `roomyx serve nope.jsonl`
|
|
33
|
+
printed a raw `ENOENT` with a stack. It now says what is missing and the one
|
|
34
|
+
command that creates it — a typo'd path being the most ordinary way to get
|
|
35
|
+
there.
|
|
36
|
+
- **The bundled `startup-room` skill told dispatchers to keep the transcript in
|
|
37
|
+
markdown, which roomyx cannot read.** The section that added roomyx was
|
|
38
|
+
written without reconciling the format, so an agent following the skill
|
|
39
|
+
produced a `.md` log and a room that would not serve. It now creates the log
|
|
40
|
+
with `roomyx room new` (JSONL) and appends with `roomyx room append --force`,
|
|
41
|
+
and says why `--force` is right there: the dispatcher *is* the single writer
|
|
42
|
+
the guard exists to protect, and roomyx cannot tell that from outside. The
|
|
43
|
+
markdown convention remains, for when roomyx is not available.
|
|
44
|
+
- The skill also now tells the dispatcher to mention `roomyx rooms history` and
|
|
45
|
+
`roomyx-client --archive` when a room ends, so the owner knows a closed room
|
|
46
|
+
can still be reread.
|
|
47
|
+
|
|
48
|
+
## [0.7.0] — 2026-09-10
|
|
49
|
+
|
|
50
|
+
A minor, because two things an existing caller relied on changed. The feature is
|
|
51
|
+
that `roomyx init` now finishes the job instead of leaving you a staged file no
|
|
52
|
+
runtime reads.
|
|
53
|
+
|
|
54
|
+
### Changed — breaking
|
|
55
|
+
|
|
56
|
+
- **`roomyx skills sync --target all` now writes nine files, not three.** The
|
|
57
|
+
runtime table grew: Cursor and Grok were added, and every one of the four
|
|
58
|
+
agents now has a project-scoped location as well as a user-scoped one. `all`
|
|
59
|
+
genuinely means all, so a caller who typed it before now reaches more places.
|
|
60
|
+
If you wanted the old set, name them: `--target claude`, `--target codex`,
|
|
61
|
+
`--target keryx`.
|
|
62
|
+
- **`roomyx init` is interactive on a terminal.** It used to scaffold `.roomyx/`
|
|
63
|
+
and exit. It still does exactly that through a pipe, in CI, or with
|
|
64
|
+
`--no-interactive` — so nothing scripted changes — but on a terminal it now
|
|
65
|
+
shows what it can do and waits for you to pick.
|
|
66
|
+
|
|
67
|
+
### Added
|
|
68
|
+
|
|
69
|
+
- **An init picker.** Skill targets for Claude Code, Codex, Cursor, Grok and
|
|
70
|
+
keryx, at both scopes, each showing the exact path it would write. Arrows or
|
|
71
|
+
`j`/`k` move, Space ticks, Enter installs, `q` cancels. Nothing is written
|
|
72
|
+
until you submit. Boxes start ticked only where the answer is not in doubt —
|
|
73
|
+
a runtime whose directory exists on this machine, a project that already uses
|
|
74
|
+
that runtime — because a default tick must never surprise you with a file.
|
|
75
|
+
- **Three more things init offers**, all opt-out in the same list: the room-log
|
|
76
|
+
directory `config.json` has named since the first release and nothing ever
|
|
77
|
+
created; `.gitignore` lines for the registry and lockfiles (the room logs are
|
|
78
|
+
deliberately *not* ignored — the transcript is the point); and registration of
|
|
79
|
+
the roomyx MCP server in `.mcp.json` and `.cursor/mcp.json`.
|
|
80
|
+
- **`roomyx mcp --stdio`.** The transport an MCP client actually spawns. This is
|
|
81
|
+
what init registers: an HTTP URL would name a port nothing is listening on
|
|
82
|
+
until you remember to start a server, so the registration would be broken by
|
|
83
|
+
default. Over stdio the client owns the lifetime and there is no port.
|
|
84
|
+
|
|
85
|
+
### Fixed
|
|
86
|
+
|
|
87
|
+
- **`roomyx init` no longer leaves you with a skill nothing can see.** The
|
|
88
|
+
staged copy under `.roomyx/skills/` is not a directory any runtime scans, and
|
|
89
|
+
installing was a separate command nothing pointed at. Reported from a real
|
|
90
|
+
install: package installed, `init` run, agent still blind.
|
|
91
|
+
- Two list-rendering defects found by the tests while writing them, both
|
|
92
|
+
width-dependent: the label column pushed the "replaces" warning off a
|
|
93
|
+
40-column pane, so a row about to overwrite a file read like a fresh install;
|
|
94
|
+
and a plan taller than the terminal drew the hint line through the bottom
|
|
95
|
+
border.
|
|
96
|
+
|
|
16
97
|
## [0.6.3] — 2026-09-10
|
|
17
98
|
|
|
18
99
|
A patch: closed rooms are now remembered and can be reread. Purely additive —
|
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ bun install -g @mrciphersmith/roomyx
|
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
41
|
cd your-project
|
|
42
|
-
roomyx init # scaffold
|
|
42
|
+
roomyx init # scaffold, then pick what to install
|
|
43
43
|
roomyx room new room.jsonl --goal "Pick a database" # create a room log
|
|
44
44
|
roomyx serve room.jsonl # serve it over MCP
|
|
45
45
|
```
|
|
@@ -107,12 +107,50 @@ nothing to the room. `roomyx client`, with a space, starts that same TUI from
|
|
|
107
107
|
the single `roomyx` binary; it is an alias for convenience, not a second
|
|
108
108
|
implementation, and it does not tie the TUI's lifetime to anything.
|
|
109
109
|
|
|
110
|
-
### `roomyx init`
|
|
110
|
+
### `roomyx init [flags]`
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
Sets the project up. On a terminal it shows what it can do and waits for you to
|
|
113
|
+
pick; nothing is written until you submit.
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
┌─ roomyx init — pick what to set up ──────────────────────────────┐
|
|
117
|
+
│Skill — every project on this machine │
|
|
118
|
+
│ [x] Claude Code replaces /home/you/.claude/skills/startup-… │
|
|
119
|
+
│ [ ] Cursor /home/you/.cursor/skills/startup-room/SKILL… │
|
|
120
|
+
│ │
|
|
121
|
+
│Skill — this project only (travels with the repo) │
|
|
122
|
+
│ [x] Claude Code /home/you/proj/.claude/skills/startup-room/… │
|
|
123
|
+
│ │
|
|
124
|
+
│Also │
|
|
125
|
+
│ [x] Room-log directory /home/you/proj/.roomyx/rooms/lo… │
|
|
126
|
+
│ [x] Ignore registry, lockfiles /home/you/proj/.gitignore │
|
|
127
|
+
│ [x] MCP server for Claude Code /home/you/proj/.mcp.json │
|
|
128
|
+
│ [ Install ] ↵ │
|
|
129
|
+
│ ↑/↓ or j/k move · Space toggles · Enter installs · q cancels │
|
|
130
|
+
└──────────────────────────────────────────────────────────────────┘
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Always, first: `.roomyx/` with `config.json`, an empty room registry, and a
|
|
134
|
+
staged copy of the bundled skill. It never clobbers a registry that already has
|
|
135
|
+
rooms in it, and never overwrites an existing `config.json`.
|
|
136
|
+
|
|
137
|
+
Then, whatever you tick — the skill installed where your agents actually read
|
|
138
|
+
it, the room-log directory, `.gitignore` lines for the machine-local state (not
|
|
139
|
+
for the logs), and the MCP server registered over stdio.
|
|
140
|
+
|
|
141
|
+
| Flag | Meaning |
|
|
142
|
+
| --- | --- |
|
|
143
|
+
| `--yes` | Apply the default selection without asking. |
|
|
144
|
+
| `--no-interactive` | Scaffold `.roomyx/` only. |
|
|
145
|
+
|
|
146
|
+
**Through a pipe or in CI it never prompts** — it scaffolds and exits, printing
|
|
147
|
+
what to run next. A prompt nobody is there to answer is a hang, and a hung
|
|
148
|
+
installer is worse than one that did nothing.
|
|
149
|
+
|
|
150
|
+
Boxes start ticked only where the answer is not in doubt: a runtime whose
|
|
151
|
+
directory exists on this machine, a project that already uses that runtime, the
|
|
152
|
+
log directory the config has always named. A default tick must never surprise
|
|
153
|
+
you with a file — one in `~/.cursor` on a machine without Cursor would.
|
|
116
154
|
|
|
117
155
|
### `roomyx room new <path> [flags]` / `roomyx room append <path> [flags]`
|
|
118
156
|
|
|
@@ -179,18 +217,32 @@ signal no handler runs for — when `roomyx rooms list` next finds it gone.
|
|
|
179
217
|
Starts the management MCP server (room listing + skill-sync). Default port
|
|
180
218
|
`4320`. See **Management server** below for tools and flags.
|
|
181
219
|
|
|
182
|
-
|
|
220
|
+
`--stdio` speaks MCP over stdin/stdout instead, which is what an MCP client
|
|
221
|
+
spawns and what `roomyx init` registers. Over stdio there is no port and nothing
|
|
222
|
+
left running: the client owns the process. Nothing is printed to stdout in that
|
|
223
|
+
mode — stdout is the protocol channel.
|
|
224
|
+
|
|
225
|
+
### `roomyx skills sync --target <runtime|all|path> [flags]`
|
|
183
226
|
|
|
184
227
|
Installs the bundled `startup-room` skill into a runtime's skill location.
|
|
228
|
+
`roomyx init` does this for you with a picker; this is the same thing for a
|
|
229
|
+
script.
|
|
185
230
|
|
|
186
231
|
| Target | Path |
|
|
187
232
|
| --- | --- |
|
|
188
233
|
| `claude` | `~/.claude/skills/startup-room/SKILL.md` |
|
|
189
234
|
| `codex` | `~/.codex/skills/startup-room/SKILL.md` |
|
|
235
|
+
| `cursor` | `~/.cursor/skills/startup-room/SKILL.md` |
|
|
236
|
+
| `grok` | `~/.grok/skills/startup-room/SKILL.md` |
|
|
237
|
+
| `claude-project` … `grok-project` | the same, under `<cwd>/` instead of `~/` |
|
|
190
238
|
| `keryx` | `<cwd>/.metaproject/project-skills/startup-room/SKILL.md` |
|
|
191
|
-
| `all` |
|
|
239
|
+
| `all` | every row above |
|
|
192
240
|
| anything else | taken as a literal path |
|
|
193
241
|
|
|
242
|
+
Project-scoped locations rank **higher** than user-scoped ones in every one of
|
|
243
|
+
these runtimes, and they travel with the repository — which is usually what a
|
|
244
|
+
team wants.
|
|
245
|
+
|
|
194
246
|
| Flag | Default | Meaning |
|
|
195
247
|
| --- | --- | --- |
|
|
196
248
|
| `--yes` | off | Actually write. **Without it nothing is written** — the run reports what it would do and stops. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrciphersmith/roomyx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
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"
|
|
@@ -103,7 +103,7 @@ When the owner says "save this idea" (or a candidate clearly survives enough rou
|
|
|
103
103
|
|
|
104
104
|
1. Identify the persona profile files to use (e.g. `arena/roles/**/*.md` or a subset). Each profile should already be a neutral biography/expertise sheet — no pre-baked opinions or conclusions (see the project's persona-writing convention if one exists).
|
|
105
105
|
2. Write the **goal contract** (see above): goal statement, success criteria (default to the 50-criteria rubric for a startup-idea room), and the convergence requirement.
|
|
106
|
-
3. Create the log file with a header: the goal contract in full (not just a one-line goal — include the criteria/threshold so anyone reading the log later can check whether it was actually met), list of participants (name + one-line role), and the ground rule that only the moderator writes to it.
|
|
106
|
+
3. Create the log. **If roomyx is available, create it with `roomyx room new` (JSONL) — see below.** Otherwise create a markdown file with a header: the goal contract in full (not just a one-line goal — include the criteria/threshold so anyone reading the log later can check whether it was actually met), list of participants (name + one-line role), and the ground rule that only the moderator writes to it.
|
|
107
107
|
4. Decide the opening framing. If the task is "find something from scratch," say so explicitly and do NOT hand participants a pre-built brief that narrows their options — that biases the room before it starts. The criteria are the bar the eventual candidate must clear, not a hint about what kind of idea to look for.
|
|
108
108
|
5. If roomyx is available for this project — a `.roomyx/` directory exists, or `roomyx` resolves on `PATH` — start a server for the log so the owner can watch the room live. See **Watching the room live (roomyx)** below. If it isn't available, skip this step and run the session exactly as you would otherwise; nothing here depends on it.
|
|
109
109
|
|
|
@@ -114,20 +114,54 @@ turns it into something they can watch while it runs, without changing how the
|
|
|
114
114
|
room works: it reads the log and serves it, and it never writes to it. The
|
|
115
115
|
dispatcher stays the log's single writer.
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
**The log must be roomyx's own format, not the markdown transcript.** roomyx
|
|
118
|
+
reads JSONL: one `state` header line, then one JSON line per message. A markdown
|
|
119
|
+
file is not readable by it, so create the log with `roomyx room new` and append
|
|
120
|
+
through `roomyx room append` — those two commands are the whole of it, and the
|
|
121
|
+
dispatcher is still the single writer. Use the markdown convention described
|
|
122
|
+
above only when roomyx is *not* available.
|
|
123
|
+
|
|
124
|
+
Create the room and start the server as part of setup, before the kickoff
|
|
125
|
+
spawns:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
roomyx room new .roomyx/rooms/logs/<topic>.jsonl \
|
|
129
|
+
--goal "<the goal statement>" \
|
|
130
|
+
--criteria "<the threshold, in one line>" \
|
|
131
|
+
--roster "ann:Ann,ben:Ben,cara:Cara"
|
|
132
|
+
|
|
133
|
+
roomyx serve .roomyx/rooms/logs/<topic>.jsonl --port 0
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Then append each participant's turn verbatim as it arrives:
|
|
118
137
|
|
|
119
138
|
```bash
|
|
120
|
-
roomyx
|
|
139
|
+
roomyx room append .roomyx/rooms/logs/<topic>.jsonl --force \
|
|
140
|
+
--from ann --kind pitch --body "<their actual words>"
|
|
121
141
|
```
|
|
122
142
|
|
|
143
|
+
**`--force` is required here, and it is correct here.** Without it, `append`
|
|
144
|
+
refuses whenever a live room is serving that log — a guard against a *second*
|
|
145
|
+
writer racing the dispatcher. You are the dispatcher: the single writer the
|
|
146
|
+
guard exists to protect. roomyx cannot tell the two apart from outside, so it
|
|
147
|
+
asks, and this is the case where the answer is yes.
|
|
148
|
+
|
|
149
|
+
`--kind` is one of `pitch`, `question`, `challenge`, `answer`, `vote`, `status`,
|
|
150
|
+
`research`; `--in-reply-to <seq>` records who was being answered. Both are
|
|
151
|
+
optional and both make the transcript far easier to read later.
|
|
152
|
+
|
|
123
153
|
`--port 0` takes an ephemeral port, so several rooms can run at once without
|
|
124
154
|
colliding. It prints the bound URL and a short room ID:
|
|
125
155
|
|
|
126
156
|
```
|
|
127
|
-
roomyx serving /abs/path/room.
|
|
157
|
+
roomyx serving /abs/path/room.jsonl at http://127.0.0.1:41235/mcp
|
|
128
158
|
room ID: r-a1b2c3 — attach with `roomyx-client --room r-a1b2c3`
|
|
129
159
|
```
|
|
130
160
|
|
|
161
|
+
If `serve` refuses instead, read what it says: it now reads the log before
|
|
162
|
+
binding anything, so "must start with a valid state line" means the file is not
|
|
163
|
+
a roomyx log — most likely a markdown transcript. Create it with `room new`.
|
|
164
|
+
|
|
131
165
|
**Relay that room ID to the owner in the kickoff confirmation, with the attach
|
|
132
166
|
command.** That is the whole point of starting it — the owner opens the room in
|
|
133
167
|
a second terminal and watches the discussion as it happens instead of waiting
|
|
@@ -141,6 +175,10 @@ Stop the server with `SIGINT`/`SIGTERM` when the room ends — it removes its ow
|
|
|
141
175
|
registry entry on the way out. A server killed outright leaves a stale entry,
|
|
142
176
|
which is harmless: the next `rooms list` prunes it after a liveness check.
|
|
143
177
|
|
|
178
|
+
A closed room is not lost. It is recorded in `roomyx rooms history`, and the
|
|
179
|
+
owner can reread it at any time with `roomyx-client --archive`, so tell them the
|
|
180
|
+
room is in the history when you finish.
|
|
181
|
+
|
|
144
182
|
## Kickoff (spawn once per persona)
|
|
145
183
|
|
|
146
184
|
Spawn each participant as a separate `Agent` call (`subagent_type: general-purpose`, tools available as needed — allow `WebSearch`/`WebFetch` if the room is expected to ground claims in reality, not just riff). The kickoff prompt for each must include:
|
package/src/cli.ts
CHANGED
|
@@ -72,12 +72,66 @@ interface Command {
|
|
|
72
72
|
|
|
73
73
|
const COMMANDS: Record<string, Command> = {
|
|
74
74
|
init: {
|
|
75
|
-
usage: "roomyx init",
|
|
76
|
-
summary: "scaffold .roomyx
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
usage: "roomyx init [flags]",
|
|
76
|
+
summary: "scaffold .roomyx/, then set up skills, MCP and git for this project",
|
|
77
|
+
notes:
|
|
78
|
+
"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.",
|
|
79
|
+
flags: {
|
|
80
|
+
yes: { type: "boolean", describe: "Apply the default selection without asking" },
|
|
81
|
+
"no-interactive": { type: "boolean", describe: "Scaffold .roomyx/ only" },
|
|
82
|
+
},
|
|
83
|
+
run: async ({ flags }) => {
|
|
84
|
+
const cwd = process.cwd();
|
|
85
|
+
const result = init({ cwd, bundledSkillPath: bundledSkillPath() });
|
|
80
86
|
console.log(result.created ? `Created ${result.roomyxDir}` : `${result.roomyxDir} already initialized`);
|
|
87
|
+
|
|
88
|
+
const { buildPlan, selectedItems } = await import("./installer/init-plan");
|
|
89
|
+
const { applyPlan } = await import("./installer/init-apply");
|
|
90
|
+
|
|
91
|
+
const plan = buildPlan({ cwd });
|
|
92
|
+
// A terminal on both ends or nothing to ask. `--yes` overrides, because
|
|
93
|
+
// a script that has decided already should not be refused for lacking a
|
|
94
|
+
// tty — but the default must never block a pipeline on a prompt.
|
|
95
|
+
const interactive = process.stdout.isTTY === true && process.stdin.isTTY === true;
|
|
96
|
+
if (flags["no-interactive"] === true || (!interactive && flags.yes !== true)) {
|
|
97
|
+
console.log("");
|
|
98
|
+
console.log("Nothing else was written. To install the skill and register the MCP server:");
|
|
99
|
+
console.log(" roomyx init --yes # the default selection, no prompt");
|
|
100
|
+
console.log(" roomyx init # pick, in a terminal");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let chosen = plan;
|
|
105
|
+
if (flags.yes !== true) {
|
|
106
|
+
const { runInitPicker } = await import("./client/init-screen");
|
|
107
|
+
const picked = await runInitPicker(plan);
|
|
108
|
+
if (picked === null) {
|
|
109
|
+
console.log("Cancelled — nothing else was written.");
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
chosen = picked;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const results = applyPlan(selectedItems(chosen), {
|
|
116
|
+
cwd,
|
|
117
|
+
bundledSkillPath: bundledSkillPath(),
|
|
118
|
+
configPath: join(cwd, ".roomyx", "config.json"),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
console.log("");
|
|
122
|
+
for (const line of results) {
|
|
123
|
+
console.log(`${line.ok ? " ok " : " !! "} ${line.label}`);
|
|
124
|
+
console.log(` ${line.path} — ${line.message}`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const failed = results.filter((line) => !line.ok).length;
|
|
128
|
+
if (failed > 0) console.log(`\n${failed} item(s) failed. Everything else was applied.`);
|
|
129
|
+
if (results.some((line) => line.ok && line.id.startsWith("skill:"))) {
|
|
130
|
+
// The one thing an operator reliably forgets, and the symptom is
|
|
131
|
+
// "roomyx installed the skill and my agent still cannot see it".
|
|
132
|
+
console.log("\nRestart your agent — skills are discovered at startup.");
|
|
133
|
+
}
|
|
134
|
+
console.log("\nNext: roomyx room new .roomyx/rooms/logs/<name>.jsonl --goal \"<what the room is for>\"");
|
|
81
135
|
},
|
|
82
136
|
},
|
|
83
137
|
|
|
@@ -289,6 +343,7 @@ const COMMANDS: Record<string, Command> = {
|
|
|
289
343
|
summary: "start the management MCP server",
|
|
290
344
|
notes: "Default port 4320, so it does not collide with `roomyx serve`.",
|
|
291
345
|
flags: {
|
|
346
|
+
stdio: { type: "boolean", describe: "Speak MCP over stdin/stdout instead of HTTP (what an MCP client spawns)" },
|
|
292
347
|
port: { type: "number", describe: "Listen port (default 4320; 0 picks an ephemeral one)" },
|
|
293
348
|
host: { type: "string", describe: "Bind address (default 127.0.0.1)" },
|
|
294
349
|
"acknowledge-non-loopback": { type: "boolean", describe: "Required to bind a non-loopback host" },
|
|
@@ -296,18 +351,36 @@ const COMMANDS: Record<string, Command> = {
|
|
|
296
351
|
config: { type: "string", describe: "Config file (default .roomyx/config.json)" },
|
|
297
352
|
},
|
|
298
353
|
run: async ({ flags }) => {
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
354
|
+
const managementOptions = {
|
|
355
|
+
registryPath: typeof flags.registry === "string" ? flags.registry : defaultRegistryPath(),
|
|
356
|
+
bundledSkillPath: bundledSkillPath(),
|
|
357
|
+
configPath: typeof flags.config === "string" ? flags.config : defaultConfigPath(),
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
if (flags.stdio === true) {
|
|
361
|
+
// The transport an MCP client actually wants: it spawns the process and
|
|
362
|
+
// owns its lifetime, so there is no port to pick, nothing to leave
|
|
363
|
+
// running, and no registration that points at something not started
|
|
364
|
+
// yet. This is what `roomyx init` writes into `.mcp.json`.
|
|
365
|
+
//
|
|
366
|
+
// **Nothing may be printed to stdout here** — stdout is the protocol
|
|
367
|
+
// channel, and one stray line of greeting is a parse error at the far
|
|
368
|
+
// end. The HTTP branch below prints because it has a stdout to itself.
|
|
369
|
+
const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
|
|
370
|
+
const { createManagementMcpServer } = await import("./mcp-management/server");
|
|
371
|
+
const server = createManagementMcpServer(managementOptions);
|
|
372
|
+
await server.connect(new StdioServerTransport());
|
|
373
|
+
// The client closes the pipe when it is done; there is no port to
|
|
374
|
+
// release, so the signal handlers the HTTP branch installs would have
|
|
375
|
+
// nothing to do.
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const handle = await serveManagement(managementOptions, {
|
|
380
|
+
port: typeof flags.port === "number" ? flags.port : undefined,
|
|
381
|
+
host: typeof flags.host === "string" ? flags.host : undefined,
|
|
382
|
+
acknowledgeNonLoopback: flags["acknowledge-non-loopback"] === true,
|
|
383
|
+
});
|
|
311
384
|
|
|
312
385
|
console.log(`roomyx mcp listening at ${handle.url}`);
|
|
313
386
|
console.log("tools: roomyx.rooms.list, roomyx.skills.sync");
|
|
@@ -317,7 +390,7 @@ const COMMANDS: Record<string, Command> = {
|
|
|
317
390
|
},
|
|
318
391
|
|
|
319
392
|
"skills sync": {
|
|
320
|
-
usage: "roomyx skills sync --target <
|
|
393
|
+
usage: "roomyx skills sync --target <runtime|all|path> [flags]",
|
|
321
394
|
summary: "install the bundled startup-room skill",
|
|
322
395
|
notes:
|
|
323
396
|
"Without --yes nothing is written: the run reports what it would do and\n stops. D-02 — landing on a real skill file is a deliberate act, not a\n side effect of the mechanism existing.",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createCliRenderer } from "@opentui/core";
|
|
2
|
+
import { InitPicker } from "./screens/init-picker";
|
|
3
|
+
import { resolveAction } from "./keymap";
|
|
4
|
+
import type { PlanItem } from "../installer/init-plan";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Runs the `roomyx init` picker and resolves with the operator's choices, or
|
|
8
|
+
* with null if they cancelled.
|
|
9
|
+
*
|
|
10
|
+
* Kept apart from `src/cli.ts` and imported lazily there, so `roomyx --version`
|
|
11
|
+
* and every non-interactive path still cost nothing to load — the TUI renderer
|
|
12
|
+
* is the heaviest import in the package.
|
|
13
|
+
*/
|
|
14
|
+
export async function runInitPicker(items: PlanItem[]): Promise<PlanItem[] | null> {
|
|
15
|
+
const renderer = await createCliRenderer({ targetFps: 30 });
|
|
16
|
+
const picker = new InitPicker(renderer, items, {
|
|
17
|
+
width: renderer.terminalWidth,
|
|
18
|
+
height: renderer.terminalHeight,
|
|
19
|
+
});
|
|
20
|
+
renderer.root.add(picker.node);
|
|
21
|
+
|
|
22
|
+
return new Promise<PlanItem[] | null>((resolve) => {
|
|
23
|
+
let settled = false;
|
|
24
|
+
const finish = (value: PlanItem[] | null): void => {
|
|
25
|
+
// Guarded: a keypress arriving between `destroy()` and the process
|
|
26
|
+
// continuing would otherwise resolve a second time and, worse, draw into
|
|
27
|
+
// a destroyed renderer.
|
|
28
|
+
if (settled) return;
|
|
29
|
+
settled = true;
|
|
30
|
+
picker.destroy();
|
|
31
|
+
renderer.destroy();
|
|
32
|
+
resolve(value);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
renderer.keyInput.on("keypress", (event) => {
|
|
36
|
+
// Space is not in the keymap — it is this screen's own verb, and binding
|
|
37
|
+
// it globally would take it away from anything that later wants to type.
|
|
38
|
+
if (event.name === "space" || event.sequence === " ") {
|
|
39
|
+
picker.toggle();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
switch (resolveAction(event)) {
|
|
43
|
+
case "roster.next":
|
|
44
|
+
case "scroll.lineDown":
|
|
45
|
+
picker.move(1);
|
|
46
|
+
break;
|
|
47
|
+
case "roster.prev":
|
|
48
|
+
case "scroll.lineUp":
|
|
49
|
+
picker.move(-1);
|
|
50
|
+
break;
|
|
51
|
+
// Enter installs from anywhere in the list, not only on the submit row.
|
|
52
|
+
// The row is an affordance that says the key exists; requiring the
|
|
53
|
+
// cursor to be parked on it would be a second step for no gain.
|
|
54
|
+
case "roster.open":
|
|
55
|
+
finish(picker.result());
|
|
56
|
+
break;
|
|
57
|
+
case "app.quit":
|
|
58
|
+
finish(null);
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
if (event.name === "escape") finish(null);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { BoxRenderable, ScrollBoxRenderable, TextRenderable } from "@opentui/core";
|
|
2
|
+
import type { RenderContext } from "@opentui/core";
|
|
3
|
+
import type { PlanItem } from "../../installer/init-plan";
|
|
4
|
+
import { clip } from "../clip";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The checkbox list `roomyx init` shows: what it is about to do, grouped, with
|
|
8
|
+
* the exact path of every write, and nothing happening until Enter.
|
|
9
|
+
*
|
|
10
|
+
* The screen exists because the flag it replaces asked the operator to decide
|
|
11
|
+
* something they could not see. `roomyx skills sync --target claude --yes` is a
|
|
12
|
+
* commitment to a path typed from memory; this is the same commitment made
|
|
13
|
+
* against the path printed in front of them. D-02 wanted a deliberate act — a
|
|
14
|
+
* ticked box you had to look at is more deliberate than a flag, not less.
|
|
15
|
+
*
|
|
16
|
+
* Rows are a flat list of headers and items so that navigation, which must skip
|
|
17
|
+
* headers, is index arithmetic over one array rather than a nested walk.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export type Row = { kind: "header"; text: string } | { kind: "item"; item: PlanItem } | { kind: "submit" };
|
|
21
|
+
|
|
22
|
+
export function rowsFor(items: readonly PlanItem[]): Row[] {
|
|
23
|
+
const rows: Row[] = [];
|
|
24
|
+
let group: string | null = null;
|
|
25
|
+
for (const item of items) {
|
|
26
|
+
if (item.group !== group) {
|
|
27
|
+
// A blank row before every group but the first. Three headers stacked
|
|
28
|
+
// against their lists with no gap read as one long list with captions in
|
|
29
|
+
// it; the gap is what makes them read as sections.
|
|
30
|
+
if (group !== null) rows.push({ kind: "header", text: "" });
|
|
31
|
+
group = item.group;
|
|
32
|
+
rows.push({ kind: "header", text: group });
|
|
33
|
+
}
|
|
34
|
+
rows.push({ kind: "item", item });
|
|
35
|
+
}
|
|
36
|
+
rows.push({ kind: "submit" });
|
|
37
|
+
return rows;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Indexes into `rows` that the cursor may land on. */
|
|
41
|
+
export function selectableIndexes(rows: readonly Row[]): number[] {
|
|
42
|
+
return rows.map((row, i) => (row.kind === "header" ? -1 : i)).filter((i) => i >= 0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const LABEL_WIDTH = 26;
|
|
46
|
+
const LABEL_WIDTH_NARROW = 14;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Terminal width at or above which the label column gets its full 26 columns.
|
|
50
|
+
*
|
|
51
|
+
* Below it the column is cut to 14, because the padding was pushing the
|
|
52
|
+
* already-there warning off the end of a 40-column pane — the row that is about
|
|
53
|
+
* to overwrite a file read exactly like a row installing a fresh one. Same
|
|
54
|
+
* failure and same fix as the archive list's timestamp column; a fixed-width
|
|
55
|
+
* field ahead of a variable one is where this keeps happening.
|
|
56
|
+
*/
|
|
57
|
+
const LABEL_BREAKPOINT = 80;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* One row's text. Pure and exported for the same reason the archive list's is:
|
|
61
|
+
* every rendering defect this client has shipped in a list row was
|
|
62
|
+
* width-dependent, and a test that renders one width finds none of them.
|
|
63
|
+
*/
|
|
64
|
+
export function renderRow(row: Row, width: number, focused: boolean): string {
|
|
65
|
+
const cursor = focused ? ">" : " ";
|
|
66
|
+
if (row.kind === "header") return clip(row.text, Math.max(0, width - 1));
|
|
67
|
+
if (row.kind === "submit") {
|
|
68
|
+
return clip(`${cursor} [ Install ] ↵`, Math.max(0, width - 1));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const { item } = row;
|
|
72
|
+
const box = item.selected ? "[x]" : "[ ]";
|
|
73
|
+
const labelWidth = width >= LABEL_BREAKPOINT ? LABEL_WIDTH : LABEL_WIDTH_NARROW;
|
|
74
|
+
const label = item.label.length > labelWidth ? clip(item.label, labelWidth) : item.label.padEnd(labelWidth);
|
|
75
|
+
// The note goes before the path, because the path is the long field and is
|
|
76
|
+
// the one truncation eats first — a row whose "already there" warning was cut
|
|
77
|
+
// reads as a fresh install. Same lesson as the archive list's missing-log
|
|
78
|
+
// sigil, which had to move to the front for exactly this reason.
|
|
79
|
+
const note = item.done === undefined ? "" : `${item.done} `;
|
|
80
|
+
// One space after the label field unconditionally: a label that fills the
|
|
81
|
+
// column exactly used to abut the path with no gap, so `Ignore registry,
|
|
82
|
+
// lockfiles/home/you/.gitignore` read as one token.
|
|
83
|
+
return clip(`${cursor} ${box} ${label} ${note}${item.detail}`, Math.max(0, width - 1));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export class InitPicker {
|
|
87
|
+
readonly node: BoxRenderable;
|
|
88
|
+
private readonly rows: Row[];
|
|
89
|
+
private readonly selectable: number[];
|
|
90
|
+
private readonly rendered: TextRenderable[];
|
|
91
|
+
private readonly scroll: ScrollBoxRenderable;
|
|
92
|
+
private cursor = 0;
|
|
93
|
+
|
|
94
|
+
constructor(
|
|
95
|
+
ctx: RenderContext,
|
|
96
|
+
private readonly items: PlanItem[],
|
|
97
|
+
private readonly options: { width: number; height: number },
|
|
98
|
+
) {
|
|
99
|
+
this.rows = rowsFor(items);
|
|
100
|
+
this.selectable = selectableIndexes(this.rows);
|
|
101
|
+
this.node = new BoxRenderable(ctx, {
|
|
102
|
+
width: options.width,
|
|
103
|
+
height: options.height,
|
|
104
|
+
flexDirection: "column",
|
|
105
|
+
border: true,
|
|
106
|
+
title: " roomyx init — pick what to set up ",
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Scrolled, not laid out flat. The plan is nine skill rows today and grows
|
|
110
|
+
// by a row per runtime; a flat list overflowed a 22-row terminal by one and
|
|
111
|
+
// drew the hint line straight through the bottom border — the same defect
|
|
112
|
+
// the help overlay shipped, from the same cause.
|
|
113
|
+
this.scroll = new ScrollBoxRenderable(ctx, {
|
|
114
|
+
flexGrow: 1,
|
|
115
|
+
// Nothing here scrolls sideways: rows are clipped to the pane width.
|
|
116
|
+
horizontalScrollbarOptions: { visible: false },
|
|
117
|
+
});
|
|
118
|
+
this.node.add(this.scroll);
|
|
119
|
+
|
|
120
|
+
// The submit row is pinned below the scroll box, not carried inside it.
|
|
121
|
+
// Inside, a plan taller than the terminal pushed `[ Install ]` off the
|
|
122
|
+
// bottom — the one row that has to be visible for the screen to explain
|
|
123
|
+
// itself was the first one to disappear.
|
|
124
|
+
this.rendered = this.rows.map((row, index) => {
|
|
125
|
+
const text = new TextRenderable(ctx, {
|
|
126
|
+
content: renderRow(row, options.width - 2, index === this.focusedRowIndex()),
|
|
127
|
+
height: 1,
|
|
128
|
+
// Explicit, rather than relying on `height: 1` to hide a wrap — that
|
|
129
|
+
// reliance is what turned an overflow into a vanished row in the
|
|
130
|
+
// roster. See ../clip.
|
|
131
|
+
wrapMode: "none",
|
|
132
|
+
});
|
|
133
|
+
if (row.kind === "submit") this.node.add(text);
|
|
134
|
+
else this.scroll.add(text);
|
|
135
|
+
return text;
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
this.node.add(
|
|
139
|
+
new TextRenderable(ctx, {
|
|
140
|
+
content:
|
|
141
|
+
' ↑/↓ or j/k move · Space toggles · Enter installs · q cancels\n "replaces" — file exists; diffed and backed up first',
|
|
142
|
+
height: 2,
|
|
143
|
+
wrapMode: "none",
|
|
144
|
+
}),
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Keeps the focused row inside the viewport as the cursor moves. */
|
|
149
|
+
private reveal(): void {
|
|
150
|
+
const index = this.focusedRowIndex();
|
|
151
|
+
// The submit row is pinned outside the scroll box, so there is nothing to
|
|
152
|
+
// scroll to when the cursor is on it.
|
|
153
|
+
if (this.rows[index]?.kind === "submit") return;
|
|
154
|
+
const row = this.rendered[index];
|
|
155
|
+
if (row === undefined) return;
|
|
156
|
+
const offset = row.y - this.scroll.content.y;
|
|
157
|
+
const viewport = Math.max(1, this.scroll.viewport.height);
|
|
158
|
+
if (offset < this.scroll.scrollTop) this.scroll.scrollTop = offset;
|
|
159
|
+
else if (offset >= this.scroll.scrollTop + viewport) this.scroll.scrollTop = offset - viewport + 1;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private focusedRowIndex(): number {
|
|
163
|
+
return this.selectable[this.cursor] ?? -1;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
move(delta: 1 | -1): void {
|
|
167
|
+
if (this.selectable.length === 0) return;
|
|
168
|
+
this.cursor = (this.cursor + delta + this.selectable.length) % this.selectable.length;
|
|
169
|
+
this.repaint();
|
|
170
|
+
this.reveal();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Toggles the focused item. No-op on the submit row, which is not a choice. */
|
|
174
|
+
toggle(): void {
|
|
175
|
+
const row = this.rows[this.focusedRowIndex()];
|
|
176
|
+
if (row?.kind !== "item") return;
|
|
177
|
+
row.item.selected = !row.item.selected;
|
|
178
|
+
this.repaint();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Every item, with the operator's ticks applied. */
|
|
182
|
+
result(): PlanItem[] {
|
|
183
|
+
return this.items;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** `remove()` unlinks without freeing, and the native renderable pool is finite. */
|
|
187
|
+
destroy(): void {
|
|
188
|
+
this.node.destroyRecursively();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private repaint(): void {
|
|
192
|
+
const focused = this.focusedRowIndex();
|
|
193
|
+
this.rendered.forEach((text, index) => {
|
|
194
|
+
const row = this.rows[index];
|
|
195
|
+
if (row) text.content = renderRow(row, this.options.width - 2, index === focused);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { syncSkill } from "./skill-sync";
|
|
5
|
+
import type { PlanItem } from "./init-plan";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Performs a plan the operator has ticked. One result line per item, whether it
|
|
9
|
+
* worked or not — a run that half-succeeded must say which half.
|
|
10
|
+
*
|
|
11
|
+
* Every write here is additive or backed up. Nothing this function does removes
|
|
12
|
+
* an existing line, key or file.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export interface ApplyResult {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly label: string;
|
|
18
|
+
readonly path: string;
|
|
19
|
+
readonly ok: boolean;
|
|
20
|
+
/** What happened, in one line, for the summary the CLI prints. */
|
|
21
|
+
readonly message: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ApplyContext {
|
|
25
|
+
cwd: string;
|
|
26
|
+
bundledSkillPath: string;
|
|
27
|
+
configPath: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function applyPlan(items: readonly PlanItem[], context: ApplyContext): ApplyResult[] {
|
|
31
|
+
return items.map((item) => {
|
|
32
|
+
try {
|
|
33
|
+
return { id: item.id, label: item.label, path: item.path, ok: true, message: applyOne(item, context) };
|
|
34
|
+
} catch (error) {
|
|
35
|
+
// One failing item must not abort the rest: a `~/.cursor` that is not
|
|
36
|
+
// writable should not cost the operator the Claude install they also
|
|
37
|
+
// asked for in the same submit.
|
|
38
|
+
return {
|
|
39
|
+
id: item.id,
|
|
40
|
+
label: item.label,
|
|
41
|
+
path: item.path,
|
|
42
|
+
ok: false,
|
|
43
|
+
message: error instanceof Error ? error.message : String(error),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function applyOne(item: PlanItem, context: ApplyContext): string {
|
|
50
|
+
switch (item.kind) {
|
|
51
|
+
case "skill": {
|
|
52
|
+
const result = syncSkill({
|
|
53
|
+
bundledSkillPath: context.bundledSkillPath,
|
|
54
|
+
targetPath: item.path,
|
|
55
|
+
configPath: context.configPath,
|
|
56
|
+
dryRun: false,
|
|
57
|
+
// The operator ticked this box and pressed Enter. That is what `--yes`
|
|
58
|
+
// means on the command line, and it is a stronger signal than a flag:
|
|
59
|
+
// they saw the exact path before agreeing to it.
|
|
60
|
+
yes: true,
|
|
61
|
+
});
|
|
62
|
+
if (!result.written) return result.warnings[0] ?? "not written";
|
|
63
|
+
return result.backedUpTo ? `written (backup: ${result.backedUpTo})` : "written";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
case "logs":
|
|
67
|
+
mkdirSync(item.path, { recursive: true });
|
|
68
|
+
return "created";
|
|
69
|
+
|
|
70
|
+
case "gitignore":
|
|
71
|
+
return ensureGitignore(context.cwd);
|
|
72
|
+
|
|
73
|
+
case "mcp":
|
|
74
|
+
return ensureMcpServer(item.path, item.id === "mcp:cursor");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const IGNORE_LINES = [".roomyx/rooms/registry.json", ".roomyx/rooms/*.lock"];
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Appends the two machine-local paths to `.gitignore` if they are not already
|
|
82
|
+
* covered, and leaves everything else in the file alone.
|
|
83
|
+
*
|
|
84
|
+
* Room logs are deliberately not ignored. The transcript is the artefact worth
|
|
85
|
+
* keeping; what is machine-local is the registry (pids and ports of processes
|
|
86
|
+
* on this host) and the transient lockfiles.
|
|
87
|
+
*/
|
|
88
|
+
function ensureGitignore(cwd: string): string {
|
|
89
|
+
const path = join(cwd, ".gitignore");
|
|
90
|
+
const existing = existsSync(path) ? readFileSync(path, "utf8") : "";
|
|
91
|
+
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
92
|
+
const missing = IGNORE_LINES.filter((line) => !present.has(line));
|
|
93
|
+
if (missing.length === 0) return "already covered";
|
|
94
|
+
|
|
95
|
+
const block = `${existing.length > 0 && !existing.endsWith("\n") ? "\n" : ""}\n# roomyx — machine-local state (room logs are NOT ignored)\n${missing.join("\n")}\n`;
|
|
96
|
+
writeFileSync(path, existing + block, "utf8");
|
|
97
|
+
return `added ${missing.length} line(s)`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface McpConfig {
|
|
101
|
+
mcpServers?: Record<string, unknown>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Adds a `roomyx` entry to an MCP config, merging rather than replacing.
|
|
106
|
+
*
|
|
107
|
+
* The entry spawns `roomyx mcp --stdio`, not an HTTP URL. A URL would have to
|
|
108
|
+
* name a port that something is already listening on, so a registration written
|
|
109
|
+
* at `init` would point at nothing until the operator remembered to start a
|
|
110
|
+
* server — a config entry that is broken by default. Over stdio the client
|
|
111
|
+
* starts it when it needs it and there is no port at all.
|
|
112
|
+
*
|
|
113
|
+
* An existing `roomyx` key is left untouched: the operator may have pointed it
|
|
114
|
+
* somewhere deliberately, and silently rewriting someone's MCP config is the
|
|
115
|
+
* same class of theft D-02 exists to prevent.
|
|
116
|
+
*/
|
|
117
|
+
function ensureMcpServer(path: string, createDir: boolean): string {
|
|
118
|
+
if (createDir) mkdirSync(dirname(path), { recursive: true });
|
|
119
|
+
|
|
120
|
+
let config: McpConfig = {};
|
|
121
|
+
if (existsSync(path)) {
|
|
122
|
+
const text = readFileSync(path, "utf8").trim();
|
|
123
|
+
if (text !== "") {
|
|
124
|
+
try {
|
|
125
|
+
config = JSON.parse(text) as McpConfig;
|
|
126
|
+
} catch (error) {
|
|
127
|
+
// Refused rather than overwritten. A file we cannot parse may still be
|
|
128
|
+
// a file someone is relying on.
|
|
129
|
+
throw new Error(
|
|
130
|
+
`${path} is not valid JSON — ${error instanceof Error ? error.message : String(error)}. Left untouched.`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const servers = config.mcpServers ?? {};
|
|
137
|
+
if (servers.roomyx !== undefined) return "already registered — left as it is";
|
|
138
|
+
|
|
139
|
+
config.mcpServers = { ...servers, roomyx: { command: "roomyx", args: ["mcp", "--stdio"] } };
|
|
140
|
+
writeFileSync(path, `${JSON.stringify(config, null, 2)}\n`, "utf8");
|
|
141
|
+
return "registered";
|
|
142
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { SKILL_RUNTIMES } from "./skill-targets";
|
|
4
|
+
import type { SkillRuntime } from "./skill-targets";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What `roomyx init` offers to do, as data.
|
|
8
|
+
*
|
|
9
|
+
* Split from the screen that draws it and from the code that performs it,
|
|
10
|
+
* because the interesting decisions are here — which boxes start ticked, what
|
|
11
|
+
* is already done, what cannot be done and why — and none of them should need a
|
|
12
|
+
* renderer to test. The picker draws this list; `init-apply` executes it.
|
|
13
|
+
*
|
|
14
|
+
* **Nothing here writes.** A plan is built, shown, edited by the operator, and
|
|
15
|
+
* only then applied. That is what makes the interactive path satisfy D-02 more
|
|
16
|
+
* honestly than a flag did: landing a real skill file is a person ticking a box
|
|
17
|
+
* and pressing Enter, not a side effect of the mechanism existing.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export type PlanItemKind = "skill" | "logs" | "gitignore" | "mcp";
|
|
21
|
+
|
|
22
|
+
export interface PlanItem {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly kind: PlanItemKind;
|
|
25
|
+
/** Heading this item is listed under. */
|
|
26
|
+
readonly group: string;
|
|
27
|
+
readonly label: string;
|
|
28
|
+
/** Where it actually lands on disk. What `init-apply` acts on. */
|
|
29
|
+
readonly path: string;
|
|
30
|
+
/** How the path is shown, which may carry a short note the path itself must not. */
|
|
31
|
+
readonly detail: string;
|
|
32
|
+
/** Ticked when the picker opens. */
|
|
33
|
+
selected: boolean;
|
|
34
|
+
/** Set when the item is already satisfied — still listed, so the list is a complete picture. */
|
|
35
|
+
readonly done?: string;
|
|
36
|
+
/** For a skill item: which runtime, so `init-apply` does not have to parse the id. */
|
|
37
|
+
readonly runtime?: SkillRuntime;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const GROUP_USER = "Skill — every project on this machine";
|
|
41
|
+
export const GROUP_PROJECT = "Skill — this project only (travels with the repo)";
|
|
42
|
+
export const GROUP_EXTRAS = "Also";
|
|
43
|
+
|
|
44
|
+
export interface PlanContext {
|
|
45
|
+
cwd: string;
|
|
46
|
+
/** Injectable so the tests never look at the operator's real home directory. */
|
|
47
|
+
exists?: (path: string) => boolean;
|
|
48
|
+
/** Injectable for the same reason. */
|
|
49
|
+
home?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The offer, in the order it is shown.
|
|
54
|
+
*
|
|
55
|
+
* Boxes start ticked where the answer is not really in doubt: a runtime that is
|
|
56
|
+
* installed on this machine, a project that already has that runtime's
|
|
57
|
+
* directory, a logs directory the config already points at. Everything else
|
|
58
|
+
* starts unticked. The rule is that a default tick must never write somewhere
|
|
59
|
+
* the operator would be surprised to find a file — being surprised by a file in
|
|
60
|
+
* `~/.cursor` when Cursor is not installed is exactly that.
|
|
61
|
+
*/
|
|
62
|
+
export function buildPlan(context: PlanContext): PlanItem[] {
|
|
63
|
+
const { cwd } = context;
|
|
64
|
+
const exists = context.exists ?? existsSync;
|
|
65
|
+
const items: PlanItem[] = [];
|
|
66
|
+
|
|
67
|
+
for (const runtime of SKILL_RUNTIMES) {
|
|
68
|
+
const path = runtime.path(cwd);
|
|
69
|
+
// Presence of the runtime's own directory, not of our skill: this decides
|
|
70
|
+
// whether to *offer it ticked*, never whether to offer it at all. A runtime
|
|
71
|
+
// installed after roomyx would otherwise be unreachable.
|
|
72
|
+
const present = exists(runtime.marker(cwd));
|
|
73
|
+
items.push({
|
|
74
|
+
id: `skill:${runtime.name}`,
|
|
75
|
+
kind: "skill",
|
|
76
|
+
group: runtime.scope === "user" ? GROUP_USER : GROUP_PROJECT,
|
|
77
|
+
label: runtime.label,
|
|
78
|
+
path,
|
|
79
|
+
detail: path,
|
|
80
|
+
selected: present,
|
|
81
|
+
done: exists(path) ? "replaces" : undefined,
|
|
82
|
+
runtime,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const logsDir = join(cwd, ".roomyx", "rooms", "logs");
|
|
87
|
+
items.push({
|
|
88
|
+
id: "logs",
|
|
89
|
+
kind: "logs",
|
|
90
|
+
group: GROUP_EXTRAS,
|
|
91
|
+
label: "Room-log directory",
|
|
92
|
+
path: logsDir,
|
|
93
|
+
detail: logsDir,
|
|
94
|
+
// `config.json` has named this directory since the first release and
|
|
95
|
+
// nothing ever created it, so `roomyx room new .roomyx/rooms/logs/x.jsonl`
|
|
96
|
+
// — the path the config itself points at — failed on a fresh project.
|
|
97
|
+
selected: true,
|
|
98
|
+
done: exists(logsDir) ? "already there" : undefined,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const isRepo = exists(join(cwd, ".git"));
|
|
102
|
+
items.push({
|
|
103
|
+
id: "gitignore",
|
|
104
|
+
kind: "gitignore",
|
|
105
|
+
group: GROUP_EXTRAS,
|
|
106
|
+
label: "Ignore registry, lockfiles",
|
|
107
|
+
path: join(cwd, ".gitignore"),
|
|
108
|
+
// The registry holds pids and ports of processes on *this* machine, and the
|
|
109
|
+
// lockfiles are transient. Room logs are deliberately not ignored: the
|
|
110
|
+
// transcript is the point.
|
|
111
|
+
// The path alone. The label already names exactly what gets ignored, which
|
|
112
|
+
// is also how it says what does not: the room logs.
|
|
113
|
+
detail: join(cwd, ".gitignore"),
|
|
114
|
+
selected: isRepo,
|
|
115
|
+
done: isRepo ? undefined : "not a git repository",
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
for (const [id, label, path] of mcpTargets(cwd)) {
|
|
119
|
+
const runtimeDir = id === "mcp:claude" ? join(cwd, ".claude") : join(cwd, ".cursor");
|
|
120
|
+
items.push({
|
|
121
|
+
id,
|
|
122
|
+
kind: "mcp",
|
|
123
|
+
group: GROUP_EXTRAS,
|
|
124
|
+
label,
|
|
125
|
+
path,
|
|
126
|
+
detail: path,
|
|
127
|
+
// Only pre-ticked when that runtime is already used in this project.
|
|
128
|
+
// Registering a server for an agent nobody here runs is clutter.
|
|
129
|
+
selected: exists(runtimeDir) || exists(path),
|
|
130
|
+
done: undefined,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return items;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Project-scoped MCP config files, by runtime. */
|
|
138
|
+
function mcpTargets(cwd: string): [string, string, string][] {
|
|
139
|
+
return [
|
|
140
|
+
["mcp:claude", "MCP server for Claude Code", join(cwd, ".mcp.json")],
|
|
141
|
+
["mcp:cursor", "MCP server for Cursor", join(cwd, ".cursor", "mcp.json")],
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** The items a plan would actually act on. */
|
|
146
|
+
export function selectedItems(items: readonly PlanItem[]): PlanItem[] {
|
|
147
|
+
return items.filter((item) => item.selected);
|
|
148
|
+
}
|
|
@@ -1,53 +1,123 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import { homedir } from "node:os";
|
|
2
3
|
import { join } from "node:path";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* a
|
|
6
|
+
* Where each agent runtime looks for skills, as a table rather than a switch.
|
|
7
|
+
*
|
|
8
|
+
* Adding a runtime is one row. It used to be a `case` in one function plus a
|
|
9
|
+
* literal in a union plus a line of prose, and the three had already drifted —
|
|
10
|
+
* `grok` was missing entirely even though it reads `~/.claude/skills` and has
|
|
11
|
+
* its own `~/.grok/skills`, so the only way to install for it was to type a
|
|
12
|
+
* full path by hand.
|
|
13
|
+
*
|
|
14
|
+
* **Two scopes, deliberately both offered.** A user-scoped skill is available in
|
|
15
|
+
* every project on the machine; a project-scoped one lives in the repository and
|
|
16
|
+
* travels with it, which is what a team wants and what every one of these
|
|
17
|
+
* runtimes ranks *higher* than the user-scoped copy. Neither is the right
|
|
18
|
+
* default for everyone, so `roomyx init` asks instead of choosing.
|
|
9
19
|
*/
|
|
10
|
-
export const NAMED_TARGETS = ["claude", "codex", "keryx"] as const;
|
|
11
20
|
|
|
12
|
-
export
|
|
21
|
+
export interface SkillRuntime {
|
|
22
|
+
/** The `--target` name. */
|
|
23
|
+
readonly name: string;
|
|
24
|
+
/** How to say it to a person. */
|
|
25
|
+
readonly label: string;
|
|
26
|
+
readonly scope: "user" | "project";
|
|
27
|
+
/** Where the SKILL.md goes. */
|
|
28
|
+
readonly path: (cwd: string) => string;
|
|
29
|
+
/**
|
|
30
|
+
* The directory whose existence means this runtime is in use here. Used only
|
|
31
|
+
* to pre-tick sensible boxes in `roomyx init` — never to refuse a target,
|
|
32
|
+
* because a runtime installed after roomyx would then be unreachable.
|
|
33
|
+
*/
|
|
34
|
+
readonly marker: (cwd: string) => string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const SKILL_FILE = ["skills", "startup-room", "SKILL.md"] as const;
|
|
13
38
|
|
|
14
|
-
|
|
15
|
-
return
|
|
39
|
+
function userRuntime(name: string, label: string, dir: string): SkillRuntime {
|
|
40
|
+
return {
|
|
41
|
+
name,
|
|
42
|
+
label,
|
|
43
|
+
scope: "user",
|
|
44
|
+
path: () => join(homedir(), dir, ...SKILL_FILE),
|
|
45
|
+
marker: () => join(homedir(), dir),
|
|
46
|
+
};
|
|
16
47
|
}
|
|
17
48
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
function projectRuntime(name: string, label: string, dir: string): SkillRuntime {
|
|
50
|
+
return {
|
|
51
|
+
name,
|
|
52
|
+
label,
|
|
53
|
+
scope: "project",
|
|
54
|
+
path: (cwd) => join(cwd, dir, ...SKILL_FILE),
|
|
55
|
+
marker: (cwd) => join(cwd, dir),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const SKILL_RUNTIMES: readonly SkillRuntime[] = [
|
|
60
|
+
userRuntime("claude", "Claude Code", ".claude"),
|
|
61
|
+
userRuntime("codex", "Codex", ".codex"),
|
|
62
|
+
userRuntime("cursor", "Cursor", ".cursor"),
|
|
63
|
+
userRuntime("grok", "Grok", ".grok"),
|
|
64
|
+
projectRuntime("claude-project", "Claude Code", ".claude"),
|
|
65
|
+
projectRuntime("codex-project", "Codex", ".codex"),
|
|
66
|
+
projectRuntime("cursor-project", "Cursor", ".cursor"),
|
|
67
|
+
projectRuntime("grok-project", "Grok", ".grok"),
|
|
68
|
+
{
|
|
69
|
+
// keryx keeps a project's own skills in `.metaproject/project-skills/`, as
|
|
70
|
+
// distinct from `.metaproject/skills/`, which is keryx's own bundled set and
|
|
71
|
+
// not ours to write into. It has no user-scoped location, so there is one
|
|
72
|
+
// row rather than two, and the name has no `-project` suffix because there
|
|
73
|
+
// is nothing to distinguish it from.
|
|
74
|
+
name: "keryx",
|
|
75
|
+
label: "keryx",
|
|
76
|
+
scope: "project",
|
|
77
|
+
path: (cwd) => join(cwd, ".metaproject", "project-skills", "startup-room", "SKILL.md"),
|
|
78
|
+
marker: (cwd) => join(cwd, ".metaproject"),
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
export const NAMED_TARGETS = SKILL_RUNTIMES.map((runtime) => runtime.name) as readonly string[];
|
|
83
|
+
|
|
84
|
+
export type NamedSkillTarget = string;
|
|
85
|
+
|
|
86
|
+
export function isNamedTarget(value: string): boolean {
|
|
87
|
+
return NAMED_TARGETS.includes(value);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function runtimeByName(name: string): SkillRuntime | undefined {
|
|
91
|
+
return SKILL_RUNTIMES.find((runtime) => runtime.name === name);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** True when this runtime looks like it is actually in use here. */
|
|
95
|
+
export function isRuntimePresent(runtime: SkillRuntime, cwd: string = process.cwd()): boolean {
|
|
96
|
+
return existsSync(runtime.marker(cwd));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function pathForNamedTarget(target: string, cwd: string = process.cwd()): string {
|
|
100
|
+
const runtime = runtimeByName(target);
|
|
101
|
+
if (runtime === undefined) throw new Error(`Unknown skill target "${target}".`);
|
|
102
|
+
return runtime.path(cwd);
|
|
35
103
|
}
|
|
36
104
|
|
|
37
105
|
/**
|
|
38
106
|
* Turns whatever `--target` was given into concrete paths. `all` fans out to
|
|
39
|
-
* every
|
|
40
|
-
* is passed through as a literal path.
|
|
107
|
+
* every runtime in the table; a name resolves to that runtime's path; anything
|
|
108
|
+
* else is passed through as a literal path.
|
|
109
|
+
*
|
|
110
|
+
* `all` genuinely means all, and that widened when the table grew from three
|
|
111
|
+
* rows to nine — a caller who typed `all` before now reaches Cursor, Grok and
|
|
112
|
+
* the project-scoped locations too. That is a change to what an existing flag
|
|
113
|
+
* does without the caller asking, so it ships in the minor position (D-13),
|
|
114
|
+
* not quietly in a patch.
|
|
41
115
|
*/
|
|
42
|
-
export function resolveTargets(
|
|
43
|
-
target: string,
|
|
44
|
-
cwd: string = process.cwd(),
|
|
45
|
-
): { name: string; path: string }[] {
|
|
116
|
+
export function resolveTargets(target: string, cwd: string = process.cwd()): { name: string; path: string }[] {
|
|
46
117
|
if (target === "all") {
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
if (isNamedTarget(target)) {
|
|
50
|
-
return [{ name: target, path: pathForNamedTarget(target, cwd) }];
|
|
118
|
+
return SKILL_RUNTIMES.map((runtime) => ({ name: runtime.name, path: runtime.path(cwd) }));
|
|
51
119
|
}
|
|
120
|
+
const runtime = runtimeByName(target);
|
|
121
|
+
if (runtime) return [{ name: runtime.name, path: runtime.path(cwd) }];
|
|
52
122
|
return [{ name: target, path: target }];
|
|
53
123
|
}
|
package/src/log/store.ts
CHANGED
|
@@ -27,7 +27,19 @@ function parseLine(text: string, describe: () => string): unknown {
|
|
|
27
27
|
export function loadRoomLog(path: string): { state: RoomState; messages: MessageEnvelope[] } {
|
|
28
28
|
// Editors add a byte-order mark; it is not part of the JSON and it made the
|
|
29
29
|
// first line unparseable, which made the whole room unreadable.
|
|
30
|
-
|
|
30
|
+
let raw: string;
|
|
31
|
+
try {
|
|
32
|
+
raw = readFileSync(path, "utf8").replace(/^\uFEFF/, "");
|
|
33
|
+
} catch (error) {
|
|
34
|
+
// A sentence, not a stack. Every other failure in this function names the
|
|
35
|
+
// file and says what is wrong with it; "no such file" was the one that
|
|
36
|
+
// escaped as a raw ENOENT with a stack trace, and it is the most ordinary
|
|
37
|
+
// mistake there is \u2014 a typo in a path, or a log that has been moved.
|
|
38
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
|
|
39
|
+
throw new Error(`No room log at ${path}. Create one with \`roomyx room new ${path} --goal "\u2026"\`.`);
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`Cannot read room log at ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
42
|
+
}
|
|
31
43
|
const lines = raw.split("\n").filter((line) => line.trim().length > 0);
|
|
32
44
|
|
|
33
45
|
if (lines.length === 0) {
|
|
@@ -62,7 +62,9 @@ export function createManagementMcpServer(options: ManagementOptions): McpServer
|
|
|
62
62
|
// visits could drive it cross-origin. The CLI keeps the literal-path
|
|
63
63
|
// escape hatch, because that is the operator on their own machine;
|
|
64
64
|
// the network surface does not get one.
|
|
65
|
-
|
|
65
|
+
// `"all"` leads so the tuple has a known element at position 0 —
|
|
66
|
+
// NAMED_TARGETS is built from the runtime table and is a plain array.
|
|
67
|
+
target: z.enum(["all", ...NAMED_TARGETS] as [string, ...string[]]).describe("A runtime by name, or `all`."),
|
|
66
68
|
},
|
|
67
69
|
},
|
|
68
70
|
// No `yes`, and no `dryRun`. `yes` is what D-02's overwrite guard turns
|
package/src/server/serve.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { createRoomMcpServer } from "./index";
|
|
|
2
2
|
import type { RoomMcpServerOptions } from "./index";
|
|
3
3
|
import { serveMcpOverHttp } from "./http-transport";
|
|
4
4
|
import type { McpHttpTransportHandle } from "./http-transport";
|
|
5
|
+
import { loadRoomLog } from "../log/store";
|
|
5
6
|
|
|
6
7
|
export interface ServeOptions extends RoomMcpServerOptions {
|
|
7
8
|
/** Defaults to 4319 (specification.md's default). 0 selects an ephemeral port. */
|
|
@@ -18,6 +19,20 @@ export type ServeHandle = McpHttpTransportHandle;
|
|
|
18
19
|
* is which server a session gets and which port it defaults to.
|
|
19
20
|
*/
|
|
20
21
|
export async function serve(logPath: string, options: ServeOptions): Promise<ServeHandle> {
|
|
22
|
+
// Read the log once before binding anything.
|
|
23
|
+
//
|
|
24
|
+
// Without this, `roomyx serve` on a log it cannot parse — a markdown
|
|
25
|
+
// transcript, say, which is what the bundled skill used to tell a dispatcher
|
|
26
|
+
// to write — succeeded loudly and then failed silently: it bound a port,
|
|
27
|
+
// printed a room ID and an attach command, and every tool call threw. The
|
|
28
|
+
// liveness probe treats a throwing `room.get_state` as "not this room", so
|
|
29
|
+
// `roomyx rooms list` answered **"No live rooms"** about a server that was
|
|
30
|
+
// running, and the client refused to attach to the id it had just been given.
|
|
31
|
+
//
|
|
32
|
+
// Failing here costs one read and turns an invisible room into a sentence
|
|
33
|
+
// that names the file and the line.
|
|
34
|
+
loadRoomLog(logPath);
|
|
35
|
+
|
|
21
36
|
return serveMcpOverHttp({
|
|
22
37
|
createMcpServer: () => createRoomMcpServer(logPath, { onOwnerCommand: options.onOwnerCommand }),
|
|
23
38
|
commandLabel: "roomyx serve",
|