Commit Graph
37 Commits
Author SHA1 Message Date
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.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 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 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 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 acb81480b5 feat(orangecat): persist orangecat_service_id + render "OC ✓" badge on /money
Closes the Loop A persistence story. After
syncSubscriptionToOrangeCat() succeeds, the subscription row now stores
the OrangeCat service id back, so the /money page can render a per-row
"OC ✓" badge and future backfill jobs can target only the still-null
rows.

Schema (drizzle migration 0021):
- subscriptions.orangecat_service_id (uuid, nullable). Null = not
  mirrored (integration off, sync failed, or row predates the
  integration). Apply via `npm run migrate`.
- Partial index on (user_id) WHERE orangecat_service_id IS NULL — the
  shape the "what still needs syncing" backfill query will use; the
  column is mostly null for now.

orangecat.ts:
- syncSubscriptionToOrangeCat() now writes the back-link after a
  successful POST. The DB update is also non-fatal — OrangeCat already
  has the truth, and the next /money render still reflects the synced
  state once the column is populated.

UI (/money page SubRow):
- New "OC ✓" badge appears next to the subscription name when
  orangecatServiceId is present. Hover shows the OrangeCat service id
  for cross-system debugging.

SDK bump:
- @orangecat/sdk moved from 0.1.0 → 0.2.0 (file:vendor/). 0.2.0 adds
  .list() on every resource, which a future backfill script uses to
  enumerate what's already on the OrangeCat side before re-syncing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-03 16:06:15 +02:00
Mao NakamotoandClaude Opus 4.7 1e969983c0 feat(orangecat): Loop A — mirror subscriptions to OrangeCat via @orangecat/sdk
First real cross-product call from FleetCrown into OrangeCat. Whenever a
FleetCrown user adds a subscription on /money, the same record is
mirrored into OrangeCat as a `service` owned by the FleetCrown group
actor. Mao now sees FleetCrown's monthly burn inside the OrangeCat
ledger — the bitbaum studio narrative gets its first real data point.

- Adds @orangecat/sdk@0.1.0 as a file:vendor/ dep
  (vendor/orangecat-sdk-0.1.0.tgz committed; mirrors npm-install
  semantics for dev + Vercel until the SDK is published).
- src/lib/integrations/orangecat.ts: singleton client, no-ops when
  ORANGECAT_API_KEY is unset. syncSubscriptionToOrangeCat() is
  fire-and-forget — never throws, never blocks the subscription POST.
  Stable Idempotency-Key (`fleetcrown_sub_<id>`) so retries dedupe
  cleanly when server-side dedup lands.
- src/db/queries/money.ts: hook fires after the DB insert returns.
  Whether the OC sync succeeds or fails is irrelevant to the user
  response — the local subscription is already persisted.
- .env.example: documents ORANGECAT_API_KEY + ORANGECAT_API_BASE.

Reliability defaults baked in by the SDK: 20s timeout, 3 exp-backoff
retries on network / 5xx / 429 honouring Retry-After, User-Agent
identifying FleetCrown, AbortSignal-clean.

Failure modes are non-fatal and logged with enough context for backfill:
- ORANGECAT_API_KEY unset → silent no-op (most dev envs today)
- OrangeCat returns OrangeCatError → console.warn with code+status,
  subscription still saved locally
- Network error → SDK retries internally, then console.warn

Follow-ups (each its own commit, all post-this-spike):
- schema: add subscriptions.orangecat_service_id column so the link
  persists and the UI can render a "Synced ✓" badge
- once /api/v1 exposes GET via integration-key auth, run a backfill
  job for existing subscriptions
