/login, /register and /forgot-password are AccountKit's forms: password,
passkey, an email sign-in link, recovery, Continue with OrangeCat and the
shared bitbaum sign-in, each when its env is set. The profile settings
carry AccountKit's account panel (password, passkeys, two-factor, linked
sign-ins, deletion). compat passes screens: "accountkit" (AccountKit 0.20).
AccountKit is the only credential writer: Kivvi's registration, invite
sign-up, reset link and settings password change are removed, along with
the Auth.js runtime. A new person gets Kivvi's users row under the same id
and lands on /join; an invitation sends them through sign-up and back.
Deleting an account is refused before anything is deleted when the person
is named on kept business records or is the only owner of a company others
work in.
Migration 0039 (additive, idempotent) makes the panel's rename and deletion
reach users. The browser journey runs every method in CI against the
production build, with AccountKit's real mail caught by a sink.
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
Co-authored-by: Claude <noreply@anthropic.com>
The next-auth/react bridge, its call helper, the session plumbing, the
AUTH_RUNTIME switch, the import rehearsal script and the journey-test cookie
client were copies of code five products each carried. They now come from
AccountKit 0.18.0:
- @bitbaum/accountkit/auth/nextauth-compat answers next-auth/react. The
product's compat.ts holds only what is its own: the session shape, how each
password form signs in, its login codes and hooks.
- @bitbaum/accountkit/auth/switch: sharedRuntimeEnabled().
- `pnpm run db:rehearse-import` runs AccountKit's accountkit-rehearse-import
on this product's import SQL.
- The journeys use @bitbaum/accountkit/auth/compat-testing.
Behaviour is unchanged with the switch off. With it on, a signed-out session
reads as null, and a resolver or hook failure is a readable refusal rather
than a 500. The real-database journeys pass unchanged.
Claude-Session: https://claude.ai/code/session_019MDtmud6zcK4rStBGmYSML
Co-authored-by: Claude <noreply@anthropic.com>
* feat(auth): stage AccountKit beside Auth.js, switch off
Kivvi moves from Auth.js to @bitbaum/accountkit one reversible step at a
time, the same way evig did. This step adds everything the switch needs and
changes nothing while AUTH_RUNTIME is unset.
- Migration 0038: AccountKit's tables under an `auth_` prefix, plus the
users <-> auth_users mirror functions, inert until attached.
- scripts/db/accountkit-import.sql: copies accounts under their own ids and
bcrypt hashes byte for byte, refuses address collisions, drift or a live
shared runtime, then attaches the mirror triggers. The rehearsal CLI always
rolls back and prints only counts.
- apps/web/lib/accountkit/: the runtime (ids: 'uuid', legacy bcrypt, AccountKit
0.16.0), a session reader in Kivvi's shape re-read from `users` and the
membership on every request, and a bridge that answers next-auth/react.
AccountKit's own credential endpoints stay closed: Kivvi's sign-up, reset and
password change remain the only writers, and the triggers carry them over.
Changing your own password keeps that session and ends the others.
- apps/web/lib/session-claims.ts: the company/role/onboarding rule, written
once and used by both runtimes.
- The middleware has one routing function and two session sources, and runs
on Node so it can read a database session.
- browser-smoke.yml runs the account journey once per runtime; the AccountKit
leg first runs the rehearsal and the real-database journeys.
docs/ACCOUNTKIT-MIGRATION.md records what is left before switching.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmud6zcK4rStBGmYSML
* fix(web): load tailwindcss-animate by import; keep the switch-off password path unchanged
Node 24 loads tailwind.config.ts natively as ESM, where require() is not
defined, and next dev exited in the chatkit smoke. The settings password change
now uses a transaction only when it has a shared session to keep.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmud6zcK4rStBGmYSML
---------
Co-authored-by: Claude <noreply@anthropic.com>
0032_chilly_shatterstar re-added six columns that 0029_team_participation
already added (invitations/memberships.permission_preset,
users.location/languages/skills/availability_type), so a fresh install that
applies the files as written stopped at 0032. Those six statements now read
ADD COLUMN IF NOT EXISTS; the definitions in 0029 and 0032 are identical,
so nothing is lost by skipping them.
Safe on production: the deploy's applier (loki apply-schema.sh) already
rewrites every ADD COLUMN to ADD COLUMN IF NOT EXISTS before running a
file, so the SQL it would run for 0032 is byte-identical before and after
this change (same sha256), and it never re-runs a tag already in
_deploy_schema_history anyway. Drizzle's own migrator compares only the
journal timestamp, which is unchanged.
scripts/ci/apply-migrations.sh drops its ADD COLUMN rewrite and applies
the committed files verbatim, so CI now catches a migration that only
replays with help.
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
Co-authored-by: Claude <noreply@anthropic.com>
A new `account` job in browser-smoke.yml drives real Chromium against the
production standalone server and a PostgreSQL built from the committed
migrations:
- sign up as a new organisation, finish onboarding (company info, business
setup, start fresh) and land on the dashboard; the company, its onboarding
stamp and the owner membership are checked in the database;
- sign out from the user menu; the session is gone and the dashboard asks
for sign-in;
- a wrong password and an unknown email are refused, with no session;
- sign in and reach the dashboard;
- set a company AI key through the settings form, then check that the key
field holds only the mask or nothing, that no response of the settings
page carries the key, that it is stored sealed, and that saving with the
mask keeps it (guards #185).
scripts/ci/apply-migrations.sh applies the chain to the throwaway database.
The committed chain does not replay onto an empty one (0032 re-adds six
columns 0029 added), so ADD COLUMN is read as ADD COLUMN IF NOT EXISTS; the
migration files are unchanged.
The journey stays on the sign-in page between attempts because /login
allows 10 requests a minute per address.
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
Co-authored-by: Claude <noreply@anthropic.com>
Two absolute paths from a single machine were checked in, so anyone who
clones kivvi inherits them:
- .husky/pre-push hard-coded /home/g/dev/loki for both the CI gate and the
deploy script. The hook is committed, so every clone gets a pre-push
pointing at a stranger's home directory; on any other machine both bash
calls fail. Resolve the path at run time from DEV_ROOT (the variable
loki's scripts/hetzner/_box-env.sh uses as the source of truth for the
checkout root), falling back to $HOME/dev. The generated block and its
markers are otherwise unchanged.
- scripts/fix-line-items.ts pinned EXPORT_DIR to /home/g/dev/kivvi/...,
which cannot be right for anyone else. It now reads KIVITENDO_EXPORT_DIR
or falls back to the repo-root-relative kivitendo-export/ - the same
__dirname pattern the sibling scripts already use. The existing
"AR file not found: <path>" guard prints the resolved directory, so a
wrong or missing export dir still fails loudly.
Verified: sh -n and bash -n on .husky/pre-push, prettier --check on the
changed TypeScript.
Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* chore: add a formatter, matching the style this repo already writes
singleQuote=false was chosen by counting this repo's own
imports, not by fleet decree. The fleet is genuinely split and the two repos
that already had a .prettierrc disagreed with each other, so there was no
standard to restore. Quote style does not cross repo boundaries; having a
gate does.
Markdown is ignored for now — prettier rewraps prose, which would bury the
real diff.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* style: format with prettier (759 files)
Mechanical. No behaviour change. This SHA is listed in
.git-blame-ignore-revs so `git blame` skips it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore: teach git blame to skip the reformat
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(ci): resolve the lockfile with the pnpm major CI runs
The previous commit regenerated pnpm-lock.yaml with local pnpm 11, which
re-resolved the `github:catomean/ai-forms` shorthand from a codeload tarball
to git+ssh. CI runs pnpm 9, which cannot read that entry — and could not fetch
over SSH even if it could, having no key. The lockfile was valid on the machine
that wrote it and broken everywhere else.
Resolved with pnpm 9 instead. The rollout script now derives the major from
packageManager/PNPM_VERSION and refuses any lockfile that gains an ssh-form
resolution.
* fix(ci): resolve ai-forms over https, not ssh
pnpm records whichever transport it could use when the lockfile was written.
This laptop has an SSH key, so pnpm wrote git+ssh; CI has none and the install
died on 'Permission denied (publickey)'. Resolving with GIT_SSH_COMMAND=/bin/false
reproduces CI's capabilities and yields git+https, which needs no credentials
for a public repo.
* fix(ci): keep the lockfile byte-identical apart from the pin
kivvi already depended on prettier, so this PR is script wiring, not a new
dependency — and it should not have rewritten the lockfile at all.
Regenerating it re-resolved the `github:catomean/ai-forms` shorthand three
different ways, none of which CI could use: git+ssh (no key on the runner),
then git+https (fetches, but pnpm's virtual-store path for a git dep failed to
import). Only main's original codeload tarball works. The resolution recorded
in a lockfile depends on what the machine writing it could reach, which makes
'it resolved fine locally' worth nothing.
So: restore main's lockfile and change only the specifier, which is what
--frozen-lockfile actually compares, and format with 3.8.0 — the version this
repo's own lockfile already pinned — rather than dragging it to the fleet's
3.9.6 and reformatting against a version it does not install.
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
auto-merge-sweep.sh was copied into 22 repos and drifted into EIGHT distinct
versions, 245 to 404 lines. Three of them independently grew different fixes for
real outages, and each fix reached only the repo that wrote it:
evig, revampit infra-failure detection + re-run. An Actions incident left
main "failure" with no failed job at all; 11 PRs stranded
for roughly 14 hours.
fleetcrown DEADLOCK naming — a red base with the repairing PR sitting in
the queue was indistinguishable from "nothing to merge".
the other 19 neither.
Nothing could carry a fix across, so every repo waited to hit each outage
itself. This repo now calls the canonical sweep in maonakamoto/dotfiles, and the
local copy is deleted.
The canonical is the union of the three, built on the variant ten repos were
already running rather than on the longest one — the 404-line variant is missing
the step-summary reporting the 296-line one has, so "take the biggest file"
would have silently deleted working behaviour. The merge was 106 insertions and
zero deletions: nothing can be lost by adopting it.
The triggers stay in this file because they genuinely are per-repo: workflow_run
must name the CI workflow exactly, and that name differs across the fleet.
Two details that are silent when wrong, both found by piloting rather than
reasoning:
rearm_workflows is SPACE-separated. The sweep word-splits it; a comma makes
one bogus token, every dispatch fails, and the only symptom is that nothing
deploys — while the sweep still exits 0 and reports a successful merge.
permissions are declared on the CALLER as well. A called workflow's token is
capped by what the caller grants, so relying on the callee's block alone can
hand it a read-only token; the sweep would then merge nothing while exiting 0,
which is indistinguishable from having nothing to merge.
Verified before this rollout: the canonical ran end to end in dotfiles' own CI,
and the reusable-workflow path ran end to end in the pilot repo (s-ink).
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
`gh pr list` returns newest-first, and the sweep merges the first eligible PR
then stops. So the newest green PR wins every sweep, and an older one can wait
indefinitely.
Observed in maonakamoto/fleetcrown on 2026-08-06: two consecutive sweeps merged
the two newest PRs while three older green ones sat untouched and were never
even evaluated. With several agent sessions opening PRs continuously that is
starvation — and it starves the worst candidate, since the longest-waiting PR
is the one whose checks were proven against the most now-stale base.
PR numbers increase monotonically with creation, so sorting ascending is FIFO.
The ordering was never a decision, just whatever gh happened to return.
Fixed upstream first (fleetcrown #182) and verified in production there: the
sweep immediately after it landed correctly took the oldest open PR rather than
the newest. This is that one-line change, applied to the fleet.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* ci: add the auto-merge sweep policy
* ci: green PRs merge and deploy themselves
* ci: allow CI to be dispatched so auto-merge can re-arm it
* ci: allow deploy to be dispatched so an automated merge still ships
Vercel is fully decommissioned; kivvi.orangecat.ch runs self-hosted on the
Hetzner box behind Caddy (build → rsync → systemd restart). This repoints or
removes every LIVE Vercel reference:
- DB driver (packages/database): drop the dead `process.env.VERCEL` branch in
createDb(); the Neon serverless driver is now selected solely by USE_NEON,
preserving self-host behavior (VERCEL was always undefined).
- Dead kivvi.vercel.app fallback URLs → kivvi.orangecat.ch (intake label pages).
- Cron routes: "Vercel Cron" → system cron (self-hosted); webhook-retry no longer
points at the removed vercel.json.
- next.config.js: drop Sentry automaticVercelMonitors (no Vercel crons to monitor).
- docs/DEPLOYMENT.md: replace "Option A: Vercel + Neon" with the self-hosted
Hetzner (Caddy + systemd) production reality; fix the DB-driver/env-table/Neon
sections and upgrade/troubleshooting notes. Neon-via-USE_NEON stays documented.
- Remove apps/web/vercel.json, the .vercel gitignore entries, and the VERCEL_URL
.env.example var.
- set-org-profile impact-hub URL and bug_report deploy-target list de-Vercel'd.
Kept: the .husky/pre-push `env -u VERCEL` guardrail (defensive env strip).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Complete the revamp-it ERP-companion roadmap (items 4–6, 8) and close the
new-code review findings.
Money-path bridges (roadmap 4–6, acceptance 4–5):
- recordServiceSale + POST /api/v1/services/sales: book any paid revamp-it
service flow (workshop, appointment, IT-Hilfe, other) as one service invoice
+ one payment routed to service revenue (3200), in a single transaction.
- Idempotent by natural key: durable invoice marker (survives key pruning) plus
a concurrency claim on the existing unique-constrained apiIdempotencyKeys
table — DB-enforced single booking, no schema migration.
AI-assisted ERP (roadmap 8):
- classifyMoneyIn + classify_payment tool: deterministic, advisory triage of
unclear money-in (sale/donation/grant/refund/pass-through/manual_review);
donation/grant/refund/pass-through always flagged for Treuhänder confirmation.
- findUninvoicedRepairLabor + find_uninvoiced_repair_labor tool: surface logged
repair hours still in stock and unbilled (revenue leakage) with suggested
amounts.
Supporting:
- getOrCreateServiceProduct extracted from repair-labor (DRY); repair-labor now
delegates to it.
- Integration-health dashboard section + workflow hub (ERP projection
diagnostics), production smoke script, French i18n parity (52 keys).
- Roadmap status doc.
Money math uses decimal.js throughout. 1110 core + 104 ai tests pass;
type-check, lint, and build clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- MIGRATION_CHECKLIST.md: step-by-step guide for Swiss SME migration
from Kivitendo (German), covering CSV exports, import order, and
verification
- validate-kivitendo-csvs.ts: standalone script that validates CSV
exports against mapping profiles, reports data quality issues
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Kivitendo CSV exports store line items as extra columns beyond the CSV
header. Previously PapaParse in header mode dropped these columns,
resulting in ~3100 imported documents with no line items.
Changes:
- CsvUploader: switch to array-mode parsing, pass raw rows through
- StepDataImport: extract structured line items via parseKivitendoLineItems
- buildProductLookup: return {id, unitPrice} instead of just id
- bulkInsertDocuments: calculate proper unitPrice from product catalog
- Add repair-import settings page for backfilling existing documents
- Add repairDocumentLineItemsAction server action
- Fix all hardcoded i18n strings (Export CSV, Data Tools, Repair Import)
- Add defaultDocumentFooter to CompanySettings
- Extract PDF data builder to shared utility
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add cleanup-import-data.ts for deduplicating Kivitendo import data
(products, invoices, warehouses, stock). Add BROWSER_TEST_FINDINGS.md
documenting 20 issues found during manual testing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replaces fragmented import-kivitendo-data.ts and import-real-data.ts with a
single import-kivitendo.ts that handles all 14 import steps with proper FK
dependency ordering, dry-run support, and Swiss number/date format handling.
Adds contact address and project bulk insert functions to import-bulk.ts,
plus vendor/project/GL/stock mapping profiles to import-mappings.ts.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes GHSA-f82v (auth bypass in middleware), GHSA-gp8f (cache poisoning),
and GHSA-7gfc (authorization bypass). Also adds gitignore rules for
customer data exports.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Kivitendo exports put line items as extra columns beyond the CSV header.
PapaParser in header mode dropped them, leaving 822 documents with broken
or missing items. This adds array-mode CSV parsing to extract structured
line items and a one-time fix script that repaired all 660 AR invoices
and 162 AP purchase invoices (1,681 total items, 0 errors).
- Add parseKivitendoLineItems() to import-mappings.ts (pure, client-safe)
- Add missing units to mapUnit(): psch, Jahr, Tag
- Extend bulkInsertDocuments() with optional structuredItems parameter
- Add scripts/fix-line-items.ts one-time data fix (already executed)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Integrate next-intl v4.8.2 for full i18n support across the app with
three locales (de-CH, en, fr). Create message JSON files with 20
namespaces covering all UI strings. Convert hardcoded German/English
strings to translation calls. Add language switcher component. Fix
pre-existing TypeScript errors in banking, documents, auth, reports,
chat, bulk-import, and document-form modules to achieve clean type-check
and successful production build.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>