* wip: prose fields on chatkit DictationField (awaits chatkit 0.45)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuMRAXYWNkfowAXVfi
* feat(forms): prose fields on chatkit DictationField, with a working microphone
- Bump @bitbaum/chatkit to ^0.45.0.
- One app wrapper, components/forms/TextBox, around DictationField. Used by
the bot builder (name, description, knowledge topic and content, system
prompt), the custom-bot edit page (name, description, system prompt,
greeting), the contact message, the demo intake questions, quick-create
(name, relationship, memories) and the consultation form's
react-hook-form message field ({...register('message')}).
- app/api/transcribe: dictation server leg on ai-kit's speechChain and
transcribe(), rate limited, recordings and transcripts neither stored nor
logged. Every field and every in-page chat points voice at it, so the
microphone works where the browser has no recogniser of its own.
- Permissions-Policy allowed no microphone at all (microphone=()), which
blocked every mic on the site; it now allows the site itself.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuMRAXYWNkfowAXVfi
---------
Co-authored-by: Claude <noreply@anthropic.com>
Seven hand-built chats (/demo, the professional demos, quick-create, /try,
/my-data documents, custom bots and the guided demo) now share one
EmbeddedChat panel: chatkit's ChatThread and Composer with the microphone,
Copy/Listen, Stop, Retry on a failed turn, starters and suggested replies.
Each surface keeps its own prompt, route and persistence through a small
useChatTurns hook.
Also fixes /demo and the /my-data document chat reading the answer from the
wrong level of the jsonSuccess envelope, which showed empty answers.
Claude-Session: https://claude.ai/code/session_019MDtmuMRAXYWNkfowAXVfi
Co-authored-by: Claude <noreply@anthropic.com>
* fix(auth): a deleted account takes its documents, bots and conversations
When people were GoTrue users, deleting the auth.users row cascaded through
every botsmann table. Since accounts are AccountKit's (#289), deleting an
account in the account panel removed the account and left the person's
documents, chunks, bots, conversations, context, settings and profile
behind, under an id nobody holds. onAccountDeleted now removes them, and
the person's uploaded files in the documents bucket.
A test reads the migrations and fails when a table that referenced
auth.users is missing from PERSON_ROWS.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* ci(auth): a navigation sent on after landing is not a failed journey
The settings page can send a just-signed-in browser on once more while its
session loads; Playwright reports the first navigation as aborted. The
journey now waits for the page to arrive, however it gets there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* fix(auth): ask the server before sending a signed-in visitor to sign in
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
---------
Co-authored-by: Claude <noreply@anthropic.com>
* feat(auth): every way in on AccountKit's own screens
Botsmann signed people in against OrangeCat's GoTrue (auth.users). It now
runs on AccountKit (@bitbaum/accountkit 0.23) with AccountKit's own forms:
/auth/signin offers email and password, an emailed sign-in link, a
passkey, recovery through the mailed link and the second factor;
/auth/signup is sign-up; /account carries the account panel ("Sign-in and
security" in the account menu). "Continue with OrangeCat" and the shared
sign-in show when their clients are set, the link and recovery when mail
is. The GoTrue routes (/api/auth/signin, signup, forgot-password,
resend-verification, profile) and pages (callback, forgot-password,
reset-password, verify-email) and the cookie-session client are gone.
AccountKit's tables live in a host accounts database (drizzle/, loki
accounts-db.conf); the data stays in the botsmann supabase schema, which
every route already read with the service-role client. verifyUser now reads
AccountKit's session; /api/user/profile moves onto it too. New accounts get
uuid ids, and migration 013 drops the person columns' keys to auth.users,
which a new person's id is not in. Nothing is deleted. The profile editor
writes AccountKit's name and image.
Existing people keep their rows: scripts/db/accountkit-people.sql lists
everyone who owns rows with their OrangeCat actor id, and
scripts/db/accountkit-import.sql gives each an account under the same id,
linked to OrangeCat by that actor id, never by address (loki
accountkit-supabase.yml rehearses it rolled back, then imports).
Pages were served with public, max-age=3600 to every browser, account pages
included: after sign-out the browser showed its cached /account. /account
and /auth/* are now private, no-store. The account menu's trigger has a name.
tests/__tests__/accounts runs the ways in and the import on the committed
migration; browser-smoke.yml's account job rehearses the import and runs
the browser journey against the production build with AccountKit's real
mail caught by a sink.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* fix(auth): send a signed-out visitor to sign in with the router
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* ci(auth): the shared sign-in's button is matched by how it starts
AccountKit 0.24 names only the providers Morulia publishes, so the label
changes with Morulia.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* ci(auth): expect the shared sign-in only once Morulia publishes a provider
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* ci: run the checks on the journey change
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
---------
Co-authored-by: Claude <noreply@anthropic.com>
lib/blog.ts and lib/knowledge.ts read their folders with readCollection /
readEntry instead of their own readdir + parseFrontmatter loops; the
published: true opt-in stays. lib/longform uses bip-kit's normalizeMarkdown,
which started as a copy of ours. Same posts and guides, same fields; items
with the same date now sort by title instead of by filesystem order.
The blog content doc still described the separate MDX content repo.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(settings): API keys are sealed at rest and checked before they are saved
Readers' Groq/OpenRouter keys sat in user_settings as plaintext, and GET
/api/settings returned the whole row — keys included — to the browser.
- Keys are sealed with @bitbaum/ai-kit/seal (BYOK_SEAL_SECRET); GET returns
only a hint (…abcd). Without the secret nothing new is stored (503).
- Legacy plaintext rows keep working and are sealed in place on first read.
- Save checks a new key with probeByokKey first; a key the provider refuses is
never stored, and the reason is the provider's own words.
- An empty key field keeps the saved key (removing is explicit); the old PUT
wrote key || null, which would have wiped keys once they stopped being sent.
- The key check now runs on its own after pasting, and actually passes:
both pages read the jsonSuccess payload at the top level, so settings never
loaded and every key — good or bad — was reported invalid.
- OpenRouter is checked on /key: its /models is public and 200s a dead key.
ai-kit ^1.18.0.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(settings): type the seal-secret lookup for plain env objects
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(ai): pick chain vendors by id, and make main green again
main has been red since #203 bumped @bitbaum/ai-kit to 1.10, which put
Gemini second in freeChain('BOTSMANN'). vendorChain() indexed [1] for
OpenRouter, so a BYOK OpenRouter user's key would have been sent down the
Gemini link. Look vendors up by id instead (code and both tests).
Also clears the rest of the red verify from the same bump: prettier 3.x
reformat of six files and the new next lint rule on relative
window.location.href assignments (sign-out keeps its full reload).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
* fix(ai): context extraction runs only on the user's own key
Every professional-chat turn fired a second, unasked model call
(extractAndSaveContext, fire-and-forget after the answer) on the shared
free-tier Groq key. Standing rule (2026-09-25): free-tier keys are spent
only when a person deliberately asks. Extraction now requires the user's
own key and uses their provider; without one it returns before any call.
Adds tests/__tests__/no-free-background-ai.test.ts: walks the import graph
from the timer route (/api/rebuild, appcron-botsmann-rebuild), /api/warmup
and /api/health and fails if any reaches a model client. Proven by
mutation: importing lib/nlp into /api/rebuild fails it, and dropping the
own-key guard fails the three new extractor cases.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
---------
Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* refactor(rate-limit): one limiter from limitkit, keyed on the proxy's hop
Two hand-rolled limiters lived side by side — lib/rate-limit.ts and
lib/middleware/rate-limit.ts — each with its own window maths, its own
header names and its own idea of who the caller is. Both are gone; the
decision now comes from limitkit (fleet/SHARED.md), and what stays here
is the one table of app budgets in lib/rate-limit.ts. A route names a
bucket; it does not get to invent a number.
The reason this matters beyond tidiness: both copies keyed the limit on
the FIRST hop of X-Forwarded-For. That hop is written by the client, so
any caller could mint a fresh budget per request by adding a header —
the limiter looked like it worked and enforced nothing. limitkit counts
from the right, i.e. the hop our own proxy wrote. A test now pins it:
a forged first hop must not mint a fresh bucket.
Also removed the Supabase check_rate_limit RPC path, which failed OPEN
on every error — the limiter switched itself off whenever the database
hiccupped. And 429s now carry Retry-After and X-RateLimit-* headers plus
a retryAfter field, which is what the auth forms count down.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8
* refactor(icons): each icon body written once
Icons.tsx repeated the same 24-box outline SVG wrapper for every icon —
a 121-line self-clone. One `Outline` frame and one `icon(paths, ...)`
builder replace it; an icon is now its path data and nothing else.
Every export and every path string is byte-identical to before, so the
rendered output does not move.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8
* refactor(create): one QuickCreateFlow behind /create and /personal
The two pages held the same three-step flow twice — 192 cloned lines of
state machine, header, progress indicator and step switch. They differ
only in the copy around the template picker, so that is what the pages
now pass in: /personal supplies its title block and its link out to the
professionals, /create supplies neither.
Both renders are unchanged, including that /personal's intro and outro
only appear on the picker step.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8
* refactor(auth): one shell, one field, one submit button for the auth screens
signup, signin, forgot-password and verify-email each carried their own
copy of the page frame, the error line, the labelled input and the
submit button — six clone pairs with signup in every one. They now share
AuthShell / AuthAlert / AuthField / AuthSubmitButton, and the per-form
error-plus-countdown state lives once in useAuthError.
One real fix falls out of it: isRateLimitError compared the error code
against 'RATE_LIMITED', but the API has always sent 'RATE_LIMIT'. The
rate-limit countdown therefore never showed. It does now.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8
* chore(lint): console.info is not logging, and every disable says why
`no-console` allowed `info`, so debug lines shipped as operator output:
the blog route narrated every render to the server log at info level.
Those lines now go through lib/logger (the single logger) at the level
they actually are, and the allowance is gone — warn and error only. The
21 remaining console.log calls are all in scripts/test-db-connection.ts,
where printing to the terminal is the point.
The eslint-disable count drops 16 -> 13. Comments.tsx no longer needs one
(useSyncExternalStore is the supported way to ask "are we on the client"),
and lib/supabase.ts no longer needs its `any` — the SSG mock casts once at
the return instead. The 13 that remain each name their reason: external
avatar URLs that next/image would need a host allowlist for, and effects
that seed state from an external store.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
The product was renamed on 2026-09-14: bitbaum/loki, loki.orangecat.ch,
LOKI_* env keys, loki-* units. This repo referenced the old name in
15 files changed, 29 insertions(+), 29 deletions(-).
Email addresses at the old sending domain stay until the new domain is
verified in Resend.
Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
longform.css carried two rules (`.bp-article .bp-ul/.bp-ol { list-style-type }`)
added in #187 to put back the bullets and numbers Tailwind's preflight
erased — bip-kit coloured `::marker` but never declared a list type, so the
marker being coloured did not exist. Its own comment said to drop the rules
once a bip-kit release declared the types itself. 0.2.3 does, on the bare
`.bp-ul`/`.bp-ol`/`.bp-footnotes-list` selectors and the nested levels, with
a package test guarding it — so the patch and its note go, and the
declarations now arrive from the package.
Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
bip-kit's stylesheet styles list markers (`.bp-ul .bp-li::marker`) but never
re-declares a list type, relying on the browser default. Tailwind's preflight
resets `list-style: none` on every ul/ol, so under Tailwind bip-kit colours
markers that do not exist: every bullet and every number in an article
disappeared, leaving indented naked lines.
Caught by screenshotting the live page rather than the HTML — the markup is
identical either way, which is exactly why the structural checks in the
migration PR passed over it.
The durable fix belongs upstream in bip-kit/styles.css, since this hits every
Tailwind consumer of the renderer. These two rules are the local unblock and
carry a note to drop them once a bip-kit release declares the list types.
Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
On 2026-08-28 /api/health reported "healthy" while every AI feature on
this site was failing on an invalid Groq key. Carrying `llm` in that body
fixed the REPORTING. It did not make the state observable before a user
hit it, because nothing calls a provider until somebody uses the bot — so
straight after a deploy the field reads "unknown", and unknown is what it
stays.
GET /api/health/ai free. What the last real call did.
GET /api/health/ai?probe=1 a real call. 200 or 503. Needs the secret.
Opposite contract to /api/health on purpose: that route is LIVENESS and
must stay 200 while the LLM is down, because restarting does not fix an
expired key and failing on it would get a healthy process killed. This
one is the inverse, so an uptime monitor can page on a real AI outage
without paging on every deploy.
It probes THIS app's chain: `ask` (ai-kit 0.15.0) calls
generateWithBestProvider, the same function the chat routes use. A probe
built from its own provider list would test a path nothing else takes and
would drift from this one the first time the chain changed.
The secret is a GETTER — the handler is built once and reused, so a
captured string would be whatever the environment held on the first
request: un-rotatable without a restart, and untestable.
TWO THINGS THE TESTS TAUGHT ME, both about this app rather than the
probe:
- generateWithBestProvider goes through getServerEnv(), which validates
the WHOLE server env and throws on the first missing var. A probe
test that sets only the AI keys fails on SUPABASE_SERVICE_ROLE_KEY,
nowhere near the chain.
- Ollama is tried first and its availability is a LIVE PING, so a fetch
mock that answers every URL makes a local runtime appear to exist and
win the chain. The mock now refuses :11434, which is prod's real
shape — and the "which vendor served it" assertion looks at every
call rather than calls[0], because calls[0] is that ping.
verify green — 301 tests.
Claude-Session: https://claude.ai/code/session_01NHDLTKGirKU7He8q2YR2y4
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
The blog and the Knowledge Center each fetched their markdown from a
SEPARATE GitHub repository at request time (g-but/botsmann-blog-content,
g-but/botsmann-knowledge-content) and rendered it through next-mdx-remote
with a hand-rolled component map per surface. Two maps for one markdown
vocabulary, already drifted: the blog slugged headings with rehype-slug, the
guides with a different inline regex; the guides highlighted code, the blog
did not; each had its own Callout. The content itself lived where nobody
reviewed it, behind a GitHub handle rename that now answers only via a 301.
Both surfaces now read content/*.md from this repo and render through
bip-kit's typed-block parser and reference renderer:
- content/blog/*.md (5 posts) and content/knowledge/**/*.md (10 guides) are
vendered verbatim from the two content repos — word-level parity verified
across all 15 files, zero words lost. Post images moved to public/blog/.
- The three app/blog/<slug>/page.mdx files came along as drafts. They were
never routes: `page.mdx` only serves as a page when pageExtensions includes
mdx, and this app never configured that, so all three were dead files. They
are committed with `published: false` rather than deleted.
- lib/longform/ is the one pipeline both routes call: a fence-aware
normalizer (`# ` → `## `, `*`/`+` bullets → `-`, nested items flattened —
the guides carry 74 indented items and ~130 shell-comment `#` lines inside
fences that a naive normalizer would have corrupted), then parse → blocks +
TOC + reading time.
- setHighlighterLoader(() => import('shiki')) is registered at module scope.
This app builds `output: standalone`, where bip-kit's zero-config shiki
import is invisible to Next's file tracer — without the explicit literal,
production ships unhighlighted while dev looks right.
- The TOC is derived from the same parse that renders the page, so a TOC
anchor can no longer point at a heading id built by a different slug rule.
types/knowledge.ts loses TableOfContentsItem accordingly.
Retired: next-mdx-remote, remark-gfm, rehype-slug, rehype-autolink-headings,
gray-matter (deps), components/blog/{Server,Client}MDXContent + MDXComponents,
components/knowledge/{Callout,CodeBlock,TableOfContents}. next.config drops
the raw.githubusercontent image pattern and the GitHub hosts from CSP
connect-src, and points frame-src at the privacy video players bip-kit uses.
Article typography now flows from the token SSOT: lib/longform/longform.css
maps globals.css onto bip-kit's --bp-* contract, replacing ~40 hardcoded
Tailwind greys. The mapping covers every --bp-* colour and pins the article
light, because Botsmann has no dark theme anywhere (zero `dark:` utilities,
no theme provider, light-only chrome) — letting bip-kit's dark defaults
through would put a dark article inside a white page. When the site grows a
dark tier, this file follows it by changing values in globals.css only.
tests/__tests__/lib/longform-content.test.ts walks every content file through
the real pipeline: committed content is bip-kit's trust boundary and a
malformed chart/stats fence throws at parse time, which without a test would
surface as a 500 on the live page.
Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file already walked ai-kit's chain but kept its own fetch, so the
CHAIN came from the package and the REQUEST did not. That is where the
remaining defects lived, and they are the fleet's most common ones
(census 2026-09-06: 9 of 12 hand-rolled clients share them):
- `data.choices[0]?.message?.content || ''` handed an EMPTY 200 to the
user as the bot's reply, and the chain stopped there, satisfied. A
reasoning model that spends its budget thinking returns exactly that.
- a 429 became `throw new Error('Groq API error: ' + status)`: the body
was read, logged and discarded. Capacity, request-too-large and daily
quota share that status code and want opposite responses — retry
shortly, send less, or come back tomorrow.
- neither call had a DEADLINE. A vendor that accepted the connection
and never answered held the chat open indefinitely, and the fallback
beneath it was never reached.
Also removes the last decision this file was still making: the `attempt`
callback branched on `provider.id` to choose a key. Keys now resolve
through a synthetic env, which is the seam complete() reads, so a BYOK
caller's key and the server's own take one path instead of two. The two
per-vendor call functions and both model loops are gone (-134 lines).
Attribution is preserved deliberately. The OpenRouter call sends
HTTP-Referer and X-Title, which OpenRouter ranks apps by; complete() had
no way to send them, so ai-kit grew `extraHeaders` (0.10.0) rather than
this adoption quietly dropping Botsmann off that list. Now tested.
THREE TEST DEFECTS, all found by the conversion:
- one test asserted THE BUG: "returns empty string when no content in
response" expected `result.content === ''`. It is replaced by two
tests — an empty 200 demotes to the next link, and an empty 200 at
every link throws rather than answering with nothing.
- the fetch mocks were `{ ok, json }` literals with no `text()`. That
encoded an assumption about HOW the client reads a body and broke the
moment it read the text first (to keep the vendor's body in the
error). Real Response objects now.
- `mockResolvedValue(new Response(...))` handed every link the SAME
object, and a Response body can only be read once — so link two
always failed with "Body has already been read", a fake failure
standing in front of the real behaviour. Anything walking a chain
needs a factory, not a value.
The `vi.mock('@/lib/constants')` for the endpoint URLs is removed: the
client takes them from the same ai-kit provider record that supplies the
model list, so mocking them asserted a copy nothing reads. Verified the
resulting URLs are byte-identical to the constants they replace.
verify green: format, lint, typecheck, selfhost check, 277 tests, build.
Claude-Session: https://claude.ai/code/session_01NHDLTKGirKU7He8q2YR2y4
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
The playbook expected no SES call sites, but lib/email/service.ts is live
(consultations route sends welcome + admin mails through it), so a bare dep
removal would have broken the build. Instead the transport is swapped to the
fleet's mail layer:
- EmailService now sends via @bitbaum/mail-kit sendMail; the throw-on-failure
contract is preserved for the catching caller
- Sender comes from RESEND_FROM (fleet SSOT) with conventionalFrom('Botsmann')
fallback; FROM_EMAIL and NEXT_AWS_* reads deleted from email config paths
- @aws-sdk/client-ses removed; tests mock @bitbaum/mail-kit instead of SES,
with a new failed-send assertion
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>
lib/nlp.ts's processQuery() made a hardcoded direct fetch to
api.openai.com with a single model (gpt-3.5-turbo) and no fallback.
OPENAI_API_KEY is not configured in production, so this path always
threw before even reaching the network -- silently dead code on every
call from app/api/products/search/route.ts since deployment, papered
over only by the pre-existing basic-search fallback.
Replace the hardcoded OpenAI call with generateWithBestProvider from
lib/llm-client.ts, the same Ollama -> Groq -> OpenRouter chain every
other AI call path in this repo already uses. Preserves processQuery's
signature and its existing graceful-degradation contract (malformed
JSON or a fully unavailable chain still falls back to a basic keyword
search instead of throwing to the route).
Found by this session's fleet-wide AI-reliability audit, which has
been fixing this exact "single-vendor bypass, no fallback" shape
across the fleet.
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Tailwind 3.4 -> 4.3:
- tailwind.config.js DELETED; tokens now live in an @theme inline block in
app/globals.css (semantic names unchanged: action, paper, edge, ink...)
- postcss.config.js -> @tailwindcss/postcss; autoprefixer dropped (built in)
- @tailwind directives -> @import 'tailwindcss'; forms/typography via @plugin
- daisyui removed (no daisyui class used anywhere)
- next/font vars renamed --font-inter/--font-fraunces to break the circular
var() the old --font-sans binding would create inside @theme
- v4 deleted *-opacity-* utilities: every bg/text/ring-opacity-N rewritten to
slash syntax (bg-action/90, ring-black/5, ...); dynamic accent tint gets a
literal class map in lib/config/colors.ts so the scanner sees each class
- dead v3-era aspect-w/h custom utilities removed (unused; v4 has aspect-*)
Zod 3.24 -> 4.5:
- .errors -> .issues everywhere
- z.string().uuid( -> .guid( (v4 uuid() is RFC-variant-strict; DB ids aren't)
- z.record(z.unknown()) -> z.record(z.string(), z.unknown())
- object .default({}) -> .prefault({}) (v4 default takes the full output value)
ESLint 9 -> 10: eslint-plugin-react's version:'detect' calls the removed
context.getFilename; pin settings.react.version='19' AFTER the next configs.
Verify (format+lint+typecheck+selfhost+test+build) green: 272 tests pass.
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>
botsmann's own generateWithBestProvider/getProviderChain and llm-health.ts
were the source this session extracted ai-kit v0.5.0's tryChain and
createHealthTracker from. This adopts that package for real, closing the
gap flagged by a fleet-wide audit: botsmann had ai-kit installed for model
lists only, while the actual retry/health logic stayed hand-rolled here.
- generateWithBestProvider now builds one flat provider+model chain via
ai-kit's usableChain/freeChain and walks it with tryChain, instead of
two separate hand-rolled loops (provider here, model inside
generateWithGroq/generateWithOpenRouter). Ollama stays a special-cased
first check -- its availability is a live ping, not an API key, so it
does not fit ai-kit's Provider shape.
- generateWithGroq/generateWithOpenRouter are unchanged in behavior,
refactored into thin loops over new callGroqModel/callOpenRouterModel
single-shot primitives -- the same primitives generateWithBestProvider's
chain walk now calls directly, so there is exactly one fetch
implementation per vendor, not two.
- llm-health.ts keeps its exact five-function API (every route and test
still imports recordLLMSuccess/recordLLMFailure/getLLMHealth/
resetLLMHealth unchanged) but now wraps ai-kit's createHealthTracker
instead of hand-rolled module state.
One test's assertion on the aggregate-failure error wording updated
("provider(s)" -> "link(s)") to match ai-kit's more precise per-link
failure report; no other test needed changes. Full verify green: format,
lint, typecheck, 272 tests, production build.
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
generateWithBestProvider picked ONE provider and called it once. Being
configured counted as being available, so a present-but-revoked key was
indistinguishable from a working one: botsmann's Groq key started returning
401 and the entire AI layer went down, with no attempt at anything else.
kivvi survives the same dead-Groq situation on this box because it has an
OpenRouter key and reaches it. botsmann would not have, even after adding
one -- Groq is chosen first for merely existing, and its 401 was terminal.
getProviderChain() every configured provider, in preference order
(Ollama, Groq, OpenRouter) rather than the first
generateWithBestProvider() walks that chain, demoting on failure, and only
throws once every provider has been tried
generateLLMResponse already walks the model list within a provider (#137), so
this is the layer above: models, then providers. The error now names each
provider that failed and why, instead of surfacing whichever one happened to
be first.
This does NOT restore botsmann's AI. Every working LLM key on the box belongs
to a client -- AOZ's and RevampIT's -- and botsmann is a bitbaum product, so
pointing it at one would bill a client for our usage. It needs its own key.
What this does is make sure that once a second key exists, one dead key can
never take the product down again.
verify: format, lint, typecheck, 272 tests, build -- all green.
Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Found by driving the Lex demo in production: the chat answered "I'm sorry,
I encountered an error processing your request." Behind it, every AI feature
on the site is down and has been invisible.
The box has an invalid Groq key, no other provider key, and no Ollama:
Groq API error: 401 (model openai/gpt-oss-120b) {"code":"invalid_api_key"}
Groq API error: 401 (model openai/gpt-oss-20b) {"code":"invalid_api_key"}
Every endpoint answered HTTP 200 anyway:
/api/demo/chat {"success":true,"data":{"response":""}}
/api/quick-chat {"success":true,"data":{"response":"I'm having a moment..."}}
/api/professional-chat same
/api/health {"success":true,"data":{"status":"healthy"}}
Green everywhere, product dead. demo/chat was the worst of the three: its
catch returns `content: context`, and a bot demo has no context, so a failed
generation became a successful empty string.
- demo/chat throws LLMUnavailableError when there is nothing to fall back
on; the knowledge-base demo still serves its retrieved passage
- quick-chat and professional-chat return 503 LLM_UNAVAILABLE instead of
apologising with 200
- lib/llm-health.ts records what generations actually did; /api/health
reports it and returns 503 once the chain is consistently failing, so
"healthy" stops meaning "the database answered"
tests/__tests__/api/professional-chat.test.ts asserted the bug -- 200, the
word "moment", provider 'fallback'. It now asserts 503 LLM_UNAVAILABLE. A
test that pins broken behaviour is worse than no test.
Never-twice: tests/__tests__/lib/llm-health.test.ts covers the tracker's
state machine and asserts at source level that no chat route answers an LLM
failure with success, and that health consults the LLM chain.
This makes the outage visible. It does NOT fix it -- that needs a valid
GROQ_API_KEY (or OPENROUTER_API_KEY) in /opt/botsmann/shared/.env on the box.
Until then these endpoints will correctly return 503.
verify: format, lint, typecheck, 268 tests, build -- all green.
Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
#144 branded the bot page sections. It did not reach the demo underneath
them, so every first-party bot still ran the per-colour palette in its
interactive step -- the buttons, focus rings, progress dots, message bubbles,
dropzone and context panel -- plus the bot switcher in the nav.
The colour came from lib/demo/botDemoConfigs.ts, which carried its own
accentColor per bot (blue, green, red, indigo, amber). That is the sixth
place a colour was chosen, after: globals.css, lib/config/colors.ts,
lib/hooks/navigationConfig.ts, ACCENT_HERO_CLASSES, and data/professionals.ts.
DemoSection and BotSwitcher are used ONLY by the first-party bot pages
(verified: no custom-bot page imports either), so both are now brand:
BRAND_BUTTON, BRAND_FOCUS_RING, BRAND_STARTER, BRAND_CHECKBOX, BRAND_PROGRESS,
BRAND_MESSAGE, BRAND_DROPZONE, BRAND_CONTEXT_PANEL, BRAND_SWITCHER.
accentColor is gone from the demo config, its type, and the whole prop chain.
What still emits raw palette, correctly:
VISION_STATUS_CONFIG roadmap status -- completed green, in-progress blue,
planned amber, vision purple. Four states that have to
stay tellable apart; collapsing them to ochre would
destroy the information.
the /personal templates per-template identity in the memorial/legends
product, chosen from an allowlisted surface.
Both live behind lib/config/colors.ts, which the guard already documents as an
exception -- so the guard passing while those classes ship is correct, not a
blind spot. The blind spot was data/professionals.ts, fixed in #149.
verify: format, lint, typecheck, 256 tests, build -- all green. Bot demo
confirmed ochre end to end against a local production build.
Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Follows #146, which proved the pattern on Imhotep: recover the copy from
the components deleted in 4600019e, express it with existing section types,
add the nav entry, let the nav-integrity guard verify it. No new components.
research-assistant 5 -> 8 sections 3,062 -> 4,366 chars (+43%)
research-system the six ways Nerd organises an upload
scraping the six sources it watches (ArXiv, Scholar, PubMed,
Nature, Science Daily, MIT Tech Review)
drafts abstract / literature review / methodology / discussion
product-manager 5 -> 8 sections 2,539 -> 3,752 chars (+48%)
benefits the four Trident actually delivers
showcase feature planning, technical debt, cross-team coordination
integration GitHub and Jira, with what each one does
swiss-german-teacher 5 -> 8 sections 2,793 -> 3,900 chars (+40%)
language-learning vocabulary, conversation, grammar
communication email and texting, in the right register
culture video, podcasts, articles
artistic-advisor keeps 5 sections: it only ever had 217 lines, so unlike the
others it lost almost nothing. It gains two nav entries for the sections it
does have, instead of a two-item menu.
Nav went from a low of two items per bot to five or six, and every entry
points at a section that renders -- enforced by the guard added in #146.
Copy was rewritten rather than pasted. The originals were written for a
different page structure and carried filler; this keeps the substance and
drops the padding.
verify: format, lint, typecheck, 253 tests, build -- all green. Verified
visually against a local production build.
Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
The config-driven refactor (4600019e) deleted ~16,000 lines of bot page
content but left data/bots.ts still advertising it. Every bot's nav kept
linking to sections that no longer existed:
swiss-german-teacher communication, culture, waitlist
research-assistant scraping, drafts, questions, discovery,
integration, roadmap
medical-expert harm-reduction
artistic-advisor styles, techniques, get-started
product-manager workflow, showcase, examples, integration,
testimonials, pricing, get-started
legal-expert get-started
Twenty menu items that scrolled nowhere, on the live site, for seven months.
Nothing failed because nothing compared data/bots.ts to bot-pages.ts.
Now they do: tests/__tests__/lib/bot-nav-integrity.test.ts asserts every nav
item targets a section the page actually renders, and that ids are unique.
Mutation-verified -- repoint one item at a missing section and it fails and
names it.
legal-expert's 'Get Started' was repointed to the cta section it clearly
meant. The rest are removed, because the sections they named are gone.
Content restored for medical-expert, recovered from the deleted components
and ported as config (no new components needed):
medbox MedBox home health lab -- the 6 sensors
health-topics the 6 topics Imhotep covers
regimens Basic / Advanced, and how they compare to Blueprint
Its page goes from 7 sections to 10, and from 3,833 to 5,380 rendered
characters. The nav gains MedBox and Topics in place of the dead link.
NOT restored: the harm-reduction section, a substance comparison table
covering heroin, methamphetamine, MDMA, LSD and psilocybin. On a site
offering AI health guidance that is a product and possibly a regulatory
decision, not a cleanup one. It stays in git at 4600019e^ pending a call:
git show 4600019e^:app/bots/medical-expert/components/features/HarmReductionSection.tsx
The other four bots still need their content ported; this is the pattern.
verify: format, lint, typecheck, 253 tests, build -- all green. Verified
visually against a local production build.
Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
app/globals.css defines the identity -- editorial ink, one ochre accent --
and says so in a comment: "No generic AI gradient blue/purple." The bot
pages ignored it and ran a parallel palette, so a single viewport of
/bots/legal-expert showed a blue logo, a blue nav button and an ochre CTA
at the same time.
There were four colour sources, not two:
lib/config/colors.ts 16-colour accent sets
lib/hooks/navigationConfig its own 5-colour NAV_COLOR_CLASSES
ACCENT_HERO_CLASSES a fifth set (whose green and indigo entries
both set chatBg to 'bg-blue-50' -- it was not
even self-consistent)
raw Tailwind greys text-gray-900 / bg-white / border-gray-200
The six professional bots are Botsmann, so they now wear the brand:
BRAND_ACCENT and BRAND_HERO, plus a single NAV_COLORS scheme. 113 raw
grey/white classes became semantic tokens (text-ink, text-ink-muted,
bg-surface, bg-paper, border-edge). The page ground is bg-paper, matching
the homepage instead of flat white.
The 'B' mark in BotNavigation was literally
`bg-gradient-to-r from-blue-600 to-purple-600` -- the exact thing globals.css
forbids by name. It now renders the shared <Logo>, so it cannot drift again.
Per-bot accentColor is gone from the first-party config and its plumbing.
The per-colour sets STAY for user-created bots: custom_bots.accent_color is
a real column with a CHECK constraint and the owner picks it. That is user
data, not a design token.
Also deleted components/shared/BotPageTemplate.tsx -- nothing imported it.
Not in this change: /try, /enterprise, /bots and /knowledge still carry
blue/purple gradients (72 files match the raw palette). Same class, separate
pass, so this one stays reviewable.
verify: format, lint, typecheck, 240 tests, build -- all green. Verified
visually against a local production build.
Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
The schema fix landed in #138, but the repo still told you to operate a
Supabase we do not have. docs/SUPABASE_SETUP.md opened with "Completed Setup"
for a hosted project jkjmhtirxwhljpkcfxqe.supabase.co and said to apply
migrations by pasting SQL into a supabase.com dashboard. Two unreferenced
scripts printed the same instruction, one handing out a psql string against
pooler.supabase.com, and the CLI's .temp cache with the old project ref was
committed — twice, once nested under supabase/migrations/.
That is not stale clutter, it is the outage. A wrong pointer to a real-looking
place is worse than no pointer: no pointer makes someone ask, a plausible one
makes them assume it was handled. Nobody pasted anything, the eleven migrations
were never applied, and /api/health served PGRST205 for months while every
deploy went green.
So the doc now describes what is actually true — self-hosted on bitbaum at
supabase.orangecat.ch, our tables in the `botsmann` schema because one database
backs several apps and `public` is orangecat's, and migrations applied
automatically on deploy by fleetcrown's apply-schema.sh against the
botsmann._deploy_schema_history ledger. Nothing is pasted anywhere. 280 lines
became 100.
Fixing today's copies only clears today's copies, so check:selfhost joins
verify: it fails on supabase.com/dashboard, app.supabase.com, pooler URLs and
real project refs, allows supabase.com/docs because the product documentation
is still correct for us, and exempts docs/archive/ so history can stay honest.
Proven to fail before shipping — it catches an injected dashboard link and a
project ref, and leaves the your-project.supabase.co placeholder alone.
Claude-Session: https://claude.ai/code/session_018waGt1ieA9TjpscqrbrnGb
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
app/projects was 79 files and half of all app code -- an e-government
platform with a whitepaper, open-law, open-vote, open-pay, a transparency
portal and agency/employee directories. app/solutions was another 7 routes.
Nothing linked to either. lib/routes.ts declared PROJECTS: '/projects' and
no file imported it; there were zero inbound hrefs from any nav, footer or
page. But both were statically generated on every build and served publicly,
so they cost a build slot and an audit read each time while no visitor could
reach them.
Also removed, dead once those trees went (verified: no remaining importers):
components/governance/, components/SolutionLayout.tsx,
components/navigation/NextSection.tsx, lib/governance/,
types/governance.ts, data/solutions.json
app/ drops from 26,821 to 13,101 lines. 68 routes remain, all reachable.
Deliberately NOT removed: /personal and its bot templates. That surface is
linked from the homepage and the footer and it works, so removing it is a
product decision rather than cleanup.
Recovering any of this is one command:
git checkout f70fc612 -- app/projects app/solutions components/governance
verify: format, lint, typecheck, 240 tests, build -- all green.
Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
app/api/demo/chat is public and unauthenticated, and
app/api/custom-bots/[id]/chat lets anonymous callers chat with public
bots billed to the bot OWNER's API key. Neither had a limit. Nothing
failed, because nothing was checking.
Both are closed. The custom-bot limit is scoped per bot id so one hot
bot cannot drain another's budget.
The reason they drifted is that each route hand-rolled the same block:
read the IP, call checkRateLimit with inline magic numbers, return a
429 written slightly differently each time. So the budgets now live in
one place (RATE_LIMITS) behind one helper (enforceRateLimit), and the
seven existing copies were migrated onto it -- removing three different
429 response shapes and a hand-rolled copy of getClientIp.
Never-twice: tests/__tests__/api/rate-limit-coverage.test.ts reads every
route file and fails if one imports the LLM client without enforcing a
limit, or calls checkRateLimit directly with its own numbers. Verified
by mutation -- removing a limit makes it fail and name the file.
verify: format, lint, typecheck, 240 tests, build -- all green.
Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
/api/health has returned 503 because `public.consultations` does not exist. It
never did. Botsmann shares one self-hosted Supabase database with orangecat,
which owns `public` and its 128 tables; ours were nowhere, because all eleven
migrations were unapplied.
The schema half is fixed in the deploy pipeline (fleetcrown#398): botsmann now
declares `supabase:botsmann` and its migrations apply into a schema of its own,
exactly as printcraft's do. That has run — all 11 tags are recorded and the 12
tables exist.
This is the other half. A Supabase client that is not told the schema queries
`public`, so it would still get PGRST205. Measured against production just now:
GET /rest/v1/consultations -> 404 PGRST205
GET /rest/v1/consultations Accept-Profile: botsmann -> 200 []
`db: { schema }` is what sends that header, and it was missing from all four
client factories — anon, service-role, browser and route-handler.
The schema name is one constant in lib/constants.ts, not four literals. The
second copy is how the first goes stale, and this repo has just spent a day
proving what duplicated configuration costs.
Two things this also removes:
* `scripts/run-migration.ts` and `scripts/migrate-via-api.ts` applied SQL
through the service-role client with no schema set. They are from the era
when migrations were run by hand; now they would create our tables inside
orangecat's `public`. Schema is the pipeline's job, and a second way to do
it is a second way to do it wrong. Nothing references them.
* The bare `SupabaseClient` type hardcodes `'public'`, so annotating with it
silently asserts we query orangecat's tables — and rejects the client we
actually build. The type is now derived from the factory, which keeps the
two in step and survives supabase-js reordering its generics.
New test pins it per file, by count: every `createClient` call in a client file
must set the schema, from the shared constant, with comments stripped first so
the guard cannot be fooled by prose. Adding a fifth unscoped factory fails the
test instead of production. Mutation-checked: unscoping the browser client
fails it.
verify green: 237 tests, lint, typecheck, build.
Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Both ids in `API_CONFIG` have been retired by their vendors:
`llama-3.1-8b-instant` at Groq and `openai/gpt-oss-20b:free` at OpenRouter. With
a valid key, this app's chatbot was answering 404.
Nothing was neglected here. The constant carried the correct instruction —
"free catalogues rot; when it does, replace it with another `:free` id" — and
that is precisely the maintenance that did not happen, because nothing tells a
constant when it has stopped being true. So the ids leave this repo. `ai-kit`
holds one list for the fleet, re-probes it against the live catalogues, and
dotfiles' daily audit asks both vendors whether those ids still exist.
One id was also not enough on its own. `generateWithBestProvider` picks ONE
provider and calls it exactly once, so a retirement had nothing between it and
a dead chatbot. Each vendor's call now walks that vendor's list: a 404 (retired)
or a 429 (busy or spent) steps to the next model instead of surfacing.
This is model-level fallback, not vendor-level — provider selection is untouched.
That is the smaller half of the protection, since a spent daily budget is
org-wide and kills every model at a vendor together. It is also the half that
covers rot, which is what actually happened here, twice.
An explicit caller override is still honoured as-is and alone. If someone names
a model, quietly answering from a different one is worse than failing.
The cost rule that lived in the deleted comment survives, and got stronger.
`free-fallback.test.ts` used to regex ONE constant; it now runs `modelCost` over
every OpenRouter id this app could send, using the same function the rest of the
fleet prices models with. OpenRouter is only reached when Groq's free tier is
spent — when nobody is watching — so a paid id there turns an outage into a bill.
The old tests deserve a note, because they passed throughout the outage: they
mocked `llama-3.1-8b-instant` and asserted it back, agreeing with production
about an id production was refusing. Worse, the OpenRouter test asserted
`anthropic/claude-sonnet-5` — a paid model on the free-tier fallback path, the
exact thing the fleet rule forbids, green the whole time. They now assert
against the chain, plus two new cases: a retired first model falls through to a
different one, and exhausting the list names the whole list.
`jest.config.js` transforms `ai-kit`, which is ESM-only. The comment there says
what does NOT belong in that list, since a transitive entry would mean a package
leaking a dependency through a re-export — a bug to fix at the source.
verify: format, lint, typecheck, 232 tests, build.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
OPENROUTER_DEFAULT_MODEL was `anthropic/claude-sonnet-5`. OpenRouter is the
FALLBACK here — it is reached when Groq's free tier is spent — so the failure
mode of 'the free tier ran out' was not a degraded answer or an honest refusal.
It was a bill, on a premium model, produced by the one code path nobody watches
because it only runs when something else has already broken.
A fallback is a reliability mechanism; paying is a business decision. Wiring the
second to the first lets an outage make the decision at the worst moment,
without anyone choosing it. It also broke the standing fleet rule that Anthropic
is never a primary or fallback provider.
Now `openai/gpt-oss-20b:free`, which reports pricing.prompt = 0 in OpenRouter's
own catalogue (checked 2026-08-16) and was probed live for tool support on
2026-08-15.
Guarded by a test, because this path is invisible in normal operation: the
default must end in `:free` and must never be an Anthropic id. The rule mirrors
`modelCost` in the shared ai-ration package — a routed id is free ONLY with the
`:free` suffix, which is the entire difference between free routing and a
per-call charge for identical weights.
The same mistake was found in three apps on the same day (also kivvi and evig).
* feat(meta): give the site a real social preview
This site shipped no og:image, so every link to it — Telegram, Slack, a DM —
rendered as a blank grey rectangle. Adds the Next file-convention card
(1200x630, the size those scrapers crop to) drawn in the site's own palette.
Also sets metadataBase, which is load-bearing rather than cosmetic: without it
Next resolves the generated image to http://localhost:3000/opengraph-image — a
tag that is present, looks configured, and is unfetchable by every scraper. The
fallback is the real host, so a missing env var degrades to correct rather than
to localhost.
site.url also pointed at botsmann.com, which has no DNS A record — so
everything derived from it (canonical URL, og:image, sitemap) named a host that
does not resolve. Corrected to where the site actually serves.
Pattern verified end-to-end on a sibling repo: build, render, 200 image/png at
1200x630, and og:image emitted as the absolute production URL.
* style: apply prettier to the new preview card
- providers.py: claude-sonnet-4-20250514 (deprecated, retires Jun 2026) -> claude-sonnet-5
- constants.ts: anthropic/claude-3.5-sonnet (retired Oct 2025 on OpenRouter) -> anthropic/claude-sonnet-5 (verified against OpenRouter's live model list)
- test fixtures updated to match
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Re-enables the three React-Compiler-era rules deferred in #114
(set-state-in-effect, error-boundaries, immutability) — all now ON — and
resolves every violation with a real fix or a justified, documented exception.
error-boundaries (12 → 0, real fix):
- app/blog/[slug]/page.tsx wrapped its whole render in try/catch that only
re-threw. Removed it: notFound()/render errors now propagate to Next's
not-found.tsx / error.tsx as intended (the catch also mislogged notFound()).
immutability (5 → 0, real fix):
- The auth pages assigned window.location.href during render. Moved each
redirect into a useEffect (above the early returns for rules-of-hooks),
preserving the full-page navigation while keeping render pure.
signin, signup, forgot-password, verify-email (×2).
set-state-in-effect (13 → 0, justified inline disables):
- Every case is a legitimate effect use — external-system sync (Supabase auth,
API loads), browser-only hydration (localStorage, client-mount), or seeding
editable state from async-loaded data. Forcing them off-effect would add
complexity or risk behaviour changes to auth/data code, so each carries an
eslint-disable-next-line with a specific reason. The rule stays ON to catch
genuinely-avoidable derived-state-in-effect in future code.
Verified: eslint . (0 problems), prettier, tsc --noEmit, next build, jest 227 pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Bumps next + eslint-config-next 14.2.35 → 15.5.21. React stays on 18
(Next 15 supports React ^18.2.0), so no forced React 19 migration.
Clears all 15 open next-related Dependabot alerts (4 high) — the highest
patched version required is 15.5.16, so jumping to Next 16 would add
breakage (React 19, Turbopack default) for zero additional security gain.
Next 15 breaking-change migration:
- Async request APIs: params/searchParams awaited in the 6 dynamic pages
that consume them as props; cookies() is now async, so
createRouteHandlerClient() became async (9 call sites awaited).
- next.config: serverComponentsExternalPackages → top-level
serverExternalPackages (renamed/destabilized in Next 15).
- typedRoutes tightening: object href {pathname, hash} is no longer
accepted → string href "/path#hash" (4 governance pages).
- eslint: ignore the Next-generated next-env.d.ts (Next 15 adds a
triple-slash routes.d.ts reference that trips no-triple-slash-reference).
Verified: `next build` green — compiles, type-checks, lints, and
prerenders all 81 pages. Client components using the useParams()
hook are unaffected and left untouched.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Botsmann had no identity of its own: a generic 2021-era AI-SaaS skin with the
brand fragmented across three disagreeing sources (config OpenAI-green,
globals.css black/white, page blue/purple/cyan gradients). Derive Botsmann's
OWN voice — serious, credible counsel: warm editorial ink + a single
authoritative ochre accent, carried by a serif display face, not gradient tricks.
- globals.css is now the single SSOT for design tokens (semantic colors for
brand/action/surface/text + radii + shadows, two-tier primitive→semantic).
- tailwind.config wired to the CSS vars; literal colors removed. Ripped out the
OpenAI-borrowed tokens (openai-green #10a37f / openai-gray) and migrated every
consumer to the semantic `action` / `brand` tokens.
- Killed the generic "AI gradient" skin: removed the blue→purple→cyan gradient
wordmark, the blurred gradient hero blobs, gradient buttons, and glassmorphism.
Replaced with one confident ochre accent + ink, hairline editorial surfaces.
- Real typeface via next/font: Fraunces (serif display, headings + wordmark) +
Inter (UI/body), bound to --font-serif / --font-sans. Retires system-ui.
- Replaced emoji professional avatars (⚖️🩺🔬🇨🇭🎨♛) with a ProfessionalAvatar
monogram badge built on the existing accentColor SSOT.
- One headline value prop: tab title, hero H1 and footer now all agree on
"Your Private AI Professionals" (was a split tagline vs H1).
Design only — all content and functionality preserved. Lint clean; no new tsc
errors (the pre-existing embeddings.test.ts error is unchanged from main);
production CSS resolves the full token chain.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Create searchUserDocuments() that encapsulates the common pattern:
embed query → match_documents RPC → filter → build context + sources.
Used by both chat/route.ts and professional-chat/route.ts, removing
~50 duplicated lines across the two routes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Create lib/logger.ts — lightweight wrapper that outputs plain text in dev
and structured JSON in production. Replace 117 console.log/error/warn
calls across 31 files (27 API routes + 4 lib files) with logger.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Standardize signup route to use jsonSuccess/jsonError helpers, extract
connection status config, clean up StatusBadge/ProviderCard inline maps,
add input validation to knowledge route, fix domain validation.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Core differentiator: professionals learn about users over time.
- Add user_context table with vector embeddings (migration 011)
- Add get_relevant_context() SQL function for semantic search
- Create lib/context/ module:
- store.ts: save and retrieve user context entries
- extractor.ts: LLM-based fact extraction from conversations
- domain-detector.ts: keyword-based domain classification
- Integrate into professional-chat route:
- Retrieve relevant user context and inject into system prompt
- Async extraction of facts after each conversation turn
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
In-memory rate limiting (LRU cache + Map) doesn't work correctly in
serverless — each function instance has its own memory. Replace with
a Supabase PostgreSQL function that atomically checks and increments
per key, shared across all instances.
- Add rate_limits table + check_rate_limit SQL function (migration 010)
- Rewrite lib/rate-limit.ts to call Supabase RPC instead of LRU cache
- Simplify lib/middleware/rate-limit.ts to wrap the new checkRateLimit
- Update all 7 routes using the old LRU-based limiter
- Remove lru-cache and @types/lru-cache dependencies
- Auth routes (5) unchanged — they already use the middleware wrapper
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replaced imports in lib/api-utils.ts (-> ./supabase-server) and
app/auth/callback/page.tsx (-> @/lib/supabase) with existing local
wrappers. Removed the deprecated package from dependencies.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Created lib/hooks/useLocalStorage.ts with SSR-safe boolean persistence.
Updated ChatAuthCTA and OnboardingChecklist to use it instead of raw
localStorage calls.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Created lib/config/env.ts as SSOT for all env vars with Zod schemas
(client + server split). Updated supabase.ts, supabase-server.ts, and
llm-client.ts to use getClientEnv()/getServerEnv() instead of raw
process.env access. Missing required vars now fail with clear messages.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Added 9 new mapping exports to lib/config/colors.ts (button, focus-ring,
checkbox, starter, message, dropzone, progress, context-panel, hero,
template-hover). Removed local accentColorClasses definitions from all
8 consumer components.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove duplicate ApiResponse, apiSuccess, apiError, withErrorHandling,
requireAuth, ERROR_MESSAGES from lib/api-utils.ts — only verifyUser
was actually imported anywhere. Response utils SSOT is lib/api/responses.ts
- Archive 14 historical LEX-era design docs to docs/archive/ — docs/
now has only 9 active reference files (down from 29)
- Remove mock data and placeholder images from Amazon/Ricardo platform
integrations — functions return [] until real APIs are implemented
- Update platform tests to match actual behavior
- Fix README.md: update backend tech (Groq/OpenRouter), add Supabase
to prerequisites
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>