A full-featured CRM built with React, shadcn/ui, and Supabase.
fix(harness): correct board link path (multi-root) + add session.diff
Jeromec888ed966022
diff --git a/.claude/hooks/render-status.mjs b/.claude/hooks/render-status.mjsindex 1ce6a84e..d06c5f7f 100755--- a/.claude/hooks/render-status.mjs+++ b/.claude/hooks/render-status.mjs@@ -27,6 +27,8 @@ import { join } from "node:path";import { createHookContext } from "./lib/context.mjs";import { REPO } from "./lib/paths.mjs";import { reviewsDir } from "./lib/reviews.mjs";+import { getBaseBranch, git } from "./lib/git.mjs";+import { sessionBaseBranch, sessionBranch } from "./lib/topology.mjs";if (process.env.CHAT_SESSION_DIR) process.exit(0);@@ -96,6 +98,25 @@ function recentActivity(max = 25) {const cell = (s) => String(s ?? "").replace(/\|/g, "\\|");+// The cumulative diff of the session's merged work vs its fork anchor: the code+// the harness has actually changed. Written as a `.diff` file so the developer+// can open it and SEE the change on any surface (the VS Code extension can't show+// the /tmp worktree diffs; the desktop diff pane is undocumented for subagents).+// Returns null when the session branch does not exist yet or has no diff.+const verifyRef = (ref) =>+ git(["rev-parse", "--verify", "--quiet", ref]).status === 0;++function sessionDiff() {+ const branch = sessionBranch(ctx);+ if (!verifyRef(branch)) return null;+ const anchor = sessionBaseBranch(ctx);+ const baseRef = verifyRef(anchor) ? anchor : getBaseBranch();+ const range = `${baseRef}...${branch}`;+ const patch = git(["diff", range]).stdout;+ if (!patch.trim()) return null;+ return { range, stat: git(["diff", "--stat", range]).stdout.trim(), patch };+}+function build() {const tickets = readTickets();const worktrees = liveWorktrees();@@ -103,6 +124,7 @@ function build() {const merged = tickets.filter((t) => t.status === "merged").length;const updated = new Date(statSync(progressLog).mtime).toISOString();const activity = recentActivity();+ const diff = sessionDiff();// STATUS.md - the live board.const statusMd = [@@ -126,6 +148,11 @@ function build() {? worktrees.map((w) => `- \`${w}\``).join("\n"): "_none (nothing in flight)_","",+ "## Changes",+ diff+ ? `Full patch in \`session.diff\` (same folder).\n\n\`\`\`\n${diff.stat}\n\`\`\``+ : "_no changes on the session branch yet_",+ "","## Recent activity","```",...activity,@@ -165,11 +192,11 @@ function build() {last: activity[activity.length - 1] || "",};- return { statusMd, ticketsMd, statusJson };+ return { statusMd, ticketsMd, statusJson, diffPatch: diff?.patch };}try {- const { statusMd, ticketsMd, statusJson } = build();+ const { statusMd, ticketsMd, statusJson, diffPatch } = build();const outDir = join(REPO, ".harness", ctx.sessionShort);mkdirSync(outDir, { recursive: true });writeFileSync(join(outDir, "STATUS.md"), statusMd);@@ -178,6 +205,7 @@ try {join(outDir, "status.json"),JSON.stringify(statusJson, null, 2),);+ if (diffPatch) writeFileSync(join(outDir, "session.diff"), diffPatch);ctx.log(`rendered board -> ${outDir}`);} catch (e) {ctx.log(`skipped: ${e?.message ?? e}`);diff --git a/.claude/hooks/test/render-status.test.mjs b/.claude/hooks/test/render-status.test.mjsindex d4a9cad0..24f66738 100644--- a/.claude/hooks/test/render-status.test.mjs+++ b/.claude/hooks/test/render-status.test.mjs@@ -124,6 +124,43 @@ describe("render-status", () => {expect(s.last).toContain("TASK-001 merged");});+ test("writes session.diff and a Changes section from the session branch", () => {+ const { app, outDir, run } = setup();+ // Turn the throwaway repo into a git repo with a session branch carrying one+ // change vs its fork anchor (session-base), like the harness topology.+ const g = (...a) =>+ spawnSync("git", ["-C", app, ...a], { encoding: "utf8" });+ g("init", "-q", "-b", "main");+ g("config", "user.email", "[email protected]");+ g("config", "user.name", "t");+ writeFileSync(join(app, "Button.tsx"), "label = 'Add contact'\n");+ g("add", ".");+ g("commit", "-qm", "base");+ g("branch", `session-base/${SHORT}`);+ g("checkout", "-q", "-b", `session/${SHORT}`);+ writeFileSync(join(app, "Button.tsx"), "label = 'New contact'\n");+ g("add", ".");+ g("commit", "-qm", "rename button");+ g("checkout", "-q", "main");++ run();+ const patch = readFileSync(join(outDir, "session.diff"), "utf8");+ expect(patch).toContain("Button.tsx");+ expect(patch).toContain("+label = 'New contact'");+ expect(patch).toContain("-label = 'Add contact'");+ const md = readFileSync(join(outDir, "STATUS.md"), "utf8");+ expect(md).toContain("## Changes");+ expect(md).toContain("Button.tsx");+ });++ test("omits session.diff when there is no git session branch", () => {+ const { outDir, run } = setup();+ run();+ expect(existsSync(join(outDir, "session.diff"))).toBe(false);+ const md = readFileSync(join(outDir, "STATUS.md"), "utf8");+ expect(md).toContain("no changes on the session branch yet");+ });+test("is inert when there is no technical progress log", () => {const { app, run } = setup({ withProgressLog: false });const r = run();diff --git a/CLAUDE.md b/CLAUDE.mdindex b84c0fdc..465fa40d 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -30,7 +30,7 @@ Off by default. `#harness` (or "use the agent team" / "with the harness") routes`#technical-harness` is the same opt-in for a real developer: it appends a `PERSONA: technical` line (see `orchestrator.md` -> "`PERSONA: technical`"), which (1) uses the full technical register (file paths, `TASK-XXX`, git terms, `database`/`migration`/`Supabase`), (2) reports the mechanical truth (per-ticket status, branches, SHAs, verdicts, ADR paths), (3) stops at `session/<id>` (no promotion, no migration round; you promote and migrate yourself), and (4) appends every step to `<session_dir>/harness-progress.log`.-**Live progress (technical runs).** The report lands only at the end (possibly as a `task-notification`), so surface a live view WITHOUT flooding the chat with a raw log tail. The `render-status` SubagentStop hook renders `.harness/<SESSION_SHORT_ID>/{STATUS.md,TICKETS.md,status.json}` (gitignored, per-session, cleaned at SessionEnd) from the live session state after every agent stop. Tell the user to open `.harness/<SESSION_SHORT_ID>/STATUS.md` in a Markdown preview: it lists tickets (status + review verdict), live worktrees (who is working where), and recent activity, and updates itself as agents finish. It renders on the desktop app AND the VS Code extension (it lives in the project dir, not the `/tmp` worktrees), and `TICKETS.md` is the readable plan. An opt-in compact statusline is available (`.claude/scripts/harness-statusline.mjs`; wire it in your own `settings.local.json`, see its header) - not committed, since it would override a personal statusline. Dispatch the orchestrator with `run_in_background: true`. Prefer the board; a raw `Monitor({command: "tail -n +1 -F <session_dir>/harness-progress.log", ...})` terminal feed stays available but noisier. The authoritative end signal is the `task-notification`, not the log: on it, `TaskStop` any monitor, relay the report, and run `/harness-diff` on the session branch it stopped on.+**Live progress (technical runs).** The report lands only at the end (possibly as a `task-notification`), so surface a live view WITHOUT flooding the chat with a raw log tail. The `render-status` SubagentStop hook renders `.harness/<SESSION_SHORT_ID>/{STATUS.md,TICKETS.md,status.json,session.diff}` (gitignored, per-session, cleaned at SessionEnd) from the live session state after every agent stop. `STATUS.md` lists tickets (status + review verdict), live worktrees, a changed-files summary, and recent activity, updating itself as agents finish; `TICKETS.md` is the readable plan; `session.diff` is the actual code the harness changed (the extension does not surface the `/tmp` worktree diffs, so this file is how the user reads them). **Link it workspace-root-relative.** The board lives at `<repo>/.harness/<SESSION_SHORT_ID>/`, and the editor resolves a clickable link from the workspace root: in a multi-root workspace that means prefixing the repo folder (e.g. `atomic-crm/.harness/<SESSION_SHORT_ID>/STATUS.md`) - a bare `.harness/...` resolves to the workspace root and fails with "outside the working directory". A single-root session or the desktop app takes `.harness/<SESSION_SHORT_ID>/STATUS.md` as-is; when unsure, also give the absolute path. An opt-in compact statusline is available (`.claude/scripts/harness-statusline.mjs`; wire it in your own `settings.local.json`, see its header) - not committed, since it would override a personal statusline. Dispatch the orchestrator with `run_in_background: true`. Prefer the board; a raw `Monitor({command: "tail -n +1 -F <session_dir>/harness-progress.log", ...})` terminal feed stays available but noisier. The authoritative end signal is the `task-notification`, not the log: on it, `TaskStop` any monitor, relay the report, and run `/harness-diff` on the session branch it stopped on.## Agents