@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.
- package/CHANGELOG.md +195 -0
- package/README.md +9 -4
- package/dist/{anchor-check-ChdDqL5z.mjs → anchor-check-PHUOFj1N.mjs} +1 -1
- package/dist/{audio-Dw1lfMdb.mjs → audio-DX4POHAj.mjs} +39 -4
- package/dist/{board-tree-DRioF94d.mjs → board-tree-BXR8dw4b.mjs} +3 -1
- package/dist/{boards-DlTcpF47.mjs → boards-BeWtjGUM.mjs} +50 -5
- package/dist/boards-EH2onUXM.mjs +995 -0
- package/dist/{build-DZnFysGU.mjs → build-BsAyLMT1.mjs} +9 -22
- package/dist/{capture-vadKjuCo.mjs → capture-DdZ6xgoz.mjs} +92 -30
- package/dist/cli.mjs +56 -21
- package/dist/{collab-Dxg2trOK.mjs → collab-BEAcXrBb.mjs} +1 -1
- package/dist/{comments-DxOkCSNE.mjs → comments-CrBHPEQl.mjs} +4 -4
- package/dist/config-BezZTiov.mjs +182 -0
- package/dist/conn-BMiHS42T.mjs +222 -0
- package/dist/connectors-MR9d-EBP.mjs +290 -0
- package/dist/{context-HQ4Giw58.mjs → context-BUnFiyA3.mjs} +3 -3
- package/dist/{daemon-BSA0lV8d.mjs → daemon-C5dg2R-V.mjs} +2188 -183
- package/dist/{dev-eQJhWsqg.mjs → dev-D7YS7iT2.mjs} +25 -14
- package/dist/{init-COD0x48i.mjs → init-WE5lQkQL.mjs} +8 -3
- package/dist/jam-Cj5gBvwD.mjs +373 -0
- package/dist/{link-DDXZVGtv.mjs → link-BFFRgrMt.mjs} +4 -4
- package/dist/listener-DdLEM79A.mjs +80 -0
- package/dist/{ls-D7O1G505.mjs → ls-BZ5TAtd5.mjs} +1 -1
- package/dist/{manifest-Nl3KSVOk.mjs → manifest-DPZ3WNg_.mjs} +2 -2
- package/dist/{marks-CWM3WJjc.mjs → marks-Dyn6tmjp.mjs} +3 -3
- package/dist/{marks-CKgzucHZ.mjs → marks-Kmdab_5w.mjs} +3 -3
- package/dist/{marver-id-gate-BjF6v4bT.mjs → marver-id-gate-D-R0hSt_.mjs} +1 -1
- package/dist/perf-Cn5LiRaY.mjs +1319 -0
- package/dist/perf-jam-QxD_UnzN.mjs +635 -0
- package/dist/permit-DDa6wqOs.mjs +187 -0
- package/dist/plugin-C_0yb-Fq.mjs +5089 -0
- package/dist/{poster-Bx83ZYVK.mjs → poster-DHi6I1fO.mjs} +1 -1
- package/dist/{profile-Bh5Y5zpW.mjs → profile-jIS6BcAs.mjs} +1 -1
- package/dist/{publish-bakes-aljgm45S.mjs → publish-bakes-r4PEZuPl.mjs} +3 -3
- package/dist/{queue-CAM_vNmX.mjs → queue-c-6aTHEz.mjs} +164 -25
- package/dist/{recover-t9Pno3u9.mjs → recover-nrLEVLyJ.mjs} +2 -2
- package/dist/{serve-C8rVheYk.mjs → serve-Dp3nHstu.mjs} +3 -3
- package/dist/{session-BAaJsK5c.mjs → session-DyVE7cCk.mjs} +1 -1
- package/dist/{share-W5H3BNvP.mjs → share-Ce4tP7ji.mjs} +1 -1
- package/dist/{shot-LFhC-WYD.mjs → shot-BrRtqaiS.mjs} +34 -8
- package/dist/{shot-DoHLl6ig.mjs → shot-DBWN8hPP.mjs} +1 -1
- package/dist/sizes-wjXDev3b.mjs +139 -0
- package/dist/{slots-DCDo3N0x.mjs → slots-CFNnegCc.mjs} +8 -1
- package/dist/speech-worker.mjs +23 -3
- package/dist/{sync-BQVlHZpx.mjs → sync-CQdGARJ9.mjs} +1 -1
- package/dist/transport-C5FnY9ni.mjs +203 -0
- package/dist/{work-BroFwnup.mjs → work-BYWD_1Zf.mjs} +3 -3
- package/dist/{work-Bp1p39kq.mjs → work-DJxH7cCX.mjs} +1 -1
- package/docs/jam-session.md +42 -16
- package/docs/live-jam.md +92 -10
- package/docs/performance.md +197 -35
- package/package.json +1 -1
- package/src/client/content/video.tsx +10 -2
- package/src/client/shell/App.tsx +10 -3
- package/src/client/shell/Comments.tsx +5 -3
- package/src/client/shell/ContextMenu.tsx +5 -3
- package/src/client/shell/JamSurface.tsx +56 -21
- package/src/client/shell/LockedApp.tsx +3 -0
- package/src/client/shell/Play.tsx +4 -2
- package/src/client/shell/Tip.tsx +3 -1
- package/src/client/shell/api.ts +47 -20
- package/src/client/shell/app-bridge.ts +254 -0
- package/src/client/shell/app-perf.ts +92 -0
- package/src/client/shell/canvas/Canvas.tsx +115 -22
- package/src/client/shell/canvas/FrameNode.tsx +10 -6
- package/src/client/shell/canvas/admission.ts +23 -8
- package/src/client/shell/canvas/ctl.ts +6 -0
- package/src/client/shell/canvas/sleep.ts +57 -17
- package/src/client/shell/canvas/updates.ts +2 -1
- package/src/client/shell/icons.tsx +1 -0
- package/src/client/shell/inset.ts +44 -0
- package/src/client/shell/jam-capture.ts +113 -33
- package/src/client/shell/jam-keys.ts +40 -9
- package/src/client/shell/jam-lane.tsx +14 -5
- package/src/client/shell/jam-lines.ts +66 -9
- package/src/client/shell/jam-panel.tsx +61 -6
- package/src/client/shell/jam-queue.ts +50 -8
- package/src/client/shell/jam-session.tsx +53 -4
- package/src/client/shell/jam-surface-parts.tsx +6 -3
- package/src/client/shell/jam-ui.tsx +6 -1
- package/src/client/shell/jam-voice-wait.ts +21 -0
- package/src/client/shell/jam-voice.ts +62 -15
- package/src/client/shell/main.tsx +14 -1
- package/src/client/shell/marks-ui.tsx +5 -3
- package/src/client/shell/marver-app.ts +21 -0
- package/src/client/shell/perf-run-probe.ts +34 -0
- package/src/client/shell/perf-run.ts +70 -0
- package/src/client/shell/perf.ts +11 -0
- package/src/client/shell/recorder.ts +45 -3
- package/src/client/shell/store.ts +52 -24
- package/src/client/shell/styles.css +65 -17
- package/src/client/shell/tidy.ts +3 -2
- package/src/client/shell/unsaved.ts +81 -0
- package/src/client/shell/whiteout-probes.ts +141 -0
- package/src/shared/app-api.ts +205 -0
- package/src/shared/app-perf.ts +308 -0
- package/src/shared/approval.ts +20 -0
- package/src/shared/events.ts +1 -1
- package/src/shared/logo-sniff.ts +86 -0
- package/src/shared/machine.ts +132 -0
- package/src/shared/perf-run.ts +177 -0
- package/templates/AGENTS-embedded.md +31 -1
- package/templates/AGENTS-studio.md +31 -1
- package/templates/instructions/boards.md +10 -2
- package/templates/instructions/jam.md +90 -0
- package/dist/bake-DM_uWgAA.mjs +0 -786
- package/dist/boards-CGg6piKF.mjs +0 -342
- package/dist/perf-BWzQwZqj.mjs +0 -369
- package/dist/perf-BoDSkbEb.mjs +0 -429
- package/dist/perf-jam-D55U3FZK.mjs +0 -242
- package/dist/plugin-C-E7omsh.mjs +0 -2762
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { o as rendersDoc, r as layoutDocSource } from "./manifest-DPZ3WNg_.mjs";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
//#region src/server/sizes.ts
|
|
6
|
+
/**
|
|
7
|
+
* Content-frame heights - `design/boards/_sizes.json`, committed.
|
|
8
|
+
*
|
|
9
|
+
* A content frame (a Doc: markdown, diagrams, images) is as tall as its content, which only a
|
|
10
|
+
* render can tell. Measured live, every load started from a guess (3/4 of the width) and grew
|
|
11
|
+
* frame by frame, and each growth re-flowed the rows below - the board swam for seconds. The
|
|
12
|
+
* height a frame measured at its own width is a fact about the FRAME at that width, not about a
|
|
13
|
+
* board (one doc sits on several boards) and not something to write into the frame's source: so
|
|
14
|
+
* it lives here, one line per `scene/frame@width`, written by the dev server when the shell
|
|
15
|
+
* reports a settled measurement, read before the first layout - dev, `marver build` and the
|
|
16
|
+
* published canvas alike. A stale entry is still the best first guess; the live measurement
|
|
17
|
+
* corrects it and the file follows. Underscore = infrastructure, never a board (board-tree.ts).
|
|
18
|
+
*/
|
|
19
|
+
var sizes_exports = /* @__PURE__ */ __exportAll({
|
|
20
|
+
SIZES_BATCH_MAX: () => 500,
|
|
21
|
+
SIZES_FILE: () => SIZES_FILE,
|
|
22
|
+
SIZE_KEY: () => SIZE_KEY,
|
|
23
|
+
SIZE_MAX: () => SIZE_MAX,
|
|
24
|
+
SIZE_MIN: () => 80,
|
|
25
|
+
autoWidthOf: () => autoWidthOf,
|
|
26
|
+
keptSizes: () => keptSizes,
|
|
27
|
+
measuringFrames: () => measuringFrames,
|
|
28
|
+
mergeSizes: () => mergeSizes,
|
|
29
|
+
readSizes: () => readSizes,
|
|
30
|
+
readSizesFile: () => readSizesFile,
|
|
31
|
+
rendersDoc: () => rendersDoc,
|
|
32
|
+
serializeSizes: () => serializeSizes,
|
|
33
|
+
sizesPath: () => sizesPath,
|
|
34
|
+
validEntry: () => validEntry
|
|
35
|
+
});
|
|
36
|
+
const SIZES_FILE = "_sizes.json";
|
|
37
|
+
/** `scene/frame@width` - the frame id grammar the focus route accepts, then the width it was measured at. */
|
|
38
|
+
const SIZE_KEY = /^([\w./-]{1,200})@(\d{2,4})$/;
|
|
39
|
+
const SIZE_MAX = 4e4;
|
|
40
|
+
const ABOUT = "Written by marver dev: the height each content frame measured at its width, so boards open at their final size. Commit it; never edit it by hand.";
|
|
41
|
+
const sizesPath = (root) => join(root, "design", "boards", SIZES_FILE);
|
|
42
|
+
/** A valid entry: a well-formed key whose frame is not a traversal, and a height in the shell's clamp. */
|
|
43
|
+
function validEntry(key, h) {
|
|
44
|
+
if (typeof key !== "string" || typeof h !== "number" || !Number.isInteger(h) || h < 80 || h > 4e4) return false;
|
|
45
|
+
const m = SIZE_KEY.exec(key);
|
|
46
|
+
return !!m && !m[1].split("/").some((p) => p === ".." || p === "." || p === "");
|
|
47
|
+
}
|
|
48
|
+
function readSizesFile(root) {
|
|
49
|
+
const file = sizesPath(root);
|
|
50
|
+
if (!existsSync(file)) return {
|
|
51
|
+
state: "absent",
|
|
52
|
+
heights: {}
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
const raw = JSON.parse(readFileSync(file, "utf8"));
|
|
56
|
+
if (!raw || typeof raw !== "object" || !raw.heights || typeof raw.heights !== "object" || Array.isArray(raw.heights)) return {
|
|
57
|
+
state: "invalid",
|
|
58
|
+
heights: {}
|
|
59
|
+
};
|
|
60
|
+
const out = {};
|
|
61
|
+
for (const [k, v] of Object.entries(raw.heights)) if (validEntry(k, v)) out[k] = v;
|
|
62
|
+
return {
|
|
63
|
+
state: "ok",
|
|
64
|
+
heights: out
|
|
65
|
+
};
|
|
66
|
+
} catch {
|
|
67
|
+
return {
|
|
68
|
+
state: "invalid",
|
|
69
|
+
heights: {}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Lenient read for the readers (the shell's first layout, the build): an absent or invalid file is
|
|
74
|
+
* no heights - every frame opens at its placeholder, as before. Never throws. */
|
|
75
|
+
const readSizes = (root) => readSizesFile(root).heights;
|
|
76
|
+
/** The file's text for a set of heights: sorted keys, one entry per line - a changed height is a
|
|
77
|
+
* one-line diff, and two branches that measured different frames merge without a conflict. */
|
|
78
|
+
function serializeSizes(heights) {
|
|
79
|
+
const sorted = {};
|
|
80
|
+
for (const k of Object.keys(heights).sort()) sorted[k] = heights[k];
|
|
81
|
+
return JSON.stringify({
|
|
82
|
+
about: ABOUT,
|
|
83
|
+
heights: sorted
|
|
84
|
+
}, null, 2) + "\n";
|
|
85
|
+
}
|
|
86
|
+
const keeps = (key, autoWidth) => {
|
|
87
|
+
const m = SIZE_KEY.exec(key);
|
|
88
|
+
return !!m && autoWidth(m[1]) === Number(m[2]);
|
|
89
|
+
};
|
|
90
|
+
/** Merge incoming heights into the current ones, keeping only what a board can use: a content frame
|
|
91
|
+
* that still exists, at the width it measures at on its own. Everything else is pruned - a deleted
|
|
92
|
+
* frame, a Doc that went from document to wide. Returns the next map and the keys taken. Pruning
|
|
93
|
+
* reads only the manifest: whether a frame still renders a Doc is asked on READ (keptSizes), so a
|
|
94
|
+
* source caught mid-write can hide an entry for one load, never delete it. */
|
|
95
|
+
function mergeSizes(current, incoming, autoWidth) {
|
|
96
|
+
const next = Object.fromEntries(Object.entries(current).filter(([k]) => keeps(k, autoWidth)));
|
|
97
|
+
const accepted = [];
|
|
98
|
+
for (const [k, v] of Object.entries(incoming)) {
|
|
99
|
+
if (!validEntry(k, v) || !keeps(k, autoWidth)) continue;
|
|
100
|
+
next[k] = v;
|
|
101
|
+
accepted.push(k);
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
next,
|
|
105
|
+
accepted
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** The entries a board can use - what the GET and the build hand the shell: a content frame at its
|
|
109
|
+
* own width that MEASURES (renders a Doc). A frame that went from a Doc to a bare Md keeps the size
|
|
110
|
+
* its board gives it, never an old measurement. */
|
|
111
|
+
const keptSizes = (heights, autoWidth, measuring) => Object.fromEntries(Object.entries(heights).filter(([k]) => keeps(k, autoWidth) && measuring.has(k.slice(0, k.lastIndexOf("@")))));
|
|
112
|
+
/** The auto width rule over a manifest's frames (the shell's defaultSize, store.ts). */
|
|
113
|
+
function autoWidthOf(frames, viewports) {
|
|
114
|
+
const byId = new Map(frames.map((f) => [f.id, f]));
|
|
115
|
+
return (id) => {
|
|
116
|
+
const f = byId.get(id);
|
|
117
|
+
if (!f?.contentWidth) return null;
|
|
118
|
+
return viewports[f.viewport ?? ""]?.width ?? f.contentWidth;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** The content frames that measure: the frame renders a Doc, or a `_layout` it renders inside does
|
|
122
|
+
* (manifest.ts layoutDocSource - the same rule the manifest's width follows). A source that cannot
|
|
123
|
+
* be read, or reads empty (an editor mid-write), gets the benefit of the doubt - this only decides
|
|
124
|
+
* what a load is handed, never what the file keeps. */
|
|
125
|
+
function measuringFrames(root, frames) {
|
|
126
|
+
const out = /* @__PURE__ */ new Set();
|
|
127
|
+
const memo = /* @__PURE__ */ new Map();
|
|
128
|
+
for (const f of frames) {
|
|
129
|
+
if (!f.contentWidth || f.kind === "html" || !f.file || f.file.split("/").includes("..")) continue;
|
|
130
|
+
let src = "";
|
|
131
|
+
try {
|
|
132
|
+
src = readFileSync(join(root, f.file), "utf8");
|
|
133
|
+
} catch {}
|
|
134
|
+
if (!src.trim() || rendersDoc(src) || layoutDocSource(root, f.file, memo) !== null) out.add(f.id);
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
export { mergeSizes as a, serializeSizes as c, measuringFrames as i, sizesPath as l, autoWidthOf as n, readSizes as o, keptSizes as r, readSizesFile as s, SIZES_FILE as t, sizes_exports as u };
|
|
@@ -114,6 +114,13 @@ function asRecord(v) {
|
|
|
114
114
|
key: typeof r.key === "string" ? r.key : ""
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
+
/** What this version's shell offers the Mac app, written from the `starting` write on (spec 28 A2.14 #15): `bridge` -
|
|
118
|
+
* its shell sends A2.9's hello, theme, menu and `mv:busy` with `unsaved`, so the app's guard can trust what the page
|
|
119
|
+
* reports. A canvas without it (0.27.0) gets the app's degraded guard, which asks first. `inset` (0.27.2, A3.8 #31):
|
|
120
|
+
* its shell takes the top inset under the app's transparent strip, keeps what it means to be read or clicked below
|
|
121
|
+
* it and its scroll edge, and answers the app's presentation requests - so app 0.2 may run it at the window's full
|
|
122
|
+
* height. A canvas without it stays below the strip. */
|
|
123
|
+
const FEATURES = ["bridge", "inset"];
|
|
117
124
|
/** Take one candidate: the file, then - holding it - the port check. */
|
|
118
125
|
async function take(i, slot, port) {
|
|
119
126
|
const file = slot ? slotFileOf(slot) : portFileOf(port);
|
|
@@ -131,7 +138,7 @@ async function take(i, slot, port) {
|
|
|
131
138
|
root: i.root,
|
|
132
139
|
name: i.name,
|
|
133
140
|
version: i.version,
|
|
134
|
-
features: [],
|
|
141
|
+
features: [...FEATURES],
|
|
135
142
|
ws: i.ws,
|
|
136
143
|
startedAt: Date.now(),
|
|
137
144
|
key: key.toString("base64url")
|
package/dist/speech-worker.mjs
CHANGED
|
@@ -121,6 +121,7 @@ var Segmenter = class {
|
|
|
121
121
|
while (!this.vad.isEmpty()) {
|
|
122
122
|
const raw = this.vad.front();
|
|
123
123
|
this.vad.pop();
|
|
124
|
+
if (!raw?.samples?.length) continue;
|
|
124
125
|
const seg = {
|
|
125
126
|
start: raw.start + this.skipped,
|
|
126
127
|
samples: raw.samples
|
|
@@ -237,7 +238,9 @@ function concat(a, b) {
|
|
|
237
238
|
//#endregion
|
|
238
239
|
//#region src/server/jam/speech-worker.ts
|
|
239
240
|
/**
|
|
240
|
-
* The speech worker (spec 27, Part 4): a
|
|
241
|
+
* The speech worker (spec 27, Part 4): a process of its own, so decoding never blocks the dev server - and a
|
|
242
|
+
* native crash in the engine (an ONNX error is a C++ exception no thread can catch) ends transcription, never
|
|
243
|
+
* the canvas (27 Oct: one took a whole canvas down mid-session). It also still runs as a worker thread. It
|
|
241
244
|
* loads `sherpa-onnx-node` (an optional dependency) and the checked model once, then runs one Segmenter
|
|
242
245
|
* per capture - Silero VAD for phrases, Parakeet v3 for words.
|
|
243
246
|
*
|
|
@@ -246,8 +249,20 @@ function concat(a, b) {
|
|
|
246
249
|
* out : { type: 'ready' } · { type: 'unavailable', reason } · { type: 'words', capture, words }
|
|
247
250
|
* { type: 'final', capture }
|
|
248
251
|
*/
|
|
249
|
-
const port = parentPort
|
|
250
|
-
|
|
252
|
+
const port = parentPort ?? {
|
|
253
|
+
postMessage: (m) => {
|
|
254
|
+
try {
|
|
255
|
+
process.send?.(m);
|
|
256
|
+
} catch {}
|
|
257
|
+
},
|
|
258
|
+
on: (ev, f) => {
|
|
259
|
+
process.on(ev, f);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
const paths = parentPort ? workerData.paths : JSON.parse(process.env.MARVER_SPEECH_PATHS ?? "{}");
|
|
263
|
+
if (!parentPort) process.on("disconnect", () => process.exit(0));
|
|
264
|
+
/** Shorter than this is no phrase at all: the recognizer is never handed it (an empty one crashed it, 27 Oct). */
|
|
265
|
+
const MIN_SAMPLES = RATE / 10;
|
|
251
266
|
let sherpa;
|
|
252
267
|
let recognizer;
|
|
253
268
|
const loadStart = performance.now();
|
|
@@ -295,6 +310,11 @@ const vadFor = () => new sherpa.Vad({
|
|
|
295
310
|
const turn = () => new Promise((r) => setImmediate(r));
|
|
296
311
|
const recognize = async (samples) => {
|
|
297
312
|
await turn();
|
|
313
|
+
if (samples.length < MIN_SAMPLES) return {
|
|
314
|
+
tokens: [],
|
|
315
|
+
timestamps: [],
|
|
316
|
+
ms: 0
|
|
317
|
+
};
|
|
298
318
|
const t0 = performance.now();
|
|
299
319
|
const s = recognizer.createStream();
|
|
300
320
|
s.acceptWaveform({
|
|
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
|
2
2
|
import { n as diffEvents } from "./events-CLH4ijKP.mjs";
|
|
3
3
|
import { a as readLog, i as listBoards, t as appendEvents } from "./comments-0BSbb04K.mjs";
|
|
4
4
|
import { t as CLI_TOKEN_CHARS } from "./auth-Dix8wrXV.mjs";
|
|
5
|
-
import { i as marverHome } from "./slots-
|
|
5
|
+
import { i as marverHome } from "./slots-CFNnegCc.mjs";
|
|
6
6
|
import { chmodSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, unlinkSync, writeSync } from "node:fs";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { createHash, randomBytes } from "node:crypto";
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { b as validConnId, c as jamDir, h as readConn, x as writeAtomic } from "./conn-BMiHS42T.mjs";
|
|
2
|
+
import { mkdirSync, readFileSync, readdirSync, rmSync, statSync, watch } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
5
|
+
//#region src/server/jam/transport.ts
|
|
6
|
+
/**
|
|
7
|
+
* The session's commands travel through files, not a port (spec 29b, Part 6): Codex's and Cursor's
|
|
8
|
+
* sandboxes can block localhost, and a file in the repo reaches the daemon from any of them.
|
|
9
|
+
*
|
|
10
|
+
* The CLI writes design/.local/jam/req/<id>.json - the connection, the operation, its arguments, the
|
|
11
|
+
* time, and an HMAC-SHA256 over all of it made with the connection's key. The daemon checks the MAC,
|
|
12
|
+
* the age and that the id is new, does the operation, and answers design/.local/jam/res/<id>.json.
|
|
13
|
+
*/
|
|
14
|
+
const reqDir = (root) => join(jamDir(root), "req");
|
|
15
|
+
const resDir = (root) => join(jamDir(root), "res");
|
|
16
|
+
/** Requests and answers older than this are swept. */
|
|
17
|
+
const KEEP_MS = 6e5;
|
|
18
|
+
const REQ_ID = /^[0-9a-f-]{36}$/;
|
|
19
|
+
const OPS = [
|
|
20
|
+
"next",
|
|
21
|
+
"say",
|
|
22
|
+
"progress",
|
|
23
|
+
"done",
|
|
24
|
+
"release",
|
|
25
|
+
"status",
|
|
26
|
+
"mute",
|
|
27
|
+
"own"
|
|
28
|
+
];
|
|
29
|
+
/** JSON with its keys in order, at every depth: the bytes a MAC is made over. */
|
|
30
|
+
function canonical(v) {
|
|
31
|
+
if (Array.isArray(v)) return `[${v.map(canonical).join(",")}]`;
|
|
32
|
+
if (v && typeof v === "object") return `{${Object.keys(v).sort().filter((k) => v[k] !== void 0).map((k) => `${JSON.stringify(k)}:${canonical(v[k])}`).join(",")}}`;
|
|
33
|
+
return JSON.stringify(v);
|
|
34
|
+
}
|
|
35
|
+
const macOf = (key, body) => createHmac("sha256", Buffer.from(key, "hex")).update(canonical(body)).digest("hex");
|
|
36
|
+
/** Write a request and wait for its answer. Throws with a sentence a person can act on. */
|
|
37
|
+
async function request(root, conn, op, args, timeoutMs = 3e4) {
|
|
38
|
+
mkdirSync(reqDir(root), {
|
|
39
|
+
recursive: true,
|
|
40
|
+
mode: 448
|
|
41
|
+
});
|
|
42
|
+
mkdirSync(resDir(root), {
|
|
43
|
+
recursive: true,
|
|
44
|
+
mode: 448
|
|
45
|
+
});
|
|
46
|
+
const body = {
|
|
47
|
+
v: 1,
|
|
48
|
+
id: randomUUID(),
|
|
49
|
+
conn: conn.id,
|
|
50
|
+
op,
|
|
51
|
+
args,
|
|
52
|
+
ts: Date.now()
|
|
53
|
+
};
|
|
54
|
+
const req = {
|
|
55
|
+
...body,
|
|
56
|
+
mac: macOf(conn.key, body)
|
|
57
|
+
};
|
|
58
|
+
const res = join(resDir(root), `${req.id}.json`);
|
|
59
|
+
writeAtomic(join(reqDir(root), `${req.id}.json`), JSON.stringify(req));
|
|
60
|
+
return await new Promise((resolve, reject) => {
|
|
61
|
+
let done = false;
|
|
62
|
+
const finish = (fn) => {
|
|
63
|
+
if (done) return;
|
|
64
|
+
done = true;
|
|
65
|
+
clearInterval(poll);
|
|
66
|
+
clearTimeout(to);
|
|
67
|
+
clearTimeout(again);
|
|
68
|
+
try {
|
|
69
|
+
w?.close();
|
|
70
|
+
} catch {}
|
|
71
|
+
fn();
|
|
72
|
+
};
|
|
73
|
+
const look = () => {
|
|
74
|
+
let text;
|
|
75
|
+
try {
|
|
76
|
+
text = readFileSync(res, "utf8");
|
|
77
|
+
} catch {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
let out;
|
|
81
|
+
try {
|
|
82
|
+
out = JSON.parse(text);
|
|
83
|
+
} catch {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
rmSync(res, { force: true });
|
|
87
|
+
finish(() => resolve(out));
|
|
88
|
+
};
|
|
89
|
+
let w;
|
|
90
|
+
try {
|
|
91
|
+
w = watch(resDir(root), { persistent: false }, look);
|
|
92
|
+
} catch {}
|
|
93
|
+
const poll = setInterval(look, 200);
|
|
94
|
+
const again = setTimeout(() => {
|
|
95
|
+
if (!done && Date.now() - body.ts < 55e3) try {
|
|
96
|
+
writeAtomic(join(reqDir(root), `${req.id}.json`), JSON.stringify(req));
|
|
97
|
+
} catch {}
|
|
98
|
+
}, Math.min(timeoutMs / 2, 2e4));
|
|
99
|
+
const to = setTimeout(() => finish(() => {
|
|
100
|
+
rmSync(join(reqDir(root), `${req.id}.json`), { force: true });
|
|
101
|
+
reject(/* @__PURE__ */ new Error("the canvas did not answer - is `marver dev` running in this repo?"));
|
|
102
|
+
}), timeoutMs);
|
|
103
|
+
look();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/** Check one request file: a known, live connection, a MAC made with its key, recent, never seen. */
|
|
107
|
+
function verify(root, raw, seen, now = Date.now()) {
|
|
108
|
+
const r = raw;
|
|
109
|
+
const id = typeof r?.id === "string" && REQ_ID.test(r.id) ? r.id : void 0;
|
|
110
|
+
if (!r || r.v !== 1 || !id || !validConnId(r.conn) || !OPS.includes(r.op) || !r.args || typeof r.args !== "object" || typeof r.ts !== "number" || typeof r.mac !== "string") return {
|
|
111
|
+
ok: false,
|
|
112
|
+
id,
|
|
113
|
+
error: "not a Jam request"
|
|
114
|
+
};
|
|
115
|
+
const conn = readConn(root, r.conn);
|
|
116
|
+
if (!conn) return {
|
|
117
|
+
ok: false,
|
|
118
|
+
id,
|
|
119
|
+
error: "this session is not connected to the canvas"
|
|
120
|
+
};
|
|
121
|
+
const want = Buffer.from(macOf(conn.key, {
|
|
122
|
+
v: 1,
|
|
123
|
+
id,
|
|
124
|
+
conn: r.conn,
|
|
125
|
+
op: r.op,
|
|
126
|
+
args: r.args,
|
|
127
|
+
ts: r.ts
|
|
128
|
+
}), "hex");
|
|
129
|
+
const got = Buffer.from(/^[0-9a-f]{64}$/.test(r.mac) ? r.mac : "", "hex");
|
|
130
|
+
if (got.length !== want.length || !timingSafeEqual(got, want)) return {
|
|
131
|
+
ok: false,
|
|
132
|
+
id,
|
|
133
|
+
error: "the request is not signed by this session"
|
|
134
|
+
};
|
|
135
|
+
if (Math.abs(now - r.ts) > 6e4) return {
|
|
136
|
+
ok: false,
|
|
137
|
+
id,
|
|
138
|
+
error: "the request is too old - run the command again"
|
|
139
|
+
};
|
|
140
|
+
if (seen.has(id)) return {
|
|
141
|
+
ok: false,
|
|
142
|
+
id,
|
|
143
|
+
error: "this request was already answered"
|
|
144
|
+
};
|
|
145
|
+
seen.add(id);
|
|
146
|
+
return {
|
|
147
|
+
ok: true,
|
|
148
|
+
req: r,
|
|
149
|
+
conn
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function answer(root, id, body) {
|
|
153
|
+
if (!REQ_ID.test(id)) return;
|
|
154
|
+
mkdirSync(resDir(root), {
|
|
155
|
+
recursive: true,
|
|
156
|
+
mode: 448
|
|
157
|
+
});
|
|
158
|
+
writeAtomic(join(resDir(root), `${id}.json`), JSON.stringify(body));
|
|
159
|
+
}
|
|
160
|
+
/** The requests waiting now, oldest first - each read and removed (a request is taken once). */
|
|
161
|
+
function takeRequests(root) {
|
|
162
|
+
let names;
|
|
163
|
+
try {
|
|
164
|
+
names = readdirSync(reqDir(root)).filter((n) => n.endsWith(".json"));
|
|
165
|
+
} catch {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
const out = [];
|
|
169
|
+
for (const n of names) {
|
|
170
|
+
const file = join(reqDir(root), n);
|
|
171
|
+
let raw = null;
|
|
172
|
+
let t = 0;
|
|
173
|
+
try {
|
|
174
|
+
t = statSync(file).mtimeMs;
|
|
175
|
+
raw = JSON.parse(readFileSync(file, "utf8"));
|
|
176
|
+
} catch {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
rmSync(file, { force: true });
|
|
180
|
+
out.push({
|
|
181
|
+
file,
|
|
182
|
+
raw,
|
|
183
|
+
t
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
return out.sort((a, b) => a.t - b.t);
|
|
187
|
+
}
|
|
188
|
+
/** Requests and answers nobody came back for. */
|
|
189
|
+
function sweep(root, now = Date.now()) {
|
|
190
|
+
for (const dir of [reqDir(root), resDir(root)]) {
|
|
191
|
+
let names;
|
|
192
|
+
try {
|
|
193
|
+
names = readdirSync(dir);
|
|
194
|
+
} catch {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
for (const n of names) try {
|
|
198
|
+
if (now - statSync(join(dir, n)).mtimeMs > KEEP_MS) rmSync(join(dir, n), { force: true });
|
|
199
|
+
} catch {}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
//#endregion
|
|
203
|
+
export { answer, reqDir, request, sweep, takeRequests, verify };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as NAME } from "./cli.mjs";
|
|
2
|
-
import { i as readDevInfo, n as WORK_TTL_MAX, t as WORK_TTL_DEFAULT } from "./work-
|
|
3
|
-
import { unreachable } from "./link-
|
|
2
|
+
import { i as readDevInfo, n as WORK_TTL_MAX, t as WORK_TTL_DEFAULT } from "./work-DJxH7cCX.mjs";
|
|
3
|
+
import { unreachable } from "./link-BFFRgrMt.mjs";
|
|
4
4
|
//#region src/cli/work.ts
|
|
5
5
|
/**
|
|
6
6
|
* `marver work` - the coding agent's hand on the canvas working state.
|
|
@@ -68,7 +68,7 @@ async function workCommand(root, action, frames, opts) {
|
|
|
68
68
|
});
|
|
69
69
|
console.log(active.length ? `still working: ${active.join(", ")}` : "nothing working - all clear");
|
|
70
70
|
const done = before.filter((f) => !active.includes(f));
|
|
71
|
-
const { links, hints } = done.length ? await (await import("./link-
|
|
71
|
+
const { links, hints } = done.length ? await (await import("./link-BFFRgrMt.mjs")).handBack(root, done) : {
|
|
72
72
|
links: [],
|
|
73
73
|
hints: []
|
|
74
74
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { c as listBoardFiles } from "./boards-EH2onUXM.mjs";
|
|
3
3
|
import { r as pidRuns } from "./exclusive-B1RtpeeP.mjs";
|
|
4
4
|
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
package/docs/jam-session.md
CHANGED
|
@@ -25,12 +25,24 @@ dot. While it records, everything you do is part of it:
|
|
|
25
25
|
pictured as the capture ends - three at most - at the size you were looking at them (a
|
|
26
26
|
device, a width you dragged, the play stage). A capture holds twelve pictures in all.
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
Two ways to end it (0.28): `E` **stops and queues it** - the agent starts on it, nothing to confirm - and `⇧E`
|
|
29
|
+
**stops to review**: its read-back opens so you can check it and add to it first. Both are on the capture bar. `Esc`
|
|
30
|
+
throws it away. One capture records at a time.
|
|
31
|
+
|
|
32
|
+
After `E` the tile reads **Sending** while its last words and pictures come in, then Queued or the agent's state;
|
|
33
|
+
nothing opens and the canvas stays where it is. If the queue cannot take it (rare: another comment already sits
|
|
34
|
+
under its id), it stays on the lane as a draft reading **Not queued** and one line says why - open it to add it to
|
|
35
|
+
the queue. After `⇧E` the tile reads **Finishing**, then **To confirm** as its read-back opens. Either way the capture
|
|
36
|
+
waits for the words you said last: 15 s, longer while the speech engine is still working through them (a minute at
|
|
37
|
+
most). With the microphone on and nothing heard (the speech engine not available, the microphone still opening),
|
|
38
|
+
its record says the words may be incomplete.
|
|
39
|
+
|
|
40
|
+
Closing or reloading the tab asks first while a capture is recording, finishing or not yet taken by the canvas (as it
|
|
41
|
+
does for any unsaved work). If you leave anyway, the capture
|
|
31
42
|
is kept as it stood - its words and notes so far, and a line saying the page closed before it finished - and comes
|
|
32
|
-
back as a draft to read, resume or drop; it never goes to your agent on its own.
|
|
33
|
-
no chance to
|
|
43
|
+
back as a draft to read, resume or drop; it never goes to your agent on its own. One you had already stopped with `E`
|
|
44
|
+
(its tile reading Sending) is queued as `E` does, with that line. (Best effort: a crash gives the page no chance to
|
|
45
|
+
keep it.)
|
|
34
46
|
|
|
35
47
|
A capture the page could not send waits in this browser, for this address, and sends itself the next time the canvas
|
|
36
48
|
opens there - see [A capture left on an old address](#a-capture-left-on-an-old-address).
|
|
@@ -41,7 +53,7 @@ are the frames its run may edit, and the frames pictured before and after it.
|
|
|
41
53
|
|
|
42
54
|
## The read-back
|
|
43
55
|
|
|
44
|
-
When a capture ends, its **read-back** opens: the timeline of what you said and did, with its
|
|
56
|
+
When a capture ends with `⇧E` (and when `J` ends one to wrap the session up), its **read-back** opens: the timeline of what you said and did, with its
|
|
45
57
|
pictures, under a short name a small model gave it (see [Names](#names)). Read it, fix a
|
|
46
58
|
mistranscribed word in place, and decide:
|
|
47
59
|
|
|
@@ -55,7 +67,6 @@ mistranscribed word in place, and decide:
|
|
|
55
67
|
A draft's read-back also takes notes after the fact: type in **Add a note** and they are
|
|
56
68
|
logged under "Added after", in the timeline's style, and go to the agent with the rest.
|
|
57
69
|
|
|
58
|
-
`jam: { capture: "at-once" }` skips the read-back: a capture queues as soon as it ends.
|
|
59
70
|
|
|
60
71
|
## The lane
|
|
61
72
|
|
|
@@ -69,8 +80,11 @@ captures · 6 frames changed" - so the lane keeps its room for what still needs
|
|
|
69
80
|
(or `⏎` on it) to open them in place, behind a narrow collapse tile that folds them back.
|
|
70
81
|
|
|
71
82
|
Your agent works on up to `jam.concurrency` captures at once (6 by default), each in its own
|
|
72
|
-
run
|
|
73
|
-
|
|
83
|
+
run - your Claude Code session up to 8 more, each in a background subagent of its own - but
|
|
84
|
+
never two runners on the same frame: a capture about a frame another runner holds waits for it,
|
|
85
|
+
and its tile says so ("Waits for 01-slide", the run holding it in its tooltip). One on a frame
|
|
86
|
+
your own session's run is working goes to that session at once, which decides how the two meet
|
|
87
|
+
- after, folded in, or a variant beside it ([Live Jam](live-jam.md#your-own-session-takes-the-work-028)).
|
|
74
88
|
|
|
75
89
|
## Review
|
|
76
90
|
|
|
@@ -91,13 +105,25 @@ run - "and this too".
|
|
|
91
105
|
When a capture asked for something new beside a frame - "a laptop version of this, next to
|
|
92
106
|
it" - the frame it pointed at was only where the new one goes. If the run made a new frame
|
|
93
107
|
and left the one you pointed at unchanged, the capture's thread moves onto the new frame
|
|
94
|
-
(when that capture ran alone, so the new frame is surely its own).
|
|
108
|
+
(when that capture ran alone, or its run put the frame on the board with `--run`, so the new frame is surely its own).
|
|
95
109
|
|
|
96
110
|
## A session: `J`
|
|
97
111
|
|
|
98
|
-
`J` (or the Jam button in the toolbar) opens the start sheet: what Marver listens to,
|
|
99
|
-
|
|
100
|
-
|
|
112
|
+
`J` (or the Jam button in the toolbar) opens the start sheet: what Marver listens to, who
|
|
113
|
+
works, three switches, and the keyboard shortcuts. **Start** (`⏎`) begins the session and its
|
|
114
|
+
first capture at once.
|
|
115
|
+
|
|
116
|
+
**Who works** (0.28): while the session runs, your tags and captures go to the coding-agent
|
|
117
|
+
session you already have open in the repo - "Your Claude Code session", with everything it
|
|
118
|
+
has. With several open, the newest takes the work; click the row for the next one. With none
|
|
119
|
+
open, a copy of your last session does the run. Claude Code hands each run to a background
|
|
120
|
+
subagent and is free again in seconds, so your captures run side by side; Marver gives Codex
|
|
121
|
+
and Cursor their runs one at a time. Starting the session connects every Claude
|
|
122
|
+
Code, Codex and Cursor session in the repo - nothing else to set up ([Live Jam](live-jam.md#your-own-session-takes-the-work-028)).
|
|
123
|
+
The three switches cover the runs Marver spawns: **MCP servers and skills** (on), **your
|
|
124
|
+
session's context** (on - off means no session and no copy take work, only fresh agents), and
|
|
125
|
+
**collaborators' comments** (off - only your own words reach the agent). They are kept for this
|
|
126
|
+
machine in `design/.local/jam/prefs.json`.
|
|
101
127
|
|
|
102
128
|
While a session runs, the canvas keeps its glowing edge and the Jam button its dot and
|
|
103
129
|
clock - seconds the first minute, then minutes - and the lane shows **Jam on**, listening
|
|
@@ -151,12 +177,12 @@ shows in the review, beside the before and after pictures. The managed instructi
|
|
|
151
177
|
|
|
152
178
|
```ts
|
|
153
179
|
// design/config.ts
|
|
154
|
-
jam: { agent: "claude", concurrency: 6,
|
|
180
|
+
jam: { agent: "claude", concurrency: 6, chime: true, names: true, loc: true },
|
|
155
181
|
```
|
|
156
182
|
|
|
157
183
|
| Key | Default | What it does |
|
|
158
184
|
|---|---|---|
|
|
159
|
-
| `capture` | `"confirm"` |
|
|
185
|
+
| `capture` | `"confirm"` | No longer used (0.28): `E` queues a capture, `⇧E` stops to review it |
|
|
160
186
|
| `chime` | `true` | A soft chime when a capture is ready to review |
|
|
161
187
|
| `names` | `true` | Name each capture with Claude Haiku (Claude Code only) |
|
|
162
188
|
| `loc` | `true` | Stamp each element of your design files with `data-mv-loc` (dev only, never published) |
|
|
@@ -169,7 +195,7 @@ A bad value says so at boot and takes the default; nothing here turns Jam off.
|
|
|
169
195
|
| Where | Keys |
|
|
170
196
|
|---|---|
|
|
171
197
|
| Anywhere on the canvas | `S` capture · `J` session · `Q` the lane · `V` next to review |
|
|
172
|
-
| A capture recording | `E`
|
|
198
|
+
| A capture recording | `E` stop and queue · `⇧E` stop to review · `N` note · `I` picture · `L` laser · `⌥L` inspect · `Esc` drop |
|
|
173
199
|
| A read-back | `⏎` add to queue · `K` keep · `R` resume · `Esc` drop |
|
|
174
200
|
| A review | `⏎` looks good · `⇧⏎` more work · `→` later · `←` back · `B` both/before/after · `⌥←` `⌥→` frames · `Esc` leave |
|
|
175
201
|
| The lane (`Q`) | `←` `→` move · `⏎` open (or open/fold the Done tile) · `⌘⏎` do next · `K` keep · `⌫` drop · `Esc` leave |
|