Commit Graph

190 Commits

Author SHA1 Message Date
colinislit
cdeea793bd feat(cortex): update chat/nudge flow, deepgram streaming and agenda form
Refines chat panel, nudge messages and artifact rendering, reworks
deepgram token/streaming handling, and adds test tooling deps
(playwright, cypress) to package.json.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-09 22:37:46 +02:00
colinislit
6c6dae5eb7 feat(cortex): enhance intake workflow with new navigation and status features
- Introduced new navigation handler for intake_navigeer intent, allowing users to navigate to specific patient intake pages.
- Added intake status display to show completion percentage and section checklist.
- Updated action-parser schema to include new intake intents and improved routing for better user experience.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 12:26:33 +01:00
colinislit
af88ac9446 docs: add architecture and intake intent documentation
- Add architecture overview, implementation plan, and intent overview
- Add intake intent process specs (gap analyse, bouwplan, testplan)
- Add swift architecture specs and visualization prompts
- Remove obsolete aispeedrun-manifesto template

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 19:26:14 +01:00
colinislit
91b61d215b feat(cortex): add intake suggestions to chat UI
Add intake-related suggestions to both chat interfaces:

1. Cortex Command Center (lib/cortex/suggestions.ts):
   - New "Intake" category with status, risico, diagnose examples
   - Triggers intake_status, risico_query, diagnose_query, intake_navigeer

2. Docs Chat Widget (components/docs-chat/chat-suggestions.tsx):
   - Updated CLIENT_SUGGESTION_CATEGORIES with intake options
   - Categories: Intake Status, Risicotaxatie, Diagnoses, Navigatie

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:14:53 +01:00
colinislit
601ad8c3f0 fix(cortex): integrate intake intents into full chat + artifact flow
Fixes 4 bugs preventing intake blocks from working:

1. Chat API validation: Add 'nudge' to message type enum, allow empty
   content for streaming messages
2. AI chat recognition: Add P3 intake intents (intake_status,
   risico_query, diagnose_query, intake_navigeer) to system prompt
   with triggers, entities, and JSON examples
3. Artifact rendering: Add intake block imports and switch cases
   to artifact-container.tsx
4. API 400 error: Convert null to undefined for optional Zod params
   (searchParams.get returns null, Zod .optional() expects undefined)

Also adds:
- Testplan for E2E testing (60+ test cases)
- Session log with lessons learned and new intent checklist

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:07:10 +01:00
colinislit
a41a500fe3 feat(cortex): add intake_navigeer navigation handler (E5.S2)
- Add intake intents to action-parser schema and routing
- Add navigation handler in command-center for intake_navigeer intent
- Navigate to patient intakes page with toast feedback
- Update bouwplan: E5 now complete (6/7 epics done)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:30:15 +01:00
colinislit
b095b1e492 feat(cortex): add Intake Blocks MVP for voice/text commands
Adds 4 new intents for intake workflow:
- intake_status: shows completion percentage and section checklist
- intake_navigeer: navigation to specific intake tabs
- risico_query: displays risk assessments with severity indicators
- diagnose_query: shows primary/secondary diagnoses

New components:
- IntakeStatusBlock, RisicoBlock, DiagnoseBlock
- Shared block components (BlockLoading, BlockError, BlockEmpty, BlockSection, BlockItem, BlockFooter)
- useBlockData and useIntakeContext hooks

New API routes:
- GET /api/cortex/intake/status
- GET /api/cortex/intake/risico
- GET /api/cortex/intake/diagnose

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:21:18 +01:00
colinislit
05836c5c6a feat(cortex): implement activePatient fallback in various components
- Updated DagnotatieBlock to use activePatient for prefill if no patientId is provided.
- Enhanced PatientDashboardBlock to fallback to activePatient for patientId and name.
- Adjusted usePatientSelection to handle pending actions and re-route after patient selection.
- Refined chat components to manage nudge messages and integrate them into the chat flow.
- Improved UI elements for better patient selection experience.

This update enhances user experience by ensuring that the active patient context is utilized across multiple components, streamlining workflows and reducing manual input.
2026-01-03 22:18:30 +01:00
colinislit
7040241f7d docs(cortex): herstructureer documentatie in 6 aparte secties
Vervangt de enkele "Cortex Command Center" pagina door 6 gerichte documenten:
- Overzicht: introductie, basis gebruik, context bar
- Intent Systeem: Reflex Arc, Orchestrator, intent types
- Blocks: Dagnotitie, Zoeken, Overdracht, Patient Dashboard
- @Mention Systeem: mentions, sidebar, context-aware selectie
- Keyboard Shortcuts: alle sneltoetsen per context
- Proactieve Suggesties: Nudge systeem en protocollen

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 21:40:56 +01:00
colinislit
6cc813aa58 chore: remove dead code command-input.tsx (376 lines)
Component was exported but never imported/used anywhere.
v3.0 architecture uses chat-input.tsx instead.

