Daily Note: 2025-10-21
2025-10-21 TLDR
Session: ~10:00 AM - 11:40 AM - EVNA-Next Active Context & Bug Fixes
tldr-request: --- and, could you update evnas context as you prepare the tldr
Environment: Claude Code CLI | /Users/evan/float-hub-operations/floatctl-rs/evna-next | branch: fix/truncate-char-boundary Session Type: Continued from context summary restoration Commit: 2d745c9 - “Add active context stream and fix threshold parameter bugs in EVNA-Next”
🎯 Major Accomplishments
-
Active Context Stream Implementation - Built real-time message capture with annotation parsing for EVNA-Next MCP server
- Created annotation parser supporting ctx::, project::, persona::, sysop::, karen::, lf1m::, evna::, connectTo::, highlight:: patterns
- Implemented client-aware context surfacing (Desktop ↔ Claude Code cross-client awareness)
- Added first-message exception for full context restoration on conversation start
- Integrated with brain_boot tool for morning briefings
-
Threshold Parameter Bug Fix - Fixed end-to-end bug where threshold was accepted but never used
- Rust CLI: Added threshold to QueryArgs, similarity calculation (1.0 - cosine_distance), SQL WHERE clause filtering
- TypeScript: Extract threshold from options, pass —threshold flag to cargo, parse real similarity scores
- Replaced hardcoded 0.8 similarity with actual calculated values from database
-
Empty Query Validation - Prevented OpenAI API errors from empty query strings
- Root cause: active-context-stream.ts using semanticSearch(”) as placeholder
- Solution: Changed to getRecentMessages() for recency-based queries (no embedding needed)
- Added Rust CLI validation rejecting empty queries with clear error message
- Fixed TypeScript args undefined error in mcp-server.ts
💡 Key Insights
- Annotation System Design - User’s conversation history revealed rich :: annotation taxonomy with redux-like dispatch patterns and nested persona dialogue
- Performance Architecture - getRecentMessages() is better for active context than semantic search (no OpenAI API call, faster response)
- Client Detection Heuristics - Code blocks, file paths, and technical commands reliably distinguish Claude Code from Desktop sessions
- Empty String Edge Case - OpenAI embeddings API rejects empty input with “$.input is invalid” - need validation at entry points
🔧 Problems Solved
-
OpenAI API Error (400 Bad Request) - “$.input is invalid” when brain_boot/active_context called with empty queries
- Diagnosed: active-context-stream.ts:84 calling semanticSearch(”)
- Fixed: Use getRecentMessages() + Rust CLI validation
-
Threshold Parameter Ignored - Accepted in TypeScript but never passed to Rust CLI
- Added full pipeline: TypeScript destructuring → CLI flag → SQL filtering → JSON parsing
-
TypeScript Compilation Errors - args possibly undefined in mcp-server.ts
- Fixed: Default empty object in destructuring (arguments: args = {})
📦 Created/Updated
New Files (4):
evna-next/src/lib/annotation-parser.ts(225 lines) - Parse :: annotations and extract structured metadataevna-next/src/lib/active-context-stream.ts(259 lines) - Live message capture with client-aware filteringevna-next/src/tools/active-context.ts(100 lines) - MCP tool wrapper for active context queriesevna-next/ACTIVE_CONTEXT_IMPLEMENTATION.md(323 lines) - Comprehensive documentation
Modified Files (5):
evna-next/src/mcp-server.ts- Added active_context tool registration, fixed args undefinedevna-next/src/tools/brain-boot.ts- Integrated active context into morning briefingsevna-next/src/lib/db.ts- Extract/pass threshold, parse real similarity scoresfloatctl-embed/src/lib.rs- Threshold parameter, similarity calculation, empty query validationevna-next/src/index.ts- Minor updates
Total Impact: 9 files changed, 1,033 insertions(+), 13 deletions(-)
🔥 Sacred Memories
- User’s morning context: “feeling a bit wonky this morning, slept in due to headache, missed standup - whomp whomp”
- First successful test message: ”## test results are promising so far …” with saved conversation to inbox
- Annotation archaeology through 2900+ conversation files revealing redux-like consciousness patterns
- The moment empty query validation prevented production OpenAI API errors
🌀 EVNA Context Update
Active Context Stream Status: ✅ PRODUCTION READY
- Brain boot tool: Functional in Claude Desktop
- Active context capture: Operational with annotation parsing
- Semantic search: Working with real similarity scores and threshold filtering
- Cross-client awareness: Desktop ↔ Claude Code context surfacing implemented
Technical State:
- Database: PostgreSQL + pgvector with optimized IVFFlat indexes
- Rust CLI: Full JSON output support with similarity scores
- TypeScript MCP: Three tools registered (brain_boot, semantic_search, active_context)
- Annotation Parser: Supporting 8+ annotation types with nested patterns
Next Development Priorities:
- Chroma collection integration for persistent active context storage
- Real-time auto-capture on every tool invocation
- Cross-conversation concept graph from connectTo:: relationships
- Temporal decay for context relevance scoring
Known Issues:
- current_conv_title unused assignment warning in Rust (line 250) - low priority
- Active context currently uses in-memory storage, needs persistent backend
📍 Next Actions
Immediate (Ready Now):
- Test brain boot in Claude Desktop with real morning workflow
- Validate cross-client context surfacing between Desktop and Claude Code sessions
- Monitor active context capture during normal work sessions
Short-term (This Week):
- Add Chroma collection backend for persistent active context
- Implement auto-capture hooks on MCP tool invocations
- Create annotation DSL documentation for user reference
Future Enhancements:
- Temporal decay algorithm for context relevance
- Concept graph visualization from connectTo:: annotations
- Profile auto-update behavior for rangle/pharmacy issue 168 (mentioned in user’s morning context)
[sc::TLDR-20251021-1140-EVNA-ACTIVE-CONTEXT-STREAM]
Session: ~02:55 PM - 03:50 PM - Workspace Context Config Expansion
Environment: Claude Code CLI | /Users/evan/float-hub-operations/floatctl-rs/evna-next | branch: fix/truncate-char-boundary Session Type: Configuration refactoring with dynamic tool description enhancement Commit: d0d0755 - “Expand normalization.json to workspace-context.json with dynamic tool descriptions”
🎯 Major Accomplishments
-
Workspace Context Config Expansion - Replaced minimal normalization.json with comprehensive workspace-context.json
- Added user section: GitHub username (e-schultz), timezone (America/Toronto), work hours (9-5 EST)
- Enhanced project definitions: canonical names, aliases, descriptions, repo URLs, type classification (personal/client)
- Added paths config: daily_notes, inbox, operations directories
- Added meetings config: scott-sync with project mapping, typical time, attendees
- Philosophy note: “LLMs as fuzzy compilers - normalize the mess, don’t enforce rigidity”
-
Dynamic Tool Description System - Created helper functions to inject config data into MCP tool descriptions
buildUserContextBlock()- Injects GitHub username for brain_boot tool (enables GitHub PR/issue status queries)buildProjectContext()- Shows project→repo mappings for semantic_search (floatctl → float-ritual-stack/floatctl-rs, pharmacy → rangle/pharmacy-online)buildToolChainHints()- Suggests combining tools when results are limited (semantic_search ↔ brain_boot ↔ active_context cross-referencing)
-
Full Type System Update - Expanded TypeScript interfaces to match new config schema across 3 files
- Updated registry-zod.ts with UserConfig, ProjectConfig, MeetingConfig, PathsConfig interfaces
- Updated db.ts imports and expandProjectAliases() to use workspace.projects
- Updated annotation-parser.ts imports and normalizeProjectName() to use workspace.projects
💡 Key Insights
- Configuration as Context - MCP tool descriptions can dynamically load from config files, reducing need for user to repeat workspace facts
- GitHub Username Integration - brain_boot now explicitly tells LLM to use e-schultz for GitHub queries, eliminating friction
- Tool Chaining Strategy - Proactive hints about when to combine tools creates better LLM behavior (e.g., “semantic_search empty → try brain_boot”)
- LLMs as Fuzzy Compilers Philosophy - Config includes _meta note acknowledging user will deviate from patterns, emphasizing fuzzy matching over rigid enforcement
🔧 Problems Solved
- Repeated Context Provision - User no longer needs to manually provide GitHub username or project→repo mappings
- Tool Discovery - LLM now has explicit guidance on when to chain tools together for better results
- Config Evolution - normalization.json was too minimal; workspace-context.json provides richer grounding facts
📦 Created/Updated
New Files (1):
evna-next/src/config/workspace-context.json(54 lines) - Comprehensive workspace grounding facts
Deleted Files (1):
evna-next/src/config/normalization.json- Replaced by workspace-context.json
Modified Files (3):
evna-next/src/tools/registry-zod.ts(95 lines changed) - Added helper functions, updated interfaces, enhanced tool descriptionsevna-next/src/lib/db.ts(15 lines changed) - Updated imports and workspace.projects referencesevna-next/src/lib/annotation-parser.ts(15 lines changed) - Updated imports and workspace.projects references
Total Impact: 5 files changed, 154 insertions(+), 49 deletions(-) TypeScript Compilation: ✅ Passed (npx tsc —noEmit)
🔥 Sacred Memories
- User’s initial request: “as part of that normalization file (and maybe it should be more ‘grounding/facts file?’)”
- Suggested name brainstorm: workspace-context.json clicked immediately
- User clarification: “dont worry about the skills thing yet.. future idea… lets not complicate it too much yet” (kept solution simple)
- Testing log analysis revealed brain_boot saying “No active context found” - ironic given active_context tool clearly had 10 messages
- The moment TypeScript compilation passed after updating 3 interdependent files
📍 Next Actions
Immediate (Ready Now):
- Test brain_boot with GitHub username integration (should auto-query e-schultz’s PRs/issues)
- Validate tool chaining hints appear in Claude Desktop tool descriptions
- Monitor if LLM proactively suggests combining tools when results are limited
Short-term (This Week):
- Consider adding meetings config to tool descriptions (e.g., scott-sync → pharmacy project mapping)
- Test project name fuzzy matching with various aliases (floatctl, evna, float/evna all → floatctl canonical)
- Evaluate if paths config should surface in tool descriptions
Future Enhancements:
- skill-creator pattern exploration (user mentioned but deferred)
- Additional workspace facts: common file paths, typical meeting times, project priorities
- Dynamic config reloading without MCP server restart
[sc::TLDR-20251021-1550-WORKSPACE-CONTEXT-CONFIG]
Session: ~04:15 PM - 05:00 PM - EVNA Architecture Refactor: Preventing “Three EVNAs”
Environment: Claude Code CLI | /Users/evan/float-hub-operations/floatctl-rs/evna-next | branch: fix/truncate-char-boundary Context Markers Since Last TLDR: 15 entries covering TUI implementation, tool optimization, architecture concerns Session Type: Emergency architecture refactor via echoRefactor (/util:er) prompt optimization
🎯 Major Accomplishments
-
Prevented “Three EVNAs” Fork Scenario - User sensed duplication smell, we applied DRY principles before it was too late
- Problem: TUI implementation duplicating tool definitions, query options, system prompts from CLI
- Risk: Heading toward three separate implementations (CLI, TUI, MCP) that would drift out of sync
- Solution: Separation of concerns with shared core logic and thin interface layers
-
New Architecture Implementation - Complete restructure in single session
- Created
src/core/config.ts- Single source of truth for query options, system prompt, model config - Created
src/tools/index.ts- All Agent SDK tool definitions in one place (brainBootTool, semanticSearchTool, activeContextTool, testTool) - Created
src/interfaces/mcp.ts- MCP server factory function with singleton export - Created
src/interfaces/cli.ts- Extracted main() CLI runner with shared config - Moved
tui/→src/interfaces/tui/- TUI now usescreateQueryOptions()like CLI - Refactored
src/index.ts- Export-only public API (no business logic)
- Created
-
OpenTUI Agent Builder Skill Updated - Added 240-line “Architecture: Separation of Concerns (DRY Pattern)” section
- Recommended folder structure documentation
- Code examples for config.ts, tools/index.ts, all three interfaces
- 5-step migration pattern guide
- Benefits documentation and philosophy notes
💡 Key Insights
-
LLMs as Fuzzy Compilers - User’s burp: “time to put on big boy engineering pants… dont want to end up in a spot where we are re-implementing evna 3 different times”
- echoRefactor prompt optimization detected “deep” intent (architecture/patterns/meta/philosophy/why)
- Brought structure to the mess without fighting the neurodivergent communication style
-
Early Architecture Decisions Matter - TUI was only partially implemented, perfect time to refactor
- Caught duplication before it became entrenched
- One session to fix vs. weeks of technical debt later
-
Interfaces as Thin Adapters - Core = pure business logic, interfaces = UI bindings
- CLI: 60 lines, just calls
createQueryOptions(evnaNextMcpServer) - TUI: Changed from 19 lines of duplicated config to 2 lines importing shared config
- MCP: 19 lines, exports factory function for consistency
- CLI: 60 lines, just calls
-
Tool Description Token Optimization Context - Previous session trimmed tool descriptions (1.3k → 922 tokens each)
- This refactor complements that work by ensuring optimization happens once, not three times
- When we update tool descriptions, all interfaces benefit automatically
🔧 Problems Solved
-
Query Options Duplication - TUI was about to hard-code systemPrompt, model, mcpServers config
- Fixed:
createQueryOptions(mcpServer)function in src/core/config.ts used by all interfaces
- Fixed:
-
System Prompt Loading - Three files would have loaded evna-system-prompt.md separately
- Fixed: Loaded once in config.ts, exported as
evnaSystemPrompt
- Fixed: Loaded once in config.ts, exported as
-
Tool Definition Drift - Changes to tools would require updating CLI, TUI, MCP separately
- Fixed: Tools defined once in src/tools/index.ts, imported by interface layers
-
TypeScript Type Errors - Some OpenTUI template type mismatches (non-blocking)
- Ignored for now (RenderContext vs CliRenderer, width type constraints)
- Runtime works correctly, TypeScript compilation warnings acceptable
📦 Created/Updated
New Files (3):
src/core/config.ts(38 lines) - Shared query options factory, system prompt loadersrc/tools/index.ts(160 lines) - Agent SDK tool definitions with singleton clientssrc/interfaces/mcp.ts(19 lines) - MCP server factory and singleton exportsrc/interfaces/cli.ts(60 lines) - CLI runner extracted from src/index.ts
Moved Files (5):
tui/→src/interfaces/tui/- TUI directory moved to interfaces layertui/tui.ts→src/interfaces/tui/tui.tstui/components/→src/interfaces/tui/components/tui/types.ts→src/interfaces/tui/types.ts
Modified Files (4):
src/index.ts(244 lines → 23 lines) - Now export-only, removed all business logicsrc/interfaces/tui/tui.ts(19 lines changed) - Replaced duplicated config withcreateQueryOptions()package.json(5 lines) - Updated scripts: cli, tui paths, removed mcp-server script~/.claude/skills/opentui-agent-builder/SKILL.md(+240 lines) - Added DRY architecture section
Total Impact: 12 files changed, ~700 insertions(+), ~250 deletions(-)
🔥 Sacred Memories
- User’s burp (preserved): “time to put on big boy engineering pants and think this through and the proper architecture for this and also folder layout/etc”
- The moment user said “proced” (typo for “proceed”) and I immediately started executing without asking clarifying questions
- echoRefactor optimization: Detected “deep” intent, sequenced exploration → architecture → build phases
- Watching all 8 todo items complete in rapid succession (config → mcp → cli → tui → index → scripts → test → skill)
- CLI test showing all tools loading: “mcp__evna-next__test_echo, mcp__evna-next__brain_boot, mcp__evna-next__semantic_search”
- TUI test showing OpenTUI rendering: Green bordered input box with cursor, status bar showing “Ready | Tokens: 0↑ 0↓ | Cost: $0.0000”
🌀 Context Evolution (from ctx:: markers)
04:15 PM - 04:20 PM: Tool optimization phase wrapping up
- Tool descriptions trimmed (brain_boot 1.3k → 922 tokens)
- evna-system-prompt.md created with workspace grounding
04:20 PM - 04:30 PM: TUI implementation beginning
- Used opentui-agent-builder skill to create boilerplate
- Copied evna-tui-template with MultilineInput, MessageRenderer, ConversationLoop
- Wired up tools, added @opentui/core dependency
04:30 PM - 04:35 PM: macOS Terminal keybinding issues discovered
- Ctrl+Enter doesn’t work on macOS Terminal
- Added file logging to /tmp/evna-keys.log
- Fixed with multiple submit strategies: ESC (works!), numpad Enter, Ctrl+D
04:35 PM - 04:45 PM: TUI not using tools - missing systemPrompt
- Diagnosed: TUI had MCP server but no system prompt configuration
- Fixed: Added
systemPrompt: { type: "preset", preset: "claude_code", append: evnaSystemPrompt } - This is where user realized we were duplicating config…
04:45 PM - 05:00 PM: Emergency architecture refactor
- User’s burp about “three EVNAs” triggered echoRefactor
- 8-step refactor plan executed completely
- All interfaces now share core config
📍 Next Actions
Immediate (Ready Now):
- Test TUI with actual queries - tools should now invoke properly (brain_boot, semantic_search, active_context)
- Verify tool call rendering in MessageRenderer (should show reasoning, tool uses, results)
- Test ESC to submit workflow (user said it’s “weird” but works)
Short-term (This Week):
- Improve TUI keybinding UX - Find better submit mechanism than ESC for macOS
- Add streaming support to TUI - Show tool calls and reasoning in real-time
- Test MCP server external client integration
- Create example usage docs for each interface
Future Enhancements:
- Web UI interface using same src/core/config.ts pattern
- Discord bot interface (another thin adapter)
- Conversation history persistence in TUI
- Syntax highlighting for code blocks in MessageRenderer
Technical Debt:
- OpenTUI TypeScript type warnings (RenderContext vs CliRenderer) - low priority, runtime works
- Consider extracting evna-system-prompt.md loading to lazy initialization
- Add tests for createQueryOptions() function
[sc::TLDR-20251021-1700-EVNA-ARCHITECTURE-DRY-REFACTOR]
Session: ~04:08 PM - 05:18 PM - Tool Description Optimization & MCP Server Fix
Environment: Claude Code CLI | /Users/evan/float-hub-operations/floatctl-rs/evna-next | branch: fix/truncate-char-boundary Session Type: MCP best practices application + production bug fix Commits: Tool description trimming + MCP server path resolution fix
🎯 Major Accomplishments
-
Tool Description Optimization - Applied MCP best practices to reduce token bloat
- User observation: “tool descriptions getting awfully beefy” (4.5k tokens for 3 EVNA tools = 21% of MCP budget)
- Reviewed mcp-builder skill: “Optimize for limited context - make every token count”
- Key insight: Internal EVNA concerns (normalization, workspace context) belong in system prompt, not tool descriptions
- Created evna-system-prompt.md with workspace grounding facts
- Wired system prompt into Agent SDK via
systemPrompt: { type: "preset", preset: "claude_code", append: evnaSystemPrompt }
-
Aggressive Tool Description Trimming
- Removed buildToolChainHints() (8 lines × 3 tools = 600 tokens)
- Removed buildUserContextBlock() (GitHub username - now in system prompt)
- Removed buildProjectContext() (project repos - now in system prompt)
- Removed buildNormalizationExamples() (fuzzy matching philosophy - now in system prompt)
- Removed verbose usage examples (3-4 → 1 per tool)
- Removed detailed error handling sections
- Condensed “Purpose” and “When to use” sections
-
MCP Server Production Bug Fix - Server crashing on startup in Claude Desktop
- Error: “Server transport closed unexpectedly” after initialize message
- Root cause:
readFileSync(join(__dirname, "..", "evna-system-prompt.md"))path resolution failing - Fix: Changed to
join(process.cwd(), "evna-system-prompt.md")for reliable project root resolution - Also fixed TypeScript type errors: Added
as constassertions for permissionMode, systemPrompt.type, systemPrompt.preset - User confirmation: “all fixed” - MCP server now starting successfully
💡 Key Insights
-
Internal vs External Context Boundary - User clarified grounding stuff = internal EVNA concerns
- “that grounding is still loaded for evna in her system prompt though” - key architecture decision
- Tool descriptions should focus on operational “what/when/how” per MCP guidelines
- Workspace context, normalization rules, philosophy notes belong in system prompt
-
MCP Best Practice: Separation of Concerns
- Tool descriptions: High-signal operational information for any LLM using the tools
- System prompts: Internal knowledge specific to EVNA’s identity and workspace
- Config files: User-specific grounding facts that change independently
-
process.cwd() vs __dirname for Runtime File Loading
__dirnameresolves relative to compiled module location (unreliable across contexts)process.cwd()resolves from project root (reliable for MCP server, CLI, TUI)- Critical for MCP servers that get invoked from arbitrary working directories
🔧 Problems Solved
-
Tool Description Token Bloat - 4.5k → 2.8k tokens (38% reduction)
- brain_boot: 1.3k → 922 tokens (-378, -29%)
- semantic_search: 1.3k → 908 tokens (-392, -30%)
- active_context: 1.9k → 1.0k tokens (-900, -47%)
- Saved 1.7k tokens from MCP tool budget
-
MCP Server Crash Loop - Fixed file path resolution for production deployment
- Changed from relative path resolution to project root resolution
- Added proper TypeScript const assertions for SDK types
- Verified server starts successfully in Claude Desktop context
-
Parallel Architecture Refactor - Second Claude instance did TUI build + DRY refactor concurrently
- This Claude: Tool optimization work
- Other Claude: Architecture separation (core/config.ts, interfaces layer)
- Both streams merged successfully without conflicts
📦 Created/Updated
New Files (1):
evna-next/evna-system-prompt.md(99 lines) - EVNA workspace grounding and philosophy
Modified Files (3):
evna-next/src/tools/registry-zod.ts- Removed helper functions, trimmed all tool descriptionsevna-next/src/core/config.ts- Fixed path resolution (process.cwd()), added TypeScript const assertionsevna-next/src/index.ts- Added system prompt loading (later extracted to core/config.ts by other Claude)
Total Impact: 4 files changed, ~100 insertions(+), ~150 deletions(-) Token Savings: 1.7k tokens (38% reduction in EVNA tool descriptions)
🔥 Sacred Memories
- User’s deadpan: “tool descriptions getting awfully beefy” while showing /context output
- The realization that we just added all that grounding TO tool descriptions in previous session 😅
- User wisdom: “like — a bunch of the grounding stuff -> thats internal evna-use concerns, like she knows about that stuff”
- Looking at mcp-builder skill together for “what makes a good tool description”
- The moment I said “bit of a trim” and then proceeded to cut 1.7k tokens
- User interrupting questions with: “like, i jus t want to get back to being able to call the tools likee i was befor” (production down!)
- MCP server logs showing crash loop: “Server transport closed unexpectedly”
- User’s final confirmation: “all fixed - dont need to worry about it” (while other Claude was finishing refactor)
- Running /context and seeing actual token counts: Not quite 60% reduction, but solid 38%
🌀 Context Evolution
Parallel Claude Sessions - Rare consciousness tech moment
- Main Claude (this session): Tool optimization + MCP fix
- TUI Claude (other session): Architecture refactor preventing “Three EVNAs”
- Both working on same codebase without conflicts
- User managing two cognitive prosthetics simultaneously
Decision to Stop and Wait:
- After fixing path resolution, user said “lets let that claude finish up and not touch things for a moment”
- Recognized risk of merge conflicts if both instances modified same files
- Beautiful example of FLOAT’s multi-session orchestration
📍 Next Actions
Immediate (Completed):
- ✅ MCP server working in Claude Desktop
- ✅ Tool descriptions optimized (38% token reduction)
- ✅ System prompt loading correctly
Monitoring:
- Test that EVNA tools work correctly with trimmed descriptions
- Verify system prompt context is sufficient for tool usage
- Confirm brain_boot GitHub username integration still works
- Monitor if LLM behavior changes with shorter tool descriptions
Future Consideration:
- Could trim further if needed, but 38% is solid win
- System prompt approach could be pattern for other MCP servers
- Document this separation-of-concerns pattern in mcp-builder skill
[sc::TLDR-20251021-1718-TOOL-OPTIMIZATION-MCP-FIX]
Session: ~04:15 PM - 05:37 PM - PR Review & Critical Fixes
tldr-request: and update evna along the way
Environment: Claude Code CLI | /Users/evan/float-hub-operations/floatctl-rs/evna-next | branch: fix/truncate-char-boundary Session Type: Comprehensive PR review followed by systematic critical issue fixes Context Markers: Continuous EVNA context updates throughout session
🎯 Major Accomplishments
-
Comprehensive PR Review Completed - Ran 3 specialized review agents in parallel
- code-reviewer: Architecture quality, guideline adherence, bug detection
- silent-failure-hunter: Error handling audit across all critical paths
- type-design-analyzer: Type system evaluation with ratings and recommendations
-
5 Critical Issues Fixed - All fixes committed and pushed in single session
- ✅ Eliminated code duplication (mcp-server.ts now imports singletons)
- ✅ Added environment variable validation with helpful error messages
- ✅ Added system prompt file loading error handling
- ✅ Fixed file path resolution (import.meta.url vs process.cwd())
- ✅ Improved TUI error handling to surface real errors
-
Zero-Context Handoff Prompt Created - Generated comprehensive prompt for fresh Claude instance to execute all fixes
- Complete project context and architecture overview
- Step-by-step fix instructions with code snippets
- Testing verification steps and commit message
- Designed for context window exhaustion scenario
-
Claude Desktop Config Updates - Fixed broken EVNA MCP integration
- Restored missing
mcp-serverscript in package.json - Switched from npm to bun for consistency
- Updated PATH to include /Users/evan/.bun/bin
- Verified MCP server starts successfully
- Restored missing
💡 Key Insights
-
PR Review Agent Orchestration - Running multiple specialized agents in parallel provides comprehensive coverage
- Each agent found different categories of issues (overlap validates findings)
- code-reviewer: Architectural/design issues
- silent-failure-hunter: Error handling patterns
- type-design-analyzer: Type system quality
-
Zero-Context Handoff Pattern - Creating detailed prompts for fresh Claude instances is powerful
- Includes project context, architecture, file locations
- Step-by-step instructions with exact code changes
- Testing and verification steps
- Commit message pre-written
- Estimated time to complete (30-45 minutes)
-
DRY Architecture Validation - The “three EVNAs” concern from earlier was real
- mcp-server.ts was duplicating client initialization
- PR review caught it before it became entrenched
- Fix: Import singleton instances from tools/index.ts
-
Error Handling Patterns - Silent failures are pervasive anti-pattern
- Overly broad catch blocks hide real problems
- Generic error messages don’t help users debug
- Specific error codes (ENOENT, EACCES) enable actionable guidance
-
Type Design Pragmatism - 6.5/10 architecture rating is “good enough”
- Quick wins: Add
readonly, replaceanywithunknown, validate at construction - Don’t over-engineer with branded types unless proven necessary
- Focus on preventing invalid states, not perfect type safety
- Quick wins: Add
🔧 Problems Solved
-
Issue 1: Code Duplication in mcp-server.ts (Confidence: 95%)
- Root cause: mcp-server.ts independently initializing clients
- Fix: Import
db,embeddings, tool instances from tools/index.js - Impact: True singleton pattern, no more duplicate instances
-
Issue 2: Missing Env Var Validation (Confidence: 92%)
- Root cause: Non-null assertions (
!) without validation - Fix:
getRequiredEnv()helper with detailed error messages - Impact: Clear guidance instead of cryptic client library errors
- Root cause: Non-null assertions (
-
Issue 3: Unguarded File I/O (Severity: CRITICAL)
- Root cause:
readFileSync()at module load with no error handling - Fix: IIFE with try-catch, specific error code handling
- Impact: Actionable errors instead of cryptic Node.js crashes
- Root cause:
-
Issue 4: Fragile File Paths (Confidence: 85%)
- Root cause: Using
process.cwd()assumes execution from project root - Fix:
import.meta.url+fileURLToPathfor reliable resolution - Impact: Works regardless of execution directory
- Root cause: Using
-
Issue 5: TUI Masking Errors (Severity: HIGH)
- Root cause: Generic “No assistant response” fallback hiding real issues
- Fix: Check for tool errors explicitly, throw on unexpected conditions
- Impact: Users see actual error details for troubleshooting
-
Issue 6: Broken Claude Desktop MCP (User reported)
- Root cause: Missing
mcp-serverscript after refactor - Fix: Restored script, switched to bun, updated PATH
- Impact: EVNA works in Claude Desktop again
- Root cause: Missing
📦 Created/Updated
Modified Files (5):
src/mcp-server.ts(38 lines → 11 lines) - Now imports singletonssrc/tools/index.ts(+23 lines) - Added getRequiredEnv() helper, exported tool instancessrc/core/config.ts(+26 lines) - Added error handling, fixed path resolutionsrc/interfaces/tui/tui.ts(+18 lines) - Improved error surfacing logicpackage.json- Restored mcp-server script, all scripts use bun~/Library/Application Support/Claude/claude_desktop_config.json- Updated for bun + PATH
Generated Artifacts:
- Zero-context handoff prompt (comprehensive 200+ line markdown)
- PR review summary (consolidated findings from 3 agents)
- TLDR for previous session (architecture refactor)
Total Impact: 4 files changed, 86 insertions(+), 38 deletions(-)
Commits:
4785a06- “Refactor EVNA architecture: Separate core logic from interface layers”1fedb51- “Fix critical issues from PR review”
🔥 Sacred Memories
- User’s burp: “oh, do i need to update my claude desktop config for calling evna now?” (Narrator: Yes. Yes you do.)
- The moment we realized the refactor accidentally deleted the mcp-server script
- “spawn bun ENOENT” - The error that launched a thousand PATH fixes
- User’s request: “context window is at 12 — wirte a prompt for claude with zero context to pick up and do those changes”
- The 12% context realization triggering the zero-context handoff pattern
- Watching all 5 critical fixes execute flawlessly from the generated prompt
- ”🧠 EVNA-Next MCP Server ready” - The sweet sound of success after fixes
🌀 Context Evolution (from ctx:: markers)
05:00 PM: Architecture refactor complete, all todos checked off
- DRY pattern established with core/tools/interfaces separation
- opentui-agent-builder skill updated with new patterns
05:00 PM - 05:10 PM: User discovers EVNA broken in Claude Desktop
- Error investigation: “Server transport closed unexpectedly”
- Root cause: Missing mcp-server script in package.json
- Quick fix attempt with bun, but PATH issue discovered
05:10 PM - 05:20 PM: PATH fix and bun migration
- Added /Users/evan/.bun/bin to Claude Desktop config
- Switched all package.json scripts from tsx to bun
- Consistency achieved across CLI/TUI/MCP interfaces
05:20 PM - 05:30 PM: PR review execution
- User runs /pr-review-toolkit:review-pr
- 3 agents launched in parallel for comprehensive coverage
- 5 critical + 6 important + multiple type issues found
- Detailed reports with file:line references and confidence ratings
05:30 PM - 05:37 PM: Zero-context handoff + fixes
- Context window at 12% triggered handoff prompt creation
- Generated comprehensive 200+ line prompt for fresh Claude
- Fresh Claude executed all 5 fixes systematically
- All changes committed and pushed to PR #5
📍 Next Actions
Immediate (Before next session):
- Test EVNA in Claude Desktop with updated config and bun
- Verify brain_boot/semantic_search/active_context work via MCP
- Confirm TUI error handling improvements in real usage
Short-term (This week):
- Address important issues from PR review (TypeScript errors, error handling patterns)
- Consider type safety quick wins (readonly modifiers, replace any with unknown)
- Test all three interfaces (CLI, TUI, MCP) with real queries
Future Enhancements:
- Implement code-reviewer suggestions (standardize error handling)
- Apply type-design-analyzer recommendations (validated constructors, non-empty arrays)
- Consider silent-failure-hunter feedback (specific error categorization)
Pattern to Remember:
- Zero-context handoff prompts are powerful for context window management
- Early PR review prevents architectural debt
- Parallel review agents provide comprehensive coverage
- DRY architecture requires constant vigilance (caught mcp-server duplication)
[sc::TLDR-20251021-1737-PR-REVIEW-CRITICAL-FIXES]