Commit Graph
27 Commits
Author SHA1 Message Date
CatoandClaude Opus 5.5 ce98b0cc24 fix(ai): context extraction only on the user's own key; vendors by id (main green again) (#205)
* 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>
2026-09-25 00:44:17 -07:00
CatoandClaude Opus 5 a6906851d5 refactor(content): one markdown pipeline — bip-kit typed blocks replace MDX and two GitHub content repos (#183)
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>
2026-09-07 14:24:40 +00:00
1e60f2a8d2 chore: remove the orphaned /projects and /solutions trees (#142)
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>
2026-08-28 07:58:08 +00:00
g-butandClaude Opus 4.6 82e4623105 feat(rate-limit): replace in-memory rate limiting with Supabase-based
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>
2026-03-02 17:23:15 +01:00
g-butandClaude Opus 4.6 e1d9b18532 fix(api): fix document query using non-existent 'category' column
The professional-chat route queried .in('category', ...) but the
documents table has 'domains TEXT[]' (added in migration 009), not
'category'. Changed to .overlaps('domains', ...) for correct array
overlap matching. Updated Document interface to use domains[] field.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 17:23:11 +01:00
g-butandClaude Opus 4.6 be1f76ea9e refactor: fix DRY/SSOT violations and Tailwind build bug
- Fix dynamic Tailwind classes in ProfessionalDemo.tsx that were purged
  at build time by replacing string interpolation with static lookups
- Deduplicate LLM config by importing GROQ/OpenRouter constants from
  API_CONFIG instead of defining them locally in llm-client.ts
- Remove duplicate input type interfaces from types/ that duplicated
  Zod-inferred types in lib/validations/, re-export from SSOT
- Extract shared navigation config (AUTH_NAV_ITEMS) and icon components
  used by both AuthNav and MobileNav into lib/config/navigation.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:15:08 +01:00
g-butandClaude Opus 4.5 cc632bb57c feat: add document categories and professional chat API
Port features from legacy codebase:
- Add DocumentCategory type with 7 categories (legal, health, research, etc.)
- Add PROFESSIONAL_DOCUMENT_ACCESS mapping for category-based access
- Add CategoryBadge and CategorySelector components
- Add professional-chat API with document context integration
- Add ErrorBoundary component for error handling
- Add professionals layout with metadata
- Add useRateLimitCountdown hook

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 11:14:27 +01:00
g-butandClaude Opus 4.5 1e2d0d935d chore: remove orphaned files never imported anywhere
Removed dead code:
- components/ErrorBoundary.tsx (108 lines, Next.js error.tsx exists)
- components/CollaborationForm.tsx (190 lines, never imported)
- types/solutions.ts (24 lines, never imported)
- data/botsmann-knowledge.ts (215 lines, never imported)
- data/demo/swiss-german-knowledge.json (never imported)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 16:31:06 +01:00
g-butandClaude Opus 4.5 d10360c231 refactor: code quality improvements (DRY, SSOT, inline styles)
- Remove duplicate MAX_FILE_SIZE constant, use VALIDATION.MAX_FILE_SIZE (SSOT)
- Refactor CustomBotPage sendMessage logic to eliminate code duplication (DRY)
- Convert inline animation-delay styles to Tailwind arbitrary values
- Add development-only check to ErrorBoundary console.error
- Remove deprecated MAX_FILE_SIZE export from types/document.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 01:06:06 +01:00
g-butandClaude Opus 4.5 6c25dc8dfe refactor: comprehensive code quality improvements (DRY, SSOT, SoC)
## Broken Links Fixed
- Fix /projects/governance/build link to /contact in HeroSection.tsx

## Console Statements Removed (production code)
- Remove console.log/error from client components
- Replace with silent error handling or UI feedback
- Files: documents/page.tsx, try/page.tsx, settings/page.tsx,
  ConversationList.tsx, ProfessionalDemo.tsx, and more

## Inline Styles Converted to Tailwind
- Replace animation-delay inline styles with Tailwind arbitrary values
- Files: DemoMessage.tsx, DemoChat.tsx, ProfessionalDemo.tsx,
  QuickChat.tsx, demo/page.tsx, HeroSection.tsx

## Governance Types Consolidated (SSOT)
- Create app/projects/governance/types.ts as single source of truth
- Create app/projects/governance/utils.ts for formatting functions
- Remove duplicate EnhancedTransaction from TransactionWithTraceability.tsx
- Update component type files to re-export from SSOT

## Colors Config Extended
- Extend COLOR_CLASSES to support all 16 accent colors
- Fix type mismatch in custom bot pages

## Magic Numbers Extracted
- Add formatBytes utility to lib/format.ts (DRY)
- Add DEMO_MAX_FILE_SIZE to VALIDATION constants
- Update try/page.tsx to use centralized constants

## Minor Fixes
- Fix unused variable warning in CollaborationForm.tsx

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 00:24:27 +01:00
g-butandClaude Opus 4.5 b15cdcd432 refactor: consolidate accent colors into SSOT config
- Create lib/config/colors.ts as single source of truth for all colors
- AccentColor (16 colors) for bot templates
- CustomBotAccentColor (5 colors) for custom bots (matches DB constraint)
- Remove hardcoded color maps from QuickChat.tsx
- Derive types from Zod schemas instead of separate definitions
- Add justification comment for any type in supabase mock
- Remove console.error from production code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 23:23:04 +01:00
g-butandClaude Opus 4.5 6da1c37668 refactor: extract document status to constants and shared component (SSOT)
- Added DOCUMENT_STATUS constant to lib/constants.ts
- Added DocumentStatusType derived from constant
- Added DOCUMENT_STATUS_CONFIG for display (labels, colors)
- Created DocumentStatusBadge shared component
- Updated types/document.ts to use DocumentStatusType
- Updated app/documents/page.tsx to use shared component and constants

Changes to add a new status now require only 1 file (lib/constants.ts).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 18:45:37 +01:00
g-butandClaude Opus 4.5 1c7abeebac docs(claude): add global standards reference and update date
- Add @~/.claude/CLAUDE.md import for global engineering standards
- Update Last Updated date to 2026-01-23

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:22:36 +01:00
g-butandClaude Opus 4.5 842abc3590 feat: Migrate waitlist to Supabase and add error boundaries
- Replace file-based JSON storage with Supabase for waitlist API
- Add SQL migration for waitlist table (010_waitlist.sql)
- Add error.tsx for segment-level error handling
- Add global-error.tsx for root-level error handling
- Add not-found.tsx for 404 page
- Add reusable ErrorBoundary component for client components
- Remove unused data/waitlist.json

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 11:01:43 +01:00
g-butandClaude Sonnet 4.5 9aa417e273 refactor: clean up API routes and components, add shared utilities
Refactored multiple API routes and components to improve code organization and reduce duplication:
- Simplified API route implementations across chat, documents, consultations, and other endpoints
- Reorganized navigation components for better maintainability
- Added shared utility functions and hooks
- Created reusable Avatar and Logo components
- Added validation schemas and API utilities
- Improved type definitions and constants management

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-16 11:04:19 +01:00
g-butandClaude Opus 4.5 403c9bf5a7 Add Phase 3: Document upload and RAG chat
- Add Transformers.js for local embeddings generation
- Create document upload API with Supabase Storage
- Create document processing pipeline (parse, chunk, embed)
- Create semantic search API using pgvector
- Create RAG chat API combining search + LLM
- Add documents page UI with upload, process, and chat
- Add database migration for document status columns
- Configure Next.js to externalize ONNX packages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 12:39:43 +01:00
g-butandClaude Opus 4.5 53fd048b97 feat: implement knowledge center foundation with guides and infrastructure pages
- Add types/knowledge.ts with type definitions for guides, difficulty levels, and comparisons
- Add lib/knowledge.ts for GitHub-based content fetching with ISR caching
- Create knowledge components: DifficultyBadge, GuideCard, Callout, CodeBlock, TableOfContents
- Add /knowledge/guides page with difficulty and category filters
- Add /knowledge/guides/[slug] dynamic page for individual guide rendering with MDX
- Add /knowledge/infrastructure page with hosting comparison overview
- Update navigation menu with new Knowledge Center links

Content will be fetched from g-but/botsmann-knowledge-content GitHub repo.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 01:49:29 +01:00
g-butandClaude Opus 4.5 43260cfef2 refactor: rebuild navigation as modular megamenu system
Architecture following DRY, SSOT, SoC principles:

Types (types/navigation.ts):
- MegaMenuHeader, MegaMenuFooter, MegaMenuConfig for dropdown config
- MenuChildItem, MenuItem with proper typing
- NavItemProps, MobileNavProps for component contracts

Components (components/navigation/):
- NavItem: Unified handler for links, dropdowns, CTA buttons
- MegaMenuPanel: Configurable panel with header/footer support
- MegaMenuItem: Individual dropdown item with icon/description
- MobileNav: Extracted mobile drawer (SoC)

Data (data/menuItems.ts):
- SSOT for all navigation with megaMenu config per section
- Helper functions: getNavItems(), getButtonItems()

Features:
- Portal pattern for proper dropdown overlay
- Configurable columns (1-3), headers, footers per section
- Consistent styling with Tailwind

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 00:44:27 +01:00
g-butandClaude Opus 4.5 1f9a6a4973 refactor: add governance shared components and utilities
- Create types/governance.ts with centralized type definitions
  (TaxPayment, CitizenData, AgencyData, etc.)
- Add lib/governance/utils.ts with shared utility functions
  (formatCurrency, getTransparencyScoreClasses, getStatusBadgeClasses)
- Create reusable governance components:
  - ProfileHeader: shared header component for profile pages
  - ProfileTabs: reusable tab navigation component
  - InfoBox: configurable info/warning/success/error boxes

These shared components and utilities support breaking down large
governance components (CitizenProfile.tsx 650 lines, AgencyProfile.tsx
437 lines) into smaller, more maintainable pieces while following
DRY principles.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:48:11 +01:00
g-butandClaude Opus 4.5 a192ca24a0 refactor: centralize bot page configuration and add shared components
- Add BotSection and BotNotFoundFallback shared components
- Centralize menuItems and navigation config in data/bots.ts
- Add getBotBySlug and getBotTryLink helper functions
- Add BotMenuItem, BotAccentColor, and BotNavConfig types
- Refactor all 6 bot pages to use centralized configuration
- Remove ~180 lines of duplicated code across bot pages
- Improve consistency in error handling and section spacing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:24:47 +01:00
g-butandClaude Opus 4.5 2e39380356 feat: add strict ESLint config and fix all lint issues
- Add .eslintrc.json with strict TypeScript and React rules
- Fix all unused imports and variables (prefix with _ or remove)
- Replace all `any` types with `unknown` or specific types
- Fix React hooks rule violations (conditional hooks, deps)
- Change console.log to console.info per project standards
- Add eslint-disable comments for legitimate img element uses
- Fix anonymous default exports
- Update package.json with ESLint 8 and proper lint scripts

Lint: 0 warnings, 0 errors
Build: passes successfully

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 16:47:56 +01:00
Your Name 8a55e4fb9e feat: Complete deployment automation and modern design overhaul
- Fix header layout to prevent movement when megamenu opens
- Redesign homepage with modern, futuristic aesthetic
- Implement automated deployment with GitHub Actions
- Optimize build process for production deployment
- Add deployment monitoring and verification scripts
- Update README with comprehensive deployment documentation

Breaking changes:
- Header now uses fixed positioning with backdrop blur
- Homepage features gradient backgrounds and glassmorphism effects
- Automated CI/CD pipeline with comprehensive testing and monitoring
2025-10-02 23:46:03 +02:00
G f8a5e8bc2d refactor navigation with mega menu 2025-06-13 16:23:39 +02:00
cato 542eb45ec7 Fix type errors to enable successful build 2025-03-03 11:13:35 +01:00
cato 626e96a233 Update files and remove unnecessary components 2025-03-03 01:02:26 +01:00
Devin AIandcato 353674f332 chore: add MongoDB dependencies and types
Co-Authored-By: G <butaeff@gmail.com>
2025-02-09 20:35:05 +00:00
Devin AIandcato 247a0f50a5 feat: implement auto-shopper with rate limiting
Co-Authored-By: G <butaeff@gmail.com>
2025-02-08 17:21:55 +00:00