@mrciphersmith/roomyx 0.11.4 → 0.12.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/package.json +2 -1
  3. package/src/bundled-personas/01-ngozi-tailor-nigeria.md +10 -10
  4. package/src/bundled-personas/02-klaus-electrician-germany.md +10 -10
  5. package/src/bundled-personas/03-priya-designer-india.md +10 -10
  6. package/src/bundled-personas/04-dave-landlord-usa.md +10 -10
  7. package/src/bundled-personas/05-budi-ecommerce-indonesia.md +10 -10
  8. package/src/bundled-personas/06-alejandra-eventplanner-mexico.md +10 -10
  9. package/src/bundled-personas/07-tanaka-izakaya-japan.md +10 -10
  10. package/src/bundled-personas/08-thandiwe-ngo-southafrica.md +10 -10
  11. package/src/bundled-personas/09-marco-va-philippines.md +10 -10
  12. package/src/bundled-personas/10-amelie-bookstore-france.md +10 -10
  13. package/src/bundled-personas/11-otieno-bodaboda-kenya.md +10 -10
  14. package/src/bundled-personas/12-mehmet-textile-turkey.md +10 -10
  15. package/src/bundled-personas/13-kasia-freelancedev-poland.md +10 -10
  16. package/src/bundled-personas/14-hassan-tourguide-egypt.md +10 -10
  17. package/src/bundled-personas/15-linh-electronics-vietnam.md +10 -10
  18. package/src/bundled-personas/16-chloe-creator-uk.md +10 -10
  19. package/src/bundled-personas/17-bruce-farmer-australia.md +10 -10
  20. package/src/bundled-personas/18-sara-interiordesign-uae.md +10 -10
  21. package/src/bundled-personas/19-fernanda-daycare-brazil.md +10 -10
  22. package/src/bundled-personas/20-ryan-engmanager-usa.md +10 -10
  23. package/src/bundled-personas/21-victoria-banker-nyc.md +10 -10
  24. package/src/bundled-personas/22-omar-cryptotrader-dubai.md +10 -10
  25. package/src/bundled-personas/23-diane-surgeon-la.md +10 -10
  26. package/src/bundled-personas/24-james-consultant-london.md +10 -10
  27. package/src/bundled-personas/25-lena-biotechfounder-boston.md +10 -10
  28. package/src/bundled-personas/26-carlos-realestate-miami.md +10 -10
  29. package/src/bundled-personas/27-michelle-lawyer-singapore.md +10 -10
  30. package/src/bundled-personas/28-kevin-hedgefund-hongkong.md +10 -10
  31. package/src/bundled-personas/29-felix-cto-berlin.md +10 -10
  32. package/src/bundled-personas/30-grace-orthodontist-toronto.md +10 -10
  33. package/src/bundled-personas/31-brad-pharmavp-chicago.md +10 -10
  34. package/src/bundled-personas/32-nadia-peops-zurich.md +10 -10
  35. package/src/bundled-personas/33-junho-pilot-seoul.md +10 -10
  36. package/src/bundled-personas/34-emma-newparent-sydney.md +10 -10
  37. package/src/bundled-personas/35-minji-caregiver-seoul.md +10 -10
  38. package/src/bundled-personas/36-daniel-divorced-toronto.md +10 -10
  39. package/src/bundled-personas/37-anke-chronicillness-berlin.md +10 -10
  40. package/src/bundled-personas/38-harold-retiree-florida.md +10 -10
  41. package/src/bundled-personas/39-priyanka-immigrantfamily-toronto.md +10 -10
  42. package/src/bundled-personas/40-tyler-student-austin.md +10 -10
  43. package/src/bundled-personas/41-lotte-stayathome-amsterdam.md +10 -10
  44. package/src/bundled-personas/42-jessica-milspouse-sandiego.md +10 -10
  45. package/src/bundled-personas/43-marcus-pastor-alabama.md +10 -10
  46. package/src/bundled-personas/44-carmen-adoptiveparent-spain.md +10 -10
  47. package/src/bundled-personas/45-robert-chronicconditions-usa.md +10 -10
  48. package/src/bundled-personas/46-gary-trucker-usa.md +10 -10
  49. package/src/bundled-personas/47-giulia-weddingphotographer-italy.md +10 -10
  50. package/src/bundled-personas/48-mark-indiedev-canada.md +10 -10
  51. package/src/bundled-personas/49-fiona-pharmacist-uk.md +10 -10
  52. package/src/bundled-personas/50-willem-urbanbeekeeper-netherlands.md +10 -10
  53. package/src/bundled-personas/founders/01-marcus-serial-founder-sf.md +14 -14
  54. package/src/bundled-personas/founders/02-aisha-firsttime-technical-london.md +14 -14
  55. package/src/bundled-personas/founders/03-jonas-indiehacker-stockholm.md +14 -14
  56. package/src/bundled-personas/founders/04-vanessa-blitzscaler-sf.md +14 -14
  57. package/src/bundled-personas/founders/05-kenji-domainexpert-tokyo.md +14 -14
  58. package/src/bundled-personas/founders/06-ben-scarred-founder-berlin.md +14 -14
  59. package/src/bundled-personas/founders/07-sofia-idealist-milan.md +14 -14
  60. package/src/bundled-personas/founders/08-priya-corporate-intrapreneur-bangalore.md +14 -14
  61. package/src/bundled-personas/founders/09-dmitry-cis-trade-founder.md +12 -12
  62. package/src/bundled-personas/founders/10-aigerim-centralasia-founder.md +12 -12
  63. package/src/bundled-personas/founders/11-sheikh-rashid-uae-investor.md +13 -13
  64. package/src/bundled-personas/founders/12-viktor-russia-market-expert.md +12 -12
  65. package/src/bundled-personas/founders/13-pavel-russia-developer.md +12 -12
  66. package/src/bundled-personas/founders/14-marina-russia-executive.md +12 -12
  67. package/src/bundled-personas/founders/15-rohan-india-saas-founder.md +12 -12
  68. package/src/bundled-personas/founders/16-wei-china-tech-veteran.md +12 -12
  69. package/src/bundled-personas/founders/17-lena-verticalai-saas.md +12 -12
  70. package/src/bundled-personas/founders/18-marcus-ai-infra-llmops.md +12 -12
  71. package/src/bundled-personas/founders/19-sofia-consumer-ai-product.md +12 -12
  72. package/src/bundled-personas/groups.md +44 -44
  73. package/src/bundled-personas/panel/01-rick-operator-exec.md +12 -12
  74. package/src/bundled-personas/panel/02-elena-regtech-exec.md +12 -12
  75. package/src/bundled-personas/panel/03-david-vc-financier.md +12 -12
  76. package/src/bundled-personas/panel/04-grace-cfo-financier.md +12 -12
  77. package/src/bundled-personas/panel/05-sam-enterprise-developer.md +12 -12
  78. package/src/bundled-personas/panel/06-mira-ml-developer.md +12 -12
  79. package/src/bundled-personas/questionnaire-50.md +67 -67
  80. package/src/bundled-personas/tech/01-yuki-ai-ml-engineer.md +12 -12
  81. package/src/bundled-personas/tech/02-omar-database-backend-architect.md +12 -12
  82. package/src/bundled-personas/tech/03-zara-ui-ux-designer.md +12 -12
  83. package/src/bundled-personas/tech/04-finn-web-platform-browser-engineer.md +12 -12
  84. package/src/bundled-personas/tech/05-naledi-mobile-engineer.md +12 -12
  85. package/src/bundled-personas/tech/06-theo-plt-devtools-engineer.md +12 -12
  86. package/src/bundled-personas/tech/07-priya-security-researcher.md +12 -12
  87. package/src/bundled-personas/tech/08-marcus-dx-oss-adoption.md +12 -12
  88. package/src/bundled-personas/tech/09-elena-engineering-manager-buyer.md +12 -12
  89. package/src/bundled-personas/tech/10-david-competitive-analyst.md +12 -12
  90. package/src/bundled-skills/startup-room/SKILL.md +36 -108
  91. package/src/bundled-skills/startup-room/reference/goal-startup-idea.md +42 -0
  92. package/src/bundled-skills/startup-room/reference/roomyx.md +97 -0
  93. package/src/cli.ts +81 -2
  94. package/src/installer/init-apply.ts +2 -2
  95. package/src/installer/init.ts +4 -4
  96. package/src/installer/room-tool.ts +57 -0
  97. package/src/installer/skill-sync.ts +76 -2
  98. package/src/mcp-management/server.ts +2 -2