Voice features (useCortexVoice hook) remain available for future use.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 12:46:20 +01:00
colinislit
e77a63f25e feat(cortex): droge humor persoonlijkheid voor Cortex Assistent
System prompt aangepast voor nuchtere, understated tone of voice:
- Kernkwaliteit "Nuchter" toegevoegd
- Tone of voice: droog en behulpzaam ipv vriendelijk
- Stijlvoorbeelden sectie met concrete frases
- 6 voorbeeldresponses aangepast naar kortere, drogere stijl
- Error messages menselijker ("Hmm, snap niet helemaal...")

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 12:30:58 +01:00
colinislit
54e54d6d7e fix(cortex): add @mention detection to ChatInput (not just CommandInput)
The @mention dropdown was only in command-input.tsx but users type in
chat-input.tsx (the v3.0 chat textarea). Added @mention support there:

- @mention state and detection logic
- PatientMentionDropdown rendering
- handleMentionSelect with activePatient setting
- Escape key closes dropdown before clearing input

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 12:27:48 +01:00
colinislit
2cce338aa8 docs: update bouwplan v1.4 - Epic 2 status en totalen
- Epic 2 stories: 5→3 (YAGNI versimpeling)
- Story Points: 23→19 SP
- Voortgang: 14/19 SP (74%)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 12:23:22 +01:00
colinislit
73894ac879 feat(cortex): Epic 2 - @Mention Systeem (E2.S1-S3)
Inline patient selectie via @naam in de chat input.

YAGNI Versimpeling: 8→4 SP, 5→3 stories
- Geen selectedMentions array (activePatient is al beschikbaar)
- Geen API payload wijziging nodig
- Geen meerdere mentions tracking

E2.S1 - @-detectie:
- Detecteer laatste @ in input
- Track query en startIndex
- Actief als geen space na @ en minimaal 1 char

E2.S2 - PatientMentionDropdown:
- Hergebruik usePatientSearch (debounce 150ms, limit 5)
- Hergebruik PatientListItem (size="sm")
- Positioned above input (bottom-full)
- Escape sluit dropdown

E2.S3 - Selectie flow:
- Vervang @query met @naam in input
- Zet activePatient via usePatientSelection
- Sluit dropdown automatisch

Bouwplan v1.4: Epic 2 compleet (14/19 SP - 74%)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 12:11:14 +01:00
colinislit
9b0352de44 feat(cortex): Epic 1 - Patient Sidebar (E1.S1-S4)
Collapsible overlay sidebar voor snelle patient selectie met search en recent patients.

E1.S1 - Store uitbreiding:
- recentPatients: Patient[] (max 5, nieuwste eerst, geen duplicaten)
- patientSidebarOpen: boolean
- addRecentPatient, togglePatientSidebar, setPatientSidebarOpen actions

E1.S2 - PatientSidebar component:
- Overlay sidebar (w-80, z-50) met backdrop
- Search input met debounce (200ms)
- Recent patients sectie
- Hergebruik usePatientSearch, usePatientSelection hooks
- Hergebruik PatientListItem component

E1.S3 - Toggle button + shortcut:
- Users icon button in ContextBar
- Cmd/Ctrl+P keyboard shortcut
- Escape sluit sidebar (prioriteit boven artifacts)

E1.S4 - Click-to-select flow:
- Selectie zet activePatient
- Voegt toe aan recentPatients
- Sluit sidebar automatisch

Bouwplan v1.3: Epic 1 compleet (10/23 SP - 43%)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 11:52:13 +01:00
colinislit
43d4d095ce fix: case-insensitive voornaam zoeken door capitalize toe te passen
Voornaam zoeken werkte niet omdat name_given array case-sensitive is.
Capitalize nu de zoekterm (eerste letter hoofdletter) voordat deze
wordt gebruikt in de array search, zodat 'jan' matcht met 'Jan'.

Aangepast in beide search endpoints:
- /api/patients/search
- /api/cortex/patients/search
2026-01-03 11:47:12 +01:00
colinislit
4b45853868 chore(docs): remove duplicate swift docs (moved to docs/archive/swift)
Remove 39 swift documentation files that were duplicated.
Original files are preserved in docs/archive/swift/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 11:41:26 +01:00
colinislit
983807d833 refactor(cortex): Epic 0 - Extract patient search hooks & components (E0.S1-S4)
DRY refactor: Extract reusable patient search logic from ZoekenBlock.

New files:
- lib/cortex/hooks/use-patient-search.ts (116 lines)
  Debounced patient search with abort controller
- lib/cortex/hooks/use-patient-selection.ts (98 lines)
  FHIR fetch + store update flow
- lib/fhir/patient-mapper.ts (109 lines)
  FHIR Patient to DB Patient mapping + utilities
- components/cortex/shared/patient-list-item.tsx (114 lines)
  Reusable patient list item with loading states

Refactored:
- ZoekenBlock: 349 -> 127 lines (-64%)

Documentation:
- docs/intent/patient-search/ux-analyse-patient-selectie.md
- docs/intent/patient-search/bouwplan-patient-selectie-v1.md

