@marver-design/marver 0.25.1 → 0.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/README.md +5 -3
  3. package/dist/{anchor-DVV732zR.mjs → anchor-5H1vnoLu.mjs} +6 -1
  4. package/dist/{anchor-check-DGZnYviN.mjs → anchor-check-l-ny3UzH.mjs} +1 -1
  5. package/dist/audio-Dw1lfMdb.mjs +443 -0
  6. package/dist/{auth-DdUKeVKt.mjs → auth-Dix8wrXV.mjs} +1 -1
  7. package/dist/{bake-BpxMZfij.mjs → bake-C-awKgLA.mjs} +1 -1
  8. package/dist/{boards-Csxj2WJn.mjs → boards-DYG22tOe.mjs} +2 -2
  9. package/dist/{build-DKaGhoVN.mjs → build-BDRiO_mP.mjs} +16 -9
  10. package/dist/capture-vadKjuCo.mjs +730 -0
  11. package/dist/cli.mjs +24 -18
  12. package/dist/{collab-gqNdScUE.mjs → collab-Dxg2trOK.mjs} +4 -3
  13. package/dist/{comments-Zoch254k.mjs → comments-0BSbb04K.mjs} +14 -3
  14. package/dist/{comments-pTLlhjh4.mjs → comments-BqXua-XL.mjs} +7 -7
  15. package/dist/{config-cKgZBRj0.mjs → config-Cf7EjAMf.mjs} +12 -1
  16. package/dist/{context-D2ugHqwO.mjs → context-HQ4Giw58.mjs} +1 -1
  17. package/dist/daemon-DL6Fwq6D.mjs +2569 -0
  18. package/dist/{dev-Diqx1Rt8.mjs → dev-Bw_qYWWq.mjs} +202 -18
  19. package/dist/dev-lock-DWSpa6nj.mjs +179 -0
  20. package/dist/{events-DnK_AnrW.mjs → events-CLH4ijKP.mjs} +14 -4
  21. package/dist/{init-DO4DhUt_.mjs → init-D8DtrK_F.mjs} +2 -2
  22. package/dist/{ledger-BNXW14Xw.mjs → ledger-D54iROST.mjs} +17 -1
  23. package/dist/{link-C-qUIuKU.mjs → link-BNzLvdhI.mjs} +2 -2
  24. package/dist/live-Cgzsicwi.mjs +4 -0
  25. package/dist/{manifest-DnAte_fB.mjs → manifest-Nl3KSVOk.mjs} +1 -1
  26. package/dist/{marks-koRsbHfe.mjs → marks-CKgzucHZ.mjs} +2 -2
  27. package/dist/{marks-DFuintmJ.mjs → marks-DyWMv_Z1.mjs} +23 -5
  28. package/dist/{marver-id-gate-DGANtVyC.mjs → marver-id-gate-BjF6v4bT.mjs} +4 -4
  29. package/dist/perf-C75MZ73h.mjs +167 -0
  30. package/dist/{perf-CCisg-ny.mjs → perf-DPbLGhhO.mjs} +1 -1
  31. package/dist/perf-jam-BU3TVrZu.mjs +239 -0
  32. package/dist/{plugin-dTF5reck.mjs → plugin-DkGmZs_r.mjs} +298 -38
  33. package/dist/{poster-D-zjYpgk.mjs → poster-BdtSKMDm.mjs} +2 -1
  34. package/dist/{profile-Do0nGkXO.mjs → profile-WU9qcbIo.mjs} +1 -1
  35. package/dist/{publish-bakes-C_9VZ-Mq.mjs → publish-bakes-9RzRToXV.mjs} +3 -3
  36. package/dist/queue-29ok5_eZ.mjs +1319 -0
  37. package/dist/reserve-BURNQ2Y3.mjs +53 -0
  38. package/dist/{rolldown-runtime-D7D4PA-g.mjs → rolldown-runtime-8H4AJuhK.mjs} +1 -0
  39. package/dist/{serve-wv2QWdxB.mjs → serve-C8rVheYk.mjs} +12 -12
  40. package/dist/session-BAaJsK5c.mjs +191 -0
  41. package/dist/{share-ScamJcks.mjs → share--oFJ1bCI.mjs} +2 -2
  42. package/dist/{shot-CUlmkqFX.mjs → shot-DQeR_Pfn.mjs} +339 -20
  43. package/dist/shot-XQV7HC9A.mjs +139 -0
  44. package/dist/speech-models-DomiLQcY.mjs +299 -0
  45. package/dist/speech-worker.mjs +354 -0
  46. package/dist/{summary-CrW88e3q.mjs → summary-Y8MY1Wuc.mjs} +2 -2
  47. package/dist/{sync-C3035OnJ.mjs → sync-DKk-yT1V.mjs} +9 -8
  48. package/dist/{work-GE88wb_3.mjs → work-F5u-twpJ.mjs} +28 -5
  49. package/dist/{work-CpJn1gwY.mjs → work-VvX_JIgl.mjs} +2 -2
  50. package/docs/jam-session.md +194 -0
  51. package/docs/live-jam.md +29 -3
  52. package/package.json +7 -1
  53. package/src/client/frame-host/bridge.js +20 -2
  54. package/src/client/frame-host/inspect.d.ts +4 -0
  55. package/src/client/frame-host/inspect.js +96 -6
  56. package/src/client/frame-host/keys.d.ts +6 -0
  57. package/src/client/frame-host/keys.js +59 -0
  58. package/src/client/frame-host/trail.d.ts +7 -0
  59. package/src/client/frame-host/trail.js +204 -0
  60. package/src/client/shell/App.tsx +52 -8
  61. package/src/client/shell/Comments.tsx +20 -6
  62. package/src/client/shell/JamSurface.tsx +346 -0
  63. package/src/client/shell/Play.tsx +32 -9
  64. package/src/client/shell/Tip.tsx +8 -3
  65. package/src/client/shell/Toolbar.tsx +5 -4
  66. package/src/client/shell/canvas/Canvas.tsx +12 -2
  67. package/src/client/shell/canvas/FrameNode.tsx +14 -4
  68. package/src/client/shell/comments-store.ts +23 -16
  69. package/src/client/shell/icons.tsx +17 -0
  70. package/src/client/shell/jam-capture.ts +1005 -0
  71. package/src/client/shell/jam-keys.ts +358 -0
  72. package/src/client/shell/jam-lane.tsx +249 -0
  73. package/src/client/shell/jam-lines.ts +115 -0
  74. package/src/client/shell/jam-panel.tsx +556 -0
  75. package/src/client/shell/jam-queue.ts +126 -0
  76. package/src/client/shell/jam-session.tsx +389 -0
  77. package/src/client/shell/jam-state.ts +103 -0
  78. package/src/client/shell/jam-surface-parts.tsx +106 -0
  79. package/src/client/shell/jam-ui.tsx +104 -0
  80. package/src/client/shell/jam-voice.ts +479 -0
  81. package/src/client/shell/sound.ts +22 -0
  82. package/src/client/shell/stage-size.ts +11 -0
  83. package/src/client/shell/store.ts +47 -17
  84. package/src/client/shell/styles.css +564 -2
  85. package/src/client/stage/main.tsx +18 -2
  86. package/src/shared/capture-frames.ts +41 -0
  87. package/src/shared/events.ts +19 -4
  88. package/src/shared/speech.ts +16 -0
  89. package/templates/AGENTS-embedded.md +10 -2
  90. package/templates/AGENTS-studio.md +10 -2
  91. package/templates/instructions/iterate.md +8 -6
  92. package/templates/instructions/jam.md +131 -59
  93. package/dist/daemon-Cl8KXGW4.mjs +0 -1523
  94. package/dist/perf-QJIWtTw1.mjs +0 -68
  95. package/dist/shot-jdO_B6Qw.mjs +0 -86
