A full-featured CRM built with React, shadcn/ui, and Supabase.
Enhance validation hooks to recover task/role from transcript when not provided
Jeromeacca654ff5da
diff --git a/.claude/hooks/record-review-verdict.mjs b/.claude/hooks/record-review-verdict.mjsindex f5322563..1ee8c825 100755--- a/.claude/hooks/record-review-verdict.mjs+++ b/.claude/hooks/record-review-verdict.mjs@@ -47,6 +47,36 @@ for (const n of ids) {}}+// No suffixed agent name in this harness → recover task/role from the dispatch+// prompt in the transcript. Done unconditionally: lastAssistantText() returns+// early on last_assistant_message, bypassing its own recovery (→ task=UNKNOWN).+if (!role || !task) {+ const tp = input.agent_transcript_path || input.transcript_path;+ if (tp && existsSync(tp)) {+ let body = "";+ try {+ body = readFileSync(tp, "utf8");+ } catch {+ body = "";+ }+ for (const line of body.split("\n")) {+ if (!role) {+ const m = line.match(+ /(?:^|\\n|")ROLE:\s*(quality-reviewer|test-validator)/,+ );+ if (m) role = m[1];+ }+ if (!task) {+ const m =+ line.match(/TASK_ID[:=\s]+(TASK-\d+)/) ||+ line.match(/TICKET_FILE[=:\s]+\S*(TASK-\d+)/);+ if (m) task = m[1];+ }+ if (role && task) break;+ }+ }+}+// Last assistant text: prefer the payload field, fall back to the transcript.// While scanning the transcript, recover role/task from the dispatch prompt// (ROLE: / TICKET_FILE:) when the agent name didn't carry them.diff --git a/.claude/hooks/validate-on-stop.mjs b/.claude/hooks/validate-on-stop.mjsindex d1ba4784..4ee9effa 100755--- a/.claude/hooks/validate-on-stop.mjs+++ b/.claude/hooks/validate-on-stop.mjs@@ -1,7 +1,7 @@#!/usr/bin/env node// SubagentStop — full validation chain (prettier auto-fix, typecheck, unit app/functions, e2e) on active worktrees with changes; exit 2 keeps the subagent alive to fix and commit. VALIDATE_DRY_RUN=1 skips the chain; =fail simulates a failure.-import { readFileSync } from "node:fs";+import { existsSync, readFileSync } from "node:fs";import { createHookContext } from "./lib/context.mjs";import { git } from "./lib/git.mjs";import { getFirstTaskId } from "./lib/teams.mjs";@@ -12,7 +12,14 @@ import {} from "./lib/topology.mjs";import { runValidationSteps } from "./lib/validation.mjs";-const ctx = createHookContext(readFileSync(0, "utf8"), "validate");+const raw = readFileSync(0, "utf8");+const ctx = createHookContext(raw, "validate");+let payload = {};+try {+ payload = JSON.parse(raw);+} catch {+ payload = {};+}// Scope validation to the stopping subagent's OWN worktree: developer-TASK-XXX// validates <base>/TASK-XXX, simple-developer validates <base>/simple. Avoids the@@ -20,10 +27,34 @@ const ctx = createHookContext(readFileSync(0, "utf8"), "validate");// developer and N stops each re-validate every session worktree. Falls back to// all session worktrees when the identity can't be resolved.const ids = [ctx.agentName, ctx.agentType].filter(Boolean);-const taskId = ids.map(getFirstTaskId).find(Boolean) || "";+const isSimple = ids.some((n) => /simple-developer/.test(n));+let taskId = ids.map(getFirstTaskId).find(Boolean) || "";++// No suffixed agent name in this harness → recover TASK_ID from the dispatch+// prompt in the transcript, to scope validation to this dev's worktree (not wt=all).+if (!taskId && !isSimple) {+ const tp = payload.agent_transcript_path || payload.transcript_path;+ if (tp && existsSync(tp)) {+ try {+ const body = readFileSync(tp, "utf8");+ for (const line of body.split("\n")) {+ const m =+ line.match(/TASK_ID[:=\s]+(TASK-\d+)/) ||+ line.match(/TICKET_FILE[=:\s]+\S*(TASK-\d+)/);+ if (m) {+ taskId = m[1];+ break;+ }+ }+ } catch {+ // best-effort — fall back to all-worktree validation below+ }+ }+}+const ownWorktree = taskId? taskWorktreePath(ctx, taskId)- : ids.some((n) => /simple-developer/.test(n))+ : isSimple? simpleWorktreePath(ctx): "";