CLAUDE.md updated with Cortex architecture documentation.

Epic 0 complete: 4/4 stories (4 SP)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 11:40:23 +01:00
colinislit
7b9de4ada2 feat(ui): mobile responsiveness audit + type fixes
Mobile Responsiveness:
- Viewport meta tags toegevoegd in layout.tsx
- EPD header: patient details verborgen op mobiel, zoekbalk responsive
- Agenda: auto-switch naar dagview op mobiel, mini-kalender verborgen
- Agenda toolbar: verticale stacking, Week/Werkweek knoppen verborgen
- Patiëntenlijst: compact icoon-only button op mobiel
- Verpleegrapportage: verticale flow i.p.v. twee-koloms layout
- Cortex: artifact overlay met slide-in animatie op mobiel
- Cortex: "Terug" knop toegevoegd aan artifact panels
- Toast feedback bij succesvolle afspraak creatie

Code Quality Fixes (KISS/DRY):
- Resize listener vervangen door bestaande useMediaQuery hook
- Dubbele flex class opgeschoond in epd-header.tsx
- userScalable: false verwijderd (accessibility)

Type Fixes:
- actions.ts: status literal type met 'as const'
- agenda-block.tsx: dateRange start/end optioneel
- chat-empty-state.tsx: framer-motion ease type
- cortex-store.ts: ChatEntities.dateRange consistent met Zod schema

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 10:28:04 +01:00
colinislit
52e07aaf80 fix(cortex): update date handling in API and UI components
- Adjusted date handling in the agenda API to ensure optional parameters for start, end, and label are correctly processed.
- Enhanced chat input and action parser to support optional date labels for relative dates.
- Updated agenda components to handle date ranges and loading states more effectively.
- Improved error handling and loading indicators in the agenda block for better user experience.

This commit ensures consistency in date handling across the application, aligning with the new requirements for relative date inputs.
2026-01-02 09:21:37 +01:00
colinislit
011815072b refactor(cortex): consistente datumbepaling met referenceDate parameter
SOC: Parser en entity-extractor accepteren nu optionele referenceDate
parameter. Caller bepaalt wat "nu" is, niet de functies intern.

Wijzigingen:
- parseRelativeDate(input, referenceDate?) - referenceDate parameter
- extractEntities(input, intent, referenceDate?) - doorgeeft aan parser
- API routes gebruiken new Date() als referenceDate

Verwijderd (YAGNI):
- lib/utils/server-date.ts - wrapper om new Date() was overbodig

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-02 08:49:20 +01:00
colinislit
6add89dc51 feat(cortex): Epic 5 - Integration & Polish complete (MVP DONE)
Epic 5 completes the Cortex V2 MVP with end-to-end integration:

E5.S1 - Feature Flag Guards
- ActionChainCard wrapped with CORTEX_MULTI_INTENT flag
- ClarificationCard wrapped with CORTEX_V2_ENABLED flag
- NudgeToast wrapped with CORTEX_NUDGE flag
- V1 UI remains functional when flags disabled

E5.S2 - Chain Execution Flow
- handleConfirmAction routes actions to artifacts via routeIntentToArtifact()
- Nudge evaluation triggered after successful action completion
- Sequential chain execution with auto-advance useEffect
- Chain auto-completes when all actions done

E5.S3 - Integration Tests (21 tests)
- Scenario 1: Simple input → Reflex handles (4 tests)
- Scenario 2: Multi-intent → Orchestrator handles (4 tests)
- Scenario 3: Context-dependent → Pronoun resolution (4 tests)
- Scenario 4: Wondzorg → Nudge suggestion (4 tests)
- Scenario 5: Graceful fallback (3 tests)
- Scenario 6: Chain building (2 tests)

E5.S4 - Demo Script
- 5-minute demo flow with exact phrases
- 5 scenes: Reflex speed, Multi-intent, Pronoun, Nudge, Clarification
- Backup scenarios documented
- Test phrases reference included

Files changed:
- components/cortex/chat/chat-panel.tsx (feature flags + execution)
- components/cortex/command-center/command-center.tsx (NudgeToast flag)
- lib/cortex/__tests__/cortex-v2.test.ts (NEW - 21 integration tests)
- docs/intent/demo-script-cortex-v2.md (NEW - demo documentation)
- docs/intent/bouwplan-cortex-v2.md (v1.5 - MVP complete)

MVP Status: 26/26 stories, 48/48 SP - 100% COMPLETE

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 13:16:20 +01:00
colinislit
4b759c9b3d feat(cortex): Epic 4 - Nudge MVP (Layer 3) complete
Proactive suggestions after successful actions - proof of concept.

E4.S1 - Protocol Rules (lib/cortex/nudge.ts)
- ProtocolRule and ProtocolCondition types
- Condition operators: equals, contains, matches, exists
- 2 hardcoded rules: wondzorg-controle, medicatie-controle

