A full-featured CRM built with React, shadcn/ui, and Supabase.
fix review
Jeromea46c6a7f04f5
diff --git a/.claude/agents/chat-orchestrator.md b/.claude/agents/chat-orchestrator.mdindex 0edd9e35..b3797e58 100644--- a/.claude/agents/chat-orchestrator.md+++ b/.claude/agents/chat-orchestrator.md@@ -856,7 +856,12 @@ Agent({One line: *"Applying your changes — this can take a moment on first run."*`Bash("node \"$CLAUDE_PROJECT_DIR/.claude/scripts/apply-migrations.mjs\"")` (timeout 240000 ms).-→ exit 0: demo mode → STATE PD-LIVE-ASK; full mode → STATE PD-DONE ("Your changes are saved."). Non-zero → PD-DONE with a non-technical failure line.+→ exit 0, branch on the `<mode>` tag in your own system prompt+ - `<mode>demo</mode>` → STATE PD-LIVE-ASK.+ - `<mode>full</mode>` → STATE PD-DONE ("Your changes are saved.").+ - **no `<mode>` tag** → STATE PD-DONE ("Your changes are saved."). PD-DEPLOY is terminal here — never offer the switch, never call `switch-mode` (neither exists).++ Non-zero → PD-DONE with a non-technical failure line.### STATE PD-LIVE-ASK — offer to switch the app to real datadiff --git a/.claude/hooks/bash-guard.mjs b/.claude/hooks/bash-guard.mjsindex db598888..d45086eb 100755--- a/.claude/hooks/bash-guard.mjs+++ b/.claude/hooks/bash-guard.mjs@@ -100,14 +100,29 @@ if (violation) {// Write/Edit tools, never Bash redirection/in-place edits. Bash writes bypass the// Write|Edit-only block-migration-writes guard (a developer could otherwise write a migration in// bash).-const writesRedirect = (c) =>- /(^|[^0-9&])>>?\s*(\/|\.\.?\/|~\/|[a-zA-Z0-9._-]+\/|[a-zA-Z0-9._-]+\.[a-zA-Z0-9]+)/.test(- c,- ) && !/>>?\s*(\/dev\/null|\/chat-service\/logs\/)/.test(c);+const REDIRECT_TARGET_RE =+ /(^|[^0-9&])>>?\s*(\/dev\/null\b|\/chat-service\/logs\/\S*|\/|\.\.?\/|~\/|[a-zA-Z0-9._-]+\/|[a-zA-Z0-9._-]+\.[a-zA-Z0-9]+)/g;+const writesRedirect = (c) => {+ // Evaluate the /dev/null and logs exemptions PER redirect, so an unrelated+ // `cmd 2>/dev/null` can't disarm detection of a real `> file` write in the+ // same command.+ for (const m of c.matchAll(REDIRECT_TARGET_RE)) {+ const target = m[2];+ if (target === "/dev/null" || target.startsWith("/chat-service/logs/"))+ continue;+ return true;+ }+ return false;+};const writesSedInPlace = (c) => /sed\s+(-[a-zA-Z]*i\b|--in-place)/.test(c);const writesAwkInPlace = (c) => /awk\s+-i\s+inplace/.test(c);-const writesTee = (c) =>- /\|\s*tee\s+[^-]/.test(c) && !/\|\s*tee\s+(-a\s+)?\/dev\/null/.test(c);+const writesTee = (c) => {+ // tee writes to its file argument(s); skip leading flags (e.g. -a) to reach+ // the target, and exempt the /dev/null sink. Bare `| tee` (no file) only+ // duplicates to stdout — not a write.+ const m = c.match(/\|\s*tee\s+((?:-\S+\s+)*)(\S+)/);+ return !!m && m[2] !== "/dev/null";+};const writesScript = (c) =>/(node|python3?)\s+-[ecp].*(writeFileSync|writeFile|write_text|os\.write|fs\.write)/.test(c,diff --git a/.claude/scripts/apply-migrations.mjs b/.claude/scripts/apply-migrations.mjsindex 897be68c..57592fe9 100755--- a/.claude/scripts/apply-migrations.mjs+++ b/.claude/scripts/apply-migrations.mjs@@ -70,8 +70,8 @@ function reloadSchemaCache() {const { code } = run("npx", ["supabase","db",- "execute",- "--sql",+ "query",+ "--local","SELECT pg_notify('pgrst', 'reload schema');",]);if (code === 0) {@@ -84,7 +84,7 @@ function reloadSchemaCache() {if (await isSupabaseUp()) {// ── Apply migrations to running Supabase ──log(`${BOLD}Applying pending migrations to running Supabase...${NC}`);- let { out, code } = run("npx", ["supabase", "migration", "up"]);+ let { out, code } = run("npx", ["supabase", "migration", "up", "--local"]);if (code !== 0) {// Auto-repair phantom versions that are recorded in Supabase but absent from@@ -104,11 +104,17 @@ if (await isSupabaseUp()) {"supabase","migration","repair",+ "--local","--status","reverted",...phantomVersions,]);- ({ out, code } = run("npx", ["supabase", "migration", "up"]));+ ({ out, code } = run("npx", [+ "supabase",+ "migration",+ "up",+ "--local",+ ]));}}if (code !== 0) {diff --git a/.claude/scripts/pending-deploys.mjs b/.claude/scripts/pending-deploys.mjsindex ab4fa18d..4ccf2b23 100755--- a/.claude/scripts/pending-deploys.mjs+++ b/.claude/scripts/pending-deploys.mjs@@ -9,7 +9,8 @@//// Exit codes:// 0 — decision made (stdout empty = nothing to deploy, non-empty = paths).-// 3 — could NOT decide: the passed <SESSION_SHORT> has no session refs.+// 3 — could NOT decide: --session missing, or the passed <SESSION_SHORT>+// has session-base siblings but no refs of its own (likely a mismatch).import { execFileSync } from "node:child_process";const args = process.argv.slice(2);@@ -20,8 +21,10 @@ const get = (flag, def) => {const APP = get("--app", process.env.CLAUDE_PROJECT_DIR || "/app");const SESSION = get("--session", "");if (!SESSION) {+ // Couldn't decide — exit 3, never 0 (0 + empty stdout reads as "nothing to+ // deploy", which would silently skip a real pending deploy).process.stderr.write("--session <SESSION_SHORT> required\n");- process.exit(0);+ process.exit(3);}const refExists = (ref) => {diff --git a/.claude/scripts/test/pending-deploys.test.mjs b/.claude/scripts/test/pending-deploys.test.mjsindex e35cc145..887b069c 100644--- a/.claude/scripts/test/pending-deploys.test.mjs+++ b/.claude/scripts/test/pending-deploys.test.mjs@@ -91,6 +91,24 @@ describe("pending-deploys", () => {rmSync(dir, { recursive: true, force: true });});+ test("exits 3 (could not decide) when --session is missing", () => {+ const dir = setupRepo();+ let code = 0,+ stderr = "";+ try {+ execFileSync("node", [SCRIPT, "--app", dir], {+ encoding: "utf8",+ stdio: ["pipe", "pipe", "pipe"],+ });+ } catch (e) {+ code = e.status;+ stderr = (e.stderr || "").toString();+ }+ expect(code).toBe(3);+ expect(stderr).toMatch(/session/i);+ rmSync(dir, { recursive: true, force: true });+ });+test("fails loudly (exit 3 + stderr) on SESSION_SHORT_ID mismatch", () => {const dir = setupRepo(); // creates session-base/ab12cd34 + session/ab12cd34let code = 0,diff --git a/scripts/launch-harness.sh b/scripts/launch-harness.shindex cd93a1ad..c520ccd7 100755--- a/scripts/launch-harness.sh+++ b/scripts/launch-harness.sh@@ -5,7 +5,6 @@## Usage:# scripts/launch-harness.sh ["CRM change request"]-# MODE=full scripts/launch-harness.sh "..." # real backend (needs local Supabase up)## The request is optional: pass it to pre-fill the first message, or omit it and# type your request once the session opens.@@ -39,10 +38,7 @@ SAN="$(printf '%s' "$REPO" | sed 's#/#_#g')"SESSION_DIR="/tmp/atomic-crm-harness/${UUID}"mkdir -p "$SESSION_DIR"-MODE="${MODE:-demo}"-echo "Harness session"-echo " mode: $MODE"echo " session id: $UUID"echo " session dir: $SESSION_DIR"echo " worktree base: /tmp/${SAN}/${UUID} (created lazily by the setup-worktree hook)"@@ -55,8 +51,7 @@ ARGS=(--agent chat-orchestrator--session-id "$UUID"--permission-mode auto- --append-system-prompt "<mode>${MODE}</mode>-<session_dir>${SESSION_DIR}</session_dir>"+ --append-system-prompt "<session_dir>${SESSION_DIR}</session_dir>")if [ -n "$REQUEST" ]; thenARGS+=("$REQUEST")@@ -65,7 +60,6 @@ fiexec env \CLAUDE_PROJECT_DIR="$REPO" \CHAT_SESSION_DIR="$SESSION_DIR" \- MODE="$MODE" \DISABLE_AUTOUPDATER=1 \CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1 \claude "${ARGS[@]}"