claude-conversation-memory-mcp 0.6.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +53 -0
  2. package/dist/ConversationMemory.d.ts +151 -10
  3. package/dist/ConversationMemory.d.ts.map +1 -1
  4. package/dist/ConversationMemory.js +127 -10
  5. package/dist/ConversationMemory.js.map +1 -1
  6. package/dist/cache/QueryCache.d.ts +215 -0
  7. package/dist/cache/QueryCache.d.ts.map +1 -0
  8. package/dist/cache/QueryCache.js +294 -0
  9. package/dist/cache/QueryCache.js.map +1 -0
  10. package/dist/mcp-server.d.ts.map +1 -1
  11. package/dist/mcp-server.js +4 -1
  12. package/dist/mcp-server.js.map +1 -1
  13. package/dist/parsers/ConversationParser.d.ts +62 -3
  14. package/dist/parsers/ConversationParser.d.ts.map +1 -1
  15. package/dist/parsers/ConversationParser.js +50 -3
  16. package/dist/parsers/ConversationParser.js.map +1 -1
  17. package/dist/parsers/DecisionExtractor.d.ts +61 -3
  18. package/dist/parsers/DecisionExtractor.d.ts.map +1 -1
  19. package/dist/parsers/DecisionExtractor.js +47 -3
  20. package/dist/parsers/DecisionExtractor.js.map +1 -1
  21. package/dist/parsers/GitIntegrator.d.ts +88 -3
  22. package/dist/parsers/GitIntegrator.d.ts.map +1 -1
  23. package/dist/parsers/GitIntegrator.js +68 -3
  24. package/dist/parsers/GitIntegrator.js.map +1 -1
  25. package/dist/parsers/MistakeExtractor.d.ts +62 -3
  26. package/dist/parsers/MistakeExtractor.d.ts.map +1 -1
  27. package/dist/parsers/MistakeExtractor.js +50 -3
  28. package/dist/parsers/MistakeExtractor.js.map +1 -1
  29. package/dist/parsers/RequirementsExtractor.d.ts +95 -4
  30. package/dist/parsers/RequirementsExtractor.d.ts.map +1 -1
  31. package/dist/parsers/RequirementsExtractor.js +73 -4
  32. package/dist/parsers/RequirementsExtractor.js.map +1 -1
  33. package/dist/storage/BackupManager.d.ts +58 -0
  34. package/dist/storage/BackupManager.d.ts.map +1 -0
  35. package/dist/storage/BackupManager.js +213 -0
  36. package/dist/storage/BackupManager.js.map +1 -0
  37. package/dist/storage/ConversationStorage.d.ts +271 -2
  38. package/dist/storage/ConversationStorage.d.ts.map +1 -1
  39. package/dist/storage/ConversationStorage.js +356 -7
  40. package/dist/storage/ConversationStorage.js.map +1 -1
  41. package/dist/storage/DeletionService.d.ts +70 -0
  42. package/dist/storage/DeletionService.d.ts.map +1 -0
  43. package/dist/storage/DeletionService.js +198 -0
  44. package/dist/storage/DeletionService.js.map +1 -0
  45. package/dist/tools/ToolDefinitions.d.ts +26 -0
  46. package/dist/tools/ToolDefinitions.d.ts.map +1 -1
  47. package/dist/tools/ToolDefinitions.js +24 -0
  48. package/dist/tools/ToolDefinitions.js.map +1 -1
  49. package/dist/tools/ToolHandlers.d.ts +564 -16
  50. package/dist/tools/ToolHandlers.d.ts.map +1 -1
  51. package/dist/tools/ToolHandlers.js +664 -24
  52. package/dist/tools/ToolHandlers.js.map +1 -1
  53. package/dist/types/ToolTypes.d.ts +22 -0
  54. package/dist/types/ToolTypes.d.ts.map +1 -1
  55. package/dist/utils/Logger.d.ts +67 -0
  56. package/dist/utils/Logger.d.ts.map +1 -0
  57. package/dist/utils/Logger.js +119 -0
  58. package/dist/utils/Logger.js.map +1 -0
  59. package/dist/utils/constants.d.ts +75 -0
  60. package/dist/utils/constants.d.ts.map +1 -0
  61. package/dist/utils/constants.js +105 -0
  62. package/dist/utils/constants.js.map +1 -0
  63. package/package.json +1 -1
