@marver-design/marver 0.27.2 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/README.md +4 -2
  3. package/dist/{anchor-check-gkxkPAIv.mjs → anchor-check-PHUOFj1N.mjs} +1 -1
  4. package/dist/{audio-Dw1lfMdb.mjs → audio-DX4POHAj.mjs} +39 -4
  5. package/dist/{boards-BqUqKNW8.mjs → boards-BeWtjGUM.mjs} +49 -4
  6. package/dist/boards-EH2onUXM.mjs +995 -0
  7. package/dist/{build-VgNg4rr8.mjs → build-BsAyLMT1.mjs} +7 -5
  8. package/dist/{capture-vadKjuCo.mjs → capture-DdZ6xgoz.mjs} +92 -30
  9. package/dist/cli.mjs +37 -16
  10. package/dist/{comments-YEU1Zhv9.mjs → comments-CrBHPEQl.mjs} +2 -2
  11. package/dist/config-BezZTiov.mjs +182 -0
  12. package/dist/conn-BMiHS42T.mjs +222 -0
  13. package/dist/connectors-MR9d-EBP.mjs +290 -0
  14. package/dist/{context-Ccjrhr1J.mjs → context-BUnFiyA3.mjs} +2 -2
  15. package/dist/{daemon-Dc9AH0M3.mjs → daemon-C5dg2R-V.mjs} +2187 -182
  16. package/dist/{dev-ri6nAlRp.mjs → dev-D7YS7iT2.mjs} +22 -11
  17. package/dist/{init-W0nxR1OY.mjs → init-WE5lQkQL.mjs} +7 -2
  18. package/dist/jam-Cj5gBvwD.mjs +373 -0
  19. package/dist/{link-CdTgn94Y.mjs → link-BFFRgrMt.mjs} +3 -3
  20. package/dist/listener-DdLEM79A.mjs +80 -0
  21. package/dist/{manifest-aFyDmL8C.mjs → manifest-DPZ3WNg_.mjs} +1 -1
  22. package/dist/{marks-BF9pNEgH.mjs → marks-Dyn6tmjp.mjs} +3 -3
  23. package/dist/{marks-CnCCfAbD.mjs → marks-Kmdab_5w.mjs} +2 -2
  24. package/dist/{perf-DkAUFT6W.mjs → perf-Cn5LiRaY.mjs} +3 -3
  25. package/dist/{perf-jam-BaH3Lg0m.mjs → perf-jam-QxD_UnzN.mjs} +1 -1
  26. package/dist/permit-DDa6wqOs.mjs +187 -0
  27. package/dist/{plugin-B8UghYuF.mjs → plugin-C_0yb-Fq.mjs} +365 -518
  28. package/dist/{poster-BNgafWMK.mjs → poster-DHi6I1fO.mjs} +1 -1
  29. package/dist/{publish-bakes-38Nja78p.mjs → publish-bakes-r4PEZuPl.mjs} +2 -2
  30. package/dist/{queue-CAM_vNmX.mjs → queue-c-6aTHEz.mjs} +164 -25
  31. package/dist/{recover-B8AiI29B.mjs → recover-nrLEVLyJ.mjs} +1 -1
  32. package/dist/{session-BAaJsK5c.mjs → session-DyVE7cCk.mjs} +1 -1
  33. package/dist/{shot-Ch24tiMO.mjs → shot-BrRtqaiS.mjs} +7 -6
  34. package/dist/{shot-CMQgMVZm.mjs → shot-DBWN8hPP.mjs} +1 -1
  35. package/dist/sizes-wjXDev3b.mjs +139 -0
  36. package/dist/speech-worker.mjs +23 -3
  37. package/dist/transport-C5FnY9ni.mjs +203 -0
  38. package/dist/{work-Bxz-ObF3.mjs → work-BYWD_1Zf.mjs} +3 -3
  39. package/dist/{work-CNhFF9pU.mjs → work-DJxH7cCX.mjs} +1 -1
  40. package/docs/jam-session.md +39 -14
  41. package/docs/live-jam.md +92 -10
  42. package/package.json +1 -1
  43. package/src/client/shell/JamSurface.tsx +56 -21
  44. package/src/client/shell/icons.tsx +1 -0
  45. package/src/client/shell/jam-capture.ts +97 -22
  46. package/src/client/shell/jam-keys.ts +32 -6
  47. package/src/client/shell/jam-lane.tsx +14 -5
  48. package/src/client/shell/jam-lines.ts +66 -9
  49. package/src/client/shell/jam-panel.tsx +55 -3
  50. package/src/client/shell/jam-queue.ts +50 -8
  51. package/src/client/shell/jam-session.tsx +53 -4
  52. package/src/client/shell/jam-surface-parts.tsx +6 -3
  53. package/src/client/shell/jam-ui.tsx +6 -1
  54. package/src/client/shell/jam-voice-wait.ts +21 -0
  55. package/src/client/shell/jam-voice.ts +14 -5
  56. package/src/client/shell/styles.css +27 -11
  57. package/src/client/shell/tidy.ts +3 -2
  58. package/src/shared/approval.ts +20 -0
  59. package/src/shared/events.ts +1 -1
  60. package/templates/AGENTS-embedded.md +28 -1
  61. package/templates/AGENTS-studio.md +28 -1
  62. package/templates/instructions/boards.md +7 -1
  63. package/templates/instructions/jam.md +90 -0
  64. package/dist/boards-BHKP5yhI.mjs +0 -342
