Cairn v1.9.0
What's new
Features
- Context Size Optimization for MCP Tools: Optimized context window consumption to prevent token bloat during agent orientation or task search queries:
- Truncates pinned note
contentto1000characters inget_project_context_packand appends a truncation warning, prompting the agent to fetch the full note usingget_note. - Truncates task
descriptionto400characters in bothget_project_context_packandsearch_tasksresults and appends a truncation warning, prompting the agent to fetch the full task detail usingget_task. - Ensures detailed tools (
get_note,get_task) still return complete, untruncated content.
- Truncates pinned note
- Codebase Optimization & Architecture Simplification: Extracted and consolidated duplicate database, filesystem note sync, and AI tool logic between the Electron main process and the standalone MCP server. This decoupling respects packaging and Node ABI boundaries, allowing both executors to share pure logic safely:
- Shared DB Row Mappers (
db-mappers.ts): Centralized row mappers (toWorkspace,toProject,toNote,toColumn,toCard,toTag) and JSON serialization/parsing helpers to ensure absolute data model consistency. - Unified Note File I/O (
notes-io.ts): Extracted grey-matter parsing, metadata extraction, slug directory resolution, and note modifications into a pure filesystem layer. - Pure Read Utilities (
read-tools-pure.ts): Consolidated snapshot-based read-only tool implementations (get_project_context_pack,list_ready_tasks,search_notes,search_tasks, etc.) into a shared library.
- Shared DB Row Mappers (
- Unified Tool Return Shapes: Achieved 100% output parity between desktop chat execution and the standalone MCP server, enabling a simplified AI tool delegation loop:
upsert_project: Standardized project creation and updates to return{ project, columns }uniformly.update_task: Standardized block, unblock, and restore paths to return the full task card object across all execution contexts.
- Architecture Simplification & Search Parity: Centralized and unified the workspace context and search implementations across all tools:
- Eliminated the redundant
electron/lib/context.tsfile, routing both chat-executor and IPC live dashboard query bridge paths through the unifiedexecuteMcpTool("get_cairn_context")handler. - Relocated note and task searches into pure snapshot-based functions in
read-tools-pure.ts, ensuring parity across desktop chat execution and the standalone MCP server, and removing direct SQLite query coupling from the read-tool dispatcher.
- Eliminated the redundant
- Knowledge Graph Scoping Optimization: Scoped the
getNeighboursandget_neighborsgraph tools to project-specific queries. Instead of loading the entire workspace graph for N-hop traversal requests, they now only load records from the project(s) connected to the query node, reducing database query overhead.
Fixes
- Chat Executor Tool Loop: Resolved a compilation and Vite OXC parser error at the end of chat-executor.ts caused by duplicate closing brackets and switch cases.
- MCP update_task restore behavior: Fixed the restored task card return path to return the mapped
toCardcamelCase object instead of a raw SQLite snake_case row. - MCP upsert_project update path: Fixed project updates when
projectIdis passed, ensuring the updated project object is mapped viatoProjectand returned correctly. - Tests & Divergences: Cleaned up the
known intentional divergencestest block in tool-parity.test.ts, replacing them with unified shape parity assertions.
Changes
- Switch case tool executions in
electron/ipc/chat-executor.tssimplified to delegate directly toelectron/mcp/toolsimplementations, removing massive code blocks of redundant logic. - Tests updated in
electron/ipc/chat-executor.test.ts,electron/mcp-server.test.ts, andelectron/ipc/tool-parity.test.tsto assert shape parity.
Changed files
| File | Change |
|---|---|
electron/shared/db-mappers.ts |
[NEW] Decoupled DB mappers and parse/serialize helpers |
electron/shared/notes-io.ts |
[NEW] Pure filesystem note utilities and frontmatter parser |
electron/shared/read-tools-pure.ts |
[NEW] Pure snapshot-based read tools and project context packs. Added pure executeSearchNotes and executeSearchTasks helpers. |
electron/lib/context.ts |
[DELETE] Removed redundant file (logic consolidated into getCairnContext) |
electron/db/queries.ts |
Refactored to import mappers and parsers from db-mappers.ts |
electron/db/graph-queries.ts |
Scoped getNeighbours traversal queries by project to optimize performance |
electron/ipc/chat-executor.ts |
Simplified switch block, delegated get_cairn_context and write tools to MCP tools, fixed duplicate switch brackets |
electron/ipc/handlers.ts |
Updated db:mcpQuery to delegate get_cairn_context to MCP tools |
electron/ipc/handlers.test.ts |
Replaced obsolete buildContextResponse test block with get_cairn_context tool executor tests |
electron/ipc/tool-parity.test.ts |
Replaced divergence assertions with tool shape parity checks |
electron/lib/read-tools.ts |
Delegated read and search operations to read-tools-pure.ts |
electron/mcp-server.test.ts |
Updated tests for return shapes and added truncation/search assertions |
electron/mcp/db.ts |
Decoupled from direct node path/FS utilities, imported from db-mappers.ts and notes-io.ts |
electron/mcp/tools/metadata.ts |
Delegated context pack reads to read-tools-pure.ts |
electron/mcp/tools/projects.ts |
Mapped results using toProject and returned { project, columns } for all paths |
electron/mcp/tools/tasks.ts |
Delegated search_tasks to pure read utilities |
electron/mcp/tools/notes.ts |
Delegated search_notes to pure read utilities |
electron/mcp/tools/graph.ts |
Scoped get_neighbors traversal queries by project to optimize performance |
electron/notes-files.ts |
Decoupled from queries.ts by using newId from utils and importing generic file I/O from notes-io.ts |