@marver-design/marver 0.27.2 → 0.29.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 +160 -0
- package/README.md +6 -4
- package/dist/{anchor-check-gkxkPAIv.mjs → anchor-check-DhlpKl2K.mjs} +1 -1
- package/dist/{audio-Dw1lfMdb.mjs → audio-DX4POHAj.mjs} +39 -4
- package/dist/{boards-BqUqKNW8.mjs → boards-BeWtjGUM.mjs} +49 -4
- package/dist/boards-EH2onUXM.mjs +995 -0
- package/dist/{build-VgNg4rr8.mjs → build-CWbrb2bl.mjs} +9 -5
- package/dist/{capture-vadKjuCo.mjs → capture-DEtM4qm5.mjs} +259 -34
- package/dist/cli.mjs +40 -19
- package/dist/{comments-YEU1Zhv9.mjs → comments-XNhMmSSu.mjs} +4 -4
- package/dist/config-BezZTiov.mjs +182 -0
- package/dist/conn-BMiHS42T.mjs +222 -0
- package/dist/connectors-DekQvKt9.mjs +292 -0
- package/dist/{context-Ccjrhr1J.mjs → context-BUnFiyA3.mjs} +2 -2
- package/dist/{daemon-Dc9AH0M3.mjs → daemon-Sc_z8gT6.mjs} +2209 -205
- package/dist/{dev-ri6nAlRp.mjs → dev-DWBKQhxf.mjs} +31 -15
- package/dist/{init-W0nxR1OY.mjs → init-CYlFaRzG.mjs} +7 -2
- package/dist/jam-Cj5gBvwD.mjs +373 -0
- package/dist/{link-CdTgn94Y.mjs → link-BFFRgrMt.mjs} +3 -3
- package/dist/listener-DdLEM79A.mjs +80 -0
- package/dist/logo-CXY-1yrn.mjs +305 -0
- package/dist/{ls-BZ5TAtd5.mjs → ls-NqmePKOf.mjs} +1 -1
- package/dist/{manifest-aFyDmL8C.mjs → manifest-DPZ3WNg_.mjs} +1 -1
- package/dist/{marks-CnCCfAbD.mjs → marks-BnNANic9.mjs} +22 -3
- package/dist/{marks-BF9pNEgH.mjs → marks-DBp3h1Mc.mjs} +3 -6
- package/dist/{marver-id-gate-D-R0hSt_.mjs → marver-id-gate-vBLb_Icb.mjs} +1 -1
- package/dist/{perf-DkAUFT6W.mjs → perf-Denssrko.mjs} +45 -27
- package/dist/{perf-jam-BaH3Lg0m.mjs → perf-jam-CLkERSHo.mjs} +9 -2
- package/dist/permit-DDa6wqOs.mjs +187 -0
- package/dist/{plugin-B8UghYuF.mjs → plugin-DqoZB-D6.mjs} +849 -789
- package/dist/{poster-BNgafWMK.mjs → poster-CrsjqhY4.mjs} +1 -1
- package/dist/{profile-jIS6BcAs.mjs → profile-B1FKOM1e.mjs} +1 -1
- package/dist/{publish-bakes-38Nja78p.mjs → publish-bakes-DW-NDgU2.mjs} +3 -3
- package/dist/{queue-CAM_vNmX.mjs → queue-DeSQm24g.mjs} +189 -35
- package/dist/{recover-B8AiI29B.mjs → recover-GtJ9UDAB.mjs} +2 -2
- package/dist/{serve-Dp3nHstu.mjs → serve-DQv3Ti6X.mjs} +8 -4
- package/dist/{session-BAaJsK5c.mjs → session-VDJfXEEm.mjs} +1 -1
- package/dist/{share-Ce4tP7ji.mjs → share-Bu_kuOKL.mjs} +1 -1
- package/dist/{shot-CMQgMVZm.mjs → shot-DBWN8hPP.mjs} +1 -1
- package/dist/{shot-Ch24tiMO.mjs → shot-T04Ixrvq.mjs} +7 -6
- package/dist/sizes-wjXDev3b.mjs +139 -0
- package/dist/{slots-CFNnegCc.mjs → slots-Dn4Onb0V.mjs} +101 -3
- package/dist/speech-worker.mjs +23 -3
- package/dist/{sync-CQdGARJ9.mjs → sync-CMozOwZ0.mjs} +1 -1
- package/dist/transport-C5FnY9ni.mjs +203 -0
- package/dist/{work-Bxz-ObF3.mjs → work-BYWD_1Zf.mjs} +3 -3
- package/dist/{work-CNhFF9pU.mjs → work-DJxH7cCX.mjs} +1 -1
- package/docs/boards-and-folders.md +11 -0
- package/docs/jam-session.md +52 -18
- package/docs/live-jam.md +95 -10
- package/docs/performance.md +1 -1
- package/docs/publish.md +7 -0
- package/package.json +1 -1
- package/src/client/shell/Comments.tsx +5 -4
- package/src/client/shell/ContextMenu.tsx +5 -4
- package/src/client/shell/JamSurface.tsx +135 -29
- package/src/client/shell/Play.tsx +16 -4
- package/src/client/shell/api.ts +7 -3
- package/src/client/shell/app-bridge.ts +11 -3
- package/src/client/shell/comments-store.ts +14 -0
- package/src/client/shell/goto.ts +4 -3
- package/src/client/shell/icons.tsx +1 -0
- package/src/client/shell/jam-capture.ts +136 -37
- package/src/client/shell/jam-keys.ts +170 -18
- package/src/client/shell/jam-lane.tsx +14 -5
- package/src/client/shell/jam-lines.ts +76 -10
- package/src/client/shell/jam-panel.tsx +58 -4
- package/src/client/shell/jam-queue.ts +55 -8
- package/src/client/shell/jam-session.tsx +55 -6
- package/src/client/shell/jam-state.ts +19 -4
- package/src/client/shell/jam-surface-parts.tsx +6 -3
- package/src/client/shell/jam-ui.tsx +10 -1
- package/src/client/shell/jam-voice-wait.ts +21 -0
- package/src/client/shell/jam-voice.ts +14 -5
- package/src/client/shell/live-picture.ts +134 -0
- package/src/client/shell/open-item.ts +83 -0
- package/src/client/shell/open-resolve.ts +50 -0
- package/src/client/shell/store.ts +6 -2
- package/src/client/shell/styles.css +29 -11
- package/src/client/shell/tidy.ts +3 -2
- package/src/client/stage/main.tsx +30 -8
- package/src/shared/app-api.ts +173 -3
- package/src/shared/app-perf.ts +4 -2
- package/src/shared/approval.ts +20 -0
- package/src/shared/events.ts +1 -1
- package/templates/AGENTS-embedded.md +28 -1
- package/templates/AGENTS-studio.md +28 -1
- package/templates/instructions/boards.md +7 -1
- package/templates/instructions/jam.md +94 -0
- package/dist/boards-BHKP5yhI.mjs +0 -342
- package/dist/live-Cgzsicwi.mjs +0 -4
package/dist/cli.mjs
CHANGED
|
@@ -82,7 +82,7 @@ cli.command("init", "Scaffold design/ in this repo").option("--mode <mode>", "st
|
|
|
82
82
|
console.error(`[${NAME}] --kind ${opts.kind}: use product or knowledge`);
|
|
83
83
|
process.exit(1);
|
|
84
84
|
}
|
|
85
|
-
const { init } = await import("./init-
|
|
85
|
+
const { init } = await import("./init-CYlFaRzG.mjs");
|
|
86
86
|
init(resolve$1(opts.root), {
|
|
87
87
|
mode: opts.mode === "embedded" ? "embedded" : "studio",
|
|
88
88
|
demo: opts.demo !== false,
|
|
@@ -90,7 +90,7 @@ cli.command("init", "Scaffold design/ in this repo").option("--mode <mode>", "st
|
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
for (const [name, desc] of [["dev", "Start the local canvas (everything on: hot reload, comments, Live Jam)"], ["canvas", "Start the local canvas - same as dev"]]) cli.command(name, desc).option("--root <dir>", "Host repo root", { default: "." }).option("--port <port>", "A port of its own (default: a free slot, localhost:4805-4824 - usually the same one next time; a port in that range takes exactly that slot)").option("--recover [n]", "Run on an address this canvas had before, where an unsent Jam capture waits: alone it lists them; with a number it starts on that one; --recover --port <p>: the port 0.26 used").action(async (opts) => {
|
|
93
|
-
const { dev, DevStartError, DevLockError } = await import("./dev-
|
|
93
|
+
const { dev, DevStartError, DevLockError } = await import("./dev-DWBKQhxf.mjs");
|
|
94
94
|
let port;
|
|
95
95
|
if (opts.port !== void 0) {
|
|
96
96
|
const n = Number(opts.port);
|
|
@@ -102,7 +102,7 @@ for (const [name, desc] of [["dev", "Start the local canvas (everything on: hot
|
|
|
102
102
|
process.exit(1);
|
|
103
103
|
};
|
|
104
104
|
try {
|
|
105
|
-
if (opts.recover !== void 0 && opts.recover !== false) await (await import("./recover-
|
|
105
|
+
if (opts.recover !== void 0 && opts.recover !== false) await (await import("./recover-GtJ9UDAB.mjs")).recoverCommand(resolve$1(opts.root), opts.recover, port, { onFail });
|
|
106
106
|
else await dev(resolve$1(opts.root), {
|
|
107
107
|
port,
|
|
108
108
|
onFail
|
|
@@ -115,10 +115,10 @@ for (const [name, desc] of [["dev", "Start the local canvas (everything on: hot
|
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
117
|
cli.command("ls", "The canvases running on this Mac: slot, link, name, version, state, uptime, folder (no repo needed)").option("--json", "Machine-readable output (never a canvas's key)").action(async (opts) => {
|
|
118
|
-
(await import("./ls-
|
|
118
|
+
(await import("./ls-NqmePKOf.mjs")).lsCommand({ json: opts.json === true });
|
|
119
119
|
});
|
|
120
120
|
cli.command("build", "Static export → design/.dist (what ships comes from design/publish.json - publishing is default-closed)").option("--boards <names>", "Publish only these boards (comma-separated); overrides the publish policy").option("--all-boards", "Publish every board - the loud override for the default-closed policy").option("--embed-seeds", "Copy comment history INTO the web root (identifying - every event carries its author's email)").option("--no-textures", "Skip compiling the glass textures the published frames rest under (needs Chrome; a CI without one skips on its own)").option("--root <dir>", "Host repo root", { default: "." }).action(async (opts) => {
|
|
121
|
-
const { buildSite } = await import("./build-
|
|
121
|
+
const { buildSite } = await import("./build-CWbrb2bl.mjs");
|
|
122
122
|
try {
|
|
123
123
|
const boards = opts.boards === void 0 ? void 0 : typeof opts.boards === "string" ? opts.boards : "";
|
|
124
124
|
await buildSite(resolve$1(opts.root), boards, opts.allBoards === true, opts.embedSeeds === true, opts.textures !== false && !process.env.MARVER_NO_TEXTURES);
|
|
@@ -128,7 +128,7 @@ cli.command("build", "Static export → design/.dist (what ships comes from desi
|
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
130
|
cli.command("serve", "Serve design/.dist (set MARVER_PASSWORD to gate it)").option("--root <dir>", "Host repo root", { default: "." }).option("--port <port>", "Port (default $PORT or 4199)").action(async (opts) => {
|
|
131
|
-
const { serve } = await import("./serve-
|
|
131
|
+
const { serve } = await import("./serve-DQv3Ti6X.mjs");
|
|
132
132
|
let port;
|
|
133
133
|
if (opts.port !== void 0) {
|
|
134
134
|
const n = Number(opts.port);
|
|
@@ -137,7 +137,7 @@ cli.command("serve", "Serve design/.dist (set MARVER_PASSWORD to gate it)").opti
|
|
|
137
137
|
serve(resolve$1(opts.root), port);
|
|
138
138
|
});
|
|
139
139
|
cli.command("comments <action> [value]", "Comment collaboration: connect <url> · sync · list · new <scene/frame> · reply <thread> · move <thread> · resolve <thread> · invite <email> · revoke <email>").option("--root <dir>", "Host repo root", { default: "." }).option("--token <token>", "connect: the canvas's MARVER_CLI_TOKEN (default $MARVER_CLI_TOKEN) - the identity-mode path").option("--invite <token>", "connect: claim this invite instead of signing in").option("--canvas-password <password>", "connect: the canvas gate password (default $MARVER_PASSWORD or prompt)").option("--email <email>", "connect: account email (skips the prompt)").option("--password <password>", "connect: account password (skips the prompt - mind your shell history)").option("--name <name>", "connect --invite: display name for the new account").option("--open", "list: only unresolved threads").option("--json", "list: machine-readable output").option("--board <board>", "list: scope to one board · new: the board to pin on (default: the one its link opens)").option("--body <text>", "new / reply: the text").option("--on <text>", "new / move: pin on the element showing these words").option("--at <selector>", "new / move: pin on the element this data-testid or CSS selector names (an element without words, like an icon)").option("--nth <n>", "new / move: which of several matching elements (1 = the first)").option("--viewport <name>", "new / move: check the frame at this viewport (default: its own)").option("--theme <name>", "new / move: check the frame in this theme (default: light)").option("--thread <id>", "new: add the note to this open thread instead of pinning a new one").option("--fyi", "new: the note asks nothing (default: it asks - it comes first for the human)").option("--ask", "reply: the reply asks the human something").option("--addressed-in <frame>", "resolve: the variant frame that answered the feedback").action(async (action, value, opts) => {
|
|
140
|
-
const { commentsCommand } = await import("./comments-
|
|
140
|
+
const { commentsCommand } = await import("./comments-XNhMmSSu.mjs");
|
|
141
141
|
try {
|
|
142
142
|
await commentsCommand(resolve$1(opts.root), action, value, opts);
|
|
143
143
|
} catch (err) {
|
|
@@ -146,7 +146,7 @@ cli.command("comments <action> [value]", "Comment collaboration: connect <url>
|
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
cli.command("share <action> [value]", "Sharing roster (owner): add <who> · remove <who> · block/unblock <email> · general <mode> · list · requests · explain <who> · who").option("--root <dir>", "Host repo root", { default: "." }).option("--role <role>", "add / requests --approve: view (default) or comment").option("--expires <iso>", "add: expiry timestamp, e.g. 2026-12-31T00:00:00Z").option("--approve <email>", "requests: approve this pending request (canvas-wide in v1)").option("--decline <email>", "requests: decline this pending request (silent to the asker)").option("--json", "list: machine-readable output").action(async (action, value, opts) => {
|
|
149
|
-
const { shareCommand } = await import("./share-
|
|
149
|
+
const { shareCommand } = await import("./share-Bu_kuOKL.mjs");
|
|
150
150
|
try {
|
|
151
151
|
await shareCommand(resolve$1(opts.root), action, value, opts);
|
|
152
152
|
} catch (err) {
|
|
@@ -155,7 +155,7 @@ cli.command("share <action> [value]", "Sharing roster (owner): add <who> · remo
|
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
157
|
cli.command("work <action> [...frames]", "Working state on the canvas: start <scene/frame ...> · done <scene/frame ...> | --all · list").option("--root <dir>", "Host repo root", { default: "." }).option("--ttl <minutes>", "start: minutes before the glow self-expires (default 10, max 30)").option("--all", "done: clear every working frame").action(async (action, frames, opts) => {
|
|
158
|
-
const { workCommand } = await import("./work-
|
|
158
|
+
const { workCommand } = await import("./work-BYWD_1Zf.mjs");
|
|
159
159
|
try {
|
|
160
160
|
await workCommand(resolve$1(opts.root), action, frames ?? [], opts);
|
|
161
161
|
} catch (err) {
|
|
@@ -163,8 +163,22 @@ cli.command("work <action> [...frames]", "Working state on the canvas: start <sc
|
|
|
163
163
|
process.exit(1);
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
|
+
cli.command("jam <action> [...args]", "Live Jam from your coding-agent session: next · say <handle> <words> · progress <handle> · done <handle> --file <f> · release <handle> · status · mute (hook, listen and permit are run by the tools themselves)").option("--root <dir>", "Host repo root (default: the repo above this folder)").option("--as <connection>", "the connection Marver Jam named (Cursor)").option("--file <file>", "done: the final message (the marver-reply blocks)").option("--json", "print the answer as JSON").action(async (action, args, opts) => {
|
|
167
|
+
const jam = await import("./jam-Cj5gBvwD.mjs");
|
|
168
|
+
if (action === "hook") return jam.hookCommand(args[0] ?? "", args[1] ?? "", opts.root);
|
|
169
|
+
if (action === "listen") return jam.listenCommand(opts.root);
|
|
170
|
+
if (action === "permit") return (await import("./permit-DDa6wqOs.mjs").then((n) => n.n)).permitCommand();
|
|
171
|
+
try {
|
|
172
|
+
const root = opts.root ? resolve$1(opts.root) : jam.marverRoot(process.cwd());
|
|
173
|
+
if (!root) throw new Error("not inside a repo with a design/ folder");
|
|
174
|
+
await jam.jamCommand(root, action, args ?? [], opts);
|
|
175
|
+
} catch (err) {
|
|
176
|
+
console.error(`[${NAME}] ${err.message}`);
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
166
180
|
cli.command("link [...targets]", "The canvas link that lands on frames: link <scene/frame | scene ...> - their board, in canvas mode, selected and fitted").option("--root <dir>", "Host repo root", { default: "." }).option("--board <board>", "The board to open (default: the first board that shows them all, else one link per board)").action(async (targets, opts) => {
|
|
167
|
-
const { linkCommand } = await import("./link-
|
|
181
|
+
const { linkCommand } = await import("./link-BFFRgrMt.mjs");
|
|
168
182
|
try {
|
|
169
183
|
await linkCommand(resolve$1(opts.root), targets ?? [], opts);
|
|
170
184
|
} catch (err) {
|
|
@@ -172,30 +186,37 @@ cli.command("link [...targets]", "The canvas link that lands on frames: link <sc
|
|
|
172
186
|
process.exit(1);
|
|
173
187
|
}
|
|
174
188
|
});
|
|
175
|
-
cli.command("boards [action] [...args]", "The sidebar as files: every folder and board in reading order, with types and statuses, and the frames on no board · new <name>: a board in its type's starting layout · pin <board> <scene/frame ...>: put frames on a board").option("--root <dir>", "Host repo root", { default: "." }).option("--json", "The tree as JSON ({ tree, boards, landing, unplaced, registry })").option("--type <type>", "new: start | feature | surface | project | feedback | context | deck | archive (default: the folder's)").option("--folder <folder>", "new: the folder it sits in").option("--title <title>", "new: what humans see").option("--description <sentence>", "new: what agents read").option("--capability <slug>", "new: the capability it shows, when not its own name").action(async (action, args, opts) => {
|
|
176
|
-
const { boardsCommand, boardsNew, boardsPin } = await import("./boards-
|
|
189
|
+
cli.command("boards [action] [...args]", "The sidebar as files: every folder and board in reading order, with types and statuses, and the frames on no board · new <name>: a board in its type's starting layout · pin <board> <scene/frame ...>: put frames on a board · place <board> <scene/frame> --after|--before <scene/frame>: put a frame next to another, making room").option("--root <dir>", "Host repo root", { default: "." }).option("--json", "The tree as JSON ({ tree, boards, landing, unplaced, registry })").option("--type <type>", "new: start | feature | surface | project | feedback | context | deck | archive (default: the folder's)").option("--folder <folder>", "new: the folder it sits in").option("--title <title>", "new: what humans see").option("--description <sentence>", "new: what agents read").option("--capability <slug>", "new: the capability it shows, when not its own name").option("--after <frame>", "place: right after this frame, in its row").option("--before <frame>", "place: right before this frame, in its row").option("--run <handle>", "place, pin: a Live Jam run's new frame - given to that run first (r-xxxxxxxx.N)").option("--as <conn>", "place --run, pin --run: the session connection to speak for (as `jam` does)").action(async (action, args, opts) => {
|
|
190
|
+
const { boardsCommand, boardsNew, boardsPin, boardsPinRun, boardsPlace } = await import("./boards-BeWtjGUM.mjs");
|
|
177
191
|
const [name, ...frames] = args ?? [];
|
|
178
192
|
try {
|
|
179
193
|
if (action === void 0) boardsCommand(resolve$1(opts.root), opts);
|
|
180
194
|
else if (action === "pin") {
|
|
181
195
|
if (!name) throw new Error("name the board: `boards pin <board> <scene/frame ...>`");
|
|
182
|
-
const { added, already } = boardsPin(resolve$1(opts.root), name, frames);
|
|
196
|
+
const { added, already } = opts.run !== void 0 ? await boardsPinRun(resolve$1(opts.root), name, frames, opts) : boardsPin(resolve$1(opts.root), name, frames);
|
|
183
197
|
for (const f of added) console.log(` + ${f} on ${name}`);
|
|
184
198
|
if (already.length) console.log(` already on ${name}: ${already.join(", ")}`);
|
|
199
|
+
} else if (action === "place") {
|
|
200
|
+
if (!name) throw new Error("name the board: `boards place <board> <scene/frame> --after <scene/frame>`");
|
|
201
|
+
const p = await boardsPlace(resolve$1(opts.root), name, frames, opts);
|
|
202
|
+
const where = `${p.rel} ${p.anchor}`;
|
|
203
|
+
if (p.already) console.log(` already there: ${p.frame} is ${where} on ${name}`);
|
|
204
|
+
else if (!p.laidOut) console.log(` + ${p.frame} on ${name}, ${where} in its list - the canvas lays the board out when it opens it`);
|
|
205
|
+
else console.log(` ${p.added ? "+" : "~"} ${p.frame} on ${name}, ${where}${p.shifted ? ` (${p.shifted} moved right to make room)` : ""}`);
|
|
185
206
|
} else if (action === "new") {
|
|
186
207
|
if (!name) throw new Error("name the board: `boards new <name>`");
|
|
187
208
|
const made = boardsNew(resolve$1(opts.root), name, opts);
|
|
188
209
|
for (const c of made) console.log(` + ${c}`);
|
|
189
210
|
if (/\((feature|project)\b/.test(made[0] ?? "") && !existsSync(join(resolve$1(opts.root), "context"))) console.log(`\n note: no context/ yet - this board's status reads Backlog until there is one. Agent: end your reply with the context line in design/AGENTS.md ("Before the method").`);
|
|
190
211
|
if (made.some((c) => c.endsWith("/_brief.md")) && !made.some((c) => /\.(tsx|jsx|html)$/.test(c))) console.log(`\n next: a frame you make in these scenes shows on the board once it is pinned - a node in\n design/boards/${name}.json (an agent does this as it works: design/AGENTS.md)`);
|
|
191
|
-
} else throw new Error(`unknown action "${action}" - \`boards\` lists, \`boards new <name>\` creates, \`boards pin <board> <scene/frame ...>\` puts frames on a board`);
|
|
212
|
+
} else throw new Error(`unknown action "${action}" - \`boards\` lists, \`boards new <name>\` creates, \`boards pin <board> <scene/frame ...>\` puts frames on a board, \`boards place <board> <scene/frame> --after <scene/frame>\` puts one next to another`);
|
|
192
213
|
} catch (err) {
|
|
193
214
|
console.error(`[${NAME}] ${err.message}`);
|
|
194
215
|
process.exit(1);
|
|
195
216
|
}
|
|
196
217
|
});
|
|
197
218
|
cli.command("folders <action> [...modules]", "The shared sidebar's typed folders · add <start|features|surfaces|projects|feedback|context|decks|archive ...>").option("--root <dir>", "Host repo root", { default: "." }).action(async (action, modules, opts) => {
|
|
198
|
-
const { foldersAdd } = await import("./boards-
|
|
219
|
+
const { foldersAdd } = await import("./boards-BeWtjGUM.mjs");
|
|
199
220
|
try {
|
|
200
221
|
if (action !== "add") throw new Error(`unknown action "${action}" - \`folders add <module ...>\``);
|
|
201
222
|
const { added, existing } = foldersAdd(resolve$1(opts.root), modules);
|
|
@@ -207,7 +228,7 @@ cli.command("folders <action> [...modules]", "The shared sidebar's typed folders
|
|
|
207
228
|
}
|
|
208
229
|
});
|
|
209
230
|
cli.command("context <action>", "The project's context/ (spec 19) · init: create it · check: keep it true (exit 0 pass, 1 fail, 2 cannot determine) · index: regenerate the index's capability table").option("--root <dir>", "Host repo root", { default: "." }).option("--base <ref>", "check: the pull request's base - a change to a contracted capability's code must change its contract or say why (in ci, read from the event)").option("--head <ref>", "check: the pull request's head (default HEAD)").option("--body-file <file>", "check: the pull request's body, for `no-contract-change: <capability> - <why>`").option("--json", "check: the findings as JSON ({ exit, failures, unsure, notes })").option("--kind <kind>", "init: product (a shipped record) or knowledge (a delivered record)", { default: "product" }).action(async (action, opts) => {
|
|
210
|
-
const ctx = await import("./context-
|
|
231
|
+
const ctx = await import("./context-BUnFiyA3.mjs");
|
|
211
232
|
const root = resolve$1(opts.root);
|
|
212
233
|
try {
|
|
213
234
|
if (action === "init") {
|
|
@@ -243,7 +264,7 @@ cli.command("context <action>", "The project's context/ (spec 19) · init: creat
|
|
|
243
264
|
}
|
|
244
265
|
});
|
|
245
266
|
cli.command("marks", "What the human has not reviewed: frames waiting on them (the ones that ask first), their answers nothing has acted on yet, and frames new since they looked").option("--root <dir>", "Host repo root", { default: "." }).option("--json", "Machine-readable output").option("--all", "Also list the answers from before 0.26 that may already be handled").action(async (opts) => {
|
|
246
|
-
const { marksCommand } = await import("./marks-
|
|
267
|
+
const { marksCommand } = await import("./marks-DBp3h1Mc.mjs");
|
|
247
268
|
marksCommand(resolve$1(opts.root), opts);
|
|
248
269
|
});
|
|
249
270
|
cli.command("perf [action] [board]", "The reload log: what each edit reloaded, page-wide reloads, the slowest frames to settle, one line per board load; --loads: what each board load did; --jam: Jam's timings; `perf run <board>`: a headless run of the board, read-only (needs `dev` running); --runs: those runs compared; --crashes, --flashes, --machine: the Mac app's records").option("--root <dir>", "Host repo root", { default: "." }).option("--minutes <n>", "How far back to read (default 60; 24 h with --jam)").option("--loads", "Board loads, from the page, each board by its title: time to the visible frames ready and all ready (each frame's first render), still from the last move and settled (a second still after it) - or why it was cut, and how many frames were ready by then - how many moves and their causes, when the first frame started, the slowest frames to settle (their last height) and how long each waited for its turn to start, errors (design/.local/perf/page.jsonl)").option("--jam", "Jam's timings: captures, pictures, words, naming, runs, shots - numbers only (design/.local/perf/jam.jsonl)").option("--runs", "The headless runs (`perf run`), compared only inside a cohort (script, board, Chrome, flags, machine, power, --slow, bakes): the latest against the one before with the same inputs, and against the last with other inputs; overlapped and invalid runs listed apart (design/.local/perf/runs.jsonl)").option("--against <run>", "With --runs: the latest run of that run's cohort against it, whatever their inputs (you changed something on purpose)").option("--crashes", "The Mac app's crashes and hangs of this repo's canvases, each joined to its board load by page (what had settled, the last gesture), the minute before it, and the GPU and utility processes' ends by time (~/.marver/perf/app.jsonl, app-dev.jsonl)").option("--flashes", "The flashes marked in the Mac app (⌃⌥F) on this repo's canvases: the board, the gesture the mark fell in (or the one ending within 2 s of it), the GPU process's events, pressure at the mark, the GPU figures and the picture's path; the white-out detector's candidates apart, automatic and not verified").option("--machine", "The machine profiles the Mac app and headless runs wrote (~/.marver/perf/machine), by host, which is current, and how many records and runs name each").option("--all", "With --flashes: also the marks made on other canvases or on Home").option("--days <n>", "How far back --runs, --crashes, --flashes and --machine read (default 14)").option("--slow", "With `run`: the CPU throttled 4x (a stand-in for a slower Mac's CPU, not its GPU or memory)").option("--repeat <n>", "With `run`: how many runs, one after another (1-5, default 1)").option("--json", "Machine-readable output").action(async (action, board, opts) => {
|
|
@@ -251,7 +272,7 @@ cli.command("perf [action] [board]", "The reload log: what each edit reloaded, p
|
|
|
251
272
|
console.error(`[${NAME}] unknown action "${action}" - the one action is run: ${NAME} perf run <board>`);
|
|
252
273
|
process.exit(1);
|
|
253
274
|
}
|
|
254
|
-
const { perfCommand, perfRunCommand } = await import("./perf-
|
|
275
|
+
const { perfCommand, perfRunCommand } = await import("./perf-Denssrko.mjs");
|
|
255
276
|
const typed = (v) => typeof v === "number" ? process.argv.find((t) => !t.startsWith("-") && Number(t) === v) ?? String(v) : v === void 0 ? void 0 : String(v);
|
|
256
277
|
if (action !== "run") return perfCommand(resolve$1(opts.root), {
|
|
257
278
|
...opts,
|
|
@@ -265,7 +286,7 @@ cli.command("perf [action] [board]", "The reload log: what each edit reloaded, p
|
|
|
265
286
|
}
|
|
266
287
|
});
|
|
267
288
|
cli.command("shot [...frames]", "Render frames headless and print the PNG paths (needs `dev` running): ids, --scene <name> or --all").option("--root <dir>", "Host repo root", { default: "." }).option("--scene <name>", "Every frame of one scene").option("--all", "Every frame of the canvas").option("--theme <name>", "Theme to render (default: light)").option("--scale <n>", "Device pixels per CSS px, 1-4 (default: 2; 4 for print-quality stills)").option("--json", "Print the results as JSON ({ results: [...] }) instead of paths").action(async (frames, opts) => {
|
|
268
|
-
const { shotCommand } = await import("./shot-
|
|
289
|
+
const { shotCommand } = await import("./shot-DBWN8hPP.mjs");
|
|
269
290
|
try {
|
|
270
291
|
await shotCommand(resolve$1(opts.root), frames, opts);
|
|
271
292
|
} catch (err) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { r as NAME } from "./cli.mjs";
|
|
2
|
-
import { i as readDevInfo } from "./work-
|
|
2
|
+
import { i as readDevInfo } from "./work-DJxH7cCX.mjs";
|
|
3
3
|
import { r as replay } from "./events-CLH4ijKP.mjs";
|
|
4
4
|
import { a as readLog, i as listBoards, t as appendEvents } from "./comments-0BSbb04K.mjs";
|
|
5
|
-
import { a as syncOnce, i as loadCollab, n as connectClaim, r as connectToken, t as connect } from "./sync-
|
|
6
|
-
import { n as localProfile } from "./profile-
|
|
5
|
+
import { a as syncOnce, i as loadCollab, n as connectClaim, r as connectToken, t as connect } from "./sync-CMozOwZ0.mjs";
|
|
6
|
+
import { n as localProfile } from "./profile-B1FKOM1e.mjs";
|
|
7
7
|
import { a as runningAgent } from "./agent-BsieQGTD.mjs";
|
|
8
8
|
import { n as readTarget, r as uncheckedAnchor } from "./anchor-5H1vnoLu.mjs";
|
|
9
9
|
import { join } from "node:path";
|
|
@@ -132,7 +132,7 @@ async function commentsCommand(root, action, value, opts) {
|
|
|
132
132
|
case "new": {
|
|
133
133
|
if (opts.thread !== void 0) return addToThread(root, String(opts.thread), value, opts);
|
|
134
134
|
if (!value || !opts.body) throw new Error("usage: comments new <scene/frame> --body \"...\" --on \"<words it shows>\" | --at \"<selector or data-testid>\" [--nth <n>] [--fyi] [--board <board>]");
|
|
135
|
-
const { resolveLink, devOrigin } = await import("./link-
|
|
135
|
+
const { resolveLink, devOrigin } = await import("./link-BFFRgrMt.mjs");
|
|
136
136
|
const r = resolveLink(root, [value], opts.board);
|
|
137
137
|
if (r.exact.length !== 1) throw new Error(`"${value}" is a folder of frames - pin a note on one frame: comments new <scene/frame>`);
|
|
138
138
|
if (!r.board) throw new Error(`a note needs a board to live on - ${r.hints.join("\n")}`);
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { h as readDescription } from "./board-tree-BXR8dw4b.mjs";
|
|
3
|
+
import { i as onPath, n as AGENT_NAMES, r as detectAgent, t as AGENT_BIN } from "./agent-BsieQGTD.mjs";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
//#region src/server/config.ts
|
|
8
|
+
var config_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
+
DEFAULTS: () => DEFAULTS,
|
|
10
|
+
loadConfig: () => loadConfig
|
|
11
|
+
});
|
|
12
|
+
const DEFAULTS = {
|
|
13
|
+
mode: "studio",
|
|
14
|
+
theme: null,
|
|
15
|
+
viewports: {
|
|
16
|
+
mobile: {
|
|
17
|
+
width: 390,
|
|
18
|
+
height: 844
|
|
19
|
+
},
|
|
20
|
+
tablet: {
|
|
21
|
+
width: 768,
|
|
22
|
+
height: 1024
|
|
23
|
+
},
|
|
24
|
+
laptop: {
|
|
25
|
+
width: 1280,
|
|
26
|
+
height: 800
|
|
27
|
+
},
|
|
28
|
+
monitor: {
|
|
29
|
+
width: 1920,
|
|
30
|
+
height: 1080
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
themes: ["light", "dark"],
|
|
34
|
+
port: 5199,
|
|
35
|
+
zoomSpeed: 1,
|
|
36
|
+
share: { branding: true }
|
|
37
|
+
};
|
|
38
|
+
/** Load design/config.ts via native TS import (Node >= 22.18). Missing or broken fields fall back to defaults. */
|
|
39
|
+
async function loadConfig(root) {
|
|
40
|
+
const file = join(root, "design", "config.ts");
|
|
41
|
+
if (!existsSync(file)) return {
|
|
42
|
+
...DEFAULTS,
|
|
43
|
+
...jamFields(void 0)
|
|
44
|
+
};
|
|
45
|
+
try {
|
|
46
|
+
const user = (await import(`${pathToFileURL(file).href}?t=${Date.now()}`)).default ?? {};
|
|
47
|
+
return {
|
|
48
|
+
...DEFAULTS,
|
|
49
|
+
...user,
|
|
50
|
+
viewports: validViewports(user.viewports) ?? DEFAULTS.viewports,
|
|
51
|
+
themes: Array.isArray(user.themes) && user.themes.length ? user.themes.map(String) : DEFAULTS.themes,
|
|
52
|
+
port: validPort(user.port) ?? DEFAULTS.port,
|
|
53
|
+
zoomSpeed: validZoom(user.zoomSpeed) ?? DEFAULTS.zoomSpeed,
|
|
54
|
+
description: readDescription(user.description),
|
|
55
|
+
share: {
|
|
56
|
+
branding: user.share?.branding !== false,
|
|
57
|
+
name: typeof user.share?.name === "string" ? user.share.name : void 0,
|
|
58
|
+
logo: typeof user.share?.logo === "string" ? user.share.logo : void 0,
|
|
59
|
+
frontDoor: user.share?.frontDoor !== false && user.share?.front_door !== false,
|
|
60
|
+
notify: user.share?.notify !== false
|
|
61
|
+
},
|
|
62
|
+
...jamFields(user.jam)
|
|
63
|
+
};
|
|
64
|
+
} catch (err) {
|
|
65
|
+
console.error(`[marver] design/config.ts failed to load, using defaults and leaving Live Jam OFF:\n ${err.message}`);
|
|
66
|
+
return {
|
|
67
|
+
...DEFAULTS,
|
|
68
|
+
jamOff: "unreadable"
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const validDim = (n) => typeof n === "number" && Number.isFinite(n) && n >= 1 && n <= 2e4;
|
|
73
|
+
function validPort(n) {
|
|
74
|
+
return typeof n === "number" && Number.isInteger(n) && n > 0 && n < 65536 ? n : null;
|
|
75
|
+
}
|
|
76
|
+
function validZoom(n) {
|
|
77
|
+
return typeof n === "number" && Number.isFinite(n) && n >= .1 && n <= 10 ? n : null;
|
|
78
|
+
}
|
|
79
|
+
/** Six frames at once is what a jam actually feels like - at 3, half of a multi-frame
|
|
80
|
+
* ask sat waiting on the other half while the human watched. */
|
|
81
|
+
const DEFAULT_CONCURRENCY = 6;
|
|
82
|
+
/** A config value, printable in a warning. Never throws - a formatter that can crash inside an
|
|
83
|
+
* error path (JSON.stringify does, on a BigInt) turns a clear message into a mystery. */
|
|
84
|
+
const show = (v) => {
|
|
85
|
+
try {
|
|
86
|
+
return JSON.stringify(v) ?? String(v);
|
|
87
|
+
} catch {
|
|
88
|
+
return String(v);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
/** A `{...}` written by hand, not a Date/Map/class instance that merely types as "object". */
|
|
92
|
+
const plainObject = (v) => {
|
|
93
|
+
if (!v || typeof v !== "object") return false;
|
|
94
|
+
const proto = Object.getPrototypeOf(v);
|
|
95
|
+
return proto === Object.prototype || proto === null;
|
|
96
|
+
};
|
|
97
|
+
/** The agent to arm with - or, when the human NAMED one we cannot use, why not (said once,
|
|
98
|
+
* here, because a bad `jam.agent` is a config-file error like any other).
|
|
99
|
+
*
|
|
100
|
+
* A named agent is never quietly swapped for another: running a different tool than the one
|
|
101
|
+
* asked for is worse than not running. Nor is one armed that cannot be spawned - that would
|
|
102
|
+
* claim every @marver mention, fail it, and never retry. */
|
|
103
|
+
function resolveAgent(named) {
|
|
104
|
+
if (named === void 0) return detectAgent() ?? "no-agent";
|
|
105
|
+
if (typeof named !== "string" || !Object.hasOwn(AGENT_BIN, named)) {
|
|
106
|
+
console.warn(`[marver] design/config.ts: jam.agent ${show(named)} is not an agent marver can spawn - Live Jam is off. Use ${AGENT_NAMES}.`);
|
|
107
|
+
return "bad-agent";
|
|
108
|
+
}
|
|
109
|
+
const agent = named;
|
|
110
|
+
if (!onPath(AGENT_BIN[agent])) {
|
|
111
|
+
console.warn(`[marver] design/config.ts names jam.agent "${agent}", but \`${AGENT_BIN[agent]}\` is not on PATH - Live Jam is off until it is installed.`);
|
|
112
|
+
return "bad-agent";
|
|
113
|
+
}
|
|
114
|
+
return agent;
|
|
115
|
+
}
|
|
116
|
+
/** Resolve the jam block. Live Jam is ON by default: an absent or partial `jam` resolves
|
|
117
|
+
* to whatever agent CLI this machine has, so a fresh workspace jams with nothing
|
|
118
|
+
* configured and an old one needs no re-init. `jam: false` is the off switch. */
|
|
119
|
+
function resolveJam(v) {
|
|
120
|
+
if (v === false) return "opted-out";
|
|
121
|
+
const shape = v === void 0 || v === true ? {} : typeof v === "string" ? { agent: v } : plainObject(v) ? v : null;
|
|
122
|
+
if (!shape) {
|
|
123
|
+
console.warn(`[marver] design/config.ts: jam must be false, an agent name, or an options object - got ${show(v)}. Live Jam is off.`);
|
|
124
|
+
return "bad-agent";
|
|
125
|
+
}
|
|
126
|
+
const j = shape;
|
|
127
|
+
const agent = resolveAgent(j.agent);
|
|
128
|
+
if (agent === "no-agent" || agent === "bad-agent") return agent;
|
|
129
|
+
const c = j.concurrency;
|
|
130
|
+
const pick = (key, v, ok, fallback, want) => {
|
|
131
|
+
if (v === void 0) return fallback;
|
|
132
|
+
if (ok(v)) return v;
|
|
133
|
+
console.warn(`[marver] design/config.ts: jam.${key} must be ${want} - got ${show(v)}. Using ${JSON.stringify(fallback)}.`);
|
|
134
|
+
return fallback;
|
|
135
|
+
};
|
|
136
|
+
const bool = (v) => typeof v === "boolean";
|
|
137
|
+
return {
|
|
138
|
+
agent,
|
|
139
|
+
concurrency: typeof c === "number" && Number.isInteger(c) && c >= 1 && c <= 16 ? c : DEFAULT_CONCURRENCY,
|
|
140
|
+
subagents: j.subagents !== false,
|
|
141
|
+
proactive: j.proactive === true,
|
|
142
|
+
chime: pick("chime", j.chime, bool, true, "true or false"),
|
|
143
|
+
capture: pick("capture", j.capture, (v) => v === "confirm" || v === "at-once", "confirm", `'confirm' or 'at-once'`),
|
|
144
|
+
loc: pick("loc", j.loc, bool, true, "true or false"),
|
|
145
|
+
names: pick("names", j.names, bool, true, "true or false"),
|
|
146
|
+
runner: pick("runner", j.runner, (v) => v === "auto" || v === "session" || v === "background", "auto", `'auto', 'session' or 'background'`),
|
|
147
|
+
session: pick("session", j.session, bool, true, "true or false"),
|
|
148
|
+
context: pick("context", j.context, (v) => v === "fork" || v === "fresh", "fork", `'fork' or 'fresh'`),
|
|
149
|
+
mcp: pick("mcp", j.mcp, bool, true, "true or false"),
|
|
150
|
+
skills: pick("skills", j.skills, bool, true, "true or false"),
|
|
151
|
+
others: pick("others", j.others, bool, false, "true or false"),
|
|
152
|
+
...((sm) => sm === void 0 ? {} : { sessionMax: sm })(pick("sessionMax", j.sessionMax, (v) => typeof v === "number" && Number.isInteger(v) && v >= 1 && v <= 8, void 0, "a whole number from 1 to 8"))
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/** Exactly one of `jam` (armed) or `jamOff` (why not) - so the dev server can speak up about
|
|
156
|
+
* the one off-state nothing has reported yet, and stay quiet about the rest. BOTH keys are
|
|
157
|
+
* always written: these spread over the user's own `jam`, and a raw `jam: false` reaching the
|
|
158
|
+
* server as config would arm the daemon against a truthy object check. */
|
|
159
|
+
function jamFields(v) {
|
|
160
|
+
const r = resolveJam(v);
|
|
161
|
+
return typeof r === "string" ? {
|
|
162
|
+
jam: void 0,
|
|
163
|
+
jamOff: r
|
|
164
|
+
} : {
|
|
165
|
+
jam: r,
|
|
166
|
+
jamOff: void 0
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function validViewports(v) {
|
|
170
|
+
if (!v || typeof v !== "object") return null;
|
|
171
|
+
const out = {};
|
|
172
|
+
for (const [k, val] of Object.entries(v)) {
|
|
173
|
+
const vp = val;
|
|
174
|
+
if (validDim(vp?.width) && validDim(vp?.height)) out[k] = {
|
|
175
|
+
width: Math.round(vp.width),
|
|
176
|
+
height: Math.round(vp.height)
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return Object.keys(out).length ? out : null;
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
export { loadConfig as n, config_exports as t };
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { r as NAME } from "./cli.mjs";
|
|
3
|
+
import { chmodSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
6
|
+
//#region src/server/jam/conn.ts
|
|
7
|
+
/**
|
|
8
|
+
* The sessions connected to this repo (spec 29b, Part 3): one file per connection under
|
|
9
|
+
* design/.local/jam/conn/, written by the hooks (`marver jam hook`, `marver jam listen`) and read by
|
|
10
|
+
* the daemon. A connection is one Claude Code, Codex or Cursor session that can take Jam runs.
|
|
11
|
+
*
|
|
12
|
+
* Also the small shared state beside them: the offers file the daemon writes for each connection
|
|
13
|
+
* (what the Claude Code listener and the Stop hooks read), and this machine's Jam preferences (the
|
|
14
|
+
* start sheet's switches).
|
|
15
|
+
*
|
|
16
|
+
* Kept free of heavy imports: the hooks load this on every session start and every prompt.
|
|
17
|
+
*/
|
|
18
|
+
var conn_exports = /* @__PURE__ */ __exportAll({
|
|
19
|
+
CONN_AGENTS: () => CONN_AGENTS,
|
|
20
|
+
CURSOR_SILENT_MS: () => CURSOR_SILENT_MS,
|
|
21
|
+
alive: () => alive,
|
|
22
|
+
closeConn: () => closeConn,
|
|
23
|
+
connDir: () => connDir,
|
|
24
|
+
connFile: () => connFile,
|
|
25
|
+
connId: () => connId,
|
|
26
|
+
eligible: () => eligible,
|
|
27
|
+
endConn: () => endConn,
|
|
28
|
+
jamDir: () => jamDir,
|
|
29
|
+
listConns: () => listConns,
|
|
30
|
+
offersFile: () => offersFile,
|
|
31
|
+
offersText: () => offersText,
|
|
32
|
+
patchConn: () => patchConn,
|
|
33
|
+
pidAlive: () => pidAlive,
|
|
34
|
+
pingLine: () => pingLine,
|
|
35
|
+
prefsFile: () => prefsFile,
|
|
36
|
+
readConn: () => readConn,
|
|
37
|
+
readOffers: () => readOffers,
|
|
38
|
+
readPrefs: () => readPrefs,
|
|
39
|
+
unlike: () => unlike,
|
|
40
|
+
upsertConn: () => upsertConn,
|
|
41
|
+
validConnId: () => validConnId,
|
|
42
|
+
writeAtomic: () => writeAtomic,
|
|
43
|
+
writeOffers: () => writeOffers,
|
|
44
|
+
writePrefs: () => writePrefs
|
|
45
|
+
});
|
|
46
|
+
const CONN_AGENTS = [
|
|
47
|
+
"claude",
|
|
48
|
+
"codex",
|
|
49
|
+
"cursor"
|
|
50
|
+
];
|
|
51
|
+
const jamDir = (root) => join(root, "design", ".local", "jam");
|
|
52
|
+
const connDir = (root) => join(jamDir(root), "conn");
|
|
53
|
+
const connFile = (root, id) => join(connDir(root), `${id}.json`);
|
|
54
|
+
const offersFile = (root, id) => join(connDir(root), `${id}.offers`);
|
|
55
|
+
const prefsFile = (root) => join(jamDir(root), "prefs.json");
|
|
56
|
+
const CONN_ID = /^(claude|codex|cursor)-[0-9a-f]{12}$/;
|
|
57
|
+
const validConnId = (id) => typeof id === "string" && CONN_ID.test(id);
|
|
58
|
+
const connId = (agent, session) => `${agent}-${createHash("sha256").update(session).digest("hex").slice(0, 12)}`;
|
|
59
|
+
/** A Cursor session not heard from in this long is gone (Cursor has no process to look at). */
|
|
60
|
+
const CURSOR_SILENT_MS = 216e5;
|
|
61
|
+
/** Write a file whole or not at all: a reader never sees half of it. */
|
|
62
|
+
function writeAtomic(file, text, mode = 384) {
|
|
63
|
+
const tmp = `${file}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
64
|
+
writeFileSync(tmp, text, { mode });
|
|
65
|
+
try {
|
|
66
|
+
renameSync(tmp, file);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
rmSync(tmp, { force: true });
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const ensureDir = (dir) => {
|
|
73
|
+
mkdirSync(dir, {
|
|
74
|
+
recursive: true,
|
|
75
|
+
mode: 448
|
|
76
|
+
});
|
|
77
|
+
try {
|
|
78
|
+
chmodSync(dir, 448);
|
|
79
|
+
} catch {}
|
|
80
|
+
};
|
|
81
|
+
function readConn(root, id) {
|
|
82
|
+
if (!validConnId(id)) return null;
|
|
83
|
+
try {
|
|
84
|
+
const c = JSON.parse(readFileSync(connFile(root, id), "utf8"));
|
|
85
|
+
return c && c.v === 1 && c.id === id && typeof c.key === "string" && typeof c.inc === "string" && CONN_AGENTS.includes(c.agent) ? c : null;
|
|
86
|
+
} catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function listConns(root) {
|
|
91
|
+
let names;
|
|
92
|
+
try {
|
|
93
|
+
names = readdirSync(connDir(root));
|
|
94
|
+
} catch {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
return names.filter((n) => n.endsWith(".json")).map((n) => readConn(root, n.slice(0, -5))).filter((c) => !!c);
|
|
98
|
+
}
|
|
99
|
+
/** Register (or refresh) a session's connection. A refresh keeps its incarnation and key - the capability
|
|
100
|
+
* its commands sign with; `fresh` (a session starting, a listener taking over) begins a new incarnation with a
|
|
101
|
+
* new key, so nothing the last one held still signs. An ended connection comes back only fresh. */
|
|
102
|
+
function upsertConn(root, agent, session, patch, now = Date.now(), fresh = false) {
|
|
103
|
+
ensureDir(connDir(root));
|
|
104
|
+
const id = connId(agent, session);
|
|
105
|
+
const was0 = readConn(root, id);
|
|
106
|
+
const was = was0 && !fresh && !was0.ended ? was0 : null;
|
|
107
|
+
const known = Object.fromEntries(Object.entries(patch).filter(([, v]) => v !== void 0));
|
|
108
|
+
const c = {
|
|
109
|
+
...was ?? {
|
|
110
|
+
cwd: root,
|
|
111
|
+
busy: false,
|
|
112
|
+
since: now,
|
|
113
|
+
key: randomBytes(32).toString("hex"),
|
|
114
|
+
inc: randomBytes(6).toString("hex")
|
|
115
|
+
},
|
|
116
|
+
...known,
|
|
117
|
+
v: 1,
|
|
118
|
+
id,
|
|
119
|
+
agent,
|
|
120
|
+
session,
|
|
121
|
+
seen: now,
|
|
122
|
+
...was ? {} : {
|
|
123
|
+
ended: void 0,
|
|
124
|
+
muted: void 0,
|
|
125
|
+
acted: was0?.acted
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
writeAtomic(connFile(root, id), JSON.stringify(c));
|
|
129
|
+
return c;
|
|
130
|
+
}
|
|
131
|
+
/** Change a live registration in place - that incarnation only, never one that ended, never a new one. */
|
|
132
|
+
function patchConn(root, id, inc, patch) {
|
|
133
|
+
const c = readConn(root, id);
|
|
134
|
+
if (!c || c.ended || c.inc !== inc) return false;
|
|
135
|
+
writeAtomic(connFile(root, id), JSON.stringify({
|
|
136
|
+
...c,
|
|
137
|
+
...patch,
|
|
138
|
+
seen: Date.now()
|
|
139
|
+
}));
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
/** A session ended (its end hook, its listener exiting): marked, not removed - a run it held is reconciled first;
|
|
143
|
+
* the daemon removes it once nothing depends on it. `inc`: only that incarnation (a resumed one stays). */
|
|
144
|
+
function endConn(root, id, inc) {
|
|
145
|
+
const c = readConn(root, id);
|
|
146
|
+
if (!c || c.ended || inc && c.inc !== inc) return;
|
|
147
|
+
writeAtomic(connFile(root, id), JSON.stringify({
|
|
148
|
+
...c,
|
|
149
|
+
ended: true,
|
|
150
|
+
seen: Date.now()
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
/** Remove a connection for good: its file and its offers go. */
|
|
154
|
+
function closeConn(root, id) {
|
|
155
|
+
if (!validConnId(id)) return;
|
|
156
|
+
rmSync(connFile(root, id), { force: true });
|
|
157
|
+
rmSync(offersFile(root, id), { force: true });
|
|
158
|
+
}
|
|
159
|
+
const pidAlive = (pid) => {
|
|
160
|
+
if (!pid || !Number.isInteger(pid) || pid <= 1) return false;
|
|
161
|
+
try {
|
|
162
|
+
process.kill(pid, 0);
|
|
163
|
+
return true;
|
|
164
|
+
} catch (err) {
|
|
165
|
+
return err.code === "EPERM";
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const alive = (c, now = Date.now()) => !c.ended && (c.agent === "cursor" ? now - c.seen < 216e5 : pidAlive(c.pid));
|
|
169
|
+
/** Can this session take Jam work now? (The selection and the runner choice come after.) */
|
|
170
|
+
const eligible = (c, now = Date.now()) => alive(c, now) && !c.muted && c.mode !== "plan" && (c.agent !== "cursor" || !c.composer || c.composer === "agent");
|
|
171
|
+
const STOP_LINE = (handles, as) => `Live Jam: the owner moved ${handles.join(", ")} elsewhere - stop working on ${handles.length === 1 ? "it" : "them"} (a subagent of yours on ${handles.length === 1 ? "it" : "one"}: stop that subagent first, or tell it to stop and release it itself) and run ${handles.map((h) => `\`npx ${NAME} jam release ${h}${as ? ` --as ${as}` : ""}\``).join(", ")}.`;
|
|
172
|
+
const RESUME_LINE = (handles, as) => `Live Jam: the owner gave ${handles.join(", ")} back to you - carry on (a subagent of yours on ${handles.length === 1 ? "it" : "one"}: tell it to), and run ${handles.map((h) => `\`npx ${NAME} jam progress ${h}${as ? ` --as ${as}` : ""}\``).join(", ")}.`;
|
|
173
|
+
const READY_LINE = (n, as, latest) => `Live Jam: ${n === 1 ? "new request" : `${n} new requests`} from your Marver canvas${latest ? ` - ${n === 1 ? "" : "newest "}"${latest.title}" (${latest.id}${latest.overlaps ? `, overlaps your run ${latest.overlaps}` : ""})` : ""} - run \`npx ${NAME} jam next${as ? ` --as ${as}` : ""}\`${n === 1 ? "" : " for each"}.`;
|
|
174
|
+
/** What a session is told of its offers: the ready line, then any run it must let go or may carry on with. */
|
|
175
|
+
const offersText = (o, as) => [
|
|
176
|
+
o.n > 0 ? READY_LINE(o.n, as, o.latest) : "",
|
|
177
|
+
o.stop?.length ? STOP_LINE(o.stop, as) : "",
|
|
178
|
+
o.resume?.length ? RESUME_LINE(o.resume, as) : ""
|
|
179
|
+
].filter(Boolean).join(" ");
|
|
180
|
+
/** `text`, unless it is the line posted before it - then that line's "(again)" count, one more. Claude Code drops a
|
|
181
|
+
* message identical to the one before it from the same sender, so the listener checks what it actually posted. */
|
|
182
|
+
function unlike(text, prev) {
|
|
183
|
+
if (!text || text !== prev) return text;
|
|
184
|
+
const m = /^(.*) \(again(?: ×(\d+))?\)$/s.exec(text);
|
|
185
|
+
const times = m ? Number(m[2] ?? 1) + 1 : 1;
|
|
186
|
+
return `${m ? m[1] : text} (again${times > 1 ? ` ×${times}` : ""})`;
|
|
187
|
+
}
|
|
188
|
+
/** The listener's line for a new gen: `offersText`, ending "(again)" when it reads as the line before it did (a run
|
|
189
|
+
* offered back, a second "give it back") - Claude Code drops a message identical to the one before it. */
|
|
190
|
+
function pingLine(o, prev) {
|
|
191
|
+
const text = offersText(o);
|
|
192
|
+
const m = /^(.*) \(again(?: ×(\d+))?\)$/s.exec(prev ?? "");
|
|
193
|
+
const times = (m ? m[1] : prev) === text ? Number(m?.[2] ?? (m ? 1 : 0)) + 1 : 0;
|
|
194
|
+
return times ? `${text} (again${times > 1 ? ` ×${times}` : ""})` : text;
|
|
195
|
+
}
|
|
196
|
+
function writeOffers(root, id, o) {
|
|
197
|
+
if (!validConnId(id)) return;
|
|
198
|
+
ensureDir(connDir(root));
|
|
199
|
+
writeAtomic(offersFile(root, id), JSON.stringify(o));
|
|
200
|
+
}
|
|
201
|
+
function readOffers(root, id) {
|
|
202
|
+
try {
|
|
203
|
+
const o = JSON.parse(readFileSync(offersFile(root, id), "utf8"));
|
|
204
|
+
return Number.isInteger(o?.n) && Number.isInteger(o?.gen) ? o : null;
|
|
205
|
+
} catch {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function readPrefs(root) {
|
|
210
|
+
try {
|
|
211
|
+
const p = JSON.parse(readFileSync(prefsFile(root), "utf8"));
|
|
212
|
+
return p && typeof p === "object" && !Array.isArray(p) ? p : {};
|
|
213
|
+
} catch {
|
|
214
|
+
return {};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function writePrefs(root, p) {
|
|
218
|
+
ensureDir(jamDir(root));
|
|
219
|
+
writeAtomic(prefsFile(root), JSON.stringify(p, null, 1));
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
222
|
+
export { writePrefs as C, writeOffers as S, readPrefs as _, conn_exports as a, validConnId as b, jamDir as c, offersText as d, patchConn as f, readOffers as g, readConn as h, connId as i, listConns as l, pingLine as m, closeConn as n, eligible as o, pidAlive as p, connDir as r, endConn as s, alive as t, offersFile as u, unlike as v, writeAtomic as x, upsertConn as y };
|