@@ -1,12 +1,13 @@
1
1
  import { i as PKG, r as NAME } from "./cli.mjs";
2
- import { n as loadConfig, r as detectHost } from "./config-cKgZBRj0.mjs";
3
- import { n as tailwind3Css, r as tailwind4Plugin, t as marverPlugin } from "./plugin-dTF5reck.mjs";
2
+ import { n as loadConfig, r as detectHost } from "./config-Cf7EjAMf.mjs";
3
+ import { n as tailwind3Css, r as tailwind4Plugin, t as marverPlugin } from "./plugin-DkGmZs_r.mjs";
4
4
  import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, watch } from "node:fs";
5
- import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
5
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
- import { createLogger, createServer, parseAst, searchForWorkspaceRoot } from "vite";
7
+ import { createServer } from "node:net";
8
+ import { createLogger, createServer as createServer$1, parseAst, parseSync, searchForWorkspaceRoot } from "vite";
8
9
  import react from "@vitejs/plugin-react";
9
- import { createServer as createServer$1 } from "node:net";
10
+ import MagicString from "magic-string";
10
11
  //#region src/server/icons.ts
11
12
  /**
12
13
  * Icon barrels, unrolled.
@@ -200,13 +201,116 @@ function iconsPlugin(root) {
200
201
  };
201
202
  }
202
203
  //#endregion
204
+ //#region src/server/loc.ts
205
+ /**
206
+ * Every element knows its source (spec 27, Part 6). A dev-only transform on design files adds
207
+ * `data-mv-loc="<path>:<line>:<col>"` to every HOST JSX element - a lowercase plain name (`<div>`,
208
+ * `<button>`, `<my-el>`). Components (`<Card>`) and member names (`<motion.div>`) are skipped: they
209
+ * may not pass attributes on. The laser and a capture's bundles already read `dataset.mvLoc` into
210
+ * `source` (frame-host/inspect.js), so a pick names its file and line and the agent goes there first.
211
+ *
212
+ * It parses with Vite's own `parseSync` (oxc), so anything Vite compiles it reads, and inserts the
213
+ * attribute right after the tag name - FIRST, so an explicit `data-mv-loc` or a spread later in the
214
+ * tag wins. Edits go through magic-string, whose hires map composes with Vite's.
215
+ *
216
+ * Location: the `<` of the opening tag in the ORIGINAL source, 1-based line and 1-based column, the
217
+ * column in UTF-16 code units - what JS string indices, source maps and editors' column counters
218
+ * (VS Code included) use, so an emoji before the tag counts 2.
219
+ */
220
+ const DESIGN_FILE = /\.(tsx|jsx)$/;
221
+ /** Line starts of `code`, so an offset becomes a 1-based line and column. */
222
+ function lineIndex(code) {
223
+ const starts = [0];
224
+ for (let i = 0; i < code.length; i++) if (code.charCodeAt(i) === 10) starts.push(i + 1);
225
+ return (offset) => {
226
+ let lo = 0, hi = starts.length - 1;
227
+ while (lo < hi) {
228
+ const mid = lo + hi + 1 >> 1;
229
+ if (starts[mid] <= offset) lo = mid;
230
+ else hi = mid - 1;
231
+ }
232
+ return {
233
+ line: lo + 1,
234
+ col: offset - starts[lo] + 1
235
+ };
236
+ };
237
+ }
238
+ /** Add `data-mv-loc` to every host element of one design file. `file` is the path the attribute
239
+ * names (relative to the repo root, forward slashes). Null when there is nothing to add or the
240
+ * file does not parse - Vite then reports the error as it would have. */
241
+ function addSourceLocations(code, file) {
242
+ if (!code.includes("<")) return null;
243
+ const parsed = parseSync(file, code, {
244
+ lang: file.endsWith(".jsx") ? "jsx" : "tsx",
245
+ sourceType: "module"
246
+ });
247
+ if (parsed.errors.length) return null;
248
+ const at = lineIndex(code);
249
+ const s = new MagicString(code);
250
+ let added = 0;
251
+ const walk = (n) => {
252
+ if (!n || typeof n !== "object") return;
253
+ if (Array.isArray(n)) {
254
+ for (const x of n) walk(x);
255
+ return;
256
+ }
257
+ const node = n;
258
+ if (node.type === "JSXOpeningElement" && node.name?.type === "JSXIdentifier" && /^[a-z]/.test(node.name.name ?? "") && typeof node.start === "number" && typeof node.name.end === "number") {
259
+ const { line, col } = at(node.start);
260
+ s.appendLeft(node.name.end, ` data-mv-loc={${JSON.stringify(`${file}:${line}:${col}`)}}`);
261
+ added++;
262
+ }
263
+ for (const k in node) if (k !== "parent") walk(node[k]);
264
+ };
265
+ walk(parsed.program);
266
+ if (!added) return null;
267
+ return {
268
+ code: s.toString(),
269
+ map: s.generateMap({
270
+ hires: true,
271
+ source: file,
272
+ includeContent: true
273
+ })
274
+ };
275
+ }
276
+ /** The dev server's plugin: design/**\/*.tsx|jsx only, never node_modules, never the published
277
+ * build (dev.ts adds it; build.ts does not). Ids are real paths, so the root is matched both ways. */
278
+ function locPlugin(root) {
279
+ const roots = [.../* @__PURE__ */ new Set([root, safeReal$1(root)])];
280
+ const repoPath = (id) => {
281
+ const file = id.split("?")[0];
282
+ if (!DESIGN_FILE.test(file) || file.includes(`${sep}node_modules${sep}`) || file.includes("/node_modules/")) return null;
283
+ for (const r of roots) {
284
+ const rel = relative(r, file);
285
+ if (!rel.startsWith("..") && (rel.startsWith(`design${sep}`) || rel.startsWith("design/"))) return rel.split(sep).join("/");
286
+ }
287
+ return null;
288
+ };
289
+ return {
290
+ name: "marver:loc",
291
+ enforce: "pre",
292
+ apply: "serve",
293
+ transform(code, id) {
294
+ const file = repoPath(id);
295
+ return file ? addSourceLocations(code, file) : null;
296
+ }
297
+ };
298
+ }
299
+ function safeReal$1(p) {
300
+ try {
301
+ return realpathSync(p);
302
+ } catch {
303
+ return p;
304
+ }
305
+ }
306
+ //#endregion
203
307
  //#region src/server/dev.ts