@@ -1,70 +1,618 @@
1
1
  /**
2
- * MCP Tool Handlers - Implementation of all 13 tools (including migration)
2
+ * MCP Tool Handlers - Implementation of all 13 tools for the conversation-memory MCP server.
3
+ *
4
+ * This class provides the implementation for all MCP (Model Context Protocol) tools
5
+ * that allow Claude to interact with conversation history and memory.
6
+ *
7
+ * Tools are organized into categories:
8
+ * - Indexing: index_conversations
9
+ * - Search: search_conversations, searchDecisions, search_mistakes
10
+ * - File Context: check_before_modify, get_file_evolution
11
+ * - History: get_tool_history, link_commits_to_conversations
12
+ * - Discovery: find_similar_sessions, get_requirements
13
+ * - Recall: recall_and_apply
14
+ * - Documentation: generate_documentation
15
+ * - Migration: discover_old_conversations, migrate_project
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const handlers = new ToolHandlers(memory, db, '/path/to/projects');
20
+ * const result = await handlers.indexConversations({
21
+ * project_path: '/Users/me/my-project'
22
+ * });
23
+ * ```
3
24
  */
4
25
  import { ConversationMemory } from "../ConversationMemory.js";
5
26
  import type { SQLiteManager } from "../storage/SQLiteManager.js";
6
27
  import type * as Types from "../types/ToolTypes.js";
