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>
This commit is contained in:
colinislit
2025-12-30 09:18:06 +01:00
parent c8aaba657e
commit 2170b23348
62 changed files with 364 additions and 355 deletions

View File

@@ -10,14 +10,14 @@
* Stories: E1.S3, E3.S6, E4.S1, E4.S2
*/
import { useSwiftStore } from '@/stores/swift-store';
import { useCortexStore } from '@/stores/cortex-store';
import { ArtifactContainer } from './artifact-container';
export function ArtifactArea() {
const openArtifacts = useSwiftStore((s) => s.openArtifacts);
const activeArtifactId = useSwiftStore((s) => s.activeArtifactId);
const switchArtifact = useSwiftStore((s) => s.switchArtifact);
const closeArtifact = useSwiftStore((s) => s.closeArtifact);
const openArtifacts = useCortexStore((s) => s.openArtifacts);
const activeArtifactId = useCortexStore((s) => s.activeArtifactId);
const switchArtifact = useCortexStore((s) => s.switchArtifact);
const closeArtifact = useCortexStore((s) => s.closeArtifact);
return (
<ArtifactContainer

View File

@@ -18,7 +18,7 @@ import { OverdrachtBlock } from '../blocks/overdracht-block';
import { PatientDashboardBlock } from '../blocks/patient-dashboard-block';
import { FallbackPicker } from '../blocks/fallback-picker';
import { APPOINTMENT_TYPES, type AppointmentTypeCode, type LocationClassCode } from '@/app/epd/agenda/types';
import type { Artifact, BlockType } from '@/stores/swift-store';
import type { Artifact, BlockType } from '@/stores/cortex-store';
interface ArtifactContainerProps {
artifacts: Artifact[];

View File

@@ -12,7 +12,7 @@
import { X } from 'lucide-react';
import { cn } from '@/lib/utils';
import type { Artifact } from '@/stores/swift-store';
import type { Artifact } from '@/stores/cortex-store';
interface ArtifactTabProps {
artifact: Artifact;

View File

@@ -93,7 +93,7 @@ export function AgendaCreateForm({ prefillData, onClose }: AgendaCreateFormProps
setIsSearching(true);
try {
const res = await fetch(`/api/swift/patients/search?q=${encodeURIComponent(searchQuery)}`);
const res = await fetch(`/api/cortex/patients/search?q=${encodeURIComponent(searchQuery)}`);
if (res.ok) {
const data = await res.json();
setSearchResults(data.patients || []);

View File

@@ -9,8 +9,8 @@
import { ReactNode } from 'react';
import { motion, type Variants } from 'framer-motion';
import { X } from 'lucide-react';
import { useSwiftStore } from '@/stores/swift-store';
import type { BlockSize } from '@/lib/swift/types';
import { useCortexStore } from '@/stores/cortex-store';
import type { BlockSize } from '@/lib/cortex/types';
interface BlockContainerProps {
title: string;
@@ -66,7 +66,7 @@ const closeButtonVariants = {
};
export function BlockContainer({ title, size = 'md', children }: BlockContainerProps) {
const { closeBlock } = useSwiftStore();
const { closeBlock } = useCortexStore();
return (
<motion.div

View File

@@ -9,10 +9,10 @@
import { useState, useEffect, useCallback, useRef } from 'react';
import { useToast } from '@/hooks/use-toast';
import { useSwiftStore } from '@/stores/swift-store';
import { useCortexStore } from '@/stores/cortex-store';
import { BlockContainer } from './block-container';
import type { BlockPrefillData } from '@/stores/swift-store';
import { BLOCK_CONFIGS } from '@/lib/swift/types';
import type { BlockPrefillData } from '@/stores/cortex-store';
import { BLOCK_CONFIGS } from '@/lib/cortex/types';
import {
VERPLEEGKUNDIG_CATEGORIES,
CATEGORY_CONFIG,
@@ -24,7 +24,7 @@ import { Textarea } from '@/components/ui/textarea';
import { Button } from '@/components/ui/button';
import { Loader2, Search, User, RefreshCw } from 'lucide-react';
import { cn } from '@/lib/utils';
import { safeFetch, getErrorInfo, retryFetch } from '@/lib/swift/error-handler';
import { safeFetch, getErrorInfo, retryFetch } from '@/lib/cortex/error-handler';
interface DagnotitieBlockProps {
prefill?: BlockPrefillData;
@@ -39,7 +39,7 @@ interface Patient {
export function DagnotatieBlock({ prefill }: DagnotitieBlockProps) {
const config = BLOCK_CONFIGS.dagnotitie;
const { closeBlock } = useSwiftStore();
const { closeBlock } = useCortexStore();
const { toast } = useToast();
// Form state

View File

@@ -10,8 +10,8 @@
import { useEffect, useCallback } from 'react';
import { motion } from 'framer-motion';
import { FileText, Search, ArrowRightLeft, X } from 'lucide-react';
import { useSwiftStore } from '@/stores/swift-store';
import type { BlockType } from '@/lib/swift/types';
import { useCortexStore } from '@/stores/cortex-store';
import type { BlockType } from '@/lib/cortex/types';
interface FallbackPickerProps {
originalInput?: string;
@@ -54,7 +54,7 @@ const BLOCK_OPTIONS: BlockOption[] = [
];
export function FallbackPicker({ originalInput }: FallbackPickerProps) {
const { openBlock, closeBlock, addRecentAction } = useSwiftStore();
const { openBlock, closeBlock, addRecentAction } = useCortexStore();
const handleSelect = useCallback(
(option: BlockOption) => {

View File

@@ -1,5 +1,5 @@
/**
* Swift Blocks Barrel Export
* Cortex Blocks Barrel Export
*/
export { BlockContainer } from './block-container';

View File

@@ -9,10 +9,10 @@
import { useState, useEffect, useCallback } from 'react';
import { useToast } from '@/hooks/use-toast';
import { useSwiftStore } from '@/stores/swift-store';
import { useCortexStore } from '@/stores/cortex-store';
import { BlockContainer } from './block-container';
import type { BlockPrefillData } from '@/stores/swift-store';
import { BLOCK_CONFIGS } from '@/lib/swift/types';
import type { BlockPrefillData } from '@/stores/cortex-store';
import { BLOCK_CONFIGS } from '@/lib/cortex/types';
import type { PatientOverzicht, AISamenvatting } from '@/lib/types/overdracht';
import {
Sparkles,
@@ -28,8 +28,8 @@ import { format } from 'date-fns';
import { nl } from 'date-fns/locale/nl';
import { cn } from '@/lib/utils';
import { Button } from '@/components/ui/button';
import { safeFetch, getErrorInfo, retryFetch } from '@/lib/swift/error-handler';
import { LinkedEvidence } from '@/components/swift/shared/linked-evidence';
import { safeFetch, getErrorInfo, retryFetch } from '@/lib/cortex/error-handler';
import { LinkedEvidence } from '@/components/cortex/shared/linked-evidence';
interface OverdrachtBlockProps {
prefill?: BlockPrefillData;
@@ -53,7 +53,7 @@ interface PatientSummary {
export function OverdrachtBlock({ prefill }: OverdrachtBlockProps) {
const config = BLOCK_CONFIGS.overdracht;
const { activePatient } = useSwiftStore();
const { activePatient } = useCortexStore();
const { toast } = useToast();
const [period, setPeriod] = useState<PeriodValue>('1d');

View File

@@ -8,9 +8,9 @@
*/
import { useEffect, useState } from 'react';
import { useSwiftStore } from '@/stores/swift-store';
import { useCortexStore } from '@/stores/cortex-store';
import { BlockContainer } from './block-container';
import { BLOCK_CONFIGS } from '@/lib/swift/types';
import { BLOCK_CONFIGS } from '@/lib/cortex/types';
import type { PatientDetail, Report, VitalSign, Condition, RiskAssessment } from '@/lib/types/overdracht';
import { Loader2, FileText, Activity, Stethoscope, AlertTriangle, Calendar } from 'lucide-react';
import { format } from 'date-fns';
@@ -18,7 +18,7 @@ import { nl } from 'date-fns/locale/nl';
import { cn } from '@/lib/utils';
export function PatientContextCard() {
const { activePatient, closeBlock } = useSwiftStore();
const { activePatient, closeBlock } = useCortexStore();
const [data, setData] = useState<PatientDetail | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<string | null>(null);

View File

@@ -19,10 +19,10 @@ import {
User,
} from 'lucide-react';
import { BlockContainer } from './block-container';
import { safeFetch, getErrorInfo } from '@/lib/swift/error-handler';
import { safeFetch, getErrorInfo } from '@/lib/cortex/error-handler';
import { useToast } from '@/hooks/use-toast';
import { BLOCK_CONFIGS } from '@/lib/swift/types';
import type { BlockPrefillData } from '@/stores/swift-store';
import { BLOCK_CONFIGS } from '@/lib/cortex/types';
import type { BlockPrefillData } from '@/stores/cortex-store';
import type { FHIRPatient } from '@/lib/fhir';
import type { Intake } from '@/lib/types/intake';
import { cn } from '@/lib/utils';

View File

@@ -9,15 +9,15 @@
import { useState, useEffect, useCallback, useRef } from 'react';
import { useToast } from '@/hooks/use-toast';
import { useSwiftStore } from '@/stores/swift-store';
import { useCortexStore } from '@/stores/cortex-store';
import { BlockContainer } from './block-container';
import type { BlockPrefillData } from '@/stores/swift-store';
import { BLOCK_CONFIGS } from '@/lib/swift/types';
import type { BlockPrefillData } from '@/stores/cortex-store';
import { BLOCK_CONFIGS } from '@/lib/cortex/types';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Loader2, Search, User, Check } from 'lucide-react';
import { cn } from '@/lib/utils';
import { safeFetch, getErrorInfo } from '@/lib/swift/error-handler';
import { safeFetch, getErrorInfo } from '@/lib/cortex/error-handler';
interface ZoekenBlockProps {
prefill?: BlockPrefillData;
@@ -34,7 +34,7 @@ interface PatientSearchResult {
export function ZoekenBlock({ prefill }: ZoekenBlockProps) {
const config = BLOCK_CONFIGS.zoeken;
const { closeBlock, setActivePatient, addRecentAction, openArtifact } = useSwiftStore();
const { closeBlock, setActivePatient, addRecentAction, openArtifact } = useCortexStore();
const { toast } = useToast();
const prefillQuery = prefill?.patientName || prefill?.query || '';

View File

@@ -11,7 +11,7 @@
import { useState, useRef, KeyboardEvent, ChangeEvent, forwardRef, useImperativeHandle } from 'react';
import { Send, Mic } from 'lucide-react';
import { useSwiftStore } from '@/stores/swift-store';
import { useCortexStore } from '@/stores/cortex-store';
import { cn } from '@/lib/utils';
interface ChatInputProps {
@@ -32,7 +32,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(function Ch
}, ref) {
const [inputValue, setInputValue] = useState('');
const textareaRef = useRef<HTMLTextAreaElement>(null);
const addChatMessage = useSwiftStore((s) => s.addChatMessage);
const addChatMessage = useCortexStore((s) => s.addChatMessage);
// Expose focus and clear methods to parent
useImperativeHandle(ref, () => ({

View File

@@ -14,8 +14,8 @@ import { format } from 'date-fns';
import { nl } from 'date-fns/locale';
import { CheckCircle2, Sparkles } from 'lucide-react';
import { cn } from '@/lib/utils';
import type { ChatMessage as ChatMessageType } from '@/stores/swift-store';
import { getConfidenceLabel } from '@/lib/swift/action-parser';
import type { ChatMessage as ChatMessageType } from '@/stores/cortex-store';
import { getConfidenceLabel } from '@/lib/cortex/action-parser';
// Message styling configuration per type
const MESSAGE_STYLES = {

View File

@@ -13,20 +13,20 @@ import { useRef, useEffect, useState, useCallback } from 'react';
import { ArrowDown } from 'lucide-react';
import { ChatMessage } from './chat-message';
import { ChatInput, ChatInputHandle } from './chat-input';
import { useSwiftStore } from '@/stores/swift-store';
import { sendChatMessage } from '@/lib/swift/chat-api';
import { parseActionFromResponse, shouldOpenArtifact } from '@/lib/swift/action-parser';
import { useCortexStore } from '@/stores/cortex-store';
import { sendChatMessage } from '@/lib/cortex/chat-api';
import { parseActionFromResponse, shouldOpenArtifact } from '@/lib/cortex/action-parser';
import { cn } from '@/lib/utils';
export function ChatPanel() {
const chatMessages = useSwiftStore((s) => s.chatMessages);
const addChatMessage = useSwiftStore((s) => s.addChatMessage);
const updateLastMessage = useSwiftStore((s) => s.updateLastMessage);
const setStreaming = useSwiftStore((s) => s.setStreaming);
const isStreaming = useSwiftStore((s) => s.isStreaming);
const setPendingAction = useSwiftStore((s) => s.setPendingAction);
const activePatient = useSwiftStore((s) => s.activePatient);
const shift = useSwiftStore((s) => s.shift);
const chatMessages = useCortexStore((s) => s.chatMessages);
const addChatMessage = useCortexStore((s) => s.addChatMessage);
const updateLastMessage = useCortexStore((s) => s.updateLastMessage);
const setStreaming = useCortexStore((s) => s.setStreaming);
const isStreaming = useCortexStore((s) => s.isStreaming);
const setPendingAction = useCortexStore((s) => s.setPendingAction);
const activePatient = useCortexStore((s) => s.activePatient);
const shift = useCortexStore((s) => s.shift);
// Refs for scrolling
const scrollContainerRef = useRef<HTMLDivElement>(null);
@@ -108,7 +108,7 @@ export function ChatPanel() {
<div className="max-w-md text-center text-slate-500">
<div className="text-4xl mb-4">💬</div>
<h3 className="text-lg font-medium text-slate-700 mb-2">
Welkom bij Swift Assistent
Welkom bij Cortex Assistent
</h3>
<p className="text-sm mb-4">
Typ of spreek wat je wilt doen...

View File

@@ -7,8 +7,8 @@
*/
import { AnimatePresence, motion } from 'framer-motion';
import { useSwiftStore } from '@/stores/swift-store';
import type { BlockType, BlockPrefillData } from '@/stores/swift-store';
import { useCortexStore } from '@/stores/cortex-store';
import type { BlockType, BlockPrefillData } from '@/stores/cortex-store';
import { DagnotatieBlock } from '../blocks/dagnotitie-block';
import { ZoekenBlock } from '../blocks/zoeken-block';
import { OverdrachtBlock } from '../blocks/overdracht-block';
@@ -16,7 +16,7 @@ import { PatientContextCard } from '../blocks/patient-context-card';
import { FallbackPicker } from '../blocks/fallback-picker';
export function CanvasArea() {
const { activeBlock, prefillData, activePatient } = useSwiftStore();
const { activeBlock, prefillData, activePatient } = useCortexStore();
function renderBlock(blockType: BlockType, prefill: BlockPrefillData) {
switch (blockType) {

View File

@@ -3,7 +3,7 @@
/**
* Command Center (v3.0)
*
* Main container for the Swift interface.
* Main container for the Cortex interface.
* Split-screen layout: Chat Panel (40%) | Artifact Area (60%)
*
* Layout specs:
@@ -17,16 +17,16 @@
*/
import { useEffect, useCallback, useRef } from 'react';
import { useSwiftStore } from '@/stores/swift-store';
import { useCortexStore } from '@/stores/cortex-store';
import { ContextBar } from './context-bar';
import { OfflineBanner } from './offline-banner';
import { ChatPanel } from '../chat/chat-panel';
import { ArtifactArea } from '../artifacts/artifact-area';
import { getArtifactTitle } from '../artifacts/artifact-container';
import { routeIntentToArtifact } from '@/lib/swift/action-parser';
import { routeIntentToArtifact } from '@/lib/cortex/action-parser';
export function CommandCenter() {
const { closeAllArtifacts, openArtifacts, openArtifact, pendingAction, setPendingAction } = useSwiftStore();
const { closeAllArtifacts, openArtifacts, openArtifact, pendingAction, setPendingAction } = useCortexStore();
const inputRef = useRef<HTMLInputElement>(null);
// Global keyboard shortcuts

View File

@@ -15,13 +15,13 @@
*/
import { forwardRef, useState, useEffect, useRef } from 'react';
import { useSwiftStore } from '@/stores/swift-store';
import { useSwiftVoice } from '@/lib/swift/use-swift-voice';
import type { BlockType } from '@/lib/swift/types';
import { useCortexStore } from '@/stores/cortex-store';
import { useCortexVoice } from '@/lib/cortex/use-cortex-voice';
import type { BlockType } from '@/lib/cortex/types';
import { Mic, MicOff, Send, Loader2 } from 'lucide-react';
import { useToast } from '@/hooks/use-toast';
import { safeFetch, getErrorInfo } from '@/lib/swift/error-handler';
import { routeIntentToArtifact } from '@/lib/swift/action-parser';
import { safeFetch, getErrorInfo } from '@/lib/cortex/error-handler';
import { routeIntentToArtifact } from '@/lib/cortex/action-parser';
export const CommandInput = forwardRef<HTMLInputElement>(function CommandInput(_, ref) {
const {
@@ -34,7 +34,7 @@ export const CommandInput = forwardRef<HTMLInputElement>(function CommandInput(_
openBlock,
openArtifact,
addRecentAction,
} = useSwiftStore();
} = useCortexStore();
const { toast } = useToast();
const {
@@ -46,7 +46,7 @@ export const CommandInput = forwardRef<HTMLInputElement>(function CommandInput(_
stopRecording,
analyserNode,
isBrowserSupported,
} = useSwiftVoice();
} = useCortexVoice();
const [isProcessing, setIsProcessing] = useState(false);
const waveformRef = useRef<HTMLCanvasElement>(null);

View File

@@ -7,7 +7,7 @@
* Height: 48px (h-12)
*/
import { useSwiftStore, type ShiftType } from '@/stores/swift-store';
import { useCortexStore, type ShiftType } from '@/stores/cortex-store';
import { Sun, Moon, Sunrise, Sunset, X, User, ArrowLeft } from 'lucide-react';
import Link from 'next/link';
import { useOffline } from './offline-banner';
@@ -20,7 +20,7 @@ const SHIFT_CONFIG: Record<ShiftType, { icon: typeof Sun; label: string; color:
};
export function ContextBar() {
const { shift, activePatient, setActivePatient } = useSwiftStore();
const { shift, activePatient, setActivePatient } = useCortexStore();
const isOffline = useOffline();
const shiftConfig = SHIFT_CONFIG[shift];
const ShiftIcon = shiftConfig.icon;

View File

@@ -7,10 +7,10 @@
* Height: 48px (h-12)
*/
import { useSwiftStore, type SwiftIntent } from '@/stores/swift-store';
import { useCortexStore, type CortexIntent } from '@/stores/cortex-store';
import { FileText, Search, ArrowRightLeft, HelpCircle, Clock, Calendar, Plus, X } from 'lucide-react';
const INTENT_CONFIG: Record<SwiftIntent, { icon: typeof FileText; color: string; label: string }> = {
const INTENT_CONFIG: Record<CortexIntent, { icon: typeof FileText; color: string; label: string }> = {
dagnotitie: { icon: FileText, color: 'text-blue-600 bg-blue-50 border border-blue-200', label: 'Notitie' },
zoeken: { icon: Search, color: 'text-emerald-600 bg-emerald-50 border border-emerald-200', label: 'Zoeken' },
overdracht: { icon: ArrowRightLeft, color: 'text-purple-600 bg-purple-50 border border-purple-200', label: 'Overdracht' },
@@ -34,7 +34,7 @@ function formatRelativeTime(date: Date): string {
}
export function RecentStrip() {
const { recentActions, setInputValue, openBlock } = useSwiftStore();
const { recentActions, setInputValue, openBlock } = useCortexStore();
const handleActionClick = (action: typeof recentActions[0]) => {
// Set the input to repeat the action

View File

@@ -1,5 +1,5 @@
/**
* Swift Components Barrel Export
* Cortex Components Barrel Export
*/
export * from './command-center';