E4.S2 - evaluateNudge Function
- evaluateNudge(input) returns NudgeSuggestion[]
- checkCondition() helper for rule matching
- Priority sorting (high → medium → low)

E4.S3 - NudgeToast Component
- Countdown progress bar with auto-dismiss (5 min)
- Priority-based styling (low/medium/high)
- Accept and dismiss buttons
- Framer Motion animations

E4.S4 - Integration
- NudgeToast rendered in CommandCenter (fixed position)
- Trigger added in DagnotatieBlock after successful save
- Accept opens corresponding artifact with prefilled data

Demo flow:
1. Create dagnotitie with "wond" in content
2. Save → NudgeToast appears
3. Click "Ja, inplannen" → Appointment artifact opens

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 12:42:49 +01:00
colinislit
42d64761ec feat(cortex): Epic 3 - UI Components complete
Epic 3 delivers the visual layer for multi-intent flows and clarification:

E3.S1 - ActionChainCard (3 SP)
- Container for multi-intent chain display
- Header with AI/Local source badge and action count
- Original user input context
- Stacked ActionItems with Framer Motion animations
- Collapsible AI reasoning section
- Status-dependent styling (pending/executing/completed/partial/failed)

E3.S2 - ActionItem (2 SP)
- 6 status icons (pending, confirming, executing, success, failed, skipped)
- Dutch intent labels via shared intent-labels.ts
- Confidence badge with color coding (green ≥90%, amber ≥70%, red <70%)
- Entity summary formatting
- Confirmation buttons for confirming status
- Retry button for failed + recoverable actions

E3.S3 - ClarificationCard (2 SP)
- Amber-themed styling for question context
- Header with HelpCircle icon
- Original user input display
- Responsive options grid (2 cols desktop, 1 col mobile)
- Dismiss button and cancel link
- Framer Motion entry/exit animations

E3.S4 - ProcessingIndicator (1 SP)
- 3 variants: spinner, skeleton, pulse
- 3 sizes: sm, md, lg
- Configurable message
- InlineSpinner export for buttons

Integration in ChatPanel (v4.0):
- V2 store hooks for activeChain, pendingClarification
- Event handlers for confirm/skip/retry/dismiss
- Conditional rendering with AnimatePresence

New files:
- lib/cortex/intent-labels.ts
- components/cortex/chat/action-chain-card.tsx
- components/cortex/chat/action-item.tsx
- components/cortex/chat/clarification-card.tsx
- components/cortex/chat/processing-indicator.tsx

Modified:
- components/cortex/chat/chat-panel.tsx (v3.0 → v4.0)
- docs/intent/bouwplan-cortex-v2.md (v1.2 → v1.3)

Progress: 35/48 SP (73%) - E0, E1, E2, E3 complete

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 12:02:15 +01:00
colinislit
b36df63d03 feat(cortex): Epic 2 - Intent Orchestrator (Layer 2) complete
Implements AI-powered multi-intent classification for Cortex V2.
When Reflex Arc (Layer 1) detects complexity, it escalates to
the Orchestrator for intelligent classification using Claude 3.5 Haiku.

E2.S1 - System prompt for Orchestrator
- ORCHESTRATOR_SYSTEM_PROMPT constant with Dutch instructions
- Multi-intent detection (en, daarna, ook, eerst, vervolgens)
- Pronoun resolution rules (hij/zij → active patient)
- JSON-only output format specification

E2.S2 - Context formatting for AI
- formatContextForPrompt() with emoji structure
- Dutch labels for shifts and views
- Graceful null handling, token limiting (max 5 agenda, 3 recent)

E2.S3 - AI classification endpoint
- classifyWithOrchestrator() calling Claude 3.5 Haiku
- Builds IntentChain from AI response
- Tracks tokens used and processing time

E2.S4 - IntentChain parsing with Zod
- parseAIResponse() with Zod schema validation
- Strips markdown code blocks
- Partial extraction for malformed responses
- Graceful fallback to intent: 'unknown'

E2.S5 - POST /api/cortex/classify hybrid endpoint
- Reflex first, escalate to Orchestrator if needed
- Response includes handledBy: 'reflex' | 'orchestrator'
- Auth check, feature flag check, request validation

E2.S6 - Graceful fallback
- buildFallbackChain() with confidence cap (0.6)
- buildChainFromReflex() for simple chains
- classifyWithTimeout() wrapper (5s default)

New files:
- lib/cortex/orchestrator.ts (~780 lines)
- app/api/cortex/classify/route.ts (~180 lines)

Key deliverable: "Zeg Jan af en maak notitie" correctly
parsed into 2 actions in an IntentChain.

