@marver-design/marver 0.24.0 → 0.25.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +1 -1
  3. package/dist/anchor-DVV732zR.mjs +33 -0
  4. package/dist/anchor-check-BE5VVN6Q.mjs +135 -0
  5. package/dist/{bake-ZhXq-X9f.mjs → bake-D8byeRzB.mjs} +1 -1
  6. package/dist/{boards-BRLnoTC3.mjs → board-tree-DRioF94d.mjs} +21 -277
  7. package/dist/boards-CGg6piKF.mjs +342 -0
  8. package/dist/{boards-Dv-Ipd8G.mjs → boards-Csxj2WJn.mjs} +23 -9
  9. package/dist/{build-ckcinlWH.mjs → build-BHoWLvSj.mjs} +63 -37
  10. package/dist/cli.mjs +31 -17
  11. package/dist/{collab-mAiNZlDj.mjs → collab-gqNdScUE.mjs} +39 -9
  12. package/dist/{comments-DZyobpxG.mjs → comments-Zoch254k.mjs} +19 -1
  13. package/dist/{comments-Dx1hCVOT.mjs → comments-pTLlhjh4.mjs} +150 -20
  14. package/dist/{config-BUKprFAp.mjs → config-cKgZBRj0.mjs} +1 -1
  15. package/dist/{context-BncTXjLB.mjs → context-D2ugHqwO.mjs} +17 -123
  16. package/dist/{daemon-CQv73-jM.mjs → daemon-Cl8KXGW4.mjs} +146 -64
  17. package/dist/{dev-gv4NS6Fk.mjs → dev-DJdgow47.mjs} +23 -11
  18. package/dist/{events-B3LBn74P.mjs → events-DnK_AnrW.mjs} +13 -15
  19. package/dist/imports-WBSnnHLb.mjs +143 -0
  20. package/dist/{init--3Moc4J7.mjs → init-DO4DhUt_.mjs} +28 -6
  21. package/dist/link-C-qUIuKU.mjs +160 -0
  22. package/dist/{board-status-BZSzc9Hp.mjs → manifest-DnAte_fB.mjs} +537 -13
  23. package/dist/marks-DFuintmJ.mjs +50 -0
  24. package/dist/marks-koRsbHfe.mjs +397 -0
  25. package/dist/{marver-id-gate-B_idGdHm.mjs → marver-id-gate-DGANtVyC.mjs} +2 -2
  26. package/dist/perf-CCisg-ny.mjs +49 -0
  27. package/dist/perf-QJIWtTw1.mjs +68 -0
  28. package/dist/{plugin-Sa08E7wO.mjs → plugin-CTyhjwoJ.mjs} +424 -207
  29. package/dist/{poster-B2QPvKOq.mjs → poster-D0cbV7hi.mjs} +1 -1
  30. package/dist/{profile-CrZohD6g.mjs → profile-Do0nGkXO.mjs} +1 -1
  31. package/dist/{publish-bakes-BJR3huhu.mjs → publish-bakes--l8ot2eQ.mjs} +9 -9
  32. package/dist/{serve-z5qtj_wJ.mjs → serve-wv2QWdxB.mjs} +6 -6
  33. package/dist/{share-BD-wcDQq.mjs → share-ScamJcks.mjs} +1 -1
  34. package/dist/{shot-Cw96h5Kk.mjs → shot-CckrGW-J.mjs} +19 -11
  35. package/dist/{shot-Dh6fV1Lm.mjs → shot-jdO_B6Qw.mjs} +1 -1
  36. package/dist/{summary-C7CAypbB.mjs → summary-CrW88e3q.mjs} +1 -1
  37. package/dist/{sync-DoA1vf4u.mjs → sync-C3035OnJ.mjs} +18 -8
  38. package/dist/{work-CBUfsOOT.mjs → work-CpJn1gwY.mjs} +8 -4
  39. package/dist/{work-ayuL_9Kk.mjs → work-GE88wb_3.mjs} +4 -4
  40. package/docs/boards-and-folders.md +62 -21
  41. package/docs/live-jam.md +10 -5
  42. package/package.json +1 -1
  43. package/src/client/frame-host/bridge.js +2 -1
  44. package/src/client/frame-host/inspect.js +195 -84
  45. package/src/client/frame-host/main.tsx +7 -2
  46. package/src/client/frame-host/registry.ts +5 -5
  47. package/src/client/shell/App.tsx +66 -22
  48. package/src/client/shell/BoardList.tsx +54 -11
  49. package/src/client/shell/Comments.tsx +79 -34
  50. package/src/client/shell/ContextMenu.tsx +5 -2
  51. package/src/client/shell/LockedApp.tsx +45 -12
  52. package/src/client/shell/Play.tsx +35 -34
  53. package/src/client/shell/Toolbar.tsx +3 -1
  54. package/src/client/shell/canvas/Canvas.tsx +1 -1
  55. package/src/client/shell/canvas/FrameNode.tsx +10 -5
  56. package/src/client/shell/canvas/sleep.ts +4 -3
  57. package/src/client/shell/canvas/updates.ts +55 -0
  58. package/src/client/shell/comments-store.ts +48 -19
  59. package/src/client/shell/goto.ts +11 -14
  60. package/src/client/shell/hash.ts +12 -5
  61. package/src/client/shell/icons.tsx +1 -2
  62. package/src/client/shell/legacy-links.ts +67 -0
  63. package/src/client/shell/marks-ui.tsx +17 -19
  64. package/src/client/shell/pin-layout.ts +37 -0
  65. package/src/client/shell/store.ts +312 -92
  66. package/src/client/shell/styles.css +10 -8
  67. package/src/client/stage/main.tsx +19 -2
  68. package/src/shared/anchor.ts +57 -0
  69. package/src/shared/board-tree.ts +27 -10
  70. package/src/shared/events.ts +19 -10
  71. package/src/shared/marks.ts +17 -12
  72. package/templates/AGENTS-embedded.md +34 -15
  73. package/templates/AGENTS-studio.md +34 -15
  74. package/templates/instructions/boards.md +9 -5
  75. package/templates/instructions/iterate.md +20 -10
  76. package/templates/instructions/jam.md +13 -4
  77. package/templates/instructions/publish.md +2 -1
  78. package/templates/instructions/reference/deck-story.md +2 -2
  79. package/dist/link-vXjxMHTG.mjs +0 -132
  80. package/dist/manifest-cyG3kbhk.mjs +0 -528
