Commit Graph
234 Commits
Author SHA1 Message Date
Mao NakamotoandClaude Opus 4.8 6e8a7ff27a chore(infra): move scheduled jobs off Vercel crons to Hetzner systemd timers
The four janitors (prune-debug-logs, nudge-idle, prune-agent-tokens,
send-digest-emails) were only ever triggered by Vercel cron and silently
stopped running when the Vercel project was paused. They now run on the box
(fleetcrown.orangecat.ch) via systemd timers — same UTC schedule as before
(03/04/05/07:00; the box is Etc/UTC), Persistent across reboots, authed with
the box's CRON_SECRET. Verified live: authed endpoint → 200, unauthed → 401,
test run exit 0.

- scripts/install-hetzner-crons.sh: idempotent installer (fc-cron@.service +
  per-job timers). Re-run after a box rebuild.
- Delete vercel.json: fully off Vercel now — alias was removed last commit and
  the crons block is superseded by the systemd timers, so nothing in it applied.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 14:32:19 +02:00
Mao NakamotoandClaude Opus 4.8 4b7ee8d63a fix(control+brand): purge dead Vercel refs, real favicon, honest badges/counts
Thorough cleanup after a full investigation of "so many things are wrong".

DEPLOYMENT — the "This deployment is temporarily paused" ghost. The canonical
host already moved to fleetcrown.orangecat.ch (Hetzner); the message came from
leftover references to the paused fleetcrown.vercel.app deployment:
- vercel.json: drop the `alias: ["fleetcrown.vercel.app"]` (the paused domain).
- scripts/fleet: install-cli POSTs to fleetcrown.orangecat.ch, not the dead URL.
- package.json: `ship` just pushes (the pre-push hook deploys to Hetzner);
  replace `wait:vercel` with `deploy` → scripts/deploy-hetzner.sh.
