Files
loki/scripts
Mao NakamotoandClaude Opus 4.7 f0d4795945 feat(states): finish SSOT — bash vocab + agent prompt context + daemon banner
Phase B + C + D of /home/g/.claude/plans/ethereal-crunching-clover.md.

B1. Generate bash state vocabulary from the TS SSOT
   - scripts/generate-bash-state-vocab.ts reads STATE_DEFINITIONS from
     src/lib/control-states.ts and emits scripts/control-states.generated.sh
     with FC_LABEL_<KEY>, FC_DESCRIPTION_<KEY>, FC_COUNTER_CATEGORY_<KEY>
     for every state.
   - Wired into package.json's prebuild step so every `npm run build`
     refreshes the file. Daemon sources it; new states propagate without
     hand-editing any bash.

B2. Agent prompt context reads STATE_DEFINITIONS[k].description
   - buildPromptWithSession(base, tab, projectStateDescription?) gained
     a third optional argument. When passed, prepends
     "Project state: <description>" before the session-state block — the
     same one-line WHY the human sees on the badge hover tooltip.
   - deriveProjectStateKey() in control-states.ts maps the raw signal
     set (agentRunning / tabOpen / sessionStatus / readyAt / lockAt /
     closingAt / closedAt) to a ProjectStateKey without dragging in the
     full presenter machinery.
   - Threaded into /api/inject (promptKey path) and the Claude +
     Codex/Gemini paths in /api/orchestration/run. The agent now reads
     the same words the user reads.

C. ControlFleetStatus migrated to DAEMON_STATE_DEFINITIONS
   - lib/control-states.ts gains a sibling SSOT for daemon-side states
     (setup_needed / offline / state_unknown / connected). Same shape:
     label, description, dotClass, problem hint.
   - ControlFleetStatus reads from it for the banner label + tooltip +
     problem CTA, dropping the hand-rolled `daemonNeverSeen ? "Setup
     needed" : daemonOffline ? "Daemon offline" : ...` tree.
   - "Setup needed" surfaces an "Install Fleet Runner" action chip
     linking to /download with the longer how-to on hover — same
     pattern the per-project badge uses.
   - DaemonStatusBanner (the rich 320-line install/recovery card) is
     left alone — its UX is distinct from the status indicator.

D. Cleanup
   - fleetcrown-daemon.sh now traps EXIT in addition to INT/TERM and
     kills its forked sibling daemons (the multi-source polling forks
     spawned for each FLEETCROWN_BASE_URLS entry). Was a defensive
     improvement; the observed "12+ stale daemons" turned out to be
     normal subshell tree.
   - .env.vercel.production renamed to .OLD so an accidental
     `vercel --prod` from CLI doesn't reupload the stale Neon URLs over
     the live Hetzner Postgres (memory/pattern_vercel_cli_env_local_override.md).
     .gitignore extended to keep the .OLD file out of git too.
   - DATABASE_URL + DATABASE_POOL_URL moved from a single-branch preview
     scope to all-preview, so future PRs build without the
     "DATABASE_URL is required" build crash we hit on the
     arch/control-stream-no-poll branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-09 14:50:42 +02:00
..