Progress: 27 SP / 48 SP (56%) - E0, E1, E2 complete

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 11:28:14 +01:00
colinislit
7df92dd2fb feat(blog): enhance blog functionality and SEO
- Added a new '/blog' route to middleware for improved navigation.
- Updated sitemap to dynamically include blog posts and series URLs.
- Enhanced blog page metadata with Open Graph and Twitter card information.
- Implemented structured data for blog posts and series to improve SEO.
- Removed outdated blog post "Week 1: De Kickoff" from content.
- Introduced optional OG image field in blog frontmatter for better sharing visuals.
2026-01-01 10:56:34 +01:00
colinislit
e7294e712f feat(navigation): add Blog link to Dutch navigation
- Introduced a new link for "Blog" in the navigation JSON file, enhancing user access to blog content.
2026-01-01 09:39:30 +01:00
colinislit
c1dc92035b feat(cortex): Epic 1 - Reflex Arc (Layer 1) classifier
Implement fast local intent classification with escalation-aware logic.
Target: <20ms processing time for simple commands.

E1.S1 - Pattern Matching
- New reflex-classifier.ts with 7 intent types
- Top-2 match tracking for ambiguity detection
- Confidence thresholds (0.7) and ambiguity threshold (0.1)

E1.S2 - Escalation Triggers
- Multi-intent detection: "en", "daarna", "eerst", "vervolgens"
- Context-dependent pronouns: "hij", "zij", "hem", "haar", "zijn"
- Relative time expressions: "morgen", "overmorgen", "volgende week"

E1.S3 - Ambiguity Detection
- Top-2 score comparison (delta < 0.1 → escalate)
- secondBestIntent and secondBestConfidence tracking
- Low confidence escalation (< 0.7)

E1.S4 - Unit Tests
- 25 tests covering all scenarios
- Performance test: 100 classifications in <1ms
- Test runner: pnpm tsx (no Jest/Vitest setup required)

New files:
- lib/cortex/reflex-classifier.ts
- lib/cortex/__tests__/reflex-classifier.test.ts

Run tests: pnpm tsx lib/cortex/__tests__/reflex-classifier.test.ts

Progress: 14 SP / 48 SP (29%) - E0 + E1 complete

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 16:24:33 +01:00
colinislit
ccdc425d78 docs(cortex): update Epic 0 status to Done in bouwplan
- Epic 0 status:  To Do →  Done
- All 5 stories (E0.S1-S5) marked as complete
- All done criteria checkboxes marked as checked

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 12:51:42 +01:00
colinislit
0215d7bb92 feat(cortex): update confidence thresholds and API endpoints for Cortex V2
- Adjusted confidence threshold for executing simple commands from >0.9 to >=0.7 in architecture documentation and code.
- Updated API endpoint paths from `/api/intent/*` to `/api/cortex/*` for intent classification and execution.
- Modified related tests to reflect the new confidence threshold and endpoint changes.

This update enhances the system's responsiveness to user commands while maintaining clarity in API structure.
2025-12-31 12:49:24 +01:00
colinislit
cf26022583 feat(cortex): Epic 0 - Foundation & Context voor V2 architectuur
Implementeert de basis voor de Cortex V2 three-layer architecture.

E0.S1 - CortexContext Types (lib/cortex/types.ts):
- EscalationReason type voor Reflex → Orchestrator
- LocalClassificationResult met ambiguity detection
- CortexContext voor AI classificatie context
- IntentChain en IntentAction voor multi-intent flows
- NudgeSuggestion voor proactieve suggesties
- CONFIDENCE_THRESHOLD (0.7) en AMBIGUITY_THRESHOLD (0.1)
- getCurrentShift() utility (DRY - herbruikbaar)

E0.S2 - Context API (app/api/cortex/context/route.ts):
- GET endpoint voor huidige context
- Haalt agenda vandaag op uit database
- Retourneert CortexContext object

E0.S3 - Feature Flags (lib/config/feature-flags.ts):
- CORTEX_V2_ENABLED, CORTEX_MULTI_INTENT
- CORTEX_NUDGE, CORTEX_LOGGING
- isFeatureEnabled() helper
- Dev mode: default true

E0.S4 - CortexStore V2 (stores/cortex-store.ts):
- Types geïmporteerd uit lib/cortex (DRY)
- ChatEntities type voor AI responses (string-based)
- V2 state: context, activeChain, chainHistory, suggestions
- V2 actions: chain management, nudge management, clarification

E0.S5 - Classification Logging (lib/cortex/logger.ts):
- PII sanitization (BSN, tel, namen, email)
- logClassification(), logEscalation(), logNudge()
- logPerformance() met threshold checks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 12:46:35 +01:00
colinislit
06287d49f4 refactor(login): update interface preference from 'swift' to 'cortex'
- Changed default interface preference in LoginForm component from 'klassiek' to 'cortex'.
- Updated redirect path logic to reflect the new 'cortex' preference.
- Modified button label and state management to align with the new interface preference terminology.
- Adjusted type definition for InterfacePreference to include 'cortex' instead of 'swift'.
2025-12-31 10:08:22 +01:00
colinislit
26ed58b7ff docs(cortex): add PRD, TO and rename swift → cortex
New documents:
- prd-cortex-v2.md: Product Requirements Document with MVP scope,
  user flows, success criteria, and roadmap