- when OrangeCat publishes the SDK to npm, replace the vendor/ tarball
  with a normal version range

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-03 15:27:51 +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
Georgy Butaev 5bc875fb3a feat(desktop): introduce Electron Fleet Runner (local authoritative runtime) with home/ stack integration, x.ai minimalist styling, dispatch with real prompt rendering + zellij injection, and electron-builder packaging for AppImage/deb 2026-06-02 10:59:30 +02:00
g-butandClaude Opus 4.7 1bfe2d1751 refactor(prompts): unify two prompt sources behind one TS SSOT
Until today, prompts lived in two parallel files: 35 entries in
~/.config/agent-prompts.json (out-of-repo, snake_case keys,
dev/ship/vision taxonomy + dimensionId) and 35 in
src/config/prompt-library.ts (in-repo, kebab-case ids, domain
taxonomy + scope). 12+ duplicate pairs with subtly different
bodies; 6 security prompts in TS only (invisible to DimensionSection
in /control); 6 control prompts in JSON only (invisible to /prompts
library page and ProjectPromptLibrary modal). Adding a new prompt
required two edits in two formats. Real SSOT violation.

This commit promotes the in-repo TS file to canonical SSOT for
prompt METADATA (id, name, description, category, scope, style,
slot, sendNow). For the subset of prompts that also need to be
dispatchable by the autopilot daemon, an optional `agentKey` field
ties the TS entry back to the snake_case identifier the daemon
expects. JSON becomes a build artifact, regenerated from TS via
`npm run generate:agent-prompts`.

Mechanics:

- PromptTemplate type gains optional agentKey, icon, style, slot,
  dimensionId, sendNow fields. Category enum gains "control" and
  "content". CATEGORY_META extended. No breaking changes to existing
  fields.

- All 6 JSON-only control prompts (hard_stop, blocker_create,
  orient, unblock, roadmap_check, onboarding) added to TS with
  agentKey set to their daemon key + dimensionId: "control". They
  now appear in BOTH /prompts library page AND DimensionSection AND
  remain dispatchable by the daemon. hard_stop is the only one
  flagged sendNow:true (kill switch — preview makes no sense).

- /api/prompts/agent route gains a mergePromptSources() helper that
  reads JSON, transforms TS entries with agentKey, dedups by key
  (TS wins on conflict). The DimensionSection in /control now sees
  the unified set without a UI change. Old reference to
  PROMPTS_FILE() preserved so the daemon still works during the
  incremental migration.

- New scripts/generate-agent-prompts.ts generator transforms
  PROMPT_TEMPLATES → AgentPrompt[] and writes them back to JSON,
  preserving any legacy JSON entries not yet migrated. Wired as
  `npm run generate:agent-prompts`. Backup of pre-regen JSON kept
  at ~/.config/agent-prompts.json.bak-20260531-ssot.

Verification: tsc clean. Generator dry-run output: 35 entries (29
legacy + 6 TS-overridden). The 6 TS-sourced entries are byte-
identical to their old JSON bodies (same key, same prompt text).

Adding a new prompt is now ONE TS edit. Migrating the remaining 29
JSON-only entries to TS is a follow-up commit; the bridge keeps
everything working during the transition.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-31 06:51:58 +02:00
g-butandClaude Opus 4.7 b89fdfc9d2 fix(dispatch): gate autopilot on status:working + pending blockers
Live-incident regression. Earlier today the autopilot injected a
2000-char next_best template into the user's keystrokes mid-typing
while they were composing a message to the agent, producing garbled
text like "wtf ust happened? what is this injecSetup (run, read
outputs):...". The session handoff said status:working — which is
documented in three places as the suppression signal — but the
daemon fired anyway because nothing in the dispatch pipeline
actually read the status field.

Root cause: agent-hook-bridge.sh:autopilot_dispatch_and_inject()
extracted done/next/tests/todos/health from the session file but
not status. The dispatch route's HandoffSchema didn't include
status either. The user trusted a guarantee the code never made.

Three coordinated fixes:

1. agent-hook-bridge.sh now reads `status:` from the session file
   AND counts files in ~/.claude/sessions/<P>.blockers/pending/.
   Either condition (status:working OR blockerCount>0) causes the
   daemon to skip the dispatch HTTP call entirely — saves a network
   round-trip and surfaces the gate in daemon logs.

