@marver-design/marver 0.23.1 → 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 +66 -0
- package/README.md +3 -1
- package/dist/anchor-DVV732zR.mjs +33 -0
- package/dist/anchor-check-BE5VVN6Q.mjs +135 -0
- package/dist/{bake-DQtnDB8-.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-_ndp_dXn.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-BlqyZh3D.mjs → comments-pTLlhjh4.mjs} +150 -20
- package/dist/{config-BUKprFAp.mjs → config-cKgZBRj0.mjs} +1 -1
- package/dist/{context-CdkNiKdJ.mjs → context-D2ugHqwO.mjs} +17 -123
- package/dist/{daemon-BvMPdQ3k.mjs → daemon-Cl8KXGW4.mjs} +146 -64
- package/dist/{dev-Cf-4eqaC.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-hfZV7TwY.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-DoXql0ZZ.mjs → plugin-CTyhjwoJ.mjs} +469 -82
- package/dist/{poster-XBmUvQiL.mjs → poster-D0cbV7hi.mjs} +1 -1
- package/dist/{profile-CrZohD6g.mjs → profile-Do0nGkXO.mjs} +1 -1
- package/dist/{publish-bakes-KKTHWqq3.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-DOD8v6fJ.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-ClFFq0Qh.mjs → work-CpJn1gwY.mjs} +8 -4
- package/dist/{work-ayuL_9Kk.mjs → work-GE88wb_3.mjs} +4 -4
- package/docs/boards-and-folders.md +70 -4
- package/docs/live-jam.md +12 -4
- 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 +98 -30
- package/src/client/shell/BoardList.tsx +74 -16
- 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 -32
- package/src/client/shell/Toolbar.tsx +3 -1
- package/src/client/shell/canvas/Canvas.tsx +2 -0
- package/src/client/shell/canvas/FrameNode.tsx +15 -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 -17
- 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 +117 -0
- package/src/client/shell/pin-layout.ts +37 -0
- package/src/client/shell/store.ts +377 -67
- package/src/client/shell/styles.css +32 -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 +70 -0
- 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-BodAbIQz.mjs +0 -132
- package/dist/manifest-TpfDWldB.mjs +0 -528
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { i as PKG, n as CONTENT_WIDTH } from "./cli.mjs";
|
|
3
|
+
import { a as checkRealDirs, f as readRegistry, h as hash, i as checkBoardsDir, r as boardFields, s as listBoardFiles } from "./boards-CGg6piKF.mjs";
|
|
4
|
+
import { D as readStatusWord, E as readReason, T as readCapability, a as buildTree, f as isBoardName, h as readTitle, k as resolveType, m as readDescription, o as flatten, s as folderEntries, x as HAS_STATUS, y as DECISIONS } from "./board-tree-DRioF94d.mjs";
|
|
5
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { join, relative, sep } from "node:path";
|
|
7
|
+
import { randomBytes } from "node:crypto";
|
|
4
8
|
//#region src/shared/context.ts
|
|
5
9
|
const LEVEL = /`(confirmed|reported|unknown)`/g;
|
|
6
10
|
/** What counts as a citation beside a level: a `path:line`, a run id, a cited file, or a link to a
|
|
@@ -22,11 +26,11 @@ const lf = (text) => text.replace(/^\uFEFF/, "").replace(/\r\n?/g, "\n");
|
|
|
22
26
|
const EVIDENCE_COLUMN = /^(evidence|verified|available|delivered)$/i;
|
|
23
27
|
/** A Marver-managed file's first line (the playbooks Marver maintains) - front matter follows it. */
|
|
24
28
|
const MANAGED_LINE = /^<!-- marver:managed [^\n]*-->\n/;
|
|
25
|
-
function frontMatter(raw) {
|
|
29
|
+
function frontMatter$1(raw) {
|
|
26
30
|
const text = lf(raw);
|
|
27
31
|
const managed = MANAGED_LINE.exec(text);
|
|
28
32
|
if (managed) {
|
|
29
|
-
const r = frontMatter(text.slice(managed[0].length));
|
|
33
|
+
const r = frontMatter$1(text.slice(managed[0].length));
|
|
30
34
|
return {
|
|
31
35
|
...r,
|
|
32
36
|
offset: r.offset + 1
|
|
@@ -307,7 +311,7 @@ function capabilityTable(map) {
|
|
|
307
311
|
].join("\n");
|
|
308
312
|
}
|
|
309
313
|
/** Words in a document's body (front matter excluded) - the index's budget counts these. */
|
|
310
|
-
const wordCount = (text) => frontMatter(text).body.split(/\s+/).filter(Boolean).length;
|
|
314
|
+
const wordCount = (text) => frontMatter$1(text).body.split(/\s+/).filter(Boolean).length;
|
|
311
315
|
//#endregion
|
|
312
316
|
//#region src/shared/status.ts
|
|
313
317
|
/**
|
|
@@ -551,7 +555,7 @@ function readFresh(dir) {
|
|
|
551
555
|
if (e.code !== "ENOENT") facts.unreadable.set("*", `context/shipped.md: ${e.message}`);
|
|
552
556
|
}
|
|
553
557
|
if (text !== null) {
|
|
554
|
-
const fm = frontMatter(text);
|
|
558
|
+
const fm = frontMatter$1(text);
|
|
555
559
|
if (fm.error) facts.unreadable.set("*", `context/shipped.md: ${fm.error}`);
|
|
556
560
|
else if (!tables(text).some(isRecordTable)) facts.unreadable.set("*", "context/shipped.md: no Capability table with an Available column");
|
|
557
561
|
else {
|
|
@@ -569,7 +573,7 @@ function readFresh(dir) {
|
|
|
569
573
|
const where = `context/product/${f}`;
|
|
570
574
|
const slug = f.slice(0, -3);
|
|
571
575
|
try {
|
|
572
|
-
const fm = frontMatter(readFileSync(join(dir, "product", f), "utf8"));
|
|
576
|
+
const fm = frontMatter$1(readFileSync(join(dir, "product", f), "utf8"));
|
|
573
577
|
if (fm.error || !fm.data) {
|
|
574
578
|
facts.unreadable.set(slug, `${where}: ${fm.error ?? "no front matter"}`);
|
|
575
579
|
continue;
|
|
@@ -595,7 +599,7 @@ function readFresh(dir) {
|
|
|
595
599
|
const where = `context/plans/${f}`;
|
|
596
600
|
f.slice(0, -3);
|
|
597
601
|
try {
|
|
598
|
-
const fm = frontMatter(readFileSync(join(dir, "plans", f), "utf8"));
|
|
602
|
+
const fm = frontMatter$1(readFileSync(join(dir, "plans", f), "utf8"));
|
|
599
603
|
if (fm.error || !fm.data) {
|
|
600
604
|
facts.unreadable.set("*", `${where}: ${fm.error ?? "no front matter"}`);
|
|
601
605
|
continue;
|
|
@@ -646,7 +650,7 @@ function readScene(root, scene) {
|
|
|
646
650
|
let phase;
|
|
647
651
|
let audience;
|
|
648
652
|
try {
|
|
649
|
-
const fm = frontMatter(readFileSync(join(dir, "_brief.md"), "utf8"));
|
|
653
|
+
const fm = frontMatter$1(readFileSync(join(dir, "_brief.md"), "utf8"));
|
|
650
654
|
if (typeof fm.data?.phase === "string") {
|
|
651
655
|
phase = fm.data.phase;
|
|
652
656
|
audience = fm.data.audience === void 0 ? "publishable" : readAudience(fm.data.audience);
|
|
@@ -747,7 +751,7 @@ function planWithStage(raw, stage) {
|
|
|
747
751
|
}
|
|
748
752
|
const eol = (line?.text.match(/\r?\n$/) ?? lines[lines.length - 1]?.text.match(/\r?\n$/) ?? head[0].match(/\r?\n$/))[0];
|
|
749
753
|
const text = stage === null ? line ? raw.slice(0, line.at) + raw.slice(line.at + line.text.length) : raw : line ? raw.slice(0, line.at) + `stage: ${stage}` + (line.text.match(/\r?\n$/)?.[0] ?? "") + raw.slice(line.at + line.text.length) : raw.slice(0, end) + `stage: ${stage}${eol}` + raw.slice(end);
|
|
750
|
-
const before = frontMatter(raw).data ?? {}, after = frontMatter(text).data ?? {};
|
|
754
|
+
const before = frontMatter$1(raw).data ?? {}, after = frontMatter$1(text).data ?? {};
|
|
751
755
|
if ("stage" in before && typeof before.stage !== "string") return { error: "has a `stage` that is not one word - write it as `stage: build`" };
|
|
752
756
|
const rest = (d) => JSON.stringify(Object.entries(d).filter(([k]) => k !== "stage").sort(([a], [b]) => a.localeCompare(b)));
|
|
753
757
|
if (rest(before) !== rest(after) || (stage ? after.stage !== stage : "stage" in after)) return { error: "has a `stage` this cannot edit as one line - write it as `stage: build`" };
|
|
@@ -756,11 +760,531 @@ function planWithStage(raw, stage) {
|
|
|
756
760
|
/** Is this plan text open, and naming the capability? The check a write repeats on what it reads -
|
|
757
761
|
* a plan closed, or moved to another capability, since the evidence was gathered is not written. */
|
|
758
762
|
function planNames(raw, capability) {
|
|
759
|
-
const fm = frontMatter(raw);
|
|
763
|
+
const fm = frontMatter$1(raw);
|
|
760
764
|
if (fm.error || !fm.data) return false;
|
|
761
765
|
if (typeof fm.data.state === "string" && CLOSED_PLAN.has(fm.data.state)) return false;
|
|
762
766
|
const list = (v) => Array.isArray(v) ? v : v === void 0 ? [] : [v];
|
|
763
767
|
return [...list(fm.data.capability), ...list(fm.data.capabilities)].map(readCapability).includes(capability);
|
|
764
768
|
}
|
|
765
769
|
//#endregion
|
|
766
|
-
|
|
770
|
+
//#region src/server/manifest.ts
|
|
771
|
+
var manifest_exports = /* @__PURE__ */ __exportAll({
|
|
772
|
+
NOTE_MAX: () => NOTE_MAX,
|
|
773
|
+
affectedFrameIds: () => affectedFrameIds,
|
|
774
|
+
codeOnly: () => codeOnly,
|
|
775
|
+
contentScan: () => contentScan,
|
|
776
|
+
contentWidthOf: () => contentWidthOf,
|
|
777
|
+
docTags: () => docTags,
|
|
778
|
+
extractMeta: () => extractMeta,
|
|
779
|
+
frontMatter: () => frontMatter,
|
|
780
|
+
isNoteFile: () => isNoteFile,
|
|
781
|
+
layoutDocSource: () => layoutDocSource,
|
|
782
|
+
noteFileFor: () => noteFileFor,
|
|
783
|
+
readNote: () => readNote,
|
|
784
|
+
rendersDoc: () => rendersDoc,
|
|
785
|
+
scanFrames: () => scanFrames,
|
|
786
|
+
sceneBrief: () => sceneBrief,
|
|
787
|
+
sceneNote: () => sceneNote,
|
|
788
|
+
setSceneTitle: () => setSceneTitle,
|
|
789
|
+
statusBoards: () => statusBoards,
|
|
790
|
+
tagPattern: () => tagPattern,
|
|
791
|
+
toFrameId: () => toFrameId,
|
|
792
|
+
writeManifest: () => writeManifest
|
|
793
|
+
});
|
|
794
|
+
const FRAME_EXT = /\.(tsx|jsx|html)$/;
|
|
795
|
+
const RESERVED_SCENES = /* @__PURE__ */ new Set(["components", "screens"]);
|
|
796
|
+
/** Sticky notes (spec 18): the longest note the manifest carries - a note is an aside, not a spec. */
|
|
797
|
+
const NOTE_MAX = 2e4;
|
|
798
|
+
/** The note file beside a frame file: `cart.tsx` -> `cart.note.md`; a scene's is `_note.md`. */
|
|
799
|
+
const noteFileFor = (frameFile) => frameFile.replace(FRAME_EXT, ".note.md");
|
|
800
|
+
/** Is this path a note file - the dev watcher's "regenerate on change" predicate. */
|
|
801
|
+
const isNoteFile = (file) => /(^|[\\/])(_note|[^\\/]+\.note)\.md$/.test(file);
|
|
802
|
+
/** A note's text: BOM stripped, trimmed, capped at NOTE_MAX. Undefined when the file is missing,
|
|
803
|
+
* empty, or not a regular file (a symlink is never followed - the `_brief.md` rule). */
|
|
804
|
+
function readNote(abs) {
|
|
805
|
+
try {
|
|
806
|
+
if (!lstatSync(abs).isFile()) return void 0;
|
|
807
|
+
const text = readFileSync(abs, "utf8").replace(/^/, "").trim();
|
|
808
|
+
return text ? text.slice(0, NOTE_MAX) : void 0;
|
|
809
|
+
} catch {
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
/** Extract `export const meta = {...}` with literal string values only. Anything else is silently omitted. */
|
|
814
|
+
function extractMeta(src) {
|
|
815
|
+
const m = /export\s+const\s+meta\s*=\s*\{([\s\S]*?)\}/.exec(src);
|
|
816
|
+
if (!m) return {};
|
|
817
|
+
const body = m[1];
|
|
818
|
+
const pick = (key) => {
|
|
819
|
+
const r = new RegExp(`(?:^|[{,])\\s*${key}\\s*:\\s*(?:'([^'\\n]*)'|"([^"\\n]*)"|\`([^\`\\n]*)\`)\\s*(?=[,}\\n]|$)`).exec(body);
|
|
820
|
+
return r ? r[1] ?? r[2] ?? r[3] : void 0;
|
|
821
|
+
};
|
|
822
|
+
const pickBool = (key) => {
|
|
823
|
+
const r = new RegExp(`(?:^|[{,])\\s*${key}\\s*:\\s*(true|false)\\b`).exec(body);
|
|
824
|
+
return r ? r[1] === "true" : void 0;
|
|
825
|
+
};
|
|
826
|
+
const out = {};
|
|
827
|
+
const title = pick("title");
|
|
828
|
+
if (title) out.title = title;
|
|
829
|
+
const viewport = pick("viewport");
|
|
830
|
+
if (viewport) out.viewport = viewport;
|
|
831
|
+
const theme = pick("theme");
|
|
832
|
+
if (theme) out.theme = theme;
|
|
833
|
+
const of = pick("of");
|
|
834
|
+
if (of) out.of = of;
|
|
835
|
+
const variant = pick("variant");
|
|
836
|
+
if (variant) out.variant = variant;
|
|
837
|
+
const intent = pick("intent");
|
|
838
|
+
if (intent) out.intent = intent;
|
|
839
|
+
const slide = pickBool("slide");
|
|
840
|
+
if (slide !== void 0) out.slide = slide;
|
|
841
|
+
const description = readDescription(pick("description"));
|
|
842
|
+
if (description) out.description = description;
|
|
843
|
+
return out;
|
|
844
|
+
}
|
|
845
|
+
/** Content-frame detection: LEXICAL by convention - the frame file itself imports
|
|
846
|
+
* PKG/content (an import specifier scan, so "<Diagram" inside a string in a UI frame can
|
|
847
|
+
* never misbadge it; barrels/re-exports are not detected - meta.intent is the taught path
|
|
848
|
+
* and always works) AND renders a DOCUMENT primitive: Doc, Md, Diagram or Img (reference
|
|
849
|
+
* imagery - a moodboard is Rows of Img). The import alone is not enough - Chart, Video, Row,
|
|
850
|
+
* Col and Space are shared blocks a UI screen or a slide uses too, and a dashboard with one
|
|
851
|
+
* <Chart> is still a screen (device height, no document measuring), never a spec. Returns
|
|
852
|
+
* the inferred intent + natural width, or null for UI frames. */
|
|
853
|
+
const CONTENT_IMPORT = new RegExp(`from\\s+['"]${PKG}/content['"]`);
|
|
854
|
+
/** The JSX names a Doc renders under in this source: `Doc`, an alias (`import { Doc as Page }`),
|
|
855
|
+
* a namespace's member (`import * as C` -> `C.Doc`). Read from the code only (codeOnly). */
|
|
856
|
+
function docTags(code) {
|
|
857
|
+
const tags = ["Doc"];
|
|
858
|
+
for (const m of code.matchAll(/\bDoc\s+as\s+([A-Za-z_$][\w$]*)/g)) tags.push(m[1]);
|
|
859
|
+
for (const m of code.matchAll(/import\s+\*\s+as\s+([A-Za-z_$][\w$]*)\s+from/g)) tags.push(`${m[1]}.Doc`);
|
|
860
|
+
return tags;
|
|
861
|
+
}
|
|
862
|
+
const tagPattern = (tag) => tag.replace(/[.$]/g, "\\$&");
|
|
863
|
+
/** Does this source render a `<Doc>` - the one primitive that measures (content/index.tsx)? Lexical
|
|
864
|
+
* on the code (comments and strings blanked), through an aliased or namespace import too. */
|
|
865
|
+
function rendersDoc(src) {
|
|
866
|
+
const code = codeOnly(src);
|
|
867
|
+
return docTags(code).some((t) => new RegExp(`<${tagPattern(t)}[\\s>/]`).test(code));
|
|
868
|
+
}
|
|
869
|
+
/** The source of the nearest `_layout.tsx|jsx` around a frame that renders a Doc - the frame host
|
|
870
|
+
* wraps a frame in every `_layout` from its directory up to `scenes/` or `components/` - or null.
|
|
871
|
+
* `file` is the frame's path from the root; `memo` caches per directory across one scan. */
|
|
872
|
+
function layoutDocSource(root, file, memo) {
|
|
873
|
+
const parts = file.split("/").slice(0, -1);
|
|
874
|
+
if (parts.includes("..")) return null;
|
|
875
|
+
for (let i = parts.length; i >= 2; i--) {
|
|
876
|
+
const dir = parts.slice(0, i).join("/");
|
|
877
|
+
let found = memo.get(dir);
|
|
878
|
+
if (found === void 0) {
|
|
879
|
+
found = null;
|
|
880
|
+
for (const ext of ["tsx", "jsx"]) try {
|
|
881
|
+
const src = readFileSync(join(root, dir, `_layout.${ext}`), "utf8");
|
|
882
|
+
if (rendersDoc(src)) {
|
|
883
|
+
found = src;
|
|
884
|
+
break;
|
|
885
|
+
}
|
|
886
|
+
} catch {}
|
|
887
|
+
memo.set(dir, found);
|
|
888
|
+
}
|
|
889
|
+
if (found !== null) return found;
|
|
890
|
+
}
|
|
891
|
+
return null;
|
|
892
|
+
}
|
|
893
|
+
const contentWidthOf = (src) => docTags(codeOnly(src)).some((t) => new RegExp(`<${tagPattern(t)}\\b[^>]*\\blayout\\s*=\\s*["']wide["']`).test(src)) ? CONTENT_WIDTH.wide : CONTENT_WIDTH.document;
|
|
894
|
+
/** The source with comments, template literals and CODE-shaped strings blanked (a JSX
|
|
895
|
+
* expression string `{'<Diagram>'}`, an attribute value), so a tag name quoted in an example
|
|
896
|
+
* or a comment never counts as a rendered element. Prose is left alone: JSX text has
|
|
897
|
+
* apostrophes ("it's"), and a blanket quote match would swallow real tags between two of them. */
|
|
898
|
+
const codeOnly = (src) => src.replace(/`(?:[^`\\]|\\[\s\S])*`/g, "``").replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/\{\s*(?:"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*')\s*\}/g, "{\"\"}").replace(/([=(,:[{?+|&!]|\breturn)\s*(?:"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*')/g, "$1\"\"").replace(/([=(,:[{?+|&!]|\breturn)\s*\/(?:[^/\\\n[]|\\.|\[(?:[^\]\\\n]|\\.)*\])+\/[gimsuy]*/g, "$1/re/");
|
|
899
|
+
function contentScan(src) {
|
|
900
|
+
if (!CONTENT_IMPORT.test(src)) return null;
|
|
901
|
+
const code = codeOnly(src);
|
|
902
|
+
const count = (re) => (code.match(re) ?? []).length;
|
|
903
|
+
const docs = count(/<Doc[\s>/]/g);
|
|
904
|
+
const diagrams = count(/<Diagram[\s>/]/g);
|
|
905
|
+
const imgs = count(/<Img[\s>/]/g);
|
|
906
|
+
const mds = count(/<Md[\s>/]/g);
|
|
907
|
+
if (docs + diagrams + mds + imgs === 0) return null;
|
|
908
|
+
return {
|
|
909
|
+
intent: diagrams > 0 ? "diagram" : imgs > mds ? "moodboard" : "spec",
|
|
910
|
+
width: contentWidthOf(src)
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
/** id = path relative to design/, extension dropped, `scenes/` prefix dropped. Always `/`-separated. */
|
|
914
|
+
function toFrameId(designRelPath) {
|
|
915
|
+
const noExt = designRelPath.split(sep).join("/").replace(FRAME_EXT, "");
|
|
916
|
+
return noExt.startsWith("scenes/") ? noExt.slice(7) : noExt;
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* A7: which frames does a changed `design/**` file affect? Manifest + directory conventions,
|
|
920
|
+
* NOT a module-graph walk (deterministic, cheap, may over-reload but never misses a
|
|
921
|
+
* conventionally-affected frame). Returns:
|
|
922
|
+
* null -> uncontrolled: leave to default Vite HMR (src/** deps, theme.css, config, assets)
|
|
923
|
+
* [] -> controlled but affects no current frame (e.g. a layout in an empty dir)
|
|
924
|
+
* [ids] -> controlled: the shell drives a rev-stamped reload of these frames
|
|
925
|
+
*/
|
|
926
|
+
function affectedFrameIds(absFile, root, manifest) {
|
|
927
|
+
const design = join(root, "design");
|
|
928
|
+
if (absFile !== design && !absFile.startsWith(design + sep)) return null;
|
|
929
|
+
const rel = relative(design, absFile).split(sep).join("/");
|
|
930
|
+
const name = rel.split("/").pop() ?? rel;
|
|
931
|
+
const designRel = `design/${rel}`;
|
|
932
|
+
const tsxFrames = manifest.frames.filter((f) => f.kind === "tsx");
|
|
933
|
+
if (name === "theme.css") return null;
|
|
934
|
+
if (rel === "providers.tsx" || rel === "providers.jsx") return tsxFrames.map((f) => f.id);
|
|
935
|
+
if (/(^|\/)(_layout\.(tsx|jsx)|_fixtures\.(ts|tsx|js|jsx|json))$/.test(rel)) {
|
|
936
|
+
const prefix = `design/${rel.slice(0, rel.length - name.length)}`;
|
|
937
|
+
return tsxFrames.filter((f) => f.file.startsWith(prefix)).map((f) => f.id);
|
|
938
|
+
}
|
|
939
|
+
const direct = manifest.frames.find((f) => f.file === designRel);
|
|
940
|
+
if (direct) return [direct.id];
|
|
941
|
+
return null;
|
|
942
|
+
}
|
|
943
|
+
function walk(dir, out = []) {
|
|
944
|
+
if (!existsSync(dir)) return out;
|
|
945
|
+
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
946
|
+
if (e.name.startsWith(".")) continue;
|
|
947
|
+
const p = join(dir, e.name);
|
|
948
|
+
if (e.isDirectory()) walk(p, out);
|
|
949
|
+
else out.push(p);
|
|
950
|
+
}
|
|
951
|
+
return out;
|
|
952
|
+
}
|
|
953
|
+
/** The YAML front matter at the top of a markdown file, read flat: `key: value` scalars,
|
|
954
|
+
* quoted (JSON-style double quotes, or single quotes with '' for one) or bare. `end` is the
|
|
955
|
+
* line the body starts at (0 = no block; an unclosed block swallows the file). */
|
|
956
|
+
function frontMatter(lines) {
|
|
957
|
+
const fields = {};
|
|
958
|
+
if (lines[0]?.trim() !== "---") return {
|
|
959
|
+
fields,
|
|
960
|
+
end: 0
|
|
961
|
+
};
|
|
962
|
+
let close = lines.findIndex((l, i) => i > 0 && l.trim() === "---");
|
|
963
|
+
if (close < 0) close = lines.length;
|
|
964
|
+
for (const l of lines.slice(1, close)) {
|
|
965
|
+
const m = /^([A-Za-z_][\w-]*)\s*:\s*(.*)$/.exec(l.trim());
|
|
966
|
+
if (!m) continue;
|
|
967
|
+
let v = m[2].trim();
|
|
968
|
+
if (v.startsWith("\"")) try {
|
|
969
|
+
v = String(JSON.parse(v));
|
|
970
|
+
} catch {
|
|
971
|
+
v = v.replace(/^"|"$/g, "");
|
|
972
|
+
}
|
|
973
|
+
else if (v.length >= 2 && v.startsWith("'") && v.endsWith("'")) v = v.slice(1, -1).replace(/''/g, "'");
|
|
974
|
+
fields[m[1]] = v;
|
|
975
|
+
}
|
|
976
|
+
return {
|
|
977
|
+
fields,
|
|
978
|
+
end: Math.min(close + 1, lines.length)
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
/** A scene's title is `title` in its `_brief.md` front matter; its description is the first
|
|
982
|
+
* non-blank line after the block (a leading `#` stripped) - no new file. */
|
|
983
|
+
function sceneBrief(root, scene) {
|
|
984
|
+
if (!scene) return {};
|
|
985
|
+
const rel = `design/scenes/${scene}/_brief.md`;
|
|
986
|
+
const abs = join(root, ...rel.split("/"));
|
|
987
|
+
if (!existsSync(abs)) return {};
|
|
988
|
+
let title, description;
|
|
989
|
+
try {
|
|
990
|
+
const lines = readFileSync(abs, "utf8").replace(/^\uFEFF/, "").split(/\r?\n/);
|
|
991
|
+
const fm = frontMatter(lines);
|
|
992
|
+
title = readTitle(fm.fields.title);
|
|
993
|
+
const line = lines.slice(fm.end).map((l) => l.trim()).find((l) => l);
|
|
994
|
+
description = readDescription(line?.replace(/^#+\s*/, ""));
|
|
995
|
+
} catch {}
|
|
996
|
+
return {
|
|
997
|
+
brief: rel,
|
|
998
|
+
...title ? { title } : {},
|
|
999
|
+
...description ? { description } : {}
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
/** A scene's sticky note: `design/scenes/<scene>/_note.md` (spec 18). */
|
|
1003
|
+
function sceneNote(root, scene) {
|
|
1004
|
+
return scene ? readNote(join(root, "design", "scenes", scene, "_note.md")) : void 0;
|
|
1005
|
+
}
|
|
1006
|
+
/** Write a scene's title into its brief's front matter - only that line changes; the body,
|
|
1007
|
+
* every other field and the file's own line endings are kept. No brief yet = a front-matter-only
|
|
1008
|
+
* brief. An empty title removes the line, and the file when nothing else is in it. The write
|
|
1009
|
+
* is atomic (temp + rename); a symlinked scene directory or brief, or a front matter block
|
|
1010
|
+
* that never closes, is refused untouched - the brief is the agent's document, never rewritten
|
|
1011
|
+
* from a guess. Returns the error, or null. */
|
|
1012
|
+
function setSceneTitle(root, scene, title) {
|
|
1013
|
+
const design = join(root, "design"), scenes = join(design, "scenes"), dir = join(scenes, scene);
|
|
1014
|
+
const de = checkRealDirs(root, [
|
|
1015
|
+
[design, "design"],
|
|
1016
|
+
[scenes, "design/scenes"],
|
|
1017
|
+
[dir, `design/scenes/${scene}`]
|
|
1018
|
+
]);
|
|
1019
|
+
if (de) return de;
|
|
1020
|
+
try {
|
|
1021
|
+
if (!lstatSync(dir).isDirectory()) return `"${scene}" is not a scene directory`;
|
|
1022
|
+
} catch {
|
|
1023
|
+
return `scene "${scene}" does not exist`;
|
|
1024
|
+
}
|
|
1025
|
+
const file = join(dir, "_brief.md");
|
|
1026
|
+
let had = false;
|
|
1027
|
+
try {
|
|
1028
|
+
if (!lstatSync(file).isFile()) return `design/scenes/${scene}/_brief.md is not a regular file - refusing to write it`;
|
|
1029
|
+
had = true;
|
|
1030
|
+
} catch {}
|
|
1031
|
+
const text = had ? readFileSync(file, "utf8") : "";
|
|
1032
|
+
const bom = text.startsWith("") ? "" : "";
|
|
1033
|
+
const raw = text.slice(bom.length);
|
|
1034
|
+
const eol = raw.includes("\r\n") ? "\r\n" : "\n";
|
|
1035
|
+
const lines = raw.split(/\r?\n/);
|
|
1036
|
+
const fm = frontMatter(lines);
|
|
1037
|
+
if (fm.end === lines.length && lines[0]?.trim() === "---" && !lines.slice(1).some((l) => l.trim() === "---")) return `design/scenes/${scene}/_brief.md: the front matter never closes - fix the file`;
|
|
1038
|
+
const line = title ? [`title: ${JSON.stringify(title)}`] : [];
|
|
1039
|
+
let out;
|
|
1040
|
+
if (fm.end === 0) {
|
|
1041
|
+
if (!title) return null;
|
|
1042
|
+
out = [
|
|
1043
|
+
"---",
|
|
1044
|
+
...line,
|
|
1045
|
+
"---",
|
|
1046
|
+
...raw.trim() ? ["", ...lines] : [""]
|
|
1047
|
+
];
|
|
1048
|
+
} else {
|
|
1049
|
+
const close = Math.max(1, fm.end - 1);
|
|
1050
|
+
const kept = lines.slice(1, close).filter((l) => !/^title\s*:/.test(l.trim()));
|
|
1051
|
+
const body = lines.slice(fm.end);
|
|
1052
|
+
out = kept.length || title ? [
|
|
1053
|
+
"---",
|
|
1054
|
+
...line,
|
|
1055
|
+
...kept,
|
|
1056
|
+
"---",
|
|
1057
|
+
...body
|
|
1058
|
+
] : body;
|
|
1059
|
+
}
|
|
1060
|
+
if (!out.join("").trim()) {
|
|
1061
|
+
if (had) rmSync(file);
|
|
1062
|
+
return null;
|
|
1063
|
+
}
|
|
1064
|
+
const tmp = join(dir, `.brief-${randomBytes(6).toString("hex")}.tmp`);
|
|
1065
|
+
try {
|
|
1066
|
+
writeFileSync(tmp, bom + out.join(eol));
|
|
1067
|
+
renameSync(tmp, file);
|
|
1068
|
+
} catch (err) {
|
|
1069
|
+
rmSync(tmp, { force: true });
|
|
1070
|
+
throw err;
|
|
1071
|
+
}
|
|
1072
|
+
return null;
|
|
1073
|
+
}
|
|
1074
|
+
/** The sidebar as files say it is, for the manifest: folders in reading order (a sub-folder
|
|
1075
|
+
* after its parent, with `parent`), boards in reading order with the folder they sit in
|
|
1076
|
+
* directly and their description. A boards dir we may not read (symlink)
|
|
1077
|
+
* or a malformed registry yields nothing here - the API and the build say why; the
|
|
1078
|
+
* orientation file must never fail to write. */
|
|
1079
|
+
function scanBoards(root) {
|
|
1080
|
+
const dir = join(root, "design", "boards");
|
|
1081
|
+
if (checkBoardsDir(root, dir)) return {};
|
|
1082
|
+
const reg = readRegistry(dir);
|
|
1083
|
+
if (reg.state === "malformed") return {};
|
|
1084
|
+
const files = listBoardFiles(dir).boards;
|
|
1085
|
+
const rows = files.map((b) => ({
|
|
1086
|
+
name: b.name,
|
|
1087
|
+
...boardFields(b.json, isBoardName)
|
|
1088
|
+
}));
|
|
1089
|
+
const tree = buildTree(rows, reg.folders);
|
|
1090
|
+
const entries = folderEntries(tree);
|
|
1091
|
+
const folderOf = /* @__PURE__ */ new Map();
|
|
1092
|
+
for (const { folder } of entries) for (const k of folder.items) if (k.kind === "board") folderOf.set(k.name, folder.name);
|
|
1093
|
+
const folders = entries.map(({ folder: it, parent }) => ({
|
|
1094
|
+
name: it.name,
|
|
1095
|
+
...parent ? { parent } : {},
|
|
1096
|
+
...it.title ? { title: it.title } : {},
|
|
1097
|
+
...it.description ? { description: it.description } : {},
|
|
1098
|
+
...it.type ? { type: it.type } : {}
|
|
1099
|
+
}));
|
|
1100
|
+
const notes = annotateBoards(root, files, reg.folders, (n) => folderOf.get(n) ?? null);
|
|
1101
|
+
const boards = flatten(tree).map((name) => {
|
|
1102
|
+
const r = rows.find((x) => x.name === name);
|
|
1103
|
+
const n = notes.get(name);
|
|
1104
|
+
const st = n?.status;
|
|
1105
|
+
return {
|
|
1106
|
+
name,
|
|
1107
|
+
...folderOf.has(name) ? { folder: folderOf.get(name) } : {},
|
|
1108
|
+
...r?.title ? { title: r.title } : {},
|
|
1109
|
+
...r?.description ? { description: r.description } : {},
|
|
1110
|
+
...n && n.type !== "plain" ? { type: n.type } : {},
|
|
1111
|
+
...st ? { status: {
|
|
1112
|
+
status: st.status,
|
|
1113
|
+
...st.fill ? { fill: st.fill } : {},
|
|
1114
|
+
...st.reason ? { reason: st.reason } : {},
|
|
1115
|
+
audience: st.audience
|
|
1116
|
+
} } : {}
|
|
1117
|
+
};
|
|
1118
|
+
});
|
|
1119
|
+
return {
|
|
1120
|
+
...folders.length ? { folders } : {},
|
|
1121
|
+
...boards.length ? { boards } : {}
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
/** The boards that wear a status (feature and project, by their resolved type) - for the dev
|
|
1125
|
+
* server's word at boot when there is no context/ to read it from. */
|
|
1126
|
+
const statusBoards = (root) => (scanBoards(root).boards ?? []).filter((b) => b.type === "feature" || b.type === "project").map((b) => b.name);
|
|
1127
|
+
function scanFrames(root, project) {
|
|
1128
|
+
const design = join(root, "design");
|
|
1129
|
+
const frames = [];
|
|
1130
|
+
const layoutDocs = /* @__PURE__ */ new Map();
|
|
1131
|
+
for (const base of ["scenes", "components"]) for (const abs of walk(join(design, base))) {
|
|
1132
|
+
const name = abs.split(sep).pop();
|
|
1133
|
+
const rel = relative(design, abs).split(sep).join("/");
|
|
1134
|
+
const folders = rel.split("/").slice(base === "scenes" ? 2 : 1, -1);
|
|
1135
|
+
if (!FRAME_EXT.test(name) || name.startsWith("_") || folders.some((s) => s.startsWith("_"))) continue;
|
|
1136
|
+
const id = toFrameId(rel);
|
|
1137
|
+
const scene = id.includes("/") ? id.split("/")[0] : "";
|
|
1138
|
+
if (base === "scenes" && RESERVED_SCENES.has(scene)) {
|
|
1139
|
+
console.error(`[marver] scene "${scene}" is a reserved name - "${rel}" skipped. Rename the scene.`);
|
|
1140
|
+
continue;
|
|
1141
|
+
}
|
|
1142
|
+
const kind = name.endsWith(".html") ? "html" : "tsx";
|
|
1143
|
+
const entry = {
|
|
1144
|
+
id,
|
|
1145
|
+
file: `design/${rel}`,
|
|
1146
|
+
kind,
|
|
1147
|
+
scene
|
|
1148
|
+
};
|
|
1149
|
+
const note = readNote(noteFileFor(abs));
|
|
1150
|
+
if (note) entry.note = note;
|
|
1151
|
+
if (kind === "tsx") {
|
|
1152
|
+
const src = readFileSync(abs, "utf8");
|
|
1153
|
+
const meta = extractMeta(src);
|
|
1154
|
+
if (meta.title) entry.title = meta.title;
|
|
1155
|
+
if (meta.viewport) entry.viewport = meta.viewport;
|
|
1156
|
+
if (meta.theme) entry.theme = meta.theme;
|
|
1157
|
+
if (meta.of) entry.variantGroup = meta.of;
|
|
1158
|
+
if (meta.variant) entry.variant = meta.variant;
|
|
1159
|
+
if (meta.slide) entry.slide = true;
|
|
1160
|
+
if (meta.description) entry.description = meta.description;
|
|
1161
|
+
const content = contentScan(src);
|
|
1162
|
+
if (content || meta.intent) {
|
|
1163
|
+
entry.intent = meta.intent ?? content.intent;
|
|
1164
|
+
const layout = rendersDoc(src) ? null : layoutDocSource(root, entry.file, layoutDocs);
|
|
1165
|
+
entry.contentWidth = layout !== null ? contentWidthOf(layout) : content?.width ?? contentWidthOf(src);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
frames.push(entry);
|
|
1169
|
+
}
|
|
1170
|
+
const extRank = (file) => file.endsWith(".tsx") ? 0 : file.endsWith(".jsx") ? 1 : 2;
|
|
1171
|
+
frames.sort((a, b) => a.id.localeCompare(b.id) || extRank(a.file) - extRank(b.file) || a.file.localeCompare(b.file));
|
|
1172
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1173
|
+
const deduped = frames.filter((f) => {
|
|
1174
|
+
const prev = seen.get(f.id);
|
|
1175
|
+
if (prev) {
|
|
1176
|
+
console.error(`[marver] duplicate frame id "${f.id}" (${prev} vs ${f.file}) - keeping ${prev}.`);
|
|
1177
|
+
return false;
|
|
1178
|
+
}
|
|
1179
|
+
seen.set(f.id, f.file);
|
|
1180
|
+
return true;
|
|
1181
|
+
});
|
|
1182
|
+
frames.length = 0;
|
|
1183
|
+
frames.push(...deduped);
|
|
1184
|
+
inferVariantGroups(frames);
|
|
1185
|
+
const sceneCounts = /* @__PURE__ */ new Map();
|
|
1186
|
+
for (const f of frames) sceneCounts.set(f.scene, (sceneCounts.get(f.scene) ?? 0) + 1);
|
|
1187
|
+
const scenesDir = join(design, "scenes");
|
|
1188
|
+
if (existsSync(scenesDir)) {
|
|
1189
|
+
for (const e of readdirSync(scenesDir, { withFileTypes: true })) if (e.isDirectory() && !e.name.startsWith(".") && !RESERVED_SCENES.has(e.name) && !sceneCounts.has(e.name) && existsSync(join(scenesDir, e.name, "_brief.md"))) sceneCounts.set(e.name, 0);
|
|
1190
|
+
}
|
|
1191
|
+
const scenes = [...sceneCounts.entries()].map(([name, n]) => {
|
|
1192
|
+
const note = sceneNote(root, name);
|
|
1193
|
+
return {
|
|
1194
|
+
name,
|
|
1195
|
+
frames: n,
|
|
1196
|
+
...sceneBrief(root, name),
|
|
1197
|
+
...note ? { note } : {}
|
|
1198
|
+
};
|
|
1199
|
+
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
1200
|
+
return {
|
|
1201
|
+
...project && (project.name || project.description) ? { project: {
|
|
1202
|
+
...project.name ? { name: project.name } : {},
|
|
1203
|
+
...project.description ? { description: project.description } : {}
|
|
1204
|
+
} } : {},
|
|
1205
|
+
...scanBoards(root),
|
|
1206
|
+
scenes,
|
|
1207
|
+
frames
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
/** Variant groups. A group = 2+ frames in one DIRECTORY whose basenames
|
|
1211
|
+
* are letter-prefixed (`a-terminal`), or frames declaring `meta.of`. Group id = the
|
|
1212
|
+
* directory's id prefix (or meta.of); variant key = the letter (or meta.variant).
|
|
1213
|
+
* Nested directories scope alternatives inside a busy scene (checkout/payment/a-card).
|
|
1214
|
+
* States (empty.tsx, error.tsx) never letter-prefix, so they never misgroup.
|
|
1215
|
+
* Mutates entries in place: only frames whose group materializes keep the fields. */
|
|
1216
|
+
function inferVariantGroups(frames) {
|
|
1217
|
+
const dirOf = (id) => {
|
|
1218
|
+
const i = id.lastIndexOf("/");
|
|
1219
|
+
return i >= 0 ? id.slice(0, i) : "";
|
|
1220
|
+
};
|
|
1221
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
1222
|
+
for (const f of frames) {
|
|
1223
|
+
if (f.kind !== "tsx") {
|
|
1224
|
+
delete f.variantGroup;
|
|
1225
|
+
delete f.variant;
|
|
1226
|
+
continue;
|
|
1227
|
+
}
|
|
1228
|
+
let group = f.variantGroup;
|
|
1229
|
+
let key = f.variant;
|
|
1230
|
+
if (!group) {
|
|
1231
|
+
const base = f.id.slice(f.id.lastIndexOf("/") + 1);
|
|
1232
|
+
const m = /^([a-z])-.+$/.exec(base);
|
|
1233
|
+
if (!m) continue;
|
|
1234
|
+
group = dirOf(f.id);
|
|
1235
|
+
if (!group) continue;
|
|
1236
|
+
key = key ?? m[1];
|
|
1237
|
+
} else if (!key) {
|
|
1238
|
+
const m = /^([a-z])-.+$/.exec(f.id.slice(f.id.lastIndexOf("/") + 1));
|
|
1239
|
+
if (!m) {
|
|
1240
|
+
console.warn(`[marver] ${f.file} declares of:"${group}" but no variant key (add meta.variant or a letter prefix) - not grouped.`);
|
|
1241
|
+
delete f.variantGroup;
|
|
1242
|
+
delete f.variant;
|
|
1243
|
+
continue;
|
|
1244
|
+
}
|
|
1245
|
+
key = m[1];
|
|
1246
|
+
}
|
|
1247
|
+
f.variantGroup = group;
|
|
1248
|
+
f.variant = key;
|
|
1249
|
+
candidates.set(group, [...candidates.get(group) ?? [], f]);
|
|
1250
|
+
}
|
|
1251
|
+
for (const [group, members] of candidates) {
|
|
1252
|
+
if (new Set(members.map((m) => dirOf(m.id))).size > 1) {
|
|
1253
|
+
console.warn(`[marver] group "${group}" spans directories - variants must be siblings; not grouped.`);
|
|
1254
|
+
for (const m of members) {
|
|
1255
|
+
delete m.variantGroup;
|
|
1256
|
+
delete m.variant;
|
|
1257
|
+
}
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1260
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1261
|
+
const kept = [];
|
|
1262
|
+
for (const m of members.sort((a, b) => (a.variant ?? "").localeCompare(b.variant ?? ""))) {
|
|
1263
|
+
if (seen.has(m.variant)) {
|
|
1264
|
+
console.warn(`[marver] duplicate variant "${m.variant}" in group "${group}" (${m.file}) - not grouped.`);
|
|
1265
|
+
delete m.variantGroup;
|
|
1266
|
+
delete m.variant;
|
|
1267
|
+
continue;
|
|
1268
|
+
}
|
|
1269
|
+
seen.add(m.variant);
|
|
1270
|
+
kept.push(m);
|
|
1271
|
+
}
|
|
1272
|
+
if (kept.length < 2) for (const m of kept) {
|
|
1273
|
+
delete m.variantGroup;
|
|
1274
|
+
delete m.variant;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
for (const f of frames) if (f.variant && !f.variantGroup) delete f.variant;
|
|
1278
|
+
}
|
|
1279
|
+
/** Write design/manifest.json only when content changed. Returns the manifest either way. */
|
|
1280
|
+
function writeManifest(root, manifest) {
|
|
1281
|
+
const file = join(root, "design", "manifest.json");
|
|
1282
|
+
const next = JSON.stringify(manifest, null, 2) + "\n";
|
|
1283
|
+
const prev = existsSync(file) ? readFileSync(file, "utf8") : "";
|
|
1284
|
+
if (hash(prev) === hash(next)) return false;
|
|
1285
|
+
mkdirSync(join(root, "design"), { recursive: true });
|
|
1286
|
+
writeFileSync(file, next);
|
|
1287
|
+
return true;
|
|
1288
|
+
}
|
|
1289
|
+
//#endregion
|
|
1290
|
+
export { levelsIn as A, LEVEL as C, globRe as D, frontMatter$1 as E, tables as F, wordCount as I, looseTables as M, parseMap as N, hasGlob as O, proseLines as P, GENERATED as S, capabilityTable as T, STATUS_LABEL as _, noteFileFor as a, CITED_FILE as b, setSceneTitle as c, annotateBoards as d, planNames as f, PUBLISHABLE as g, PHASE_LABEL as h, manifest_exports as i, lf as j, isRecordTable as k, toFrameId as l, readContextFacts as m, isNoteFile as n, rendersDoc as o, planWithStage as p, layoutDocSource as r, scanFrames as s, affectedFrameIds as t, writeManifest as u, publishableStatus as v, availableLevels as w, EVIDENCE_COLUMN as x, CITATION as y };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { s as scanFrames } from "./manifest-DnAte_fB.mjs";
|
|
2
|
+
import { r as replay, t as asks } from "./events-DnK_AnrW.mjs";
|
|
3
|
+
import { a as readLog, i as listBoards } from "./comments-Zoch254k.mjs";
|
|
4
|
+
import { o as projectMarks } from "./marks-koRsbHfe.mjs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
//#region src/shared/marks.ts
|
|
7
|
+
const isNew = (m, id) => !!m && (m.changed[id] ?? 0) > (m.seen[id] ?? 0);
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/cli/marks.ts
|
|
10
|
+
/**
|
|
11
|
+
* `marver marks` (spec 26): what the human has not reviewed yet - the frames waiting on them (a
|
|
12
|
+
* Marver thread whose last word is Marver's, the ones that ask first) and the frames new since they
|
|
13
|
+
* looked. A read-only view of design/.local, a fresh scan of the frames and the comment logs:
|
|
14
|
+
* running it writes nothing, so it never starts the clock, and it works with dev off.
|
|
15
|
+
*/
|
|
16
|
+
function marksCommand(root, opts) {
|
|
17
|
+
const manifest = scanFrames(root);
|
|
18
|
+
const m = projectMarks(root, manifest);
|
|
19
|
+
const dir = join(root, "design", "comments");
|
|
20
|
+
const waiting = listBoards(dir).flatMap((b) => replay(readLog(dir, b)).flatMap((t) => {
|
|
21
|
+
if (t.resolved || !t.frame || !(t.agent || t.replies.some((r) => r.agent))) return [];
|
|
22
|
+
const last = t.replies.length ? t.replies[t.replies.length - 1] : t;
|
|
23
|
+
if (!last.agent) return [];
|
|
24
|
+
return [{
|
|
25
|
+
frame: t.frame,
|
|
26
|
+
thread: t.id,
|
|
27
|
+
board: b,
|
|
28
|
+
asks: asks(last, last === t),
|
|
29
|
+
body: (last.body ?? "").replace(/\s+/g, " ").trim()
|
|
30
|
+
}];
|
|
31
|
+
})).sort((a, b) => Number(b.asks) - Number(a.asks));
|
|
32
|
+
const fresh = m ? manifest.frames.map((f) => f.id).filter((id) => isNew(m, id)) : [];
|
|
33
|
+
if (opts.json) {
|
|
34
|
+
console.log(JSON.stringify({
|
|
35
|
+
started: !!m,
|
|
36
|
+
waiting,
|
|
37
|
+
new: fresh
|
|
38
|
+
}, null, 2));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (!m) console.log(" (marks start with the next `marver dev` - nothing is new until then)");
|
|
42
|
+
const pad = (s, n) => s.length >= n ? s + " " : s + " ".repeat(n - s.length);
|
|
43
|
+
const w = Math.max(0, ...waiting.map((x) => x.frame.length)) + 2;
|
|
44
|
+
if (waiting.length) waiting.forEach((x, i) => console.log(`${pad(i ? "" : `waiting on you (${waiting.length})`, 21)}${pad(x.frame, w)}${pad(x.asks ? "asks" : "", 6)}"${x.body.length > 60 ? x.body.slice(0, 57) + "..." : x.body}"`));
|
|
45
|
+
else console.log(`${pad("waiting on you", 21)}nothing`);
|
|
46
|
+
const shown = fresh.slice(0, 6).join(", ") + (fresh.length > 6 ? `, ... (+${fresh.length - 6})` : "");
|
|
47
|
+
console.log(`${pad(fresh.length ? `new (${fresh.length})` : "new", 21)}${fresh.length ? shown : "nothing"}`);
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { marksCommand };
|