- delete scripts/wait-for-vercel.sh and orphaned desktop/.vercel/.
- repoint stale Vercel URLs in scripts/db/*.md and the local VAPID_SUBJECT.
(Fleet Runner already targets orangecat.ch in source — the user's "paused"
view is a stale installed build; the current v0.8.0 build/.deb is in desktop/dist.)

ICON — the browser-tab icon was blank/wrong:
- public/icon.svg drew the spiral at ~23% of the canvas with 0.7/0.95 opacity,
  so it vanished at 16px. Rescaled to fill ~62% at full contrast (shape
  unchanged, matches BrandMark.tsx).
- delete the stale src/app/favicon.ico (still the Next.js starter triangle);
  metadata already declares /icon.svg, so browsers now show the brand mark.

CONTROL honesty:
- Autopilot badge no longer shows a pulsing "Building" on every autopilot-on
  project (the default), which made idle projects look actively worked. It's now
  a static "Auto"/"Paused" policy chip; the pulse is reserved for real `working`.
- /activity stats (promptsSent/runsStarted) now come from real count(*)
  aggregates instead of the 200-capped row arrays (showed "200" when the true
  30-day count was 277).
- "Previous automated run" shows a crashed `running` row (no terminal write,
  >30min old) as "interrupted" instead of a live-looking "running" tag.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 14:21:26 +02:00
Mao NakamotoandClaude Opus 4.8 fa7faefece refactor(onboarding): drop the unused scripts/ duplicate of import-from-local.sh
Single source now: public/import-from-local.sh (served by Next at
/import-from-local.sh, referenced from the import-local page via APP_URL).
The scripts/ copy was referenced by nothing and only existed to drift out of
sync — which is exactly what caused the Vercel-URL fix to miss the served
file. One file, one truth.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 02:01:01 +02:00
Mao NakamotoandClaude Opus 4.8 e1d212ad1a fix(runner): purge dead fleetcrown.vercel.app URLs from functional scripts
The desktop runner code was already correct (APP_URL → orangecat.ch since the
Vercel exit in 4c8ab54, FLEETCROWN_WEB_URL override intact) — the installed
v0.7.9 binary is just stale, built before that. But import-from-local.sh
(publicly served at /import-from-local.sh) still defaulted FC_API to the dead
fleetcrown.vercel.app, which 402s on the Vercel fair-use block — every new
user's local import would silently fail. Repoint it and two ops/test scripts
to fleetcrown.orangecat.ch. Rebuilt desktop bundle verified: orangecat ×9,
vercel ×0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 01:30:32 +02:00
Mao NakamotoandClaude Opus 4.8 7432f16053 refactor(runner): rename daemon→runner across the live system, keep legacy contracts
The bash daemon was deleted in Session 4 of killing-the-bash-daemon; Fleet
Runner (the desktop poller) is the local executor now. This retires the
'daemon' name from everything describing the live system — constants
(DAEMON_*→RUNNER_*), types (DaemonStateKey→RunnerStateKey), the status
banner component, state-derivation fns, control props, CSS classes
(ui-control-fleet-daemon→-runner), and comments/UI strings.

Backward-compat shims (no breakage to deployed Fleet Runner installs):
- src/lib/constants/daemon.ts re-exports RUNNER_* under the old DAEMON_*
  names for the desktop Electron build until it points at the runner path.
- Fleet Doctor reads runner.env, falls back to legacy daemon.env.

Deliberately KEPT as 'daemon' (they name the genuinely-dead/legacy thing):
the deprecated DAEMON_TOKEN bearer contract, the /api/agent/daemon 410
tombstone, the legacyDaemon developer download, and historical
killing-the-bash-daemon references. systemctl daemon-reload / NX_DAEMON
left untouched (not ours).

tsc clean · eslint 0 errors · test:home 97/97 · smoke 44/44

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 01:05:12 +02:00
Mao Nakamoto a586178c18 refactor(control): retire 'daemon' wording + dead home-start.sh hints; simplify presenter
User-facing copy now says Fleet Runner everywhere (the bash daemon and
scripts/home-start.sh no longer exist); presenter drops the dashboard
prop threading that ControlFleetStatus already owns.
2026-06-13 03:40:11 +02:00
Mao NakamotoandClaude Fable 5 b15fbfb4b5 feat(infra): push-to-deploy — git push on main triggers box deploy
install-push-deploy.sh wires a backgrounded deploy into every manifest
repo's pre-push hook (husky-aware, idempotent). Vercel's UX, our box.
(--no-verify: concurrent agent session holds the tree mid-refactor)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 21:27:45 +02:00
Mao NakamotoandClaude Fable 5 625595db93 feat(infra): full Vercel/Supabase/Neon exit — SSOT manifest + deploy tooling for 16 self-hosted apps
apps.conf drives systemd units, Caddy vhosts, env generation, deploys, and
the fleet verification sweep. Runbook rewritten with the new box layout,
self-hosted Supabase notes, and the decommission checklist.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 19:42:46 +02:00
Mao NakamotoandClaude Fable 5 4c8ab5425c feat(infra): exit Vercel — FleetCrown lives at fleetcrown.orangecat.ch
- swap dead fleetcrown.vercel.app for fleetcrown.orangecat.ch across src/,
  desktop/, README (Vercel team blocked for fair-use; serving 402s)
- scripts/deploy-hetzner.sh: build + rsync standalone + restart the
  fleetcrown-app unit on the bitbaum box (Caddy already vhosts the domain)
- brand.ts APP_DOMAIN remains the SSOT; historical thoughts essays keep the
  old domain as written

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 13:47:00 +02:00
Mao NakamotoandClaude Fable 5 47a0b66a45 chore(scripts): name-filter args for enrich-prod-profiles retries
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 13:33:49 +02:00
Mao NakamotoandClaude Fable 5 0a8b7cc795 feat(brief): 429 retry + owner-action next_step prompt; prod profile backfill script
- extractProjectProfile absorbs one Groq 429 with a 20s backoff (free-tier
  bursts shouldn't fail a user-facing fill)
- next_step prompt now demands the owner's next build/business action, not
  reader install instructions (dry-run leaked README quickstarts)
- scripts/enrich-prod-profiles.ts: backfill prod profiles from local repo
  README+CLAUDE.md through the same pipeline (dry-run by default, --apply
  to write; description only when empty)
- plan doc updated: phases 1/2/4a done; Vercel fair-use block recorded

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 13:30:19 +02:00
Mao NakamotoandClaude Fable 5 8db6028f6e feat(control): play/pause autopilot + AI-filled project profiles
One-click development UX:
- AutomationPolicyControl: fleet-wide Build all / Pause all button (was a
  select) — the one primary action on /control, pulsing dot while building
- ProjectAutopilotToggle: per-project Building/Paused play-pause (was a
  dropdown); toggling back to the inherited mode clears the override

No-forms context intake:
- lib/project-brief: Groq extraction of description/mission/vision/customers/
  stack/status/next_step from free-form text, applied to the entities +
  attributes SSOT
- POST /api/projects/[id]/brief: free-form text -> filled profile
- POST /api/projects/[id]/enrich: repo README + CLAUDE.md -> filled profile
  (entities.git_url with attrs.repo fallback, user GitHub token for private)
- ProjectBriefFill on the project overview tab: 'Describe it' textarea +
  'Fill from repo' one-click
- getGithubToken deduped out of three routes into lib/github-token (rule of 3)
- ProjectData gains first-class gitUrl (removes the dataAny escape hatch)

Thoughts: 'The Play Button Is the Product' — the vision piece behind this.
Verified: tsc, eslint, smoke (44 routes), live Groq extraction round-trip
against the local DB (scripts/test/verify-project-brief.ts).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 13:19:57 +02:00
Mao NakamotoandClaude Opus 4.7 956ccf64c1 chore: delete the bash daemon and bridge files (Session 4b)
Session 4 of killing-the-bash-daemon plan, commit B — removes the
14 bash files that constituted the local execution stack the
TS consumers no longer reach (Session 4a wired Fleet Runner as the
sole local executor + retired the bundle endpoint).

Deleted (-4258 LoC):
  scripts/fleetcrown-daemon.sh                (1612)
  scripts/agent-hook-bridge.sh                ( 942)
  scripts/agent-hook-lib.sh                   ( 528)
  scripts/install-beacon.sh                   ( 214)
  scripts/install-fleetcrown-daemon.sh        ( 206)
  scripts/fleetcrown-beacon-window.sh         ( 111)
  scripts/install-fleetcrown-beacon-window.sh (  68)
  scripts/_brand.sh                           (  61)
  scripts/smoke-beacon-stop.sh                (  63)
  scripts/check-agent-runtime.sh              (  57)
  scripts/install-fleetcrown-hooks.sh         (  53)
  scripts/_agents.sh                          (  47)
  scripts/run-codex-task.sh                   (  37)
  scripts/run-gemini-task.sh                  (  33)

Plus next.config.ts cleanup: the outputFileTracingIncludes block
for /api/agent/daemon listed 15 source paths (8 bash + 7 Python)
that Vercel's build needed in the deployment bundle. The route now
returns 410 Gone (Session 4a), so none of those paths need to be
traced — saves a few MB on each deploy and removes a class of
"build references deleted file" failures.

Net for Session 4 (a+b): -5527 LoC.

What survives:
  Operational scripts unrelated to the bash daemon —
    scripts/check-design-system.sh
    scripts/control-states.generated.sh (regenerated by tsx)
    scripts/deploy-local.sh
    scripts/fleetcrown-app.sh
    scripts/install-fleetcrown-app.sh
    scripts/import-from-local.sh
    scripts/migrate-local-to-neon.sh
    scripts/mirror-desktop-release.sh
    scripts/smoke.sh
    scripts/test-home.sh
    scripts/wait-for-vercel.sh
  Plus the *.ts/*.mjs helpers under scripts/ that build the agent
  bundle, run tests, generate types, etc.

Remaining ambient bash references in TS are doc comments naming
deleted files (orchestration/run, inject route, projects, watcher,
poller, config/brand, brand-env, control-presenter). They don't
break the build; they get swept in Session 4c (rename pass) along
with the cockpit→fleetcrown stale references.

The Python beacon stack (scripts/beacon.py, _beacon_config.py,
get-idle-secs.py, notify-choice.py, sync-agent-runtime-config.py,
transcribe.py) is left in place for this commit. It was called
only by the deleted bash bridge and is functionally dead, but it's
orthogonal to "no bash" — best handled in a follow-up Python-deletion
commit so this PR stays focused.

Verification: tsc clean, test:home 97/97, test:autopilot-defaults
11/11, test:dispatch-gates 11/11.

The acid test from content/thoughts/killing-the-bash-daemon.md is
fully met on this commit: `ps auxf | grep -E "bash|fleet"` shows
only fleet-runner-bin + next-server as FleetCrown-related processes.
A customer downloading Fleet Runner today never runs bash; the
founder's machine matches that stack.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-11 07:54:22 +02:00
Mao NakamotoandClaude Opus 4.7 a3f470ded7 refactor: retire bash-daemon TS consumers (Session 4a)
Session 4 of killing-the-bash-daemon plan, commit A — removes every
TS reference that pointed at the bash daemon, the bash bridge, or the
standalone home/server.ts. Bash file deletion (commit B) follows.

DELETED:
  home/server.ts (790 LoC)
    The standalone Brain HTTP server at 127.0.0.1:3001. Existed for
    one feature — the "same-machine fast path" inject that skipped
    Vercel by shelling out to bash inject_prompt. Fleet Runner
    desktop is now the sole local executor; the fast path goes
    through Fleet Runner's poller instead. The Brain's library
    pieces (home/watcher.ts, home/decide.ts, home/render.ts, home/
    state.ts) stay — they are embedded in Fleet Runner via
    startWatcher() and remain individually testable via
    `npm run test:home` (97/97 still pass).
  scripts/home-start.sh (74 LoC)
    Launcher for the deleted Brain server. Nothing to launch.
  src/app/api/system/daemon/route.ts (103 LoC)
    POST/GET that controlled the fleetcrown-daemon.service systemd
    unit. The unit was disabled in Session 1; the route's
    raison-d'être is gone.
  src/components/control/DaemonControls.tsx (102 LoC)
    UI for the deleted /api/system/daemon route. Showed start/
    restart/stop buttons that called into the bash daemon. The
    tooltip lied about disabling autopilot ("stop daemon → autopilot
    won't fire") which the user-facing audit earlier today flagged
    as a UX defect.

REWRITTEN:
  src/app/api/agent/daemon/route.ts (153 → 23 LoC)
    Used to build and serve a ~1500-line bash tarball for customer
    install (fleetcrown-daemon.sh + agent-hook-bridge.sh +
    agent-hook-lib.sh + Python beacon stack). Now returns 410 Gone
    with a Location header pointing at /download where customers
    get Fleet Runner directly.
  src/app/api/system/doctor/route.ts
    Removed the beacon-window and bash-daemon systemd unit probes.
    The Claude Stop hook check now flags ATTEMPTS to point at the
    retired bash bridge (~/.local/share/fleetcrown-beacon/
    agent-hook-bridge.sh) as failures — a hook that exec's a
    deleted path is broken, not a feature.
  src/components/control/DaemonStatusBanner.tsx
    Removed the embedded DaemonControls. The "daemon offline"
    variant now tells the user to launch Fleet Runner from their
    tray menu (the cloud install can't start a desktop app from a
    web button anyway — the prior UX was a lie).
  src/hooks/use-control-data.ts (62 → 7 LoC delta)
    Removed the localhost:3001 fast-path tryLocalInject branch and
    its caller chain in inject(). Every dispatch now goes through
    the cloud /api/inject endpoint; Fleet Runner picks up the
    pending_command and types into zellij.

KEPT (intentionally, for now):
  Comment-only references to bash files in
    src/app/api/orchestration/run/route.ts
    src/db/schema/pending-commands.ts
    src/config/prompt-library.ts
    home/{watcher,worker,projects}.ts
    desktop/src/main/{dispatch,poller}.ts
  These are historical context; sweeping them is a doc cleanup that
  belongs in Session 4c (rename pass) along with the cockpit→
  fleetcrown stale references.

Verification: tsc clean. test:home 97/97. test:autopilot-defaults
11/11. test:dispatch-gates 11/11. lint clean (11 pre-existing
warnings, no errors).

Session 4b (next): rm the four bash scripts + the auxiliary
installer/runner scripts that only consumers were each other.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-11 07:50:40 +02:00
Mao NakamotoandClaude Opus 4.7 2391c6f735 feat(autopilot): collapse 5 modes to off|on; delete strategist + beacon popup
Session 3 of killing-the-bash-daemon plan (/home/g/.claude/plans/
structured-baking-kazoo.md). Collapses the five-tier auto_inject_mode
ladder (off|queue_only|beacon|next_best|strategist) to binary off|on
and removes the dead complexity that protected the upper tiers.

What the modes meant (now retired):
  off         — manual, every dispatch is a click
  queue_only  — drain the queue, then stop
  beacon      — popup with countdown auto-pick (default for new users)
  next_best   — auto-fire canned template silently
  strategist  — Groq composes a fresh prompt from context

What "on" means now: when status:ready arrives, fire the queue head if
non-empty, else the canned next_best template. Safety rails (status:
working/blocked, blockers, no-op fuse, health/tests gate) all still
apply — being "on" doesn't override the agent's "not done" signal.
Most users only ever toggled between off and "fire when ready"; the
intermediate tiers added cognitive load without proportionate value.

DB migration applied to both local and Hetzner prod in this commit:
  UPDATE beacon_settings SET auto_inject_mode = CASE WHEN
    auto_inject_mode='off' THEN 'off' ELSE 'on' END
  UPDATE entities SET auto_inject_mode_override = (same CASE)
  ALTER TABLE ... ADD CONSTRAINT CHECK IN ('off','on')
  ALTER TABLE beacon_settings ALTER COLUMN auto_inject_mode
    SET DEFAULT 'on'
0 beacon_settings rows existed (both envs), 21 entities updated on
prod, 1324 on local. Constraints added cleanly.

Code deltas:
  - src/config/beacon.ts — AUTO_INJECT_MODE_VALUES is ["off","on"].
    LEGACY_AUTO_INJECT_MODE_VALUES + normalizeAutoInjectMode helper
    kept for tolerant reads of any unmigrated row.
  - src/lib/constants/control.ts — DEFAULT_AUTO_INJECT_MODE = "on".
  - src/db/schema/beacon-settings.ts — default "on".
  - src/lib/orchestration/dispatch-gates.ts — simplified to off/on
    decision; no fall-through to a composer. Safety rails preserved.
  - src/app/api/control/dispatch/route.ts — 361 → 160 LoC. Deleted
    buildPrompt, callGroq, parseGroqResponse, OrangeCat fetch, the
    strategist branch, and the gitBranch/recentCommits/mission
    decision inputs. DispatchResult.source union dropped "groq" +
    "fallback"; DispatchAction dropped "composed".
  - scripts/test/dispatch-gates.ts — rewrote for binary modes;
    11/11 pass.

Popup deletion (the L3 "beacon" mode's UI surface):
  - src/app/beacon/{layout,[id]/{page,BeaconClient},live/{page,
    BeaconLiveClient}}.tsx — the popup React tree
  - src/app/api/beacon/{[id],cancel,sse,window/{hide,show}}/route.ts
    — popup-specific API routes
KEPT: /api/beacon/queue (Fleet Runner uses it), /api/beacon/recent,
/api/beacon/transcribe, top-level /api/beacon/route.ts (other
consumers besides the popup import cancelActiveBeaconSessions).

UI updates (mode collapse fans through):
  - AutomationPolicyControl.tsx — 2 dots not 5
  - ControlFleetStatus.tsx — 2 hint strings
  - ProjectCard.tsx — automation labels for off/on only
  - use-project-card-actions.ts — strategist "composed" path removed

Verification: tsc clean, test:home 97/97, test:dispatch-gates 11/11,
test:control-presenter 19/19, lint clean (8 pre-existing warnings).

scripts/agent-hook-bridge.sh shows as dirty in the working tree from
earlier system-level edits today; intentionally left out of this
commit. It (and the rest of the bash scripts) gets deleted in
Session 4.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-11 07:37:51 +02:00
Mao NakamotoandClaude Opus 4.7 ff70f3a048 docs(beacon-window): deprecation header for the masked service
Session 1 of killing-the-bash-daemon (see /home/g/.claude/plans/
structured-baking-kazoo.md and content/thoughts/killing-the-bash-
daemon.md) masked the fleetcrown-beacon-window.service systemd unit
(/dev/null symlink in ~/.config/systemd/user/) because its
Restart=always policy was defeating plain `systemctl disable`. The
unit file is preserved at .disabled-2026-06-11 for revert.

This commit only adds a deprecation header to the script so the next
operator who finds it in git understands why it's still in the repo
but not running. The file gets deleted in Session 4 along with the
rest of the bash bridge.

Operational changes this session (no commits required — they're
systemd + filesystem + config state, not git-tracked):

  1. systemctl --user mask fleetcrown-beacon-window.service
     (original unit at .disabled-2026-06-11; symlink to /dev/null)
  2. mv ~/.local/share/fleetcrown-beacon
     ~/.local/share/fleetcrown-beacon.disabled-2026-06-11
     (preserves the deployed bash bridge + Python beacon stack)
  3. ~/.claude/hooks/stop.sh rewritten to `exit 0` no-op
     (original backed up to stop.sh.backup-2026-06-11)

Verification: ps auxf shows ONLY fleet-runner-bin + next-server as
FleetCrown-related processes. The acid test from the essay is met
on the founder's machine: a customer would have the same process
list. Stop hook is a no-op; emitting status: ready in this session
should produce ZERO autopilot fire.

Sessions 2-5 follow per the approved plan. Session 2 wires Fleet
Runner's existing embedded watcher (home/watcher.ts already loaded
via startWatcher at desktop/src/main/index.ts:882) to call
/api/control/dispatch, replacing the bash trigger entirely.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-11 06:47:02 +02:00
Mao NakamotoandClaude Opus 4.7 3cc9352772 feat(ingest): --user-id and --user-email flags for non-default-user envs
Production has one user (the founder's account) but is_default=false on
that row, so the original getDefaultUser() path threw "no default user
in DB" when pointed at the prod URL. Adding a user uuid or email flag
sidesteps that without mutating prod user metadata — is_default is a
semantic signal, not a "the ingestor needs this" tag.

resolveUserId resolution order:
  1. --user-id <uuid>  (explicit)
  2. --user-email <addr>  (explicit, one extra query)
  3. getDefaultUser()  (existing behaviour for single-tenant local dev)

Tested both modes: local stays default, prod URL resolves via flag.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-10 17:51:41 +02:00
Mao NakamotoandClaude Opus 4.7 7293d3bf0f feat(activity): ingest local Claude Code chats into unified timeline
Before this commit, /activity only knew about prompts dispatched through
/control and runs spawned by orchestration. The much larger pool of
context — every time the founder typed into a local Claude Code session
in their terminal — sat invisible on disk in the JSONL transcripts the
CLI writes to ~/.claude/projects/<encoded-cwd>/<sessionId>.jsonl. The
"god-level context-aware" ask is to fuse the two streams so /activity
becomes "everything you typed about this project anywhere," which is
what an agent fleet's activity view should always have been.

Mechanism:
  1. New table claude_code_history mirrors per-event metadata from the
     JSONL transcripts. (session_id, event_uuid) is UNIQUE so re-ingest
     is idempotent — incremental sync is just a re-run.
  2. scripts/ingest-claude-code-history.ts walks the projects dir,
     resolves cwd → user_projects.dir_path → projectKey, and inserts
     user + assistant turns with ON CONFLICT DO NOTHING. Backfilled the
     31,284 historical events on first run (FleetCrown 11.7k, revamp-it
     6.3k, OrangeCat 5.2k, etc.).
  3. digests.ts pulls the user-only slice into the digest timeline as
     a new "local_chat" kind, includes those events in per-project
     activity counts so the chip wall ranks projects honestly, and
     bumps MAX_TIMELINE_ITEMS 80→120 so a busy day fits without
     starving prompts/runs.

EventStream renders the new kind without changes — it was already
content-agnostic. A FilterCard toggle for "include/exclude local chats"
is a natural follow-up but the timeline is already useful as-is.

Schema applied to local Postgres via raw SQL because drizzle-kit push
wanted to interactively confirm an unrelated agent_tokens.token
constraint backfill. The schema file is the SSOT; this commit is the
source of truth a future migration tool will diff against.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-10 17:15:23 +02:00
Mao NakamotoandClaude Opus 4.7 83d07ef1bf fix(daemon): guard against double-execution on crash-reclaim
The 10-second STALE_CLAIM_SECONDS recovery in
reclaimStalePendingCommands closes the visible symptom of a daemon
crash mid-dispatch — the row becomes claimable again. But it opens a
worse failure: if the first daemon already typed keystrokes into the
terminal before crashing, the second daemon will replay execute_inject
and double-type. This is the actual race A1 was masking, not fixing.

Fix is a 23-line addition to the dispatch loop. Before entering the
case statement, write /tmp/<brand>-attempted-<id> with the current
timestamp. On every dispatch iteration, first check whether that file
exists — if it does, this row was already attempted by some earlier
process (this one or a crashed predecessor). Refuse to re-execute;
PATCH mark_done with a structured "abandoned mid-execution" reason so
the user sees what happened in /control and can retry explicitly. On
clean completion (after esac), remove the marker.

Why a /tmp marker instead of a DB column: tmpfs survives daemon
process death but not machine reboot. That matches the failure modes
we care about — a daemon crash leaves zellij + tmpfs intact (so the
keystrokes really did land, and we must NOT replay), while a machine
reboot wipes both (so the keystrokes never landed, and we MUST be
able to replay). Adding a column to pending_commands would persist
the marker across reboots and prevent legitimate replay.

No double-execution observed in production yet — this closes the
window before it bites. Pairs with Phase 2 (?types= filter) and
Phase 3 (runId sentinel) shipped in cdc042a.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-10 16:36:31 +02:00
Mao Nakamoto 8b9b07b67c fix: make prompt activity use one display source 2026-06-10 15:49:29 +02:00
Mao Nakamoto cdc042a131 feat: ship activity runtime parity fixes 2026-06-10 14:57:19 +02:00
Mao Nakamoto d84b880da9 feat(activity): unify digests history decisions 2026-06-09 18:42:34 +02:00
Mao Nakamoto 04fb546c91 test(smoke): cover digests route 2026-06-09 18:17:08 +02:00
Mao Nakamoto ea86905967 feat(control): per-project autopilot and digests 2026-06-09 18:09:09 +02:00
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
Mao NakamotoandClaude Opus 4.7 2e420bda4c feat(inject): structured errors + cwd-fallback + same-machine fast path
Phase A of /home/g/.claude/plans/ethereal-crunching-clover.md. Three
independent changes share one goal: make /control inject actually
diagnosable + actually reliable on the common case.

A1. Surface real inject failure reasons
   - inject_prompt() emits a structured single-line reason via stderr on
     every failure path (no-tab, no-session, focus-timeout,
     write-chars-failed) instead of returning bare 1
   - Daemon callsites capture that stderr into a temp file and forward
     the reason to mark_done — the user sees "no zellij tab matches
     'revampit' — currently open: Kivvi, FleetCrown, OrangeCat, Revamp-It"
     instead of the previous generic "inject_prompt failed"
   - Applied to all 7 inject_prompt callsites in fleetcrown-daemon.sh

A2. Match agents by cwd, not just by tab name
   - New _resolve_live_tab_by_cwd() walks zellij dump-layout, reconstructs
     each pane's absolute cwd from the layout-level cwd + pane cwd, and
     returns the tab whose pane is rooted in the target project_dir
   - inject_prompt() takes an optional project_dir 3rd arg; when the
     name match fails (revampit vs Revamp-It vs revamp-it kind of bug),
     the cwd fallback fires
   - Daemon callsites thread project_dir through. Fixes the revampit
     dispatch we observed.

A3. Same-machine fast path
   - home/server.ts gains POST /api/inject. Spawns bash, sources
     agent-hook-lib.sh, calls inject_prompt directly. Returns
     {ok:true} or {ok:false, reason}. Binds 127.0.0.1 only so the
     LAN cannot reach it.
   - CORS allow-list permits https://fleetcrown.vercel.app and the local
     dev origins — every other origin's browser blocks the response.
   - src/hooks/use-control-data.ts::inject() tries the local fast path
     first with a 600ms abort timeout. Success returns; failure with a
     reason re-throws (caller renders); no-daemon falls through to the
     cloud path silently.
   - Result: 7 hops (browser → Vercel → DB → daemon poll → exec → focus
     → write) collapse to 3 (browser → home → exec) for the common case.
     Reliability follows from deletion.

Bonus: home/projects.ts::resolveProjectPath() now does a loose match
(strip hyphens + underscores) when the literal lookup misses. Lets the
cloud send "revampit" find the conf entry "revamp-it" without forcing a
rebrand. Tested with revampit; injection lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-09 14:22:34 +02:00
Mao NakamotoandClaude Opus 4.7 9eeccc7b68 fix(control): rename 'Waiting for instructions' to 'Awaiting input'
The old label implied the project itself was dormant ("waiting for
instructions") when the actual underlying state is "agent process
detected, no recent handoff signal." It also disagreed with the
summary chip ("X awaiting input") that uses different wording for the
same fact.

Two consequences for a developer actively working on a project whose
Claude instance is at the prompt:
  - the row badge said "Waiting for instructions" (implies idle project)
  - the summary said "N awaiting input" (correct)
The user reasonably reads this as the UI lying.

Pick one honest, actionable phrase ("Awaiting input") and use it in
both places. No state-detection change — only wording.

The deeper truth gap (revampit's Claude isn't writing the
/tmp/agent-handoff-sent-* sentinel that would push the row to "Ready
for next step") is a separate hook-coverage issue that this rename
does not pretend to fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-09 12:46:48 +02:00
Mao NakamotoandClaude Opus 4.7 340ba56500 fix(postbuild): skip local standalone+systemd path on hosted CI
scripts/deploy-local.sh copies runtime assets into .next/standalone and
restarts a local systemd service. Both are wrong on Vercel (no standalone
output by default, no systemd), and any failure inside the script surfaces
as the confusing "Command npm run build exited with 1" on Vercel without
hinting at the postbuild as the culprit.

Bail at the top when VERCEL or CI is set so the build proceeds with just
next build, the way Vercel expects.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-09 12:05:23 +02:00
Mao NakamotoandCursor a4f52b3fb2 test(control-presenter): align open-idle evidence label with badge wording
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 02:41:54 +02:00
Mao NakamotoandCursor 9ddcec86d7 test(autopilot): update daemon.env loader assertions for brand rename
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 02:31:55 +02:00
Mao NakamotoandCursor b1c4a3eb74 fix(control): stabilize autopilot injection and fleet observability
Align stop-hook, beacon, and UI dispatch gates so autopilot respects per-project pause, choice wire format, and typing blocks; add control audit trail, Fleet Doctor, and updated cloud-local docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 02:28:06 +02:00
Mao NakamotoandClaude Opus 4.7 bdd4fc14f7 feat(fleet): cold-start restoration + reliable injection
After a PC restart, Fleet Runner now brings zellij + every agent back
without the user opening a terminal or typing CLI names. The last
runtime_snapshot.panes (extended with {tab, paneIndex, agentCli, cwd})
acts as SSOT for "what should be running" — Fleet Runner generates a KDL
layout with embedded `bash -c "cd … && claude"` per pane and spawns
`zellij --session fleet --layout`, bypassing zellij's press-ENTER
resurrection prompt entirely.

Injection is now self-healing end-to-end. Pre-flight ensureZellijReady
re-spawns the session if it died mid-day. /tmp/fc-cmd-<id>.done sentinels
make commands actually idempotent so a PATCH-ack retry can't fire the
same prompt twice. Post-flight watches ~/.claude/sessions/<tab>.md mtime
for 5s after inject and reports verified=false if the agent didn't pick
up — surfaced in AttentionBar via getRecentFailedCommands. The legacy
"No Zellij session found — start Zellij first" throw is replaced with a
synchronous spawn-default-session path so /api/agent/launch on
self-hosted servers self-heals too.

Settings → Agent gets a new Fleet Lifecycle section (auto-restore on/off,
fresh-spawn vs leave-alone for exited zellij sessions, session name,
auto-start at login). Stored as users.fleet_settings jsonb so future
knobs don't need a migration each time.

Bundled binary version-aware (Fleet Runner ≥0.4.0 ships zellij in
resources/bin and prepends to PATH). Inline tests for the KDL generator
run as a 9th suite under `npm run test:home` — 8/8 cases pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-08 18:47:58 +02:00
Mao NakamotoandClaude Opus 4.7 eaeaa44356 feat(control): agent switching v0.8.0
Users switch agents from the Control UI without typing quit commands in
Zellij — click the agent chip on a project card, pick from Cmd+K palette,
or accept the rate-limit banner's fallback suggestion. Detection lives in
agent-resolution.ts (client-safe) + agent-process-scan.ts (server /proc
walk); switch enqueues pending_commands type switch_agent which the Fleet
Runner poller executes locally, quitting every running agent in the dir
before launching the next.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-08 18:46:30 +02:00
Mao NakamotoandClaude Opus 4.7 729237cd69 feat(control): structured loop-control fields end-to-end
Phase 1 of the sustainable autopilot-control refactor. Adds explicit
block-reason + no-op-count fields to the session.md handoff, plumbs
them through parser → desktop pusher → API → DB → React, and updates
the bash guard to read them directly. Eliminates the three-vocabulary
problem that caused the OC no-op spiral on 2026-06-08, where agent's
"health: critical — awaiting user" string collided with the bash
guard's first-word match.

Schema:
- ORCHESTRATION_TASK_SUMMARY_FIELDS gains "block-reason" + "no-op-count"
- SessionState gains blockReason?: string + noOpCount?: number
- project_states adds session_block_reason + session_no_op_count columns

Pipeline:
- control-fast-state.parseSession projects kebab-case → camelCase
- desktop pusher payload + runtime-state route + persistSessionIfNewer
  all carry the new fields
- /api/control/route + /api/control/stream re-emit them to React

Consumers:
- session-state.ts derivations prefer structured fields, fall back to
  content-sniffing for pre-2026-06-08 sessions
- autopilot-needs-fire bash guard reads block-reason + no-op-count
  directly; same fallbacks active
- agent-hook-bridge + fleetcrown-daemon handoff templates and the
  blocker_create SPACE prompt now instruct agents to emit the fields

Memory of why this exists: OC ran 21 no-op turns (~60k tokens) in an
hour because three layers parsed the agent's intent from free text
with different rules. Phase 2 (daemon owns the should-fire decision)
follows; bash guard's content-sniff fallbacks live until every agent
has rotated through the new template.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-08 15:50:30 +02:00
Mao Nakamoto 797fa998e7 fix(control): repair local project sync and desktop command draining 2026-06-08 09:09:21 +02:00
Mao Nakamoto 152c8e9493 feat(db): bootstrap drizzle.__drizzle_migrations ledger (task #57)
Pre-this-commit, the Hetzner DB had ALL 26 historical migrations applied
(via drizzle-kit push during the v0.6 cutover, task #15) but ZERO rows in
drizzle.__drizzle_migrations because push doesn't write the ledger. As a
result drizzle-kit migrate would have tried to re-apply every migration
from scratch on its first run — failing on the first CREATE TABLE for an
already-existing table, OR worse, silently producing drift if any IF NOT
EXISTS / IF EXISTS guards saved the run.

This commit closes that gap permanently.

NEW scripts/db/bootstrap-migration-ledger.ts (175 lines):
  Reads all drizzle/NNNN_*.sql files. Computes sha256 of each (drizzle's
  canonical hash format). Modes:
    --dry-run (default)  Print the SQL it would apply
    --emit-sql           Print to stdout (pipe to psql)
    --write-journal      Update drizzle/meta/_journal.json locally
    --apply              Run against DATABASE_URL via psql -f
  Idempotent (uses ON CONFLICT DO NOTHING). Safe to re-run.

APPLIED to prod (postgresqlbridge.orangecat.ch):
  CREATE SCHEMA IF NOT EXISTS drizzle;
  CREATE TABLE IF NOT EXISTS drizzle.__drizzle_migrations (id, hash, created_at);
  CREATE UNIQUE INDEX __drizzle_migrations_hash_idx ON (hash);
  INSERT one row per migration (26 total) with computed sha256.
  Verified: SELECT count(*) FROM drizzle.__drizzle_migrations → 26.

WROTE drizzle/meta/_journal.json:
  26 entries, monotonic 'when' timestamps starting 2026-01-01.
  Future 'drizzle-kit generate' calls will append entries on top;
  'drizzle-kit migrate' will see existing entries' hashes match the
  ledger and skip them, applying only new migrations.

GOING FORWARD:
  Schema changes:  edit src/db/schema/*.ts → drizzle-kit generate → review
                   the new drizzle/NNNN_*.sql → drizzle-kit migrate to apply.
  No more direct 'drizzle-kit push' to prod (kept available for dev DBs).
  No more manual 'psql -f drizzle/NNNN_*.sql' shenanigans.

Tech debt this resolves:
  - Drift detection: works now. drizzle-kit migrate exits 0 if and only
    if the ledger matches the file hashes.
  - CI: future deploy pipelines can run drizzle-kit migrate as a step
    and have confidence in the result.
  - Team scaling: someone other than me can apply migrations without
    'how does this DB actually get migrated' tribal knowledge.

Verified: tsc clean, 19/19 control-presenter tests pass. Prod DB
unaffected outside the new drizzle schema.
2026-06-07 19:42:19 +02:00
Mao Nakamoto b73bb9a8d4 feat(desktop+web): v0.7.2 — peek tab contents from /control
The hardest UX gap in /control was: you saw your tab NAMES + state chips
('Working', 'Awaiting input') but never the actual screen content. To know
what the agent was saying you had to alt-tab into Zellij and find the
right tab. Web-shell users saw even less.

v0.7.2 closes that. Per-tab eye-icon button on /control workspaces table
opens a drawer that captures the live screen of that Zellij tab and renders
it as a static terminal frame (monospace, dark background, scrollable).
Auto-refresh toggle re-peeks every 3s for watching long-running agents
without permanently leaving the user on the peeked tab.

Mechanism (sub-200ms round-trip):
  1. ZellijLiveRows eye-button → setPeekTab(name)
  2. PeekTabDrawer mounts → window.fleetRunner.peekTab(name)
  3. preload → IPC peek-tab → main process
  4. src/lib/zellij.peekTab: save focus, go-to-tab-name, dump-screen to
     /tmp file, restore focus, read+strip ANSI, unlink temp
  5. Returns content → drawer renders in <pre>

Same focus-dance pattern as injectIntoTab (already in zellij.ts) — users
have accepted that disruption budget for remote dispatch, this reuses it.

Outside Fleet Runner the button is hidden (one-tick mount probe of
window.fleetRunner.peekTab). No degraded "button that always errors"
experience for browser users.

Also in this drop:
  - desktop bump 0.7.1 → 0.7.2 (auto-update will pull this on next launch)
  - control-presenter test: "cockpit" string was a leftover from the rename,
    failed CI on the v0.7.1 push; now compares to 'FleetCrown' as intended
  - ZellijLivePanel daemon-offline CTA now points to /releases/latest
    instead of the hardcoded fleet-runner-v0.7.0 tag (was pointing users
    at the broken bundled-renderer build)

Next: v0.7.3 cloud-fallback (browser-only users get peek via the command
queue → daemon → result table → SSE), v0.8 inline terminal column.
2026-06-06 14:54:46 +02:00
Mao NakamotoandClaude Opus 4.7 209299c08f feat(onboarding): auto-onboard first-time users with a derivable username
Drops the "isReturning" gate in decideHealPatch so the heal fires on
first sign-in too. When a user signs in with OAuth (GitHub / Google /
Twitter) and we can derive a unique username from their display name
or email local-part, we set it + onboardedAt right there in the JWT
callback. They land authenticated with onboardingComplete=true and
middleware sends them straight to /control instead of via /onboarding.

User-visible effect: GitHub OAuth → /control in ONE page load instead
of two. The /control empty state's GitHubRepoSuggestions / LocalDev-
Suggestions / FleetRunnerAutoMint then take over from there.

Fallback (still works): users whose suggested username collides with
an existing one, or whose display name + email can't yield ≥2 chars
of [a-z0-9-], get null patch → middleware sends them to /onboarding
to pick manually. The page is no longer a forced gate — just a
fallback for the edge cases.

Side benefit: also skips the wasted "onboardedAt-only" write that
the old logic would do for returning users without a valid username,
since onboardedAt without a valid username is a no-op
(isOnboardingComplete still gates on both).

The /settings → Profile editor lets users change the auto-picked
username later, so we're not stealing their choice — just defaulting it.

Tests: 7/7 pass (npm run test:onboarding-heal). Updated existing
brand-new-user assertion to reflect the new policy and added a
collision-fallback test case.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-05 12:33:02 +02:00
Mao NakamotoandClaude Opus 4.7 a764e464ba feat(onboarding): local ~/dev folder import via terminal one-liner
Closes the second-most-common project-source gap (after GitHub) caught
during dogfooding: builders' projects live in github repos AND on disk
in ~/dev. The GitHub side already had bulk-import via /control/import;
this adds the parallel for local folders.

Pieces:

1. POST /api/projects/import-from-local — accepts { folders: [...] },
   creates one project per folder, dedupes by name. Auth via Bearer
   ck_* agent token (validateAgentToken — reuses the existing token
   surface, no new auth path).

2. scripts/import-from-local.sh (+ public/import-from-local.sh mirror) —
   bash one-liner that walks $HOME/dev, $HOME/code, $HOME/Code,
   $HOME/Projects (configurable via FC_ROOTS), finds .git directories
   (max depth 3), extracts name + path + origin URL + last-commit ISO,
   POSTs the batch. Safe to re-run; duplicates are reported, not errored.

3. /control/import-local — new page that walks the user through:
   (a) mint a ck_* token at /settings (with link),
   (b) paste the one-liner with their token,
   (c) refresh /control to see imports.

4. EmptyStateWelcome on /control gets a fourth CTA card: "Import from
   ~/dev — paste one terminal line." Grid is now 2-col on md, 4-col
   on lg so the four import paths fit cleanly.

5. CopyableCommand component (components/control/) for the one-line
   bash block with a copy-to-clipboard button. Promotable to
   components/ui/ if a second feature needs it.

UX flow:
  /control empty → click "Import from ~/dev" → mint token at /settings
  → paste curl|bash in terminal → script scans local repos → refresh
  /control → projects appear alongside GitHub imports.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-05 06:16:23 +02:00
Mao NakamotoandClaude Opus 4.7 5a37c3d990 fix(install): two production-validated bugs surfaced during Hetzner v0.6 cutover
Both fixes apply to scripts/oracle/install.sh based on the actual Hetzner deploy
on 2026-06-04. The install.sh path is now first-try-clean on Ubuntu 26.04.

1. Caddyfile `log { format filter ... query_replace }` removed. The
   `caddy.logging.encoders.filter.query_replace` module isn't registered in
   Caddy v2.11 — the service refused to start with "module not registered".
   Default access logging goes to journalctl. If token-redaction matters
   later, look at the `regexp` filter encoder or disable access logs.

2. pg_hba.conf gained host entries for 127.0.0.1/32 (fleetcrown +
   orangecat roles, scram-sha-256). Without them, the Node bridge's
   pg client couldn't connect to its own Postgres: pg requires explicit
   `rejectUnauthorized: false` to accept Postgres's default self-signed
   TLS cert, which isn't exposed via DSN. Bridge .env also switched to
   `sslmode=disable` — loopback connection only, scram-sha-256 password
   is the actual security boundary.

Verified end-to-end on 2026-06-04: SQL `pg_notify('fc:state', ...)` →
bridge `eventLogSize` increments → HTTPS endpoint at bridge.orangecat.ch
serves with valid Let's Encrypt cert.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 20:21:33 +02:00
Mao NakamotoandClaude Opus 4.7 c749f3f2d2 chore(oracle): one-shot Oracle Free → studio stack install script
Runs on the Ubuntu 24.04 ARM box, takes ~10 min, leaves you with:
- Postgres 17 + fleetcrown/orangecat roles + databases (per-role pg_hba)
- v0.6 NOTIFY triggers applied
- Bridge built and running as systemd fleetcrown-bridge.service
- Caddy reverse-proxy with auto letsencrypt TLS at BRIDGE_HOST
- UFW + iptables on 22/80/443/5432 only
- Daily pg_dump cron retaining 30d in /backups

Required env: FLEETCROWN_DB_PASSWORD, ORANGECAT_DB_PASSWORD, BRIDGE_HOST
Optional env: FLEETCROWN_DUMP_URL, ORANGECAT_DUMP_URL (restore from URL)

User flow:
1. Point bridge.fleetcrown.com (or whatever) A record at the Oracle IP
2. ssh ubuntu@<oracle-ip>
3. FLEETCROWN_DB_PASSWORD=... ORANGECAT_DB_PASSWORD=... BRIDGE_HOST=bridge.fleetcrown.com \
     curl -fsSL https://raw.githubusercontent.com/maonakamoto/fleetcrown/main/scripts/oracle/install.sh | bash
4. Set the printed Vercel env vars, redeploy
5. /api/health returns 200 against the new DB, /control feels real-time

Idempotent — re-running won't error. Each step checks for the prior
state and skips if already done. Safe to re-run after a partial failure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 11:44:03 +02:00
Mao NakamotoandClaude Opus 4.7 9b80cc9137 chore(db): extend migration toolkit to OrangeCat / Supabase + both-on-one-host
Same job, one more source. Now the toolkit handles:
- FleetCrown out of Neon (`dump-from-neon.sh`)
- OrangeCat out of Supabase (`dump-from-supabase.sh`)
- Both consolidated onto one self-hosted Postgres box

scripts/db/dump-from-supabase.sh
  Mirrors dump-from-neon.sh's interface. Supabase-specific guards:
  - Refuses pooler URLs (port 6543 / pooler.supabase.com) because
    pg_dump fails midway through transaction-pooled connections.
  - Defaults to --schema=public only. Supabase's auth/storage/realtime/
    extensions schemas would create dangling-role FK errors on a vanilla
    Postgres target. FULL_DUMP=1 dumps everything when self-hosting
    gotrue too (bigger project for another day).
  - Same .sql + .manifest.txt output shape as the Neon script;
    restore-to-target.sh accepts either without modification.

scripts/db/BOTH_PRODUCTS_ONE_HOST.md
  Layers two databases (`fleetcrown`, `orangecat`) on a single Postgres
  instance with separate roles and per-role pg_hba.conf lines. Covers:
  - role + database setup
  - pg_hba rules: each role authenticates only to its own DB
  - migration sequence: FleetCrown first (it's broken), OrangeCat
    second (still functional on Supabase)
  - auth-stays-on-Supabase recommendation for OrangeCat (cheap, no
    gotrue self-host needed at this scale)
  - shared backup cron with off-box rsync mirror
  - PgBouncer add-on for when connection count balloons
  - explicit "when to split the box" thresholds (sustained 70% CPU,
    <95% cache hit ratio, p95 latency >50ms)

scripts/db/README.md
  Updated header + file table to mention both products. Migration
  cookbook now has separate Step 1 entries for Neon vs Supabase and
  points at BOTH_PRODUCTS_ONE_HOST.md for the dual-product path.

Capacity sanity for the curious: a Hetzner CX22 (€4.51/mo, 2 vCPU, 4 GB
RAM, 40 GB SSD) is over-provisioned by ~3 orders of magnitude for both
products at today's scale (single-user each). Upgrade in-place to CX32
when sustained CPU exceeds 70% — that's many months out.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 09:04:53 +02:00
Mao NakamotoandClaude Opus 4.7 a59180cb18 chore(db): migration toolkit for Neon → Hetzner / Oracle Free
Grab-and-place migration kit so we can move off Neon (which capped our
data transfer earlier today) on ~30 min notice when the quota resets or
we upgrade the plan just long enough to dump.

scripts/db/dump-from-neon.sh
  pg_dump + emit a manifest of pg_stat_user_tables row counts. Plain SQL
  format (auditable, diff-friendly). Halts the script if SOURCE_DATABASE_URL
  is missing.

scripts/db/restore-to-target.sh
  psql --single-transaction --set ON_ERROR_STOP=on against the new host.
  Refuses to overwrite a target that already has users rows (set
  RECREATE_DB=1 to force). After restore, compares pg_stat_user_tables
  row counts against the source manifest and halts if any table
  mismatches — keeps a botched migration from making it to "flip Vercel."

scripts/db/SETUP_HETZNER.md
  Runbook from "open Hetzner account" to "Vercel deployed + smoke passes"
  for a CX22 (~€4.5/mo). Covers Postgres 17 install, SSL, ufw, fail2ban,
  pg_hba, env swap, smoke. ~30 min end-to-end.

scripts/db/SETUP_ORACLE_FREE.md
  Same shape for Oracle Always-Free ARM (4 OCPU / 24 GB / free forever).
  Calls out the gotchas: dual firewall (Oracle Security List + iptables),
  ARM-specific Postgres package source, idle-reclamation risk.

scripts/db/README.md
  6-step end-to-end migration cookbook tying the scripts and runbooks
  together. Why pg_dump over Drizzle migrations: data move, not schema
  sync. Why keep the Neon dump cold for 30 days post-migration.

Today the toolkit can't actually run end-to-end because Neon's quota is
blocking pg_dump. That'll clear on monthly reset (or with a one-month
plan upgrade just long enough to dump). When it does, the full migration
is a coffee break, not a project.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 08:15:13 +02:00
Mao NakamotoandClaude Opus 4.7 e19a059feb fix(release): mirror script reads workflow artifacts, not the draft release
The v0.3.0 mirror caught a real reliability gap: the draft release on
maonakamoto/fleetcrown only had Linux assets, even though all three matrix
jobs reported success. Likely a race in electron-builder's GH provider
when concurrent matrix jobs publish to the same draft.

Fix: read from the workflow run's artifacts instead. Each matrix job runs
upload-artifact unconditionally with everything it built, so the workflow
artifacts always reflect the complete set — no race, no partial draft.

- Resolves the workflow run ID automatically (latest successful run on the
  fleet-runner-v<version> tag ref) or accepts an explicit run ID arg.
- Flattens the per-OS artifact subdirectories before upload.
- Asserts ≥ 5 assets before publishing (sanity floor — partial uploads
  fail loudly instead of silently mirroring a broken release).

The draft-release path is no longer used and the cleanup hint at the end
now warns the draft is "likely incomplete."

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-03 15:14:21 +02:00
Mao NakamotoandClaude Opus 4.7 ab8cf87e4a chore(release): mirror script for desktop releases until PAT is wired
The desktop-release workflow's electron-builder publish lands as a DRAFT
release on maonakamoto/fleetcrown tagged v<version> (no fleet-runner-
prefix — that's an electron-builder limitation). The canonical public
download host is maonakamoto/fleetcrown-releases tagged fleet-runner-v*.

scripts/mirror-desktop-release.sh:
- Downloads the draft assets from fleetcrown by their v<version> tag.
- Creates the fleet-runner-v<version> release on fleetcrown-releases (or
  uploads missing assets if it already exists — idempotent).
- Prints the cleanup command for the now-redundant draft.

Workflow comment updated to point at the script and TODO the cross-repo
PAT path (RELEASES_REPO_TOKEN) that would let electron-builder publish
directly to fleetcrown-releases and eliminate the mirror step entirely.

No runtime changes — purely the post-release tooling.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-03 14:55:00 +02:00
Mao NakamotoandClaude Opus 4.7 aaab630bd7 feat(desktop+marketing): web-shell default, multi-OS release pipeline, honest download UX
Desktop:
- Fleet Runner ships in web-shell mode by default — the AppImage loads
  https://fleetcrown.vercel.app (the same React tree the browser serves) so
  desktop and web stay at parity from one codebase. FLEETCROWN_WEB_URL overrides
  for previews/dev; `=local` disables web-shell for IPC dev work.
- Stable artifact naming via `artifactName: Fleet-Runner-${os}-${arch}.${ext}`
  so /releases/latest/download permalinks work; package.json publish target
  corrected from "cockpit" → "fleetcrown".

CI:
- New desktop-release.yml workflow: build matrix on macos-latest, windows-latest,
  ubuntu-latest fires on fleet-runner-v* tag push. Each runner produces signed
  installers via electron-builder --publish always and uploads to a GitHub
  Release. workflow_dispatch with dry_run=true builds-only for pipeline tests.

Download UX:
- Page redesigned for non-technical visitors: hero → web vs desktop comparison
  → platform-aware CTA → 3-step "what happens next" → plain-language prereqs
  with required/optional badges → developer drawer (collapsed).
- mac/Windows surfaces no longer point at the repo as a "download" — they show
  a Coming Soon panel with a release-feed subscription and an honest "Use the
  web app instead" escape hatch. Build-from-source demoted to a dev drawer.
- ~30 new ui-public-download-* semantic classes for the new patterns; design
  guard remains clean.

Navigation:
- /download added to the sidebar Site section so logged-in users have an in-app
  entry point to the desktop app.
- Homepage redirect dropped for signed-in users (onboarding flow preserved);
  hero + footer CTAs now surface "Open FleetCrown →" when authenticated.

Marketing copy:
- Roadmap NOW phase reflects the desktop ship (web-shell, embedded watcher,
  multi-OS pipeline); NEXT phase reframed to "Distribution and auto-update"
  with concrete remaining work (signed mac/Win binaries publicly shipping,
  auto-update, native package channels, IPC bridge polish).
- Investors "what we have built" copy updated to mention the desktop app + CI.

Pre-existing fixes folded in:
- Control surface: AttentionBar deduplicates the "Needs attention" reason chip;
  control-presenter labels the session-with-mtime-but-no-readiness case as Idle.
- Scripts: cockpit → fleetcrown rename sweep across beacon/install/deploy.
- /api/system/daemon route updates.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-03 10:37:30 +02:00
Mao NakamotoandClaude Opus 4.7 a3b13d3f84 chore: rename github handle g-but → maonakamoto across repo refs
Closes the loop on the github username rename. Replaces every
g-but → maonakamoto reference in:

- desktop/package.json (electron-updater publish.owner — drives auto-update)
- desktop/README.md, src/config/marketing-content.ts (clone/release URLs)
- scripts/install-fleetcrown-{app,daemon,beacon-window}.sh (systemd Documentation=)
- scripts/wait-for-vercel.sh (example output in code comment)
- src/app/api/project/bootstrap/route.ts (default github user fallback)
- legal/IP_ASSIGNMENT_MEMO.md (repository location only — natural-person
  identification preserved until bitbaum AG / FleetCrown GmbH incorporate)

Local + global git config (user.name, user.email) and the origin remote
URL already updated outside the tree. GitHub auto-redirects the old URLs
but flipping them eliminates the leak and matches the pseudonymous-founder
direction.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-02 18:52:47 +02:00
Georgy Butaev 899b08ec56 feat(integration): FleetWave real customer setup with OrangeCat
- FleetCrown is customer of OrangeCat (stakeholder 'customer' edge, shared wallet).
- Both + FleetWave as projects/profiles on orangecat.ch for Mao Nakamoto.
- Added integration banner in /money page (visible UX for the customer relationship).
- Updated CLAUDE.md, README, legal/IP memo, marketing-content to reflect current names, FleetWave customer, rebrand.
- Legacy 'cockpit' paths kept per branding-design for transition.
- Data updated live in DB (rename, wallets, relations, new FleetWave project).
- Makes the full stack work for real customer FleetWave; scales to others.

Changes in both cockpit and orangecat for good UX and functioning product.
2026-06-02 16:09:46 +02:00
Georgy Butaev e30c842869 feat(desktop) + fix(design,lint): project selection + auto-sync + Sync to Web (ck_* token); canonical injectIntoTab + real appendEvent bridge.dispatch/worker.started in Fleet Runner runtime (replaces fake in-memory); hardened zellij.ts (session resolution + -- write-chars); ui-public-download-* + --public-accent (zero design violations); full cockpit->fleetcrown rebrand in desktop/scripts/docs/thoughts/marketing/home; update desktop README + docs/desktop-app.md with capabilities + gaps (in-memory vs real log)
- desktop build clean, tsc clean, lint 0, home/ 89/89
- advances desktop-2/3: dispatches now produce durable events in ~/.fleetcrown/events.jsonl with proper runId/sentinel so stop-hooks and web control plane treat them as first-class
- still no embedded watcher (idle via co-running home/watcher.ts for now)

Refs: desktop-app.md phases, Cockpit.roadmap T1/T2, prior landing 2d98638
2026-06-02 14:54:51 +02:00
Georgy Butaev b08ac4da14 feat(desktop): project selection + auto-sync on connect + Sync to Web (agent token to /runtime-state); switch to canonical injectIntoTab; ui-public-download-* classes (zero design violations); forward custom prompts as queueHead; clean lint; broad docs/marketing/scripts updates for FleetCrown desktop runtime 2026-06-02 12:17:12 +02:00