2. The dispatch route's HandoffSchema gains a `status` field and
   the body gains `blockerCount`. Defence-in-depth: even if a
   custom integration or cloud-only caller bypasses the daemon's
   client-side gate, the route refuses to act on a working status
   or pending blockers. Two new DispatchResult.source values
   (status_gate, blocker_gate) make these refusals greppable in
   logs.

3. The gate logic moves out of the route handler into a pure
   helper at src/lib/orchestration/dispatch-gates.ts so the
   invariants can be unit-tested without spinning up a real Next
   request. 11 inline tests cover: status:working wins over every
   mode; blockers beat happy-path; legacy empty status preserves
   existing permissive behavior; etc. Wired into
   `npm run test:dispatch-gates`.

Closes the highest-impact symptom of the strategist's broken trust
model. The user can now leave autopilot on and trust that their
status:working handoff actually stops it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-31 06:45:24 +02:00
g-butandCursor 60f0cff749 feat(push): web push subscriptions and stop-hook notifications
Adds VAPID-backed subscribe/notify API, service worker, top-bar pill,
and Stop hook push_notify_stop for ambient agent-done signals on mobile.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-30 21:05:35 +02:00
g-butandClaude Opus 4.7 997f1aa622 feat(autopilot): flip default auto_inject_mode to strategist
Cockpit's promise is autopilot — agents keep working when you're away.
The "queue_only" default introduced 2026-05-25 silenced the strategist on
day one, leaving new users in a non-autopilot product. Safety rails are
already in /api/control/dispatch (manual override, health gate, hard_stop,
queue priority) and the Stop hook respects them; the day-one risk that
prompted the flip no longer applies after /control became trustworthy in
6da8d7e + 7d7c40a.

Centralizes the default in DEFAULT_AUTO_INJECT_MODE (src/lib/constants/
control.ts) so the schema, queries, Settings UI, and Python/shell fallbacks
all source one constant. Adds an inline self-test (test:autopilot-defaults)
that pins every fallback to the autopilot value, wired into pre-push.