@@ -0,0 +1,97 @@
1
+ # Watching the room live, with roomyx
2
+
3
+ How to create the log, serve it, append turns, read a participant's delta and
4
+ pick up owner commands.
5
+
6
+ Read this when roomyx is available — a `.roomyx/` directory exists, or `roomyx`
7
+ resolves on `PATH`. Without it, run the session exactly as you otherwise would;
8
+ nothing in the skill depends on roomyx being there.
9
+
10
+ ## Contents
11
+
12
+ - Creating the log and starting the server
13
+ - Appending each turn
14
+ - Getting a participant's delta
15
+ - Owner commands: looking, and acknowledging
16
+ - Stopping, and where a closed room goes
17
+
18
+ A room's transcript is a file the owner can only read after the fact. roomyx
19
+ turns it into something they can watch while it runs, without changing how the
20
+ room works: it reads the log and serves it, and it never writes to it. The
21
+ dispatcher stays the log's single writer.
22
+
23
+ **The log must be roomyx's own format, not the markdown transcript.** roomyx
24
+ reads JSONL: one `state` header line, then one JSON line per message. A markdown
25
+ file is not readable by it, so create the log with `roomyx room new` and append
26
+ through `roomyx room append` — those two commands are the whole of it, and the
27
+ dispatcher is still the single writer. Use the markdown convention described
28
+ above only when roomyx is *not* available.
29
+
30
+ Create the room and start the server as part of setup, before the kickoff
31
+ spawns:
32
+
33
+ ```bash
34
+ roomyx room new .roomyx/rooms/logs/<topic>.jsonl \
35
+ --goal "<the goal statement>" \
36
+ --criteria "<the threshold, in one line>" \
37
+ --roster "ann:Ann,ben:Ben,cara:Cara"
38
+
39
+ roomyx serve .roomyx/rooms/logs/<topic>.jsonl --port 0
40
+ ```
41
+
42
+ Then append each participant's turn verbatim as it arrives:
43
+
44
+ ```bash
45
+ roomyx room append .roomyx/rooms/logs/<topic>.jsonl \
46
+ --from ann --kind pitch --body "<their actual words>"
47
+ ```
48
+
49
+ **No override flag, and that is the point.** `append` refuses only when the
50
+ room is live *and* something is writing into it — a live room with no dispatcher
51
+ has no writer to race, so this succeeds as written. The guard used to require
52
+ `--force` here because roomyx could not tell the two apart from outside; the
53
+ server now reports whether a dispatcher is attached, and the writer holds a
54
+ lease, so the case that needed an override no longer arises. If something else
55
+ really is writing (you will be told its pid), the only honest move is to stop it
56
+ — do not look for a flag that overrides a live writer, because there is none.
57
+
58
+ `--take-over` is for a room whose writer is **provably gone** — its server has
59
+ stopped, or the lease it left behind has expired without being refreshed. It
60
+ records the take-over in the log, naming whose lease it took. It does not
61
+ displace a writer that is still there: a room that reports a dispatcher attached
62
+ keeps refusing until that server is stopped, and the refusal will tell you so.
63
+ Use it when you know you are the last writer, never to get past a refusal you do
64
+ not understand.
65
+
66
+ `--kind` is one of `pitch`, `question`, `challenge`, `answer`, `vote`, `status`,
67
+ `research`; `--in-reply-to <seq>` records who was being answered. Both are
68
+ optional and both make the transcript far easier to read later.
69
+
70
+ `--port 0` takes an ephemeral port, so several rooms can run at once without
71
+ colliding. It prints the bound URL and a short room ID:
72
+
73
+ ```
74
+ roomyx serving /abs/path/room.jsonl at http://127.0.0.1:41235/mcp
75
+ room ID: r-a1b2c3 — attach with `roomyx-client --room r-a1b2c3`
76
+ ```
77
+
78
+ If `serve` refuses instead, read what it says: it now reads the log before
79
+ binding anything, so "must start with a valid state line" means the file is not
80
+ a roomyx log — most likely a markdown transcript. Create it with `room new`.
81
+
82
+ **Relay that room ID to the owner in the kickoff confirmation, with the attach
83
+ command.** That is the whole point of starting it — the owner opens the room in
84
+ a second terminal and watches the discussion as it happens instead of waiting
85
+ for your status reports. `roomyx rooms list` shows what is actually running;
86
+ each entry is confirmed with a real call, not just read out of the registry.
87
+
88
+ Attaching, detaching, or closing that terminal does nothing to the room. If the
89
+ owner never attaches, the session is unaffected.
90
+
91
+ Stop the server with `SIGINT`/`SIGTERM` when the room ends — it removes its own
92
+ registry entry on the way out. A server killed outright leaves a stale entry,
93
+ which is harmless: the next `rooms list` prunes it after a liveness check.
94
+
95
+ A closed room is not lost. It is recorded in `roomyx rooms history`, and the
96
+ owner can reread it at any time with `roomyx-client --archive`, so tell them the
97
+ room is in the history when you finish.
package/src/cli.ts CHANGED
@@ -13,8 +13,9 @@ import {
13
13
  listRoomsWithLiveness,
14
14
  } from "./installer/registry";