@@ -0,0 +1,342 @@
1
+ import { D as readStatusWord, E as readReason, O as readType, T as readCapability, a as buildTree, c as folderMap, d as isBoardFile, f as isBoardName, h as readTitle, i as archiveLast, k as resolveType, l as framesOn, m as readDescription, o as flatten, p as parseFolders, r as FOLDERS_FILE } from "./board-tree-DRioF94d.mjs";
2
+ import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
3
+ import { join, sep } from "node:path";
4
+ import { createHash, randomBytes } from "node:crypto";
5
+ //#region src/server/hash.ts
6
+ /** sha256 hex of a string - the CAS token for board files, the registry, the manifest. */
7
+ const hash = (s) => createHash("sha256").update(s).digest("hex");
8
+ //#endregion
9
+ //#region src/server/boards.ts
10
+ /**
11
+ * Reading design/boards/ safely - the one enumerator the dev API, the build and the tests
12
+ * share. Only REGULAR files on the board-name grammar count as boards (a symlink, dangling or
13
+ * live, could read or publish JSON from outside the project - it is skipped, and reported so
14
+ * the build can fail closed). The folder registry is read the same way: absent = no folders,
15
+ * malformed = an error the human must fix, never a silently empty registry.
16
+ */
17
+ /** Does realpath(dir) stay inside realpath(root)? A symlinked design/boards can't escape. */
18
+ function underRoot(root, dir) {
19
+ try {
20
+ const rr = realpathSync(root);
21
+ const rd = realpathSync(dir);
22
+ return rd === rr || rd.startsWith(rr + sep);
23
+ } catch {
24
+ return false;
25
+ }
26
+ }
27
+ /** Is design/boards a directory we may read and write? It must not be a symlink at all (a
28
+ * link to the repo root would list package.json as a board and let a tree write rewrite
29
+ * it; a link outside would publish foreign JSON) and must resolve inside the root. Absent
30
+ * is fine (no boards yet). Returns the error, or null. */
31
+ function checkBoardsDir(root, boardsDir) {
32
+ return checkRealDirs(root, [[join(boardsDir, ".."), "design"], [boardsDir, "design/boards"]]);
33
+ }
34
+ /** Every EXISTING path in `dirs` (root-down order) must be a real directory inside the root -
35
+ * a symlinked `design` with no boards dir yet would otherwise be followed by the mkdir that
36
+ * creates it; a symlinked `design/scenes` would let a brief write land outside the project.
37
+ * An absent one ends the walk (nothing beneath it exists either). Returns the error, or null. */
38
+ function checkRealDirs(root, dirs) {
39
+ for (const [p, label] of dirs) {
40
+ try {
41
+ if (lstatSync(p).isSymbolicLink()) return `${label} must be a real directory, not a symlink`;
42
+ } catch {
43
+ return null;
44
+ }
45
+ if (!underRoot(root, p)) return `${label} escapes the project`;
46
+ }
47
+ return null;
48
+ }
49
+ /** A regular file (lstat: a symlink is never followed, a dangling one is not "absent"). */
50
+ const isRegularFile = (p) => {
51
+ try {
52
+ return lstatSync(p).isFile();
53
+ } catch {
54
+ return false;
55
+ }
56
+ };
57
+ /** Is there ANY node at p (a dangling symlink counts)? */
58
+ const nodeExists = (p) => {
59
+ try {
60
+ lstatSync(p);
61
+ return true;
62
+ } catch {
63
+ return false;
64
+ }
65
+ };
66
+ /** A board file's JSON, or why it is not JSON - the parser's own words, naming the line and column (#6). */
67
+ function parseBoard(content) {
68
+ try {
69
+ return { json: JSON.parse(content) };
70
+ } catch (e) {
71
+ const msg = e.message, lines = content.split("\n");
72
+ return {
73
+ json: null,
74
+ error: /end of JSON input$/.test(msg) ? `${msg} (line ${lines.length} column ${lines[lines.length - 1].length + 1})` : msg
75
+ };
76
+ }
77
+ }
78
+ /** Every board file: name, raw content, hash, and its JSON (null when malformed). `skipped`
79
+ * names the entries that looked like boards but were not regular files. */
80
+ function listBoardFiles(boardsDir) {
81
+ const boards = [], skipped = [];
82
+ if (!existsSync(boardsDir)) return {
83
+ boards,
84
+ skipped
85
+ };
86
+ for (const f of readdirSync(boardsDir)) {
87
+ if (!isBoardFile(f)) continue;
88
+ const file = join(boardsDir, f);
89
+ if (!isRegularFile(file)) {
90
+ skipped.push(f);
91
+ continue;
92
+ }
93
+ const content = readFileSync(file, "utf8");
94
+ boards.push({
95
+ name: f.slice(0, -5),
96
+ file,
97
+ content,
98
+ sha256: hash(content),
99
+ ...parseBoard(content)
100
+ });
101
+ }
102
+ return {
103
+ boards,
104
+ skipped
105
+ };
106
+ }
107
+ function boardFields(json, validName) {
108
+ const o = json;
109
+ const title = readTitle(o?.title);
110
+ const description = readDescription(o?.description);
111
+ const type = readType(o?.type), capability = readCapability(o?.capability), status = readStatusWord(o?.status), reason = readReason(o?.reason);
112
+ return {
113
+ ...typeof o?.order === "number" && Number.isFinite(o.order) ? { order: o.order } : {},
114
+ ...validName(o?.folder) ? { folder: o.folder } : {},
115
+ ...title ? { title } : {},
116
+ ...description ? { description } : {},
117
+ ...type ? { type } : {},
118
+ ...capability ? { capability } : {},
119
+ ...status ? { status } : {},
120
+ ...reason ? { reason } : {}
121
+ };
122
+ }
123
+ /** The fields a board's file owns that the shell's save shape never carries: an autosave keeps
124
+ * each one from disk when the incoming board omits it (spec 20 - the fields survive every write). */
125
+ const AUTHOR_FIELDS = [
126
+ "order",
127
+ "folder",
128
+ "title",
129
+ "description",
130
+ "type",
131
+ "capability",
132
+ "status",
133
+ "reason"
134
+ ];
135
+ /** The folder registry. `sha256` is the CAS token a tree write must echo (null = "there was
136
+ * no file"), so a write can never silently replace a registry it never saw. */
137
+ function readRegistry(boardsDir) {
138
+ const p = join(boardsDir, FOLDERS_FILE);
139
+ if (!nodeExists(p)) return {
140
+ state: "absent",
141
+ folders: [],
142
+ sha256: null
143
+ };
144
+ if (!isRegularFile(p)) return {
145
+ state: "malformed",
146
+ error: `design/boards/${FOLDERS_FILE} must be a regular file, not a symlink`,
147
+ sha256: null
148
+ };
149
+ const content = readFileSync(p, "utf8");
150
+ let raw;
151
+ try {
152
+ raw = JSON.parse(content);
153
+ } catch {
154
+ return {
155
+ state: "malformed",
156
+ error: `design/boards/${FOLDERS_FILE} is not valid JSON - fix the file`,
157
+ sha256: hash(content)
158
+ };
159
+ }
160
+ const parsed = parseFolders(raw);
161
+ if (typeof parsed === "string") return {
162
+ state: "malformed",
163
+ error: `design/boards/${FOLDERS_FILE}: ${parsed}`,
164
+ sha256: hash(content)
165
+ };
166
+ return {
167
+ state: "ok",
168
+ folders: parsed,
169
+ sha256: hash(content)
170
+ };
171
+ }
172
+ /** The registry's write lock - one writer at a time across processes (the dev server's tree write,
173
+ * `folders add`, `init --kind`), so a read-modify-write of `_folders.json` is atomic among Marver's
174
+ * writers. A lock older than 10 s is a crashed writer's and is taken over. `wait` = how long to
175
+ * try (the CLI waits; the dev server never blocks its event loop - it answers 409 instead). */
176
+ const REGISTRY_LOCK = ".folders.lock";
177
+ function withRegistryLock(dir, wait, fn) {
178
+ const lock = join(dir, REGISTRY_LOCK);
179
+ const t0 = Date.now();
180
+ for (;;) try {
181
+ writeFileSync(lock, `${process.pid} ${Date.now()}\n`, { flag: "wx" });
182
+ break;
183
+ } catch (e) {
184
+ if (e.code !== "EEXIST") throw e;
185
+ try {
186
+ if (Date.now() - lstatSync(lock).mtimeMs > 1e4) {
187
+ rmSync(lock, { force: true });
188
+ continue;
189
+ }
190
+ } catch {
191
+ continue;
192
+ }
193
+ if (Date.now() - t0 >= wait) return null;
194
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 25);
195
+ }
196
+ try {
197
+ return fn();
198
+ } finally {
199
+ rmSync(lock, { force: true });
200
+ }
201
+ }
202
+ /** Append typed folders to the registry (spec 20: `init --kind`, `folders add`). Never renames,
203
+ * moves or retypes a folder that exists - a name already registered is skipped and reported - and
204
+ * never drops a field of an existing entry it does not manage. New folders rank after everything
205
+ * already at the root. The write is compare-and-swap: the registry is re-read just before the
206
+ * atomic rename, and a change since the first read (the shell's drag, another agent) starts the
207
+ * append over from the new file. A malformed registry is an error, never overwritten. */
208
+ function addFolders(root, folders) {
209
+ const dir = join(root, "design", "boards");
210
+ const de = checkBoardsDir(root, dir);
211
+ if (de) throw new Error(de);
212
+ mkdirSync(dir, { recursive: true });
213
+ const file = join(dir, FOLDERS_FILE);
214
+ const done = withRegistryLock(dir, 5e3, () => appendFolders(dir, file, folders));
215
+ if (!done) throw new Error(`design/boards/${FOLDERS_FILE} is being written by another process - try again`);
216
+ return done;
217
+ }
218
+ function appendFolders(dir, file, folders) {
219
+ for (let attempt = 0; attempt < 5; attempt++) {
220
+ const before = nodeExists(file) ? readFileSync(file, "utf8") : null;
221
+ const reg = readRegistry(dir);
222
+ if (reg.state === "malformed") throw new Error(reg.error);
223
+ let raw = [];
224
+ if (before !== null) {
225
+ const j = JSON.parse(before);
226
+ raw = Array.isArray(j.folders) ? j.folders : [];
227
+ }
228
+ const have = new Set(raw.map((f) => f.name));
229
+ const rootRanks = [...raw.filter((f) => f.parent === void 0).map((f) => f.order), ...listBoardFiles(dir).boards.map((b) => {
230
+ const o = b.json;
231
+ return o?.folder ? void 0 : o?.order;
232
+ })].filter((o) => typeof o === "number" && Number.isFinite(o));
233
+ let next = rootRanks.length ? Math.max(...rootRanks) + 1 : 0;
234
+ const added = [], existing = [];
235
+ const rows = [...raw];
236
+ for (const f of folders) {
237
+ if (have.has(f.name)) {
238
+ existing.push(f.name);
239
+ continue;
240
+ }
241
+ rows.push({
242
+ name: f.name,
243
+ order: next++,
244
+ ...f.title ? { title: f.title } : {},
245
+ ...f.type ? { type: f.type } : {}
246
+ });
247
+ have.add(f.name);
248
+ added.push(f.name);
249
+ }
250
+ if (!added.length) return {
251
+ added,
252
+ existing
253
+ };
254
+ const version = rows.some((f) => f.parent !== void 0) ? 2 : 1;
255
+ const tmp = `${file}.${process.pid}.${Date.now()}.${attempt}.tmp`;
256
+ writeFileSync(tmp, JSON.stringify({
257
+ version,
258
+ folders: rows
259
+ }, null, 2) + "\n", { flag: "wx" });
260
+ if ((nodeExists(file) ? readFileSync(file, "utf8") : null) !== before) {
261
+ rmSync(tmp, { force: true });
262
+ continue;
263
+ }
264
+ renameSync(tmp, file);
265
+ return {
266
+ added,
267
+ existing
268
+ };
269
+ }
270
+ throw new Error(`design/boards/${FOLDERS_FILE} kept changing while folders were added - try again`);
271
+ }
272
+ function readMembership(root, live) {
273
+ const dir = join(root, "design", "boards");
274
+ const files = checkBoardsDir(root, dir) ? [] : listBoardFiles(dir).boards;
275
+ const reg = readRegistry(dir);
276
+ const folders = reg.state === "ok" ? reg.folders : [];
277
+ const rows = files.map((b) => ({
278
+ name: b.name,
279
+ ...boardFields(b.json, isBoardName)
280
+ }));
281
+ const tree = buildTree(rows, folders);
282
+ const fm = folderMap(tree);
283
+ const byName = new Map(folders.map((f) => [f.name, f]));
284
+ const isArchive = (n) => {
285
+ const folder = byName.get(fm.get(n) ?? "");
286
+ return n === "archive" || resolveType(rows.find((r) => r.name === n)?.type, folder?.type, folder?.parent ? byName.get(folder.parent)?.type : void 0) === "archive";
287
+ };
288
+ const boards = archiveLast(flatten(tree), isArchive).map((name) => ({
289
+ name,
290
+ frames: framesOn(files.find((b) => b.name === name)?.json, live)
291
+ }));
292
+ const on = new Set(boards.flatMap((b) => b.frames));
293
+ return {
294
+ boards,
295
+ unplaced: live.filter((f) => !on.has(f))
296
+ };
297
+ }
298
+ /** What to say about frames on no board, one line each: the boards holding its scene's other frames,
299
+ * and the command that pins it - what `work done`, `marver link` and `comments new` print. */
300
+ function unplacedHint(m, frames) {
301
+ return frames.map((f) => {
302
+ const scene = f.split("/")[0];
303
+ const homes = m.boards.filter((b) => b.frames.some((x) => x !== f && x.split("/")[0] === scene)).map((b) => b.name);
304
+ return `${f} is on no board${homes.length ? ` (its scene's other frames are on ${homes.join(", ")})` : ""} - pin it where it belongs: npx marver boards pin ${homes[0] ?? "<board>"} ${f}`;
305
+ });
306
+ }
307
+ /** `boards pin`: append frames to a board as nodes - the shell sizes and lays them out, as for any
308
+ * node an agent appends. A frame the board already shows is skipped (every frame, on an `auto`
309
+ * board). Never creates a board; a malformed one is the human's to fix. */
310
+ function pinFrames(root, board, frames, live) {
311
+ if (!isBoardName(board) || board === "all-scenes") throw new Error(`"${board}" is not a board name - lowercase letters, numbers and dashes`);
312
+ const dir = join(root, "design", "boards");
313
+ const de = checkBoardsDir(root, dir);
314
+ if (de) throw new Error(de);
315
+ const file = join(dir, `${board}.json`);
316
+ if (!isRegularFile(file)) throw new Error(`no board "${board}" in design/boards/ - make it first (npx marver boards new ${board})`);
317
+ const content = readFileSync(file, "utf8");
318
+ const { json, error } = parseBoard(content);
319
+ if (error || !json || typeof json !== "object" || Array.isArray(json)) throw new Error(`design/boards/${board}.json is not a board object - fix the file${error ? ` (${error})` : ""}`);
320
+ const shown = new Set(framesOn(json, live));
321
+ const already = frames.filter((f) => shown.has(f));
322
+ const added = [...new Set(frames.filter((f) => !shown.has(f)))];
323
+ if (!added.length) return {
324
+ added,
325
+ already
326
+ };
327
+ const obj = json;
328
+ obj.nodes = [...Array.isArray(obj.nodes) ? obj.nodes : [], ...added.map((frame) => ({ frame }))];
329
+ const tmp = `${file}.${randomBytes(6).toString("hex")}.tmp`;
330
+ writeFileSync(tmp, JSON.stringify(obj, null, 2) + "\n", { flag: "wx" });
331
+ if (readFileSync(file, "utf8") !== content) {
332
+ rmSync(tmp, { force: true });
333
+ throw new Error(`design/boards/${board}.json changed while pinning - try again`);
334
+ }
335
+ renameSync(tmp, file);
336
+ return {
337
+ added,
338
+ already
339
+ };
340
+ }
341
+ //#endregion
342
+ export { checkRealDirs as a, nodeExists as c, readMembership as d, readRegistry as f, hash as h, checkBoardsDir as i, parseBoard as l, withRegistryLock as m, addFolders as n, isRegularFile as o, unplacedHint as p, boardFields as r, listBoardFiles as s, AUTHOR_FIELDS as t, pinFrames as u };
@@ -1,6 +1,8 @@
1
1
  import { r as NAME } from "./cli.mjs";
2
- import { A as knownType, E as FOLDER_MODULES, F as resolveType, _ as folderMap, a as checkRealDirs, h as flatten, i as checkBoardsDir, j as readCapability, m as buildTree, n as addFolders, r as boardFields, s as listBoardFiles, u as readRegistry, v as humanize, w as BOARD_TYPES, y as isBoardName } from "./boards-BRLnoTC3.mjs";
3
- import { a as PHASE_LABEL, s as STATUS_LABEL, t as annotateBoards } from "./board-status-BZSzc9Hp.mjs";
2
+ import { a as checkRealDirs, d as readMembership, f as readRegistry, i as checkBoardsDir, n as addFolders, r as boardFields, s as listBoardFiles, u as pinFrames } from "./boards-CGg6piKF.mjs";
3
+ import { T as readCapability, a as buildTree, b as FOLDER_MODULES, c as folderMap, f as isBoardName, k as resolveType, o as flatten, u as humanize, v as BOARD_TYPES, w as knownType } from "./board-tree-DRioF94d.mjs";
4
+ import { _ as STATUS_LABEL, d as annotateBoards, h as PHASE_LABEL, s as scanFrames } from "./manifest-DnAte_fB.mjs";
5
+ import { resolveTargets } from "./link-C-qUIuKU.mjs";
4
6
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
5
7
  import { join } from "node:path";
6
8
  //#region src/cli/boards.ts
@@ -23,11 +25,11 @@ function boardsCommand(root, opts) {
23
25
  ...b.error ? { error: b.error } : {}
24
26
  }));
