refactor(chatTools): split 3412-line monolith into focused modules

↗ view on GitHub · Amal · 2026-05-24 · abe78b7d

chatTools.ts was a 3412-line file mixing static constants, types, context
builders, and tool execution. Now split into three focused files so each
concern is navigable and independently testable:

- lib/chatToolDefs.ts  - static constants + shared types (SYSTEM_PROMPT,
  TOOLS, PROJECT_EXTRA_TOOLS, TABULAR_TOOLS, WORKFLOW_TOOLS, DocStore,
  WorkflowStore, DocIndex, ToolCall, ChatMessage)
- lib/chatContext.ts   - chat context builders (buildMessages,
  enrichWithPriorEvents, buildDocContext, buildProjectDocContext,
  buildWorkflowStore, generateSpotlightNonce)
- lib/chatTools.ts     - runtime tool execution, down to 2604 lines;
  re-exports everything from both sub-modules so no callers changed

All 128 tests pass, zero type errors.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Repository amal66/mike
Author Amal <mamalanand3@gmail.com>
Authored
Parents 97b37ca4
Stats 3 files changed , +974 , -863
Part of Decompose the chat-tools monolith

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-abe78b7d.md from inside the repo you want the change in.

⬇ Download capture-commit-abe78b7d.md