feat: assistant workspace — persistent AI personality & memory via Markdown files (#165)
Add "Assistant Workspace" feature that lets users designate a directory (e.g. Obsidian vault) containing 4 Markdown files (soul.md, user.md, memory.md, claude.md) to define AI personality, user profile, long-term memory, and execution rules. These files are automatically injected into the system prompt for assistant project sessions. Core library (src/lib/assistant-workspace.ts): - Workspace validation, initialization with template files - File loading with 8000-char truncation, XML prompt assembly (40k limit) - State management via .assistant/state.json - Directory docs generation (README.ai.md + PATH.ai.md) - Case-insensitive file name fallback (soul.md → SOUL.md) System prompt injection (src/app/api/chat/route.ts): - Scoped to sessions where working_directory === workspace path - Workspace prompt prepended before session-level system prompt - Onboarding/check-in instructions injected as <assistant-project-task> - autoTrigger flag skips user message save and title update Chat-based onboarding (10 questions) & daily check-in (3 questions): - AI conducts conversation, outputs structured completion code blocks - Frontend detects onboarding-complete/checkin-complete blocks - Backend calls Claude API to generate file content from answers - Fallback to raw answers if API call fails Auto-trigger pipeline: - Mount trigger (500ms delay) + focus fallback in MessageInput - assistantTriggerFiredRef prevents duplicate triggers per mount - hookTriggeredSessionId in state.json prevents cross-reload duplicates - Daily check-in only triggers in the most recent workspace session - hookTriggeredSessionId cleared via __clear__ sentinel after completion API endpoints: - GET/PUT /api/settings/workspace — path CRUD + file status - POST /api/workspace/session — create (onboarding) or reuse (check-in) - POST /api/workspace/onboarding — AI-generate soul.md + user.md - POST /api/workspace/checkin — AI-update memory.md + user.md - POST /api/workspace/hook-triggered — set/clear trigger guard - GET /api/workspace/latest-session — latest session lookup - POST /api/workspace/docs — refresh directory documentation UI: - Settings "Assistant" tab with workspace path, file status, controls - Violet badge on workspace project group in ChatListPanel - useAssistantWorkspace hook for state queries Also includes: - 102 passing tests (16 new regression tests for workspace logic) - i18n keys for en.ts and zh.ts - Handover documentation and execution plan Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
3f19290c8d
commit
19aba25c8f
24 files changed
+1812
-24
No files matched your search
@@ -439,8 +439,27 @@ export const SETTING_KEYS = {
|
||||
THEME: 'theme',
|
||||
PERMISSION_MODE: 'permission_mode',
|
||||
MAX_THINKING_TOKENS: 'max_thinking_tokens',
|
||||
ASSISTANT_WORKSPACE_PATH: 'assistant_workspace_path',
|
||||
} as const;
|
||||
|
||||
// ==========================================
|
||||
// Assistant Workspace Types
|
||||
// ==========================================
|
||||
|
||||
export interface AssistantWorkspaceState {
|
||||
onboardingComplete: boolean;
|
||||
lastCheckInDate: string | null;
|
||||
schemaVersion: number;
|
||||
hookTriggeredSessionId?: string;
|
||||
}
|
||||
|
||||
export interface AssistantWorkspaceFiles {
|
||||
soul?: string;
|
||||
memory?: string;
|
||||
user?: string;
|
||||
claude?: string;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// Reference Image Types (for image generation)
|
||||
// ==========================================
|
||||
|
||||
Reference in new issue
Block a user