25
27
  const tree = buildTree(rows, reg.folders);
26
- const hasAll = boards.some((b) => b.name === "all-scenes");
27
28
  const fm = folderMap(tree);
28
- const notes = annotateBoards(root, boards.filter((b) => b.name !== "all-scenes"), reg.folders, (n) => fm.get(n) ?? null);
29
+ const notes = annotateBoards(root, boards, reg.folders, (n) => fm.get(n) ?? null);
30
+ const { unplaced } = readMembership(root, scanFrames(root).frames.map((f) => f.id));
29
31
  if (opts.json) {
30
- const out = rows.filter((r) => r.name !== "all-scenes").map((r) => ({
32
+ const out = rows.map((r) => ({
31
33
  ...r,
32
34
  ...notes.get(r.name) ?? {}
33
35
  }));
@@ -35,14 +37,19 @@ function boardsCommand(root, opts) {
35
37
  console.log(JSON.stringify({
36
38
  tree,
37
39
  boards: out,
38
- landing: flatten(tree)[0] ?? (hasAll ? "all-scenes" : null),
40
+ landing: flatten(tree)[0] ?? null,
41
+ unplaced,
39
42
  registry: reg.state === "ok" ? "design/boards/_folders.json" : null,
40
43
  ...Object.keys(invalid).length ? { invalid } : {}
41
44
  }, null, 2));
42
45
  return;
43
46
  }
44
- if (!tree.length && !hasAll) {
47
+ const notOnABoard = () => {
48
+ if (unplaced.length) console.log(`\nnot on a board (${unplaced.length}): ${unplaced.join(", ")}\n every frame goes on the board it belongs to: npx ${NAME} boards pin <board> <scene/frame ...>`);
49
+ };
50
+ if (!tree.length) {
45
51
  console.log("no boards yet - design/boards/ is empty");
52
+ notOnABoard();
46
53
  return;
47
54
  }
48
55
  const order = (n) => {
@@ -83,11 +90,11 @@ function boardsCommand(root, opts) {
83
90
  }
84
91
  };
85
92
  print(tree, "", null);
86
- if (hasAll) console.log(`all-scenes${bad("all-scenes")} (auto, always last)`);
87
93
  const landing = flatten(tree)[0];
88
94
  if (landing) console.log(`\nlanding board: ${landing}`);
89
95
  console.log(`registry: ${reg.state === "ok" ? "design/boards/_folders.json" : "none (no empty or ranked folders yet)"}`);
90
96
  if (skipped.length) console.log(`skipped (not regular files): ${skipped.join(", ")}`);
97
+ notOnABoard();
91
98
  if ([...notes.values()].filter((n) => n.status).length && !existsSync(join(root, "context"))) console.log(`\nno context/ yet - every feature and project board reads Backlog. Agent: end your reply with the context line in design/AGENTS.md ("Before the method").`);
92
99
  }
93
100
  /** `marver boards new <name>` - a board in its type's starting layout (spec 20): a feature's three
@@ -184,6 +191,13 @@ function boardsNew(root, name, opts) {
184
191
  created.unshift(`design/boards/${name}.json (${type}${opts.type ? "" : type === "plain" ? "" : `, from ${opts.folder}`})`);
185
192
  return created;
186
193
  }
194
+ /** `marver boards pin <board> <scene/frame | scene ...>` - put frames on a board without hand-editing
195
+ * its JSON (spec 26, Part 7): appended as nodes, the ones it already shows skipped. */
196
+ function boardsPin(root, board, targets) {
197
+ if (!targets.length) throw new Error("name the frames: boards pin <board> <scene/frame | scene ...>");
198
+ const live = scanFrames(root).frames.map((f) => f.id);
199
+ return pinFrames(root, board, resolveTargets(live, targets).all, live);
200
+ }
187
201
  /** `marver folders add <module...>` - the shared sidebar's typed folders (spec 20): start, features,
188
202
  * surfaces, projects, feedback, context, decks, archive. Appended; never renames or moves one. */
189
203
  function foldersAdd(root, modules) {
@@ -193,4 +207,4 @@ function foldersAdd(root, modules) {
193
207
  return addFolders(root, modules.map((m) => FOLDER_MODULES[m]));
194
208
  }
195
209
  //#endregion
196
- export { boardsCommand, boardsNew, foldersAdd };
210
+ export { boardsCommand, boardsNew, boardsPin, foldersAdd };
@@ -1,9 +1,10 @@
1
1
  import { a as ROUTE, r as NAME } from "./cli.mjs";
2
- import { h as flatten, i as checkBoardsDir, k as PROPOSED_PUBLISH, m as buildTree, r as boardFields, s as listBoardFiles, u as readRegistry, y as isBoardName } from "./boards-BRLnoTC3.mjs";
3
- import { c as publishableStatus, o as PUBLISHABLE } from "./board-status-BZSzc9Hp.mjs";
4
- import { s as scanFrames } from "./manifest-cyG3kbhk.mjs";
5
- import { n as loadConfig, r as detectHost } from "./config-BUKprFAp.mjs";
6
- import { a as autoWidthOf, c as readSizes, n as tailwind3Css, o as keptSizes, r as tailwind4Plugin, s as measuringFrames, t as marverPlugin } from "./plugin-Sa08E7wO.mjs";
2
+ import { f as readRegistry, i as checkBoardsDir, o as isRegularFile, r as boardFields, s as listBoardFiles } from "./boards-CGg6piKF.mjs";
3
+ import { C as PROPOSED_PUBLISH, a as buildTree, f as isBoardName, l as framesOn, o as flatten, t as ALL_SCENES } from "./board-tree-DRioF94d.mjs";
4
+ import { g as PUBLISHABLE, s as scanFrames, v as publishableStatus } from "./manifest-DnAte_fB.mjs";
5
+ import { a as readLog, r as legacyExposure, t as appendEvents } from "./comments-Zoch254k.mjs";
6
+ import { n as loadConfig, r as detectHost } from "./config-cKgZBRj0.mjs";
7
+ import { a as autoWidthOf, c as readSizes, n as tailwind3Css, o as keptSizes, r as tailwind4Plugin, s as measuringFrames, t as marverPlugin } from "./plugin-CTyhjwoJ.mjs";
7
8
  import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
8
9
  import { basename, dirname, join, sep } from "node:path";
9
10
  import { fileURLToPath } from "node:url";
@@ -255,7 +256,7 @@ const DECK_CHROME = [
255
256
  /** Publishing is default-CLOSED - no policy and no explicit flag = no build.
256
257
  * Boards absent from the result do not ship. */
257
258
  function resolvePolicy(root, allBoards, boardsFlag, allBoardsFlag) {
258
- const known = (n) => n === "all-scenes" || !!allBoards[n];
259
+ const known = (n) => !!allBoards[n];
259
260
  const reveal = {
260
261
  structure: true,
261
262
  source: false
@@ -264,9 +265,18 @@ function resolvePolicy(root, allBoards, boardsFlag, allBoardsFlag) {
264
265
  max,
265
266
  type: "mix"
266
267
  });
268
+ const withoutAllScenes = (names, where) => {
269
+ if (!names.includes("all-scenes")) return names;
270
+ const rest = names.filter((n) => n !== ALL_SCENES);
271
+ const curated = Object.keys(allBoards);
272
+ if (!rest.length) throw new Error(`${where} names only "${ALL_SCENES}" - the All Scenes board is gone since 0.25: name the boards to publish instead${curated.length ? ` (${curated.join(", ")})` : ""}, or --all-boards for every board`);
273
+ console.warn(` warning: ${where} names "${ALL_SCENES}" - the All Scenes board is gone since 0.25; dropped, these ship: ${rest.join(", ")}`);
274
+ return rest;
275
+ };
267
276
  if (boardsFlag !== void 0) {
268
- const names = boardsFlag.split(",").map((s) => s.trim()).filter(Boolean);
269
- if (!names.length) throw new Error("--boards was given but named no boards");
277
+ const named = boardsFlag.split(",").map((s) => s.trim()).filter(Boolean);
278
+ if (!named.length) throw new Error("--boards was given but named no boards");
279
+ const names = withoutAllScenes(named, "--boards");
270
280
  const missing = names.filter((n) => !known(n));
271
281
  if (missing.length) throw new Error(`--boards names not found in design/boards/: ${missing.join(", ")}`);
272
282
  return {
@@ -274,10 +284,13 @@ function resolvePolicy(root, allBoards, boardsFlag, allBoardsFlag) {
274
284
  reveal
275
285
  };
276
286
  }
277
- if (allBoardsFlag) return {
278
- boards: Object.fromEntries(["all-scenes", ...Object.keys(allBoards).filter((n) => n !== "all-scenes")].map((n) => [n, row("comment", n)])),
279
- reveal
280
- };
287
+ if (allBoardsFlag) {
288
+ if (!Object.keys(allBoards).length) throw new Error("--all-boards found no boards in design/boards/ - make one first (npx marver boards new <name>)");
289
+ return {
290
+ boards: Object.fromEntries(Object.keys(allBoards).map((n) => [n, row("comment", n)])),
291
+ reveal
292
+ };
293
+ }
281
294
  const policyFile = join(root, "design", "publish.json");
282
295
  if (!existsSync(policyFile)) throw new Error("publishing is default-closed and no publish policy exists.\n Either declare one in design/publish.json: { \"boards\": { \"<board>\": \"read\" | \"comment\" } }\n or be explicit: --boards a,b (publish just those) · --all-boards (publish everything)");
283
296
  let policy;
@@ -286,10 +299,11 @@ function resolvePolicy(root, allBoards, boardsFlag, allBoardsFlag) {
286
299
  } catch {
287
300
  throw new Error("design/publish.json is not valid JSON");
288
301
  }
289
- const entries = Object.entries(policy?.boards ?? {});
290
- if (!entries.length) throw new Error("design/publish.json has no \"boards\" entries - publishing is default-closed, name what ships");
302
+ const rows = policy?.boards ?? {};
303
+ if (!Object.keys(rows).length) throw new Error("design/publish.json has no \"boards\" entries - publishing is default-closed, name what ships");
291
304
  const out = {};
292
- for (const [n, level] of entries) {
305
+ for (const n of withoutAllScenes(Object.keys(rows), "design/publish.json")) {
306
+ const level = rows[n];
293
307
  if (!known(n)) throw new Error(`design/publish.json names an unknown board: ${n}`);
294
308
  if (level === "read" || level === "comment") {
295
309
  out[n] = row(level, n);
@@ -344,11 +358,10 @@ function readBoards(root) {
344
358
  }
345
359
  /** Switcher order = the sidebar's reading order: the folder tree over the PUBLISHED boards only
346
360
  * (a folder left with no published board at any depth drops out - its name never reaches the bundle),
347
- * flattened depth-first; all-scenes always LAST (it is the expensive everything-board, never
348
- * the landing). `names[0]` is where `/` opens. Folder names of published boards are structure,
349
- * like board names: they ship. */
361
+ * flattened depth-first. `names[0]` is where `/` opens. Folder names of published boards are
362
+ * structure, like board names: they ship. */
350
363
  function publishedTree(published, allBoards, folders) {
351
- const built = buildTree(published.filter((n) => n !== "all-scenes").map((n) => ({
364
+ const built = buildTree(published.map((n) => ({
352
365
  name: n,
353
366
  ...boardFields(allBoards[n], isBoardName)
354
367
  })), folders);
@@ -363,7 +376,7 @@ function publishedTree(published, allBoards, folders) {
363
376
  const tree = prune(built);
364
377
  return {
365
378
  tree,
366
- names: [...flatten(tree), ...published.includes("all-scenes") ? ["all-scenes"] : []]
379
+ names: flatten(tree)
367
380
  };
368
381
  }
369
382
  /** The bundle's manifest: the published frames, and descriptions of published things ONLY -
@@ -491,7 +504,7 @@ const chains = { ${rows.map((r) => `'${r.ok}': ${JSON.stringify(r.chain)}`).join
491
504
  export function layoutChain(fileKey) { return chains[fileKey] ?? [] }
492
505
  `;
493
506
  }
494
- /** The generated registry for filtered builds: explicit imports only, same exports. */
507
+ /** The generated registry of every build: explicit imports of the published frames only, same exports. */
495
508
  function registrySource(root, frameKeys) {
496
509
  const bases = ["/design/scenes", "/design/components"];
497
510
  const layouts = /* @__PURE__ */ new Set();
@@ -564,15 +577,19 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
564
577
  const buildSalt = randomBytes(16).toString("hex");
565
578
  const opaquePath = (id, ext) => `__mv/f/mv${createHash("sha256").update(buildSalt).update(id).digest("hex").slice(0, 12)}${ext}`;
566
579
  const { tree, names: publishedNames } = publishedTree(Object.keys(rights), allBoards, readFolders(root));
567
- const includeAll = publishedNames.includes("all-scenes");
568
580
  const boards = {};
569
581
  for (const n of publishedNames) if (allBoards[n]) boards[n] = withoutEvidence(allBoards[n]);
570
- let frames = manifest.frames;
571
- if (!includeAll) {
572
- const wanted = /* @__PURE__ */ new Set();
573
- for (const b of Object.values(boards)) for (const node of Array.isArray(b?.nodes) ? b.nodes : []) if (typeof node?.frame === "string") wanted.add(node.frame);
574
- frames = manifest.frames.filter((f) => wanted.has(f.id));
575
- }
582
+ const live = manifest.frames.map((f) => f.id);
583
+ const shows = Object.fromEntries(publishedNames.map((n) => [n, framesOn(boards[n], live)]));
584
+ const wanted = new Set(Object.values(shows).flat());
585
+ const frames = manifest.frames.filter((f) => wanted.has(f.id));
586
+ const leftover = join(root, "design", "boards", `${ALL_SCENES}.json`);
587
+ let oldNodes = null;
588
+ try {
589
+ if (isRegularFile(leftover)) oldNodes = JSON.parse(readFileSync(leftover, "utf8"))?.nodes;
590
+ } catch {}
591
+ const allScenesKeys = Object.fromEntries((Array.isArray(oldNodes) ? oldNodes : []).flatMap((n) => typeof n?.key === "string" && wanted.has(n?.frame) ? [[n.key, n.frame]] : []));
592
+ const filtered = frames.length < manifest.frames.length;
576
593
  const pubFrames = strip ? frames.map((f) => ({
577
594
  ...f,
578
595
  file: opaquePath(f.id, f.kind === "html" ? ".html" : "")
@@ -583,7 +600,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
583
600
  for (const n of publishedNames) {
584
601
  const pb = policy.boards[n];
585
602
  if (pb?.type !== "slides" && pb?.open !== "slides") continue;
586
- const ids = new Set((boards[n]?.nodes ?? []).map((x) => x.frame));
603
+ const ids = new Set(shows[n]);
587
604
  const on = pubManifest.frames.filter((f) => ids.has(f.id));
588
605
  const off = on.filter((f) => !(f.kind === "tsx" && f.slide));
589
606
  if (off.length === on.length) throw new Error(`design/publish.json: board "${n}" plays as slides but none of its ${on.length} frame(s) carry \`slide: true\` - add it to the frames' meta, or set "type"/"open" to "present" (0.13.0 let slides alias present; 0.14.0 plays only slide frames)`);
@@ -627,8 +644,9 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
627
644
  ...Object.keys(titles).length ? { titles } : {},
628
645
  ...Object.keys(meta).length ? { meta } : {},
629
646
  ...Object.keys(sizes).length ? { sizes } : {},
647
+ ...Object.keys(allScenesKeys).length ? { allScenesKeys } : {},
630
648
  ...Object.values(meta).some((m) => m.status) ? { statusAsOf: (/* @__PURE__ */ new Date()).toISOString() } : {},
631
- default: publishedNames.find((n) => n !== "all-scenes") ?? publishedNames[0],
649
+ default: publishedNames[0],
632
650
  rights,
633
651
  policy: {
634
652
  boards: boardsMeta,
@@ -654,7 +672,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
654
672
  id: f.id,
655
673
  file: posix(f.file)
656
674
  })), buildSalt);
657
- if (!includeAll) return registrySource(root, tsxFrames.map((f) => "/" + posix(f.file)));
675
+ return registrySource(root, tsxFrames.map((f) => "/" + posix(f.file)));
658
676
  }
659
677
  }
660
678
  }, react()];
@@ -664,7 +682,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
664
682
  }
665
683
  let css;
666
684
  if (host.tailwind === 3) css = await tailwind3Css(root) ?? void 0;
667
- plugins.push(marverPlugin({
685
+ plugins.push(...marverPlugin({
668
686
  root,
669
687
  clientDir,
670
688
  config,
@@ -762,7 +780,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
762
780
  const realAssets = existsSync(assetsDir) ? realpathSync(assetsDir) : null;
763
781
  for (const r of refs) {
764
782
  if (!isLocalAssetRef(r) || !r.endsWith(".poster.png") || existsSync(join(assetsDir, r))) continue;
765
- const { ensurePoster } = await import("./poster-B2QPvKOq.mjs");
783
+ const { ensurePoster } = await import("./poster-D0cbV7hi.mjs");
766
784
  const g = await ensurePoster(assetsDir, r.slice(0, -11));
767
785
  if (!g.ok) throw new Error(`design/assets/${r}: ${g.error}`);
768
786
  console.log(` poster: rendered design/assets/${r} (${g.width}×${g.height})`);
@@ -793,6 +811,13 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
793
811
  cpSync(f, join(seedOut, `${n}.jsonl`));
794
812
  seeded++;
795
813
  }
814
+ const old = readLog(commentsDir, ALL_SCENES);
815
+ const exposed = legacyExposure(old, rights, shows);
816
+ const kept = old.filter((e) => exposed(e).length);
817
+ if (kept.length) {
818
+ appendEvents(seedOut, ALL_SCENES, kept);
819
+ seeded++;
820
+ }
796
821
  if (seeded) console.log(` comments: ${seeded} board log${seeded === 1 ? "" : "s"} seeded${embedSeeds ? "" : " (design/.dist-seeds, outside the web root)"}`);
797
822
  if (seeded && embedSeeds) console.log(" WARNING: --embed-seeds put comment history in the web root - every event carries\n its author's email, readable by anyone who can reach the deployed files.");
798
823
  }
@@ -822,6 +847,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
822
847
  branding: config.share.branding,
823
848
  logo,
824
849
  rights,
850
+ shows,
825
851
  boards: boardsMeta,
826
852
  reveal: policy.reveal,
827
853
  ...config.share.frontDoor === false ? { frontDoor: false } : {},
@@ -829,7 +855,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
829
855
  }));
830
856
  let textureLine = " textures: skipped (--no-textures)";
831
857
  if (textures && bakeGen) {
832
- const { bakePublished } = await import("./publish-bakes-BJR3huhu.mjs");
858
+ const { bakePublished } = await import("./publish-bakes--l8ot2eQ.mjs");
833
859
  const pubFrameFile = new Map(pubFrames.map((f) => [f.id, f]));
834
860
  const r = await bakePublished({
835
861
  root,
@@ -840,7 +866,7 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
840
866
  log: (l) => console.log(l),
841
867
  frames: pubFrames,
842
868
  viewports: config.viewports,
843
- allScenes: includeAll,
869
+ autoBoard: Object.values(boards).some((b) => b?.auto === true),
844
870
  urlFor: (id, theme) => {
845
871
  const f = pubFrameFile.get(id);
846
872
  if (!f) return null;
@@ -852,9 +878,9 @@ async function buildSite(root, boardsFlag, allBoardsFlag, embedSeeds, textures =
852
878
  console.log(`\n ${NAME} build → design/.dist`);
853
879
  console.log(` boards: ${publishedNames.map((n) => `${n} (${rights[n]})`).join(", ")}`);
854
880
  console.log(textureLine);
855
- console.log(` frames: ${frames.length}${includeAll ? "" : ` of ${manifest.frames.length} (build-time filter)`}`);
881
+ console.log(` frames: ${frames.length}${filtered ? ` of ${manifest.frames.length} (build-time filter)` : ""}`);
856
882
  if (copiedAssets) console.log(` assets: ${copiedAssets} referenced file${copiedAssets === 1 ? "" : "s"} from design/assets/ (unreferenced assets never ship)`);
857
- if (!includeAll && existsSync(join(root, "public"))) console.log(` note: the host public/ directory ships in full - the --boards filter covers frames, not public assets`);
883
+ if (filtered && existsSync(join(root, "public"))) console.log(` note: the host public/ directory ships in full - the --boards filter covers frames, not public assets`);
858
884
  console.log(`\n serve it: npx ${NAME} serve (set MARVER_PASSWORD to gate it)\n`);
859
885
  }
860
886
  //#endregion