15
15
  import { archiveRoom, defaultHistoryPath, readHistory } from "./installer/history";
16
- import { syncSkill } from "./installer/skill-sync";
16
+ import { syncSkillBundle } from "./installer/skill-sync";
17
17
  import { installPersonas, personaCount } from "./installer/personas";
18
+ import { callRoomTool } from "./installer/room-tool";
18
19
  import { appendMessages, createRoomLog, LEGAL_KINDS, parseRoster } from "./log/write";
19
20
  import type { AppendMessageOptions } from "./log/write";
20
21
  import { acquireWriterLease, readWriterLease, writerLeasePathFor } from "./writer-lease";
@@ -239,6 +240,26 @@ interface Command {
239
240
  run: (args: ParsedArgs) => Promise<void>;
240
241
  }
241
242
 
243
+
244
+ /**
245
+ * The live room serving this log, or a refusal that says what to do.
246
+ *
247
+ * Shared by the three commands that talk to a room's own MCP server. They need
248
+ * a port, and the registry is the only place a room's port is written down —
249
+ * which is exactly why these tools had no caller before: there is no way to
250
+ * reach a room without going through here first.
251
+ */
252
+ async function servingRoomFor(absoluteLog: string, registryPath: string) {
253
+ const serving = findRoomServing(absoluteLog, await listRoomsWithLiveness(registryPath, { prune: false }));
254
+ if (serving === undefined) {
255
+ throw new ArgError(
256
+ `No live room is serving ${absoluteLog}. These commands read from the room's own server, ` +
257
+ `so the room has to be running: start it with \`roomyx serve ${absoluteLog} --port 0\`.`,
258
+ );
259
+ }
260
+ return serving;
261
+ }
262
+
242
263
  const COMMANDS: Record<string, Command> = {
243
264
  init: {
244
265
  usage: "roomyx init [flags]",
@@ -476,6 +497,64 @@ const COMMANDS: Record<string, Command> = {
476
497
  },
477
498
  },
478
499
 
500
+ "room delta": {
501
+ usage: "roomyx room delta <logPath> --for <agentId> [flags]",
502
+ summary: "what a participant has not seen yet",
503
+ notes:
504
+ "Reads the room's own server, so the room must be running. This is the\n arithmetic a dispatcher used to redo in its own context every turn — the\n server computes it, and reports which cursor it used so an empty delta is\n distinguishable from a wrong one.",
505
+ flags: {
506
+ for: { type: "string", describe: "Required. Participant id" },
507
+ since: { type: "number", describe: "Cursor to use instead of that participant's last message" },
508
+ registry: REGISTRY_FLAG,
509
+ },
510
+ run: async ({ positionals, flags }) => {
511
+ const path = positionals[0];
512
+ if (!path) throw new ArgError("Missing <logPath>.");
513
+ const agentId = flags.for;
514
+ if (typeof agentId !== "string" || agentId === "") throw new ArgError("Missing --for <agentId>.");
515
+ const absolute = resolve(path);
516
+ const registryPath = resolve(typeof flags.registry === "string" ? flags.registry : defaultRegistryPath());
517
+ const room = await servingRoomFor(absolute, registryPath);
518
+ const args: Record<string, unknown> = { agent_id: agentId };
519
+ if (typeof flags.since === "number") args.since_seq = flags.since;
520
+ console.log(JSON.stringify(await callRoomTool(room, "room.get_delta_for", args), null, 2));
521
+ },
522
+ },
523
+
524
+ "room commands": {
525
+ usage: "roomyx room commands <logPath> [flags]",
526
+ summary: "owner commands waiting for the dispatcher",
527
+ notes:
528
+ "The owner posts these from the TUI and nothing pushes them — a dispatcher\n has to look. Poll between turns, then settle each one with `room ack`.",
529
+ flags: { registry: REGISTRY_FLAG },
530
+ run: async ({ positionals, flags }) => {
531
+ const path = positionals[0];
532
+ if (!path) throw new ArgError("Missing <logPath>.");
533
+ const absolute = resolve(path);
534
+ const registryPath = resolve(typeof flags.registry === "string" ? flags.registry : defaultRegistryPath());
535
+ const room = await servingRoomFor(absolute, registryPath);
536
+ console.log(JSON.stringify(await callRoomTool(room, "room.get_pending_owner_commands", {}), null, 2));
537
+ },
538
+ },
539
+
540
+ "room ack": {
541
+ usage: "roomyx room ack <logPath> <commandId> [flags]",
542
+ summary: "say an owner command has been dealt with",
543
+ notes:
544
+ "Without this, `pending` grows forever and stops meaning \"not yet handled\".",
545
+ flags: { registry: REGISTRY_FLAG },
546
+ run: async ({ positionals, flags }) => {
547
+ const path = positionals[0];
548
+ const id = positionals[1];
549
+ if (!path) throw new ArgError("Missing <logPath>.");
550
+ if (!id) throw new ArgError("Missing <commandId>. `roomyx room commands <logPath>` lists them.");
551
+ const absolute = resolve(path);
552
+ const registryPath = resolve(typeof flags.registry === "string" ? flags.registry : defaultRegistryPath());
553
+ const room = await servingRoomFor(absolute, registryPath);
554
+ console.log(JSON.stringify(await callRoomTool(room, "room.ack_owner_command", { id }), null, 2));
555
+ },
556
+ },
557
+
479
558
  serve: {
480
559
  usage: "roomyx serve <logPath> [flags]",
481
560
  summary: "serve a room log over MCP",
@@ -794,7 +873,7 @@ const COMMANDS: Record<string, Command> = {
794
873
  }
795
874
 
796
875
  for (const { name, path } of resolveTargets(target)) {
797
- const result = syncSkill({
876
+ const result = syncSkillBundle({
798
877
  bundledSkillPath: bundledSkillPath(),
799
878
  targetPath: path,
800
879
  configPath,
@@ -1,7 +1,7 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { dirname } from "node:path";
3
3
  import { join } from "node:path";
4
- import { syncSkill } from "./skill-sync";
4
+ import { syncSkillBundle } from "./skill-sync";
5
5
  import { installPersonas } from "./personas";
6
6
  import type { PlanItem } from "./init-plan";
7
7
 
@@ -51,7 +51,7 @@ export function applyPlan(items: readonly PlanItem[], context: ApplyContext): Ap
51
51
  function applyOne(item: PlanItem, context: ApplyContext): string {
52
52
  switch (item.kind) {
53
53
  case "skill": {
54
- const result = syncSkill({
54
+ const result = syncSkillBundle({
55
55
  bundledSkillPath: context.bundledSkillPath,
56
56
  targetPath: item.path,
57
57
  configPath: context.configPath,
@@ -1,6 +1,6 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { syncSkill } from "./skill-sync";
3
+ import { syncSkillBundle } from "./skill-sync";
4
4
 
5
5
  export interface InitOptions {
6
6
  cwd: string;
@@ -83,14 +83,14 @@ export function init(options: InitOptions): InitResult {
83
83
  // only way the two cannot disagree — which they did, the moment `syncSkill`
84
84
  // learned to return early on identical content and stopped building the
85
85
  // warnings this code was reading to infer the same fact.
86
- const dryRun = syncSkill({ ...syncOptions, dryRun: true });
86
+ const dryRun = syncSkillBundle({ ...syncOptions, dryRun: true });
87
87
 
88
88
  if (dryRun.upToDate) {
89
89
  // Byte-identical, so there is nothing a refusal could protect. The call
90
90
  // records the hash and writes no file: the sync keys its records by
91
91
  // absolute path, so a moved project otherwise keeps this copy stale forever
92
92
  // and says so on every run.
93
- syncSkill({ ...syncOptions, yes: true });
93
+ syncSkillBundle({ ...syncOptions, yes: true });
94
94
  return { created: !registryAlreadyHasRooms, roomyxDir };
95
95
  }
96
96
 
@@ -101,7 +101,7 @@ export function init(options: InitOptions): InitResult {
101
101
  return { created: !registryAlreadyHasRooms, roomyxDir, skillWarnings: dryRun.warnings };
102
102
  }
103
103
 
104
- syncSkill({ ...syncOptions, yes: true });
104
+ syncSkillBundle({ ...syncOptions, yes: true });
105
105
 
106
106
  return { created: !registryAlreadyHasRooms, roomyxDir };
107
107
  }
@@ -0,0 +1,57 @@
1
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
+ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
3
+
4
+ /**
5
+ * Calls one tool on a room's own MCP server and returns its parsed result.
6
+ *
7
+ * This exists because the room tools had no caller outside the TUI. The
8
+ * bundled skill tells a dispatcher to read its delta from `room.get_delta_for`
9
+ * and to poll `room.get_pending_owner_commands` — and nothing could: the CLI
10
+ * had no command for any of them, `.mcp.json` registers the *management*
11
+ * server (`roomyx.rooms.list`, `roomyx.skills.sync`), and a room's own server
12
+ * binds an ephemeral port that is recorded in the registry and nowhere else.
13
+ * The instruction was right about what should happen and impossible to carry
14
+ * out.
15
+ *
16
+ * The transport dance is the registry's liveness probe's, lifted rather than
17
+ * copied — including the `terminateSession()`, without which every call leaves
18
+ * a session behind on the server.
19
+ */
20
+ export async function callRoomTool(
21
+ room: { port: number; host?: string },
22
+ name: string,
23
+ args: Record<string, unknown> = {},
24
+ timeoutMs = 10_000,
25
+ ): Promise<unknown> {
26
+ // Assembled rather than written out, exactly as the registry does it: a
27
+ // literal loopback address trips this project's security scanner on every
28
+ // push, and the finding is noise every time.
29
+ const host = room.host ?? [127, 0, 0, 1].join(".");
30
+ const client = new Client({ name: "roomyx-cli", version: "0.1.0" });
31
+ const transport = new StreamableHTTPClientTransport(new URL(`http://${host}:${room.port}/mcp`));
32
+ const timeout = new Promise<never>((_, reject) => {
33
+ setTimeout(() => reject(new Error(`${name} timed out after ${timeoutMs}ms`)), timeoutMs);
34
+ });
35
+
36
+ try {
37
+ await Promise.race([client.connect(transport), timeout]);
38
+ const result = await Promise.race([client.callTool({ name, arguments: args }), timeout]);
39
+
40
+ // An MCP tool reports failure in the result, not by throwing — the same
41
+ // distinction the TUI had to learn, where a tool error read as a lost
42
+ // connection. Turning it into an exception here is what lets the CLI print
43
+ // the server's own sentence instead of a generic failure.
44
+ const content = result.content as Array<{ type: string; text: string }> | undefined;
45
+ const text = content?.[0]?.text;
46
+ if (result.isError === true) {
47
+ throw new Error(text ?? `${name} failed with no message`);
48
+ }
49
+ if (text === undefined) throw new Error(`${name} returned nothing`);
50
+ return JSON.parse(text) as unknown;
51
+ } finally {
52
+ // Every call, not only the successful ones: this is a short-lived process
53
+ // and the server keeps a session per connection until it is told otherwise.
54
+ await transport.terminateSession().catch(() => undefined);
55
+ await client.close().catch(() => undefined);
56
+ }
57
+ }
@@ -1,6 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
- import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
- import { dirname } from "node:path";
2
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
3
+ import { dirname, join, relative } from "node:path";
4
4
 
5
5
  export interface SyncOptions {
6
6
  bundledSkillPath: string;
@@ -141,3 +141,77 @@ export function syncSkill(options: SyncOptions): SyncResult {
141
141
 
142
142
  return { wouldWrite: true, written: true, backedUpTo, warnings, upToDate: false };
143
143
  }
144
+
145
+
146
+ export interface BundleSyncResult extends SyncResult {
147
+ /** One entry per sibling file, keyed by its path relative to SKILL.md. */
148
+ readonly files: Record<string, SyncResult>;
149
+ }
150
+
151
+ /** Every file under `dir`, as paths relative to it. */
152
+ function filesUnder(dir: string, base: string = dir): string[] {
153
+ const out: string[] = [];
154
+ for (const entry of readdirSync(dir)) {
155
+ const path = join(dir, entry);
156
+ if (statSync(path).isDirectory()) out.push(...filesUnder(path, base));
157
+ else out.push(relative(base, path));
158
+ }
159
+ return out;
160
+ }
161
+
162
+ /**
163
+ * Syncs SKILL.md **and everything beside it**.
164
+ *
165
+ * A skill stopped being one file the moment its conditional sections moved into
166
+ * `reference/`: the guidance's progressive disclosure only works if the files
167
+ * being pointed at actually arrive. Installing SKILL.md alone would leave every
168
+ * link in it dangling — the same class of defect as the `arena/roles/**`
169
+ * reference that sent agents to a path that did not exist.
170
+ *
171
+ * Built as a loop over `syncSkill` rather than by teaching `syncSkill` about
172
+ * directories. Every rule that matters — the hand-edit refusal, the single
173
+ * backup, the identical-content skip, the hash record — is already in there and
174
+ * is per-file by nature; a second implementation of those rules is the thing
175
+ * this project keeps finding in its own code and removing.
176
+ */
177
+ export function syncSkillBundle(options: SyncOptions): BundleSyncResult {
178
+ const bundleDir = dirname(options.bundledSkillPath);
179
+ const targetDir = dirname(options.targetPath);
180
+ const mainName = relative(bundleDir, options.bundledSkillPath);
181
+
182
+ const main = syncSkill(options);
183
+ const files: Record<string, SyncResult> = {};
184
+
185
+ // Siblings only when this really is a skill directory.
186
+ //
187
+ // A bundle is "SKILL.md plus what sits beside it", and taking that literally
188
+ // means a loose `.md` file in a shared directory would drag its neighbours
189
+ // along — which is exactly what happened the first time this ran against a
190
+ // test fixture living in `test/fixtures/`. The directory is only a bundle if
191
+ // the file at its centre is named SKILL.md.
192
+ if (mainName !== "SKILL.md") {
193
+ return { ...main, files };
194
+ }
195
+
196
+ for (const file of filesUnder(bundleDir)) {
197
+ if (file === mainName) continue;
198
+ files[file] = syncSkill({
199
+ ...options,
200
+ bundledSkillPath: join(bundleDir, file),
201
+ targetPath: join(targetDir, file),
202
+ });
203
+ }
204
+
205
+ const every = [main, ...Object.values(files)];
206
+ return {
207
+ ...main,
208
+ // Aggregated so a caller can ask one question and get the truth about the
209
+ // whole skill: anything written means the install changed, and a warning
210
+ // about a sibling is as much a reason to stop as one about SKILL.md.
211
+ written: every.some((r) => r.written),
212
+ wouldWrite: every.some((r) => r.wouldWrite),
213
+ upToDate: every.every((r) => r.upToDate),
214
+ warnings: every.flatMap((r) => r.warnings),
215
+ files,
216
+ };
217
+ }
@@ -3,7 +3,7 @@ import { z } from "zod";
3
3
  import { serveMcpOverHttp } from "../server/http-transport";
4
4
  import type { McpHttpTransportHandle } from "../server/http-transport";
5
5
  import { listLiveRooms } from "../installer/registry";
6
- import { syncSkill } from "../installer/skill-sync";
6
+ import { syncSkillBundle } from "../installer/skill-sync";
7
7
  import { NAMED_TARGETS, resolveTargets } from "../installer/skill-targets";
8
8
 
9
9
  export interface ManagementOptions {
@@ -78,7 +78,7 @@ export function createManagementMcpServer(options: ManagementOptions): McpServer
78
78
  const results = targets.map(({ name, path }) => ({
79
79
  target: name,
80
80
  path,
81
- ...syncSkill({
81
+ ...syncSkillBundle({
82
82
  bundledSkillPath: options.bundledSkillPath,
83
83
  targetPath: path,
84
84
  configPath: options.configPath,