search_similar_mistakes
Identify and avoid repeating writing errors by searching for similar mistakes in your manuscript to improve document quality.
Instructions
Search for similar mistakes to avoid repeating them
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | No | Path to manuscript directory (defaults to current directory) | |
| description | Yes | Description to search for similar mistakes | |
| limit | No | Maximum results |
Implementation Reference
- src/tools/WriterToolHandlers.ts:395-400 (handler)Tool handler that parses input arguments and delegates execution to WritersAid.searchSimilarMistakes
private async searchSimilarMistakes(args: Record<string, unknown>) { const description = args.description as string; const limit = (args.limit as number) || 5; return this.writersAid.searchSimilarMistakes({ description, limit }); } - Input schema definition for the MCP tool, specifying parameters like description and optional limit
{ name: "search_similar_mistakes", description: "Search for similar mistakes to avoid repeating them", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path to manuscript directory (defaults to current directory)" }, description: { type: "string", description: "Description to search for similar mistakes" }, limit: { type: "number", description: "Maximum results", default: 5 }, }, required: ["description"], }, }, - src/tools/WriterToolHandlers.ts:74-75 (registration)Registration of the tool handler in the main switch dispatcher within handleTool method
case "search_similar_mistakes": return this.searchSimilarMistakes(args); - src/memory/MistakeTracker.ts:186-213 (helper)Core helper function implementing similarity search via keyword extraction and SQL LIKE queries on the mistakes database
searchSimilarMistakes( description: string, limit = 5 ): WritingMistake[] { const keywords = description .toLowerCase() .split(/\s+/) .filter((w) => w.length > 3); if (keywords.length === 0) { return []; } // Use LIKE for basic text matching let sql = `SELECT id, session_id, file_path, line_range, mistake_type, description, correction, how_fixed, timestamp, created_at FROM writing_mistakes WHERE `; const conditions = keywords.map(() => `LOWER(description) LIKE ?`); sql += conditions.join(" OR "); sql += ` ORDER BY timestamp DESC LIMIT ?`; const params: unknown[] = keywords.map((kw) => `%${kw}%`); params.push(limit); const rows = this.db.prepare(sql).all(...params) as MistakeRow[]; return rows.map((row) => this.rowToMistake(row)); } - src/WritersAid.ts:500-518 (helper)Intermediate wrapper in WritersAid that invokes MistakeTracker and formats the response for the tool
searchSimilarMistakes(options: { description: string; limit?: number }) { const mistakes = this.mistakeTracker.searchSimilarMistakes( options.description, options.limit || 5 ); return { matches: mistakes.map((m) => ({ id: m.id, filePath: m.filePath, mistakeType: m.mistakeType, description: m.description, correction: m.correction, howFixed: m.howFixed, timestamp: new Date(m.timestamp).toISOString(), })), total: mistakes.length, }; }