@mrciphersmith/roomyx 0.10.3 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/README.md +50 -0
- package/package.json +1 -1
- package/src/cli.ts +83 -3
- package/src/installer/init-plan.ts +37 -12
- package/src/installer/skill-targets.ts +13 -5
- package/src/log/schema.ts +76 -8
- package/src/log/store.ts +57 -8
- package/src/log/types.ts +14 -1
- package/src/log/write.ts +18 -32
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,74 @@ 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.11.1] — 2026-09-10
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **`roomyx setup`** — the machine-wide half of `roomyx init`, for when there is
|
|
21
|
+
no project yet. Same picker, narrowed to the rows that land on the machine
|
|
22
|
+
(the skill for each runtime, and the persona library under `~/.roomyx`), and
|
|
23
|
+
it writes nothing into the working directory. This is what to run straight
|
|
24
|
+
after installing from npm: an npm lifecycle script cannot ask, because npm
|
|
25
|
+
runs one with no terminal in CI, `npm ci` and Docker, and skips it entirely
|
|
26
|
+
under `--ignore-scripts`.
|
|
27
|
+
- The persona library is ticked in `setup` and unticked in `init`, and the
|
|
28
|
+
difference is the point: in a project the machine-wide copy duplicates one the
|
|
29
|
+
project already gets and the skill prefers, but `setup` has no project copy to
|
|
30
|
+
fall back on.
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- **`done` on a plan item meant two things at once.** It meant "already
|
|
35
|
+
installed", and also carried the persona file count — so a caller asking "is
|
|
36
|
+
this already there?" read `87 files` as yes. `roomyx setup` was that caller,
|
|
37
|
+
and it silently stopped ticking the persona library. The count moved to
|
|
38
|
+
`detail`, where a description belongs.
|
|
39
|
+
- **`buildPlan({ home })` was honoured by the persona rows and ignored by the
|
|
40
|
+
skill rows**, which read `homedir()` inside the runtime table. A test
|
|
41
|
+
asserting "nothing here lands outside this directory" was passing against the
|
|
42
|
+
real `~`. The home is a parameter now, and the test means what it says.
|
|
43
|
+
|
|
44
|
+
## [0.11.0] — 2026-09-10
|
|
45
|
+
|
|
46
|
+
A minor, for the reason D-13 gives: `room.get_state` now returns a **changed
|
|
47
|
+
result for a caller who asked for nothing different**. The log format also gained
|
|
48
|
+
an optional field and two message kinds, which is additive on its own.
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- **A room's state can change.** `goal_edit` and `add_participant` are message
|
|
53
|
+
kinds carrying the change in a new optional `change` field, and
|
|
54
|
+
`room.get_state` folds them: the header, then every edit in `seq` order, last
|
|
55
|
+
one winning. Before this, a room's state was its first line and nothing else —
|
|
56
|
+
so `goal_edit` and `add_participant` had **nowhere to land**, and
|
|
57
|
+
`updated_in_round` / `updated_by` sat in the schema with nothing writing them
|
|
58
|
+
since the format was defined.
|
|
59
|
+
- `room append --json <envelope>` accepts `change`, so an edit can be posted the
|
|
60
|
+
same way any other message is.
|
|
61
|
+
|
|
62
|
+
### Notes
|
|
63
|
+
|
|
64
|
+
- **The edit is a message, and that is the point.** The header cannot be
|
|
65
|
+
rewritten (append-only) and cannot be followed by a second one (every line
|
|
66
|
+
after the first must be a message, or the room becomes unreadable forever). A
|
|
67
|
+
message is therefore the only representation available — and because it is a
|
|
68
|
+
message it lands in the transcript, which is where this project already puts
|
|
69
|
+
state changes so a person can see them.
|
|
70
|
+
- **Reading is a fold, never a rewrite.** The file keeps the contract the room was
|
|
71
|
+
created with; bytes and mtime are untouched by any read. A test asserts both.
|
|
72
|
+
- **The body stays prose.** `"raise the pass mark to 85"`, with the structure
|
|
73
|
+
beside it in `change` — a JSON blob in the message pane is unreadable.
|
|
74
|
+
- **An edit kind with no `change` is a valid message that is not an edit**, and
|
|
75
|
+
the fold skips it. Making that ill-formed would have invented a new way for a
|
|
76
|
+
log to become unreadable, which is the one thing this format cannot afford.
|
|
77
|
+
A `change` whose `type` does not match its kind *is* ill-formed and is refused
|
|
78
|
+
by the writer.
|
|
79
|
+
- **Known divergence, recorded rather than fixed:** `archiveRoom` summarises a
|
|
80
|
+
closed room from its header, so `rooms history` shows the goal the room was
|
|
81
|
+
*created* with, not the one it ended with. Deciding which of those the index
|
|
82
|
+
should record is a follow-up.
|
|
83
|
+
|
|
16
84
|
## [0.10.3] — 2026-09-10
|
|
17
85
|
|
|
18
86
|
A patch. A new read tool, and no existing response changes.
|
package/README.md
CHANGED
|
@@ -195,6 +195,24 @@ are pruned from the registry file as a side effect. A pruned room is also
|
|
|
195
195
|
recorded in the history index at that moment — for a room that crashed, this is
|
|
196
196
|
the only point at which anything notices it ended.
|
|
197
197
|
|
|
198
|
+
### `roomyx setup [flags]`
|
|
199
|
+
|
|
200
|
+
Sets the **machine** up, without touching the current project: the same picker
|
|
201
|
+
`roomyx init` shows, narrowed to the rows that land under your home directory —
|
|
202
|
+
the skill for each agent runtime you use, and the persona library in
|
|
203
|
+
`~/.roomyx/personas`. Nothing is created in the working directory.
|
|
204
|
+
|
|
205
|
+
This is what to run right after `npm install -g @mrciphersmith/roomyx`. An npm
|
|
206
|
+
lifecycle script cannot ask instead: npm runs one with no terminal (CI,
|
|
207
|
+
`npm ci`, Docker builds), skips it entirely under `--ignore-scripts`, re-runs it
|
|
208
|
+
on every `npm update`, and under `npm i -g` may run it as a different user. A
|
|
209
|
+
prompt there either hangs the install or never happens — and a postinstall
|
|
210
|
+
writing into `~/.claude` is exactly what supply-chain hardening exists to stop.
|
|
211
|
+
|
|
212
|
+
| Flag | Meaning |
|
|
213
|
+
| --- | --- |
|
|
214
|
+
| `--yes` | Apply the default selection without asking. |
|
|
215
|
+
|
|
198
216
|
### `roomyx personas [flags]`
|
|
199
217
|
|
|
200
218
|
Installs the bundled persona library into `.roomyx/personas/`. `roomyx init`
|
|
@@ -410,6 +428,38 @@ record; every subsequent line is a `message` record.
|
|
|
410
428
|
- `roster` entries are `{ id, name }` — `id` is what `room.get_agent_detail`
|
|
411
429
|
takes as `agent_id`; `name` is the display name used in `from`.
|
|
412
430
|
|
|
431
|
+
### Edits: how a room's state changes
|
|
432
|
+
|
|
433
|
+
The first line is a room's **original** state and it is never rewritten — the log
|
|
434
|
+
is append-only, and it cannot be followed by a second `state` line either, because
|
|
435
|
+
every line after the first must be a `message`. So an edit is a **message**:
|
|
436
|
+
|
|
437
|
+
```jsonl
|
|
438
|
+
{"type":"message","seq":5,"from":"owner","kind":"goal_edit","body":"raise the pass mark to 85","change":{"type":"goal_contract","goal_contract":{"version":1,"goal_statement":"...","criteria":"...","threshold":{"fail_below":60,"pass_at_or_above":85}}}}
|
|
439
|
+
{"type":"message","seq":6,"from":"owner","kind":"add_participant","body":"adding Omar","change":{"type":"roster","add":[{"id":"omar","name":"Омар"}]}}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
- `change` is **optional**, so every message written by an earlier version still
|
|
443
|
+
validates. It is present only on the two edit kinds, and its `type` must match
|
|
444
|
+
the kind: `goal_edit` carries a `goal_contract`, `add_participant` carries
|
|
445
|
+
`roster`.
|
|
446
|
+
- **What a room reads as** is its first line *folded* with every edit, in `seq`
|
|
447
|
+
order, last one winning. That is what `room.get_state` returns. The file keeps
|
|
448
|
+
the original contract — the fold is an interpretation, never a rewrite — so a
|
|
449
|
+
transcript stays exactly as it was written.
|
|
450
|
+
- An edit is also an ordinary message, so it appears in the transcript: this
|
|
451
|
+
project puts state changes in the transcript as text precisely so a person can
|
|
452
|
+
see what happened, rather than having it land in a record nobody reads.
|
|
453
|
+
- A `goal_edit` with no `change` is a **valid message that simply is not an
|
|
454
|
+
edit** — the fold ignores it, and nothing about it is an error. Whether an edit
|
|
455
|
+
kind *should* carry its change is a rule about applying a message, not about the
|
|
456
|
+
message being well-formed, and an ill-formed line would make a room unreadable
|
|
457
|
+
forever (the log has no repair command). A `change` whose `type` does not match
|
|
458
|
+
its kind **is** ill-formed, and the writer refuses it.
|
|
459
|
+
- The body of an edit is prose (`"raise the pass mark to 85"`), not JSON: the
|
|
460
|
+
transcript is what a person reads, and the structure travels beside it in
|
|
461
|
+
`change`.
|
|
462
|
+
|
|
413
463
|
This format is this package's own design choice, not dictated by either JSON
|
|
414
464
|
Schema: the specification defers the on-disk representation to implementation,
|
|
415
465
|
and the schemas describe one message and one goal contract, not the log file as
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrciphersmith/roomyx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "MCP server + terminal UI for startup-room: live room status, chat, per-agent modal, an installable room registry, and skill-sync.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
package/src/cli.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join, resolve } from "node:path";
|
|
5
5
|
import { serve } from "./server/serve";
|
|
@@ -109,7 +109,7 @@ function bodyFromFile(file: string): string {
|
|
|
109
109
|
return raw.replace(/\r?\n$/, "");
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
const ENVELOPE_KEYS = ["from", "body", "kind", "in_reply_to"] as const;
|
|
112
|
+
const ENVELOPE_KEYS = ["from", "body", "kind", "in_reply_to", "change"] as const;
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Parses one envelope, refusing keys that would silently vanish.
|
|
@@ -135,7 +135,7 @@ function envelopeFrom(text: string): AppendMessageOptions {
|
|
|
135
135
|
throw new ArgError(`--json has an unknown key "${key}". Allowed: ${ENVELOPE_KEYS.join(", ")}.`);
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
const { from, body, kind, in_reply_to: inReplyTo } = envelope;
|
|
138
|
+
const { from, body, kind, in_reply_to: inReplyTo, change } = envelope;
|
|
139
139
|
if (typeof from !== "string" || from === "") throw new ArgError('--json needs a non-empty "from".');
|
|
140
140
|
if (typeof body !== "string") throw new ArgError('--json needs a string "body".');
|
|
141
141
|
if (kind !== undefined && (typeof kind !== "string" || !(MESSAGE_KINDS as readonly string[]).includes(kind))) {
|
|
@@ -144,11 +144,20 @@ function envelopeFrom(text: string): AppendMessageOptions {
|
|
|
144
144
|
if (inReplyTo !== undefined && (typeof inReplyTo !== "number" || !Number.isInteger(inReplyTo) || inReplyTo < 1)) {
|
|
145
145
|
throw new ArgError('--json "in_reply_to" must be a whole number of at least 1.');
|
|
146
146
|
}
|
|
147
|
+
// The change is passed through unexamined here and validated where the rule
|
|
148
|
+
// lives (the log's own schema, imported by the writer). Re-checking its shape
|
|
149
|
+
// in the CLI would be a second copy of a rule the log already owns — and the
|
|
150
|
+
// two copies would drift, which is the failure `src/log/schema.ts` exists to
|
|
151
|
+
// make impossible.
|
|
152
|
+
if (change !== undefined && (typeof change !== "object" || change === null)) {
|
|
153
|
+
throw new ArgError('--json "change" must be an object.');
|
|
154
|
+
}
|
|
147
155
|
return {
|
|
148
156
|
from,
|
|
149
157
|
body,
|
|
150
158
|
kind: kind as MessageEnvelope["kind"],
|
|
151
159
|
inReplyTo: inReplyTo as number | undefined,
|
|
160
|
+
change: change as MessageEnvelope["change"],
|
|
152
161
|
};
|
|
153
162
|
}
|
|
154
163
|
|
|
@@ -526,6 +535,77 @@ const COMMANDS: Record<string, Command> = {
|
|
|
526
535
|
},
|
|
527
536
|
},
|
|
528
537
|
|
|
538
|
+
setup: {
|
|
539
|
+
usage: "roomyx setup [flags]",
|
|
540
|
+
summary: "set this machine up, without touching the current project",
|
|
541
|
+
notes:
|
|
542
|
+
"The same picker `roomyx init` shows, narrowed to the rows that land on\n the machine: the skill for each agent runtime you use, and the persona\n library under ~/.roomyx. Nothing is created in the current directory, so\n this is what to run right after installing from npm — an npm lifecycle\n script cannot ask, because npm runs one with no terminal (CI, `npm ci`,\n Docker) and skips it entirely under --ignore-scripts.",
|
|
543
|
+
flags: {
|
|
544
|
+
yes: { type: "boolean", describe: "Apply the default selection without asking" },
|
|
545
|
+
},
|
|
546
|
+
run: async ({ flags }) => {
|
|
547
|
+
const home = homedir();
|
|
548
|
+
const cwd = process.cwd();
|
|
549
|
+
// Its own config, under the home directory: `syncSkill` records the hash
|
|
550
|
+
// of what it wrote so a later sync can tell "unchanged since we wrote it"
|
|
551
|
+
// from "edited by someone", and a machine-wide install has no project
|
|
552
|
+
// config to record into. Created here rather than demanded, because the
|
|
553
|
+
// whole point of this command is that there is no project yet.
|
|
554
|
+
const configPath = join(home, ".roomyx", "config.json");
|
|
555
|
+
if (!existsSync(configPath)) {
|
|
556
|
+
mkdirSync(join(home, ".roomyx"), { recursive: true });
|
|
557
|
+
writeFileSync(configPath, JSON.stringify({ schemaVersion: 1 }, null, 2));
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const { buildPlan, machineItems, selectedItems } = await import("./installer/init-plan");
|
|
561
|
+
const { applyPlan } = await import("./installer/init-apply");
|
|
562
|
+
const plan = machineItems(buildPlan({ cwd, personaFiles: personaCount(bundledPersonasPath()) }));
|
|
563
|
+
// Ticked here, unticked in `init`, and the difference is the point. In a
|
|
564
|
+
// project the machine-wide library is a second copy of one the project
|
|
565
|
+
// already gets and the skill prefers. Here there is no project copy — so
|
|
566
|
+
// leaving it off would set a machine up with a skill that casts its room
|
|
567
|
+
// from personas that are nowhere on disk, which is the unfinished
|
|
568
|
+
// installer this whole command exists to avoid.
|
|
569
|
+
for (const item of plan) {
|
|
570
|
+
if (item.id === "personas:user" && item.done === undefined) item.selected = true;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
const interactive = process.stdout.isTTY === true && process.stdin.isTTY === true;
|
|
574
|
+
if (!interactive && flags.yes !== true) {
|
|
575
|
+
console.log("Not a terminal, so nothing was asked and nothing was written.");
|
|
576
|
+
console.log(" roomyx setup --yes # the default selection, no prompt");
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
let chosen = plan;
|
|
581
|
+
if (flags.yes !== true) {
|
|
582
|
+
const { runInitPicker } = await import("./client/init-screen");
|
|
583
|
+
const picked = await runInitPicker(plan);
|
|
584
|
+
if (picked === null) {
|
|
585
|
+
console.log("Cancelled — nothing was written.");
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
chosen = picked;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
const results = applyPlan(selectedItems(chosen), {
|
|
592
|
+
cwd,
|
|
593
|
+
bundledSkillPath: bundledSkillPath(),
|
|
594
|
+
bundledPersonasPath: bundledPersonasPath(),
|
|
595
|
+
configPath,
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
for (const line of results) {
|
|
599
|
+
console.log(`${line.ok ? " ok " : " !! "} ${line.label}`);
|
|
600
|
+
console.log(` ${line.path} — ${line.message}`);
|
|
601
|
+
}
|
|
602
|
+
if (results.some((line) => line.ok)) {
|
|
603
|
+
console.log("\nRestart your agent — skills are discovered at startup.");
|
|
604
|
+
}
|
|
605
|
+
console.log("\nNext, in a project: roomyx init");
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
|
|
529
609
|
personas: {
|
|
530
610
|
usage: "roomyx personas [flags]",
|
|
531
611
|
summary: "install the bundled persona library into this project",
|
|
@@ -25,6 +25,14 @@ export interface PlanItem {
|
|
|
25
25
|
readonly kind: PlanItemKind;
|
|
26
26
|
/** Heading this item is listed under. */
|
|
27
27
|
readonly group: string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether this lands on the machine or in the project.
|
|
30
|
+
*
|
|
31
|
+
* Carried as data rather than inferred from the group, because `roomyx setup`
|
|
32
|
+
* selects on it: the group is what the row is printed under, and inferring a
|
|
33
|
+
* behavioural rule from a display string is how the two drift apart.
|
|
34
|
+
*/
|
|
35
|
+
readonly scope: "user" | "project";
|
|
28
36
|
readonly label: string;
|
|
29
37
|
/** Where it actually lands on disk. What `init-apply` acts on. */
|
|
30
38
|
readonly path: string;
|
|
@@ -66,18 +74,20 @@ export interface PlanContext {
|
|
|
66
74
|
export function buildPlan(context: PlanContext): PlanItem[] {
|
|
67
75
|
const { cwd } = context;
|
|
68
76
|
const exists = context.exists ?? existsSync;
|
|
77
|
+
const home = context.home ?? homedir();
|
|
69
78
|
const items: PlanItem[] = [];
|
|
70
79
|
|
|
71
80
|
for (const runtime of SKILL_RUNTIMES) {
|
|
72
|
-
const path = runtime.path(cwd);
|
|
81
|
+
const path = runtime.path(cwd, home);
|
|
73
82
|
// Presence of the runtime's own directory, not of our skill: this decides
|
|
74
83
|
// whether to *offer it ticked*, never whether to offer it at all. A runtime
|
|
75
84
|
// installed after roomyx would otherwise be unreachable.
|
|
76
|
-
const present = exists(runtime.marker(cwd));
|
|
85
|
+
const present = exists(runtime.marker(cwd, home));
|
|
77
86
|
items.push({
|
|
78
87
|
id: `skill:${runtime.name}`,
|
|
79
88
|
kind: "skill",
|
|
80
89
|
group: runtime.scope === "user" ? GROUP_USER : GROUP_PROJECT,
|
|
90
|
+
scope: runtime.scope,
|
|
81
91
|
label: runtime.label,
|
|
82
92
|
path,
|
|
83
93
|
detail: path,
|
|
@@ -93,8 +103,8 @@ export function buildPlan(context: PlanContext): PlanItem[] {
|
|
|
93
103
|
// the machine, including throwaway ones. The skill prefers the project copy
|
|
94
104
|
// and falls back to the home one, which is the order every runtime already
|
|
95
105
|
// uses for skills.
|
|
96
|
-
const homeDir =
|
|
97
|
-
const personaScopes: [string, string, string, boolean][] = [
|
|
106
|
+
const homeDir = home;
|
|
107
|
+
const personaScopes: [string, string, string, boolean, "user" | "project"][] = [
|
|
98
108
|
[
|
|
99
109
|
"personas:user",
|
|
100
110
|
"For every project",
|
|
@@ -104,24 +114,28 @@ export function buildPlan(context: PlanContext): PlanItem[] {
|
|
|
104
114
|
// directory is convenience, and 87 files appearing in a directory the
|
|
105
115
|
// operator did not know existed is the surprise the tick rule forbids.
|
|
106
116
|
false,
|
|
117
|
+
"user",
|
|
107
118
|
],
|
|
108
|
-
["personas:project", "In this project", join(cwd, ".roomyx", "personas"), true],
|
|
119
|
+
["personas:project", "In this project", join(cwd, ".roomyx", "personas"), true, "project"],
|
|
109
120
|
];
|
|
110
121
|
|
|
111
|
-
for (const [id, label, path, ticked] of personaScopes) {
|
|
122
|
+
for (const [id, label, path, ticked, scope] of personaScopes) {
|
|
112
123
|
items.push({
|
|
113
124
|
id,
|
|
114
125
|
kind: "personas",
|
|
115
126
|
group: GROUP_PERSONAS,
|
|
127
|
+
scope,
|
|
116
128
|
label,
|
|
117
129
|
path,
|
|
118
|
-
|
|
130
|
+
// The file count belongs to the description of the target, not to
|
|
131
|
+
// `done`. It lived in `done` for one release and made that field mean
|
|
132
|
+
// two things — "already satisfied" and "here is how big this is" — so a
|
|
133
|
+
// caller asking "is this already installed?" got "87 files" and read it
|
|
134
|
+
// as yes. `roomyx setup` was that caller, and it silently stopped
|
|
135
|
+
// ticking the library.
|
|
136
|
+
detail: context.personaFiles === undefined ? path : `${path} (${context.personaFiles} files)`,
|
|
119
137
|
selected: ticked && !exists(path),
|
|
120
|
-
done: exists(path)
|
|
121
|
-
? "already there — existing files are kept"
|
|
122
|
-
: context.personaFiles === undefined
|
|
123
|
-
? undefined
|
|
124
|
-
: `${context.personaFiles} files`,
|
|
138
|
+
done: exists(path) ? "already there — existing files are kept" : undefined,
|
|
125
139
|
});
|
|
126
140
|
}
|
|
127
141
|
|
|
@@ -130,6 +144,7 @@ export function buildPlan(context: PlanContext): PlanItem[] {
|
|
|
130
144
|
id: "logs",
|
|
131
145
|
kind: "logs",
|
|
132
146
|
group: GROUP_EXTRAS,
|
|
147
|
+
scope: "project",
|
|
133
148
|
label: "Room-log directory",
|
|
134
149
|
path: logsDir,
|
|
135
150
|
detail: logsDir,
|
|
@@ -145,6 +160,7 @@ export function buildPlan(context: PlanContext): PlanItem[] {
|
|
|
145
160
|
id: "gitignore",
|
|
146
161
|
kind: "gitignore",
|
|
147
162
|
group: GROUP_EXTRAS,
|
|
163
|
+
scope: "project",
|
|
148
164
|
label: "Ignore registry, lockfiles",
|
|
149
165
|
path: join(cwd, ".gitignore"),
|
|
150
166
|
// The registry holds pids and ports of processes on *this* machine, and the
|
|
@@ -163,6 +179,7 @@ export function buildPlan(context: PlanContext): PlanItem[] {
|
|
|
163
179
|
id,
|
|
164
180
|
kind: "mcp",
|
|
165
181
|
group: GROUP_EXTRAS,
|
|
182
|
+
scope: "project",
|
|
166
183
|
label,
|
|
167
184
|
path,
|
|
168
185
|
detail: path,
|
|
@@ -188,3 +205,11 @@ function mcpTargets(cwd: string): [string, string, string][] {
|
|
|
188
205
|
export function selectedItems(items: readonly PlanItem[]): PlanItem[] {
|
|
189
206
|
return items.filter((item) => item.selected);
|
|
190
207
|
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* The rows that land on the machine rather than in a project — what
|
|
211
|
+
* `roomyx setup` offers when there is no project to set up.
|
|
212
|
+
*/
|
|
213
|
+
export function machineItems(items: readonly PlanItem[]): PlanItem[] {
|
|
214
|
+
return items.filter((item) => item.scope === "user");
|
|
215
|
+
}
|
|
@@ -24,14 +24,22 @@ export interface SkillRuntime {
|
|
|
24
24
|
/** How to say it to a person. */
|
|
25
25
|
readonly label: string;
|
|
26
26
|
readonly scope: "user" | "project";
|
|
27
|
-
/**
|
|
28
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Where the SKILL.md goes.
|
|
29
|
+
*
|
|
30
|
+
* `home` is a parameter rather than a call to `homedir()` inside, so a test
|
|
31
|
+
* can build a plan against a temporary home. It was read from the process
|
|
32
|
+
* before, which meant `buildPlan({ home })` honoured the persona rows and
|
|
33
|
+
* silently ignored the skill ones — a test asserting "nothing lands outside
|
|
34
|
+
* this directory" was passing against the real `~`.
|
|
35
|
+
*/
|
|
36
|
+
readonly path: (cwd: string, home?: string) => string;
|
|
29
37
|
/**
|
|
30
38
|
* The directory whose existence means this runtime is in use here. Used only
|
|
31
39
|
* to pre-tick sensible boxes in `roomyx init` — never to refuse a target,
|
|
32
40
|
* because a runtime installed after roomyx would then be unreachable.
|
|
33
41
|
*/
|
|
34
|
-
readonly marker: (cwd: string) => string;
|
|
42
|
+
readonly marker: (cwd: string, home?: string) => string;
|
|
35
43
|
}
|
|
36
44
|
|
|
37
45
|
const SKILL_FILE = ["skills", "startup-room", "SKILL.md"] as const;
|
|
@@ -41,8 +49,8 @@ function userRuntime(name: string, label: string, dir: string): SkillRuntime {
|
|
|
41
49
|
name,
|
|
42
50
|
label,
|
|
43
51
|
scope: "user",
|
|
44
|
-
path: () => join(homedir(), dir, ...SKILL_FILE),
|
|
45
|
-
marker: () => join(homedir(), dir),
|
|
52
|
+
path: (_cwd, home) => join(home ?? homedir(), dir, ...SKILL_FILE),
|
|
53
|
+
marker: (_cwd, home) => join(home ?? homedir(), dir),
|
|
46
54
|
};
|
|
47
55
|
}
|
|
48
56
|
|
package/src/log/schema.ts
CHANGED
|
@@ -25,8 +25,19 @@ export const MESSAGE_KINDS = [
|
|
|
25
25
|
"vote",
|
|
26
26
|
"status",
|
|
27
27
|
"research",
|
|
28
|
+
// D-19: the two kinds that change a room's state. The header cannot be
|
|
29
|
+
// rewritten and a second state line makes the room unreadable, so an edit is a
|
|
30
|
+
// message — and because it is a message it is also visible in the transcript,
|
|
31
|
+
// which is where this project already puts state changes.
|
|
32
|
+
"goal_edit",
|
|
33
|
+
"add_participant",
|
|
28
34
|
] as const;
|
|
29
35
|
|
|
36
|
+
/** The kinds that must carry a `change`, and which change each one means. */
|
|
37
|
+
export const EDIT_KINDS = { goal_edit: "goal_contract", add_participant: "roster" } as const;
|
|
38
|
+
|
|
39
|
+
export type EditKind = keyof typeof EDIT_KINDS;
|
|
40
|
+
|
|
30
41
|
export const rosterEntrySchema = z.object({ id: z.string(), name: z.string() });
|
|
31
42
|
|
|
32
43
|
export const goalContractSchema = z.object({
|
|
@@ -49,11 +60,68 @@ export const stateLineSchema = z.object({
|
|
|
49
60
|
roster: z.array(rosterEntrySchema),
|
|
50
61
|
});
|
|
51
62
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
/**
|
|
64
|
+
* What an edit message changes, as a discriminated payload.
|
|
65
|
+
*
|
|
66
|
+
* It travels in a field of its own rather than in `body` because the transcript
|
|
67
|
+
* is what a person reads: a JSON blob in the message pane is unreadable, and the
|
|
68
|
+
* body of an edit stays a sentence ("raise the pass mark to 85").
|
|
69
|
+
*/
|
|
70
|
+
export const messageChangeSchema = z.discriminatedUnion("type", [
|
|
71
|
+
z.object({ type: z.literal("goal_contract"), goal_contract: goalContractSchema }),
|
|
72
|
+
z.object({ type: z.literal("roster"), add: z.array(rosterEntrySchema).min(1) }),
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
export type MessageChange = z.infer<typeof messageChangeSchema>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The log's message contract, and the one place the edit rule is expressed.
|
|
79
|
+
*
|
|
80
|
+
* D-08 is why the rule lives here rather than in the writer and the reader
|
|
81
|
+
* separately: "a writer whose output its own reader rejects is the thing this
|
|
82
|
+
* module exists to make impossible". The writer refuses on this rule and the fold
|
|
83
|
+
* skips on it — two uses of one rule, not two rules.
|
|
84
|
+
*
|
|
85
|
+
* `change` is optional, which is what keeps the format change additive: every
|
|
86
|
+
* message written by every earlier version still validates.
|
|
87
|
+
*/
|
|
88
|
+
export const messageLineSchema = z
|
|
89
|
+
.object({
|
|
90
|
+
type: z.literal("message"),
|
|
91
|
+
seq: z.number().int().min(1),
|
|
92
|
+
from: z.string().min(1),
|
|
93
|
+
in_reply_to: z.number().int().min(1).optional(),
|
|
94
|
+
kind: messageKindSchema.optional(),
|
|
95
|
+
body: z.string(),
|
|
96
|
+
change: messageChangeSchema.optional(),
|
|
97
|
+
})
|
|
98
|
+
.superRefine((message, ctx) => {
|
|
99
|
+
// Shape rules only — deliberately not "an edit kind must carry a change".
|
|
100
|
+
//
|
|
101
|
+
// That rule would make the message *invalid*, and an invalid line makes a room
|
|
102
|
+
// unreadable forever: the log is append-only with no repair command. So a
|
|
103
|
+
// `goal_edit` with no change is a **valid message that simply is not an
|
|
104
|
+
// edit**, and the fold ignores it. Whether an edit kind carries its change is
|
|
105
|
+
// a rule about *applying* a message, not about the message being well-formed,
|
|
106
|
+
// and conflating the two would have invented a new way for a log to die.
|
|
107
|
+
if (message.change === undefined) return;
|
|
108
|
+
|
|
109
|
+
const expected = message.kind === undefined ? undefined : EDIT_KINDS[message.kind as EditKind];
|
|
110
|
+
if (expected === undefined) {
|
|
111
|
+
// A change on an ordinary message will never be applied by anything, so
|
|
112
|
+
// accepting it would let a writer believe it changed state it did not.
|
|
113
|
+
ctx.addIssue({
|
|
114
|
+
code: "custom",
|
|
115
|
+
path: ["change"],
|
|
116
|
+
message: `a "change" requires an edit kind (${Object.keys(EDIT_KINDS).join(", ")}), not "${message.kind ?? "none"}"`,
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (message.change.type !== expected) {
|
|
121
|
+
ctx.addIssue({
|
|
122
|
+
code: "custom",
|
|
123
|
+
path: ["change", "type"],
|
|
124
|
+
message: `kind "${message.kind}" carries a "${message.change.type}" change; it must be "${expected}"`,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
package/src/log/store.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { messageLineSchema, stateLineSchema } from "./schema";
|
|
3
|
-
import type {
|
|
3
|
+
import type { MessageChange } from "./schema";
|
|
4
|
+
import type { AgentDelta, AgentDetail, GoalContract, MessageEnvelope, RoomState, RosterEntry } from "./types";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* `JSON.parse`, with the one thing it never says: where.
|
|
@@ -56,13 +57,6 @@ export function loadRoomLog(path: string): { state: RoomState; messages: Message
|
|
|
56
57
|
);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
const state: RoomState = {
|
|
60
|
-
goal_contract: headerResult.data.goal_contract,
|
|
61
|
-
roster: headerResult.data.roster,
|
|
62
|
-
// The reader knows which file it read; the state header does not carry it.
|
|
63
|
-
log_path: path,
|
|
64
|
-
};
|
|
65
|
-
|
|
66
60
|
const messages: MessageEnvelope[] = rest.map((line, index) => {
|
|
67
61
|
const result = messageLineSchema.safeParse(
|
|
68
62
|
parseLine(line, () => `Invalid "message" line ${index + 2} in ${path}`),
|
|
@@ -75,9 +69,64 @@ export function loadRoomLog(path: string): { state: RoomState; messages: Message
|
|
|
75
69
|
return envelope;
|
|
76
70
|
});
|
|
77
71
|
|
|
72
|
+
const state: RoomState = {
|
|
73
|
+
// The header is the room's ORIGINAL contract and the base every edit is
|
|
74
|
+
// applied to; it is never reinterpreted as one of them.
|
|
75
|
+
...foldEdits({ goal_contract: headerResult.data.goal_contract, roster: headerResult.data.roster }, messages),
|
|
76
|
+
// The reader knows which file it read; the state header does not carry it.
|
|
77
|
+
log_path: path,
|
|
78
|
+
};
|
|
79
|
+
|
|
78
80
|
return { state, messages };
|
|
79
81
|
}
|
|
80
82
|
|
|
83
|
+
/**
|
|
84
|
+
* A room's current state, from its original state and every edit since.
|
|
85
|
+
*
|
|
86
|
+
* The reason this exists at all: a room's state lives in the first line and that
|
|
87
|
+
* line cannot be rewritten (append-only) and cannot be followed by a second one
|
|
88
|
+
* (`loadRoomLog` requires every following line to be a message, so a second state
|
|
89
|
+
* line makes the room unreadable forever). D-19 therefore makes an edit a
|
|
90
|
+
* *message* — which also puts it in the transcript, where this project already
|
|
91
|
+
* puts state changes so a person can see what happened.
|
|
92
|
+
*
|
|
93
|
+
* In `seq` order, last edit wins. A message whose kind is an edit kind but which
|
|
94
|
+
* carries no change is not an edit and is skipped: it is a valid message that
|
|
95
|
+
* happens to be tagged, and the schema deliberately does not make it invalid,
|
|
96
|
+
* because an invalid line would kill the room.
|
|
97
|
+
*
|
|
98
|
+
* Nothing here writes. The fold is an interpretation of an append-only log, and
|
|
99
|
+
* the header keeps the contract the room was created with.
|
|
100
|
+
*/
|
|
101
|
+
export function foldEdits(
|
|
102
|
+
base: { goal_contract: GoalContract; roster: RosterEntry[] },
|
|
103
|
+
messages: MessageEnvelope[],
|
|
104
|
+
): { goal_contract: GoalContract; roster: RosterEntry[] } {
|
|
105
|
+
let goalContract = base.goal_contract;
|
|
106
|
+
let roster = base.roster;
|
|
107
|
+
|
|
108
|
+
for (const message of [...messages].sort((a, b) => a.seq - b.seq)) {
|
|
109
|
+
const change: MessageChange | undefined = message.change;
|
|
110
|
+
if (change === undefined) continue;
|
|
111
|
+
if (change.type === "goal_contract") {
|
|
112
|
+
goalContract = {
|
|
113
|
+
...change.goal_contract,
|
|
114
|
+
// The schema has carried these since the beginning with nothing writing
|
|
115
|
+
// them; an edit is exactly what they were designed for.
|
|
116
|
+
updated_by: "owner",
|
|
117
|
+
updated_in_round: message.seq,
|
|
118
|
+
};
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
// "add", not "set": the roster grows, and replacing it would silently drop
|
|
122
|
+
// everyone an earlier message had introduced.
|
|
123
|
+
const known = new Set(roster.map((entry) => entry.id));
|
|
124
|
+
roster = [...roster, ...change.add.filter((entry) => !known.has(entry.id))];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return { goal_contract: goalContract, roster };
|
|
128
|
+
}
|
|
129
|
+
|
|
81
130
|
/** Messages with seq strictly greater than sinceSeq, in log order. */
|
|
82
131
|
export function getTranscript(messages: MessageEnvelope[], sinceSeq: number): MessageEnvelope[] {
|
|
83
132
|
return messages.filter((m) => m.seq > sinceSeq);
|
package/src/log/types.ts
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
import type { MessageChange } from "./schema";
|
|
2
|
+
|
|
1
3
|
export interface MessageEnvelope {
|
|
2
4
|
seq: number;
|
|
3
5
|
from: string;
|
|
4
6
|
in_reply_to?: number;
|
|
5
|
-
kind?:
|
|
7
|
+
kind?:
|
|
8
|
+
| "pitch"
|
|
9
|
+
| "question"
|
|
10
|
+
| "challenge"
|
|
11
|
+
| "answer"
|
|
12
|
+
| "vote"
|
|
13
|
+
| "status"
|
|
14
|
+
| "research"
|
|
15
|
+
| "goal_edit"
|
|
16
|
+
| "add_participant";
|
|
6
17
|
body: string;
|
|
18
|
+
/** Present only on an edit message; see `EDIT_KINDS` and D-19. */
|
|
19
|
+
change?: MessageChange;
|
|
7
20
|
}
|
|
8
21
|
|
|
9
22
|
export interface RosterEntry {
|
package/src/log/write.ts
CHANGED
|
@@ -20,6 +20,7 @@ function describeInvalid(error: z.ZodError): string {
|
|
|
20
20
|
const field = issue.path.join(".") || "message";
|
|
21
21
|
if (field === "kind") return `kind must be one of: ${LEGAL_KINDS}`;
|
|
22
22
|
if (field === "in_reply_to") return "in-reply-to must be a whole number of at least 1";
|
|
23
|
+
if (field === "change") return issue.message;
|
|
23
24
|
return `${field}: ${issue.message}`;
|
|
24
25
|
})
|
|
25
26
|
.join("; ");
|
|
@@ -47,6 +48,8 @@ export interface AppendMessageOptions {
|
|
|
47
48
|
body: string;
|
|
48
49
|
kind?: MessageEnvelope["kind"];
|
|
49
50
|
inReplyTo?: number;
|
|
51
|
+
/** Required by the edit kinds, refused on everything else — enforced by the schema. */
|
|
52
|
+
change?: MessageEnvelope["change"];
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
/** Refuses to overwrite: a room log is append-only, and clobbering one loses a session. */
|
|
@@ -111,20 +114,21 @@ export function appendMessages(
|
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
export function appendMessage(path: string, options: AppendMessageOptions): MessageEnvelope & { type: "message" } {
|
|
114
|
-
|
|
115
|
-
throw new Error(`${path} does not exist. Create it with \`roomyx room new\` first.`);
|
|
116
|
-
}
|
|
117
|
-
// Allocating `seq` and writing the line is one critical section, not two.
|
|
118
|
-
// `nextSeq` reads the whole file and returns max+1, and nothing stood between
|
|
119
|
-
// that and the append: three concurrent `roomyx room append` calls all
|
|
120
|
-
// allocated `seq: 1` and all three landed on disk. `seq` is the transcript
|
|
121
|
-
// cursor, so a client polling between two colliding writes advances past both
|
|
122
|
-
// and never receives the second message — on disk, invisible in the TUI,
|
|
123
|
-
// permanently.
|
|
117
|
+
// Delegates to the batch path rather than assembling the envelope again.
|
|
124
118
|
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
|
|
119
|
+
// It used to have its own inline construction and its own `writeMessage`, and
|
|
120
|
+
// the two copies had already drifted: this one silently dropped `change`, so an
|
|
121
|
+
// edit appended one message at a time was written without the thing that made
|
|
122
|
+
// it an edit — valid by the schema, accepted, and never applied. Fixing that
|
|
123
|
+
// instance by adding one spread would have left the class: two places building
|
|
124
|
+
// one envelope. There is now one implementation, and the only thing this
|
|
125
|
+
// function adds is the single-message shape of the answer.
|
|
126
|
+
const written = appendMessages(path, [options]);
|
|
127
|
+
const first = written[0];
|
|
128
|
+
if (first === undefined) {
|
|
129
|
+
throw new Error(`${path}: appending one message produced nothing. This is a bug: report it.`);
|
|
130
|
+
}
|
|
131
|
+
return first;
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
function buildMessage(seq: number, options: AppendMessageOptions): MessageEnvelope & { type: "message" } {
|
|
@@ -135,6 +139,7 @@ function buildMessage(seq: number, options: AppendMessageOptions): MessageEnvelo
|
|
|
135
139
|
body: options.body,
|
|
136
140
|
...(options.kind ? { kind: options.kind } : {}),
|
|
137
141
|
...(options.inReplyTo !== undefined ? { in_reply_to: options.inReplyTo } : {}),
|
|
142
|
+
...(options.change !== undefined ? { change: options.change } : {}),
|
|
138
143
|
};
|
|
139
144
|
}
|
|
140
145
|
|
|
@@ -143,25 +148,6 @@ function validate(message: MessageEnvelope & { type: "message" }): void {
|
|
|
143
148
|
if (!parsed.success) throw new LogWriteError(describeInvalid(parsed.error));
|
|
144
149
|
}
|
|
145
150
|
|
|
146
|
-
function writeMessage(path: string, options: AppendMessageOptions): MessageEnvelope & { type: "message" } {
|
|
147
|
-
const message: MessageEnvelope & { type: "message" } = {
|
|
148
|
-
type: "message",
|
|
149
|
-
seq: nextSeq(path),
|
|
150
|
-
from: options.from,
|
|
151
|
-
body: options.body,
|
|
152
|
-
...(options.kind ? { kind: options.kind } : {}),
|
|
153
|
-
...(options.inReplyTo !== undefined ? { in_reply_to: options.inReplyTo } : {}),
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
// Validated against the reader's own schema, before the write rather than
|
|
157
|
-
// after it. The log is append-only and roomyx ships no repair command, so a
|
|
158
|
-
// line the reader refuses is not a failed write — it is a room nobody can
|
|
159
|
-
// open again. Types alone did not hold this: they are erased at the CLI
|
|
160
|
-
// boundary, where `--kind` arrived as an unchecked string.
|
|
161
|
-
validate(message);
|
|
162
|
-
appendFileSync(path, JSON.stringify(message) + "\n");
|
|
163
|
-
return message;
|
|
164
|
-
}
|
|
165
151
|
|
|
166
152
|
/** `id:Name,id2:Name2` — the shape the CLI takes and the log stores. */
|
|
167
153
|
export function parseRoster(spec: string): RosterEntry[] {
|