Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Handoff: the build workflow resumes stage by stage, guards rebuilt bases, and PR templates

Claude76b819acb826
diff --git a/docs/handoff/make-workflow.mjs b/docs/handoff/make-workflow.mjs
index d74bb7d2..fc0c2ab2 100755
--- a/docs/handoff/make-workflow.mjs
+++ b/docs/handoff/make-workflow.mjs
@@ -1,10 +1,11 @@
#!/usr/bin/env node
// Writes the build workflow script from docs/handoff/queue.json and workflow.body.js (docs/HANDOFF.md explains it).
// Usage: node docs/handoff/make-workflow.mjs <out.js> --trailer-file <file> [--repo <dir>] [--wt <dir>] [--ext <dir>]
-// [--base <branch>] [--skip key,key] [--only R,O,A] [--journal <journal.jsonl>]… [--done <results.json>]
-// [--remove-worktrees]
-// --trailer-file the lines every commit message ends with (this session's attribution lines)
-// --repo the checkout the integrator merges in (default: this repository's top folder)
+// [--base <branch>] [--skip key,key] [--only R,O] [--journal <journal.jsonl>]… [--done <results.json>]
+// [--save-done] [--remove-worktrees]
+// --trailer-file the lines every commit message ends with (the attribution lines your session was given)
+// --repo the checkout the integrator merges in (default: this repository's main checkout, even when this
+// script runs from a linked worktree)
// --wt where package worktrees go (default: <repo>/../wt)
// --ext the folder of owner-shared and downloaded inputs that briefs call @EXT@ (default: <repo>/../ext)
// --skip packages to leave out of their lanes (packages already merged into the base, found by their
@@ -13,9 +14,16 @@
// --journal a stopped build workflow's journal.jsonl (in its transcript folder; repeat for several runs, oldest
// first): the implement, review and fix stages it finished are reused, and packages its integrator
// merged are left out
-// --done a JSON object { key: { impl?, review?, fix? } } of finished stages, merged over the queue's `done`
-// and the journals'
+// --done a JSON object { key: { impl?, review?, fix? } } of finished stages (the agents' reports)
+// --save-done also writes the merged finished stages of the queued packages that aren't merged yet into
+// queue.json `done` (before a session ends: then commit queue.json to the base and push)
// --remove-worktrees the integrator removes clean worktrees of merged branches (only with the owner's go-ahead)
+// Finished stages are merged stage by stage, oldest source first: the queue's `done`, then each journal, then --done.
+// A source that brings an earlier stage again (a new implement report) drops the later stages older sources had,
+// since those were made from the earlier work.
+// Before writing, it checks the branches with work in progress (o/<key>, local or on origin): a branch whose
+// BASE..o/<key> holds an integrator's merge of another package was cut from a base that has since been rebuilt, and
+// merging it would bring that work back, so the script stops and says which branches to move first.
import { execFileSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
@@ -34,7 +42,9 @@ if (!out || out.startsWith("--") || !trailerFile) {
process.exit(2);
}
-const repo = path.resolve(opt("--repo") ?? execFileSync("git", ["-C", here, "rev-parse", "--show-toplevel"], { encoding: "utf8" }).trim());
+// The main checkout: the parent of the shared git directory (a linked worktree's own top folder is not it).
+const mainCheckout = () => path.dirname(execFileSync("git", ["-C", here, "rev-parse", "--path-format=absolute", "--git-common-dir"], { encoding: "utf8" }).trim());
+const repo = path.resolve(opt("--repo") ?? mainCheckout());
const wt = path.resolve(opt("--wt") ?? path.join(repo, "..", "wt"));
const ext = path.resolve(opt("--ext") ?? path.join(repo, "..", "ext"));
const queue = JSON.parse(fs.readFileSync(path.join(here, "queue.json"), "utf8"));
@@ -45,26 +55,44 @@ const only = opt("--only")?.split(",").filter(Boolean);
// Packages the integrator merged: "Merge branch 'o/<key>' into <base>" on the base's history (local or origin).
const git = (...a) => execFileSync("git", ["-C", repo, ...a], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
-const baseRef = [base, `origin/${base}`].find((r) => { try { git("rev-parse", "--verify", "-q", r); return true; } catch { return false; } });
+const exists = (ref) => { try { git("rev-parse", "--verify", "-q", ref); return true; } catch { return false; } };
+const baseRef = [base, `origin/${base}`].find(exists);
if (!baseRef) throw new Error(`no branch ${base} or origin/${base} in ${repo}: git fetch origin first`);
-const merged = new Set([...git("log", "--format=%s", baseRef).matchAll(/^Merge branch 'o\/([^']+)'/gm)].map((m) => m[1]));
+const mergedKeys = (subjects) => [...subjects.matchAll(/^Merge branch 'o\/([^']+)'/gm)].map((m) => m[1]);
+const merged = new Set(mergedKeys(git("log", "--format=%s", baseRef)));
// Stages finished by earlier build workflows: each journal line is {type, key, label?, result?}.
-const fromJournals = {};
+const STAGES = ["impl", "review", "fix"];
+const journals = [];
argv.forEach((a, i) => {
if (a !== "--journal") return;
const label = {};
+ const stages = {};
for (const line of fs.readFileSync(argv[i + 1], "utf8").split("\n")) {
if (!line.trim()) continue;
const j = JSON.parse(line);
if (j.label) label[j.key] = j.label;
if (j.type !== "result" || !label[j.key] || !j.result) continue;
const [stage, key] = label[j.key].split(":");
- if (["impl", "review", "fix"].includes(stage)) (fromJournals[key] ??= {})[stage] = j.result;
+ if (STAGES.includes(stage)) {
+ const s = (stages[key] ??= {});
+ // A stage run again makes the later stages of an earlier attempt stale.
+ for (const later of STAGES.slice(STAGES.indexOf(stage) + 1)) delete s[later];
+ s[stage] = j.result;
+ }
if (stage === "merge" && j.result.merged?.length) merged.add(key);
}
+ journals.push(stages);
});
-const done = { ...queue.done, ...fromJournals, ...(opt("--done") ? JSON.parse(fs.readFileSync(opt("--done"), "utf8")) : {}) };
+const doneFile = opt("--done") ? JSON.parse(fs.readFileSync(opt("--done"), "utf8")) : {};
+const done = {};
+for (const src of [queue.done ?? {}, ...journals, doneFile]) {
+ for (const [k, v] of Object.entries(src)) {
+ const first = STAGES.findIndex((s) => s in v);
+ const kept = Object.fromEntries(Object.entries(done[k] ?? {}).filter(([s]) => first === -1 || STAGES.indexOf(s) < first));
+ done[k] = { ...kept, ...v };
+ }
+}
const lanes = {};
for (const [name, keys] of Object.entries(queue.lanes)) {
@@ -76,11 +104,36 @@ const pkgs = {};
for (const key of Object.values(lanes).flat()) {
const p = queue.packages[key];
if (!p) throw new Error(`queue.json has no package ${key}`);
- pkgs[key] = { key, title: p.title, phase: p.phase, brief: p.brief.replaceAll("@EXT@", ext) };
+ const wip = queue.wip?.[key];
+ pkgs[key] = { key, title: p.title, phase: p.phase, brief: p.brief.replaceAll("@EXT@", ext), ...(wip && { wip }) };
}
const keep = Object.fromEntries(Object.entries(done).filter(([k]) => k in pkgs));
const phases = [...new Set(Object.values(pkgs).map((p) => p.phase))];
+// Before a session ends: keep the finished stages of every queued package that isn't merged yet in queue.json `done`.
+if (argv.includes("--save-done")) {
+ const queued = new Set(Object.values(queue.lanes).flat());
+ queue.done = Object.fromEntries(Object.entries(done).filter(([k]) => queued.has(k) && !merged.has(k)));
+ fs.writeFileSync(path.join(here, "queue.json"), `${JSON.stringify(queue, null, 1)}\n`);
+ const saved = Object.entries(queue.done).map(([k, v]) => `${k} (${Object.keys(v).join(", ")})`);
+ console.log(`queue.json done now holds: ${saved.join(", ") || "nothing"}; commit it to ${base} and push (docs/HANDOFF.md, "Before a session ends")`);
+}
+
+// Branches cut from a base that has since been rebuilt (docs/HANDOFF.md, "Work in progress").
+const stale = [];
+for (const key of Object.keys(pkgs)) {
+ for (const ref of [`refs/heads/o/${key}`, `refs/remotes/origin/o/${key}`]) {
+ if (!exists(ref)) continue;
+ const others = [...new Set(mergedKeys(git("log", "--format=%s", `${baseRef}..${ref}`)).filter((k) => k !== key))];
+ const named = others.slice(0, 5).map((k) => `o/${k}`).join(", ") + (others.length > 5 ? ` and ${others.length - 5} more` : "");
+ if (others.length) stale.push(`${ref.replace(/^refs\/(heads|remotes)\//, "")} (it carries merges of ${named})`);
+ }
+}
+if (stale.length) {
+ console.error(`These branches were cut from a base that has since been rebuilt; move their own commits onto ${baseRef} first (git rebase --onto ${baseRef} <old base> <branch>; docs/HANDOFF.md, "Work in progress"), or leave the packages out with --skip:\n ${stale.join("\n ")}`);
+ process.exit(1);
+}
+
const meta = {
name: "fuobe-continue",
description: `Continue Fuobe's build queue: lanes ${Object.keys(lanes).join(", ")}, ${Object.keys(pkgs).length} packages, each implement → review → fix → merge into ${base}`,
@@ -91,6 +144,7 @@ const script = [
`export const meta = ${JSON.stringify(meta, null, 2)}`,
`const REPO = ${j(repo)}`,
`const WT = ${j(wt)}`,
+ `const EXT = ${j(ext)}`,
`const BASE = ${j(base)}`,
`const PLAN = 'docs/research/fuobe-originals-recipes-5.md'`,
`const TRAILER = ${j(trailer)}`,
@@ -106,4 +160,5 @@ if (bytes >= 512 * 1024) throw new Error(`the script is ${bytes} bytes; the Work
fs.writeFileSync(out, script);
const left = Object.values(queue.lanes).flat().filter((k) => merged.has(k));
if (left.length) console.log(`already merged into ${baseRef}, left out: ${left.join(", ")}`);
-console.log(`${out}: ${Object.keys(pkgs).length} packages in lanes ${Object.entries(lanes).map(([n, k]) => `${n} (${k.length}, first ${k[0]})`).join(", ")}; reused stages for ${Object.keys(keep).join(", ") || "none"}; ${bytes} bytes`);
+const reused = Object.entries(keep).map(([k, v]) => `${k} (${Object.keys(v).join(", ")})`);
+console.log(`${out}: ${Object.keys(pkgs).length} packages in lanes ${Object.entries(lanes).map(([n, k]) => `${n} (${k.length}, first ${k[0]})`).join(", ")}; reused stages for ${reused.join(", ") || "none"}; ${bytes} bytes`);
diff --git a/docs/handoff/pr-describe.js b/docs/handoff/pr-describe.js
new file mode 100644
index 00000000..bcf3def0
--- /dev/null
+++ b/docs/handoff/pr-describe.js
@@ -0,0 +1,179 @@
+export const meta = {
+ name: 'fuobe-pr-describe',
+ description: 'Write a Fuobe pull request description from the merged packages: area readers → writer → three fact-check lenses (accuracy, completeness, clarity) → reviser, which saves the title and body to files',
+ whenToUse: 'Cutting a PR from a snapshot branch (docs/HANDOFF.md, "Cutting a PR"), after verify.sh; pass the args object described at the top of the script',
+ phases: [{ title: 'Read' }, { title: 'Write' }, { title: 'Check' }, { title: 'Revise' }],
+}
+
+// The PR description template (docs/HANDOFF.md, "Cutting a PR"). Run it with the Workflow tool:
+// Workflow({ scriptPath: "docs/handoff/pr-describe.js", args: { … } })
+// args (an object; the Workflow tool passes it to the script as `args`):
+// repo the checkout to read from, read-only, by refs only (the main checkout is fine while others work in it)
+// head the PR's branch, e.g. 'claude/fuobe-r5-batch-8'
+// base main's commit this PR builds on (the last PR's merge on main, or git merge-base origin/main <head>)
+// pr the PR's number (or the next one), used in wording only
+// round how the title starts, e.g. 'Round 5, part 3'
+// reports a folder holding <package>.json per merged package: { impl, review, fix, merge }, the build workflow's
+// reports (from its journal, or docs/handoff/queue.json `done`)
+// out a folder where the reviser writes title.txt, body.md and notes.md (the result you post)
+// history a few sentences on how the branch was made: what was merged in which order (the first-parent merges and
+// their commits), main merged in, commits added on top
+// areas [{ key, title, pkgs: [[packageKey, mergeCommit], …] }]: one reader per area; a merge commit may carry a
+// note after a space, e.g. 'f105d19 (integration fix 4e8359f)'
+// other optional: commits outside the areas and what they are (research notes, the handoff, check fixes)
+// notInPr what "Not in this PR" lists: the queue's next packages (docs/HANDOFF.md) and owner decisions pending
+// handoff optional: what "Handoff for the next session" says (what docs/HANDOFF.md and docs/handoff/ now hold)
+// The body keeps one <!-- CHECKS --> line under "## How it was checked": fill it from verify.sh's summary before posting.
+
+const A = args || {}
+const missing = ['repo', 'head', 'base', 'round', 'reports', 'out', 'history', 'areas', 'notInPr'].filter((k) => A[k] === undefined || A[k] === '')
+if (missing.length) throw new Error(`pr-describe: missing args ${missing.join(', ')} (the comment at the top of the script lists them)`)
+const { repo: REPO, head: HEAD, base: BASE, reports: REPORTS, out: OUT } = A
+const PR = A.pr ? `PR #${A.pr}` : 'this PR'
+
+const RULES = `Ground rules:
+- Work read-only in ${REPO} using refs only: git log / git show / git diff / git show ${HEAD}:<path>. Do not checkout, merge, commit, stash or edit anything, and do not read the working tree's files (other agents may be changing that checkout); read files at the ref instead (git show ${HEAD}:path, git grep <pattern> ${HEAD} -- <paths>).
+- The range for ${PR} is ${BASE}..${HEAD}. How the branch was made: ${A.history} Use git log --first-parent ${BASE}..${HEAD} and git diff ${BASE} ${HEAD} (the exact change this PR makes to main).
+- Implementer/reviewer/fixer reports per package are in ${REPORTS}/<package>.json ({impl, review, fix, merge}; the fix stage ran last, so fix.finalSummary / fix.applied / fix.left are the most current; merge is the integrator's report). Reports can be stale or overstate: every claim you pass on must be backed by the diff or by a check the report names (say which). If code and report disagree, the code wins and you say so.
+- Fuobe is an open-source alternative to Higgsfield: each feature runs on paid cloud models (fal.ai / Replicate with the user's own key) and on open-weight models through a ComfyUI ("open engine"), with a demo mode (mock provider, no keys). With public sign-up on (docs/public-signup.md), guests browse read-only and accounts run only on their own ComfyUI.`
+
+const PKG_SCHEMA = {
+ type: 'object',
+ properties: {
+ area: { type: 'string' },
+ packages: { type: 'array', items: { type: 'object', properties: {
+ key: { type: 'string' },
+ mergeCommit: { type: 'string' },
+ oneLine: { type: 'string', description: 'what this package gives a user, one plain sentence' },
+ userFacing: { type: 'array', items: { type: 'string' }, description: 'what a person can now do, where (page/studio/button), in plain words' },
+ cloud: { type: 'array', items: { type: 'string' }, description: 'cloud models/endpoints used and what they do (with prices only if the code shows them)' },
+ open: { type: 'array', items: { type: 'string' }, description: 'ComfyUI workflows/model ids used, custom node packs or model downloads they need' },
+ routesAndPages: { type: 'array', items: { type: 'string' }, description: 'new or changed pages and API routes (path + one phrase), and what guests and accounts get from them under public sign-up' },
+ migrations: { type: 'array', items: { type: 'string' } },
+ fixesToExisting: { type: 'array', items: { type: 'string' }, description: 'behaviour of features that already existed that changed or got fixed' },
+ verified: { type: 'array', items: { type: 'string' }, description: 'what was actually checked and how (tests, live ComfyUI run on CPU, browser screenshots at 1440/390 light/dark…), per the report AND consistent with the diff' },
+ notVerifiedOrLeft: { type: 'array', items: { type: 'string' }, description: 'built but not run end to end, known gaps, things left for later' },
+ reviewerNotes: { type: 'array', items: { type: 'string' }, description: 'risky spots or things a reviewer should look at' },
+ evidence: { type: 'array', items: { type: 'string' }, description: 'files / commits backing the key claims' },
+ }, required: ['key', 'oneLine', 'userFacing', 'verified', 'notVerifiedOrLeft', 'evidence'] } },
+ crossCutting: { type: 'array', items: { type: 'string' } },
+ discrepancies: { type: 'array', items: { type: 'string' }, description: 'places where a report claims something the diff does not back, or vice versa' },
+ },
+ required: ['area', 'packages', 'crossCutting', 'discrepancies'],
+}
+
+const readArea = (a) => agent(`${RULES}
+
+You are summarising one area of a large pull request so that its description is accurate and complete. Area: ${a.title}.
+Packages and the merge commits that brought them in (first-parent merges on ${HEAD}):
+${a.pkgs.map(([k, m]) => { const c = m.split(' ')[0]; return `- ${k}: merge ${m} (its changes: git diff ${c}^1 ${c}, plus the integration fix commit if named; its commits: git log --oneline ${c}^1..${c}^2; report: ${REPORTS}/${k}.json, whose merge field, if present, is the integrator's report)` }).join('\n')}
+
+For each package: read the report, then the diff and commit messages, and the key files at ${HEAD}. Produce what a person merging this PR needs to know: what users can now do and where, what each engine uses (cloud model endpoints; open ComfyUI workflow ids, custom node packs, model downloads), new pages and API routes (and how they answer guests and accounts under public sign-up), DB migrations (src/server/db.ts MIGRATIONS entries this package added), changes to existing behaviour, what was verified and how vs only built, what is left, and spots a reviewer should look at. Be concrete (names of studios, buttons, routes, model ids) and plain-spoken. Note any report claim the code does not back under discrepancies.`, { label: `read:${a.key}`, phase: 'Read', schema: PKG_SCHEMA })
+
+const CROSS_SCHEMA = {
+ type: 'object',
+ properties: {
+ standaloneCommits: { type: 'array', items: { type: 'object', properties: { commit: { type: 'string' }, summary: { type: 'string' } }, required: ['commit', 'summary'] } },
+ research: { type: 'array', items: { type: 'string' }, description: 'research docs added/changed in the range and what each says, in one or two lines' },
+ migrations: { type: 'array', items: { type: 'string' }, description: 'every MIGRATIONS entry added in the range, with what it changes and which package added it' },
+ newRoutes: { type: 'array', items: { type: 'string' }, description: 'every new src/app/api route and every new page under src/app in the range' },
+ comfyLibrary: { type: 'string', description: 'workflow count before/after in workflows/comfyui/manifest.json, new workflow ids grouped by feature, any new custom node packs (customNodes, workflows/comfyui/packs.json) and large model downloads (sizeGb), and whether workflows/comfyui/requirements.json (the GPU pre-flight index) covers them' },
+ dependencies: { type: 'array', items: { type: 'string' }, description: 'package.json / lockfile dependency changes, Python/uv deps, scripts' },
+ settingsAndEnv: { type: 'array', items: { type: 'string' }, description: 'new settings, env vars, keys, data dir changes' },
+ publicSignup: { type: 'array', items: { type: 'string' }, description: 'how the new routes, pages and runs follow public sign-up (src/lib/guest-access.ts, tests/public-signup.test.ts) and the GPU pre-flight board (src/server/gpu/tools.ts), and any that do not' },
+ tests: { type: 'string', description: 'test files added/changed (count and the notable ones); e2e scripts added' },
+ upgradeNotes: { type: 'array', items: { type: 'string' }, description: 'what someone upgrading an existing install must know (migrations run automatically or not, new ComfyUI nodes/models to install, breaking changes, removed things)' },
+ mainInteraction: { type: 'string', description: "main's docs (README.md, docs/FEATURES.md, docs/SELF-HOSTING.md, docs/DEVELOPMENT.md, docs/STATUS.md, docs/ARCHITECTURE.md, docs/research/README.md) describe main as of the base. What in this PR makes them out of date (new features, counts, settings, upgrade steps, what is next)? List what the docs would need to say." },
+ uncovered: { type: 'array', items: { type: 'string' }, description: 'anything in the range not part of the areas or the other commits named' },
+ },
+ required: ['standaloneCommits', 'research', 'migrations', 'newRoutes', 'comfyLibrary', 'dependencies', 'settingsAndEnv', 'publicSignup', 'tests', 'upgradeNotes', 'mainInteraction', 'uncovered'],
+}
+
+const AREA_KEYS = A.areas.flatMap((a) => a.pkgs.map(([k]) => k)).join(', ')
+
+const readCross = () => agent(`${RULES}
+
+You cover the cross-cutting parts of this PR (the area readers cover the packages: ${AREA_KEYS}). First-parent history: git log --first-parent --oneline ${BASE}..${HEAD}. ${A.other ? `Commits that are not in the areas: ${A.other}` : 'Name every first-parent commit that is not one of the areas\' merges.'} The integrator's reports are the merge field of ${REPORTS}/<package>.json. Also cover the owner's decisions behind the build (docs/handoff/owner-decisions.json at ${HEAD}): no Higgsfield models or API (confirm with git grep -i higgsfield ${HEAD} -- src scripts bin skills workflows package.json that only history/comparison wording is left); licences are information, not gates (Settings → Models & licences: check new models, packs and libraries record theirs); each engine does all it can (the cloud uses only hosted models, with no substitute model; the open engine keeps every capability it has); and public sign-up (new routes, pages and runs follow src/lib/guest-access.ts and tests/public-signup.test.ts; new studios show on the GPU pre-flight board). Check where this PR follows them and where it doesn't.
+Then take whole-range inventories with git (diff ${BASE} ${HEAD}): every DB migration added to MIGRATIONS in src/server/db.ts (and which package added it), every new API route and page, the ComfyUI workflow library change (manifest.json counts before/after, new ids, customNodes packs, model sizes, requirements.json), dependency changes (package.json, pnpm-lock.yaml, Python), new settings/env vars and data files, tests added (count, notable; e2e scripts), research docs (docs/research/*) added or changed. Also say what in main's docs this PR makes out of date. Finish with upgrade notes for someone with an existing install.`, { label: 'read:cross-cutting', phase: 'Read', schema: CROSS_SCHEMA })
+
+phase('Read')
+const reads = await parallel([...A.areas.map((a) => () => readArea(a)), () => readCross()])
+const areaSummaries = reads.slice(0, A.areas.length).filter(Boolean)
+const cross = reads[A.areas.length]
+log(`Read: ${areaSummaries.length}/${A.areas.length} areas${cross ? ' + cross-cutting' : ' (cross-cutting reader failed)'}`)
+
+const BODY = {
+ type: 'object',
+ properties: { title: { type: 'string' }, body: { type: 'string' }, notes: { type: 'string' } },
+ required: ['title', 'body'],
+}
+
+const STYLE = `Style for the PR text:
+- Audience: the repo owner (product-minded, merges and runs Fuobe, also on Windows via start.bat) and any reviewer. Plain words, short sentences, no jargon a user wouldn't know without a gloss. Lead with what people can now do; engineering detail goes lower.
+- Title: a plain summary under ~100 characters, starting "${A.round}:".
+- Body in GitHub Markdown: a short opening paragraph (what this PR is, from the history above; counts of commits and files); "## What's new" with one ### per feature area (bullets: what you can do, where, cloud vs open engine, and what guests and accounts get under public sign-up where it matters; a compact table per area is fine where it reads better); "## Fixes and changes to existing features"; "## Under the hood" (migrations, API routes, ComfyUI library and the GPU pre-flight index, dependencies, settings); "## Research" only if research notes changed (a plan is not a feature); ${A.handoff ? `"## Handoff for the next session" (${A.handoff}; a few bullets, linking docs/HANDOFF.md); ` : ''}"## Upgrading" (only what someone with an existing install must do or know); "## How it was checked" containing exactly the line <!-- CHECKS --> and nothing else (filled in later from the real run); "## Known gaps" (real ones only, from the verified notVerifiedOrLeft items); "## Not in this PR" (short: ${A.notInPr}); "## Docs" (one line: the PR branch carries the docs update for this batch in README.md, docs/FEATURES.md, docs/SELF-HOSTING.md, docs/DEVELOPMENT.md, docs/STATUS.md and docs/ARCHITECTURE.md, as far as the docs pass changed them).
+- Be exact and honest: say "verified" only for what was actually run (tests, a live CPU ComfyUI run, a browser check) and "built" for what wasn't run end to end. No marketing adjectives. No claims you can't back from the summaries.
+- Never mention AI model identifiers of the assistant that wrote this; model names of the image/video/audio models the app uses are fine. No local file paths (/home/..., /tmp/...), no internal hostnames, no secrets, no email addresses. No bare @handles (GitHub would notify them): put such text in backticks. Do not add a signature or footer; one is appended later.
+- Aim for a body that a person can scan in a few minutes: roughly 6–14k characters. Collapse long inventories (routes, workflow ids, test files) inside <details><summary>…</summary> blocks.`
+
+phase('Write')
+const draft = await agent(`You write the pull request description for Fuobe ${A.round} (${BASE}..${HEAD}). Facts to work from (only these; each was checked against the diff by a reader):
+AREA SUMMARIES:
+${JSON.stringify(areaSummaries, null, 1)}
+CROSS-CUTTING:
+${JSON.stringify(cross, null, 1)}
+
+${STYLE}
+
+You may spot-check facts with read-only git commands in ${REPO} (git show ${HEAD}:<path>, git diff ${BASE} ${HEAD} -- <path>); never change anything. Return the title and the body, and in notes anything you left out or were unsure about.`, { label: 'write:draft', phase: 'Write', schema: BODY })
+
+const CHECK = {
+ type: 'object',
+ properties: {
+ issues: { type: 'array', items: { type: 'object', properties: {
+ kind: { type: 'string', enum: ['wrong', 'overstated', 'missing', 'unclear', 'style'] },
+ severity: { type: 'string', enum: ['high', 'medium', 'low'] },
+ quote: { type: 'string', description: 'the exact text in the draft this is about (empty for missing)' },
+ evidence: { type: 'string', description: 'git command output / file+line that shows the problem' },
+ correction: { type: 'string', description: "the replacement or addition, written in the PR's style" },
+ }, required: ['kind', 'severity', 'evidence', 'correction'] } },
+ verdict: { type: 'string' },
+ },
+ required: ['issues', 'verdict'],
+}
+
+const LENSES = [
+ { key: 'accuracy', prompt: 'ACCURACY lens. Go through the draft claim by claim (every bullet, table cell, number and name: routes, model ids, workflow ids, migrations, counts, prices, "verified" statements). For each, find the backing in the diff or the reports; flag anything wrong, misnamed, or overstated (especially "verified" claims that were only built, and anything claimed for an engine that the code doesn\'t wire). Default to flagging when you cannot find backing.' },
+ { key: 'completeness', prompt: `COMPLETENESS lens. Independently sweep the diff (git diff --stat ${BASE} ${HEAD}; new files; src/app routes and pages; MIGRATIONS; manifest.json and requirements.json; package.json; settings; docs/research) and the commit messages (git log --no-merges --format='%h %s' ${BASE}..${HEAD}) for user-visible features, behaviour changes, migrations, new dependencies or ComfyUI requirements, public sign-up behaviour, and upgrade-relevant changes that the draft leaves out or under-explains. Only flag things a person merging or upgrading would want to know; give the exact addition.` },
+ { key: 'clarity', prompt: 'CLARITY lens, as the repo owner reading it on a phone: is it scannable, plain, and does it lead with what people can do? Flag jargon without a gloss, vague lines that don\'t say where to find a feature, walls of text that belong in <details>, inconsistent names for the same thing, and anything in the "Not in this PR" / "Known gaps" sections that would confuse. Also check the style rules: no assistant model ids, no local paths or hostnames, no bare @handles, no footer, contains exactly one <!-- CHECKS --> line under "## How it was checked".' },
+]
+
+phase('Check')
+const checks = draft ? (await parallel(LENSES.map((l) => () => agent(`${RULES}
+
+You fact-check a pull request description before it is posted. ${l.prompt}
+
+${STYLE}
+
+THE DRAFT (title, then body):
+${draft.title}
+---
+${draft.body}`, { label: `check:${l.key}`, phase: 'Check', schema: CHECK })))).filter(Boolean) : []
+log(`Check: ${checks.map((c) => `${c.issues.length} issues`).join(', ') || 'no draft to check'}`)
+
+phase('Revise')
+const final = draft ? await agent(`${RULES}
+
+You produce the final pull request title and body. Start from the draft, apply every correction below that you confirm (re-check high/medium ones with read-only git yourself; drop corrections that don't hold and list them in notes with why), and keep the style rules.
+
+${STYLE}
+
+DRAFT TITLE: ${draft.title}
+DRAFT BODY:
+${draft.body}
+
+CHECKER FINDINGS:
+${JSON.stringify(checks, null, 1)}
+
+Then save the result as files (create the folder if needed; write nothing else anywhere): the final title on one line in ${OUT}/title.txt, the final body (still containing exactly one <!-- CHECKS --> line under "## How it was checked") in ${OUT}/body.md, and in ${OUT}/notes.md what you changed and what you rejected. Return the same title, body and notes.`, { label: 'revise:final', phase: 'Revise', schema: BODY }) : null
+log(final ? `Saved ${OUT}/title.txt, ${OUT}/body.md and ${OUT}/notes.md: "${final.title}"` : 'No description: the writer or the reviser failed (see the agents above)')
diff --git a/docs/handoff/pr-docs.js b/docs/handoff/pr-docs.js
new file mode 100644
index 00000000..86149820
--- /dev/null
+++ b/docs/handoff/pr-docs.js
@@ -0,0 +1,96 @@
+export const meta = {
+ name: 'fuobe-pr-docs',
+ description: "Update Fuobe's docs for a PR on its branch: writers per doc group → accuracy and staleness checkers → reviser (uncommitted edits in the PR's worktree)",
+ whenToUse: 'The docs pass before a PR (docs/HANDOFF.md, "Cutting a PR"), after pr-describe.js; pass the args object described at the top of the script',
+ phases: [{ title: 'Write' }, { title: 'Check' }, { title: 'Revise' }],
+}
+
+// The docs pass template (docs/HANDOFF.md, "Cutting a PR"). Run it with the Workflow tool:
+// Workflow({ scriptPath: "docs/handoff/pr-docs.js", args: { … } })
+// args (an object; the Workflow tool passes it to the script as `args`):
+// worktree the PR branch's worktree, where the writers edit (nothing is committed: review the diff, then commit it)
+// docsBase the commit on main the docs describe today (the last PR's merge on main)
+// pr the PR's number, used in wording only
+// round how the docs name this batch, e.g. 'round 5, part 3'
+// summary what this PR adds, a paragraph: the features and packages, and what each runs on, on each engine
+// notYet what is still not in the branch (the queue in docs/HANDOFF.md), for "what's next" only
+// facts a folder holding the PR description as body.md (pr-describe.js's output; its "How it was checked" section
+// is the real verification of the branch) and the packages' reports as reports/<package>.json
+// files optional: [{ key, files, brief }] to replace the default writer assignments below
+// It returns nothing; the reviser's summary is logged, and the edits are in the worktree.
+
+const A = args || {}
+const missing = ['worktree', 'docsBase', 'round', 'summary', 'notYet', 'facts'].filter((k) => A[k] === undefined || A[k] === '')
+if (missing.length) throw new Error(`pr-docs: missing args ${missing.join(', ')} (the comment at the top of the script lists them)`)
+const { worktree: WT, docsBase: BASE, facts: F } = A
+const PR = A.pr ? `PR #${A.pr}` : 'this PR'
+
+const DOCS = 'README.md, docs/FEATURES.md, docs/SELF-HOSTING.md, docs/DEVELOPMENT.md, docs/STATUS.md, docs/ARCHITECTURE.md, docs/public-signup.md, docs/cli.md, docs/research/README.md, scripts/comfy/README.md, scripts/eval/README.md and skills/README.md'
+
+const CONTEXT = `Fuobe is an open-source alternative to Higgsfield: every studio runs on paid cloud models (fal.ai / Replicate with the user's own key) and on open-weight models through the user's own ComfyUI ("Open source" engine), with a demo mode that needs neither. The owner's decisions (docs/handoff/owner-decisions.json): Fuobe uses no Higgsfield models and no Higgsfield API; licences are information, not gates (Settings → Models & licences); each engine does all it can (the cloud uses only models that are hosted, with no substitute model, and the open engine keeps every capability it has even when the cloud can't match it); and accounts are the owner's public sign-up (docs/public-signup.md: guests browse, accounts see a guest view of the owner's library and run only on their own ComfyUI). You are updating the documentation in the git worktree ${WT}, the branch of ${PR}, which already contains main.
+
+The docs describe main as of ${BASE}. ${PR} is ${A.round}: ${A.summary} Read the range with git log --first-parent --format='%h %s' ${BASE}..HEAD and git diff ${BASE} HEAD.
+Facts already checked against the code: the PR description is ${F}/body.md (its "How it was checked" section is the real verification of this branch). Per-package reports: ${F}/reports/<package>.json (fix.finalSummary / fix.applied / fix.left are the most current; code wins over reports). docs/HANDOFF.md lists what is queued and what is waiting on the owner.
+Still NOT in this branch (for "what's next" only, never described as available): ${A.notYet}
+
+Where things live (main's layout): README.md is the product page (short sections, a feature grid, a quick start, "Upgrading from an earlier version" under "Self-hosting and security"; details go to the docs it links); docs/FEATURES.md is the full feature list; docs/SELF-HOSTING.md covers install, engine mode, the AI helper, keys, security, environment variables and ComfyUI; docs/DEVELOPMENT.md covers checks, browser checks, the evaluation harness and where things are; docs/STATUS.md is what is verified and the feature matrix; docs/ARCHITECTURE.md is how it is built.
+
+Rules:
+- Edit only the files you are assigned, in ${WT}. Do not commit, stash, switch branches or touch any other checkout. Read code at HEAD of ${WT} to confirm facts; git log/show/diff are fine.
+- Update, don't rewrite: keep each doc's structure, tone, tables and legend; change what is now wrong, add what is new, remove only what is no longer true. Plain words, short sentences, in the docs' existing voice. Dated history (what an earlier round or PR did) stays as history. Keep README.md short: new detail goes to the doc it links.
+- Be honest about verification, using STATUS.md's legend: ✅ verified (actually run here: tests, a live CPU ComfyUI, the browser), 🟢 built (not run with real keys or GPU weights), 🟡 partial, ⬜ not started. Say plainly when no paid key and no GPU were used.
+- Every number, route, model id, workflow id, price and name you write must be backed by the code at HEAD or by the fact-checked files above. If you can't back it, leave it out.
+- No local paths like /home/... or /tmp/... in the docs, no secrets, no email addresses, no assistant model names.`
+
+const FILES = A.files || [
+ { key: 'status', files: 'docs/STATUS.md', brief: `docs/STATUS.md: set "Last updated" to ${A.round}. Section 1: replace the checks for the current state with the PR description's "How it was checked" and add rows for what each package verified (per its report and the description), keeping rows that still hold, marked as earlier. Section 2 (feature matrix): add or update rows for this PR's features; say what each runs on, on each engine, what guests and accounts get under public sign-up where it matters, and how it was verified. Section 3: add the real known gaps from the description. Section 4 (what's next): the "Still NOT in this branch" list, pointing to docs/HANDOFF.md for the queue and order. Section 5: add new browser checks and scripts.` },
+ { key: 'architecture', files: 'docs/ARCHITECTURE.md', brief: 'docs/ARCHITECTURE.md: describe this PR\'s changes where they belong, architecturally with file paths: catalog entries per engine, new ComfyUI graphs (and their entries in workflows/comfyui/requirements.json for the GPU pre-flight), providers, routes and how they follow public sign-up (src/lib/guest-access.ts), migrations (update the storage section\'s list), new libraries and settings. Add short pointers to new research notes (plans, not features) and keep the pointer to docs/HANDOFF.md for how the build continues. Keep it architectural.' },
+ { key: 'product', files: 'README.md, docs/FEATURES.md, docs/SELF-HOSTING.md and docs/DEVELOPMENT.md', brief: `README.md: keep it a short product page; add this PR's features to the feature grid or the lines that link to docs/FEATURES.md only where they belong there, keep every count it states consistent with HEAD, and make "Upgrading from an earlier version" right for this PR (migrations added, dependencies added in package.json since ${BASE}, new ComfyUI workflows, packs or weights to install, data files to back up). docs/FEATURES.md: the new features in plain words, each with where to find it and what each engine runs. docs/SELF-HOSTING.md: new settings, environment variables, ComfyUI packs or weights. docs/DEVELOPMENT.md: new checks, browser checks, scripts and counts (test files and tests, if stated).` },
+ { key: 'references', files: 'docs/research/README.md, docs/cli.md, docs/public-signup.md, scripts/comfy/README.md, scripts/eval/README.md and skills/README.md (only where this PR makes them wrong)', brief: 'docs/research/README.md: every new research note has a row and every row\'s "used by" says what this branch actually uses. scripts/comfy/README.md: the library counts (workflows and validated) must match workflows/comfyui/manifest.json at HEAD, and new graphs\' sections must match the code. docs/public-signup.md: only if this PR adds routes or rules guests and accounts see. docs/cli.md, scripts/eval/README.md and skills/README.md: fix only what this PR made wrong.' },
+]
+
+phase('Write')
+const writes = await parallel(FILES.map((f) => () => agent(`${CONTEXT}
+
+YOUR ASSIGNMENT: ${f.files}.
+${f.brief}
+
+When done, return a short summary of what you changed and anything you were unsure about (and left out).`, { label: `write:${f.key}`, phase: 'Write' })))
+log(`Write: ${writes.filter(Boolean).length}/${FILES.length} writers finished`)
+
+const CHECK = {
+ type: 'object',
+ properties: {
+ issues: { type: 'array', items: { type: 'object', properties: {
+ file: { type: 'string' }, quote: { type: 'string' },
+ kind: { type: 'string', enum: ['wrong', 'overstated', 'stale', 'missing', 'inconsistent', 'style'] },
+ severity: { type: 'string', enum: ['high', 'medium', 'low'] },
+ evidence: { type: 'string' }, correction: { type: 'string' },
+ }, required: ['file', 'kind', 'severity', 'evidence', 'correction'] } },
+ verdict: { type: 'string' },
+ },
+ required: ['issues', 'verdict'],
+}
+
+const LENSES = [
+ { key: 'accuracy', prompt: `ACCURACY lens: read git -C ${WT} diff (the writers' uncommitted changes). Check every added or changed claim (numbers, routes, file paths, model ids, workflow ids, prices, statuses ✅/🟢/🟡, "verified" wording) against the code at HEAD and the fact-checked files. Flag anything wrong, overstated (especially ✅ for things only built) or unbacked; also check that relative links in the changed lines point at files that exist.` },
+ { key: 'staleness', prompt: `STALENESS + CONSISTENCY lens: read ${DOCS} in full as they are now in ${WT}. Find statements this PR's changes made false that the writers left in place: features of this PR described as coming later or not started; test, model, migration or workflow counts presented as current that no longer match HEAD; contradictions between the docs (and with docs/HANDOFF.md and docs/public-signup.md); the same feature named differently; and anything from the "Still NOT in this branch" list described as available. Also: no doc may describe Higgsfield as a provider, key, setting or API Fuobe calls (history and comparisons are fine). Historical statements clearly marked as from an earlier round are fine.` },
+]
+
+phase('Check')
+const checks = (await parallel(LENSES.map((l) => () => agent(`${CONTEXT}
+
+You check documentation edits before they are committed. Do not edit files. ${l.prompt}`, { label: `check:${l.key}`, phase: 'Check', schema: CHECK })))).filter(Boolean)
+log(`Check: ${checks.map((c) => `${c.issues.length} issues`).join(', ') || 'no checker finished'}`)
+
+phase('Revise')
+const revise = await agent(`${CONTEXT}
+
+You finish the documentation update in ${WT}. The writers' summaries:
+${JSON.stringify(writes, null, 1)}
+
+The checkers' findings:
+${JSON.stringify(checks, null, 1)}
+
+Confirm each finding against the code / facts and fix the ones that hold, in ${DOCS} only. Reject findings that don't hold. Then re-read the full diff (git -C ${WT} diff) once more for anything wrong, overstated or unclear, and check every relative link in the edited files resolves (a quick script is fine). Do not commit. Return: what you fixed, what you rejected and why, and a 5–10 line summary of what the docs now say that they didn't before.`, { label: 'revise', phase: 'Revise' })
+log(revise ? `Revise: ${revise}` : 'Revise failed: the writers\' edits are in the worktree unchecked')
diff --git a/docs/handoff/verify.sh b/docs/handoff/verify.sh
index c687aea1..a59857f0 100755
--- a/docs/handoff/verify.sh
+++ b/docs/handoff/verify.sh
@@ -3,18 +3,23 @@
# cases, the production build, the browser checks in demo mode, hosted prices with a fake fal key, the live CPU ComfyUI
# checks and the ComfyUI workflow library. docs/HANDOFF.md ("Cutting a PR") explains when to run it.
# Usage: bash docs/handoff/verify.sh <branch> <out-dir>
-# Needs: origin/main fetched, the main checkout's scripts/comfy/node_modules (cd scripts/comfy && npm install) and a
-# ComfyUI at http://127.0.0.1:8188 (scripts/comfy/start-comfyui.sh). Results: <out-dir>/verify-summary.txt, logs in
-# <out-dir>/logs. Each step's exit code is recorded; a failing step doesn't stop the later ones.
+# Needs: origin/main fetched, the main checkout's scripts/comfy/node_modules (cd scripts/comfy && npm install), ffmpeg
+# and ffprobe, and a ComfyUI at http://127.0.0.1:8188 (scripts/comfy/start-comfyui.sh). It can run from any folder:
+# the throwaway worktree goes next to the main checkout (<repo>/../wt), whichever worktree holds this script. Results:
+# <out-dir>/verify-summary.txt, logs in <out-dir>/logs. Each step's exit code is recorded; a failing step doesn't stop
+# the later ones. comfy-validate exits 1 on a server that lacks some graphs' node packs: its log should list only the
+# graphs docs/HANDOFF.md names under "Known gaps".
set -u
BRANCH=${1:?branch}
S=$(mkdir -p "${2:?out-dir}" && cd "$2" && pwd)
-REPO=$(git rev-parse --show-toplevel)
+# The main checkout: the parent of the shared git directory (a linked worktree's own top folder is not it).
+REPO=$(dirname "$(git -C "$(dirname "$0")" rev-parse --path-format=absolute --git-common-dir)")
WT=$REPO/../wt/verify-$(echo "$BRANCH" | tr '/' '-')
L=$S/logs
SUM=$S/verify-summary.txt
mkdir -p "$L"
: > "$SUM"
+[ -d "$REPO/scripts/comfy/node_modules" ] || echo "warn: $REPO/scripts/comfy/node_modules is missing (cd scripts/comfy && npm install): comfy-validate will fail" >> "$SUM"
step() { local name=$1; shift; local t0=$(date +%s); ( "$@" ) > "$L/$name.log" 2>&1; local rc=$?; printf '%-34s exit=%-3s %5ss\n' "$name" "$rc" "$(( $(date +%s) - t0 ))" >> "$SUM"; return $rc; }
# Next 16's server process is named next-server, so stop servers by port, not by name.
stop_port() { local port=$1; for i in 1 2 3 4 5; do fuser -k -n tcp "$port" >/dev/null 2>&1 || break; sleep 1; done; sleep 1; }
@@ -66,6 +71,7 @@ FUOBE_DATA_DIR=$S/data-live NEXT_TELEMETRY_DISABLED=1 pnpm start -p 3400 > "$L/s
wait_up http://localhost:3400/ && echo "live server up" >> "$SUM"
step e2e-comfyui-selftest timeout 2400 node tests/e2e/comfyui-selftest.mjs http://localhost:3400
step e2e-comfyui-canvas-concat timeout 2400 node tests/e2e/comfyui-canvas-concat.mjs http://localhost:3400
+step e2e-comfyui-faceless-plus timeout 2400 node tests/e2e/comfyui-faceless-plus.mjs http://localhost:3400
stop_port 3400
# Every workflow in the library posted to the live ComfyUI (never run); packs this server lacks show as failures.
diff --git a/docs/handoff/workflow.body.js b/docs/handoff/workflow.body.js
index 7f30c134..b31cc886 100644
--- a/docs/handoff/workflow.body.js
+++ b/docs/handoff/workflow.body.js
@@ -1,33 +1,44 @@
// The build workflow's body: each package goes implement → adversarial review → fix in its own worktree, then one
// integrator at a time merges it into BASE and runs the checks. make-workflow.mjs puts `export const meta` and the
-// constants (REPO, WT, BASE, PLAN, TRAILER, LANES, DONE, PKGS, REMOVE_WORKTREES) in front of it; docs/HANDOFF.md
-// explains how to run it. Lanes R, O and A run side by side; inside a lane, packages run in order, and a lane stops
-// at the first package that fails a stage so a relaunch picks up there.
+// constants (REPO, WT, EXT, BASE, PLAN, TRAILER, LANES, DONE, PKGS, REMOVE_WORKTREES) in front of it; docs/HANDOFF.md
+// explains how to run it. Lanes R and O run side by side; inside a lane, packages run in order, and a lane stops at
+// the first package that fails a stage so a relaunch picks up there.
-const PRODUCT = `PRODUCT DIRECTION (from the owner): Fuobe uses NO Higgsfield API or keys. Everything Higgsfield offers as its own product is rebuilt as a "Fuobe Original" from open-weight models plus LoRAs, on both engines: the open engine (the user's ComfyUI) and the cloud engine through HOSTED models on fal.ai / Replicate. Partner models (Kling, Seedance, Veo, Nano Banana, GPT Image…) stay available through fal / Replicate as separate choices. LICENCES ARE INFORMATION, NOT GATES: build every model and route; record each model's, LoRA's and node pack's licence as data and show it in Settings → Models & licences, where the admin turns things on or off. EACH ENGINE DOES ALL IT CAN (owner, 10-30): the cloud uses only models that are hosted (no substitute model), with what the hosted endpoint supports; the open engine keeps every capability it has (LoRAs, custom nodes, longer clips, references) even when the cloud can't match it; say plainly in the UI what each engine does. The owner's decisions are in docs/handoff/owner-decisions.json. The plan for the Originals is ${PLAN}; use what Higgsfield's client code revealed only as facts about behaviour, never copy Higgsfield code, prompts or preview media.`
+const PRODUCT = `PRODUCT DIRECTION (from the owner): Fuobe uses NO Higgsfield API or keys. Everything Higgsfield offers as its own product is rebuilt as a "Fuobe Original" from open-weight models plus LoRAs, on both engines: the open engine (the user's ComfyUI) and the cloud engine through HOSTED models on fal.ai / Replicate. Partner models (Kling, Seedance, Veo, Nano Banana, GPT Image…) stay available through fal / Replicate as separate choices. LICENCES ARE INFORMATION, NOT GATES: build every model and route; record each model's, LoRA's and node pack's licence as data and show it in Settings → Models & licences, where the admin turns things on or off. EACH ENGINE DOES ALL IT CAN (owner, 10-30): the cloud uses only models that are hosted (no substitute model), with what the hosted endpoint supports; the open engine keeps every capability it has (LoRAs, custom nodes, longer clips, references) even when the cloud can't match it; say plainly in the UI what each engine does. ACCOUNTS ARE THE OWNER'S PUBLIC SIGN-UP (owner, 10-30: main wins): guests browse, people sign up with an email, accounts see a guest view of the owner's library and run only on their own ComfyUI (docs/public-signup.md); the old accounts plan (docs/research/accounts-8.md, packages acc-*) is dropped, so never build on it. The owner's decisions are in docs/handoff/owner-decisions.json on ${BASE}; if your branch predates that file, read it with git -C ${REPO} show ${BASE}:docs/handoff/owner-decisions.json. The plan for the Originals is ${PLAN}; use what Higgsfield's client code revealed only as facts about behaviour, never copy Higgsfield code, prompts or preview media.`
+
+// Where a package's worktree comes from, in this order: a local branch can exist without a worktree (the setup's
+// git branch -f), and a pushed branch must never be shadowed by a fresh one cut from the base.
+const WORKTREE = (p) => `the first case that applies, after git -C ${REPO} fetch -q origin 2>/dev/null:
+ (1) ${WT}/o-${p.key} exists: cd into it and continue on o/${p.key}.
+ (2) a local branch o/${p.key} exists (git -C ${REPO} rev-parse -q --verify refs/heads/o/${p.key}): git -C ${REPO} worktree add ${WT}/o-${p.key} o/${p.key}
+ (3) origin/o/${p.key} exists (work pushed by an earlier session): git -C ${REPO} worktree add ${WT}/o-${p.key} -b o/${p.key} origin/o/${p.key}
+ (4) otherwise: git -C ${REPO} worktree add ${WT}/o-${p.key} -b o/${p.key} ${BASE} (the base branch already contains every package this one depends on)
+ In cases (1) to (3), check the branch first: git log --oneline ${BASE}..o/${p.key} may list only this package's own commits (and merges of ${BASE} into it). If it lists an integrator's merge of another package ("Merge branch 'o/<other>' into …") or another package's commits, the branch was cut from a base that has since been rebuilt: change nothing, say so in your report's "blocked" field, and stop (docs/HANDOFF.md, "Work in progress", says how the main session moves it). Otherwise, if git -C ${REPO} merge-base --is-ancestor ${BASE} o/${p.key} fails, merge ${BASE} into the branch.`
+
+const WIP = (p) => (p.wip ? `\nWORK IN PROGRESS (what the last session found on this branch; check each point against the code before acting on it):\n${JSON.stringify(p.wip, null, 1)}\n` : '')
const commonO = (p) => `You are a senior engineer on Fuobe (${REPO}), an open-source alternative to Higgsfield with a fast, friendly shadcn/ui interface inspired by Liner. Package "${p.key}" (${p.title}).
${PRODUCT}
-SETUP (do this first):
- git -C ${REPO} fetch -q origin 2>/dev/null; git -C ${REPO} worktree add ${WT}/o-${p.key} -b o/${p.key} ${BASE} (the base branch already contains every package this one depends on). If the worktree exists, cd into it and continue on o/${p.key}. If it doesn't but origin/o/${p.key} exists (work pushed by an earlier session), use git -C ${REPO} worktree add ${WT}/o-${p.key} -b o/${p.key} origin/o/${p.key} and merge ${BASE} into it if the base moved.
- cd ${WT}/o-${p.key} && pnpm install --frozen-lockfile --prefer-offline && npx next typegen
+SETUP (do this first): ${WORKTREE(p)}
+ Then: cd ${WT}/o-${p.key} && pnpm install --frozen-lockfile --prefer-offline && npx next typegen
RESUMING: if the branch already had commits, an earlier attempt was cut off (usage limit, restart or a stopped session). Read its work first (git log ${BASE}..HEAD, git status, git diff), keep what is right, finish it; don't start over.
Work ONLY inside ${WT}/o-${p.key}. Never edit or run state-changing git commands in ${REPO}'s own checkout (an integrator uses it). Do not push.
-
-READ FIRST: docs/STATUS.md and docs/ARCHITECTURE.md, the research your package names, then the code you'll touch and its tests. AGENTS.md: Next.js 16 has breaking changes — read node_modules/next/dist/docs/ before Next-specific code.
+${WIP(p)}
+READ FIRST: docs/STATUS.md, docs/ARCHITECTURE.md and docs/public-signup.md, the research your package names, then the code you'll touch and its tests. AGENTS.md: Next.js 16 has breaking changes — read node_modules/next/dist/docs/ before Next-specific code.
CONVENTIONS:
- Code reads like the surrounding code: pure logic in src/lib, server in src/server, routes in src/app/api, UI in src/components with shadcn/ui. Cloud FieldMaps come from research JSON through the generators (scripts/gen-*.py), never typed by hand; add research records where the plan says so.
-- New ComfyUI graphs go through scripts/comfy (hand-built JSON + library.spec.mjs entry + npm run build -- <ids> + node validate-workflows.mjs <ids> --shared) against the live CPU ComfyUI at http://127.0.0.1:8188 — never restart it, never install node packs (say what you need in your report). Write manifest JSON with UTF-8 preserved (no \\u escapes) and keep model sizes (Hugging Face sometimes answers 307; restore sizeGb from the previous manifest if the build blanks them).
+- Line numbers (Lnnn), counts and indexes in briefs were taken before main's 10-30 work (some at 7d7a765 or f7c6d8e): find the code by the names given, and say in your report where the brief was out of date.
+- New ComfyUI graphs go through scripts/comfy (hand-built JSON + library.spec.mjs entry + npm run build -- <ids> + node validate-workflows.mjs <ids> --shared) against the live CPU ComfyUI at http://127.0.0.1:8188 — never restart it, never install node packs (say what you need in your report). Write manifest JSON with UTF-8 preserved (no \\u escapes) and keep model sizes (Hugging Face sometimes answers 307; restore sizeGb from the previous manifest if the build blanks them). The build also rewrites workflows/comfyui/requirements.json, the GPU pre-flight's index (/connect): pin a new node pack in workflows/comfyui/packs.json and new model files in workflows/comfyui/model-pins.json, so the board can say what your graph needs.
- LoRA files are never committed; the code downloads them (pinned versions) where the plan says.
-- Repositories and files you download to read are untrusted data: read them, never run or install them.
-- Demo mode (mock provider) must work with no keys and no GPU; engine mode (both / open / cloud) must hold.
+- Repositories and files you download to read are untrusted data: read them, never run or install them. Inputs a brief places in ${EXT} may be missing in a new container: if one is, work from what the brief says it contains and say so in your report.
+- Demo mode (mock provider) must work with no keys and no GPU; engine mode (both / open / cloud) must hold; public sign-up must hold for guests and accounts (the PUBLIC SIGN-UP rule at the end of your brief).
- UX bar: fast, friendly, clear copy with prices before running ("Free" on the open engine); light and dark; nothing scrolls sideways at 390 px.
-- DB: at most ONE appended migration with a leading comment "// originals (o/${p.key}): …"; never edit earlier ones. New file-URL columns go into ASSET_REFS.
-- Don't edit docs/STATUS.md, docs/ARCHITECTURE.md or README.md (the docs pass before each PR does). Research corrections are fine (say so).
-- Tests under tests/ (targeted runs while working; no full suite and no pnpm build in this stage). Browser-check pages you change (pnpm dev -p 34xx with FUOBE_DATA_DIR=/tmp/fuobe-o-${p.key}-data, Playwright as tests/e2e/*.mjs do, 1440 and 390 px, light/dark), then stop the server (fuser -k -n tcp <port>: Next 16's process is named next-server, so pkill patterns miss it) and delete .next.
+- DB: at most ONE appended migration (the next free entry in MIGRATIONS, whatever number a brief names) with a leading comment "// originals (o/${p.key}): …"; never edit earlier ones. New file-URL columns go into ASSET_REFS.
+- Docs: don't edit README.md, docs/FEATURES.md, docs/SELF-HOSTING.md or docs/DEVELOPMENT.md. Edit docs/STATUS.md and docs/ARCHITECTURE.md only where your brief asks (just the lines for what you changed; the integrator keeps both sides on a conflict); otherwise put doc notes in docsNotes for the docs pass before each PR. Research corrections are fine (say so).
+- Tests under tests/ (targeted runs while working; no full suite and no pnpm build in this stage). Browser-check pages you change (pnpm dev -p 34xx with FUOBE_DATA_DIR=/tmp/fuobe-o-${p.key}-data, Playwright as tests/e2e/*.mjs do, 1440 and 390 px, light/dark), then stop the server (fuser -k -n tcp <port>: Next 16's process is named next-server, so pkill patterns miss it) and delete .next. Never use ports 3399-3401 (docs/handoff/verify.sh) or 8188 (ComfyUI).
- If commit.gpgsign is on, commits must be signed: never pass --no-gpg-sign or -c commit.gpgsign=false; if signing fails, stop and say so in your report instead of committing unsigned.
- Work economically (a usage limit can interrupt you): commit finished pieces as you go, in the repo's style ("Area: what changed, in plain words"), each message ending with these lines after a blank line:
${TRAILER}
@@ -36,17 +47,19 @@ ${TRAILER}
YOUR PACKAGE:
${p.brief}`
-const IMPL = { type: 'object', properties: { branch: { type: 'string' }, summary: { type: 'string' }, built: { type: 'array', items: { type: 'object', properties: { feature: { type: 'string' }, status: { type: 'string' }, verifiedHow: { type: 'string' } }, required: ['feature', 'status', 'verifiedHow'] } }, tests: { type: 'string' }, left: { type: 'array', items: { type: 'string' } }, docsNotes: { type: 'string' } }, required: ['branch', 'summary', 'built', 'tests', 'left', 'docsNotes'] }
+const BLOCKED = { type: 'string', description: 'only when the stage could not run at all (for example a branch cut from a rebuilt base): why, and what the main session must do' }
+const IMPL = { type: 'object', properties: { branch: { type: 'string' }, summary: { type: 'string' }, built: { type: 'array', items: { type: 'object', properties: { feature: { type: 'string' }, status: { type: 'string' }, verifiedHow: { type: 'string' } }, required: ['feature', 'status', 'verifiedHow'] } }, tests: { type: 'string' }, left: { type: 'array', items: { type: 'string' } }, docsNotes: { type: 'string' }, blocked: BLOCKED }, required: ['branch', 'summary', 'built', 'tests', 'left', 'docsNotes'] }
const FIND = { type: 'object', properties: { findings: { type: 'array', items: { type: 'object', properties: { file: { type: 'string' }, line: { type: 'number' }, severity: { type: 'string', enum: ['blocker', 'major', 'minor', 'nit'] }, summary: { type: 'string' }, failureScenario: { type: 'string' }, verified: { type: 'boolean' } }, required: ['file', 'severity', 'summary', 'failureScenario', 'verified'] } }, checks: { type: 'string' }, verdict: { type: 'string' } }, required: ['findings', 'checks', 'verdict'] }
-const FIX = { type: 'object', properties: { applied: { type: 'array', items: { type: 'string' } }, rejected: { type: 'array', items: { type: 'string' } }, checks: { type: 'string' }, finalSummary: { type: 'string' }, left: { type: 'array', items: { type: 'string' } } }, required: ['applied', 'rejected', 'checks', 'finalSummary'] }
+const FIX = { type: 'object', properties: { applied: { type: 'array', items: { type: 'string' } }, rejected: { type: 'array', items: { type: 'string' } }, checks: { type: 'string' }, finalSummary: { type: 'string' }, left: { type: 'array', items: { type: 'string' } }, blocked: BLOCKED }, required: ['applied', 'rejected', 'checks', 'finalSummary'] }
const MERGE = { type: 'object', properties: { merged: { type: 'array', items: { type: 'string' } }, notMerged: { type: 'array', items: { type: 'string' } }, conflicts: { type: 'string' }, checks: { type: 'string', description: 'typecheck / lint / vitest exit codes and counts' }, pushed: { type: 'boolean' }, head: { type: 'string' } }, required: ['merged', 'notMerged', 'checks', 'pushed'] }
const INTEGRATE = (branches, why) => `You are the integrator for Fuobe (${REPO}). Merge these branches, in this order, into ${BASE} in ${REPO}'s own checkout (you are the only one using it; other agents work in ${WT}/*): ${branches.join(', ')}. ${why}
If commit.gpgsign is on, commits must be signed: never pass --no-gpg-sign or -c commit.gpgsign=false; if signing fails, stop and say so in your report instead of committing unsigned.
+Before each merge, git -C ${REPO} log --oneline ${BASE}..<branch> may list only that package's own commits (and merges of ${BASE} into it). If it lists an integrator's merge of another package ("Merge branch 'o/<other>' into …") or another package's commits, the branch was cut from a base that has since been rebuilt (it would bring back work the owner dropped, such as acc-1 and acc-2): don't merge it; put it in notMerged with that reason (docs/HANDOFF.md, "Work in progress").
For each: git -C ${REPO} merge --no-ff <branch> -m "Merge branch '<branch>' into ${BASE}" + a blank line + these lines:
${TRAILER}
-Conflict policy: both sides usually ADD (imports, list entries, spec entries, settings rows, tests): keep both, in a sensible order, and make sure the result compiles (watch JSX and object-literal closings a naive union breaks). Migrations: keep every migration, appended in merge order (never two at one index, never edit an applied one). workflows/comfyui/manifest.json and object_info.subset.json: take ours, then rebuild only the ids the branch added or changed from the merged scripts/comfy/library.spec.mjs (cd scripts/comfy && npm run build -- <ids> && node validate-workflows.mjs <ids> --shared; the live ComfyUI is http://127.0.0.1:8188 — never restart it; entries whose node packs this server lacks, such as image-vectorize-vtracer, sfx-thinksound, captions-whisper-burnin, lipsync-latentsync16, separate-soundtrack-dbs and the H3 Relay graphs, keep their entries as merged and aren't re-validated); keep UTF-8 (write JSON with ensure_ascii=False / JSON.stringify) and restore any sizeGb the rebuild blanked from the branch's manifest. Real code conflicts (two different behaviours): read both packages' intent and keep both behaviours; if that's impossible, keep the later package's and note it.
-After each merge: npx next typegen; pnpm typecheck; pnpm lint — check each command's OWN exit code (never pipe it through tail before checking). After all merges: pnpm vitest run --maxWorkers=2 and check vitest's own exit code. Fix merge-interaction failures minimally (tests that pinned one package's behaviour now meeting another's, counts, lists) in a separate commit with the trailer. Then git push -u origin ${BASE}.${REMOVE_WORKTREES ? ` Finally remove the merged worktrees (git worktree remove ${WT}/<dir> for each merged branch whose worktree is clean) to free disk.` : ''} Report what merged, what didn't and why, the conflicts you resolved, the check results, and the pushed head.`
+Conflict policy: both sides usually ADD (imports, list entries, spec entries, settings rows, guest-access rules, tests): keep both, in a sensible order, and make sure the result compiles (watch JSX and object-literal closings a naive union breaks). Migrations: keep every migration, appended in merge order (never two at one index, never edit an applied one). workflows/comfyui/manifest.json and object_info.subset.json: take ours, then rebuild only the ids the branch added or changed from the merged scripts/comfy/library.spec.mjs (cd scripts/comfy && npm run build -- <ids> && node validate-workflows.mjs <ids> --shared; the live ComfyUI is http://127.0.0.1:8188 — never restart it; entries whose node packs this server lacks, such as sfx-thinksound, lipsync-latentsync16 and the H3 Relay graphs, keep their entries as merged and aren't re-validated); keep UTF-8 (write JSON with ensure_ascii=False / JSON.stringify) and restore any sizeGb the rebuild blanked from the branch's manifest. workflows/comfyui/packs.json and model-pins.json are kept by hand: keep both sides. workflows/comfyui/requirements.json (the GPU pre-flight's index): take ours, then let the build above rewrite it (or run node scripts/comfy/build-requirements.mjs). Real code conflicts (two different behaviours): read both packages' intent and keep both behaviours; if that's impossible, keep the later package's and note it.
+After each merge: npx next typegen; pnpm typecheck; pnpm lint — check each command's OWN exit code (never pipe it through tail before checking). After all merges: pnpm vitest run --maxWorkers=2 and check vitest's own exit code (tests/public-signup.test.ts must pass with the new routes). Fix merge-interaction failures minimally (tests that pinned one package's behaviour now meeting another's, counts, lists) in a separate commit with the trailer. Then git push -u origin ${BASE}.${REMOVE_WORKTREES ? ` Finally remove the merged worktrees (git worktree remove ${WT}/<dir> for each merged branch whose worktree is clean) to free disk.` : ''} Report what merged, what didn't and why, the conflicts you resolved, the check results, and the pushed head.`
let mergeLock = Promise.resolve()
const serial = (fn) => { const run = mergeLock.then(fn, fn); mergeLock = run.catch(() => {}); return run }
@@ -55,20 +68,24 @@ async function runO(p) {
const done = DONE[p.key] || {}
const impl = done.impl || await agent(commonO(p), { label: `impl:${p.key}`, phase: p.phase, schema: IMPL })
if (!impl) return { key: p.key, failed: 'implement' }
+ if (impl.blocked) return { key: p.key, impl, failed: `implement (blocked: ${impl.blocked})` }
const review = done.review || await agent(`You are an adversarial reviewer for Fuobe (${REPO}), package "${p.key}" (${p.title}) on branch o/${p.key} in ${WT}/o-${p.key}, based on ${BASE}.
${PRODUCT}
Implementer report: ${JSON.stringify(impl)}
Brief: ${p.brief}
-Review git diff ${BASE}...o/${p.key} with the code around it. Look for correctness bugs, regressions, broken flows on either engine or in demo mode, payloads that don't match the research's endpoint fields, ComfyUI bindings that don't match the manifest, a model, LoRA or node pack added without its licence recorded as data (for Settings → Models & licences), LoRA files or Higgsfield media committed, Higgsfield API use, a local capability removed or weakened because the cloud lacks it, security problems (SSRF via LoRA / download URLs, path traversal, auth, a route or row that skips the accounts core's actor and scope checks), missing ASSET_REFS, weak tests, UI that breaks at 390 px or for keyboard users, and things the brief asked for that are missing. Verify each finding (trace it or run a targeted test; no edits, no commits). Most severe first.`, { label: `review:${p.key}`, phase: p.phase, schema: FIND })
+Review git diff ${BASE}...o/${p.key} with the code around it. Look for correctness bugs, regressions, broken flows on either engine or in demo mode, payloads that don't match the research's endpoint fields, ComfyUI bindings that don't match the manifest, a model, LoRA or node pack added without its licence recorded as data (for Settings → Models & licences), LoRA files or Higgsfield media committed, Higgsfield API use, a local capability removed or weakened because the cloud lacks it, security problems (SSRF via LoRA / download URLs, path traversal, auth), a route, page or run that breaks the owner's public sign-up rules (docs/public-signup.md, src/lib/guest-access.ts, src/proxy.ts, tests/public-signup.test.ts: guests and accounts get the guest view of the owner's library, run only on their own ComfyUI, never touch settings, keys or tokens), a new studio or graph the GPU pre-flight board can't see (src/server/gpu/tools.ts, workflows/comfyui/requirements.json), missing ASSET_REFS, weak tests, UI that breaks at 390 px or for keyboard users, and things the brief asked for that are missing. Verify each finding (trace it or run a targeted test; no edits, no commits). Most severe first.`, { label: `review:${p.key}`, phase: p.phase, schema: FIND })
if (!review) return { key: p.key, impl, failed: 'review' }
- const fix = done.fix || await agent(`You are finishing Fuobe package "${p.key}" in ${WT}/o-${p.key} (branch o/${p.key}, base ${BASE}). Never touch ${REPO}'s checkout. If an earlier attempt at this stage was cut off, read git log ${BASE}..HEAD and git status first and continue from there. If the worktree is missing, recreate it from origin/o/${p.key} (git -C ${REPO} worktree add ${WT}/o-${p.key} -b o/${p.key} origin/o/${p.key}; pnpm install --frozen-lockfile --prefer-offline; npx next typegen).
+ const fix = done.fix || await agent(`You are finishing Fuobe package "${p.key}" in ${WT}/o-${p.key} (branch o/${p.key}, base ${BASE}). Never touch ${REPO}'s checkout. If an earlier attempt at this stage was cut off, read git log ${BASE}..HEAD and git status first and continue from there. Set up the worktree with ${WORKTREE(p)}
+ Then pnpm install --frozen-lockfile --prefer-offline; npx next typegen.
${PRODUCT}
+${WIP(p)}
Report and findings: ${JSON.stringify({ impl, review })}
Brief: ${p.brief}
Confirm each finding before fixing; fix confirmed blockers, majors, minors and clear nits with tests; finish what the brief asked for that's missing; reject the rest with reasons. Then pnpm typecheck, pnpm lint and pnpm vitest run --maxWorkers=2 (check each command's own exit code; all must pass — a failure that also fails on ${BASE} is reported, not hidden). Commit in the repo's style with these lines after a blank line:
${TRAILER}
-Delete .next if present and leave git status clean. Return applied, rejected, checks, a final summary (each engine: what works, verified vs built, what needs a GPU or a key) and what's left.`, { label: `fix:${p.key}`, phase: p.phase, schema: FIX })
+Delete .next if present and leave git status clean. Return applied, rejected, checks, a final summary (each engine: what works, verified vs built, what needs a GPU or a key; what guests and accounts get under public sign-up) and what's left.`, { label: `fix:${p.key}`, phase: p.phase, schema: FIX })
if (!fix) return { key: p.key, impl, review, failed: 'fix' }
+ if (fix.blocked) return { key: p.key, impl, review, fix, failed: `fix (blocked: ${fix.blocked})` }
const m = await serial(() => agent(INTEGRATE([`o/${p.key}`], `Package ${p.key} finished implement → review → fix; packages after it start from ${BASE} once this merge is pushed.`), { label: `merge:${p.key}`, phase: p.phase, schema: MERGE }))
return m && m.merged && m.merged.length ? { key: p.key, impl, review, fix, merge: m } : { key: p.key, impl, review, fix, merge: m, failed: 'merge' }
}