Commit Graph
16 Commits
Author SHA1 Message Date
CatoandClaude Opus 5.5 5f1e283117 fix(scripts): grep -q is never the reader of a pipe under pipefail (#874)
`echo "$x" | grep -q PAT` under `set -o pipefail` can report "not found"
for text that IS there: grep -q exits on its first match and closes the
pipe, the writer takes SIGPIPE (141), and pipefail makes the pipeline
status 141. An `if` then takes the else branch on a successful match.

#587 found this in one file and noted it "only fires when the payload
exceeds the ~4KB pipe buffer". That is not so, and the belief is why
82 copies in 22 scripts survived. Measured today on retire-site's real
1,158-byte plan output with has()'s exact pattern, 3,000 calls each:

  'DRY RUN'        line 3 of 20    echo|grep -q   2/3000 false misses
  'apps.conf row'  line 11 of 20   echo|grep -q   2/3000 false misses
  last phrase      line 20 of 20   echo|grep -q   0/3000
  'DRY RUN'                        here-string    0/3000

Rare per call, but verify makes hundreds of these calls, and the
retire-site suite went red on those two exact phrases twice this week,
passing every rerun. It is worse in a NEGATIVE check - hasnt() read a
false miss as a PASS. And several copies are not tests: deploy-hetzner.sh
exits 1 on a false miss, and the sshd drift watch would raise a false
security alert.

All 82 rewritten to `grep -q PAT <<<"$x"` (a here-string is not a
pipeline, so there is no writer to signal) by a script that only touched
the simple quoted-variable form and reported anything else. Checked: all
22 files pass `bash -n`, every file is a 1:1 line swap (82 lines), and
the 20 line-continuation sites keep the here-string before the trailing
backslash (the first draft of the rewrite got those wrong; caught in a
dry-run diff before anything was written).

#587's comment is corrected so it stops teaching the wrong threshold.

Gate: scripts/test/no-grep-q-in-a-pipe.ts ratchets it repo-wide,
including forms the rewrite skipped (e.g. "$(cmd)" | grep -q), and
self-tests that its detector still fires. Proven by restoring the
original deploy-hetzner.sh line.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 02:57:19 -07:00
CatoandClaude Fable 5.1 95c40a9cd8 refactor: rename the product from FleetCrown to Loki (#695)
The product, its assistant, the repo, the host and every unit on the box now
share one name. 638 files, ~3,000 mentions: UI copy, config, env keys
(FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs,
articles, the deploy workflow other repos reuse, and nine file names.

- Three article slugs carried the old name and had been shared; permanent
  redirects keep those links alive (next.config.ts).
- test-no-retired-name.sh now also forbids the old product name across the
  whole repo, so the rename cannot creep back through templates and examples.
- ASSISTANT_STACK collapses the product and the assistant into one entry,
  because they are now the same name.

Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki`
database and role, loki.orangecat.ch (old host 308s to it; /api, /widget,
/embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases.
The Resend sending domain stays fleetcrown.orangecat.ch until the new domain
is verified in DNS.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 16:13:10 -07:00
CatoandClaude Fable 5 0585ab32c0 chore(thoughts): adopt bip-kit 0.2.1 — retire the local mermaid island and shiki workarounds (#515)
bip-kit 0.2.1 upstreamed both reasons the local copies existed:

- MermaidBlock now does canvas color normalization (oklch/lab tokens no
  longer blank diagrams) and class-based theme detection (next-themes
  attribute="class" works), so src/components/thoughts/MermaidDiagram.tsx
  is deleted in favor of bip-kit/react/mermaid. Its orphaned PALETTE
  fallback groups go with it; the one value email still used
  (darkFallback.textTertiary) moves to the canonical dark mirror group.

- setHighlighterLoader(() => import("shiki")) is the supported seam for
  standalone builds: the literal import lives in our code, so the bundler
  ships shiki like any other dependency. The serverExternalPackages
  "shiki" entry and deploy-local.sh's node_modules/shiki symlink (and the
  load-bearing static-import assertion) are all removed; node-pty's
  handling stays untouched.

Verified on the assembled standalone locally: code essay serves 56
--shiki-light spans with NO top-level node_modules/shiki present, and the
mermaid essay renders a themed SVG in both dark and light (labels flip
near-white/near-black; per-theme re-render confirmed).


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-07 05:52:19 +00:00
CatoandClaude Fable 5 084f17c054 fix(deploy): link node_modules/shiki into the standalone — the tracer never will (#513)
Second half of the shiki saga (#510 shipped tracing globs that copied
nothing; #512 added serverExternalPackages + a static import, which got the
.pnpm store files traced but still no highlighting in prod).

Hermetic diagnosis (standalone copied OUTSIDE the repo tree, so the dev
node_modules can no longer leak into Node's resolution walk — which is
exactly how the earlier local verification fooled itself): Turbopack's
externalized import of shiki resolves through its own module wrapper, but
bip-kit loads the peer via `new Function("s","return import(s)")` — plain
Node resolution from the server chunk path. Next emits the .pnpm store
entries yet never the top-level node_modules/shiki symlink, so that import
finds nothing and ArticleBody silently degrades to the mono fallback.
With the link created: bp-codeblock-highlighted spans with dual-theme
--shiki-light/--shiki-dark vars. Without: bp-pre fallback. Reproduced both
ways before shipping.

deploy-local.sh (the postbuild that already supplies what the tracer can't
see — static assets, content, node-pty's native binary) now creates the
symlink, version-agnostically, from the store entry it finds. The static
import also becomes load-bearing (bare `import "shiki"` was tree-shaken:
shiki declares sideEffects:false) and asserts at module load, so a missing
peer is a loud failure instead of a quiet styling regression.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-06 22:37:46 +00:00
65dea6f303 chore: pnpm — the fleet has one package manager (#478)
* chore: pnpm — the fleet has one package manager

- packageManager pnpm@11.25.0; lockfile via pnpm import, package-lock.json
  removed; npm "workspaces" replaced by pnpm-workspace.yaml packages
  (packages/agent), and bridge/ joins the workspace — one install, one
  lockfile, its own package-lock.json removed
- npm "overrides" (fast-uri pin) moved to pnpm-workspace.yaml (pnpm ignores
  the npm-only field)
- allowBuilds: better-sqlite3, node-pty, @sentry/cli, native toolchain, and
  the two git-hosted deps (@fleet/ai-forms, limitkit — pnpm wants the exact
  resolved spec, keys move with the pinned tags); temporary
  minimumReleaseAgeExclude for our own @bitbaum/ai-kit@0.6.2
- phantom deps declared: @auth/core (src/auth.ts augments @auth/core/jwt —
  TS2664 under pnpm's strict layout), dotenv, sharp (scripts)
- CI/audit/deploy workflows: pnpm/action-setup@v6, store-dir pinned outside
  the action's bin dir, cache: pnpm, frozen-lockfile; deploy's separate
  `npm --prefix bridge ci` is covered by the workspace install; Next cache
  key hashes pnpm-lock.yaml; npm audit → pnpm audit
- desktop-release: root install → pnpm; desktop/ itself STAYS an npm package
  (own package-lock.json, electron toolchain untouched)
- husky: pre-push staleness gate now compares pnpm-lock.yaml against
  node_modules/.modules.yaml; hooks + scripts (deploy-hetzner, hetzner/deploy,
  install-app, doctor, smoke) converted to pnpm
- check-deploy-ready fleet gate now recognizes pnpm verify/test lines too

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

* fix: prettier-format pnpm-workspace.yaml — format:check gates verify

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

---------

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-04 10:35:27 +00:00
be76332744 fix(deploy): assemble standalone in CI too, skip only the local restart (#116)
deploy-local.sh (npm postbuild) bailed entirely under CI, so the CI deploy
runner never copied .next/static + public + node-pty into .next/standalone —
deploy-hetzner.sh --no-build then failed with '.next/standalone missing static
assets'. CI genuinely needs the assembly (it rsyncs that tree to the box); it's
only the local-machine tail (schema warning + systemctl --user restart) that must
be skipped there. Move the CI guard to after assembly. Local path unchanged.

Co-authored-by: test <test@test>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-28 11:09:08 +02:00
7b9d0a37b8 chore(db): demote drizzle-kit push footgun — rename migrate → db:push (#111)
The `migrate` script aliased `drizzle-kit push`, training the habit of
diff-applying unreviewed schema to whatever DATABASE_URL points at — prod, if
misconfigured. Rename it to `db:push` so the name no longer reads as the normal
workflow, document it as local/scratch-only, and point every call-site at the
generate → review → forward-apply loop instead. No `db:migrate` alias added:
there is no local forward-only applier (the deploy owns forward-apply via
apply-schema.sh), so a hollow alias would just be a new landmine.

Call-sites updated: README, check-schema-drift, deploy-host, deploy-local,
postgres-portability. Implements docs/infrastructure/migration-strategy.md §3;
the optional CI guard is deferred there (it collides with the raw-SQL migration
path until the two paths are unified).

Co-authored-by: test <test@test>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-28 10:17:14 +02:00
GandClaude Opus 4.8 c98607f8f6 fix(deploy): gate the local postbuild restart on the pinned ref too (#45)
The pinned-deploy guard protected the box but not local. deploy-hetzner.sh
--ref checks HEAD==REF after the build and aborts the BOX rsync on drift — but
`npm run build`'s postbuild (deploy-local.sh) had already restarted the LOCAL
systemd service with the just-built (possibly torn) standalone. So a `git
checkout` mid-build left local prod on a torn tree even though the box was safe,
and the "not shipping a torn tree" abort message was misleading.

Fix: deploy-hetzner.sh exports FLEETCROWN_DEPLOY_REF into the build env;
deploy-local.sh skips the local restart when that's set and HEAD has drifted
from it. Now a mid-build branch switch restarts nothing — local and box
consistent — and the abort message says so. (Root cause was running git ops
during a backgrounded deploy; the guard is now airtight against it on both ends.)

bash -n clean on both scripts.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 12:29:36 +02:00
GandClaude Opus 4.8 9b8650d7db fix(deploy): atomic asset swap so deploys don't 500 marketing pages (#28)
deploy-local.sh did `rm -rf <dir>; cp -r <dir>` for static/public/content,
leaving a multi-second window where the LIVE standalone dir was missing or
half-populated. The running server reads content/*.md at request time, so
/whitepaper (and broken CSS/JS) 500'd on every deploy until the copy finished —
exactly the marketing-page outage window we want gone.

swap_dir() builds each tree in a sibling temp dir then renames it into place:
the only window where the live dir is absent is between two consecutive renames
on one filesystem (microseconds), not seconds. Applies to .next/static, public,
content, and the node-pty build. Also clears swap temporaries left by an
interrupted deploy. Verified: content swapped with no nesting, no stray temps,
/whitepaper stays 200.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 06:06:04 +02:00
GandClaude Opus 4.8 c5cad9ba3a feat(db): read-only schema-drift guard to catch missing tables before they 500 (#16)
The Drizzle schema (src/db/schema) is the SSOT for what tables must exist, but
nothing in the deploy path runs drizzle-kit push. A table added in code reaches
the box unmigrated and silently 500s the first feature that queries it — exactly
how `prompts`, `cron_jobs`, `conversations` and `conversation_messages` went
missing and took down /prompts, /loki and the System cron list this session.

Add scripts/check-schema-drift.ts: compares schema-declared table names against
the live DB's public tables, exits 1 (listing the missing tables + the migrate
command) if any are absent. Strictly READ-ONLY — never creates/alters/drops.
Loads .env.local itself and skips cleanly (exit 0) when no DB is configured or
the DB is unreachable, so it never blocks a push for infra reasons.

Wired in two places:
- .husky/pre-push runs `npm run check:schema` — drift becomes a push-time error.
- scripts/deploy-local.sh prints a non-fatal warning on every local build, so
  drift surfaces at rebuild time too (a plain `npm run build` doesn't push).

Verified: reports "all 45 declared tables exist"; before this session's manual
table creation it would have listed the 4 missing ones.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 16:39:00 +02:00
Mao NakamotoandClaude Opus 4.8 ed382a1f0c fix(deploy): copy node-pty native binary into standalone build
Phase 2b browser-verify exposed it: Next's standalone tracer copies node-pty's
JS (lib/, package.json) but not its dynamically-loaded build/Release/pty.node,
so /api/workspaces 500'd with 'Failed to load native module: pty.node'. The
postbuild deploy already copies tracer-missed assets (static/public/content) —
node-pty's binary belongs in the same step. Verified: with the binary present,
the embedded PTY terminal round-trips end-to-end in the browser (provision +
output stream + keystroke input + event-sourced status), zero zellij.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 08:17:30 +02:00
Mao NakamotoandClaude Opus 4.8 c6bc058cb4 chore: purge Vercel / Neon / managed-Supabase across the codebase
Self-hosted on Hetzner is the only reality now; the leftover references were
stale at best and a security hole at worst. Thorough sweep across code, config,
scripts, docs, and comments (84+ files). Self-hosted supabase.orangecat.ch is
kept; historical migration records stay accurate.

Functional / security fixes:
- cron-auth: prod detection was process.env.VERCEL (unset on the box!), so the
  fail-closed 'CRON_SECRET unset -> 503' gate never fired in production. Now
  keys on NODE_ENV=production. (security)
- auth trustHost: dropped the dead process.env.VERCEL===1 branch.
- AppFooter: read the baked-in build SHA instead of VERCEL_GIT_COMMIT_SHA/ENV.
- project bootstrap: removed 'neon projects create' + the Vercel deploy brief;
  DB option is now self-hosted Postgres, deploy guidance is the self-hosted flow.
- db-url: removed the legacy NEON_DATABASE_URL* fallbacks (+ updated its test).

Infra / removals:
- deleted .github/workflows/vercel-deploy.yml and scripts/db/dump-from-{neon,supabase}.sh.
- stripped NEON_* env fallbacks from db dump/restore/sync scripts.

User-facing:
- desktop offline overlay no longer blames a 'Vercel hiccup'; privacy page +
  PRIVACY_POLICY subprocessors now say Hetzner self-hosted / self-hosted Postgres.

Plus ~50 comment/doc rewrites (Vercel -> the cloud host/the box; Neon -> Postgres).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 10:46:43 +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 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
g-but 7c28ab15f8 refactor(control): create trustworthy agent operations workspace 2026-05-27 19:02:18 +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