fix: convert MCP query/analyze/context responses from JSON to formatted text#8
fix: convert MCP query/analyze/context responses from JSON to formatted text#8ulascanzorer wants to merge 1 commit intomainfrom
Conversation
| decisionsCount: number; | ||
| hasImplementationPlan: boolean; | ||
| }; | ||
|
|
There was a problem hiding this comment.
[blocking] Missing JSDoc. All 11 exported functions in this file need @param/@returns docstrings.
| // --------------------------------------------------------------------------- | ||
| // Context: summary | ||
| // --------------------------------------------------------------------------- | ||
|
|
There was a problem hiding this comment.
[blocking] These local types duplicate handler return shapes. Please, import from tool-handlers.ts
| critical_path: formatCriticalPath, | ||
| plannable: formatPlannableTasks, | ||
| } as const; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any |
There was a problem hiding this comment.
[blocking] as any bypasses type safety. Please consider a discriminated union on type to properly narrow result.data.
| }; | ||
|
|
||
| export function formatBlockedTasks(data: BlockedTask[]): string { | ||
| if (data.length === 0) return "# Blocked Tasks (0)\n\nNo blocked tasks."; |
There was a problem hiding this comment.
[blocking] Inconsistent empty states: plain sentences (lines 75, 107, 132) vs heading+sentence (lines 267, 285, 301). Please, pick one pattern.
- Plain sentence: lines 75, 107, 132 ("No results found.", "No tasks.", "No edges.")
- Heading + sentence: lines 267, 285, 301 ("# Blocked Tasks (0)\n\nNo blocked tasks.")
| // --------------------------------------------------------------------------- | ||
| // Query: search | ||
| // --------------------------------------------------------------------------- |
There was a problem hiding this comment.
[blocking] please remove all the inline comments
| edges: formatEdges, | ||
| overview: formatOverview, | ||
| } as const; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any |
There was a problem hiding this comment.
[blocking] same concern, lets try to avoid any
Summary
Convert
mymir_query,mymir_analyze, andmymir_context(summary depth) MCP tool responses from raw JSON to pre-formatted markdown text. Reduces token consumption by 30-50% in agent context windows. Mutation tools (mymir_project,mymir_task,mymir_edge) intentionally kept as JSON since agents need returned IDs for follow-up calls.Type of change
Testing
bun run devbun run lint)bun run typecheck)Notes for reviewer
text()helper alongside existingjson()inhelpers.tsformatters.tswith 11 formatter functions (one per response shape)analyze.ts,query.ts,context.tsupdated to use formatters instead ofjson()lib/ai/tool-handlers.tsunchanged — web app still gets structured objects