- to-cortex-v2.md: Technical Design with three-layer architecture,
  API design, error handling, and logging

Renamed files (swift → cortex):
- architecture-swift-cortex-v2.md → architecture-cortex-v2.md
- fo-swift-intent-system-v2.md → fo-cortex-intent-system-v2.md
- haalbaarheidsanalyse-swift-cortex-v2.md → haalbaarheidsanalyse-cortex-v2.md
- review-swift-cortex-v2.md → review-cortex-v2.md

Updated content:
- All swift references replaced with cortex
- FO: confidence threshold 0.9 → 0.7 (industry standard)
- TO v1.1: Added error handling, input sanitization, improved
  suïcidaliteit regex, model version note
- Legacy docs: Added note about swift → cortex rename

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 10:22:22 +01:00
colinislit
2170b23348 refactor: rename swift → cortex in code and documentation
Complete rename of "swift" terminology to "cortex" across the codebase:

Code Changes:
- Rename directories: lib/swift → lib/cortex, components/swift → components/cortex
- Rename API routes: /api/swift/* → /api/cortex/*
- Rename page routes: /epd/swift → /epd/cortex
- Rename store: swift-store.ts → cortex-store.ts

Type Renames:
- SwiftIntent → CortexIntent
- SwiftStore → CortexStore
- useSwiftStore → useCortexStore
- SwiftContext → CortexContext
- useSwiftVoice → useCortexVoice

Documentation Updates (docs/intent/):
- Safety Net → Nudge (Layer 3 rename)
- SafetySuggestion → NudgeSuggestion
- evaluateSafetyNet → evaluateNudge
- SWIFT_* feature flags → CORTEX_*
- All path references updated to match new structure

Files affected: 47 files, ~700 lines changed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 09:18:06 +01:00
colinislit
c8aaba657e refactor(swift): update references from Medical Scribe to Swift Assistent
- Updated comments and documentation to reflect the new branding of the chat API and related components.
- Renamed functions and variables to align with the Swift Assistent terminology.
- Enhanced UI components with animations using Framer Motion for a smoother user experience.
- Removed outdated architecture documentation related to the Medical Scribe system.

This change is part of the transition to the Swift Assistent branding, ensuring consistency across the application.
2025-12-29 22:40:34 +01:00
colinislit
94aab93f1c feat: wire agenda artifacts 2025-12-28 14:54:32 +01:00
colinislit
14a9d34337 feat(swift): voeg chat orchestration toe (E5)
Epic 5 compleet: Chat orchestration voor Swift Agenda Planning.
Alle agenda intents worden nu correct gerouteerd naar AgendaBlock
met user-friendly error handling en fallback opties.

E5.S1 - Action Routing (2 SP)
- routeIntentToArtifact() functie in action-parser
- Maps agenda intents naar juiste AgendaBlock mode
- Confidence threshold enforcement (< 0.7 → fallback)
- Required entity validation (patient voor create, identifier voor reschedule)
- Command-input gebruikt nieuwe routing ipv legacy openBlock
- Migratie naar modern artifact systeem (openArtifact)

E5.S2 - Chat Prompt Update (2 SP)
- 4 agenda intents toegevoegd aan Swift chat system prompt
- agenda_query: afspraken opvragen op datumrange
- create_appointment: nieuwe afspraak maken (required: patient, datetime)
- cancel_appointment: afspraak annuleren (disambiguation support)
- reschedule_appointment: afspraak verzetten (required: identifier)
- Entity extraction rules gedocumenteerd (dateRange, datetime, identifier)
- 4 complete voorbeelden met JSON action format
- Clarification questions voor incomplete data
- Prompt size: ~325 → ~525 regels (+60%)

E5.S3 - Error States (2 SP)
- AgendaErrorState component voor full-page errors
- AgendaErrorAlert component voor inline form errors
- getUserFriendlyMessage() vertaalt technical → user-friendly Dutch
- Auto-redirect bij auth errors (401 → /login)
- Fallback link naar /epd/agenda in alle error states
- Context-aware messaging (query/create/cancel/reschedule)
- Retry functionaliteit voor recoverable errors
- Dev-only technical details collapsible

Error message mapping:
- 401 → "Je sessie is verlopen. Log opnieuw in." + auto-redirect
- 403 → "Je hebt geen toegang tot deze afspraak."
- 404 → "De gevraagde afspraak kon niet worden gevonden."
- 500 → "Er ging iets mis op de server. Probeer het opnieuw."
- Network → "Geen internetverbinding. Controleer je netwerkverbinding."
- Timeout → "De aanvraag duurde te lang. Probeer het opnieuw."

Components updated:
- command-input: gebruikt routeIntentToArtifact + openArtifact
- agenda-create-form: gebruikt AgendaErrorAlert met fallback link
- chat/route: uitgebreide system prompt met agenda sectie

Nieuwe files:
- lib/swift/action-parser.ts: routeIntentToArtifact() functie
- components/swift/artifacts/blocks/agenda-error-state.tsx (225 regels)
- docs/swift/implementation-e5-s1-action-routing.md
- docs/swift/implementation-e5-s2-chat-prompt.md
- docs/swift/implementation-e5-s3-error-states.md

Documentatie:
- Bouwplan bijgewerkt: Epic 5 → Done
- 3 implementation docs met API specs en testing scenarios
- Error handling best practices gedocumenteerd

Progress: 48 SP / 51 SP (94%) - Epic 6 (QA) remaining

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 22:44:18 +01:00
colinislit
a6b63665e1 feat(swift): implement agenda planning module (Epic 4 UI)
- Add AgendaBlock core component with list, create, cancel, reschedule modes
- Implement AgendaListView with patient/type/location details and actions
- Implement AgendaCreateForm with fuzzy patient search and validation
- Implement AgendaCancelView with disambiguation support
- Implement AgendaRescheduleForm with date/time picker
- Integrate with server actions (create, cancel, reschedule)
- Add radio-group UI component
- Update documentation and status
2025-12-27 22:29:11 +01:00
colinislit
0031bd5fd1 feat(swift): voeg date/time parsing toe (E2)
Epic 2 compleet: NLP-helpers voor datum en tijd interpretatie.

Implementatie:
- parseRelativeDate(): ondersteunt "vandaag", "morgen", "deze week",
  weekdagen (maandag-zondag), en absolute datums (30 december, 28-12-2024)
- parseTime(): ondersteunt "14:00", "14", "half drie", "kwart voor drie",
  en natuurlijke taal tijdsaanduidingen
- combineDatetime(): combineert datum + tijd naar ISO string
- isNotInPast(): validatie voor toekomstige datums
- isDateRange(): type guard voor datum ranges

Integratie:
- Entity extractor gebruikt date/time parser voor agenda intents
- Normaliseert ruwe strings ("morgen", "14:00") naar Date objecten
- Ondersteunt Nederlandse tijdsaanduidingen

Tests & validatie:
- Unit tests voor alle parser functies
- Verify script voor handmatige testing
- Review document met bevindingen en suggesties

Story points: 7 SP (E2.S1: 3, E2.S2: 2, E2.S3: 2)
2025-12-27 22:14:22 +01:00
colinislit
d2ffccc22b feat(swift): voeg agenda backend API's toe (E3)
Epic 3 compleet: Backend integratie voor Swift Agenda Planning.

Nieuwe endpoints:
- GET /api/swift/agenda - Query afspraken op datumrange
- POST /api/swift/agenda/create - Nieuwe afspraak aanmaken
- POST /api/swift/agenda/cancel - Afspraak annuleren
- POST /api/swift/agenda/reschedule - Afspraak verzetten
- GET /api/swift/patients/search - Fuzzy patiënt zoeken

Alle endpoints bevatten:
- Supabase authenticatie + resource ownership checks
- Zod validatie met Nederlandse foutmeldingen
- Hergebruik van bestaande agenda server actions

Test documentatie: docs/swift/test-plan-epic3-backend.md

Progress: 3/7 Epics compleet (E0, E1, E2, E3)
Story points: 11 SP (E3.S1: 3, E3.S2: 3, E3.S3: 3, E3.S4: 2)
2025-12-27 22:12:01 +01:00
colinislit
6460b4361f feat: add agenda intent scaffolding 2025-12-27 21:46:24 +01:00
colinislit
5b27a3b538 docs: complete agenda planning epic 0 2025-12-27 21:13:27 +01:00
colinislit
da76336d83 docs: add swift agenda planning build plan 2025-12-27 21:08:25 +01:00
colinislit
43467f07fa feat: show patient dashboard artifact on selection 2025-12-27 20:50:39 +01:00
colinislit
eed3c8c80c fix: point swift backlink to epd clients 2025-12-27 20:02:41 +01:00
colinislit
812c41a042 feat: split swift into standalone module 2025-12-27 19:56:24 +01:00
colinislit
0f7c8f00be docs(swift): Epic 5 status update - voortgang 87%
Bouwplan v3 bijgewerkt met correcte status na Epic 5 completion:

Status Updates:
- Epic 3 header: IN PROGRESS → COMPLEET 
- Epic 5 header: toegevoegd COMPLEET status 

Voortgang Correcties:
- Stories: 24/31 compleet, 3 geskipt = 27 done (was: 26/31)
- Story Points: 71 SP / 82 SP = 87% (ongewijzigd, correct)
- Geannuleerde SP: 1+3+3 = 7 SP (was: 3 SP)

Epic 5 Samenvatting Toegevoegd:
- Status: 5/5 stories compleet (13 SP)
- Features: AI-filtering psychiater, linked evidence UI, voice input, error handling, polish
- Git commits: c6616d8, adf6c3f, 1bab375, 1ecc8f9, 60afb17
- Files: overdracht.ts, overdracht-prompt.ts, overdracht-block.tsx, linked-evidence.tsx, error-handler.ts, offline-banner.tsx

Huidige Status:
 Epics 0-5 compleet (27 stories done, 71 SP)
 Epic 6 te doen (4 stories, 8 SP)

Voortgang: 87% - Ready voor Epic 6 (Testing & Refinement)!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 19:19:15 +01:00
colinislit
60afb175c5 docs(swift): Epic 5 COMPLEET! 🎉 E5.S5 polish & animations (87% total)
Bouwplan progress update: 71 SP / 82 SP (87%)

🎉 **EPIC 5 COMPLEET** - AI-Filtering & Polish (13 SP / 13 SP = 100%)

Updates:
- Epic 5 status: 4/5 → 5/5 stories  **COMPLEET**
- Total progress: 26/31 stories (was 25/31)
- Story points: 71/82 SP = 87% (was 70/82 = 85%)
- E5.S5 status: 

E5.S5 was al volledig geïmplementeerd verspreid over Epics 2-5:

**Smooth Transitions (14 components):**
- transition-colors, transition-all in alle interactive elements
- Button/input hover + focus states
- artifact-enter animation (200ms ease-out)
- Reduced motion support

**Loading States (6 components):**
- CommandInput: isProcessing met Loader2
- DagnotatieBlock: isSubmitting
- OverdrachtBlock: isLoadingPatients
- ZoekenBlock: isSearching
- ChatPanel: isStreaming
- LinkedEvidence: popover loading

**Toast Confirmations:**
- DagnotatieBlock: "Dagnotitie opgeslagen" + smooth close (500ms)
- Error toasts met getErrorInfo() Nederlandse berichten
- All blocks: safeFetch error handling

**Animations:**
- @keyframes artifact-enter (translateX 100% → 0%)
- @keyframes float (badges)
- Reduced motion: animations → none
- Loader2 animate-spin

Deliverables section toegevoegd met:
- 5 implementation secties gedocumenteerd
- 11 deliverables
- 10 acceptatiecriteria
- Technical details (durations, easing, sizes)
- Status: "AL GEÏMPLEMENTEERD (Epics 2-5)"

🎯 **Epic 5 Samenvatting:**
- E5.S1 (5 SP): AI-filtering psychiater 
- E5.S2 (3 SP): Linked evidence UI 
- E5.S3 (2 SP): Voice input integratie 
- E5.S4 (2 SP): Error states & offline 
- E5.S5 (1 SP): Polish & animations 

Voortgang: 87% compleet - Alleen Epic 6 (Testing & Refinement) nog te doen!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 19:11:09 +01:00
colinislit
1ecc8f93c1 docs(swift): mark E5.S4 as complete (already implemented in E5.S2)
Bouwplan progress update: 70 SP / 82 SP (85%)

Updates:
- Epic 5 status: 3/5 → 4/5 stories (12 SP compleet)
- Total progress: 25/31 stories (was 24/31)
- Story points: 70/82 SP = 85% (was 68/82 = 83%)
- E5.S4 status: 

E5.S4 was al volledig geïmplementeerd in E5.S2:
- error-handler.ts (301 regels) met isOffline(), getErrorInfo(), safeFetch(), retryFetch()
- offline-banner.tsx (72 regels) met OfflineBanner component + useOffline hook
- CommandCenter: OfflineBanner integration
- ContextBar: margin fix (marginTop: '40px' when offline)
- ChatPanel: error messages (type: 'error')
- All blocks: safeFetch + getErrorInfo error handling

Deliverables section toegevoegd met:
- Bestaande implementatie details (3 secties)
- 11 deliverables gedocumenteerd
- 10 acceptatiecriteria
- Technical details (timeout, retry logic, event listeners)
- Status: "AL GEÏMPLEMENTEERD IN E5.S2"

Voortgang: 85% compleet - Epic 5 4/5 stories done! Laatste story: E5.S5 (1 SP)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 18:57:22 +01:00
colinislit
1bab37592b docs(swift): mark E5.S3 as complete (already implemented in E2)
Bouwplan progress update: 68 SP / 82 SP (83%)

Updates:
- Epic 5 status: 2/5 → 3/5 stories (10 SP compleet)
- Total progress: 24/31 stories (was 23/31)
- Story points: 68/82 SP = 83% (was 66/82 = 80%)
- E5.S3 status: 

E5.S3 was al volledig geïmplementeerd in Epic 2:
- use-swift-voice.ts hook (116 regels)
- CommandInput voice integratie
- Mic button rechts van input
- Live transcript in input field
- Waveform visualization
- Deepgram streaming (nl, nova-2, 2000ms endpointing)

Deliverables section toegevoegd met:
- Bestaande implementatie details
- Code references (regelnu mmers)
- Technical details (base text tracking, interim/final logic)
- 8 acceptatiecriteria gedocumenteerd
- Status: "AL GEÏMPLEMENTEERD IN E2"

Voortgang: 83% compleet - Epic 5 3/5 stories done!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 18:51:51 +01:00