@@ -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 };
@@ -0,0 +1,290 @@
1
+ import { i as onPath } from "./agent-BsieQGTD.mjs";
2
+ import { C as writePrefs, _ as readPrefs, c as jamDir, x as writeAtomic } from "./conn-BMiHS42T.mjs";
3
+ import { existsSync, mkdirSync, readFileSync, statSync } from "node:fs";
4
+ import { dirname, isAbsolute, join } from "node:path";
5
+ import { spawnSync } from "node:child_process";
6
+ //#region src/server/jam/connectors.ts
7
+ /**
8
+ * Connectors (spec 29b, Part 2): the hooks that connect Claude Code, Codex and Cursor sessions in this
9
+ * repo to Live Jam - written by `marver init`, by `marver dev` at boot, and when a Jam session starts.
10
+ * The owner never writes them; they are what makes starting a Jam session the one switch.
11
+ *
12
+ * Every entry runs one command, `<repo>/node_modules/.bin/marver jam hook|listen ...`. The merge only
13
+ * ever touches Marver's own entries (recognised by that command), keeps every other key and hook, and
14
+ * leaves alone a file that does not parse, a file git tracks, and an entry the owner removed by hand.
15
+ */
16
+ /** Marver's own hook commands - how an entry is recognised as ours, whatever path it was written with. */
17
+ const OURS = /\bmarver(?:\.mjs)?["']?\s+jam\s+(?:hook|listen)\b/;
18
+ const FILES = {
19
+ claude: ".claude/settings.local.json",
20
+ codex: ".codex/hooks.json",
21
+ cursor: ".cursor/hooks.json"
22
+ };
23
+ /** The CLIs (and app) whose presence means the owner uses that tool here. */
24
+ const BINS = {
25
+ claude: ["claude"],
26
+ codex: ["codex"],
27
+ cursor: ["cursor-agent", "cursor"]
28
+ };
29
+ /** The marver the hooks run: the repo's own install (fast, no network). */
30
+ const hookBin = (root) => {
31
+ const bin = join(root, "node_modules", ".bin", "marver");
32
+ return existsSync(bin) ? bin : null;
33
+ };
34
+ const q = (s) => `"${s.replace(/(["\\$`])/g, "\\$1")}"`;
35
+ /** Every event's handlers, as Claude Code and Codex nest them: `hooks[event] = [{ matcher?, hooks: [handler] }]`. */
36
+ function mergeNested(file, want) {
37
+ const hooks = file.hooks && typeof file.hooks === "object" && !Array.isArray(file.hooks) ? { ...file.hooks } : {};
38
+ for (const ev of Object.keys(hooks)) {
39
+ if (!Array.isArray(hooks[ev])) continue;
40
+ hooks[ev] = hooks[ev].map((g) => g && Array.isArray(g.hooks) ? {
41
+ ...g,
42
+ hooks: g.hooks.filter((h) => !(typeof h?.command === "string" && OURS.test(h.command)))
43
+ } : g).filter((g) => !(g && Array.isArray(g.hooks) && g.hooks.length === 0));
44
+ if (!hooks[ev].length) delete hooks[ev];
45
+ }
46
+ for (const [ev, handlers] of Object.entries(want)) hooks[ev] = [...Array.isArray(hooks[ev]) ? hooks[ev] : [], { hooks: handlers }];
47
+ return {
48
+ ...file,
49
+ hooks
50
+ };
51
+ }
52
+ /** Cursor's flat shape: `hooks[event] = [{ command, ... }]`, with `version: 1`. */
53
+ function mergeFlat(file, want) {
54
+ const hooks = file.hooks && typeof file.hooks === "object" && !Array.isArray(file.hooks) ? { ...file.hooks } : {};
55
+ for (const ev of Object.keys(hooks)) {
56
+ if (!Array.isArray(hooks[ev])) continue;
57
+ hooks[ev] = hooks[ev].filter((h) => !(typeof h?.command === "string" && OURS.test(h.command)));
58
+ if (!hooks[ev].length) delete hooks[ev];
59
+ }
60
+ for (const [ev, entries] of Object.entries(want)) hooks[ev] = [...Array.isArray(hooks[ev]) ? hooks[ev] : [], ...entries];
61
+ return {
62
+ version: 1,
63
+ ...file,
64
+ hooks
65
+ };
66
+ }
67
+ /** Is any entry of ours in this file? (Each command looked at as written - in JSON its quotes are escaped.) */
68
+ const hasOurs = (file) => {
69
+ const cmds = [];
70
+ const walk = (v) => {
71
+ if (Array.isArray(v)) v.forEach(walk);
72
+ else if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) if (k === "command" && typeof x === "string") cmds.push(x);
73
+ else walk(x);
74
+ };
75
+ walk(file.hooks);
76
+ return cmds.some((c) => OURS.test(c));
77
+ };
78
+ /** What each tool's file should hold, for this repo's marver. */
79
+ function wanted(agent, bin, root) {
80
+ const r = ` --root ${q(root)}`;
81
+ if (agent === "claude") {
82
+ const listen = {
83
+ type: "command",
84
+ command: `${q(bin)} jam listen${r}`,
85
+ async: true
86
+ };
87
+ return { nested: {
88
+ SessionStart: [listen],
89
+ UserPromptSubmit: [listen],
90
+ SessionEnd: [{
91
+ type: "command",
92
+ command: `${q(bin)} jam hook claude end${r}`,
93
+ timeout: 10
94
+ }]
95
+ } };
96
+ }
97
+ if (agent === "codex") {
98
+ const h = (ev) => ({
99
+ type: "command",
100
+ command: `${q(bin)} jam hook codex ${ev}${r}`,
101
+ timeout: 10
102
+ });
103
+ return { nested: {
104
+ SessionStart: [h("start")],
105
+ UserPromptSubmit: [h("prompt")],
106
+ Stop: [h("stop")],
107
+ SessionEnd: [h("end")]
108
+ } };
109
+ }
110
+ const h = (ev, extra = {}) => ({
111
+ command: `${q(bin)} jam hook cursor ${ev}${r}`,
112
+ timeout: 10,
113
+ ...extra
114
+ });
115
+ return { flat: {
116
+ sessionStart: [h("start")],
117
+ beforeSubmitPrompt: [h("prompt")],
118
+ stop: [h("stop", { loop_limit: 20 })],
119
+ sessionEnd: [h("end")]
120
+ } };
121
+ }
122
+ const git = (root, args) => spawnSync("git", [
123
+ "-C",
124
+ root,
125
+ ...args
126
+ ], {
127
+ encoding: "utf8",
128
+ timeout: 5e3
129
+ });
130
+ const inGit = (root) => git(root, ["rev-parse", "--git-dir"]).status === 0;
131
+ const tracked = (root, rel) => inGit(root) && git(root, [
132
+ "ls-files",
133
+ "--error-unmatch",
134
+ "--",
135
+ rel
136
+ ]).status === 0;
137
+ const ignored = (root, rel) => git(root, [
138
+ "check-ignore",
139
+ "-q",
140
+ "--",
141
+ rel
142
+ ]).status === 0;
143
+ /** Keep `rel` out of commits without touching a committed file: .git/info/exclude is local. */
144
+ function exclude(root, rel) {
145
+ if (!inGit(root) || ignored(root, rel)) return;
146
+ const r = git(root, [
147
+ "rev-parse",
148
+ "--git-path",
149
+ "info/exclude"
150
+ ]);
151
+ if (r.status !== 0) return;
152
+ const p = r.stdout.trim();
153
+ const file = isAbsolute(p) ? p : join(root, p);
154
+ const line = `/${rel.split("\\").join("/")}`;
155
+ let text = "";
156
+ try {
157
+ text = readFileSync(file, "utf8");
158
+ } catch {}
159
+ if (text.split("\n").some((l) => l.trim() === line)) return;
160
+ mkdirSync(dirname(file), { recursive: true });
161
+ writeAtomic(file, `${text}${text && !text.endsWith("\n") ? "\n" : ""}# marver: Live Jam's local hooks\n${line}\n`, 420);
162
+ }
163
+ const recordFile = (root) => join(jamDir(root), "connectors.json");
164
+ const readInstalled = (root) => {
165
+ try {
166
+ return JSON.parse(readFileSync(recordFile(root), "utf8"));
167
+ } catch {
168
+ return {};
169
+ }
170
+ };
171
+ const writeInstalled = (root, r) => {
172
+ mkdirSync(jamDir(root), {
173
+ recursive: true,
174
+ mode: 448
175
+ });
176
+ writeAtomic(recordFile(root), JSON.stringify(r, null, 1));
177
+ };
178
+ /** Is this tool used on this Mac (its CLI on PATH, or - Cursor - its app)? */
179
+ function present(agent, env = process.env) {
180
+ if (BINS[agent].some((b) => onPath(b, env))) return true;
181
+ return agent === "cursor" && existsSync("/Applications/Cursor.app");
182
+ }
183
+ /**
184
+ * Write the connectors this repo is missing. `force` (the start sheet turning a tool back on) writes
185
+ * one the owner had removed. Never throws: each tool's result says what happened.
186
+ */
187
+ function ensureConnectors(root, opts = {}) {
188
+ const env = opts.env ?? process.env;
189
+ const agents = opts.agents ?? [
190
+ "claude",
191
+ "codex",
192
+ "cursor"
193
+ ].filter((a) => present(a, env));
194
+ const bin = opts.bin === void 0 ? hookBin(root) : opts.bin;
195
+ const prefs = readPrefs(root);
196
+ const installed = readInstalled(root);
197
+ const out = [];
198
+ if (opts.force?.some((a) => prefs.off?.[a])) {
199
+ for (const a of opts.force) delete prefs.off?.[a];
200
+ try {
201
+ writePrefs(root, prefs);
202
+ } catch {}
203
+ }
204
+ for (const agent of agents) {
205
+ const rel = FILES[agent];
206
+ const file = join(root, rel);
207
+ const res = (state, note) => out.push({
208
+ agent,
209
+ file: rel,
210
+ state,
211
+ ...note ? { note } : {}
212
+ });
213
+ try {
214
+ if (prefs.off?.[agent] && !opts.force?.includes(agent)) {
215
+ res("off");
216
+ continue;
217
+ }
218
+ if (!bin) {
219
+ res("no-bin", "marver is not installed in this repo (node_modules/.bin/marver)");
220
+ continue;
221
+ }
222
+ let cur = {};
223
+ if (existsSync(file)) {
224
+ if (!statSync(file).isFile()) {
225
+ res("unreadable", `${rel} is not a file`);
226
+ continue;
227
+ }
228
+ try {
229
+ cur = JSON.parse(readFileSync(file, "utf8") || "{}");
230
+ } catch {
231
+ res("unreadable", `${rel} does not parse - left as it is`);
232
+ continue;
233
+ }
234
+ if (!cur || typeof cur !== "object" || Array.isArray(cur)) {
235
+ res("unreadable", `${rel} is not a JSON object - left as it is`);
236
+ continue;
237
+ }
238
+ }
239
+ if (tracked(root, rel)) {
240
+ res("tracked", `${rel} is committed to git - Marver never changes a committed file`);
241
+ continue;
242
+ }
243
+ if (installed[agent] && (!existsSync(file) || !hasOurs(cur)) && !opts.force?.includes(agent)) {
244
+ res("removed");
245
+ continue;
246
+ }
247
+ const w = wanted(agent, bin, root);
248
+ const next = w.nested ? mergeNested(cur, w.nested) : mergeFlat(cur, w.flat);
249
+ if (JSON.stringify(next) === JSON.stringify(cur)) {
250
+ exclude(root, rel);
251
+ res("present");
252
+ continue;
253
+ }
254
+ mkdirSync(dirname(file), { recursive: true });
255
+ writeAtomic(file, JSON.stringify(next, null, 2) + "\n", 420);
256
+ exclude(root, rel);
257
+ installed[agent] = {
258
+ file: rel,
259
+ at: Date.now()
260
+ };
261
+ res("installed");
262
+ } catch (err) {
263
+ res("failed", err.message);
264
+ }
265
+ }
266
+ try {
267
+ writeInstalled(root, installed);
268
+ } catch {}
269
+ return out;
270
+ }
271
+ /** One line for the dev server and init: what the connectors did, or nothing worth saying. */
272
+ function connectorLine(results) {
273
+ const name = {
274
+ claude: "Claude Code",
275
+ codex: "Codex",
276
+ cursor: "Cursor"
277
+ };
278
+ const made = results.filter((r) => r.state === "installed").map((r) => name[r.agent]);
279
+ const skipped = results.filter((r) => [
280
+ "tracked",
281
+ "unreadable",
282
+ "failed"
283
+ ].includes(r.state));
284
+ const parts = [];
285
+ if (made.length) parts.push(`jam: connected ${made.join(", ")} sessions in this repo - their hooks are in ${results.filter((r) => r.state === "installed").map((r) => r.file).join(", ")} (local, never committed)${results.some((r) => r.state === "installed" && r.agent === "codex") ? "; Codex asks you to trust them once (/hooks)" : ""}`);
286
+ for (const s of skipped) parts.push(`jam: ${name[s.agent]} not connected - ${s.note ?? s.state}`);
287
+ return parts.length ? parts.map((p) => ` ${p}`).join("\n") : null;
288
+ }
289
+ //#endregion
290
+ export { connectorLine, ensureConnectors, hookBin, present };
@@ -1,7 +1,7 @@
1
1
  import { r as NAME } from "./cli.mjs";