28
+ /**
29
+ * Tool handlers for the conversation-memory MCP server.
30
+ *
31
+ * Provides methods for indexing, searching, and managing conversation history.
32
+ */
7
33
  export declare class ToolHandlers {
8
34
  private memory;
9
35
  private db;
10
36
  private migration;
37
+ /**
38
+ * Create a new ToolHandlers instance.
39
+ *
40
+ * @param memory - ConversationMemory instance for core operations
41
+ * @param db - SQLiteManager for database access
42
+ * @param projectsDir - Optional directory for storing project data
43
+ */
11
44
  constructor(memory: ConversationMemory, db: SQLiteManager, projectsDir?: string);
12
45
  /**
13
- * Tool 1: index_conversations
46
+ * Index conversation history for a project.
47
+ *
48
+ * Parses conversation files from Claude Code's conversation history, extracts
49
+ * decisions, mistakes, and requirements, links git commits, and generates
50
+ * semantic embeddings for search.
51
+ *
52
+ * @param args - Indexing arguments:
53
+ * - `project_path`: Path to the project (defaults to cwd)
54
+ * - `session_id`: Optional specific session to index
55
+ * - `include_thinking`: Include thinking blocks (default: false)
56
+ * - `enable_git`: Enable git integration (default: true)
57
+ * - `exclude_mcp_conversations`: Exclude MCP tool conversations (default: 'self-only')
58
+ * - `exclude_mcp_servers`: List of specific MCP servers to exclude
59
+ *
60
+ * @returns Result containing:
61
+ * - `success`: Whether indexing succeeded
62
+ * - `stats`: Counts of conversations, messages, decisions, etc.
63
+ * - `indexed_folders`: List of folders that were indexed
64
+ * - `database_path`: Path to the SQLite database
65
+ * - `embeddings_generated`: Whether embeddings were created
66
+ * - `embedding_error`: Error message if embeddings failed
67
+ * - `message`: Human-readable status message
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const result = await handlers.indexConversations({
72
+ * project_path: '/Users/me/my-project',
73
+ * enable_git: true,
74
+ * exclude_mcp_conversations: 'self-only'
75
+ * });
76
+ * console.log(result.message); // "Indexed 5 conversation(s) with 245 messages..."
77
+ * ```
14
78
  */
15
79
  indexConversations(args: Record<string, unknown>): Promise<Types.IndexConversationsResponse>;
16
80
  /**
17
- * Tool 2: search_conversations
81
+ * Search conversation history using natural language queries.
82
+ *
83
+ * Uses semantic search with embeddings if available, otherwise falls back
84
+ * to full-text search. Returns relevant messages with context and similarity scores.
85
+ *
86
+ * @param args - Search arguments:
87
+ * - `query`: Natural language search query (required)
88
+ * - `limit`: Maximum number of results (default: 10)
89
+ * - `date_range`: Optional [start_timestamp, end_timestamp] filter
90
+ *
91
+ * @returns Search results containing:
92
+ * - `query`: The search query used
93
+ * - `results`: Array of matching messages with:
94
+ * - `conversation_id`: Conversation containing the message
95
+ * - `message_id`: Message identifier
96
+ * - `timestamp`: When the message was created
97
+ * - `similarity`: Relevance score (0-1)
98
+ * - `snippet`: Text excerpt from the message
99
+ * - `git_branch`: Git branch at the time
100
+ * - `message_type`: Type of message
101
+ * - `role`: Message role (user/assistant)
102
+ * - `total_found`: Number of results returned
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const result = await handlers.searchConversations({
107
+ * query: 'authentication bug fix',
108
+ * limit: 5
109
+ * });
110
+ * result.results.forEach(r => {
111
+ * console.log(`${r.similarity.toFixed(2)}: ${r.snippet}`);
112
+ * });
113
+ * ```
18
114
  */
19
115
  searchConversations(args: Record<string, unknown>): Promise<Types.SearchConversationsResponse>;
20
116
  /**
21
- * Tool 3: get_decisions
117
+ * Find decisions made about a specific topic, file, or component.
118
+ *
119
+ * Searches through extracted decisions to find relevant architectural choices,
120
+ * technical decisions, and their rationale. Shows alternatives considered and
121
+ * rejected approaches.
122
+ *
123
+ * @param args - Decision search arguments:
124
+ * - `query`: Topic or keyword to search for (required)
125
+ * - `file_path`: Optional filter for decisions related to a specific file
126
+ * - `limit`: Maximum number of results (default: 10)
127
+ *
128
+ * @returns Decision search results containing:
129
+ * - `query`: The search query used
130
+ * - `file_path`: File filter if applied
131
+ * - `decisions`: Array of matching decisions with:
132
+ * - `decision_id`: Decision identifier
133
+ * - `decision_text`: The decision that was made
134
+ * - `rationale`: Why this decision was made
135
+ * - `alternatives_considered`: Other options that were considered
136
+ * - `rejected_reasons`: Why alternatives were rejected
137
+ * - `context`: Context in which the decision was made
138
+ * - `related_files`: Files affected by this decision
139
+ * - `related_commits`: Git commits implementing this decision
140
+ * - `timestamp`: When the decision was made
141
+ * - `similarity`: Relevance score
142
+ * - `total_found`: Number of decisions returned
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * const result = await handlers.getDecisions({
147
+ * query: 'database',
148
+ * file_path: 'src/storage/SQLiteManager.ts',
149
+ * limit: 5
150
+ * });
151
+ * result.decisions.forEach(d => {
152
+ * console.log(`Decision: ${d.decision_text}`);
153
+ * console.log(`Rationale: ${d.rationale}`);
154
+ * });
155
+ * ```
22
156
  */
23
157
  getDecisions(args: Record<string, unknown>): Promise<Types.GetDecisionsResponse>;
24
158
  /**
25
- * Tool 4: check_before_modify
159
+ * Check important context before modifying a file.
160
+ *
161
+ * Shows recent changes, related decisions, commits, and past mistakes to avoid
162
+ * when working on a file. Use this before making significant changes to understand
163
+ * the file's history and context.
164
+ *
165
+ * @param args - Check arguments:
166
+ * - `file_path`: Path to the file you want to modify (required)
167
+ *
168
+ * @returns Context information containing:
169
+ * - `file_path`: The file being checked
170
+ * - `warning`: Warning message if important context found
171
+ * - `recent_changes`: Recent edits and commits to this file
172
+ * - `edits`: Recent file edits with timestamps and conversation IDs
173
+ * - `commits`: Recent git commits affecting this file
174
+ * - `related_decisions`: Decisions that affect this file
175
+ * - `mistakes_to_avoid`: Past mistakes related to this file
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * const context = await handlers.checkBeforeModify({
180
+ * file_path: 'src/storage/SQLiteManager.ts'
181
+ * });
182
+ * console.log(context.warning);
183
+ * console.log(`${context.related_decisions.length} decisions affect this file`);
184
+ * console.log(`${context.mistakes_to_avoid.length} mistakes to avoid`);
185
+ * ```
26
186
  */
27
187
  checkBeforeModify(args: Record<string, unknown>): Promise<Types.CheckBeforeModifyResponse>;
28
188
  /**
29
- * Tool 5: get_file_evolution
189
+ * Show complete timeline of changes to a file.
190
+ *
191
+ * Returns a chronological timeline of all edits, commits, and related decisions
192
+ * for a specific file across all conversations and git history.
193
+ *
194
+ * @param args - Evolution arguments:
195
+ * - `file_path`: Path to the file (required)
196
+ * - `include_decisions`: Include related decisions (default: true)
197
+ * - `include_commits`: Include git commits (default: true)
198
+ *
199
+ * @returns File evolution timeline containing:
200
+ * - `file_path`: The file being analyzed
201
+ * - `total_edits`: Total number of edits to this file
202
+ * - `timeline`: Chronological array of events (most recent first):
203
+ * - `type`: Event type ('edit', 'commit', or 'decision')
204
+ * - `timestamp`: When the event occurred
205
+ * - `data`: Event-specific data (conversation_id, commit hash, decision text, etc.)
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * const evolution = await handlers.getFileEvolution({
210
+ * file_path: 'src/index.ts',
211
+ * include_decisions: true,
212
+ * include_commits: true
213
+ * });
214
+ * console.log(`${evolution.total_edits} edits across ${evolution.timeline.length} events`);
215
+ * evolution.timeline.forEach(event => {
216
+ * console.log(`${event.timestamp}: ${event.type}`);
217
+ * });
218
+ * ```
30
219
  */
31
220
  getFileEvolution(args: Record<string, unknown>): Promise<Types.GetFileEvolutionResponse>;
32
221
  /**
33
- * Tool 6: link_commits_to_conversations
222
+ * Link git commits to the conversations where they were made or discussed.
223
+ *
224
+ * Finds git commits that are associated with specific conversations, showing
225
+ * which code changes were made during which conversations. Helps answer "WHY
226
+ * was this code changed?"
227
+ *
228
+ * @param args - Link arguments:
229
+ * - `query`: Optional search query for commit messages
230
+ * - `conversation_id`: Optional filter for specific conversation
231
+ * - `limit`: Maximum number of commits (default: 20)
232
+ *
233
+ * @returns Commit links containing:
234
+ * - `query`: Search query if provided
235
+ * - `conversation_id`: Conversation filter if provided
236
+ * - `commits`: Array of linked commits with:
237
+ * - `hash`: Short commit hash (7 chars)
238
+ * - `full_hash`: Full commit hash
239
+ * - `message`: Commit message
240
+ * - `author`: Commit author
241
+ * - `timestamp`: When commit was made
242
+ * - `branch`: Git branch
243
+ * - `files_changed`: List of files changed
244
+ * - `conversation_id`: Conversation where this was discussed/made
245
+ * - `total_found`: Number of commits returned
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * const links = await handlers.linkCommitsToConversations({
250
+ * query: 'fix authentication',
251
+ * limit: 10
252
+ * });
253
+ * links.commits.forEach(c => {
254
+ * console.log(`${c.hash}: ${c.message}`);
255
+ * console.log(` Conversation: ${c.conversation_id}`);
256
+ * });
257
+ * ```
34
258
  */
35
259
  linkCommitsToConversations(args: Record<string, unknown>): Promise<Types.LinkCommitsToConversationsResponse>;
36
260
  /**
37
- * Tool 7: search_mistakes
261
+ * Find past mistakes to avoid repeating them.
262
+ *
263
+ * Searches through extracted mistakes to find documented errors, bugs, and
264
+ * wrong approaches. Shows what went wrong and how it was corrected.
265
+ *
266
+ * @param args - Mistake search arguments:
267
+ * - `query`: Search query for mistakes (required)
268
+ * - `mistake_type`: Optional filter by type (logic_error, wrong_approach, misunderstanding, tool_error, syntax_error)
269
+ * - `limit`: Maximum number of results (default: 10)
270
+ *
271
+ * @returns Mistake search results containing:
272
+ * - `query`: Search query used
273
+ * - `mistake_type`: Type filter if applied
274
+ * - `mistakes`: Array of matching mistakes with:
275
+ * - `mistake_id`: Mistake identifier
276
+ * - `mistake_type`: Type of mistake
277
+ * - `what_went_wrong`: Description of the mistake
278
+ * - `correction`: How it was fixed
279
+ * - `user_correction_message`: User's correction message if available
280
+ * - `files_affected`: List of files involved
281
+ * - `timestamp`: When the mistake occurred
282
+ * - `total_found`: Number of mistakes returned
283
+ *
284
+ * @example
285
+ * ```typescript
286
+ * const mistakes = await handlers.searchMistakes({
287
+ * query: 'database transaction',
288
+ * mistake_type: 'logic_error',
289
+ * limit: 5
290
+ * });
291
+ * mistakes.mistakes.forEach(m => {
292
+ * console.log(`${m.mistake_type}: ${m.what_went_wrong}`);
293
+ * console.log(`Fix: ${m.correction}`);
294
+ * });
295
+ * ```
38
296
  */
39
297
  searchMistakes(args: Record<string, unknown>): Promise<Types.SearchMistakesResponse>;
40
298
  /**
41
- * Tool 8: get_requirements
299
+ * Look up requirements and constraints for a component or feature.
300
+ *
301
+ * Finds documented requirements, dependencies, performance constraints, and
302
+ * compatibility requirements that affect a component or feature.
303
+ *
304
+ * @param args - Requirements search arguments:
305
+ * - `component`: Component or feature name (required)
306
+ * - `type`: Optional filter by requirement type (dependency, performance, compatibility, business)
307
+ *
308
+ * @returns Requirements results containing:
309
+ * - `component`: Component searched
310
+ * - `type`: Type filter if applied
311
+ * - `requirements`: Array of matching requirements with:
312
+ * - `requirement_id`: Requirement identifier
313
+ * - `type`: Requirement type
314
+ * - `description`: Requirement description
315
+ * - `rationale`: Why this requirement exists
316
+ * - `affects_components`: List of affected components
317
+ * - `timestamp`: When requirement was documented
318
+ * - `total_found`: Number of requirements returned
319
+ *
320
+ * @example
321
+ * ```typescript
322
+ * const reqs = await handlers.getRequirements({
323
+ * component: 'authentication',
324
+ * type: 'security'
325
+ * });
326
+ * reqs.requirements.forEach(r => {
327
+ * console.log(`${r.type}: ${r.description}`);
328
+ * console.log(`Rationale: ${r.rationale}`);
329
+ * });
330
+ * ```
42
331
  */
43
332
  getRequirements(args: Record<string, unknown>): Promise<Types.GetRequirementsResponse>;
44
333
  /**
45
- * Tool 9: get_tool_history
334
+ * Query history of tool uses (bash commands, file edits, reads, etc.).
335
+ *
336
+ * Shows what tools were used during conversations and their results. Useful
337
+ * for understanding what commands were run, what files were edited, and
338
+ * whether operations succeeded or failed.
339
+ *
340
+ * @param args - Tool history arguments:
341
+ * - `tool_name`: Optional filter by tool name (Bash, Edit, Write, Read)
342
+ * - `file_path`: Optional filter by file path
343
+ * - `limit`: Maximum number of results (default: 20)
344
+ *
345
+ * @returns Tool history containing:
346
+ * - `tool_name`: Tool filter if applied
347
+ * - `file_path`: File filter if applied
348
+ * - `tool_uses`: Array of tool uses with:
349
+ * - `tool_use_id`: Tool use identifier
350
+ * - `tool_name`: Name of the tool used
351
+ * - `tool_input`: Input parameters to the tool
352
+ * - `result`: Tool execution result with:
353
+ * - `content`: Result content
354
+ * - `is_error`: Whether the tool failed
355
+ * - `stdout`: Standard output (for Bash)
356
+ * - `stderr`: Standard error (for Bash)
357
+ * - `timestamp`: When the tool was used
358
+ * - `total_found`: Number of tool uses returned
359
+ *
360
+ * @example
361
+ * ```typescript
362
+ * const history = await handlers.getToolHistory({
363
+ * tool_name: 'Bash',
364
+ * limit: 10
365
+ * });
366
+ * history.tool_uses.forEach(t => {
367
+ * console.log(`${t.tool_name}: ${JSON.stringify(t.tool_input)}`);
368
+ * console.log(`Success: ${!t.result.is_error}`);
369
+ * });
370
+ * ```
46
371
  */
47
372
  getToolHistory(args: Record<string, unknown>): Promise<Types.GetToolHistoryResponse>;
48
373
  /**
49
- * Tool 10: find_similar_sessions
374
+ * Find conversations that dealt with similar topics or problems.
375
+ *
376
+ * Searches across all conversations to find ones that discussed similar topics,
377
+ * allowing you to learn from past work on similar problems.
378
+ *
379
+ * @param args - Similarity search arguments:
380
+ * - `query`: Description of the topic or problem (required)
381
+ * - `limit`: Maximum number of sessions (default: 5)
382
+ *
383
+ * @returns Similar sessions containing:
384
+ * - `query`: Search query used
385
+ * - `sessions`: Array of similar conversation sessions with:
386
+ * - `conversation_id`: Session identifier
387
+ * - `project_path`: Project path for this session
388
+ * - `first_message_at`: When the conversation started
389
+ * - `message_count`: Number of messages in the conversation
390
+ * - `git_branch`: Git branch at the time
391
+ * - `relevance_score`: Similarity score to the query
392
+ * - `relevant_messages`: Sample of relevant messages from this session
393
+ * - `total_found`: Number of sessions returned
394
+ *
395
+ * @example
396
+ * ```typescript
397
+ * const similar = await handlers.findSimilarSessions({
398
+ * query: 'implementing user authentication with JWT',
399
+ * limit: 3
400
+ * });
401
+ * similar.sessions.forEach(s => {
402
+ * console.log(`Session ${s.conversation_id} (${s.message_count} messages)`);
403
+ * console.log(`Relevance: ${s.relevance_score.toFixed(2)}`);
404
+ * console.log(`Messages: ${s.relevant_messages.length} relevant`);
405
+ * });
406
+ * ```
50
407
  */
51
408
  findSimilarSessions(args: Record<string, unknown>): Promise<Types.FindSimilarSessionsResponse>;
52
409
  /**
53
- * Tool 11: recall_and_apply
54
- * Recall relevant context and format for application to current work
410
+ * Recall relevant context and format for application to current work.
411
+ *
412
+ * This is a comprehensive context retrieval tool that searches across multiple
413
+ * data sources (conversations, decisions, mistakes, file changes, commits) and
414
+ * returns actionable suggestions for applying historical context to current work.
415
+ *
416
+ * @param args - Recall arguments:
417
+ * - `query`: What you're working on or need context for (required)
418
+ * - `context_types`: Types to recall (default: all types)
419
+ * - Options: "conversations", "decisions", "mistakes", "file_changes", "commits"
420
+ * - `file_path`: Optional filter for file-specific context
421
+ * - `date_range`: Optional [start_timestamp, end_timestamp] filter
422
+ * - `limit`: Maximum items per context type (default: 5)
423
+ *
424
+ * @returns Recalled context containing:
425
+ * - `query`: Search query used
426
+ * - `context_summary`: High-level summary of what was found
427
+ * - `recalled_context`: Structured context data:
428
+ * - `conversations`: Relevant past conversations
429
+ * - `decisions`: Related decisions with rationale
430
+ * - `mistakes`: Past mistakes to avoid
431
+ * - `file_changes`: File modification history
432
+ * - `commits`: Related git commits
433
+ * - `application_suggestions`: Actionable suggestions for applying this context
434
+ * - `total_items_found`: Total number of context items found
435
+ *
436
+ * @example
437
+ * ```typescript
438
+ * const context = await handlers.recallAndApply({
439
+ * query: 'refactoring database connection pooling',
440
+ * context_types: ['decisions', 'mistakes', 'commits'],
441
+ * file_path: 'src/database/pool.ts',
442
+ * limit: 5
443
+ * });
444
+ * console.log(context.context_summary);
445
+ * context.application_suggestions.forEach(s => console.log(`- ${s}`));
446
+ * ```
55
447
  */
56
448
  recallAndApply(args: Record<string, unknown>): Promise<Types.RecallAndApplyResponse>;
57
449
  /**
58
- * Tool 12: generate_documentation
450
+ * Generate comprehensive project documentation by combining codebase analysis
451
+ * with conversation history.
452
+ *
453
+ * Creates documentation that shows WHAT exists in the code (via CODE-GRAPH-RAG-MCP)
454
+ * and WHY it was built that way (via conversation history). Requires CODE-GRAPH-RAG-MCP
455
+ * to be indexed first.
456
+ *
457
+ * @param args - Documentation generation arguments:
458
+ * - `project_path`: Path to the project (defaults to cwd)
459
+ * - `session_id`: Optional specific session to include
460
+ * - `scope`: Documentation scope (default: 'full')
461
+ * - 'full': Everything (architecture, decisions, quality)
462
+ * - 'architecture': Module structure and dependencies
463
+ * - 'decisions': Decision log with rationale
464
+ * - 'quality': Code quality insights
465
+ * - `module_filter`: Optional filter for specific module path (e.g., 'src/auth')
466
+ *
467
+ * @returns Documentation result containing:
468
+ * - `success`: Whether generation succeeded
469
+ * - `project_path`: Project that was documented
470
+ * - `scope`: Scope of documentation generated
471
+ * - `documentation`: Generated markdown documentation
472
+ * - `statistics`: Summary statistics:
473
+ * - `modules`: Number of modules documented
474
+ * - `decisions`: Number of decisions included
475
+ * - `mistakes`: Number of mistakes documented
476
+ * - `commits`: Number of commits referenced
477
+ *
478
+ * @example
479
+ * ```typescript
480
+ * const doc = await handlers.generateDocumentation({
481
+ * project_path: '/Users/me/my-project',
482
+ * scope: 'full',
483
+ * module_filter: 'src/auth'
484
+ * });
485
+ * console.log(doc.documentation); // Markdown documentation
486
+ * console.log(`Documented ${doc.statistics.modules} modules`);
487
+ * ```
59
488
  */
60
489
  generateDocumentation(args: Record<string, unknown>): Promise<Types.GenerateDocumentationResponse>;
61
490
  /**
62
- * Tool 12: discover_old_conversations
491
+ * Discover old conversation folders that might contain conversation history
492
+ * for the current project.
493
+ *
494
+ * Searches through stored conversation folders to find potential matches for
495
+ * the current project path. Useful when project paths have changed (e.g., after
496
+ * moving or renaming a project directory).
497
+ *
498
+ * @param args - Discovery arguments:
499
+ * - `current_project_path`: Current project path (defaults to cwd)
500
+ *
501
+ * @returns Discovery results containing:
502
+ * - `success`: Whether discovery succeeded
503
+ * - `current_project_path`: Current project path searched for
504
+ * - `candidates`: Array of potential matches sorted by score:
505
+ * - `folder_name`: Name of the conversation folder
506
+ * - `folder_path`: Full path to the folder
507
+ * - `stored_project_path`: Original project path stored in conversations
508
+ * - `score`: Match score (higher is better match)
509
+ * - `stats`: Folder statistics:
510
+ * - `conversations`: Number of conversations in folder
511
+ * - `messages`: Number of messages in folder
512
+ * - `files`: Number of .jsonl files
513
+ * - `last_activity`: Timestamp of last activity
514
+ * - `message`: Human-readable status message
515
+ *
516
+ * @example
517
+ * ```typescript
518
+ * const discovery = await handlers.discoverOldConversations({
519
+ * current_project_path: '/Users/me/projects/my-app'
520
+ * });
521
+ * console.log(discovery.message);
522
+ * discovery.candidates.forEach(c => {
523
+ * console.log(`Score ${c.score}: ${c.folder_name}`);
524
+ * console.log(` Original path: ${c.stored_project_path}`);
525
+ * console.log(` Stats: ${c.stats.conversations} conversations, ${c.stats.files} files`);
526
+ * });
527
+ * ```
63
528
  */
64
529
  discoverOldConversations(args: Record<string, unknown>): Promise<Types.DiscoverOldConversationsResponse>;
65
530
  /**
66
- * Tool 13: migrate_project
531
+ * Migrate or merge conversation history from an old project path to a new one.
532
+ *
533
+ * Use this when a project has been moved or renamed to bring the conversation
534
+ * history along. Supports two modes: 'migrate' (move all files) or 'merge'
535
+ * (combine with existing files).
536
+ *
537
+ * @param args - Migration arguments:
538
+ * - `source_folder`: Source folder containing old conversations (required)
539
+ * - `old_project_path`: Original project path in the conversations (required)
540
+ * - `new_project_path`: New project path to update to (required)
541
+ * - `dry_run`: Preview changes without applying them (default: false)
542
+ * - `mode`: Migration mode (default: 'migrate')
543
+ * - 'migrate': Move all files from source to target
544
+ * - 'merge': Combine source files with existing target files
545
+ *
546
+ * @returns Migration result containing:
547
+ * - `success`: Whether migration succeeded
548
+ * - `source_folder`: Source folder path
549
+ * - `target_folder`: Target folder path (where files were copied)
550
+ * - `files_copied`: Number of files copied/migrated
551
+ * - `database_updated`: Whether database was updated with new paths
552
+ * - `backup_created`: Whether backup was created (always true for non-dry-run)
553
+ * - `message`: Human-readable status message
554
+ *
555
+ * @example
556
+ * ```typescript
557
+ * // First, preview with dry run
558
+ * const preview = await handlers.migrateProject({
559
+ * source_folder: '/path/to/old/conversations',
560
+ * old_project_path: '/old/path/to/project',
561
+ * new_project_path: '/new/path/to/project',
562
+ * dry_run: true
563
+ * });
564
+ * console.log(preview.message); // "Dry run: Would migrate X files..."
565
+ *
566
+ * // Then, execute the migration
567
+ * const result = await handlers.migrateProject({
568
+ * source_folder: '/path/to/old/conversations',
569
+ * old_project_path: '/old/path/to/project',
570
+ * new_project_path: '/new/path/to/project',
571
+ * dry_run: false,
572
+ * mode: 'migrate'
573
+ * });
574
+ * console.log(`Migrated ${result.files_copied} files`);
575
+ * ```
67
576
  */
68
577
  migrateProject(args: Record<string, unknown>): Promise<Types.MigrateProjectResponse>;
578
+ /**
579
+ * Forget conversations by topic/keywords.
580
+ *
581
+ * Searches for conversations matching the provided keywords and optionally deletes them.
582
+ * Creates automatic backup before deletion.
583
+ *
584
+ * @param args - Arguments:
585
+ * - `keywords`: Array of keywords/topics to search for
586
+ * - `project_path`: Path to the project (defaults to cwd)
587
+ * - `confirm`: Must be true to actually delete (default: false for preview)
588
+ *
589
+ * @returns Result containing:
590
+ * - `success`: Whether operation succeeded
591
+ * - `preview_mode`: Whether this was a preview (confirm=false)
592
+ * - `conversations_found`: Number of conversations matching keywords
593
+ * - `conversations_deleted`: Number of conversations actually deleted
594
+ * - `messages_deleted`: Number of messages deleted
595
+ * - `decisions_deleted`: Number of decisions deleted
596
+ * - `mistakes_deleted`: Number of mistakes deleted
597
+ * - `backup_path`: Path to backup file (if deletion occurred)
598
+ * - `conversation_summaries`: List of conversations with basic info
599
+ * - `message`: Human-readable status message
600
+ *
601
+ * @example
602
+ * ```typescript
603
+ * // Preview what would be deleted
604
+ * const preview = await handlers.forgetByTopic({
605
+ * keywords: ['authentication', 'redesign'],
606
+ * confirm: false
607
+ * });
608
+ *
609
+ * // Actually delete after reviewing preview
610
+ * const result = await handlers.forgetByTopic({
611
+ * keywords: ['authentication', 'redesign'],
612
+ * confirm: true
613
+ * });
614
+ * ```
615
+ */
616
+ forgetByTopic(args: unknown): Promise<Types.ForgetByTopicResponse>;
69
617
  }
70
618
  //# sourceMappingURL=ToolHandlers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToolHandlers.d.ts","sourceRoot":"","sources":["../../src/tools/ToolHandlers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,KAAK,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAOpD,qBAAa,YAAY;IAGX,OAAO,CAAC,MAAM;IAAsB,OAAO,CAAC,EAAE;IAF1D,OAAO,CAAC,SAAS,CAAmB;gBAEhB,MAAM,EAAE,kBAAkB,EAAU,EAAE,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,MAAM;IAI/F;;OAEG;IACG,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC;IAqDlG;;OAEG;IACG,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC;IA2BpG;;OAEG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,CA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