@mrciphersmith/roomyx 0.6.3 → 0.7.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 CHANGED
@@ -13,6 +13,55 @@ 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.0] — 2026-09-10
17
+
18
+ A minor, because two things an existing caller relied on changed. The feature is
19
+ that `roomyx init` now finishes the job instead of leaving you a staged file no
20
+ runtime reads.
21
+
22
+ ### Changed — breaking
23
+
24
+ - **`roomyx skills sync --target all` now writes nine files, not three.** The
25
+ runtime table grew: Cursor and Grok were added, and every one of the four
26
+ agents now has a project-scoped location as well as a user-scoped one. `all`
27
+ genuinely means all, so a caller who typed it before now reaches more places.
28
+ If you wanted the old set, name them: `--target claude`, `--target codex`,
29
+ `--target keryx`.
30
+ - **`roomyx init` is interactive on a terminal.** It used to scaffold `.roomyx/`
31
+ and exit. It still does exactly that through a pipe, in CI, or with
32
+ `--no-interactive` — so nothing scripted changes — but on a terminal it now
33
+ shows what it can do and waits for you to pick.
34
+
35
+ ### Added
36
+
37
+ - **An init picker.** Skill targets for Claude Code, Codex, Cursor, Grok and
38
+ keryx, at both scopes, each showing the exact path it would write. Arrows or
39
+ `j`/`k` move, Space ticks, Enter installs, `q` cancels. Nothing is written
40
+ until you submit. Boxes start ticked only where the answer is not in doubt —
41
+ a runtime whose directory exists on this machine, a project that already uses
42
+ that runtime — because a default tick must never surprise you with a file.
43
+ - **Three more things init offers**, all opt-out in the same list: the room-log
44
+ directory `config.json` has named since the first release and nothing ever
45
+ created; `.gitignore` lines for the registry and lockfiles (the room logs are
46
+ deliberately *not* ignored — the transcript is the point); and registration of
47
+ the roomyx MCP server in `.mcp.json` and `.cursor/mcp.json`.
48
+ - **`roomyx mcp --stdio`.** The transport an MCP client actually spawns. This is
49
+ what init registers: an HTTP URL would name a port nothing is listening on
50
+ until you remember to start a server, so the registration would be broken by
51
+ default. Over stdio the client owns the lifetime and there is no port.
52
+
53
+ ### Fixed
54
+
55
+ - **`roomyx init` no longer leaves you with a skill nothing can see.** The
56
+ staged copy under `.roomyx/skills/` is not a directory any runtime scans, and
57
+ installing was a separate command nothing pointed at. Reported from a real
58
+ install: package installed, `init` run, agent still blind.
59
+ - Two list-rendering defects found by the tests while writing them, both
60
+ width-dependent: the label column pushed the "replaces" warning off a
61
+ 40-column pane, so a row about to overwrite a file read like a fresh install;
62
+ and a plan taller than the terminal drew the hint line through the bottom
63
+ border.
64
+
16
65
  ## [0.6.3] — 2026-09-10
17
66
 
18
67
  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 .roomyx/
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
- Creates `.roomyx/` in the current directory: `config.json`, an empty room
113
- registry, and a staged copy of the bundled `startup-room` skill. It never
114
- clobbers a registry that already has rooms in it, and never overwrites an
115
- existing `config.json`.
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
- ### `roomyx skills sync --target <claude|codex|keryx|all|path> [flags]`
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` | all three of the above |
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.6.3",
3
+ "version": "0.7.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"
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/ in this project",
77
- flags: {},
78
- run: async () => {
79
- const result = init({ cwd: process.cwd(), bundledSkillPath: bundledSkillPath() });
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 handle = await serveManagement(
300
- {
301
- registryPath: typeof flags.registry === "string" ? flags.registry : defaultRegistryPath(),
302
- bundledSkillPath: bundledSkillPath(),
303
- configPath: typeof flags.config === "string" ? flags.config : defaultConfigPath(),
304
- },
305
- {
306
- port: typeof flags.port === "number" ? flags.port : undefined,
307
- host: typeof flags.host === "string" ? flags.host : undefined,
308
- acknowledgeNonLoopback: flags["acknowledge-non-loopback"] === true,
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 <claude|codex|keryx|all|path> [flags]",
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
- * The runtimes `roomyx skills sync --target` knows by name. Anything else the
6
- * flag is given is treated as a literal path, which is what the tests use —
7
- * D-02 requires the mechanism to be exercised against fixtures, never against
8
- * a real `~/.claude/skills/...` file.
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 type NamedSkillTarget = (typeof NAMED_TARGETS)[number];
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
- export function isNamedTarget(value: string): value is NamedSkillTarget {
15
- return (NAMED_TARGETS as readonly string[]).includes(value);
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
- * Where each runtime keeps the `startup-room` skill.
20
- *
21
- * Claude and Codex both scope skills to the user, under a home directory.
22
- * keryx scopes them to the project instead: `.metaproject/project-skills/` is
23
- * where a project's own skills live, as distinct from `.metaproject/skills/`,
24
- * which is keryx's own bundled set and not ours to write into.
25
- */
26
- export function pathForNamedTarget(target: NamedSkillTarget, cwd: string = process.cwd()): string {
27
- switch (target) {
28
- case "claude":
29
- return join(homedir(), ".claude", "skills", "startup-room", "SKILL.md");
30
- case "codex":
31
- return join(homedir(), ".codex", "skills", "startup-room", "SKILL.md");
32
- case "keryx":
33
- return join(cwd, ".metaproject", "project-skills", "startup-room", "SKILL.md");
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 named runtime; a name resolves to that runtime's path; anything else
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 NAMED_TARGETS.map((name) => ({ name, path: pathForNamedTarget(name, cwd) }));
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
  }
@@ -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
- target: z.enum([...NAMED_TARGETS, "all"]).describe("A runtime by name, or `all`."),
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