@marver-design/marver 0.24.0 → 0.25.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 +43 -0
- package/README.md +1 -1
- package/dist/anchor-DVV732zR.mjs +33 -0
- package/dist/anchor-check-BE5VVN6Q.mjs +135 -0
- package/dist/{bake-ZhXq-X9f.mjs → bake-D8byeRzB.mjs} +1 -1
- package/dist/{boards-BRLnoTC3.mjs → board-tree-DRioF94d.mjs} +21 -277
- package/dist/boards-CGg6piKF.mjs +342 -0
- package/dist/{boards-Dv-Ipd8G.mjs → boards-Csxj2WJn.mjs} +23 -9
- package/dist/{build-ckcinlWH.mjs → build-BHoWLvSj.mjs} +63 -37
- package/dist/cli.mjs +31 -17
- package/dist/{collab-mAiNZlDj.mjs → collab-gqNdScUE.mjs} +39 -9
- package/dist/{comments-DZyobpxG.mjs → comments-Zoch254k.mjs} +19 -1
- package/dist/{comments-Dx1hCVOT.mjs → comments-pTLlhjh4.mjs} +150 -20
- package/dist/{config-BUKprFAp.mjs → config-cKgZBRj0.mjs} +1 -1
- package/dist/{context-BncTXjLB.mjs → context-D2ugHqwO.mjs} +17 -123
- package/dist/{daemon-CQv73-jM.mjs → daemon-Cl8KXGW4.mjs} +146 -64
- package/dist/{dev-gv4NS6Fk.mjs → dev-DJdgow47.mjs} +23 -11
- package/dist/{events-B3LBn74P.mjs → events-DnK_AnrW.mjs} +13 -15
- package/dist/imports-WBSnnHLb.mjs +143 -0
- package/dist/{init--3Moc4J7.mjs → init-DO4DhUt_.mjs} +28 -6
- package/dist/link-C-qUIuKU.mjs +160 -0
- package/dist/{board-status-BZSzc9Hp.mjs → manifest-DnAte_fB.mjs} +537 -13
- package/dist/marks-DFuintmJ.mjs +50 -0
- package/dist/marks-koRsbHfe.mjs +397 -0
- package/dist/{marver-id-gate-B_idGdHm.mjs → marver-id-gate-DGANtVyC.mjs} +2 -2
- package/dist/perf-CCisg-ny.mjs +49 -0
- package/dist/perf-QJIWtTw1.mjs +68 -0
- package/dist/{plugin-Sa08E7wO.mjs → plugin-CTyhjwoJ.mjs} +424 -207
- package/dist/{poster-B2QPvKOq.mjs → poster-D0cbV7hi.mjs} +1 -1
- package/dist/{profile-CrZohD6g.mjs → profile-Do0nGkXO.mjs} +1 -1
- package/dist/{publish-bakes-BJR3huhu.mjs → publish-bakes--l8ot2eQ.mjs} +9 -9
- package/dist/{serve-z5qtj_wJ.mjs → serve-wv2QWdxB.mjs} +6 -6
- package/dist/{share-BD-wcDQq.mjs → share-ScamJcks.mjs} +1 -1
- package/dist/{shot-Cw96h5Kk.mjs → shot-CckrGW-J.mjs} +19 -11
- package/dist/{shot-Dh6fV1Lm.mjs → shot-jdO_B6Qw.mjs} +1 -1
- package/dist/{summary-C7CAypbB.mjs → summary-CrW88e3q.mjs} +1 -1
- package/dist/{sync-DoA1vf4u.mjs → sync-C3035OnJ.mjs} +18 -8
- package/dist/{work-CBUfsOOT.mjs → work-CpJn1gwY.mjs} +8 -4
- package/dist/{work-ayuL_9Kk.mjs → work-GE88wb_3.mjs} +4 -4
- package/docs/boards-and-folders.md +62 -21
- package/docs/live-jam.md +10 -5
- package/package.json +1 -1
- package/src/client/frame-host/bridge.js +2 -1
- package/src/client/frame-host/inspect.js +195 -84
- package/src/client/frame-host/main.tsx +7 -2
- package/src/client/frame-host/registry.ts +5 -5
- package/src/client/shell/App.tsx +66 -22
- package/src/client/shell/BoardList.tsx +54 -11
- package/src/client/shell/Comments.tsx +79 -34
- package/src/client/shell/ContextMenu.tsx +5 -2
- package/src/client/shell/LockedApp.tsx +45 -12
- package/src/client/shell/Play.tsx +35 -34
- package/src/client/shell/Toolbar.tsx +3 -1
- package/src/client/shell/canvas/Canvas.tsx +1 -1
- package/src/client/shell/canvas/FrameNode.tsx +10 -5
- package/src/client/shell/canvas/sleep.ts +4 -3
- package/src/client/shell/canvas/updates.ts +55 -0
- package/src/client/shell/comments-store.ts +48 -19
- package/src/client/shell/goto.ts +11 -14
- package/src/client/shell/hash.ts +12 -5
- package/src/client/shell/icons.tsx +1 -2
- package/src/client/shell/legacy-links.ts +67 -0
- package/src/client/shell/marks-ui.tsx +17 -19
- package/src/client/shell/pin-layout.ts +37 -0
- package/src/client/shell/store.ts +312 -92
- package/src/client/shell/styles.css +10 -8
- package/src/client/stage/main.tsx +19 -2
- package/src/shared/anchor.ts +57 -0
- package/src/shared/board-tree.ts +27 -10
- package/src/shared/events.ts +19 -10
- package/src/shared/marks.ts +17 -12
- package/templates/AGENTS-embedded.md +34 -15
- package/templates/AGENTS-studio.md +34 -15
- package/templates/instructions/boards.md +9 -5
- package/templates/instructions/iterate.md +20 -10
- package/templates/instructions/jam.md +13 -4
- package/templates/instructions/publish.md +2 -1
- package/templates/instructions/reference/deck-story.md +2 -2
- package/dist/link-vXjxMHTG.mjs +0 -132
- package/dist/manifest-cyG3kbhk.mjs +0 -528
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { r as NAME } from "./cli.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { a as checkRealDirs } from "./boards-CGg6piKF.mjs";
|
|
3
|
+
import { D as readStatusWord, f as isBoardName, l as framesOn } from "./board-tree-DRioF94d.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-DnAte_fB.mjs";
|
|
4
5
|
import { pkgDir } from "./managed-HwHVNI3h.mjs";
|
|
5
6
|
import { t as writeManaged } from "./managed-write-Bo-oPc-i.mjs";
|
|
6
|
-
import {
|
|
7
|
+
import { t as imports } from "./imports-WBSnnHLb.mjs";
|
|
7
8
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
8
9
|
import { basename, dirname, join, normalize, relative, sep } from "node:path";
|
|
9
10
|
import { execFileSync } from "node:child_process";
|
|
@@ -11,12 +12,10 @@ import { execFileSync } from "node:child_process";
|
|
|
11
12
|
/**
|
|
12
13
|
* What a canvas build carries, as repository paths - the same selection the build makes, so a
|
|
13
14
|
* check against it judges what actually ships: the published boards' frames (every frame when
|
|
14
|
-
* `
|
|
15
|
+
* an `auto` board ships), each frame's `_layout` chain, `design/providers`, and everything they import -
|
|
15
16
|
* relative paths, `design/tsconfig.json` aliases, `?raw` and asset strings. An import that looks
|
|
16
17
|
* local and does not resolve is reported, never silently skipped.
|
|
17
18
|
*/
|
|
18
|
-
const IMPORT = /(?:import|export)\s[^'"]*?from\s*['"]([^'"]+)['"]|import\(\s*['"]([^'"]+)['"]\s*\)|require\(\s*['"]([^'"]+)['"]\s*\)|['"]((?:\.{1,2}\/|\/)[^'"\s]+\.[a-z0-9]{1,5})(?:\?[a-z]+)?['"]/g;
|
|
19
|
-
const CODE = /\.(tsx?|jsx?|mjs|cjs|mdx?)$/;
|
|
20
19
|
/** The published board names, straight from design/publish.json (an unreadable policy ships nothing). */
|
|
21
20
|
function publishedBoards(root) {
|
|
22
21
|
try {
|
|
@@ -25,72 +24,6 @@ function publishedBoards(root) {
|
|
|
25
24
|
return [];
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
/** JSON with comments and trailing commas, as tsconfig allows - comments stripped outside strings only
|
|
29
|
-
* (a "$schema": "https://..." is a string, not a comment). */
|
|
30
|
-
function parseJsonc(text) {
|
|
31
|
-
let out = "", i = 0, str = false;
|
|
32
|
-
const t = text.replace(/^\uFEFF/, "");
|
|
33
|
-
while (i < t.length) {
|
|
34
|
-
const c = t[i];
|
|
35
|
-
if (str) {
|
|
36
|
-
out += c;
|
|
37
|
-
if (c === "\\") {
|
|
38
|
-
out += t[i + 1] ?? "";
|
|
39
|
-
i += 2;
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (c === "\"") str = false;
|
|
43
|
-
i++;
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (c === "\"") {
|
|
47
|
-
str = true;
|
|
48
|
-
out += c;
|
|
49
|
-
i++;
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (c === "/" && t[i + 1] === "/") {
|
|
53
|
-
while (i < t.length && t[i] !== "\n") i++;
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if (c === "/" && t[i + 1] === "*") {
|
|
57
|
-
i += 2;
|
|
58
|
-
while (i < t.length && !(t[i] === "*" && t[i + 1] === "/")) i++;
|
|
59
|
-
i += 2;
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
out += c;
|
|
63
|
-
i++;
|
|
64
|
-
}
|
|
65
|
-
return JSON.parse(out.replace(/,(\s*[}\]])/g, "$1"));
|
|
66
|
-
}
|
|
67
|
-
/** design/tsconfig.json's path aliases, resolved against the config that declares them - its own,
|
|
68
|
-
* or one it `extends` (the host's tsconfig), as TypeScript and Vite would. */
|
|
69
|
-
function aliases(root) {
|
|
70
|
-
const read = (rel, depth) => {
|
|
71
|
-
if (depth > 4) return [];
|
|
72
|
-
let cfg;
|
|
73
|
-
try {
|
|
74
|
-
cfg = parseJsonc(readFileSync(join(root, rel), "utf8"));
|
|
75
|
-
} catch {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
const dir = dirname(rel);
|
|
79
|
-
const base = typeof cfg.compilerOptions?.baseUrl === "string" ? normalize(join(dir, cfg.compilerOptions.baseUrl)) : dir;
|
|
80
|
-
const own = Object.entries(cfg.compilerOptions?.paths ?? {}).flatMap(([k, v]) => Array.isArray(v) ? [{
|
|
81
|
-
prefix: k.replace(/\*$/, ""),
|
|
82
|
-
targets: v.map((t) => normalize(join(base, t.replace(/\*$/, ""))))
|
|
83
|
-
}] : []);
|
|
84
|
-
const ext = (Array.isArray(cfg.extends) ? cfg.extends : [cfg.extends]).filter((e) => typeof e === "string" && e.startsWith("."));
|
|
85
|
-
let inherited = [];
|
|
86
|
-
for (const e of ext) {
|
|
87
|
-
const got = read(normalize(join(dir, e.endsWith(".json") ? e : `${e}.json`)), depth + 1);
|
|
88
|
-
inherited = [...got, ...inherited.filter((p) => !got.some((g) => g.prefix === p.prefix))];
|
|
89
|
-
}
|
|
90
|
-
return [...own, ...inherited.filter((p) => !own.some((o) => o.prefix === p.prefix))];
|
|
91
|
-
};
|
|
92
|
-
return read("design/tsconfig.json", 0);
|
|
93
|
-
}
|
|
94
27
|
function publishGraph(root) {
|
|
95
28
|
const files = /* @__PURE__ */ new Set();
|
|
96
29
|
const unresolved = [];
|
|
@@ -108,18 +41,15 @@ function publishGraph(root) {
|
|
|
108
41
|
}
|
|
109
42
|
};
|
|
110
43
|
const manifest = scanFrames(root);
|
|
111
|
-
|
|
44
|
+
const live = manifest.frames.map((f) => f.id);
|
|
45
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
112
46
|
for (const b of boards) {
|
|
113
|
-
if (b === "all-scenes")
|
|
114
|
-
wanted = null;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
47
|
+
if (!isBoardName(b) || b === "all-scenes") continue;
|
|
117
48
|
try {
|
|
118
|
-
const
|
|
119
|
-
for (const n of Array.isArray(j?.nodes) ? j.nodes : []) if (typeof n?.frame === "string") wanted.add(n.frame);
|
|
49
|
+
for (const f of framesOn(JSON.parse(readFileSync(join(root, "design", "boards", `${b}.json`), "utf8")), live)) wanted.add(f);
|
|
120
50
|
} catch {}
|
|
121
51
|
}
|
|
122
|
-
const entries = manifest.frames.filter((f) =>
|
|
52
|
+
const entries = manifest.frames.filter((f) => wanted.has(f.id));
|
|
123
53
|
const frames = entries.map((f) => rel(join(root, f.file)));
|
|
124
54
|
const queue = [...frames];
|
|
125
55
|
for (const [i, f] of frames.entries()) {
|
|
@@ -138,53 +68,17 @@ function publishGraph(root) {
|
|
|
138
68
|
}
|
|
139
69
|
}
|
|
140
70
|
for (const ext of ["tsx", "jsx"]) if (isFile(`design/providers.${ext}`)) queue.push(`design/providers.${ext}`);
|
|
141
|
-
const
|
|
142
|
-
const resolve = (from, spec) => {
|
|
143
|
-
const bare = spec.replace(/\?[a-z]+$/, "");
|
|
144
|
-
let bases = [];
|
|
145
|
-
if (bare.startsWith(".")) bases = [normalize(join(dirname(from), bare))];
|
|
146
|
-
else if (bare.startsWith("/")) bases = [normalize(bare.slice(1))];
|
|
147
|
-
else {
|
|
148
|
-
const a = al.find((x) => bare.startsWith(x.prefix) && x.prefix);
|
|
149
|
-
if (!a) return "";
|
|
150
|
-
bases = a.targets.map((t) => normalize(join(t, bare.slice(a.prefix.length))));
|
|
151
|
-
}
|
|
152
|
-
for (const b of bases) for (const cand of [
|
|
153
|
-
b,
|
|
154
|
-
`${b}.ts`,
|
|
155
|
-
`${b}.tsx`,
|
|
156
|
-
`${b}.js`,
|
|
157
|
-
`${b}.jsx`,
|
|
158
|
-
`${b}/index.ts`,
|
|
159
|
-
`${b}/index.tsx`
|
|
160
|
-
]) if (!cand.startsWith("..") && isFile(cand)) return cand.split(sep).join("/");
|
|
161
|
-
return null;
|
|
162
|
-
};
|
|
71
|
+
const im = imports(root);
|
|
163
72
|
while (queue.length) {
|
|
164
73
|
const p = queue.pop();
|
|
165
74
|
if (files.has(p)) continue;
|
|
166
75
|
files.add(p);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
for (const m of text.matchAll(IMPORT)) {
|
|
175
|
-
const spec = m[1] || m[2] || m[3] || m[4] || "";
|
|
176
|
-
if (!spec) continue;
|
|
177
|
-
const r = resolve(p, spec);
|
|
178
|
-
if (r === "") continue;
|
|
179
|
-
if (r === null) {
|
|
180
|
-
if (spec.startsWith(".") || spec.startsWith("/") || al.some((x) => x.prefix && spec.startsWith(x.prefix))) unresolved.push({
|
|
181
|
-
from: p,
|
|
182
|
-
spec
|
|
183
|
-
});
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
queue.push(r);
|
|
187
|
-
}
|
|
76
|
+
const { resolved, unresolved: miss } = im.of(p);
|
|
77
|
+
queue.push(...resolved);
|
|
78
|
+
for (const spec of miss) unresolved.push({
|
|
79
|
+
from: p,
|
|
80
|
+
spec
|
|
81
|
+
});
|
|
188
82
|
}
|
|
189
83
|
return {
|
|
190
84
|
files,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { l as toFrameId } from "./manifest-DnAte_fB.mjs";
|
|
2
|
+
import { a as workActivity } from "./work-GE88wb_3.mjs";
|
|
3
|
+
import { r as replay } from "./events-DnK_AnrW.mjs";
|
|
4
|
+
import { a as readLog, i as listBoards, t as appendEvents } from "./comments-Zoch254k.mjs";
|
|
5
|
+
import { n as localProfile } from "./profile-Do0nGkXO.mjs";
|
|
6
|
+
import { readTarget, uncheckedAnchor } from "./anchor-DVV732zR.mjs";
|
|
6
7
|
import { has, t as deviceId } from "./ledger-BNXW14Xw.mjs";
|
|
7
8
|
import { closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, watch, writeFileSync, writeSync } from "node:fs";
|
|
8
9
|
import { join } from "node:path";
|
|
@@ -98,9 +99,12 @@ function goalText(packet, subagents = true) {
|
|
|
98
99
|
"",
|
|
99
100
|
"PREFER edits that keep the element's tag / data-testid / visible text, so the comment pin self-heals.",
|
|
100
101
|
"If you RENAMED or MOVED the commented element so its old anchor no longer matches, re-pin the thread",
|
|
101
|
-
"with a fenced block (after your marver-reply block)
|
|
102
|
+
"with a fenced block (after your marver-reply block) naming the element per thread: \"on\" = words it",
|
|
103
|
+
"shows, or \"at\" = its data-testid or a CSS selector (an element without words); \"nth\" picks one of",
|
|
104
|
+
"several matches (1 = the first); \"viewport\" / \"theme\" when only another viewport or theme shows it.",
|
|
105
|
+
"The system finds it in the rendered frame and pins it, e.g.",
|
|
102
106
|
"```marver-reanchor",
|
|
103
|
-
"[{\"thread\":\"<threadId from the packet>\",\"
|
|
107
|
+
"[{\"thread\":\"<threadId from the packet>\",\"on\":\"Get started\"}]",
|
|
104
108
|
"```",
|
|
105
109
|
"Omit the block entirely if the element's identity is unchanged.",
|
|
106
110
|
"",
|
|
@@ -115,7 +119,7 @@ function goalText(packet, subagents = true) {
|
|
|
115
119
|
" thread on the board - recent pins and asks on this frame often explain a terse one). If that",
|
|
116
120
|
" unlocks it, post your ack and proceed.",
|
|
117
121
|
"- STILL unclear after looking around: your first line is ONE clarifying question, then STOP",
|
|
118
|
-
" without editing (end the run; put that same question in
|
|
122
|
+
" without editing (end the run; put that same question in a marver-reply ask block).",
|
|
119
123
|
"",
|
|
120
124
|
"YOUR COMPLETION REPLY: end your run with this block - the system posts ONLY what is inside it,",
|
|
121
125
|
"and DISCARDS everything else in your final message (any narration or explanation never reaches",
|
|
@@ -123,6 +127,9 @@ function goalText(packet, subagents = true) {
|
|
|
123
127
|
"```marver-reply",
|
|
124
128
|
"<your reply>",
|
|
125
129
|
"```",
|
|
130
|
+
"When the reply ASKS the owner something they must answer (a question, a decision), open the block",
|
|
131
|
+
"with ```marver-reply ask instead - it comes first for them. A done reply stays plain, even with an",
|
|
132
|
+
"optional follow-up.",
|
|
126
133
|
"(a marver-reanchor block, if needed, goes after it)",
|
|
127
134
|
"REPLY RULES (both the first line and the marver-reply block):",
|
|
128
135
|
"- PLAIN TEXT ONLY. The thread renders raw text, so markdown shows as literal characters. No **bold**,",
|
|
@@ -142,25 +149,46 @@ function goalText(packet, subagents = true) {
|
|
|
142
149
|
JSON.stringify(packet)
|
|
143
150
|
].join("\n");
|
|
144
151
|
}
|
|
145
|
-
/**
|
|
146
|
-
*
|
|
147
|
-
* leak an essay into the thread
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
/** The one parser of an agent's message, for every adapter and for early delivery alike. Posts ONLY
|
|
153
|
+
* what the agent put in its ```marver-reply``` block - narration around it is discarded, so a
|
|
154
|
+
* chatty model can never leak an essay into the thread; no block = the whole text (backward
|
|
155
|
+
* compatible). The block's header says whether the reply asks (```marver-reply ask); a message with
|
|
156
|
+
* no block falls back to the old rule, a trailing "?". */
|
|
157
|
+
function parseAgentText(text) {
|
|
158
|
+
const { reply: visible, reanchors } = extractReanchors(text);
|
|
159
|
+
const m = /```marver-reply(?:[ \t]+(ask)\b)?[ \t]*([\s\S]*?)```/.exec(visible);
|
|
160
|
+
const reply = (m ? m[2] : visible).trim();
|
|
161
|
+
return {
|
|
162
|
+
reply,
|
|
163
|
+
asks: m ? !!m[1] : /\?\s*$/.test(reply),
|
|
164
|
+
reanchors
|
|
165
|
+
};
|
|
151
166
|
}
|
|
152
167
|
/** Pull a trailing ```marver-reanchor``` block out of an agent reply: returns the visible reply
|
|
153
|
-
* (block removed) and the
|
|
168
|
+
* (block removed) and the re-pins it names - each a thread and its element, read like the CLI's
|
|
169
|
+
* --on / --at / --nth (an entry naming neither is dropped). Adapter-agnostic: one protocol. */
|
|
154
170
|
function extractReanchors(text) {
|
|
155
171
|
const m = /```marver-reanchor\s*([\s\S]*?)```/.exec(text);
|
|
156
172
|
if (!m) return {
|
|
157
173
|
reply: text.trim(),
|
|
158
174
|
reanchors: []
|
|
159
175
|
};
|
|
160
|
-
|
|
176
|
+
const reanchors = [];
|
|
161
177
|
try {
|
|
162
178
|
const parsed = JSON.parse(m[1].trim());
|
|
163
|
-
|
|
179
|
+
for (const r of Array.isArray(parsed) ? parsed : []) {
|
|
180
|
+
const target = r && typeof r.thread === "string" ? readTarget(r) : "no thread";
|
|
181
|
+
const name = (v) => typeof v === "string" && v.trim() ? v.trim().slice(0, 64) : void 0;
|
|
182
|
+
const look = {
|
|
183
|
+
viewport: name(r.viewport),
|
|
184
|
+
theme: name(r.theme)
|
|
185
|
+
};
|
|
186
|
+
if (typeof target !== "string") reanchors.push({
|
|
187
|
+
thread: r.thread,
|
|
188
|
+
target,
|
|
189
|
+
...look.viewport || look.theme ? { look } : {}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
164
192
|
} catch {}
|
|
165
193
|
return {
|
|
166
194
|
reply: text.replace(m[0], "").trim(),
|
|
@@ -237,11 +265,11 @@ const claudeAdapter = {
|
|
|
237
265
|
} catch {
|
|
238
266
|
if (!sawEvents) text = stdout.trim();
|
|
239
267
|
}
|
|
240
|
-
const { reply
|
|
241
|
-
const reply = extractReplyBlock(visible);
|
|
268
|
+
const { reply, asks, reanchors } = parseAgentText(text);
|
|
242
269
|
return {
|
|
243
270
|
reply,
|
|
244
271
|
model,
|
|
272
|
+
asks,
|
|
245
273
|
reanchors,
|
|
246
274
|
ok: code === 0 && !failed && !!reply
|
|
247
275
|
};
|
|
@@ -295,11 +323,11 @@ const codexAdapter = {
|
|
|
295
323
|
if (typeof o.model === "string") model = o.model;
|
|
296
324
|
} catch {}
|
|
297
325
|
}
|
|
298
|
-
const { reply
|
|
299
|
-
const reply = extractReplyBlock(visible);
|
|
326
|
+
const { reply, asks, reanchors } = parseAgentText(text);
|
|
300
327
|
return {
|
|
301
328
|
reply,
|
|
302
329
|
model,
|
|
330
|
+
asks,
|
|
303
331
|
reanchors,
|
|
304
332
|
ok: code === 0 && !failed && !!reply
|
|
305
333
|
};
|
|
@@ -375,11 +403,11 @@ const cursorAdapter = {
|
|
|
375
403
|
} catch {}
|
|
376
404
|
}
|
|
377
405
|
if (!text) text = lastAssistant;
|
|
378
|
-
const { reply
|
|
379
|
-
const reply = extractReplyBlock(visible);
|
|
406
|
+
const { reply, asks, reanchors } = parseAgentText(text);
|
|
380
407
|
return {
|
|
381
408
|
reply,
|
|
382
409
|
model,
|
|
410
|
+
asks,
|
|
383
411
|
reanchors,
|
|
384
412
|
ok: code === 0 && !failed && !!reply
|
|
385
413
|
};
|
|
@@ -451,11 +479,11 @@ const droidAdapter = {
|
|
|
451
479
|
if (typeof j.result === "string") text = j.result.trim();
|
|
452
480
|
if (j.is_error) failed = true;
|
|
453
481
|
} catch {}
|
|
454
|
-
const { reply
|
|
455
|
-
const reply = extractReplyBlock(visible);
|
|
482
|
+
const { reply, asks, reanchors } = parseAgentText(text);
|
|
456
483
|
return {
|
|
457
484
|
reply,
|
|
458
485
|
model,
|
|
486
|
+
asks,
|
|
459
487
|
reanchors,
|
|
460
488
|
ok: code === 0 && !failed && !!reply
|
|
461
489
|
};
|
|
@@ -541,11 +569,11 @@ const grokAdapter = {
|
|
|
541
569
|
} catch {}
|
|
542
570
|
}
|
|
543
571
|
if (!text) text = lastAssistant;
|
|
544
|
-
const { reply
|
|
545
|
-
const reply = extractReplyBlock(visible);
|
|
572
|
+
const { reply, asks, reanchors } = parseAgentText(text);
|
|
546
573
|
return {
|
|
547
574
|
reply,
|
|
548
575
|
model,
|
|
576
|
+
asks,
|
|
549
577
|
reanchors,
|
|
550
578
|
ok: code === 0 && !failed && !!reply
|
|
551
579
|
};
|
|
@@ -614,10 +642,10 @@ const opencodeAdapter = {
|
|
|
614
642
|
} else if (o.type === "error") failed = true;
|
|
615
643
|
} catch {}
|
|
616
644
|
}
|
|
617
|
-
const { reply
|
|
618
|
-
const reply = extractReplyBlock(visible);
|
|
645
|
+
const { reply, asks, reanchors } = parseAgentText(parts.join("\n\n"));
|
|
619
646
|
return {
|
|
620
647
|
reply,
|
|
648
|
+
asks,
|
|
621
649
|
reanchors,
|
|
622
650
|
ok: code === 0 && !failed && !!reply
|
|
623
651
|
};
|
|
@@ -713,11 +741,11 @@ const adapters = {
|
|
|
713
741
|
} catch {}
|
|
714
742
|
}
|
|
715
743
|
if (last?.error) failed = true;
|
|
716
|
-
const { reply
|
|
717
|
-
const reply = extractReplyBlock(visible);
|
|
744
|
+
const { reply, asks, reanchors } = parseAgentText(last?.text ?? "");
|
|
718
745
|
return {
|
|
719
746
|
reply,
|
|
720
747
|
model: last?.model,
|
|
748
|
+
asks,
|
|
721
749
|
reanchors,
|
|
722
750
|
ok: code === 0 && !failed && !!reply
|
|
723
751
|
};
|
|
@@ -1040,6 +1068,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
1040
1068
|
} catch {
|
|
1041
1069
|
return resolve({
|
|
1042
1070
|
reply: "",
|
|
1071
|
+
asks: false,
|
|
1043
1072
|
ok: false,
|
|
1044
1073
|
reanchors: []
|
|
1045
1074
|
});
|
|
@@ -1064,6 +1093,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
1064
1093
|
fenceGroup(child.pid);
|
|
1065
1094
|
settle({
|
|
1066
1095
|
reply: "",
|
|
1096
|
+
asks: false,
|
|
1067
1097
|
ok: false,
|
|
1068
1098
|
reanchors: []
|
|
1069
1099
|
});
|
|
@@ -1079,13 +1109,13 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
1079
1109
|
for (const line of lines) {
|
|
1080
1110
|
const hit = adapter.earlyText(line);
|
|
1081
1111
|
if (!hit) continue;
|
|
1082
|
-
const
|
|
1083
|
-
const
|
|
1084
|
-
const text =
|
|
1112
|
+
const parsed = parseAgentText(hit.text);
|
|
1113
|
+
const fenced = /```marver-reply/.test(hit.text);
|
|
1114
|
+
const text = fenced ? parsed.reply : parsed.reply.split(/\n\s*\n/)[0].trim();
|
|
1085
1115
|
if (!text || metaNarration(text)) continue;
|
|
1086
1116
|
earlyFired = true;
|
|
1087
1117
|
try {
|
|
1088
|
-
onEarly(text, hit.model);
|
|
1118
|
+
onEarly(text, fenced && parsed.asks, hit.model);
|
|
1089
1119
|
} catch {}
|
|
1090
1120
|
break;
|
|
1091
1121
|
}
|
|
@@ -1096,6 +1126,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
1096
1126
|
}));
|
|
1097
1127
|
child.on("error", () => settle({
|
|
1098
1128
|
reply: "",
|
|
1129
|
+
asks: false,
|
|
1099
1130
|
ok: false,
|
|
1100
1131
|
reanchors: []
|
|
1101
1132
|
}));
|
|
@@ -1117,7 +1148,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
1117
1148
|
};
|
|
1118
1149
|
/** House style: never an em/en dash in a reply - a plain dash reads human. */
|
|
1119
1150
|
const plainDashes = (s) => s.replace(/\s*[—–]\s*/g, " - ");
|
|
1120
|
-
const writeReply = (b, p, body, model, kind = "reply") => {
|
|
1151
|
+
const writeReply = (b, p, body, asks, model, kind = "reply") => {
|
|
1121
1152
|
const me = localProfile(root);
|
|
1122
1153
|
const suffix = kind === "early" ? `e${b.attempts}-${b.batchId}` : b.batchId;
|
|
1123
1154
|
const reply = {
|
|
@@ -1129,6 +1160,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
1129
1160
|
board: b.board,
|
|
1130
1161
|
author: me,
|
|
1131
1162
|
body: plainDashes(body),
|
|
1163
|
+
asks,
|
|
1132
1164
|
agent: true,
|
|
1133
1165
|
agentMeta: {
|
|
1134
1166
|
devUser: me.name,
|
|
@@ -1137,27 +1169,56 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
1137
1169
|
}
|
|
1138
1170
|
};
|
|
1139
1171
|
appendEvents(commentsDir, b.board, [reply]);
|
|
1172
|
+
return reply.commentId;
|
|
1140
1173
|
};
|
|
1141
|
-
/** Emit reanchor events for threads the agent re-pinned
|
|
1142
|
-
*
|
|
1143
|
-
|
|
1144
|
-
|
|
1174
|
+
/** Emit reanchor events for threads the agent re-pinned, in the shared anchor format: each
|
|
1175
|
+
* element found in the rendered frame the way `comments move` finds it, unchecked when the
|
|
1176
|
+
* check cannot run, skipped when the frame shows no such element or several. Owner-authored +
|
|
1177
|
+
* agent:true (attributable, never re-triggers), deterministic ids so a re-run dedups. Returns
|
|
1178
|
+
* how many it wrote. */
|
|
1179
|
+
const emitReanchors = async (b, reanchors) => {
|
|
1180
|
+
if (!reanchors.length) return 0;
|
|
1145
1181
|
const me = localProfile(root);
|
|
1146
|
-
const
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
author: me,
|
|
1154
|
-
agent: true,
|
|
1155
|
-
agentMeta: {
|
|
1156
|
-
devUser: me.name,
|
|
1157
|
-
harness: adapter.name
|
|
1182
|
+
const threads = replay(readLog(commentsDir, b.board));
|
|
1183
|
+
const events = [];
|
|
1184
|
+
for (const [i, r] of reanchors.entries()) {
|
|
1185
|
+
const t = threads.find((t) => t.id === r.thread);
|
|
1186
|
+
if (!t?.frame) {
|
|
1187
|
+
log(` jam: re-pin skipped - no thread ${r.thread} on ${b.board}`);
|
|
1188
|
+
continue;
|
|
1158
1189
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1190
|
+
const others = threads.filter((o) => !o.resolved && o.frame === t.frame && o.id !== t.id).map((o) => ({
|
|
1191
|
+
key: o.id,
|
|
1192
|
+
anchor: o.anchor
|
|
1193
|
+
}));
|
|
1194
|
+
const check = hooks.anchor ? await hooks.anchor(t.frame, r.target, others, r.look).catch((err) => ({
|
|
1195
|
+
ok: false,
|
|
1196
|
+
unchecked: err.message
|
|
1197
|
+
})) : {
|
|
1198
|
+
ok: false,
|
|
1199
|
+
unchecked: "no anchor check here"
|
|
1200
|
+
};
|
|
1201
|
+
if (!check.ok && "refused" in check) {
|
|
1202
|
+
log(` jam: re-pin skipped - ${t.frame} shows ${check.refused === "none" ? "no" : "several"} matching elements`);
|
|
1203
|
+
continue;
|
|
1204
|
+
}
|
|
1205
|
+
events.push({
|
|
1206
|
+
id: `jam-ra-${b.batchId}-${i}`,
|
|
1207
|
+
ts: Date.now(),
|
|
1208
|
+
type: "reanchor",
|
|
1209
|
+
commentId: t.id,
|
|
1210
|
+
anchor: check.ok ? check.anchor : uncheckedAnchor(r.target),
|
|
1211
|
+
board: b.board,
|
|
1212
|
+
author: me,
|
|
1213
|
+
agent: true,
|
|
1214
|
+
agentMeta: {
|
|
1215
|
+
devUser: me.name,
|
|
1216
|
+
harness: adapter.name
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
if (events.length) appendEvents(commentsDir, b.board, events);
|
|
1221
|
+
return events.length;
|
|
1161
1222
|
};
|
|
1162
1223
|
const finish = (b) => {
|
|
1163
1224
|
journal.batches = journal.batches.filter((x) => x.batchId !== b.batchId);
|
|
@@ -1207,15 +1268,18 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
1207
1268
|
};
|
|
1208
1269
|
const beat = setInterval(followWork, 2e3);
|
|
1209
1270
|
beat.unref?.();
|
|
1210
|
-
let
|
|
1271
|
+
let early;
|
|
1211
1272
|
let run;
|
|
1212
1273
|
try {
|
|
1213
1274
|
run = await runAgent(goalText(packet, cfg.subagents && adapter.supportsSubagents), (pid) => {
|
|
1214
1275
|
b.pgid = pid;
|
|
1215
1276
|
persist();
|
|
1216
|
-
}, (text, model) => {
|
|
1217
|
-
|
|
1218
|
-
|
|
1277
|
+
}, (text, asks, model) => {
|
|
1278
|
+
early = {
|
|
1279
|
+
body: text,
|
|
1280
|
+
asks,
|
|
1281
|
+
commentId: writeReply(b, p, text, asks, model, "early")
|
|
1282
|
+
};
|
|
1219
1283
|
hooks.changed?.(b.board);
|
|
1220
1284
|
});
|
|
1221
1285
|
} finally {
|
|
@@ -1227,14 +1291,31 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
1227
1291
|
return;
|
|
1228
1292
|
}
|
|
1229
1293
|
if (run.ok) {
|
|
1230
|
-
if (run.reply !==
|
|
1231
|
-
|
|
1294
|
+
if (run.reply !== early?.body) writeReply(b, p, run.reply, run.asks, run.model);
|
|
1295
|
+
else if (run.asks && !early.asks) {
|
|
1296
|
+
const me = localProfile(root);
|
|
1297
|
+
appendEvents(commentsDir, b.board, [{
|
|
1298
|
+
id: `jam-f-e${b.attempts}-${b.batchId}`,
|
|
1299
|
+
ts: Date.now(),
|
|
1300
|
+
type: "edit",
|
|
1301
|
+
commentId: early.commentId,
|
|
1302
|
+
asks: run.asks,
|
|
1303
|
+
board: b.board,
|
|
1304
|
+
author: me,
|
|
1305
|
+
agent: true,
|
|
1306
|
+
agentMeta: {
|
|
1307
|
+
devUser: me.name,
|
|
1308
|
+
harness: adapter.name
|
|
1309
|
+
}
|
|
1310
|
+
}]);
|
|
1311
|
+
}
|
|
1312
|
+
const repinned = await emitReanchors(b, run.reanchors);
|
|
1232
1313
|
hooks.changed?.(b.board);
|
|
1233
1314
|
clearGlow();
|
|
1234
1315
|
finish(b);
|
|
1235
|
-
log(` jam: replied on ${b.board}${run.model ? ` (${run.model})` : ""}${
|
|
1316
|
+
log(` jam: replied on ${b.board}${run.model ? ` (${run.model})` : ""}${repinned ? ` · re-pinned ${repinned}` : ""}`);
|
|
1236
1317
|
} else if (b.attempts >= MAX_ATTEMPTS) {
|
|
1237
|
-
writeReply(b, p, "I couldn't finish that one. The raw run log is in design/.local/jam-logs - the troubleshooting drill in design/instructions/jam.md reads it. Or just rephrase and try again.", run.model);
|
|
1318
|
+
writeReply(b, p, "I couldn't finish that one. The raw run log is in design/.local/jam-logs - the troubleshooting drill in design/instructions/jam.md reads it. Or just rephrase and try again.", false, run.model);
|
|
1238
1319
|
hooks.changed?.(b.board);
|
|
1239
1320
|
clearGlow();
|
|
1240
1321
|
finish(b);
|
|
@@ -1394,7 +1475,7 @@ function createJam(root, cfg, adapter, log = () => {}, hooks = {}) {
|
|
|
1394
1475
|
* activity set (work.ts) - the `marver work` CLI writes the same set, so the canvas shows
|
|
1395
1476
|
* one merged glow. Returns null when the adapter is unavailable or another dev server
|
|
1396
1477
|
* already holds the repo lock (that one runs the loop; this one watches without it). */
|
|
1397
|
-
function startJam(root, cfg, log = () => {}, onChanged = () => {}) {
|
|
1478
|
+
function startJam(root, cfg, log = () => {}, onChanged = () => {}, anchor) {
|
|
1398
1479
|
const adapter = adapters[cfg.agent] ?? null;
|
|
1399
1480
|
if (!adapter) {
|
|
1400
1481
|
log(` jam: the "${cfg.agent}" adapter is not available yet; Live Jam is off`);
|
|
@@ -1410,7 +1491,8 @@ function startJam(root, cfg, log = () => {}, onChanged = () => {}) {
|
|
|
1410
1491
|
const core = createJam(root, cfg, adapter, log, {
|
|
1411
1492
|
work: (f, on) => on ? activity.mark(f ?? "", void 0, "jam") : activity.clear(f ?? "", "jam"),
|
|
1412
1493
|
changed: onChanged,
|
|
1413
|
-
held: (f) => activity.has(f, "cli")
|
|
1494
|
+
held: (f) => activity.has(f, "cli"),
|
|
1495
|
+
anchor
|
|
1414
1496
|
});
|
|
1415
1497
|
let stopped = false;
|
|
1416
1498
|
let scheduled = null;
|