2
- import { a as checkRealDirs } from "./boards-BHKP5yhI.mjs";
2
+ import { o as checkRealDirs } from "./boards-EH2onUXM.mjs";
3
3
  import { O as readStatusWord, f as isBoardName, l as framesOn } from "./board-tree-BXR8dw4b.mjs";
4
- import { A as levelsIn, C as LEVEL, D as globRe, E as frontMatter, F as tables, I as wordCount, M as looseTables, N as parseMap, O as hasGlob, P as proseLines, S as GENERATED, T as capabilityTable, b as CITED_FILE, j as lf, k as isRecordTable, s as scanFrames, w as availableLevels, x as EVIDENCE_COLUMN, y as CITATION } from "./manifest-aFyDmL8C.mjs";
4
+ import { A as levelsIn, C as LEVEL, D as globRe, E as frontMatter, F as tables, I as wordCount, M as looseTables, N as parseMap, O as hasGlob, P as proseLines, S as GENERATED, T as capabilityTable, b as CITED_FILE, j as lf, k as isRecordTable, s as scanFrames, w as availableLevels, x as EVIDENCE_COLUMN, y as CITATION } from "./manifest-DPZ3WNg_.mjs";
5
5
  import { pkgDir } from "./managed-HwHVNI3h.mjs";
6
6
  import { t as writeManaged } from "./managed-write-Bo-oPc-i.mjs";
7
7
  import { t as imports } from "./imports-WBSnnHLb.mjs";