Existing users keep their explicit choice — only NEW rows get strategist.
The Drizzle migration is idempotent and reaffirms the column default.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 13:31:13 +02:00
g-but f6dc058459 chore(repo): sharpen public repo surface 2026-05-28 12:47:41 +02:00
g-but 8f80b56b19 fix(orchestration): preserve LOOP v2 handoff signals 2026-05-26 10:38:51 +02:00
g-but 047e29ceb6 test(auth): pin heal decision logic with 6 unit tests via pure split
Extracted the branch logic from healReturningUserOnboarding into a
pure decideHealPatch() function in src/lib/onboarding-heal-decision.ts,
so it can be unit-tested without spinning up Postgres (the previous
location imported @/db/queries/* transitively, which fails at import
time without DATABASE_URL).

The I/O wrapper in onboarding-heal.ts now resolves projectCount and
suggested-username availability up front, then delegates the patch
decision to the pure function. Re-exports decideHealPatch + HealPatch
type so existing callers don't need to update import paths.

Test suite (npm run test:onboarding-heal) covers the six observable
branches:
  - brand-new user → no heal
  - returning user + free suggestion → both fields patched
  - returning user + taken suggestion → onboardedAt only
  - already-onboarded + valid username → no heal
  - legacy migrated row (onboardedAt set, no username) → username only
  - zero projects + onboardedAt set → still treated as returning

The never-throws contract on the I/O wrapper is verified by inspection
(try/catch wraps every await — there is no test-framework-friendly way
to inject a throw through the @/db import boundary without a real DB).
2026-05-24 23:43:12 +02:00
g-but f20e520268 feat(infra): oracle-await script + cutover SKIP_DUMP/NODE_ENV hardening
Finishes the Oracle migration plumbing started in ec6f423. Three pieces:

1. scripts/db/oracle-await-cutover.sh — polls
   ~/.config/cockpit/oracle-migration.env every 15s for ORACLE_HOST
   (timeout 7200s by default), then runs oracle-cutover.sh with
   SKIP_DUMP=1 once the IP is set. Lets the operator launch this
   before creating the VM in the Oracle console; cutover fires
   automatically the moment the public IP lands in the config.

2. scripts/db/oracle-cutover.sh — SKIP_DUMP=1 reuses an existing
   pre-oracle-cutover.sql.gz instead of re-dumping prod, so the await
   loop doesn't double-dump on every retry; env -u NODE_ENV wraps
   `npm run build` and `vercel deploy`/`vercel redeploy` so the
   ambient NODE_ENV=production from systemd or .env files can't
   poison the build's mode resolution.

3. package.json — adds db:oracle-await alias.
2026-05-24 23:18:12 +02:00
g-butandCursor ec6f423b0f feat(infra): Postgres portability, Oracle cutover scripts, and DB kill-switch essay
Vendor-neutral DATABASE_URL helpers, dump/restore/sync tooling, and one-command
Oracle migration after a single console VM step. Publishes the studio-stack
thoughts article and hardens build (dynamic layout, resilient sitemap).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 11:24:20 +02:00
g-butandCursor 6fb9c199b2 feat: harden cloud onboarding with agent CLI, private zone, and cron DB
Add @cockpit/agent init, server-side PIN enforcement for private APIs,
Postgres-backed cron jobs, daemon auto-continue sync, and cloud/local docs
so SaaS users get a clear path from browser signup to local dispatch.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-21 15:20:03 +02:00
g-butandClaude Opus 4.7 154c354e68 feat(deploy): wait-for-vercel.sh — fail-fast on bad deploys
Vercel deploy failures previously sat in Error state silently until
someone ran `vercel ls`. The just-fixed CRON_SECRET-whitespace incident
(02c3c0d) is exactly this class: the build error existed for several
minutes before I noticed.

scripts/wait-for-vercel.sh polls vercel ls --prod for the most-recent
deployment, echoes each status transition, and exits:
  0  on Ready
  1  on Error / Failed / Canceled (prints `vercel inspect <url> --logs` hint)
  2  on timeout (default 420s; tunable via env)
  3  when the vercel CLI isn't installed

Gotcha I hit while writing this: `vercel ls` emits the deploy table to
STDERR, not stdout — `2>/dev/null` silently swallows every row. Use
`2>&1` to merge. Comment in the script flags it so the next person
debugging doesn't waste the same hour.

npm scripts:
  wait:vercel    direct invocation
  ship           git push origin main && wait:vercel

Use:
  npm run ship                   # push and wait
  bash scripts/wait-for-vercel.sh --quiet   # exit code only

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 02:03:04 +02:00
g-but b775d185e8 feat(home): npm run test:home runs all eight self-test suites in one shot
Each home/ module ships an inline test suite (state/decide/projects/
render/emit/log/watcher/worker — 76 tests total as of 00058f9), but
running them required eight separate npx tsx invocations. Added
scripts/test-home.sh that chains them in a stable order, captures
each suite's output, parses the N/M passed footer, and aggregates a
total at the end. Wired as 'npm run test:home' alongside the existing
smoke and check:design scripts.

The footer regex matches '^N/M' rather than 'N/M passed' specifically
because render.ts prints '12/12 intents render' — most suites use
'passed' but the loose anchor catches both shapes. Exits non-zero on
the first suite that fails (set -euo pipefail + a tracked total_fail
counter for the summary line).

Output of npm run test:home ends with:
  ✓ 76 total tests passed across 8 home/ self-test suites

No code change in home/. tsc unaffected.
2026-05-20 06:43:28 +02:00
g-butandClaude Sonnet 4.6 d2ee8b993a feat(auth): resend SDK + styled emails, email verification, Groq fallback for Ivy
- Upgrade email.ts to resend SDK with sendEmailFire (fire-and-forget) and sendEmail (awaitable)
- Add styled HTML templates for verification, welcome, and password reset emails
- Add email_verification_tokens table + queries (mirrors password-reset-tokens pattern)
- Register route now sends verification + welcome emails after sign-up
- Add /verify-email/[token] page and /api/auth/verify-email/[token] route to consume tokens
- Add /verify-email page (success, expired-link, and resend states)
- Add /api/auth/resend-verification route with rate limiting
- Add verify-email to proxy public route exclusions
- Add Groq (llama-3.3-70b-versatile) fallback to /api/ivy when openclaw is unavailable

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 14:56:15 +02:00
g-butandClaude Sonnet 4.6 50d760f772 chore(deploy): postbuild hook copies static assets + restarts cockpit-app service
`npm run build` alone left .next/standalone/ with stale CSS/JS chunks,
causing the production server to serve 404s until `install-app` was run
manually. The new postbuild hook runs deploy-local.sh automatically after
every build: copies .next/static and public/ into standalone, then
conditionally restarts the cockpit-app systemd service if installed.

No-ops cleanly on CI (no standalone dir) and on machines without the
service (systemctl check skipped). install-app is preserved for first-time
setup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 22:14:33 +02:00
g-butandClaude Sonnet 4.6 d973ad63a8 feat(local): add production server installer and systemd user service
Adds two scripts to run Cockpit locally as a production-grade service
instead of relying on `npm run dev`:

- scripts/cockpit-app.sh: wrapper that sources .env.local and launches
  the Next.js standalone server at localhost:3000. Unsets the bash
  HOSTNAME builtin so the server binds to 0.0.0.0 (not the machine's
  hostname which resolves to 127.0.1.1).

- scripts/install-cockpit-app.sh: one-shot installer that builds the
  production bundle, copies static assets into .next/standalone, writes
  ~/.config/systemd/user/cockpit-app.service, and enables + starts it.
  Accepts --skip-build to reinstall without rebuilding.

Run: npm run install-app  (or npm run build && npm run install-app --skip-build)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 21:27:56 +02:00
g-butandClaude Sonnet 4.6 048a66b8c7 fix(queue): clear selection on reorder, atomic remove() via setQueue updater
- After drag-to-reorder, selected Set still held old indices — item X selected
  could now refer to a different item at that position. Clear on drop instead.
- remove() was reading from localStorage which may lag behind React state when
  called immediately after enqueue(). Switch to setQueue updater form so next
  is derived from the authoritative React state, then write localStorage and
  file synchronously inside the updater before returning.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 16:43:59 +02:00
g-butandClaude Sonnet 4.6 c47a22eb5f feat(billing): Stripe subscription infrastructure — schema, routes, BillingSettings UI
Adds complete ready-to-activate payment infrastructure:
- DB: plan/planStatus/stripeCustomerId/stripeSubscriptionId on users table
- src/lib/stripe.ts: Stripe client + price ID config (returns null until keys added)
- /api/stripe/checkout: creates checkout session for personal/pro/team plans
- /api/stripe/portal: redirects to Stripe billing portal for subscription management
- /api/stripe/webhook: handles subscription lifecycle (activated, updated, canceled)
- BillingSettings component: shows current plan, monthly/annual toggle, upgrade cards
- Settings page: BillingSettings wired in above ProjectsSettings
- Landing: pricing CTAs pass ?plan= param when Stripe is ready

Activate by adding to .env.local:
  STRIPE_SECRET_KEY=sk_live_...
  STRIPE_WEBHOOK_SECRET=whsec_...
  STRIPE_PRICE_PERSONAL_MONTHLY=price_...
  STRIPE_PRICE_PERSONAL_ANNUAL=price_...
  STRIPE_PRICE_PRO_MONTHLY=price_...
  STRIPE_PRICE_PRO_ANNUAL=price_...
  STRIPE_PRICE_TEAM_MONTHLY=price_...
  STRIPE_PRICE_TEAM_ANNUAL=price_...

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 14:08:06 +02:00
g-butandClaude Sonnet 4.6 27d9ce0171 feat(thoughts): add image and Mermaid diagram support to parser and renderer
- Parser: new 'image' block (![alt](src)) and 'code' block (fenced backtick blocks)
  Paragraph accumulator breaks on backtick fences and ![ so neither leaks into prose
- MermaidDiagram client component: dynamic mermaid import, dark theme matching
  Cockpit surface colors; SVG inline; falls back to raw text on render error
- Page: Next.js Image for image blocks with figcaption; MermaidDiagram for mermaid
  fenced blocks; pre/code for all other lang tags
- Images convention: /public/thoughts/{slug}/, referenced as /thoughts/{slug}/file

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 17:42:45 +02:00
g-butandClaude Sonnet 4.6 e90b5e323f refactor(core): consolidate agent-config SSOT, add Gemini/multi-agent support, expand shell
- Merge claude-config.ts into agent-config.ts (single SSOT for all state file paths,
  project conf, sessions dir, and prompt file resolution)
- Delete claude-config.ts; all importers updated to use agent-config
- Add Gemini to agent registry with availability detection; update agent-catalog to
  buildSwitchableAgentCatalog; add agent-preferences persistence
- Expand orchestration: add lifecycle state derivation, event persistence, and
  shouldPersistLifecycleEvent guard in orchestration/state.ts
- Add thoughts-content.ts (SSOT for article metadata read from content/thoughts/)
- Add MOBILE_NAV_ITEMS export to navigation.ts; integrate into MobileNav
- AppShell: use useState lazy initializer for sidebar collapse (fixes react-hooks/set-state-in-effect)
- Sidebar: collapse to icon rail on smaller screens; AppShell shows user avatar + name
- Control: SSE stream for real-time fast-state updates; ReadyBanner auto-inject countdown
- Shell, prompts, settings, today, goals, events, people: styling and UX consistency pass
- Update error/loading/not-found to use design system tokens
- Package.json dependency updates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 16:21:10 +02:00
g-butandClaude Sonnet 4.6 70d1d6def4 feat(packaging): self-hosted distribution foundation
First-run flow:
- /setup page + /api/setup: creates first user with hashed password
  (Node crypto scrypt, no new deps). POST rejects if users already exist.
- Landing page redirects to /setup when DB has no users
- middleware.ts: protects app routes, passes public pages through

Auth:
- passwordHash column added to users schema (drizzle-kit push applied)
- src/lib/password.ts: hashPassword/verifyPassword via Node scrypt
- auth.ts Credentials: env var takes priority, falls back to DB hash
  so packaged installs work without LOCAL_AUTH_PASSWORD

Multi-tenancy groundwork:
- Replaced DEFAULT_USER_ID with getCurrentUserId() across all 12 API
  route files (people, subscriptions, events, goals, projects, commitments)

Docker:
- Dockerfile: multi-stage Node 22 alpine, standalone output
- docker-compose.yml: postgres + migrate + app services
- .dockerignore, .env.example with documented required vars
- next.config.ts: output: standalone
- package.json: added migrate script (drizzle-kit push)
- tsconfig.json: scope to src/ only, exclude .next generated files

Install: clone → cp .env.example .env.local → docker-compose up
First visit → /setup → create account → sign in → done.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 13:46:07 +02:00
g-butandClaude Sonnet 4.6 e84b6d4f0a feat: GitHub OAuth, design system rebuild, reliability fixes (M1-M7)
Auth & multi-user:
- GitHub OAuth via next-auth DrizzleAdapter; signIn callback absorbs first
  login into is_default=true user so all pre-auth data stays accessible
- getCurrentUserId() helper; onboarding + profile pages
- normalizeUsername() extracted to lib/username.ts (DRY fix)

Design system:
- All public pages (landing, sign-in, onboarding, settings) rebuilt to use
  ui-* classes and semantic tokens only — zero raw Tailwind color violations
- ui-input, ui-btn-*, ui-panel, bg-surface-*, text-text-* throughout

Reliability (M1–M7):
- M1: Stale claude-stop-active lock cleanup on stop hook entry
- M2: /api/inject validates tab exists in Zellij before writing /tmp
- M3: Prompt SSOT unified — claude-prompts.json single array format
- M4: DBUS UID hardcode removed (already in dotfiles)
- M5: auth.ts signIn callback + AdapterAccountType cast
- M6: project_states DB table — persists ready/closing/closed/session/prompt
  across reboots; stop.sh PATCHes on stop/close; control falls back to DB
  when /tmp is empty (24h window); inject writes currentPrompt to DB
- M7: scheduleOpenClawWorker now async; waits for spawn event (2s timeout);
  marks run as error in DB if worker fails to start

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-02 18:20:46 +02:00
g-butandClaude Sonnet 4.6 3a56dbc748 chore: seed scripts, crons, sessions, docs, gitignore, package updates
- scripts/seed.ts + seed-goals.ts — updated entity/attribute seeding
- src/app/api/crons/route.ts — cron schedule updates
- src/app/api/sessions/route.ts — session handling fix
- docs/ — openclaw orchestration plan document
- .gitignore — added .next/logs to ignore list
- package.json/lock — dependency updates
- next-env.d.ts — auto-generated update

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 11:50:29 +02:00
g-butandClaude Opus 4.7 b53421dfb5 chore(deps): bump next 16.2.2 → 16.2.4 (high-severity DoS CVE)
Patch-level bump within the 16.x line. npm flagged it as outside the
stated dep range only because package.json pinned exactly "16.2.2";
relaxing to "16.2.4" lets the security patch land without --force.

Fixes the high-severity advisory:
  next  Denial of Service with Server Components
  GHSA-q4gf-8mx6-v5v3

Vulnerability count: 6 (5 moderate, 1 high) → 6 (all moderate).
The remaining moderates are transitive (esbuild via @esbuild-kit
inside drizzle-kit, postcss-via-next on a different branch) and need
larger major-version bumps that aren't safe to do automatically.

Bumps eslint-config-next in lockstep (same 16.2.2 → 16.2.4) since
they're released together and stay version-synced.

Verified: tsc clean, eslint clean, smoke 18/18.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 20:42:42 +02:00
g-butandClaude Opus 4.7 bceacc8222 chore(husky): add pre-commit hook running tsc + eslint
Adds husky as a dev dep and wires .husky/pre-commit to run:
  npx tsc --noEmit
  npx eslint src/

Both must pass for the commit to land. Smoke is intentionally NOT in
the hook because it needs a live dev server — run `npm run smoke`
manually before opening a PR.

Catches the regressions a 100-commit refactor sweep can introduce
(broken zod schema, missed import, accidentally-disabled rule)
before they reach origin/main, complementing the human / cron /
agent commit flow we've established.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 11:35:54 +02:00
g-butandClaude Opus 4.7 b9aa7e657c chore(scripts): add npm run smoke — route-level regression check
Until now the codebase had zero automated coverage; every refactor
relied on a manual curl loop. scripts/smoke.sh runs that loop in one
command: probe BASE/, then GET every page route and assert 2xx/3xx.

- Routes match config/navigation.ts NAV_ITEMS plus the / redirect
- BASE env var override for prod smoke (defaults to localhost:3000)
- Fast-fails with a clear "start the dev server first" message if
  the base is unreachable, instead of dribbling 11 curl errors
- No new dependencies — bash + curl only

Verified: all 11 routes return 200 against the running dev server.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 18:30:20 +02:00
g-but 0e0852330a feat: initial commit 2026-04-04 22:47:22 +02:00