@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
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { i as PKG, r as NAME } from "./cli.mjs";
|
|
2
|
-
import { a as notePrefer, c as ranDevBefore, f as startedWhere, i as marverHome,
|
|
2
|
+
import { _ as runIdentity, a as notePrefer, c as ranDevBefore, f as startedWhere, i as marverHome, o as originOf, p as stopPrefer, s as place, t as forgetDevTraces } from "./slots-Dn4Onb0V.mjs";
|
|
3
3
|
import { t as detectHost } from "./detect-C0wpaePX.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { n as loadConfig } from "./config-BezZTiov.mjs";
|
|
5
|
+
import { n as tailwind3Css, o as liveChanged, r as tailwind4Plugin, s as installedVersion, t as marverPlugin } from "./plugin-DqoZB-D6.mjs";
|
|
5
6
|
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, watch, writeSync } from "node:fs";
|
|
6
7
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
7
8
|
import { fileURLToPath } from "node:url";
|
|
@@ -986,7 +987,7 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
986
987
|
const port = claim.port;
|
|
987
988
|
const origin = originOf(server.httpServer?.address()) ?? `http://localhost:${port}`;
|
|
988
989
|
claim.ready(origin);
|
|
989
|
-
const { workActivity, writeDevInfo, removeDevInfo, boardsShowing, onBoardsChanged, nextActivitySeq } = await import("./work-
|
|
990
|
+
const { workActivity, writeDevInfo, removeDevInfo, boardsShowing, onBoardsChanged, nextActivitySeq } = await import("./work-DJxH7cCX.mjs").then((n) => n.o);
|
|
990
991
|
t.claim(() => removeDevInfo(root, instance));
|
|
991
992
|
writeDevInfo(root, port, instance);
|
|
992
993
|
await opts.at?.("published");
|
|
@@ -1018,7 +1019,7 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1018
1019
|
if (fromConfig !== void 0 && !placed.fellBackFrom) console.log(` this canvas keeps its own port (${fromConfig} in design/config.ts); remove it to use the slots\n`);
|
|
1019
1020
|
setTimeout(async () => {
|
|
1020
1021
|
try {
|
|
1021
|
-
await (await import("./shot-
|
|
1022
|
+
await (await import("./shot-T04Ixrvq.mjs").then((n) => n.u)).sweepGhosts((m) => console.log(` ${m}`));
|
|
1022
1023
|
} catch {}
|
|
1023
1024
|
}, 0);
|
|
1024
1025
|
try {
|
|
@@ -1032,11 +1033,11 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1032
1033
|
} catch {}
|
|
1033
1034
|
try {
|
|
1034
1035
|
if (!existsSync(join(root, "context"))) {
|
|
1035
|
-
const n = (await import("./manifest-
|
|
1036
|
+
const n = (await import("./manifest-DPZ3WNg_.mjs").then((n) => n.i)).statusBoards(root).length;
|
|
1036
1037
|
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`);
|
|
1037
1038
|
}
|
|
1038
1039
|
} catch {}
|
|
1039
|
-
const { loadCollab, syncOnce } = await import("./sync-
|
|
1040
|
+
const { loadCollab, syncOnce } = await import("./sync-CMozOwZ0.mjs").then((n) => n.o);
|
|
1040
1041
|
if (loadCollab(root)) console.log(` comments: syncing with the published canvas\n`);
|
|
1041
1042
|
let syncing = false;
|
|
1042
1043
|
const tick = async () => {
|
|
@@ -1090,6 +1091,7 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1090
1091
|
due.set(m[1], setTimeout(() => {
|
|
1091
1092
|
due.delete(m[1]);
|
|
1092
1093
|
server.ws.send("sh:jam-comment", { board: m[1] });
|
|
1094
|
+
liveChanged();
|
|
1093
1095
|
}, 120));
|
|
1094
1096
|
}));
|
|
1095
1097
|
t.defer(() => {
|
|
@@ -1099,9 +1101,12 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1099
1101
|
} catch {}
|
|
1100
1102
|
}
|
|
1101
1103
|
if (config.jam) {
|
|
1102
|
-
const { startJam } = await import("./daemon-
|
|
1103
|
-
const { checkAnchor } = await import("./anchor-check-
|
|
1104
|
-
const jam = startJam(root, config.jam, (m) => console.log(m), (board) =>
|
|
1104
|
+
const { startJam } = await import("./daemon-Sc_z8gT6.mjs");
|
|
1105
|
+
const { checkAnchor } = await import("./anchor-check-DhlpKl2K.mjs");
|
|
1106
|
+
const jam = startJam(root, config.jam, (m) => console.log(m), (board) => {
|
|
1107
|
+
server.ws.send("sh:jam-comment", { board });
|
|
1108
|
+
liveChanged();
|
|
1109
|
+
}, (frameId, target, others, look) => checkAnchor({
|
|
1105
1110
|
root,
|
|
1106
1111
|
viewports: config.viewports,
|
|
1107
1112
|
origin: `http://localhost:${port}`,
|
|
@@ -1114,12 +1119,13 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1114
1119
|
return () => {
|
|
1115
1120
|
due ??= setTimeout(async () => {
|
|
1116
1121
|
due = null;
|
|
1117
|
-
const { jamLive } = await import("./
|
|
1122
|
+
const { jamLive } = await import("./plugin-DqoZB-D6.mjs").then((n) => n.a);
|
|
1118
1123
|
server.ws.send("sh:jam-queue", jamLive.view?.() ?? { cards: [] });
|
|
1124
|
+
liveChanged();
|
|
1119
1125
|
}, 60);
|
|
1120
1126
|
};
|
|
1121
1127
|
})(), async (frameId, theme, entry, size) => {
|
|
1122
|
-
const { shootFrame } = await import("./shot-
|
|
1128
|
+
const { shootFrame } = await import("./shot-T04Ixrvq.mjs").then((n) => n.u);
|
|
1123
1129
|
const r = await shootFrame({
|
|
1124
1130
|
root,
|
|
1125
1131
|
viewports: config.viewports,
|
|
@@ -1129,7 +1135,7 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1129
1135
|
...size ? { size } : {}
|
|
1130
1136
|
});
|
|
1131
1137
|
if (!r.ok) return null;
|
|
1132
|
-
const { addPicture } = await import("./capture-
|
|
1138
|
+
const { addPicture } = await import("./capture-DEtM4qm5.mjs").then((n) => n.i);
|
|
1133
1139
|
return addPicture(root, r.path, {
|
|
1134
1140
|
frame: frameId,
|
|
1135
1141
|
...entry,
|
|
@@ -1138,9 +1144,19 @@ async function boot(root, opts, instance, t, ctx) {
|
|
|
1138
1144
|
}, watch$1.add);
|
|
1139
1145
|
if (jam) {
|
|
1140
1146
|
t.defer(() => jam.stop());
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1147
|
+
if (config.jam.session !== false) try {
|
|
1148
|
+
const { ensureConnectors, connectorLine } = await import("./connectors-DekQvKt9.mjs");
|
|
1149
|
+
const { jamLive } = await import("./plugin-DqoZB-D6.mjs").then((n) => n.a);
|
|
1150
|
+
const results = ensureConnectors(root);
|
|
1151
|
+
jamLive.connectors = results;
|
|
1152
|
+
const line = connectorLine(results);
|
|
1153
|
+
if (line) console.log(line);
|
|
1154
|
+
} catch (err) {
|
|
1155
|
+
console.log(` jam: could not connect sessions - ${err.message}`);
|
|
1156
|
+
}
|
|
1157
|
+
const { createSpeech, speechLive } = await import("./audio-DX4POHAj.mjs");
|
|
1158
|
+
const { appendTalk } = await import("./session-VDJfXEEm.mjs").then((n) => n.s);
|
|
1159
|
+
const { logJam } = await import("./perf-jam-CLkERSHo.mjs").then((n) => n.n);
|
|
1144
1160
|
const speech = createSpeech({
|
|
1145
1161
|
onTalk: (t) => appendTalk(root, t.session, t.words),
|
|
1146
1162
|
onTiming: (t) => logJam(root, {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { r as NAME } from "./cli.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { c as listBoardFiles, n as addFolders } from "./boards-EH2onUXM.mjs";
|
|
3
3
|
import { C as KIND_FOLDERS, x as FOLDER_MODULES } from "./board-tree-BXR8dw4b.mjs";
|
|
4
|
-
import { s as scanFrames, u as writeManifest } from "./manifest-
|
|
4
|
+
import { s as scanFrames, u as writeManifest } from "./manifest-DPZ3WNg_.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
8
|
import { n as readJson, t as detectHost } from "./detect-C0wpaePX.mjs";
|
|
9
|
+
import { connectorLine, ensureConnectors } from "./connectors-DekQvKt9.mjs";
|
|
9
10
|
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
10
11
|
import { basename, dirname, join, relative } from "node:path";
|
|
11
12
|
//#region src/cli/init.ts
|
|
@@ -264,6 +265,10 @@ function init(root, opts) {
|
|
|
264
265
|
if (!existsSync(join(root, "context"))) console.log(`\n note: no context/ yet - feature and project boards read Backlog until there is one, and nothing records what shipped. To start it, tell your agent: "Set up our context." (design/instructions/context.md)`);
|
|
265
266
|
if (!jamAgent) console.log(`\n note: Live Jam found no agent CLI on PATH (claude, codex, cursor, droid, opencode, grok, or pi) - install one and it arms itself on the next \`${NAME} dev\`.`);
|
|
266
267
|
else if (created.includes("design/config.ts")) console.log(`\n Live Jam is on (${jamAgent}): tag @${NAME} in a canvas comment and your agent does the work, then replies in the thread.`);
|
|
268
|
+
if (jamAgent) try {
|
|
269
|
+
const line = connectorLine(ensureConnectors(root));
|
|
270
|
+
if (line) console.log(`\n${line}`);
|
|
271
|
+
} catch {}
|
|
267
272
|
console.log(`\n next: npx ${NAME} dev (or: npx ${NAME} canvas - same thing; it prints its link: a free slot, localhost:4805-4824, usually the same one next time)\n`);
|
|
268
273
|
if (!noApp(host) && created.includes("design/config.ts")) console.log(` then, to your agent: "Read design/AGENTS.md. This is our first session - follow design/instructions/welcome.md."\n`);
|
|
269
274
|
}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { r as NAME } from "./cli.mjs";
|
|
2
|
+
import { _ as readPrefs, d as offersText, g as readOffers, h as readConn, i as connId, l as listConns, p as pidAlive, s as endConn, u as offersFile, v as unlike, y as upsertConn } from "./conn-BMiHS42T.mjs";
|
|
3
|
+
import { request } from "./transport-C5FnY9ni.mjs";
|
|
4
|
+
import { existsSync, readFileSync, realpathSync, statSync, watch } from "node:fs";
|
|
5
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
6
|
+
import { createConnection } from "node:net";
|
|
7
|
+
import { execFileSync } from "node:child_process";
|
|
8
|
+
//#region src/cli/jam.ts
|
|
9
|
+
/**
|
|
10
|
+
* `marver jam` - Live Jam from a coding-agent session (spec 29b).
|
|
11
|
+
*
|
|
12
|
+
* jam next | say <handle> <words> | progress <handle> | done <handle> --file <f> | release <handle> | status | mute
|
|
13
|
+
* what a session runs when Marver Jam wakes it: take a run, work on it, hand the result back
|
|
14
|
+
* jam hook <claude|codex|cursor> <start|prompt|stop|end> run by the tools' hooks, never by hand
|
|
15
|
+
* jam listen Claude Code's listener, started by its hooks
|
|
16
|
+
* jam permit the permission tool of a background Claude Code run
|
|
17
|
+
*
|
|
18
|
+
* The session's commands reach the daemon through files (transport.ts) - a sandbox that blocks
|
|
19
|
+
* localhost cannot stop them. A hook never fails its host: an error prints nothing and exits 0.
|
|
20
|
+
*/
|
|
21
|
+
/** The repo a hook or a session works in: the nearest folder above `from` with a design/ that marver made. */
|
|
22
|
+
function marverRoot(from) {
|
|
23
|
+
let at = resolve(from);
|
|
24
|
+
for (;;) {
|
|
25
|
+
if ([
|
|
26
|
+
"config.ts",
|
|
27
|
+
"scenes",
|
|
28
|
+
".local"
|
|
29
|
+
].some((x) => existsSync(join(at, "design", x)))) try {
|
|
30
|
+
return realpathSync(at);
|
|
31
|
+
} catch {
|
|
32
|
+
return at;
|
|
33
|
+
}
|
|
34
|
+
const up = dirname(at);
|
|
35
|
+
if (up === at) return null;
|
|
36
|
+
at = up;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Jam is off for this repo's sessions (`jam: false`, `jam.session: false`), or for this process. */
|
|
40
|
+
async function sessionsOff(root, env) {
|
|
41
|
+
if (env.MARVER_JAM_BACKGROUND === "1" || env.MARVER_JAM === "off") return true;
|
|
42
|
+
try {
|
|
43
|
+
const { loadConfig } = await import("./config-BezZTiov.mjs").then((n) => n.t);
|
|
44
|
+
const cfg = await loadConfig(root);
|
|
45
|
+
return !cfg.jam || cfg.jam.session === false;
|
|
46
|
+
} catch {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const readStdin = async () => {
|
|
51
|
+
if (process.stdin.isTTY) return {};
|
|
52
|
+
const chunks = [];
|
|
53
|
+
let to;
|
|
54
|
+
const done = new Promise((res) => {
|
|
55
|
+
process.stdin.on("data", (c) => chunks.push(c));
|
|
56
|
+
process.stdin.on("end", () => res());
|
|
57
|
+
process.stdin.on("error", () => res());
|
|
58
|
+
});
|
|
59
|
+
await Promise.race([done, new Promise((r) => {
|
|
60
|
+
to = setTimeout(r, 2e3);
|
|
61
|
+
})]);
|
|
62
|
+
clearTimeout(to);
|
|
63
|
+
try {
|
|
64
|
+
const o = JSON.parse(Buffer.concat(chunks).toString("utf8") || "{}");
|
|
65
|
+
return o && typeof o === "object" ? o : {};
|
|
66
|
+
} catch {
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/** The nearest ancestor process whose command is `name` (Codex runs its hooks through a shell). */
|
|
71
|
+
function ancestor(name, from = process.ppid) {
|
|
72
|
+
let pid = from;
|
|
73
|
+
for (let i = 0; i < 8 && pid > 1; i++) {
|
|
74
|
+
let line;
|
|
75
|
+
try {
|
|
76
|
+
line = execFileSync("ps", [
|
|
77
|
+
"-o",
|
|
78
|
+
"ppid=,comm=",
|
|
79
|
+
"-p",
|
|
80
|
+
String(pid)
|
|
81
|
+
], {
|
|
82
|
+
encoding: "utf8",
|
|
83
|
+
timeout: 2e3
|
|
84
|
+
}).trim();
|
|
85
|
+
} catch {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const m = /^(\d+)\s+(.*)$/.exec(line);
|
|
89
|
+
if (!m) return void 0;
|
|
90
|
+
if (name.test(m[2].split("/").pop() ?? "")) return pid;
|
|
91
|
+
pid = Number(m[1]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const CONNECTED_LINE = (as) => `This session is connected to Marver's Live Jam: the owner's requests from the design canvas (their @marver tags and voice captures) come to you as "Live Jam: ... new request" - take each with \`npx ${NAME} jam next${as ? ` --as ${as}` : ""}\` (design/AGENTS.md, "Live Jam").`;
|
|
95
|
+
/** `jam hook <agent> <event>`: register, mark busy or idle, answer in the tool's own words. Prints
|
|
96
|
+
* nothing and exits 0 on anything unexpected - a hook must never break its host. */
|
|
97
|
+
async function hookCommand(agent, event, rootOpt) {
|
|
98
|
+
try {
|
|
99
|
+
if (process.env.MARVER_JAM_BACKGROUND === "1" || process.env.GROK_HOOK_EVENT) return;
|
|
100
|
+
const out = await hook(agent, event, await readStdin(), process.env, Date.now(), rootOpt);
|
|
101
|
+
if (out) process.stdout.write(JSON.stringify(out));
|
|
102
|
+
} catch {}
|
|
103
|
+
}
|
|
104
|
+
/** Is this hook input from the tool the entry was written for? Cursor runs Claude Code's hooks, Grok runs
|
|
105
|
+
* both Claude Code's and Cursor's - and either may have inherited a Claude Code session's variables, so the
|
|
106
|
+
* input's own shape decides, before anything else is looked at. */
|
|
107
|
+
function ownHost(agent, input, env) {
|
|
108
|
+
if (env.GROK_HOOK_EVENT || typeof input.hookEventName === "string") return false;
|
|
109
|
+
const cursor = typeof input.cursor_version === "string";
|
|
110
|
+
if (agent === "cursor") return cursor && typeof (input.session_id ?? input.conversation_id) === "string";
|
|
111
|
+
if (cursor || typeof input.hook_event_name !== "string" || typeof input.session_id !== "string") return false;
|
|
112
|
+
return agent === "claude" ? !!env.CLAUDE_CODE_MESSAGING_SOCKET : agent === "codex";
|
|
113
|
+
}
|
|
114
|
+
/** The repo a hook speaks for: its `--root`, else the session's folder, else here. */
|
|
115
|
+
const hookRoot = (input, rootOpt) => {
|
|
116
|
+
if (rootOpt) return marverRoot(rootOpt);
|
|
117
|
+
return marverRoot(typeof input.cwd === "string" && isAbsolute(input.cwd) ? input.cwd : Array.isArray(input.workspace_roots) && typeof input.workspace_roots[0] === "string" ? input.workspace_roots[0] : process.cwd());
|
|
118
|
+
};
|
|
119
|
+
/** The hook itself, pure enough to test: what it writes is the connection, what it returns is the answer. */
|
|
120
|
+
async function hook(agent, event, input, env, now = Date.now(), rootOpt) {
|
|
121
|
+
if (env.MARVER_JAM_BACKGROUND === "1") return null;
|
|
122
|
+
if (!ownHost(agent, input, env)) return null;
|
|
123
|
+
if (agent === "claude" && event !== "end") return null;
|
|
124
|
+
const session = String(input.session_id ?? input.conversation_id ?? "");
|
|
125
|
+
const root = hookRoot(input, rootOpt);
|
|
126
|
+
if (!session || !root) return null;
|
|
127
|
+
const id = connId(agent, session);
|
|
128
|
+
if (event === "end") {
|
|
129
|
+
endConn(root, id);
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
if (await sessionsOff(root, env) || readPrefs(root).off?.[agent]) {
|
|
133
|
+
endConn(root, id);
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
if (agent === "codex") {
|
|
137
|
+
const start = event === "start";
|
|
138
|
+
const was = readConn(root, id);
|
|
139
|
+
const pid = start || !was?.pid || was.ended ? ancestor(/^codex/) : was.pid;
|
|
140
|
+
const c = upsertConn(root, "codex", session, {
|
|
141
|
+
pid,
|
|
142
|
+
cwd: root,
|
|
143
|
+
mode: typeof input.permission_mode === "string" ? input.permission_mode : void 0,
|
|
144
|
+
busy: event === "prompt"
|
|
145
|
+
}, now, !was || !!was.ended || !!pid && was.pid !== pid);
|
|
146
|
+
const offers = readOffers(root, id);
|
|
147
|
+
const text = offers ? offersText(offers) : "";
|
|
148
|
+
if (start) return { hookSpecificOutput: {
|
|
149
|
+
hookEventName: "SessionStart",
|
|
150
|
+
additionalContext: CONNECTED_LINE()
|
|
151
|
+
} };
|
|
152
|
+
if (event === "prompt") return text ? { hookSpecificOutput: {
|
|
153
|
+
hookEventName: "UserPromptSubmit",
|
|
154
|
+
additionalContext: text
|
|
155
|
+
} } : null;
|
|
156
|
+
if (event === "stop" && offers && text && offers.gen > (c.acted ?? 0)) {
|
|
157
|
+
upsertConn(root, "codex", session, {
|
|
158
|
+
acted: offers.gen,
|
|
159
|
+
busy: true
|
|
160
|
+
}, now);
|
|
161
|
+
return {
|
|
162
|
+
decision: "block",
|
|
163
|
+
reason: text
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
if (input.is_background_agent === true) return null;
|
|
169
|
+
const composer = typeof input.composer_mode === "string" ? input.composer_mode : void 0;
|
|
170
|
+
const c = upsertConn(root, "cursor", session, {
|
|
171
|
+
cwd: root,
|
|
172
|
+
busy: event === "prompt",
|
|
173
|
+
...composer ? { composer } : {}
|
|
174
|
+
}, now, event === "start" || !!readConn(root, id)?.ended);
|
|
175
|
+
const offers = readOffers(root, id);
|
|
176
|
+
const text = offers ? offersText(offers, c.id) : "";
|
|
177
|
+
if (event === "start") return { additional_context: CONNECTED_LINE(c.id) };
|
|
178
|
+
if (event === "prompt") return { continue: true };
|
|
179
|
+
if (event === "stop" && offers && text && offers.gen > (c.acted ?? 0)) {
|
|
180
|
+
upsertConn(root, "cursor", session, {
|
|
181
|
+
acted: offers.gen,
|
|
182
|
+
busy: true
|
|
183
|
+
}, now);
|
|
184
|
+
return { followup_message: text };
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
/** One listener per Claude Code process (spec 29b, Part 5): registers the session, wakes it through
|
|
189
|
+
* its inbox when runs are offered, and exits with it. Started by both hooks; a second start hands
|
|
190
|
+
* over the current session id and exits. It posts the line the canvas wrote, word for word - an upgrade
|
|
191
|
+
* under it changes nothing it says, so it never restarts itself. */
|
|
192
|
+
async function listenCommand(rootOpt) {
|
|
193
|
+
const env = process.env;
|
|
194
|
+
if (env.MARVER_JAM_BACKGROUND === "1" || env.GROK_HOOK_EVENT || env.CLAUDE_CODE_ENTRYPOINT && env.CLAUDE_CODE_ENTRYPOINT !== "cli") return;
|
|
195
|
+
const input = await readStdin().catch(() => ({}));
|
|
196
|
+
if (!ownHost("claude", input, env)) return;
|
|
197
|
+
const sock = env.CLAUDE_CODE_MESSAGING_SOCKET, token = env.CLAUDE_CODE_MESSAGING_TOKEN, claudePid = Number(env.CLAUDE_PID);
|
|
198
|
+
if (!token || !Number.isInteger(claudePid) || claudePid <= 1) return;
|
|
199
|
+
const session = String(input.session_id);
|
|
200
|
+
const root = hookRoot(input, rootOpt);
|
|
201
|
+
if (!root || await sessionsOff(root, env) || readPrefs(root).off?.claude) return;
|
|
202
|
+
const { claimListener, readListener, writeListener, releaseListener } = await import("./listener-DdLEM79A.mjs");
|
|
203
|
+
const mode = typeof input.permission_mode === "string" ? input.permission_mode : void 0;
|
|
204
|
+
const held = readListener(root, claudePid);
|
|
205
|
+
if (held && held.pid !== process.pid && pidAlive(held.pid)) {
|
|
206
|
+
if (held.session !== session || mode && held.mode !== mode) writeListener(root, claudePid, {
|
|
207
|
+
...held,
|
|
208
|
+
session,
|
|
209
|
+
...mode ? { mode } : {}
|
|
210
|
+
});
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (!claimListener(root, claudePid, {
|
|
214
|
+
pid: process.pid,
|
|
215
|
+
session,
|
|
216
|
+
...mode ? { mode } : {}
|
|
217
|
+
})) return;
|
|
218
|
+
const parent = process.ppid;
|
|
219
|
+
let current = session;
|
|
220
|
+
const prev = readConn(root, connId("claude", current));
|
|
221
|
+
let conn = upsertConn(root, "claude", current, {
|
|
222
|
+
pid: claudePid,
|
|
223
|
+
cwd: root,
|
|
224
|
+
mode,
|
|
225
|
+
busy: false
|
|
226
|
+
}, Date.now(), !prev || prev.pid !== claudePid || !!prev.ended);
|
|
227
|
+
let posted = 0;
|
|
228
|
+
/** Post one message to the session's inbox: true once it is written (a failure is tried again next look). */
|
|
229
|
+
const post = (text) => new Promise((res) => {
|
|
230
|
+
const c = createConnection(sock);
|
|
231
|
+
let ok = false;
|
|
232
|
+
const end = () => {
|
|
233
|
+
try {
|
|
234
|
+
c.destroy();
|
|
235
|
+
} catch {}
|
|
236
|
+
res(ok);
|
|
237
|
+
};
|
|
238
|
+
c.on("connect", () => {
|
|
239
|
+
c.write(JSON.stringify({
|
|
240
|
+
type: "auth",
|
|
241
|
+
token
|
|
242
|
+
}) + "\n");
|
|
243
|
+
c.write(JSON.stringify({
|
|
244
|
+
type: "user",
|
|
245
|
+
message: {
|
|
246
|
+
role: "user",
|
|
247
|
+
content: text
|
|
248
|
+
}
|
|
249
|
+
}) + "\n", (err) => {
|
|
250
|
+
ok = !err;
|
|
251
|
+
setTimeout(end, 500);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
c.on("error", end);
|
|
255
|
+
setTimeout(end, 5e3);
|
|
256
|
+
});
|
|
257
|
+
const quit = (over) => {
|
|
258
|
+
if (over) endConn(root, conn.id, conn.inc);
|
|
259
|
+
releaseListener(root, claudePid, process.pid);
|
|
260
|
+
process.exit(0);
|
|
261
|
+
};
|
|
262
|
+
process.on("SIGTERM", () => quit(!pidAlive(claudePid)));
|
|
263
|
+
process.on("SIGINT", () => quit(!pidAlive(claudePid)));
|
|
264
|
+
process.on("SIGHUP", () => quit(!pidAlive(claudePid)));
|
|
265
|
+
let delivered = "";
|
|
266
|
+
const look = async () => {
|
|
267
|
+
if (!pidAlive(claudePid) || process.ppid !== parent || !existsSync(join(root, "design")) || readPrefs(root).off?.claude) return quit(!pidAlive(claudePid) || !!readPrefs(root).off?.claude);
|
|
268
|
+
const l = readListener(root, claudePid);
|
|
269
|
+
if (l && l.pid !== process.pid) return quit(false);
|
|
270
|
+
if (l && (l.session !== current || l.mode !== conn.mode)) {
|
|
271
|
+
if (l.session !== current) {
|
|
272
|
+
endConn(root, conn.id, conn.inc);
|
|
273
|
+
current = l.session;
|
|
274
|
+
posted = 0;
|
|
275
|
+
}
|
|
276
|
+
conn = upsertConn(root, "claude", current, {
|
|
277
|
+
pid: claudePid,
|
|
278
|
+
cwd: root,
|
|
279
|
+
mode: l.mode,
|
|
280
|
+
busy: false
|
|
281
|
+
}, Date.now(), l.session !== conn.session);
|
|
282
|
+
}
|
|
283
|
+
const now = readConn(root, conn.id);
|
|
284
|
+
if (!now || now.inc !== conn.inc) conn = upsertConn(root, "claude", current, {
|
|
285
|
+
pid: claudePid,
|
|
286
|
+
cwd: root,
|
|
287
|
+
mode: conn.mode,
|
|
288
|
+
busy: false
|
|
289
|
+
}, Date.now(), true);
|
|
290
|
+
const o = readOffers(root, conn.id);
|
|
291
|
+
if (!o || o.gen <= posted) return;
|
|
292
|
+
const text = unlike(o.n || o.stop?.length || o.resume?.length ? o.line ?? offersText(o) : "", delivered);
|
|
293
|
+
if (!text || await post(text)) {
|
|
294
|
+
posted = o.gen;
|
|
295
|
+
if (text) delivered = text;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
let busy = false;
|
|
299
|
+
const tick = () => {
|
|
300
|
+
if (busy) return;
|
|
301
|
+
busy = true;
|
|
302
|
+
look().catch(() => {}).finally(() => {
|
|
303
|
+
busy = false;
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
try {
|
|
307
|
+
watch(dirname(offersFile(root, conn.id)), { persistent: false }, tick);
|
|
308
|
+
} catch {}
|
|
309
|
+
setInterval(tick, 1e3);
|
|
310
|
+
}
|
|
311
|
+
/** This session's own connection: by its tool's session id, or `--as` (Cursor) - never "whichever". */
|
|
312
|
+
function ownConn(root, env, as) {
|
|
313
|
+
if (as) {
|
|
314
|
+
const c = readConn(root, as);
|
|
315
|
+
if (!c) throw new Error(`no connected session ${as} - it may have ended`);
|
|
316
|
+
return c;
|
|
317
|
+
}
|
|
318
|
+
const tries = [["claude", env.CLAUDE_CODE_SESSION_ID], ["codex", env.CODEX_THREAD_ID]];
|
|
319
|
+
for (const [agent, session] of tries) {
|
|
320
|
+
if (!session) continue;
|
|
321
|
+
const c = readConn(root, connId(agent, session));
|
|
322
|
+
if (c) return c;
|
|
323
|
+
}
|
|
324
|
+
if (env.CLAUDE_CODE_SESSION_ID || env.CODEX_THREAD_ID) throw new Error("this session is not connected to the canvas yet - it connects at its next message (or start a Jam session on the canvas)");
|
|
325
|
+
const cursor = listConns(root).filter((c) => c.agent === "cursor");
|
|
326
|
+
throw new Error(cursor.length ? "name your connection: --as <id>, as the Live Jam message said" : "run this from the coding-agent session Live Jam woke");
|
|
327
|
+
}
|
|
328
|
+
async function jamCommand(root, action, args, opts) {
|
|
329
|
+
if (![
|
|
330
|
+
"next",
|
|
331
|
+
"say",
|
|
332
|
+
"progress",
|
|
333
|
+
"done",
|
|
334
|
+
"release",
|
|
335
|
+
"status",
|
|
336
|
+
"mute"
|
|
337
|
+
].includes(action)) throw new Error(`unknown jam action "${action}" - next, say, progress, done, release, status or mute`);
|
|
338
|
+
const conn = ownConn(root, process.env, opts.as);
|
|
339
|
+
const a = {};
|
|
340
|
+
if ([
|
|
341
|
+
"say",
|
|
342
|
+
"progress",
|
|
343
|
+
"done",
|
|
344
|
+
"release"
|
|
345
|
+
].includes(action)) {
|
|
346
|
+
if (!args[0]) throw new Error(`name the run: jam ${action} <handle>`);
|
|
347
|
+
a.handle = args[0];
|
|
348
|
+
}
|
|
349
|
+
if (action === "say") {
|
|
350
|
+
a.text = args.slice(1).join(" ").trim();
|
|
351
|
+
if (!a.text) throw new Error("say what: jam say <handle> \"On it - ...\"");
|
|
352
|
+
}
|
|
353
|
+
if (action === "done") {
|
|
354
|
+
let text = "";
|
|
355
|
+
if (opts.file) {
|
|
356
|
+
const f = resolve(root, opts.file);
|
|
357
|
+
if (!statSync(f).isFile()) throw new Error(`${opts.file} is not a file`);
|
|
358
|
+
text = readFileSync(f, "utf8");
|
|
359
|
+
} else if (!process.stdin.isTTY) text = readFileSync(0, "utf8");
|
|
360
|
+
if (!text.trim()) throw new Error("hand back the final message: jam done <handle> --file <file> (the marver-reply blocks)");
|
|
361
|
+
if (text.length > 4e5) throw new Error("the final message is too long - the replies go in marver-reply blocks, not the work itself");
|
|
362
|
+
a.text = text;
|
|
363
|
+
}
|
|
364
|
+
const r = await request(root, conn, action, a, action === "done" ? 12e4 : 3e4);
|
|
365
|
+
if (opts.json) {
|
|
366
|
+
console.log(JSON.stringify(r, null, 1));
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (r.ok === false) throw new Error(String(r.error ?? "refused"));
|
|
370
|
+
if (typeof r.text === "string") console.log(r.text);
|
|
371
|
+
}
|
|
372
|
+
//#endregion
|
|
373
|
+
export { hookCommand, jamCommand, listenCommand, marverRoot, ownConn };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { r as NAME } from "./cli.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { _ as unplacedHint, a as checkBoardsDir, c as listBoardFiles, p as readMembership } from "./boards-EH2onUXM.mjs";
|
|
3
3
|
import { f as isBoardName } from "./board-tree-BXR8dw4b.mjs";
|
|
4
|
-
import { s as scanFrames } from "./manifest-
|
|
5
|
-
import { i as readDevInfo } from "./work-
|
|
4
|
+
import { s as scanFrames } from "./manifest-DPZ3WNg_.mjs";
|
|
5
|
+
import { i as readDevInfo } from "./work-DJxH7cCX.mjs";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
//#region src/cli/link.ts
|
|
8
8
|
/**
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { c as jamDir, p as pidAlive, x as writeAtomic } from "./conn-BMiHS42T.mjs";
|
|
2
|
+
import { mkdirSync, readFileSync, rmSync, rmdirSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
//#region src/server/jam/listener.ts
|
|
5
|
+
/**
|
|
6
|
+
* The Claude Code listener's lock (spec 29b, Part 5): one listener per Claude Code process, at
|
|
7
|
+
* design/.local/jam/listen/<CLAUDE_PID>.json. A second start finds it alive and hands over the current
|
|
8
|
+
* session id (a new prompt, /clear, compaction, a resume); a lock whose listener is gone is taken over.
|
|
9
|
+
* S29-5b's lesson: without it, the wake-up's own prompt hook starts a second listener, and a third.
|
|
10
|
+
*
|
|
11
|
+
* Taking over a dead listener's lock happens under a reclaim lock of its own (created exclusively), and
|
|
12
|
+
* only after reading the lock again under it - so two starts that both saw it stale never both win.
|
|
13
|
+
*/
|
|
14
|
+
const listenerFile = (root, claudePid) => join(jamDir(root), "listen", `${claudePid}.json`);
|
|
15
|
+
function readListener(root, claudePid) {
|
|
16
|
+
try {
|
|
17
|
+
const l = JSON.parse(readFileSync(listenerFile(root, claudePid), "utf8"));
|
|
18
|
+
return Number.isInteger(l?.pid) && typeof l.session === "string" ? l : null;
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Hand over a new session id or mode - only to the listener that holds the lock now. */
|
|
24
|
+
function writeListener(root, claudePid, l) {
|
|
25
|
+
if (readListener(root, claudePid)?.pid !== l.pid) return;
|
|
26
|
+
writeAtomic(listenerFile(root, claudePid), JSON.stringify(l));
|
|
27
|
+
}
|
|
28
|
+
/** Is the lock held by nobody alive? A lock that cannot be read and is not new (a start that crashed mid-write) is. */
|
|
29
|
+
function stale(file, held) {
|
|
30
|
+
if (held) return !pidAlive(held.pid);
|
|
31
|
+
try {
|
|
32
|
+
return Date.now() - statSync(file).mtimeMs > 5e3;
|
|
33
|
+
} catch {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Take the lock: created exclusively when there is none; a dead one replaced only under the reclaim lock. */
|
|
38
|
+
function claimListener(root, claudePid, l) {
|
|
39
|
+
const file = listenerFile(root, claudePid);
|
|
40
|
+
mkdirSync(join(jamDir(root), "listen"), {
|
|
41
|
+
recursive: true,
|
|
42
|
+
mode: 448
|
|
43
|
+
});
|
|
44
|
+
const create = () => {
|
|
45
|
+
try {
|
|
46
|
+
writeFileSync(file, JSON.stringify(l), {
|
|
47
|
+
flag: "wx",
|
|
48
|
+
mode: 384
|
|
49
|
+
});
|
|
50
|
+
return true;
|
|
51
|
+
} catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
if (create()) return true;
|
|
56
|
+
if (!stale(file, readListener(root, claudePid))) return false;
|
|
57
|
+
const reclaim = `${file}.reclaim`;
|
|
58
|
+
try {
|
|
59
|
+
mkdirSync(reclaim);
|
|
60
|
+
} catch {
|
|
61
|
+
try {
|
|
62
|
+
if (Date.now() - statSync(reclaim).mtimeMs > 1e4) rmdirSync(reclaim);
|
|
63
|
+
} catch {}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
if (!stale(file, readListener(root, claudePid))) return false;
|
|
68
|
+
rmSync(file, { force: true });
|
|
69
|
+
return create();
|
|
70
|
+
} finally {
|
|
71
|
+
try {
|
|
72
|
+
rmdirSync(reclaim);
|
|
73
|
+
} catch {}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function releaseListener(root, claudePid, pid) {
|
|
77
|
+
if (readListener(root, claudePid)?.pid === pid) rmSync(listenerFile(root, claudePid), { force: true });
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { claimListener, readListener, releaseListener, writeListener };
|