204
308
  /** packageDir = the installed marver package root (dist/cli.js lives one level down). */
205
309
  function packageDir() {
206
310
  return join(dirname(fileURLToPath(import.meta.url)), "..");
207
311
  }
208
312
  const portFree = (p) => new Promise((res) => {
209
- const s = createServer$1();
313
+ const s = createServer();
210
314
  s.once("error", () => res(false));
211
315
  s.once("listening", () => s.close(() => res(true)));
212
316
  s.listen(p, "127.0.0.1");
@@ -346,7 +450,40 @@ function denyLocalSecrets(root) {
346
450
  }
347
451
  };
348
452
  }
453
+ /** A canvas already runs in this folder (or one is starting): the line says where, or what to do. */
454
+ var DevLockError = class extends Error {};
349
455
  async function dev(root, portFlag) {
456
+ const { takeDevLock } = await import("./dev-lock-DWSpa6nj.mjs").then((n) => n.n);
457
+ const lock = await takeDevLock(root);
458
+ if (!lock.ok) throw new DevLockError(lock.message);
459
+ const { removeDevInfo } = await import("./work-F5u-twpJ.mjs").then((n) => n.o);
460
+ const onExit = () => {
461
+ removeDevInfo(root, lock.instance);
462
+ lock.release();
463
+ };
464
+ const onSignal = (sig) => {
465
+ onExit();
466
+ process.kill(process.pid, sig);
467
+ };
468
+ process.once("exit", onExit);
469
+ process.once("SIGINT", onSignal);
470
+ process.once("SIGTERM", onSignal);
471
+ process.once("SIGHUP", onSignal);
472
+ const unhook = () => {
473
+ process.off("exit", onExit);
474
+ process.off("SIGINT", onSignal);
475
+ process.off("SIGTERM", onSignal);
476
+ process.off("SIGHUP", onSignal);
477
+ lock.release();
478
+ };
479
+ try {
480
+ return await boot(root, portFlag, lock.instance, unhook);
481
+ } catch (err) {
482
+ unhook();
483
+ throw err;
484
+ }
485
+ }
486
+ async function boot(root, portFlag, instance, unhook) {
350
487
  const config = await loadConfig(root);
351
488
  const host = detectHost(root);
352
489
  const pkgDir = packageDir();
@@ -357,6 +494,7 @@ async function dev(root, portFlag) {
357
494
  const esc = (p) => join(p, "design").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
358
495
  const designDir = new RegExp(`^(${[.../* @__PURE__ */ new Set([root, safeReal(root)])].map(esc).join("|")})[/\\\\]`);
359
496
  const plugins = [denyLocalSecrets(root), react({ exclude: [/\/node_modules\//, designDir] })];
497
+ if (config.jam?.loc !== false) plugins.unshift(locPlugin(root));
360
498
  if (host.tailwind === 4) {
361
499
  const tw = await tailwind4Plugin(root);
362
500
  if (tw) plugins.push(...tw);
@@ -380,9 +518,10 @@ async function dev(root, portFlag) {
380
518
  logger.warnOnce = (msg, opts) => {
381
519
  if (!noise(msg)) warnOnceBase(msg, opts);
382
520
  };
383
- const server = await createServer({
521
+ const server = await createServer$1({
384
522
  configFile: false,
385
523
  root,
524
+ cacheDir: join(root, "node_modules", ".vite-marver"),
386
525
  css,
387
526
  customLogger: logger,
388
527
  plugins,
@@ -444,6 +583,10 @@ async function dev(root, portFlag) {
444
583
  `${PKG} > mermaid`,
445
584
  `${PKG} > roughjs`,
446
585
  `${PKG} > html-to-image`,
586
+ `${PKG} > echarts/core`,
587
+ `${PKG} > echarts/renderers`,
588
+ `${PKG} > echarts/charts`,
589
+ `${PKG} > echarts/components`,
447
590
  ...iconModules(root)
448
591
  ],
449
592
  entries: [join(clientDir, "frame-host", "index.html"), "design/**/*.{tsx,jsx}"]
@@ -457,12 +600,12 @@ async function dev(root, portFlag) {
457
600
  console.log(`\n ${NAME} · ${projectName} → http://localhost:${port}/\n`);
458
601
  setTimeout(async () => {
459
602
  try {
460
- await (await import("./shot-CUlmkqFX.mjs")).sweepGhosts((m) => console.log(` ${m}`));
603
+ await (await import("./shot-DQeR_Pfn.mjs")).sweepGhosts((m) => console.log(` ${m}`));
461
604
  } catch {}
462
605
  }, 0);
463
606
  try {
464
607
  const { staleManagedInstructions } = await import("./managed-HwHVNI3h.mjs");
465
- const { installedVersion } = await import("./plugin-dTF5reck.mjs").then((n) => n.i);
608
+ const { installedVersion } = await import("./plugin-DkGmZs_r.mjs").then((n) => n.i);
466
609
  const stale = staleManagedInstructions(root);
467
610
  if (stale.length) {
468
611
  const shown = stale.slice(0, 4).join(", ") + (stale.length > 4 ? `, +${stale.length - 4} more` : "");
@@ -472,11 +615,11 @@ async function dev(root, portFlag) {
472
615
  } catch {}
473
616
  try {
474
617
  if (!existsSync(join(root, "context"))) {
475
- const n = (await import("./manifest-DnAte_fB.mjs").then((n) => n.i)).statusBoards(root).length;
618
+ const n = (await import("./manifest-Nl3KSVOk.mjs").then((n) => n.i)).statusBoards(root).length;
476
619
  if (n) console.log(` ${n} feature/project board${n === 1 ? "" : "s"}, no context/ - every status reads Backlog. To start it, tell your agent: "Set up our context."\n`);
477
620
  }
478
621
  } catch {}
479
- const { loadCollab, syncOnce } = await import("./sync-C3035OnJ.mjs").then((n) => n.o);
622
+ const { loadCollab, syncOnce } = await import("./sync-DKk-yT1V.mjs").then((n) => n.o);
480
623
  if (loadCollab(root)) console.log(` comments: syncing with the published canvas\n`);
481
624
  let syncing = false;
482
625
  const tick = async () => {
@@ -491,7 +634,7 @@ async function dev(root, portFlag) {
491
634
  };
492
635
  tick();
493
636
  setInterval(tick, 3e4).unref();
494
- const { workActivity, writeDevInfo, removeDevInfo, boardsShowing, onBoardsChanged, nextActivitySeq } = await import("./work-GE88wb_3.mjs").then((n) => n.o);
637
+ const { workActivity, writeDevInfo, removeDevInfo, boardsShowing, onBoardsChanged, nextActivitySeq } = await import("./work-F5u-twpJ.mjs").then((n) => n.o);
495
638
  let sent = "";
496
639
  const broadcast = (frames) => {
497
640
  const state = {
@@ -512,14 +655,15 @@ async function dev(root, portFlag) {
512
655
  });
513
656
  const sweep = setInterval(() => workActivity.sweep(), 15e3);
514
657
  sweep.unref?.();
515
- writeDevInfo(root, port);
658
+ writeDevInfo(root, port, instance);
516
659
  {
517
660
  const close = server.close.bind(server);
518
661
  server.close = (async () => {
519
662
  unsubscribe();
520
663
  offBoards();
521
664
  clearInterval(sweep);
522
- removeDevInfo(root);
665
+ removeDevInfo(root, instance);
666
+ unhook();
523
667
  return close();
524
668
  });
525
669
  }
@@ -546,8 +690,8 @@ async function dev(root, portFlag) {
546
690
  } catch {}
547
691
  }
548
692
  if (config.jam) {
549
- const { startJam } = await import("./daemon-Cl8KXGW4.mjs");
550
- const { checkAnchor } = await import("./anchor-check-DGZnYviN.mjs");
693
+ const { startJam } = await import("./daemon-DL6Fwq6D.mjs");
694
+ const { checkAnchor } = await import("./anchor-check-l-ny3UzH.mjs");
551
695
  const jam = startJam(root, config.jam, (m) => console.log(m), (board) => server.ws.send("sh:jam-comment", { board }), (frameId, target, others, look) => checkAnchor({
552
696
  root,
553
697
  viewports: config.viewports,
@@ -556,11 +700,51 @@ async function dev(root, portFlag) {
556
700
  target,
557
701
  others,
558
702
  ...look
559
- }));
703
+ }), (() => {
704
+ let due = null;
705
+ return () => {
706
+ due ??= setTimeout(async () => {
707
+ due = null;
708
+ const { jamLive } = await import("./live-Cgzsicwi.mjs");
709
+ server.ws.send("sh:jam-queue", jamLive.view?.() ?? { cards: [] });
710
+ }, 60);
711
+ };
712
+ })(), async (frameId, theme, entry, size) => {
713
+ const { shootFrame } = await import("./shot-DQeR_Pfn.mjs");
714
+ const r = await shootFrame({
715
+ root,
716
+ viewports: config.viewports,
717
+ frameId,
718
+ theme,
719
+ origin: `http://localhost:${port}`,
720
+ ...size ? { size } : {}
721
+ });
722
+ if (!r.ok) return null;
723
+ const { addPicture } = await import("./capture-vadKjuCo.mjs").then((n) => n.i);
724
+ return addPicture(root, r.path, {
725
+ frame: frameId,
726
+ ...entry,
727
+ .../not checked for a stale surface/.test(r.note ?? "") ? { unchecked: true } : {}
728
+ });
729
+ });
560
730
  if (jam) {
731
+ const { createSpeech, speechLive } = await import("./audio-Dw1lfMdb.mjs");
732
+ const { appendTalk } = await import("./session-BAaJsK5c.mjs").then((n) => n.s);
733
+ const { logJam } = await import("./perf-jam-BU3TVrZu.mjs").then((n) => n.n);
734
+ const speech = createSpeech({
735
+ onTalk: (t) => appendTalk(root, t.session, t.words),
736
+ onTiming: (t) => logJam(root, {
737
+ kind: "words",
738
+ ...t
739
+ })
740
+ });
741
+ if (server.httpServer) speech.attach(server.httpServer);
742
+ speechLive.svc = speech;
561
743
  const close = server.close.bind(server);
562
744
  server.close = (async () => {
563
745
  jam.stop();
746
+ speech.stop();
747
+ speechLive.svc = void 0;
564
748
  return close();
565
749
  });
566
750
  }
@@ -568,4 +752,4 @@ async function dev(root, portFlag) {
568
752
  return server;
569
753
  }
570
754
  //#endregion
571
- export { dev };
755
+ export { DevLockError, dev };
@@ -0,0 +1,179 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
+ import { linkSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { randomBytes, randomUUID } from "node:crypto";
5
+ import { createServer } from "node:net";
6
+ //#region src/server/dev-lock.ts
7
+ /**
8
+ * One canvas per folder (#19, spec 27 Part 7). `marver dev` takes design/.local/dev.lock before it
9
+ * starts the server, so a second `marver dev` in the same folder says where the first one runs
10
+ * instead of taking over dev.json (which the CLI - `work`, `shot`, `comments new --on` - reads to
11
+ * find the canvas).
12
+ *
13
+ * The rules, none of which guess a holder dead from time or from an unanswered request:
14
+ * - no lock: create it exclusively. Done.
15
+ * - a lock whose pid runs: a canvas runs here (a slow or paused one too) - stop with its link.
16
+ * - a lock whose pid is dead: reclaim it while holding dev.lock.reclaim (also exclusive): read it
17
+ * again, still the same dead holder -> replace it. A reclaim lock already there means another
18
+ * start is reclaiming: wait a second and start over once; still there -> fail closed.
19
+ * - a 0.25 server writes no lock and no pid: dev.json without a lock is decided by binding its port.
20
+ *
21
+ * Both files are created by linking a fully written temp file into place, so a reader never sees
22
+ * an empty or half-written lock - `link` fails if the name exists, which is the exclusive create.
23
+ */
24
+ var dev_lock_exports = /* @__PURE__ */ __exportAll({
25
+ RECLAIM_STUCK: () => RECLAIM_STUCK,
26
+ createExclusive: () => createExclusive,
27
+ pidRuns: () => pidRuns,
28
+ portInUse: () => portInUse,
29
+ releaseDevLock: () => releaseDevLock,
30
+ takeDevLock: () => takeDevLock
31
+ });
32
+ const localDir = (root) => join(root, "design", ".local");
33
+ const lockPath = (root) => join(localDir(root), "dev.lock");
34
+ const reclaimPath = (root) => `${lockPath(root)}.reclaim`;
35
+ const infoPath = (root) => join(localDir(root), "dev.json");
36
+ /** Is this pid a running process? EPERM means it runs under another user - still running. A
37
+ * process paused with SIGSTOP runs too, as far as this is concerned. */
38
+ function pidRuns(pid) {
39
+ if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) return false;
40
+ try {
41
+ process.kill(pid, 0);
42
+ return true;
43
+ } catch (err) {
44
+ return err.code === "EPERM";
45
+ }
46
+ }
47
+ /** Create `file` holding `body`, failing with EEXIST if it is there - atomically, content included. */
48
+ function createExclusive(file, body) {
49
+ const tmp = `${file}.${randomBytes(6).toString("hex")}.tmp`;
50
+ writeFileSync(tmp, body, { mode: 384 });
51
+ try {
52
+ linkSync(tmp, file);
53
+ } finally {
54
+ try {
55
+ unlinkSync(tmp);
56
+ } catch {}
57
+ }
58
+ }
59
+ const readJson = (file) => {
60
+ try {
61
+ return JSON.parse(readFileSync(file, "utf8"));
62
+ } catch (err) {
63
+ return err.code === "ENOENT" ? void 0 : null;
64
+ }
65
+ };
66
+ const asHolder = (v) => {
67
+ const h = v;
68
+ return h && typeof h.pid === "number" && typeof h.instance === "string" ? {
69
+ pid: h.pid,
70
+ instance: h.instance,
71
+ at: Number(h.at) || 0
72
+ } : null;
73
+ };
74
+ /** Is anything listening on `port` on this machine? Vite binds ::1 for `localhost`, an older or
75
+ * configured one 127.0.0.1 - a port is in use if either refuses the bind. */
76
+ async function portInUse(port) {
77
+ const bind = (host) => new Promise((res) => {
78
+ const s = createServer();
79
+ s.once("error", (err) => res(err.code === "EADDRINUSE" || err.code === "EACCES"));
80
+ s.once("listening", () => s.close(() => res(false)));
81
+ s.listen(port, host);
82
+ });
83
+ return await bind("127.0.0.1") || await bind("::1");
84
+ }
85
+ const runsHere = (root) => {
86
+ const port = readJson(infoPath(root))?.port;
87
+ return typeof port === "number" ? `a canvas already runs here: http://localhost:${port} - open it, or stop it first` : "a canvas already runs here - open it, or stop it first";
88
+ };
89
+ const RECLAIM_STUCK = "a canvas is starting here, or a start crashed: delete design/.local/dev.lock.reclaim if no canvas runs";
90
+ /** Take the folder's canvas lock. On success the caller owns dev.lock until `release()` (which
91
+ * removes it only while it still names this instance). */
92
+ async function takeDevLock(root, opts = {}) {
93
+ mkdirSync(localDir(root), { recursive: true });
94
+ const me = {
95
+ pid: opts.pid ?? process.pid,
96
+ instance: randomUUID(),
97
+ at: Date.now()
98
+ };
99
+ const body = JSON.stringify(me);
100
+ const release = () => releaseDevLock(root, me.instance);
101
+ const won = async () => {
102
+ const info = readJson(infoPath(root));
103
+ if (info && info.instance !== me.instance) {
104
+ if (typeof info.pid === "number" ? pidRuns(info.pid) : typeof info.port === "number" ? await portInUse(info.port) : false) {
105
+ release();
106
+ return {
107
+ ok: false,
108
+ message: `${runsHere(root)}${typeof info.pid === "number" ? "" : " (or delete design/.local/dev.json if it is not)"}`
109
+ };
110
+ }
111
+ }
112
+ return {
113
+ ok: true,
114
+ instance: me.instance,
115
+ release
116
+ };
117
+ };
118
+ for (let round = 0; round < 2; round++) {
119
+ try {
120
+ createExclusive(lockPath(root), body);
121
+ return await won();
122
+ } catch (err) {
123
+ if (err.code !== "EEXIST") throw err;
124
+ }
125
+ const raw = readJson(lockPath(root));
126
+ if (raw === void 0) continue;
127
+ const holder = asHolder(raw);
128
+ if (!holder) return {
129
+ ok: false,
130
+ message: "design/.local/dev.lock is unreadable: delete it if no canvas runs"
131
+ };
132
+ if (pidRuns(holder.pid)) return {
133
+ ok: false,
134
+ message: runsHere(root)
135
+ };
136
+ try {
137
+ createExclusive(reclaimPath(root), body);
138
+ } catch (err) {
139
+ if (err.code !== "EEXIST") throw err;
140
+ if (round === 0) {
141
+ await new Promise((r) => setTimeout(r, opts.reclaimWaitMs ?? 1e3));
142
+ continue;
143
+ }
144
+ return {
145
+ ok: false,
146
+ message: RECLAIM_STUCK
147
+ };
148
+ }
149
+ try {
150
+ const again = asHolder(readJson(lockPath(root)));
151
+ if (again && again.pid === holder.pid && again.instance === holder.instance) {
152
+ unlinkSync(lockPath(root));
153
+ try {
154
+ createExclusive(lockPath(root), body);
155
+ return await won();
156
+ } catch (err) {
157
+ if (err.code !== "EEXIST") throw err;
158
+ }
159
+ }
160
+ } finally {
161
+ try {
162
+ unlinkSync(reclaimPath(root));
163
+ } catch {}
164
+ }
165
+ }
166
+ const last = asHolder(readJson(lockPath(root)));
167
+ return {
168
+ ok: false,
169
+ message: last && pidRuns(last.pid) ? runsHere(root) : RECLAIM_STUCK
170
+ };
171
+ }
172
+ /** Remove dev.lock if it still names `instance` - a lock some other start took over stays. */
173
+ function releaseDevLock(root, instance) {
174
+ try {
175
+ if (asHolder(readJson(lockPath(root)))?.instance === instance) unlinkSync(lockPath(root));
176
+ } catch {}
177
+ }
178
+ //#endregion
179
+ export { dev_lock_exports as n, pidRuns as r, createExclusive as t };
@@ -33,7 +33,11 @@ function replay(events) {
33
33
  mentions: ev.mentions,
34
34
  asks: ev.asks,
35
35
  replies: [],
36
- reactions: {}
36
+ reactions: {},
37
+ ...ev.capture ? {
38
+ capture: ev.capture,
39
+ ...ev.facts ? { facts: ev.facts } : {}
40
+ } : {}
37
41
  });
38
42
  }
39
43
  for (const ev of ordered) switch (ev.type) {
@@ -48,16 +52,18 @@ function replay(events) {
48
52
  agent: ev.agent,
49
53
  agentMeta: ev.agentMeta,
50
54
  mentions: ev.mentions,
51
- asks: ev.asks
55
+ asks: ev.asks,
56
+ ...ev.alsoChanged?.length ? { alsoChanged: ev.alsoChanged } : {}
52
57
  });
53
58
  break;
54
59
  }
55
60
  case "edit": {
56
- if (!ev.commentId || ev.body === void 0 && ev.asks === void 0) break;
61
+ if (!ev.commentId || ev.body === void 0 && ev.asks === void 0 && ev.alsoChanged === void 0) break;
57
62
  const m = threads.get(ev.commentId) ?? [...threads.values()].flatMap((th) => th.replies).find((r) => r.id === ev.commentId);
58
63
  if (!m) break;
59
64
  if (ev.body !== void 0) m.body = ev.body;
60
65
  if (ev.asks !== void 0) m.asks = ev.asks;
66
+ if (ev.alsoChanged !== void 0 && !("replies" in m)) m.alsoChanged = ev.alsoChanged;
61
67
  break;
62
68
  }
63
69
  case "resolve": {
@@ -78,7 +84,11 @@ function replay(events) {
78
84
  }
79
85
  case "reanchor": {
80
86
  const t = ev.commentId ? threads.get(ev.commentId) : void 0;
81
- if (t && ev.anchor != null) t.anchor = ev.anchor;
87
+ if (t && typeof ev.frame === "string" && ev.frame) {
88
+ t.frame = ev.frame;
89
+ t.nodeKey = ev.nodeKey;
90
+ t.anchor = ev.anchor ?? void 0;
91
+ } else if (t && ev.anchor != null) t.anchor = ev.anchor;
82
92
  break;
83
93
  }
84
94
  case "react": {
@@ -1,11 +1,11 @@
1
1
  import { r as NAME } from "./cli.mjs";
2
2
  import { n as addFolders, s as listBoardFiles } from "./boards-CGg6piKF.mjs";
3
3
  import { S as KIND_FOLDERS, b as FOLDER_MODULES } from "./board-tree-DRioF94d.mjs";
4
- import { s as scanFrames, u as writeManifest } from "./manifest-DnAte_fB.mjs";
4
+ import { s as scanFrames, u as writeManifest } from "./manifest-Nl3KSVOk.mjs";
5
5
  import { r as detectAgent } from "./agent-BsieQGTD.mjs";
6
6
  import { MANAGED_PREFIX, enumerateInstructionTemplates, hashBody, pkgDir } from "./managed-HwHVNI3h.mjs";
7
7
  import { t as writeManaged } from "./managed-write-Bo-oPc-i.mjs";
8
- import { i as readJson, r as detectHost, t as DEFAULTS } from "./config-cKgZBRj0.mjs";
8
+ import { i as readJson, r as detectHost, t as DEFAULTS } from "./config-Cf7EjAMf.mjs";
9
9
  import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
10
10
  import { basename, dirname, join, relative } from "node:path";
11
11
  //#region src/cli/init.ts
@@ -1,3 +1,4 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
1
2
  import { closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, writeSync } from "node:fs";
2
3
  import { dirname, join } from "node:path";
3
4
  import { createHash } from "node:crypto";
@@ -58,6 +59,11 @@ function deviceId() {
58
59
  * design/.local/ and hand a clone a ledger full of pre-authorized ids. Lines stamped with
59
60
  * another machine match nothing here (device.ts).
60
61
  */
62
+ var ledger_exports = /* @__PURE__ */ __exportAll({
63
+ has: () => has,
64
+ owned: () => owned,
65
+ record: () => record
66
+ });
61
67
  const ledgerFile = (root) => join(root, "design", ".local", "jam-ledger");
62
68
  const line = (board, id) => `${deviceId()}\t${board}\t${id}`;
63
69
  /** Was this (board, id) authorized on this device by the gated dev POST? */
@@ -83,5 +89,15 @@ function record(root, board, id) {
83
89
  closeSync(fd);
84
90
  }
85
91
  }
92
+ /** Every (board, id) this device authorized, as `board\tid` - one read for a whole ingest, so
93
+ * an event that is not ledgered (yet, or ever) costs a set lookup each time it is looked at. */
94
+ function owned(root) {
95
+ const out = /* @__PURE__ */ new Set();
96
+ const file = ledgerFile(root);
97
+ if (!existsSync(file)) return out;
98
+ const mine = deviceId() + " ";
99
+ for (const l of readFileSync(file, "utf8").split("\n")) if (l.startsWith(mine)) out.add(l.slice(mine.length));
100
+ return out;
101
+ }
86
102
  //#endregion
87
- export { has, record, deviceId as t };
103
+ export { deviceId as a, record as i, ledger_exports as n, owned as r, has as t };
@@ -1,8 +1,8 @@
1
1
  import { r as NAME } from "./cli.mjs";
2
2
  import { d as readMembership, i as checkBoardsDir, p as unplacedHint, s as listBoardFiles } from "./boards-CGg6piKF.mjs";
3
3
  import { f as isBoardName } from "./board-tree-DRioF94d.mjs";
4
- import { s as scanFrames } from "./manifest-DnAte_fB.mjs";
5
- import { i as readDevInfo } from "./work-GE88wb_3.mjs";
4
+ import { s as scanFrames } from "./manifest-Nl3KSVOk.mjs";
5
+ import { i as readDevInfo } from "./work-F5u-twpJ.mjs";
6
6
  import { join } from "node:path";
7
7
  //#region src/cli/link.ts
8
8
  /**
@@ -0,0 +1,4 @@
1
+ //#region src/server/jam/live.ts
2
+ const jamLive = {};
3
+ //#endregion
4
+ export { jamLive };
@@ -1,4 +1,4 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
2
  import { i as PKG, n as CONTENT_WIDTH } from "./cli.mjs";
3
3
  import { a as checkRealDirs, f as readRegistry, h as hash, i as checkBoardsDir, r as boardFields, s as listBoardFiles } from "./boards-CGg6piKF.mjs";
4
4
  import { D as readStatusWord, E as readReason, T as readCapability, a as buildTree, f as isBoardName, h as readTitle, k as resolveType, m as readDescription, o as flatten, s as folderEntries, x as HAS_STATUS, y as DECISIONS } from "./board-tree-DRioF94d.mjs";
@@ -1,7 +1,7 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
2
  import { a as checkRealDirs, h as hash, i as checkBoardsDir, s as listBoardFiles } from "./boards-CGg6piKF.mjs";
3
3
  import { l as framesOn } from "./board-tree-DRioF94d.mjs";
4
- import { a as noteFileFor } from "./manifest-DnAte_fB.mjs";
4
+ import { a as noteFileFor } from "./manifest-Nl3KSVOk.mjs";
5
5
  import { t as imports } from "./imports-WBSnnHLb.mjs";
6
6
  import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
7
7
  import { dirname, join, relative, sep } from "node:path";