Skip to content

Cairn v1.9.0

Choose a tag to compare

@github-actions github-actions released this 15 Jun 00:06
· 1716 commits to main since this release

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 content to 1000 characters in get_project_context_pack and appends a truncation warning, prompting the agent to fetch the full note using get_note.
    • Truncates task description to 400 characters in both get_project_context_pack and search_tasks results and appends a truncation warning, prompting the agent to fetch the full task detail using get_task.
    • Ensures detailed tools (get_note, get_task) still return complete, untruncated content.
  • 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.
  • 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.ts file, routing both chat-executor and IPC live dashboard query bridge paths through the unified executeMcpTool("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.
  • Knowledge Graph Scoping Optimization: Scoped the getNeighbours and get_neighbors graph 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 toCard camelCase object instead of a raw SQLite snake_case row.
  • MCP upsert_project update path: Fixed project updates when projectId is passed, ensuring the updated project object is mapped via toProject and returned correctly.
  • Tests & Divergences: Cleaned up the known intentional divergences test block in tool-parity.test.ts, replacing them with unified shape parity assertions.

Changes

  • Switch case tool executions in electron/ipc/chat-executor.ts simplified to delegate directly to electron/mcp/tools implementations, removing massive code blocks of redundant logic.
  • Tests updated in electron/ipc/chat-executor.test.ts, electron/mcp-server.test.ts, and electron/ipc/tool-parity.test.ts to 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