@marver-design/marver 0.27.0 → 0.28.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 (111) hide show
  1. package/CHANGELOG.md +195 -0
  2. package/README.md +9 -4
  3. package/dist/{anchor-check-ChdDqL5z.mjs → anchor-check-PHUOFj1N.mjs} +1 -1
  4. package/dist/{audio-Dw1lfMdb.mjs → audio-DX4POHAj.mjs} +39 -4
  5. package/dist/{board-tree-DRioF94d.mjs → board-tree-BXR8dw4b.mjs} +3 -1
  6. package/dist/{boards-DlTcpF47.mjs → boards-BeWtjGUM.mjs} +50 -5
  7. package/dist/boards-EH2onUXM.mjs +995 -0
  8. package/dist/{build-DZnFysGU.mjs → build-BsAyLMT1.mjs} +9 -22
  9. package/dist/{capture-vadKjuCo.mjs → capture-DdZ6xgoz.mjs} +92 -30
  10. package/dist/cli.mjs +56 -21
  11. package/dist/{collab-Dxg2trOK.mjs → collab-BEAcXrBb.mjs} +1 -1
  12. package/dist/{comments-DxOkCSNE.mjs → comments-CrBHPEQl.mjs} +4 -4
  13. package/dist/config-BezZTiov.mjs +182 -0
  14. package/dist/conn-BMiHS42T.mjs +222 -0
  15. package/dist/connectors-MR9d-EBP.mjs +290 -0
  16. package/dist/{context-HQ4Giw58.mjs → context-BUnFiyA3.mjs} +3 -3
  17. package/dist/{daemon-BSA0lV8d.mjs → daemon-C5dg2R-V.mjs} +2188 -183
  18. package/dist/{dev-eQJhWsqg.mjs → dev-D7YS7iT2.mjs} +25 -14
  19. package/dist/{init-COD0x48i.mjs → init-WE5lQkQL.mjs} +8 -3
  20. package/dist/jam-Cj5gBvwD.mjs +373 -0
  21. package/dist/{link-DDXZVGtv.mjs → link-BFFRgrMt.mjs} +4 -4
  22. package/dist/listener-DdLEM79A.mjs +80 -0
  23. package/dist/{ls-D7O1G505.mjs → ls-BZ5TAtd5.mjs} +1 -1
  24. package/dist/{manifest-Nl3KSVOk.mjs → manifest-DPZ3WNg_.mjs} +2 -2
  25. package/dist/{marks-CWM3WJjc.mjs → marks-Dyn6tmjp.mjs} +3 -3
  26. package/dist/{marks-CKgzucHZ.mjs → marks-Kmdab_5w.mjs} +3 -3
  27. package/dist/{marver-id-gate-BjF6v4bT.mjs → marver-id-gate-D-R0hSt_.mjs} +1 -1
  28. package/dist/perf-Cn5LiRaY.mjs +1319 -0
  29. package/dist/perf-jam-QxD_UnzN.mjs +635 -0
  30. package/dist/permit-DDa6wqOs.mjs +187 -0
  31. package/dist/plugin-C_0yb-Fq.mjs +5089 -0
  32. package/dist/{poster-Bx83ZYVK.mjs → poster-DHi6I1fO.mjs} +1 -1
  33. package/dist/{profile-Bh5Y5zpW.mjs → profile-jIS6BcAs.mjs} +1 -1
  34. package/dist/{publish-bakes-aljgm45S.mjs → publish-bakes-r4PEZuPl.mjs} +3 -3
  35. package/dist/{queue-CAM_vNmX.mjs → queue-c-6aTHEz.mjs} +164 -25
  36. package/dist/{recover-t9Pno3u9.mjs → recover-nrLEVLyJ.mjs} +2 -2
  37. package/dist/{serve-C8rVheYk.mjs → serve-Dp3nHstu.mjs} +3 -3
  38. package/dist/{session-BAaJsK5c.mjs → session-DyVE7cCk.mjs} +1 -1
  39. package/dist/{share-W5H3BNvP.mjs → share-Ce4tP7ji.mjs} +1 -1
  40. package/dist/{shot-LFhC-WYD.mjs → shot-BrRtqaiS.mjs} +34 -8
  41. package/dist/{shot-DoHLl6ig.mjs → shot-DBWN8hPP.mjs} +1 -1
  42. package/dist/sizes-wjXDev3b.mjs +139 -0
  43. package/dist/{slots-DCDo3N0x.mjs → slots-CFNnegCc.mjs} +8 -1
  44. package/dist/speech-worker.mjs +23 -3
  45. package/dist/{sync-BQVlHZpx.mjs → sync-CQdGARJ9.mjs} +1 -1
  46. package/dist/transport-C5FnY9ni.mjs +203 -0
  47. package/dist/{work-BroFwnup.mjs → work-BYWD_1Zf.mjs} +3 -3
  48. package/dist/{work-Bp1p39kq.mjs → work-DJxH7cCX.mjs} +1 -1
  49. package/docs/jam-session.md +42 -16
  50. package/docs/live-jam.md +92 -10
  51. package/docs/performance.md +197 -35
  52. package/package.json +1 -1
  53. package/src/client/content/video.tsx +10 -2
  54. package/src/client/shell/App.tsx +10 -3
  55. package/src/client/shell/Comments.tsx +5 -3
  56. package/src/client/shell/ContextMenu.tsx +5 -3
  57. package/src/client/shell/JamSurface.tsx +56 -21
  58. package/src/client/shell/LockedApp.tsx +3 -0
  59. package/src/client/shell/Play.tsx +4 -2
  60. package/src/client/shell/Tip.tsx +3 -1
  61. package/src/client/shell/api.ts +47 -20
  62. package/src/client/shell/app-bridge.ts +254 -0
  63. package/src/client/shell/app-perf.ts +92 -0
  64. package/src/client/shell/canvas/Canvas.tsx +115 -22
  65. package/src/client/shell/canvas/FrameNode.tsx +10 -6
  66. package/src/client/shell/canvas/admission.ts +23 -8
  67. package/src/client/shell/canvas/ctl.ts +6 -0
  68. package/src/client/shell/canvas/sleep.ts +57 -17
  69. package/src/client/shell/canvas/updates.ts +2 -1
  70. package/src/client/shell/icons.tsx +1 -0
  71. package/src/client/shell/inset.ts +44 -0
  72. package/src/client/shell/jam-capture.ts +113 -33
  73. package/src/client/shell/jam-keys.ts +40 -9
  74. package/src/client/shell/jam-lane.tsx +14 -5
  75. package/src/client/shell/jam-lines.ts +66 -9
  76. package/src/client/shell/jam-panel.tsx +61 -6
  77. package/src/client/shell/jam-queue.ts +50 -8
  78. package/src/client/shell/jam-session.tsx +53 -4
  79. package/src/client/shell/jam-surface-parts.tsx +6 -3
  80. package/src/client/shell/jam-ui.tsx +6 -1
  81. package/src/client/shell/jam-voice-wait.ts +21 -0
  82. package/src/client/shell/jam-voice.ts +62 -15
  83. package/src/client/shell/main.tsx +14 -1
  84. package/src/client/shell/marks-ui.tsx +5 -3
  85. package/src/client/shell/marver-app.ts +21 -0
  86. package/src/client/shell/perf-run-probe.ts +34 -0
  87. package/src/client/shell/perf-run.ts +70 -0
  88. package/src/client/shell/perf.ts +11 -0
  89. package/src/client/shell/recorder.ts +45 -3
  90. package/src/client/shell/store.ts +52 -24
  91. package/src/client/shell/styles.css +65 -17
  92. package/src/client/shell/tidy.ts +3 -2
  93. package/src/client/shell/unsaved.ts +81 -0
  94. package/src/client/shell/whiteout-probes.ts +141 -0
  95. package/src/shared/app-api.ts +205 -0
  96. package/src/shared/app-perf.ts +308 -0
  97. package/src/shared/approval.ts +20 -0
  98. package/src/shared/events.ts +1 -1
  99. package/src/shared/logo-sniff.ts +86 -0
  100. package/src/shared/machine.ts +132 -0
  101. package/src/shared/perf-run.ts +177 -0
  102. package/templates/AGENTS-embedded.md +31 -1
  103. package/templates/AGENTS-studio.md +31 -1
  104. package/templates/instructions/boards.md +10 -2
  105. package/templates/instructions/jam.md +90 -0
  106. package/dist/bake-DM_uWgAA.mjs +0 -786
  107. package/dist/boards-CGg6piKF.mjs +0 -342
  108. package/dist/perf-BWzQwZqj.mjs +0 -369
  109. package/dist/perf-BoDSkbEb.mjs +0 -429
  110. package/dist/perf-jam-D55U3FZK.mjs +0 -242
  111. package/dist/plugin-C-E7omsh.mjs +0 -2762
@@ -1,342 +0,0 @@
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 };