@mrciphersmith/roomyx 0.12.1 → 0.12.3
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 +129 -0
- package/README.md +140 -12
- package/package.json +11 -10
- package/src/bin/launch.mjs +1 -1
- package/src/bundled-personas/groups.md +3 -3
- package/src/bundled-skills/startup-room/reference/roomyx.md +5 -0
- package/src/cli/client.ts +12 -0
- package/src/cli/experiment.ts +67 -0
- package/src/cli/init.ts +149 -0
- package/src/cli/mcp.ts +54 -0
- package/src/cli/personas.ts +40 -0
- package/src/cli/room-append.ts +357 -0
- package/src/cli/room.ts +91 -0
- package/src/cli/rooms.ts +65 -0
- package/src/cli/serve.ts +84 -0
- package/src/cli/shared.ts +71 -0
- package/src/cli/skills.ts +58 -0
- package/src/cli/specs.ts +1 -0
- package/src/cli.ts +29 -884
- package/src/client/index.ts +16 -3
- package/src/client/mcp-client.ts +106 -7
- package/src/client/shutdown.ts +29 -6
- package/src/experiment/manifest.ts +151 -0
- package/src/installer/init-apply.ts +38 -7
- package/src/installer/init.ts +5 -2
- package/src/installer/registry.ts +38 -6
- package/src/installer/resolve-connection.ts +54 -8
- package/src/installer/room-tool.ts +6 -3
- package/src/installer/skill-sync.ts +86 -3
- package/src/installer/skill-targets.ts +7 -3
- package/src/lockfile.ts +13 -2
- package/src/log/schema.ts +108 -38
- package/src/log/store.ts +1 -0
- package/src/log/types.ts +8 -1
- package/src/log/write.ts +115 -6
- package/src/mcp-management/server.ts +30 -4
- package/src/room-token.ts +129 -0
- package/src/server/http-transport.ts +43 -0
- package/src/server/index.ts +76 -3
- package/src/server/log-watcher.ts +80 -0
- package/src/server/owner-queue.ts +7 -1
- package/src/server/serve.ts +112 -30
- package/src/server/shutdown.ts +33 -7
- package/src/writer-lease.ts +161 -14
package/src/cli/room.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { callRoomTool } from "../installer/room-tool";
|
|
3
|
+
import { createRoomLog, parseRoster } from "../log/write";
|
|
4
|
+
import { ArgError } from "./args";
|
|
5
|
+
import { REGISTRY_FLAG, defaultRegistryPath, servingRoomFor } from "./shared";
|
|
6
|
+
import type { Command } from "./shared";
|
|
7
|
+
|
|
8
|
+
export const roomNew: Command = {
|
|
9
|
+
usage: "roomyx room new <path> --goal <statement> [flags]",
|
|
10
|
+
summary: "create a room log",
|
|
11
|
+
notes: "Refuses to overwrite an existing log — a room log is append-only.",
|
|
12
|
+
flags: {
|
|
13
|
+
goal: { type: "string", describe: "Required. What the room is for, in one sentence" },
|
|
14
|
+
criteria: { type: "string", describe: "Success criteria, stored in the goal contract" },
|
|
15
|
+
roster: { type: "string", describe: "Participants, as id:Name,id2:Name2" },
|
|
16
|
+
},
|
|
17
|
+
run: async ({ positionals, flags }) => {
|
|
18
|
+
const path = positionals[0];
|
|
19
|
+
if (!path) throw new ArgError("Missing <path>.");
|
|
20
|
+
const goalStatement = flags.goal;
|
|
21
|
+
if (typeof goalStatement !== "string") {
|
|
22
|
+
throw new ArgError("Missing --goal. A room without a stated goal has nothing to converge on.");
|
|
23
|
+
}
|
|
24
|
+
const absolute = resolve(path);
|
|
25
|
+
createRoomLog(absolute, {
|
|
26
|
+
goalStatement,
|
|
27
|
+
criteria: typeof flags.criteria === "string" ? flags.criteria : undefined,
|
|
28
|
+
roster: typeof flags.roster === "string" ? parseRoster(flags.roster) : [],
|
|
29
|
+
});
|
|
30
|
+
console.log(`Created ${absolute}`);
|
|
31
|
+
console.log(`serve it with \`roomyx serve ${path}\``);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const roomDelta: Command = {
|
|
36
|
+
usage: "roomyx room delta <logPath> --for <agentId> [flags]",
|
|
37
|
+
summary: "what a participant has not seen yet",
|
|
38
|
+
notes:
|
|
39
|
+
"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.",
|
|
40
|
+
flags: {
|
|
41
|
+
for: { type: "string", describe: "Required. Participant id" },
|
|
42
|
+
since: { type: "number", describe: "Cursor to use instead of that participant's last message" },
|
|
43
|
+
registry: REGISTRY_FLAG,
|
|
44
|
+
},
|
|
45
|
+
run: async ({ positionals, flags }) => {
|
|
46
|
+
const path = positionals[0];
|
|
47
|
+
if (!path) throw new ArgError("Missing <logPath>.");
|
|
48
|
+
const agentId = flags.for;
|
|
49
|
+
if (typeof agentId !== "string" || agentId === "") throw new ArgError("Missing --for <agentId>.");
|
|
50
|
+
const absolute = resolve(path);
|
|
51
|
+
const registryPath = resolve(typeof flags.registry === "string" ? flags.registry : defaultRegistryPath());
|
|
52
|
+
const room = await servingRoomFor(absolute, registryPath);
|
|
53
|
+
const args: Record<string, unknown> = { agent_id: agentId };
|
|
54
|
+
if (typeof flags.since === "number") args.since_seq = flags.since;
|
|
55
|
+
console.log(JSON.stringify(await callRoomTool(room, "room.get_delta_for", args), null, 2));
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const roomCommands: Command = {
|
|
60
|
+
usage: "roomyx room commands <logPath> [flags]",
|
|
61
|
+
summary: "owner commands waiting for the dispatcher",
|
|
62
|
+
notes:
|
|
63
|
+
"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`.",
|
|
64
|
+
flags: { registry: REGISTRY_FLAG },
|
|
65
|
+
run: async ({ positionals, flags }) => {
|
|
66
|
+
const path = positionals[0];
|
|
67
|
+
if (!path) throw new ArgError("Missing <logPath>.");
|
|
68
|
+
const absolute = resolve(path);
|
|
69
|
+
const registryPath = resolve(typeof flags.registry === "string" ? flags.registry : defaultRegistryPath());
|
|
70
|
+
const room = await servingRoomFor(absolute, registryPath);
|
|
71
|
+
console.log(JSON.stringify(await callRoomTool(room, "room.get_pending_owner_commands", {}), null, 2));
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const roomAck: Command = {
|
|
76
|
+
usage: "roomyx room ack <logPath> <commandId> [flags]",
|
|
77
|
+
summary: "say an owner command has been dealt with",
|
|
78
|
+
notes:
|
|
79
|
+
"Without this, `pending` grows forever and stops meaning \"not yet handled\".",
|
|
80
|
+
flags: { registry: REGISTRY_FLAG },
|
|
81
|
+
run: async ({ positionals, flags }) => {
|
|
82
|
+
const path = positionals[0];
|
|
83
|
+
const id = positionals[1];
|
|
84
|
+
if (!path) throw new ArgError("Missing <logPath>.");
|
|
85
|
+
if (!id) throw new ArgError("Missing <commandId>. `roomyx room commands <logPath>` lists them.");
|
|
86
|
+
const absolute = resolve(path);
|
|
87
|
+
const registryPath = resolve(typeof flags.registry === "string" ? flags.registry : defaultRegistryPath());
|
|
88
|
+
const room = await servingRoomFor(absolute, registryPath);
|
|
89
|
+
console.log(JSON.stringify(await callRoomTool(room, "room.ack_owner_command", { id }), null, 2));
|
|
90
|
+
},
|
|
91
|
+
};
|
package/src/cli/rooms.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { listRoomsWithLiveness } from "../installer/registry";
|
|
2
|
+
import { defaultHistoryPath, readHistory } from "../installer/history";
|
|
3
|
+
import { REGISTRY_FLAG, defaultRegistryPath } from "./shared";
|
|
4
|
+
import type { Command } from "./shared";
|
|
5
|
+
|
|
6
|
+
export const roomsList: Command = {
|
|
7
|
+
usage: "roomyx rooms list [flags]",
|
|
8
|
+
summary: "live rooms, confirmed by a real call rather than by the file",
|
|
9
|
+
flags: { registry: REGISTRY_FLAG },
|
|
10
|
+
run: async ({ flags }) => {
|
|
11
|
+
// `--registry` used to be accepted here and silently ignored: this
|
|
12
|
+
// command took no arguments at all and read the default path, so
|
|
13
|
+
// `rooms list --registry /nonexistent.json` printed "No live rooms"
|
|
14
|
+
// about a different file.
|
|
15
|
+
const registryPath = typeof flags.registry === "string" ? flags.registry : defaultRegistryPath();
|
|
16
|
+
const { live, unconfirmed } = await listRoomsWithLiveness(registryPath);
|
|
17
|
+
if (live.length === 0 && unconfirmed.length === 0) {
|
|
18
|
+
// An empty registry and a registry whose rooms did not answer are
|
|
19
|
+
// different facts, and the second used to print this same sentence —
|
|
20
|
+
// which is how a serving room came to look like no room at all.
|
|
21
|
+
console.log("No live rooms.");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
for (const room of live) {
|
|
25
|
+
console.log(`${room.id} port=${room.port} log=${room.logPath} started=${room.startedAt}`);
|
|
26
|
+
}
|
|
27
|
+
for (const room of unconfirmed) {
|
|
28
|
+
// Kept in the registry, not claimed live: the probe did not answer, and
|
|
29
|
+
// "did not answer" is not permission to delete a room that may be
|
|
30
|
+
// serving. Named so the reader knows what to re-check.
|
|
31
|
+
console.log(
|
|
32
|
+
`${room.id} port=${room.port} log=${room.logPath} started=${room.startedAt} did not answer — still registered`,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const roomsHistory: Command = {
|
|
39
|
+
usage: "roomyx rooms history [flags]",
|
|
40
|
+
summary: "rooms that have closed, newest first",
|
|
41
|
+
notes:
|
|
42
|
+
"History records what a room was and where its log is — it does not copy\n the log. Reopen one read-only with `roomyx-client --open <logPath>`, or\n pick from the list with `roomyx-client --archive`.",
|
|
43
|
+
flags: { registry: REGISTRY_FLAG },
|
|
44
|
+
run: async ({ flags }) => {
|
|
45
|
+
const registryPath = typeof flags.registry === "string" ? flags.registry : defaultRegistryPath();
|
|
46
|
+
const { rooms, unreadable } = readHistory(defaultHistoryPath(registryPath));
|
|
47
|
+
if (rooms.length === 0) {
|
|
48
|
+
console.log("No closed rooms recorded yet.");
|
|
49
|
+
}
|
|
50
|
+
for (const room of rooms) {
|
|
51
|
+
const when = room.closedAt.slice(0, 16).replace("T", " ");
|
|
52
|
+
const goal = room.goal === "" ? "(goal unavailable)" : room.goal;
|
|
53
|
+
console.log(
|
|
54
|
+
`${room.id} closed=${when} messages=${room.messages} participants=${room.participants} ${goal}`,
|
|
55
|
+
);
|
|
56
|
+
// The path on its own line: it is the argument to --open, and a goal
|
|
57
|
+
// statement is long enough that putting them on one line means the
|
|
58
|
+
// thing you have to copy is the thing that gets wrapped.
|
|
59
|
+
console.log(` ${room.logPath}${room.logExists ? "" : " (log no longer at this path)"}`);
|
|
60
|
+
}
|
|
61
|
+
if (unreadable > 0) {
|
|
62
|
+
console.log(`\n${unreadable} history line(s) could not be read and were skipped.`);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
};
|
package/src/cli/serve.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { serve } from "../server/serve";
|
|
3
|
+
import { registerRoom, deregisterRoom } from "../installer/registry";
|
|
4
|
+
import { archiveRoom, defaultHistoryPath } from "../installer/history";
|
|
5
|
+
import { ArgError } from "./args";
|
|
6
|
+
import { REGISTRY_FLAG, defaultRegistryPath, runUntilSignal } from "./shared";
|
|
7
|
+
import type { Command } from "./shared";
|
|
8
|
+
|
|
9
|
+
export const serveCommand: Command = {
|
|
10
|
+
usage: "roomyx serve <logPath> [flags]",
|
|
11
|
+
summary: "serve a room log over MCP",
|
|
12
|
+
flags: {
|
|
13
|
+
port: { type: "number", describe: "Listen port (default 4319; 0 picks an ephemeral one)" },
|
|
14
|
+
host: { type: "string", describe: "Bind address (default 127.0.0.1)" },
|
|
15
|
+
"acknowledge-non-loopback": { type: "boolean", describe: "Required to bind a non-loopback host" },
|
|
16
|
+
registry: REGISTRY_FLAG,
|
|
17
|
+
},
|
|
18
|
+
run: async ({ positionals, flags }) => {
|
|
19
|
+
const logPath = positionals[0];
|
|
20
|
+
if (!logPath) throw new ArgError("Missing <logPath>.");
|
|
21
|
+
|
|
22
|
+
// Absolute, because the registry outlives this process's working
|
|
23
|
+
// directory: `roomyx-client` resolves rooms from wherever the person
|
|
24
|
+
// happened to run it, and a relative logPath means nothing there.
|
|
25
|
+
const absoluteLogPath = resolve(logPath);
|
|
26
|
+
// Resolved before binding: the writer lease lives beside the registry, and
|
|
27
|
+
// a server that acquires one after it starts answering would leave a
|
|
28
|
+
// window where a live dispatcher looks like no writer at all.
|
|
29
|
+
const registryPath = typeof flags.registry === "string" ? flags.registry : defaultRegistryPath();
|
|
30
|
+
const handle = await serve(absoluteLogPath, {
|
|
31
|
+
port: typeof flags.port === "number" ? flags.port : undefined,
|
|
32
|
+
host: typeof flags.host === "string" ? flags.host : undefined,
|
|
33
|
+
acknowledgeNonLoopback: flags["acknowledge-non-loopback"] === true,
|
|
34
|
+
// No `writerLeasePath`, deliberately, and this is worth stating because
|
|
35
|
+
// it was passed here and silently discarded on every serve.
|
|
36
|
+
//
|
|
37
|
+
// `serve()` takes the lease only when a dispatcher is attached, and
|
|
38
|
+
// "attached" means an *embedder* supplied an `onOwnerCommand` callback.
|
|
39
|
+
// `roomyx serve` never supplies one — an agent dispatcher has no
|
|
40
|
+
// callback to give; it reads `room.get_pending_owner_commands` instead.
|
|
41
|
+
// So the argument could never be used, while reading like a lease was
|
|
42
|
+
// being taken.
|
|
43
|
+
//
|
|
44
|
+
// Making the CLI declare a dispatcher was tried and is WRONG: the lease
|
|
45
|
+
// would be held by the server process, while the writer is the agent
|
|
46
|
+
// running `roomyx room append` in a different process each time — so
|
|
47
|
+
// the dispatcher would be locked out of its own room. Two dispatcher
|
|
48
|
+
// models exist (embedder writes in-process; agent writes by CLI) and
|
|
49
|
+
// only the first is expressible today. Recorded rather than patched.
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const entry = registerRoom(registryPath, {
|
|
53
|
+
port: handle.port,
|
|
54
|
+
logPath: absoluteLogPath,
|
|
55
|
+
pid: process.pid,
|
|
56
|
+
// The token goes where the port goes. Anything that can find this room
|
|
57
|
+
// can find its credential, and nothing else has to be told — which is the
|
|
58
|
+
// whole of how `roomyx-client`, `rooms list` and the room commands keep
|
|
59
|
+
// working without a new argument between them.
|
|
60
|
+
token: handle.token,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Deliberately NOT printed. The port and the room id are the two things a
|
|
64
|
+
// person needs and the two things they paste into a terminal, an issue or a
|
|
65
|
+
// chat; the token is a credential, and stdout is a scrollback, a CI log and
|
|
66
|
+
// a `tee`. Whoever needs it reads the registry entry.
|
|
67
|
+
console.log(`roomyx serving ${absoluteLogPath} at ${handle.url}`);
|
|
68
|
+
console.log(`room ID: ${entry.id} — attach with \`roomyx-client --room ${entry.id}\``);
|
|
69
|
+
|
|
70
|
+
runUntilSignal(
|
|
71
|
+
() => handle.close(),
|
|
72
|
+
() => {
|
|
73
|
+
// Archive before deregistering, not after: `archiveRoom` reads the
|
|
74
|
+
// log to summarise it, and it reads better while the entry that says
|
|
75
|
+
// where the log is still exists. The order also means a crash
|
|
76
|
+
// between the two leaves the room recorded in history and still in
|
|
77
|
+
// the registry, which the next prune resolves — rather than gone
|
|
78
|
+
// from both.
|
|
79
|
+
archiveRoom(defaultHistoryPath(registryPath), entry);
|
|
80
|
+
deregisterRoom(registryPath, entry.id);
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { createServerShutdown } from "../server/shutdown";
|
|
3
|
+
import { findRoomServing, listRoomsWithLiveness } from "../installer/registry";
|
|
4
|
+
import { ArgError } from "./args";
|
|
5
|
+
import type { FlagSpecs, ParsedArgs } from "./args";
|
|
6
|
+
|
|
7
|
+
export function defaultRegistryPath(): string {
|
|
8
|
+
return join(process.cwd(), ".roomyx", "rooms", "registry.json");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function defaultConfigPath(): string {
|
|
12
|
+
return join(process.cwd(), ".roomyx", "config.json");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function bundledSkillPath(): string {
|
|
16
|
+
return join(import.meta.dir, "..", "bundled-skills", "startup-room", "SKILL.md");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function bundledPersonasPath(): string {
|
|
20
|
+
return join(import.meta.dir, "..", "bundled-personas");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const REGISTRY_FLAG = { type: "string", describe: "Registry file (default .roomyx/rooms/registry.json)" } as const;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Wires the signals. The shutdown itself lives in `../server/shutdown`, where a
|
|
27
|
+
* test can reach it — this module runs its entry point on import.
|
|
28
|
+
*
|
|
29
|
+
* Written once because there were three copies and they had drifted: the two
|
|
30
|
+
* here handled SIGINT and SIGTERM and guarded nothing, while the client handled
|
|
31
|
+
* SIGHUP as well and guarded re-entry. So closing a terminal (SIGHUP) killed
|
|
32
|
+
* `roomyx serve` outright, skipping deregistration and leaving a stale registry
|
|
33
|
+
* entry — which a recycled port then resurrects as a live room.
|
|
34
|
+
*
|
|
35
|
+
* `cleanup` runs *after* the close resolves, not before. Deregistering first
|
|
36
|
+
* meant a shutdown that hung — and it hung whenever a client was attached —
|
|
37
|
+
* removed the room from the registry while the process kept running and kept
|
|
38
|
+
* the port. The room became invisible while still being served.
|
|
39
|
+
*/
|
|
40
|
+
export function runUntilSignal(close: () => Promise<void>, cleanup: () => void = () => undefined): void {
|
|
41
|
+
const shutdown = createServerShutdown(close, cleanup);
|
|
42
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"] as const) process.on(signal, shutdown);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface Command {
|
|
46
|
+
usage: string;
|
|
47
|
+
summary: string;
|
|
48
|
+
/** Extra lines under the flag table. */
|
|
49
|
+
notes?: string;
|
|
50
|
+
flags: FlagSpecs;
|
|
51
|
+
run: (args: ParsedArgs) => Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The live room serving this log, or a refusal that says what to do.
|
|
56
|
+
*
|
|
57
|
+
* Shared by the three commands that talk to a room's own MCP server. They need
|
|
58
|
+
* a port, and the registry is the only place a room's port is written down —
|
|
59
|
+
* which is exactly why these tools had no caller before: there is no way to
|
|
60
|
+
* reach a room without going through here first.
|
|
61
|
+
*/
|
|
62
|
+
export async function servingRoomFor(absoluteLog: string, registryPath: string) {
|
|
63
|
+
const serving = findRoomServing(absoluteLog, await listRoomsWithLiveness(registryPath, { prune: false }));
|
|
64
|
+
if (serving === undefined) {
|
|
65
|
+
throw new ArgError(
|
|
66
|
+
`No live room is serving ${absoluteLog}. These commands read from the room's own server, ` +
|
|
67
|
+
`so the room has to be running: start it with \`roomyx serve ${absoluteLog} --port 0\`.`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return serving;
|
|
71
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { syncSkillBundle } from "../installer/skill-sync";
|
|
3
|
+
import { NAMED_TARGETS, resolveTargets } from "../installer/skill-targets";
|
|
4
|
+
import { ArgError } from "./args";
|
|
5
|
+
import { bundledSkillPath, defaultConfigPath } from "./shared";
|
|
6
|
+
import type { Command } from "./shared";
|
|
7
|
+
|
|
8
|
+
export const skillsSync: Command = {
|
|
9
|
+
usage: "roomyx skills sync --target <runtime|all|path> [flags]",
|
|
10
|
+
summary: "install the bundled startup-room skill",
|
|
11
|
+
notes:
|
|
12
|
+
"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.",
|
|
13
|
+
flags: {
|
|
14
|
+
target: { type: "string", describe: `Required. ${NAMED_TARGETS.join(", ")}, all, or a literal path` },
|
|
15
|
+
yes: { type: "boolean", describe: "Actually write" },
|
|
16
|
+
"dry-run": { type: "boolean", describe: "Report only (the default)" },
|
|
17
|
+
config: { type: "string", describe: "Config file the sync records hashes in" },
|
|
18
|
+
},
|
|
19
|
+
run: async ({ flags }) => {
|
|
20
|
+
const target = flags.target;
|
|
21
|
+
if (typeof target !== "string") {
|
|
22
|
+
throw new ArgError(`Missing --target. Expected one of ${NAMED_TARGETS.join(", ")}, all, or a path.`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const yes = flags.yes === true;
|
|
26
|
+
// The gate itself lives in `syncSkill` now, computed once for every
|
|
27
|
+
// surface — this line only forwards what the operator typed.
|
|
28
|
+
const dryRun = flags["dry-run"] === true;
|
|
29
|
+
const configPath = typeof flags.config === "string" ? flags.config : defaultConfigPath();
|
|
30
|
+
if (!existsSync(configPath)) {
|
|
31
|
+
throw new ArgError(`No ${configPath}. Run \`roomyx init\` first.`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
for (const { name, path } of resolveTargets(target)) {
|
|
35
|
+
const result = syncSkillBundle({
|
|
36
|
+
bundledSkillPath: bundledSkillPath(),
|
|
37
|
+
targetPath: path,
|
|
38
|
+
configPath,
|
|
39
|
+
dryRun,
|
|
40
|
+
yes,
|
|
41
|
+
});
|
|
42
|
+
console.log(name === path ? path : `${name}: ${path}`);
|
|
43
|
+
for (const warning of result.warnings) console.log(` warning: ${warning}`);
|
|
44
|
+
if (result.upToDate) {
|
|
45
|
+
console.log(" already in sync — nothing written, no backup made");
|
|
46
|
+
} else if (result.written) {
|
|
47
|
+
console.log(result.backedUpTo ? ` written (backup: ${result.backedUpTo})` : " written");
|
|
48
|
+
} else {
|
|
49
|
+
// "not written" was the message whenever `dryRun` was false, which
|
|
50
|
+
// after the gate moved into syncSkill meant the ordinary
|
|
51
|
+
// no-flags run reported a bare refusal instead of the sentence that
|
|
52
|
+
// says how to proceed. Branch on why nothing was written, not on
|
|
53
|
+
// which flag was passed.
|
|
54
|
+
console.log(result.wouldWrite ? " would write (pass --yes to apply)" : " not written");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
};
|
package/src/cli/specs.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { FlagSpecs } from "./args";
|
|
|
12
12
|
export const CLIENT_FLAGS: FlagSpecs = {
|
|
13
13
|
room: { type: "string", describe: "Attach to a specific live room by id" },
|
|
14
14
|
connect: { type: "string", describe: "Attach to an explicit MCP URL; the registry is not consulted" },
|
|
15
|
+
token: { type: "string", describe: "The room's token, when --connect names a room this registry does not know" },
|
|
15
16
|
registry: { type: "string", describe: "Registry file (default .roomyx/rooms/registry.json)" },
|
|
16
17
|
open: { type: "string", describe: "Reread a closed room from its log file, read-only" },
|
|
17
18
|
archive: { type: "boolean", describe: "Pick a closed room from the history index" },
|