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:
@@ -14,7 +14,7 @@
|
||||
3. [Data Models & Types](#3-data-models--types)
|
||||
4. [Layer 1: Reflex Arc](#4-layer-1-reflex-arc)
|
||||
5. [Layer 2: Intent Orchestrator](#5-layer-2-intent-orchestrator)
|
||||
6. [Layer 3: Safety Net](#6-layer-3-safety-net)
|
||||
6. [Layer 3: Nudge](#6-layer-3-nudge)
|
||||
7. [API Design](#7-api-design)
|
||||
8. [Frontend Components](#8-frontend-components)
|
||||
9. [State Management](#9-state-management)
|
||||
@@ -92,7 +92,7 @@ Transformatie naar een **agentic systeem** dat:
|
||||
[Action Completed]
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||||
│ LAYER 3: SAFETY NET (POST-ACTION INTELLIGENCE) [async] │
|
||||
│ LAYER 3: NUDGE (POST-ACTION INTELLIGENCE) [async] │
|
||||
│ ┌─────────────────────────────────────────────────────────────────────┐ │
|
||||
│ │ • Protocol Rules Engine: medical domain knowledge │ │
|
||||
│ │ • Trigger evaluation: "Does this action warrant a follow-up?" │ │
|
||||
@@ -108,7 +108,7 @@ Transformatie naar een **agentic systeem** dat:
|
||||
```
|
||||
┌──────────┐ ┌─────────┐ ┌─────────────┐ ┌──────────┐ ┌───────────┐
|
||||
│ Speech │───►│ Input │───►│ Classify │───►│ Execute │───►│ Safety │
|
||||
│ /Text │ │ Buffer │ │ (L1/L2) │ │ Chain │ │ Net │
|
||||
│ /Text │ │ Buffer │ │ (L1/L2) │ │ Chain │ │ Nudge │
|
||||
└──────────┘ └─────────┘ └─────────────┘ └──────────┘ └───────────┘
|
||||
│ │ │
|
||||
▼ ▼ ▼
|
||||
@@ -122,14 +122,14 @@ Transformatie naar een **agentic systeem** dat:
|
||||
|
||||
## 3. Data Models & Types
|
||||
|
||||
### 3.1 Core Types (lib/swift/types.ts)
|
||||
### 3.1 Core Types (lib/cortex/types.ts)
|
||||
|
||||
```typescript
|
||||
// ============================================================================
|
||||
// INTENT TYPES
|
||||
// ============================================================================
|
||||
|
||||
export type SwiftIntent =
|
||||
export type CortexIntent =
|
||||
| 'dagnotitie'
|
||||
| 'zoeken'
|
||||
| 'overdracht'
|
||||
@@ -146,7 +146,7 @@ export type SwiftIntent =
|
||||
/**
|
||||
* Full context passed to AI for intelligent classification
|
||||
*/
|
||||
export interface SwiftContext {
|
||||
export interface CortexContext {
|
||||
// Active patient (if any)
|
||||
activePatient: {
|
||||
id: string;
|
||||
@@ -175,7 +175,7 @@ export interface SwiftContext {
|
||||
|
||||
// Recent intents (for continuity)
|
||||
recentIntents: {
|
||||
intent: SwiftIntent;
|
||||
intent: CortexIntent;
|
||||
patientName?: string;
|
||||
timestamp: Date;
|
||||
}[];
|
||||
@@ -183,7 +183,7 @@ export interface SwiftContext {
|
||||
// User preferences (adaptive confidence)
|
||||
userPreferences?: {
|
||||
confirmationLevel: 'always' | 'destructive' | 'never';
|
||||
frequentIntents: SwiftIntent[];
|
||||
frequentIntents: CortexIntent[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ export interface IntentAction {
|
||||
sequence: number; // Order in chain (1, 2, 3...)
|
||||
|
||||
// Classification
|
||||
intent: SwiftIntent;
|
||||
intent: CortexIntent;
|
||||
confidence: number;
|
||||
|
||||
// Extracted data
|
||||
@@ -311,25 +311,25 @@ export type AppointmentType =
|
||||
| 'overig';
|
||||
|
||||
// ============================================================================
|
||||
// SAFETY NET TYPES (NEW in V2)
|
||||
// NUDGE TYPES (NEW in V2)
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* A suggestion generated by the Safety Net
|
||||
* A suggestion generated by the Nudge layer
|
||||
*/
|
||||
export interface SafetySuggestion {
|
||||
export interface NudgeSuggestion {
|
||||
id: string;
|
||||
|
||||
// What triggered this suggestion
|
||||
trigger: {
|
||||
actionId: string;
|
||||
intent: SwiftIntent;
|
||||
intent: CortexIntent;
|
||||
entities: ExtractedEntities;
|
||||
};
|
||||
|
||||
// The suggestion itself
|
||||
suggestion: {
|
||||
intent: SwiftIntent;
|
||||
intent: CortexIntent;
|
||||
entities: Partial<ExtractedEntities>;
|
||||
message: string; // "Wondcontrole inplannen over 3 dagen?"
|
||||
rationale: string; // "Bij wondzorg hoort standaard een controle"
|
||||
@@ -355,13 +355,13 @@ export interface ProtocolRule {
|
||||
|
||||
// When to trigger
|
||||
trigger: {
|
||||
intent: SwiftIntent;
|
||||
intent: CortexIntent;
|
||||
conditions?: ProtocolCondition[];
|
||||
};
|
||||
|
||||
// What to suggest
|
||||
suggestion: {
|
||||
intent: SwiftIntent;
|
||||
intent: CortexIntent;
|
||||
message: string;
|
||||
prefillFrom: (source: ExtractedEntities) => Partial<ExtractedEntities>;
|
||||
};
|
||||
@@ -386,7 +386,7 @@ export interface ProtocolCondition {
|
||||
* Result from Layer 1 (Local Reflex)
|
||||
*/
|
||||
export interface LocalClassificationResult {
|
||||
intent: SwiftIntent;
|
||||
intent: CortexIntent;
|
||||
confidence: number;
|
||||
matchedPattern?: string;
|
||||
processingTimeMs: number;
|
||||
@@ -434,33 +434,33 @@ export interface ClassificationResult {
|
||||
}
|
||||
```
|
||||
|
||||
### 3.2 Store Types (stores/swift-store.ts additions)
|
||||
### 3.2 Store Types (stores/cortex-store.ts additions)
|
||||
|
||||
```typescript
|
||||
// Add to existing SwiftStore interface
|
||||
// Add to existing CortexStore interface
|
||||
|
||||
interface SwiftStoreV2 extends SwiftStore {
|
||||
interface CortexStoreV2 extends CortexStore {
|
||||
// Context (enhanced)
|
||||
context: SwiftContext;
|
||||
|
||||
context: CortexContext;
|
||||
|
||||
// Intent Chain state
|
||||
activeChain: IntentChain | null;
|
||||
chainHistory: IntentChain[];
|
||||
|
||||
// Safety Net state
|
||||
pendingSuggestions: SafetySuggestion[];
|
||||
suggestionHistory: SafetySuggestion[];
|
||||
// Nudge state
|
||||
pendingSuggestions: NudgeSuggestion[];
|
||||
suggestionHistory: NudgeSuggestion[];
|
||||
|
||||
// Actions
|
||||
setContext: (context: Partial<SwiftContext>) => void;
|
||||
setContext: (context: Partial<CortexContext>) => void;
|
||||
|
||||
// Chain actions
|
||||
startChain: (chain: IntentChain) => void;
|
||||
updateActionStatus: (chainId: string, actionId: string, status: IntentAction['status']) => void;
|
||||
completeChain: (chainId: string) => void;
|
||||
|
||||
// Safety Net actions
|
||||
addSuggestion: (suggestion: SafetySuggestion) => void;
|
||||
// Nudge actions
|
||||
addSuggestion: (suggestion: NudgeSuggestion) => void;
|
||||
acceptSuggestion: (suggestionId: string) => void;
|
||||
dismissSuggestion: (suggestionId: string) => void;
|
||||
}
|
||||
@@ -479,7 +479,7 @@ Razendsnelle (<20ms) afhandeling van **simpele, eenduidige commando's** met hoge
|
||||
- Geen context-afhankelijke woorden ("hij", "haar", "die afspraak")
|
||||
- Geen tijdsrelaties die interpretatie nodig hebben
|
||||
|
||||
### 4.3 Implementatie (lib/swift/reflex-classifier.ts)
|
||||
### 4.3 Implementatie (lib/cortex/reflex-classifier.ts)
|
||||
|
||||
```typescript
|
||||
/**
|
||||
@@ -489,7 +489,7 @@ Razendsnelle (<20ms) afhandeling van **simpele, eenduidige commando's** met hoge
|
||||
* Escalates to Layer 2 when complexity is detected.
|
||||
*/
|
||||
|
||||
import type { LocalClassificationResult, SwiftIntent } from './types';
|
||||
import type { LocalClassificationResult, CortexIntent } from './types';
|
||||
|
||||
// Multi-intent signal words
|
||||
const MULTI_INTENT_SIGNALS = [
|
||||
@@ -513,7 +513,7 @@ const CONTEXT_SIGNALS = [
|
||||
];
|
||||
|
||||
// Intent patterns with weights
|
||||
const REFLEX_PATTERNS: Record<SwiftIntent, Array<{ pattern: RegExp; weight: number }>> = {
|
||||
const REFLEX_PATTERNS: Record<CortexIntent, Array<{ pattern: RegExp; weight: number }>> = {
|
||||
dagnotitie: [
|
||||
{ pattern: /^dagnotitie\b/i, weight: 1.0 },
|
||||
{ pattern: /^notitie\s+\w+\s+(medicatie|adl|gedrag|incident|observatie)\b/i, weight: 0.95 },
|
||||
@@ -617,14 +617,14 @@ export function classifyWithReflex(input: string): LocalClassificationResult {
|
||||
}
|
||||
|
||||
// Step 2: Pattern matching
|
||||
let bestMatch: { intent: SwiftIntent; confidence: number; pattern: string } | null = null;
|
||||
let bestMatch: { intent: CortexIntent; confidence: number; pattern: string } | null = null;
|
||||
|
||||
for (const [intent, patterns] of Object.entries(REFLEX_PATTERNS)) {
|
||||
for (const { pattern, weight } of patterns) {
|
||||
if (pattern.test(trimmedInput)) {
|
||||
if (!bestMatch || weight > bestMatch.confidence) {
|
||||
bestMatch = {
|
||||
intent: intent as SwiftIntent,
|
||||
intent: intent as CortexIntent,
|
||||
confidence: weight,
|
||||
pattern: pattern.source,
|
||||
};
|
||||
@@ -677,7 +677,7 @@ De AI krijgt altijd volledige context mee:
|
||||
/**
|
||||
* Build context for AI classification
|
||||
*/
|
||||
export function buildSwiftContext(store: SwiftStore): SwiftContext {
|
||||
export function buildCortexContext(store: CortexStore): CortexContext {
|
||||
return {
|
||||
activePatient: store.activePatient ? {
|
||||
id: store.activePatient.id,
|
||||
@@ -699,7 +699,7 @@ export function buildSwiftContext(store: SwiftStore): SwiftContext {
|
||||
}
|
||||
```
|
||||
|
||||
### 5.3 Implementatie (lib/swift/orchestrator.ts)
|
||||
### 5.3 Implementatie (lib/cortex/orchestrator.ts)
|
||||
|
||||
```typescript
|
||||
/**
|
||||
@@ -710,7 +710,7 @@ export function buildSwiftContext(store: SwiftStore): SwiftContext {
|
||||
|
||||
import Anthropic from '@anthropic-ai/sdk';
|
||||
import type {
|
||||
SwiftContext,
|
||||
CortexContext,
|
||||
IntentChain,
|
||||
IntentAction,
|
||||
AIClassificationResult
|
||||
@@ -789,7 +789,7 @@ Als je twijfelt, stel een verduidelijkingsvraag:
|
||||
/**
|
||||
* Format context for AI prompt
|
||||
*/
|
||||
function formatContextForPrompt(context: SwiftContext): string {
|
||||
function formatContextForPrompt(context: CortexContext): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
// Active patient
|
||||
@@ -829,7 +829,7 @@ function formatContextForPrompt(context: SwiftContext): string {
|
||||
*/
|
||||
export async function classifyWithOrchestrator(
|
||||
input: string,
|
||||
context: SwiftContext
|
||||
context: CortexContext
|
||||
): Promise<AIClassificationResult> {
|
||||
const startTime = performance.now();
|
||||
|
||||
@@ -903,7 +903,7 @@ Analyseer en extraheer alle intenties.`,
|
||||
*/
|
||||
function parseAIResponse(rawText: string): {
|
||||
actions: Array<{
|
||||
intent: SwiftIntent;
|
||||
intent: CortexIntent;
|
||||
confidence: number;
|
||||
entities: ExtractedEntities;
|
||||
requiresConfirmation?: boolean;
|
||||
@@ -944,7 +944,7 @@ function parseAIResponse(rawText: string): {
|
||||
|
||||
---
|
||||
|
||||
## 6. Layer 3: Safety Net
|
||||
## 6. Layer 3: Nudge
|
||||
|
||||
### 6.1 Doel
|
||||
Proactieve suggesties na succesvolle acties op basis van medische protocollen en domeinkennis.
|
||||
@@ -953,17 +953,17 @@ Proactieve suggesties na succesvolle acties op basis van medische protocollen en
|
||||
|
||||
```typescript
|
||||
/**
|
||||
* Layer 3: Safety Net
|
||||
*
|
||||
* Layer 3: Nudge
|
||||
*
|
||||
* Post-action intelligence that suggests follow-up actions
|
||||
* based on medical protocols and domain knowledge.
|
||||
*/
|
||||
|
||||
import type {
|
||||
IntentAction,
|
||||
SafetySuggestion,
|
||||
import type {
|
||||
IntentAction,
|
||||
NudgeSuggestion,
|
||||
ProtocolRule,
|
||||
ExtractedEntities
|
||||
ExtractedEntities
|
||||
} from './types';
|
||||
|
||||
// ============================================================================
|
||||
@@ -1102,7 +1102,7 @@ export const PROTOCOL_RULES: ProtocolRule[] = [
|
||||
];
|
||||
|
||||
// ============================================================================
|
||||
// SAFETY NET ENGINE
|
||||
// NUDGE ENGINE
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
@@ -1139,10 +1139,10 @@ function checkCondition(
|
||||
/**
|
||||
* Evaluate all protocol rules against a completed action
|
||||
*/
|
||||
export function evaluateSafetyNet(
|
||||
export function evaluateNudge(
|
||||
completedAction: IntentAction
|
||||
): SafetySuggestion[] {
|
||||
const suggestions: SafetySuggestion[] = [];
|
||||
): NudgeSuggestion[] {
|
||||
const suggestions: NudgeSuggestion[] = [];
|
||||
|
||||
for (const rule of PROTOCOL_RULES) {
|
||||
if (!rule.enabled) continue;
|
||||
@@ -1159,7 +1159,7 @@ export function evaluateSafetyNet(
|
||||
if (!conditionsMet) continue;
|
||||
|
||||
// Generate suggestion
|
||||
const suggestion: SafetySuggestion = {
|
||||
const suggestion: NudgeSuggestion = {
|
||||
id: crypto.randomUUID(),
|
||||
trigger: {
|
||||
actionId: completedAction.id,
|
||||
@@ -1201,16 +1201,16 @@ export function evaluateSafetyNet(
|
||||
// app/api/intent/classify/route.ts (V2)
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { classifyWithReflex } from '@/lib/swift/reflex-classifier';
|
||||
import { classifyWithOrchestrator } from '@/lib/swift/orchestrator';
|
||||
import { evaluateSafetyNet } from '@/lib/swift/safety-net';
|
||||
import { extractEntities } from '@/lib/swift/entity-extractor';
|
||||
import type { ClassificationResult, SwiftContext } from '@/lib/swift/types';
|
||||
import { classifyWithReflex } from '@/lib/cortex/reflex-classifier';
|
||||
import { classifyWithOrchestrator } from '@/lib/cortex/orchestrator';
|
||||
import { evaluateNudge } from '@/lib/cortex/nudge';
|
||||
import { extractEntities } from '@/lib/cortex/entity-extractor';
|
||||
import type { ClassificationResult, CortexContext } from '@/lib/cortex/types';
|
||||
|
||||
// Request schema
|
||||
interface ClassifyRequest {
|
||||
input: string;
|
||||
context: SwiftContext;
|
||||
context: CortexContext;
|
||||
options?: {
|
||||
forceAI?: boolean;
|
||||
skipSafetyNet?: boolean;
|
||||
@@ -1227,8 +1227,8 @@ interface ClassifyResponse {
|
||||
clarificationQuestion?: string;
|
||||
clarificationOptions?: string[];
|
||||
|
||||
// Safety Net suggestions (if any)
|
||||
suggestions?: SafetySuggestion[];
|
||||
// Nudge suggestions (if any)
|
||||
suggestions?: NudgeSuggestion[];
|
||||
|
||||
// Debug info (dev only)
|
||||
debug?: object;
|
||||
@@ -1326,14 +1326,14 @@ interface ExecuteRequest {
|
||||
interface ExecuteResponse {
|
||||
success: boolean;
|
||||
action: IntentAction;
|
||||
suggestions?: SafetySuggestion[]; // From Safety Net
|
||||
suggestions?: NudgeSuggestion[]; // From Nudge
|
||||
error?: string;
|
||||
}
|
||||
```
|
||||
|
||||
### 7.3 Context API
|
||||
|
||||
**Endpoint:** `GET /api/swift/context`
|
||||
**Endpoint:** `GET /api/cortex/context`
|
||||
|
||||
Returns current context for AI classification:
|
||||
- Active patient
|
||||
@@ -1363,19 +1363,19 @@ CommandCenter (v3.0)
|
||||
├── ArtifactArea
|
||||
│ ├── ArtifactTabs
|
||||
│ └── ArtifactContainer
|
||||
└── SuggestionToast (NEW - Layer 3)
|
||||
└── NudgeToast (NEW - Layer 3)
|
||||
```
|
||||
|
||||
### 8.2 ActionChainCard Component
|
||||
|
||||
```tsx
|
||||
// components/swift/chat/action-chain-card.tsx
|
||||
// components/cortex/chat/action-chain-card.tsx
|
||||
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { Check, X, Loader2, AlertCircle } from 'lucide-react';
|
||||
import type { IntentChain, IntentAction } from '@/lib/swift/types';
|
||||
import type { IntentChain, IntentAction } from '@/lib/cortex/types';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
@@ -1536,21 +1536,21 @@ function ActionItem({
|
||||
}
|
||||
```
|
||||
|
||||
### 8.3 SuggestionToast Component (Layer 3 UI)
|
||||
### 8.3 NudgeToast Component (Layer 3 UI)
|
||||
|
||||
```tsx
|
||||
// components/swift/suggestion-toast.tsx
|
||||
// components/cortex/command-center/nudge-toast.tsx
|
||||
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { X, Lightbulb, ArrowRight } from 'lucide-react';
|
||||
import type { SafetySuggestion } from '@/lib/swift/types';
|
||||
import type { NudgeSuggestion } from '@/lib/cortex/types';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface SuggestionToastProps {
|
||||
suggestion: SafetySuggestion;
|
||||
interface NudgeToastProps {
|
||||
suggestion: NudgeSuggestion;
|
||||
onAccept: (suggestionId: string) => void;
|
||||
onDismiss: (suggestionId: string) => void;
|
||||
}
|
||||
@@ -1561,11 +1561,11 @@ const PRIORITY_STYLES = {
|
||||
low: 'border-blue-200 bg-blue-50',
|
||||
};
|
||||
|
||||
export function SuggestionToast({
|
||||
suggestion,
|
||||
onAccept,
|
||||
onDismiss
|
||||
}: SuggestionToastProps) {
|
||||
export function NudgeToast({
|
||||
suggestion,
|
||||
onAccept,
|
||||
onDismiss
|
||||
}: NudgeToastProps) {
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
const [timeLeft, setTimeLeft] = useState(100);
|
||||
|
||||
@@ -1660,7 +1660,7 @@ export function SuggestionToast({
|
||||
### 8.4 ClarificationCard Component
|
||||
|
||||
```tsx
|
||||
// components/swift/chat/clarification-card.tsx
|
||||
// components/cortex/chat/clarification-card.tsx
|
||||
|
||||
'use client';
|
||||
|
||||
@@ -1710,24 +1710,24 @@ export function ClarificationCard({
|
||||
|
||||
## 9. State Management
|
||||
|
||||
### 9.1 Enhanced Swift Store
|
||||
### 9.1 Enhanced Cortex Store
|
||||
|
||||
```typescript
|
||||
// stores/swift-store.ts (V2 additions)
|
||||
// stores/cortex-store.ts (V2 additions)
|
||||
|
||||
import { create } from 'zustand';
|
||||
import { devtools, persist } from 'zustand/middleware';
|
||||
import type {
|
||||
SwiftContext,
|
||||
CortexContext,
|
||||
IntentChain,
|
||||
IntentAction,
|
||||
SafetySuggestion,
|
||||
} from '@/lib/swift/types';
|
||||
NudgeSuggestion,
|
||||
} from '@/lib/cortex/types';
|
||||
|
||||
interface SwiftStoreV2 {
|
||||
interface CortexStoreV2 {
|
||||
// ============ CONTEXT ============
|
||||
context: SwiftContext;
|
||||
setContext: (context: Partial<SwiftContext>) => void;
|
||||
context: CortexContext;
|
||||
setContext: (context: Partial<CortexContext>) => void;
|
||||
|
||||
// ============ INTENT CHAINS ============
|
||||
activeChain: IntentChain | null;
|
||||
@@ -1745,10 +1745,10 @@ interface SwiftStoreV2 {
|
||||
skipAction: (chainId: string, actionId: string) => void;
|
||||
completeChain: (chainId: string) => void;
|
||||
|
||||
// ============ SAFETY NET ============
|
||||
suggestions: SafetySuggestion[];
|
||||
// ============ NUDGE ============
|
||||
suggestions: NudgeSuggestion[];
|
||||
|
||||
addSuggestion: (suggestion: SafetySuggestion) => void;
|
||||
addSuggestion: (suggestion: NudgeSuggestion) => void;
|
||||
acceptSuggestion: (suggestionId: string) => void;
|
||||
dismissSuggestion: (suggestionId: string) => void;
|
||||
clearExpiredSuggestions: () => void;
|
||||
@@ -1760,11 +1760,11 @@ interface SwiftStoreV2 {
|
||||
originalInput: string;
|
||||
} | null;
|
||||
|
||||
setClarification: (clarification: SwiftStoreV2['pendingClarification']) => void;
|
||||
setClarification: (clarification: CortexStoreV2['pendingClarification']) => void;
|
||||
answerClarification: (answer: string) => void;
|
||||
}
|
||||
|
||||
export const useSwiftStoreV2 = create<SwiftStoreV2>()(
|
||||
export const useCortexStoreV2 = create<CortexStoreV2>()(
|
||||
devtools(
|
||||
persist(
|
||||
(set, get) => ({
|
||||
@@ -1899,13 +1899,13 @@ export const useSwiftStoreV2 = create<SwiftStoreV2>()(
|
||||
},
|
||||
}),
|
||||
{
|
||||
name: 'swift-store-v2',
|
||||
name: 'cortex-store-v2',
|
||||
partialize: (state) => ({
|
||||
chainHistory: state.chainHistory.slice(0, 10),
|
||||
}),
|
||||
}
|
||||
),
|
||||
{ name: 'swift-v2' }
|
||||
{ name: 'cortex-v2' }
|
||||
)
|
||||
);
|
||||
```
|
||||
@@ -1918,8 +1918,8 @@ export const useSwiftStoreV2 = create<SwiftStoreV2>()(
|
||||
|
||||
| # | Task | Beschrijving | Effort |
|
||||
|---|------|--------------|--------|
|
||||
| 1.1 | Context Types | Nieuwe types voor SwiftContext | S |
|
||||
| 1.2 | Context API | GET /api/swift/context endpoint | M |
|
||||
| 1.1 | Context Types | Nieuwe types voor CortexContext | S |
|
||||
| 1.2 | Context API | GET /api/cortex/context endpoint | M |
|
||||
| 1.3 | Context Injection | Update AI classifier om context te ontvangen | M |
|
||||
| 1.4 | Reflex Complexity Detection | Multi-intent en context signals detectie | S |
|
||||
| 1.5 | Clarification UI | ClarificationCard component | S |
|
||||
@@ -1938,13 +1938,13 @@ export const useSwiftStoreV2 = create<SwiftStoreV2>()(
|
||||
|
||||
**Deliverable:** "Zeg Jan af en maak notitie" werkt
|
||||
|
||||
### Fase 3: Safety Net (Week 5-6)
|
||||
### Fase 3: Nudge (Week 5-6)
|
||||
|
||||
| # | Task | Beschrijving | Effort |
|
||||
|---|------|--------------|--------|
|
||||
| 3.1 | Protocol Rules | Rule definitions voor wondzorg, medicatie | M |
|
||||
| 3.2 | Safety Net Engine | evaluateSafetyNet functie | M |
|
||||
| 3.3 | SuggestionToast | UI component met timer | M |
|
||||
| 3.2 | Nudge Engine | evaluateNudge functie | M |
|
||||
| 3.3 | NudgeToast | UI component met timer | M |
|
||||
| 3.4 | Suggestion Flow | Accept/dismiss handling | S |
|
||||
| 3.5 | Protocol Admin | Admin UI voor regels (optional) | L |
|
||||
|
||||
@@ -1967,7 +1967,7 @@ export const useSwiftStoreV2 = create<SwiftStoreV2>()(
|
||||
### 11.1 Unit Tests
|
||||
|
||||
```typescript
|
||||
// lib/swift/__tests__/reflex-classifier.test.ts
|
||||
// lib/cortex/__tests__/reflex-classifier.test.ts
|
||||
|
||||
import { classifyWithReflex } from '../reflex-classifier';
|
||||
|
||||
@@ -2058,7 +2058,7 @@ describe('POST /api/intent/classify', () => {
|
||||
### 11.3 Test Zinnen Dataset
|
||||
|
||||
```json
|
||||
// lib/swift/__tests__/test-sentences.json
|
||||
// lib/cortex/__tests__/test-sentences.json
|
||||
{
|
||||
"single_intent": [
|
||||
{ "input": "notitie jan medicatie", "expected": ["dagnotitie"] },
|
||||
@@ -2110,17 +2110,17 @@ describe('POST /api/intent/classify', () => {
|
||||
Het V2 systeem moet naast V1 kunnen draaien tijdens de migratie:
|
||||
|
||||
```typescript
|
||||
// lib/swift/intent-classifier-adapter.ts
|
||||
// lib/cortex/intent-classifier-adapter.ts
|
||||
|
||||
import { classifyIntent as classifyV1 } from './intent-classifier';
|
||||
import { classifyWithReflex } from './reflex-classifier';
|
||||
import { classifyWithOrchestrator } from './orchestrator';
|
||||
|
||||
const USE_V2 = process.env.NEXT_PUBLIC_SWIFT_V2 === 'true';
|
||||
const USE_V2 = process.env.NEXT_PUBLIC_CORTEX_V2 === 'true';
|
||||
|
||||
export async function classifyIntent(
|
||||
input: string,
|
||||
context?: SwiftContext
|
||||
context?: CortexContext
|
||||
): Promise<ClassificationResult> {
|
||||
if (!USE_V2) {
|
||||
// V1 path - single intent
|
||||
@@ -2167,22 +2167,22 @@ export async function classifyIntent(
|
||||
|
||||
export const FEATURE_FLAGS = {
|
||||
// V2 Features
|
||||
SWIFT_V2_ENABLED: process.env.NEXT_PUBLIC_SWIFT_V2 === 'true',
|
||||
SWIFT_MULTI_INTENT: process.env.NEXT_PUBLIC_SWIFT_MULTI_INTENT === 'true',
|
||||
SWIFT_SAFETY_NET: process.env.NEXT_PUBLIC_SWIFT_SAFETY_NET === 'true',
|
||||
SWIFT_CONTEXT_INJECTION: process.env.NEXT_PUBLIC_SWIFT_CONTEXT === 'true',
|
||||
|
||||
CORTEX_V2_ENABLED: process.env.NEXT_PUBLIC_CORTEX_V2 === 'true',
|
||||
CORTEX_MULTI_INTENT: process.env.NEXT_PUBLIC_CORTEX_MULTI_INTENT === 'true',
|
||||
CORTEX_NUDGE: process.env.NEXT_PUBLIC_CORTEX_NUDGE === 'true',
|
||||
CORTEX_CONTEXT_INJECTION: process.env.NEXT_PUBLIC_CORTEX_CONTEXT === 'true',
|
||||
|
||||
// Rollout percentage (A/B testing)
|
||||
SWIFT_V2_ROLLOUT: parseInt(process.env.NEXT_PUBLIC_SWIFT_V2_ROLLOUT || '0', 10),
|
||||
CORTEX_V2_ROLLOUT: parseInt(process.env.NEXT_PUBLIC_CORTEX_V2_ROLLOUT || '0', 10),
|
||||
};
|
||||
|
||||
export function isSwiftV2Enabled(userId?: string): boolean {
|
||||
if (!FEATURE_FLAGS.SWIFT_V2_ENABLED) return false;
|
||||
|
||||
export function isCortexV2Enabled(userId?: string): boolean {
|
||||
if (!FEATURE_FLAGS.CORTEX_V2_ENABLED) return false;
|
||||
|
||||
// A/B test based on user ID hash
|
||||
if (userId && FEATURE_FLAGS.SWIFT_V2_ROLLOUT < 100) {
|
||||
if (userId && FEATURE_FLAGS.CORTEX_V2_ROLLOUT < 100) {
|
||||
const hash = simpleHash(userId);
|
||||
return hash % 100 < FEATURE_FLAGS.SWIFT_V2_ROLLOUT;
|
||||
return hash % 100 < FEATURE_FLAGS.CORTEX_V2_ROLLOUT;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -2212,13 +2212,13 @@ export function isSwiftV2Enabled(userId?: string): boolean {
|
||||
| **IntentChain** | Lijst van intents geëxtraheerd uit één uiting |
|
||||
| **Reflex Arc** | Layer 1 - snelle lokale pattern matching |
|
||||
| **Orchestrator** | Layer 2 - AI-gedreven classificatie |
|
||||
| **Safety Net** | Layer 3 - proactieve suggesties |
|
||||
| **Nudge** | Layer 3 - proactieve suggesties |
|
||||
| **Entity** | Geëxtraheerde data (patiëntnaam, datum, etc.) |
|
||||
| **Artifact** | UI component voor een specifieke taak |
|
||||
|
||||
### B. Referenties
|
||||
|
||||
- [FO Swift Intent System V2](./fo-swift-intent-system-v2.md)
|
||||
- [FO Cortex Intent System V2](./fo-swift-intent-system-v2.md)
|
||||
- [UX Simulatie Next Level](./ux-simulation-intent-next-level.md)
|
||||
- [UX Evaluatie Schaalbaarheid](./ux-evaluation-intent-scalability.md)
|
||||
- [Architecture Proposal V2](./intent-architecture-v2-proposal.md)
|
||||
|
||||
Reference in New Issue
Block a user