mcp-adr-analysis-server 2.0.21 → 2.0.24

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 (119) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/src/index.d.ts +9 -0
  3. package/dist/src/index.d.ts.map +1 -1
  4. package/dist/src/index.js +1380 -781
  5. package/dist/src/index.js.map +1 -1
  6. package/dist/src/tools/adr-suggestion-tool.d.ts.map +1 -1
  7. package/dist/src/tools/adr-suggestion-tool.js +32 -30
  8. package/dist/src/tools/adr-suggestion-tool.js.map +1 -1
  9. package/dist/src/tools/content-masking-tool.d.ts +4 -0
  10. package/dist/src/tools/content-masking-tool.d.ts.map +1 -1
  11. package/dist/src/tools/content-masking-tool.js +531 -28
  12. package/dist/src/tools/content-masking-tool.js.map +1 -1
  13. package/dist/src/tools/deployment-readiness-tool.d.ts +8 -5
  14. package/dist/src/tools/deployment-readiness-tool.d.ts.map +1 -1
  15. package/dist/src/tools/deployment-readiness-tool.js +741 -79
  16. package/dist/src/tools/deployment-readiness-tool.js.map +1 -1
  17. package/dist/src/tools/environment-analysis-tool.d.ts +4 -0
  18. package/dist/src/tools/environment-analysis-tool.d.ts.map +1 -1
  19. package/dist/src/tools/environment-analysis-tool.js +568 -24
  20. package/dist/src/tools/environment-analysis-tool.js.map +1 -1
  21. package/dist/src/tools/mcp-planning-tool.d.ts.map +1 -1
  22. package/dist/src/tools/mcp-planning-tool.js +298 -173
  23. package/dist/src/tools/mcp-planning-tool.js.map +1 -1
  24. package/dist/src/tools/memory-loading-tool.d.ts +60 -0
  25. package/dist/src/tools/memory-loading-tool.d.ts.map +1 -0
  26. package/dist/src/tools/memory-loading-tool.js +457 -0
  27. package/dist/src/tools/memory-loading-tool.js.map +1 -0
  28. package/dist/src/tools/smart-git-push-tool.d.ts +3 -0
  29. package/dist/src/tools/smart-git-push-tool.d.ts.map +1 -1
  30. package/dist/src/tools/smart-git-push-tool.js +177 -223
  31. package/dist/src/tools/smart-git-push-tool.js.map +1 -1
  32. package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts +20 -11
  33. package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts.map +1 -1
  34. package/dist/src/tools/troubleshoot-guided-workflow-tool.js +506 -22
  35. package/dist/src/tools/troubleshoot-guided-workflow-tool.js.map +1 -1
  36. package/dist/src/types/enhanced-errors.d.ts +173 -0
  37. package/dist/src/types/enhanced-errors.d.ts.map +1 -0
  38. package/dist/src/types/enhanced-errors.js +668 -0
  39. package/dist/src/types/enhanced-errors.js.map +1 -0
  40. package/dist/src/types/knowledge-graph-schemas.d.ts +92 -0
  41. package/dist/src/types/knowledge-graph-schemas.d.ts.map +1 -1
  42. package/dist/src/types/knowledge-graph-schemas.js +45 -17
  43. package/dist/src/types/knowledge-graph-schemas.js.map +1 -1
  44. package/dist/src/types/memory-entities.d.ts +7209 -0
  45. package/dist/src/types/memory-entities.d.ts.map +1 -0
  46. package/dist/src/types/memory-entities.js +395 -0
  47. package/dist/src/types/memory-entities.js.map +1 -0
  48. package/dist/src/types/todo-json-schemas.d.ts +7 -653
  49. package/dist/src/types/todo-json-schemas.d.ts.map +1 -1
  50. package/dist/src/types/todo-json-schemas.js +6 -110
  51. package/dist/src/types/todo-json-schemas.js.map +1 -1
  52. package/dist/src/utils/enhanced-logging.d.ts +195 -0
  53. package/dist/src/utils/enhanced-logging.d.ts.map +1 -0
  54. package/dist/src/utils/enhanced-logging.js +449 -0
  55. package/dist/src/utils/enhanced-logging.js.map +1 -0
  56. package/dist/src/utils/interactive-approval.d.ts +1 -1
  57. package/dist/src/utils/interactive-approval.d.ts.map +1 -1
  58. package/dist/src/utils/interactive-approval.js +20 -16
  59. package/dist/src/utils/interactive-approval.js.map +1 -1
  60. package/dist/src/utils/knowledge-graph-manager.d.ts +23 -1
  61. package/dist/src/utils/knowledge-graph-manager.d.ts.map +1 -1
  62. package/dist/src/utils/knowledge-graph-manager.js +297 -69
  63. package/dist/src/utils/knowledge-graph-manager.js.map +1 -1
  64. package/dist/src/utils/memory-entity-manager.d.ts +134 -0
  65. package/dist/src/utils/memory-entity-manager.d.ts.map +1 -0
  66. package/dist/src/utils/memory-entity-manager.js +848 -0
  67. package/dist/src/utils/memory-entity-manager.js.map +1 -0
  68. package/dist/src/utils/memory-health-scoring.d.ts +125 -0
  69. package/dist/src/utils/memory-health-scoring.d.ts.map +1 -0
  70. package/dist/src/utils/memory-health-scoring.js +277 -0
  71. package/dist/src/utils/memory-health-scoring.js.map +1 -0
  72. package/dist/src/utils/memory-migration-manager.d.ts +93 -0
  73. package/dist/src/utils/memory-migration-manager.d.ts.map +1 -0
  74. package/dist/src/utils/memory-migration-manager.js +834 -0
  75. package/dist/src/utils/memory-migration-manager.js.map +1 -0
  76. package/dist/src/utils/memory-relationship-mapper.d.ts +87 -0
  77. package/dist/src/utils/memory-relationship-mapper.d.ts.map +1 -0
  78. package/dist/src/utils/memory-relationship-mapper.js +481 -0
  79. package/dist/src/utils/memory-relationship-mapper.js.map +1 -0
  80. package/dist/src/utils/memory-rollback-manager.d.ts +93 -0
  81. package/dist/src/utils/memory-rollback-manager.d.ts.map +1 -0
  82. package/dist/src/utils/memory-rollback-manager.js +542 -0
  83. package/dist/src/utils/memory-rollback-manager.js.map +1 -0
  84. package/dist/src/utils/memory-transformation.d.ts +59 -0
  85. package/dist/src/utils/memory-transformation.d.ts.map +1 -0
  86. package/dist/src/utils/memory-transformation.js +742 -0
  87. package/dist/src/utils/memory-transformation.js.map +1 -0
  88. package/dist/src/utils/prompt-execution.d.ts.map +1 -1
  89. package/dist/src/utils/prompt-execution.js +72 -51
  90. package/dist/src/utils/prompt-execution.js.map +1 -1
  91. package/dist/src/utils/todo-file-watcher.d.ts +11 -23
  92. package/dist/src/utils/todo-file-watcher.d.ts.map +1 -1
  93. package/dist/src/utils/todo-file-watcher.js +18 -156
  94. package/dist/src/utils/todo-file-watcher.js.map +1 -1
  95. package/package.json +22 -6
  96. package/dist/src/tools/smart-score-tool.d.ts +0 -173
  97. package/dist/src/tools/smart-score-tool.d.ts.map +0 -1
  98. package/dist/src/tools/smart-score-tool.js +0 -681
  99. package/dist/src/tools/smart-score-tool.js.map +0 -1
  100. package/dist/src/tools/todo-management-tool-v2.d.ts +0 -368
  101. package/dist/src/tools/todo-management-tool-v2.d.ts.map +0 -1
  102. package/dist/src/tools/todo-management-tool-v2.js +0 -922
  103. package/dist/src/tools/todo-management-tool-v2.js.map +0 -1
  104. package/dist/src/utils/project-health-scoring.d.ts +0 -177
  105. package/dist/src/utils/project-health-scoring.d.ts.map +0 -1
  106. package/dist/src/utils/project-health-scoring.js +0 -370
  107. package/dist/src/utils/project-health-scoring.js.map +0 -1
  108. package/dist/src/utils/todo-json-manager.d.ts +0 -71
  109. package/dist/src/utils/todo-json-manager.d.ts.map +0 -1
  110. package/dist/src/utils/todo-json-manager.js +0 -396
  111. package/dist/src/utils/todo-json-manager.js.map +0 -1
  112. package/dist/src/utils/todo-markdown-converter.d.ts +0 -16
  113. package/dist/src/utils/todo-markdown-converter.d.ts.map +0 -1
  114. package/dist/src/utils/todo-markdown-converter.js +0 -362
  115. package/dist/src/utils/todo-markdown-converter.js.map +0 -1
  116. package/dist/src/utils/todo-migration.d.ts +0 -47
  117. package/dist/src/utils/todo-migration.d.ts.map +0 -1
  118. package/dist/src/utils/todo-migration.js +0 -261
  119. package/dist/src/utils/todo-migration.js.map +0 -1
@@ -0,0 +1,668 @@
1
+ /**
2
+ * Enhanced error types for better user experience
3
+ *
4
+ * Provides structured error handling with actionable suggestions
5
+ * and contextual information to help users resolve issues.
6
+ */
7
+ /**
8
+ * Enhanced base error class with comprehensive diagnostic information
9
+ */
10
+ export class EnhancedError extends Error {
11
+ code;
12
+ severity;
13
+ suggestions;
14
+ diagnostics;
15
+ recoverable;
16
+ retryable;
17
+ constructor(message, code, options) {
18
+ super(message, { cause: options.cause });
19
+ this.name = this.constructor.name;
20
+ this.code = code;
21
+ this.severity = options.severity || 'medium';
22
+ this.suggestions = options.suggestions || [];
23
+ this.diagnostics = options.diagnostics;
24
+ this.recoverable = options.recoverable ?? true;
25
+ this.retryable = options.retryable ?? false;
26
+ }
27
+ /**
28
+ * Get formatted error message with diagnostic information
29
+ */
30
+ getDetailedMessage() {
31
+ const lines = [
32
+ `${this.name}: ${this.message}`,
33
+ `Code: ${this.code}`,
34
+ `Severity: ${this.severity}`,
35
+ `Component: ${this.diagnostics.component}`,
36
+ `Operation: ${this.diagnostics.operation}`,
37
+ `Timestamp: ${this.diagnostics.timestamp.toISOString()}`,
38
+ ];
39
+ if (this.diagnostics.context && Object.keys(this.diagnostics.context).length > 0) {
40
+ lines.push(`Context: ${JSON.stringify(this.diagnostics.context, null, 2)}`);
41
+ }
42
+ if (this.diagnostics.performanceMetrics) {
43
+ lines.push(`Performance: ${JSON.stringify(this.diagnostics.performanceMetrics, null, 2)}`);
44
+ }
45
+ if (this.suggestions.length > 0) {
46
+ lines.push('Suggestions:');
47
+ this.suggestions.forEach(s => {
48
+ lines.push(` - ${s.action}: ${s.description}`);
49
+ if (s.example) {
50
+ lines.push(` Example: ${s.example}`);
51
+ }
52
+ });
53
+ }
54
+ return lines.join('\n');
55
+ }
56
+ /**
57
+ * Convert error to structured object for logging
58
+ */
59
+ toLogObject() {
60
+ return {
61
+ name: this.name,
62
+ message: this.message,
63
+ code: this.code,
64
+ severity: this.severity,
65
+ recoverable: this.recoverable,
66
+ retryable: this.retryable,
67
+ diagnostics: this.diagnostics,
68
+ suggestions: this.suggestions,
69
+ stack: this.stack,
70
+ cause: this.cause
71
+ ? {
72
+ name: this.cause.name,
73
+ message: this.cause.message,
74
+ stack: this.cause.stack,
75
+ }
76
+ : undefined,
77
+ };
78
+ }
79
+ }
80
+ /**
81
+ * Operation Queue specific errors
82
+ */
83
+ export class OperationQueueError extends EnhancedError {
84
+ constructor(message, code, diagnostics, options = {}) {
85
+ super(message, code, {
86
+ ...options,
87
+ diagnostics: {
88
+ ...diagnostics,
89
+ component: diagnostics.component || 'OperationQueue',
90
+ },
91
+ });
92
+ }
93
+ static queueOverflow(queueSize, maxSize, diagnostics) {
94
+ return new OperationQueueError(`Operation queue overflow: ${queueSize}/${maxSize} operations`, 'QUEUE_OVERFLOW', diagnostics, {
95
+ severity: 'high',
96
+ retryable: true,
97
+ suggestions: [
98
+ {
99
+ action: 'Reduce operation frequency',
100
+ description: 'Slow down the rate of operations being queued',
101
+ },
102
+ {
103
+ action: 'Increase queue size',
104
+ description: `Consider increasing maxQueueSize from ${maxSize} to handle peak loads`,
105
+ },
106
+ {
107
+ action: 'Enable backpressure',
108
+ description: 'Use backpressure handling to automatically throttle operations',
109
+ },
110
+ {
111
+ action: 'Check for stuck operations',
112
+ description: 'Verify that operations are completing and not hanging indefinitely',
113
+ },
114
+ ],
115
+ });
116
+ }
117
+ static operationTimeout(operationId, timeoutMs, diagnostics) {
118
+ return new OperationQueueError(`Operation ${operationId} timed out after ${timeoutMs}ms`, 'OPERATION_TIMEOUT', diagnostics, {
119
+ severity: 'medium',
120
+ retryable: true,
121
+ suggestions: [
122
+ {
123
+ action: 'Increase timeout value',
124
+ description: `Consider increasing timeout from ${timeoutMs}ms for complex operations`,
125
+ },
126
+ {
127
+ action: 'Break down large operations',
128
+ description: 'Split complex operations into smaller, faster chunks',
129
+ },
130
+ {
131
+ action: 'Check system resources',
132
+ description: 'Verify system has adequate CPU and memory for the operation',
133
+ },
134
+ {
135
+ action: 'Review operation complexity',
136
+ description: 'Analyze if the operation can be optimized for better performance',
137
+ },
138
+ ],
139
+ });
140
+ }
141
+ static concurrencyViolation(activeCount, maxConcurrency, diagnostics) {
142
+ return new OperationQueueError(`Concurrency limit exceeded: ${activeCount}/${maxConcurrency} active operations`, 'CONCURRENCY_VIOLATION', diagnostics, {
143
+ severity: 'high',
144
+ recoverable: false,
145
+ suggestions: [
146
+ {
147
+ action: 'Check semaphore implementation',
148
+ description: 'Verify that concurrency control is working correctly',
149
+ },
150
+ {
151
+ action: 'Review operation lifecycle',
152
+ description: 'Ensure operations are properly cleaned up when completed',
153
+ },
154
+ {
155
+ action: 'Increase concurrency limit',
156
+ description: `Consider increasing maxConcurrency from ${maxConcurrency} if system can handle it`,
157
+ },
158
+ ],
159
+ });
160
+ }
161
+ static shutdownInProgress(diagnostics) {
162
+ return new OperationQueueError('Cannot queue operation: shutdown in progress', 'SHUTDOWN_IN_PROGRESS', diagnostics, {
163
+ severity: 'medium',
164
+ recoverable: false,
165
+ retryable: false,
166
+ suggestions: [
167
+ {
168
+ action: 'Wait for shutdown to complete',
169
+ description: 'Allow the current shutdown process to finish',
170
+ },
171
+ {
172
+ action: 'Create new queue instance',
173
+ description: 'Initialize a new operation queue after shutdown completes',
174
+ },
175
+ ],
176
+ });
177
+ }
178
+ }
179
+ /**
180
+ * Data Consistency Checker specific errors
181
+ */
182
+ export class DataConsistencyError extends EnhancedError {
183
+ constructor(message, code, diagnostics, options = {}) {
184
+ super(message, code, {
185
+ ...options,
186
+ diagnostics: {
187
+ ...diagnostics,
188
+ component: diagnostics.component || 'DataConsistencyChecker',
189
+ },
190
+ });
191
+ }
192
+ static validationFailure(validationType, affectedItems, diagnostics) {
193
+ return new DataConsistencyError(`Data validation failed for ${validationType}: ${affectedItems.length} items affected`, 'VALIDATION_FAILURE', diagnostics, {
194
+ severity: 'high',
195
+ recoverable: true,
196
+ suggestions: [
197
+ {
198
+ action: 'Review affected items',
199
+ description: `Check the ${affectedItems.length} items that failed validation`,
200
+ },
201
+ {
202
+ action: 'Run auto-fix if available',
203
+ description: 'Use auto-fix functionality to correct common issues',
204
+ },
205
+ {
206
+ action: 'Manual data correction',
207
+ description: 'Manually review and correct the data inconsistencies',
208
+ },
209
+ {
210
+ action: 'Restore from backup',
211
+ description: 'Consider restoring from a known good backup if corruption is extensive',
212
+ },
213
+ ],
214
+ });
215
+ }
216
+ static metadataSyncFailure(taskCount, metadataCount, diagnostics) {
217
+ return new DataConsistencyError(`Metadata sync failure: ${taskCount} tasks vs ${metadataCount} metadata entries`, 'METADATA_SYNC_FAILURE', diagnostics, {
218
+ severity: 'medium',
219
+ recoverable: true,
220
+ suggestions: [
221
+ {
222
+ action: 'Regenerate metadata',
223
+ description: 'Rebuild metadata from current task data',
224
+ },
225
+ {
226
+ action: 'Remove orphaned metadata',
227
+ description: 'Clean up metadata entries without corresponding tasks',
228
+ },
229
+ {
230
+ action: 'Create missing metadata',
231
+ description: 'Generate metadata for tasks that are missing it',
232
+ },
233
+ ],
234
+ });
235
+ }
236
+ static dateValidationFailure(invalidDates, diagnostics) {
237
+ return new DataConsistencyError(`Date validation failed: ${invalidDates.length} invalid dates found`, 'DATE_VALIDATION_FAILURE', diagnostics, {
238
+ severity: 'medium',
239
+ recoverable: true,
240
+ suggestions: [
241
+ {
242
+ action: 'Fix date formats',
243
+ description: 'Convert invalid dates to ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ)',
244
+ example: '2024-01-15T10:30:00.000Z',
245
+ },
246
+ {
247
+ action: 'Remove invalid dates',
248
+ description: 'Clear invalid date fields and let system set defaults',
249
+ },
250
+ {
251
+ action: 'Use date parsing utilities',
252
+ description: 'Implement robust date parsing to handle various formats',
253
+ },
254
+ ],
255
+ });
256
+ }
257
+ static circularDependencyDetected(cycle, diagnostics) {
258
+ return new DataConsistencyError(`Circular dependency detected: ${cycle.join(' → ')}`, 'CIRCULAR_DEPENDENCY', diagnostics, {
259
+ severity: 'high',
260
+ recoverable: true,
261
+ suggestions: [
262
+ {
263
+ action: 'Break dependency cycle',
264
+ description: `Remove one dependency from the cycle: ${cycle.join(' → ')}`,
265
+ },
266
+ {
267
+ action: 'Restructure task relationships',
268
+ description: 'Consider using task hierarchy instead of dependencies',
269
+ },
270
+ {
271
+ action: 'Review task design',
272
+ description: 'Break down complex tasks to eliminate circular dependencies',
273
+ },
274
+ ],
275
+ });
276
+ }
277
+ }
278
+ /**
279
+ * Enhanced error class for TODO management operations
280
+ *
281
+ * Provides structured error information with contextual suggestions
282
+ * to help users understand and resolve issues quickly.
283
+ *
284
+ * @example
285
+ * ```typescript
286
+ * try {
287
+ * await manager.updateTask({ taskId: "invalid", updates: {} });
288
+ * } catch (error) {
289
+ * if (error instanceof TodoManagerError) {
290
+ * console.log(`Error: ${error.message}`);
291
+ * console.log(`Code: ${error.code}`);
292
+ * error.suggestions.forEach(s => {
293
+ * console.log(`- ${s.action}: ${s.description}`);
294
+ * });
295
+ * }
296
+ * }
297
+ * ```
298
+ */
299
+ export class TodoManagerError extends Error {
300
+ code;
301
+ field;
302
+ value;
303
+ validValues;
304
+ suggestions;
305
+ taskId;
306
+ suggestion;
307
+ constructor(message, code, options = {}) {
308
+ super(message);
309
+ this.name = 'TodoManagerError';
310
+ this.code = code;
311
+ if (options.field !== undefined)
312
+ this.field = options.field;
313
+ this.value = options.value;
314
+ if (options.validValues !== undefined)
315
+ this.validValues = options.validValues;
316
+ this.suggestions = options.suggestions || [];
317
+ if (options.taskId !== undefined)
318
+ this.taskId = options.taskId;
319
+ if (options.suggestion !== undefined)
320
+ this.suggestion = options.suggestion;
321
+ }
322
+ static projectPathNotFound(path) {
323
+ return new TodoManagerError(`Project path '${path}' does not exist or is not accessible`, 'PROJECT_PATH_NOT_FOUND', {
324
+ value: path,
325
+ suggestions: [
326
+ {
327
+ action: 'Check the PROJECT_PATH environment variable',
328
+ description: 'Ensure the path points to a valid directory',
329
+ },
330
+ {
331
+ action: 'Create the directory',
332
+ description: `Run: mkdir -p "${path}"`,
333
+ },
334
+ {
335
+ action: 'Run from the project root',
336
+ description: 'Make sure you are in the correct project directory',
337
+ },
338
+ ],
339
+ });
340
+ }
341
+ /**
342
+ * Create a task not found error with helpful suggestions
343
+ *
344
+ * @param taskId - The task ID that could not be found
345
+ * @returns TodoManagerError with suggestions for finding the task
346
+ */
347
+ static taskNotFound(taskId) {
348
+ return new TodoManagerError(`Task '${taskId}' not found`, 'TASK_NOT_FOUND', {
349
+ taskId,
350
+ suggestions: [
351
+ {
352
+ action: 'The task may have been deleted',
353
+ description: 'Check if the task was recently removed',
354
+ },
355
+ {
356
+ action: 'Use get_tasks to list all tasks',
357
+ description: 'Verify the task ID exists in the current list',
358
+ },
359
+ {
360
+ action: 'Search for the task using find_task',
361
+ description: 'The task might have a different ID than expected',
362
+ },
363
+ ],
364
+ });
365
+ }
366
+ /**
367
+ * Create an invalid task ID error with format guidance
368
+ *
369
+ * @param taskId - The invalid task ID that was provided
370
+ * @returns TodoManagerError with suggestions for correct ID format
371
+ */
372
+ static invalidTaskId(taskId) {
373
+ return new TodoManagerError(`Invalid task ID format: '${taskId}'`, 'INVALID_TASK_ID', {
374
+ value: taskId,
375
+ suggestions: [
376
+ {
377
+ action: 'Use find_task to search for tasks',
378
+ description: 'Search by title or description instead',
379
+ },
380
+ {
381
+ action: 'Use get_tasks with showFullIds: true',
382
+ description: 'Get the complete UUID for the task',
383
+ },
384
+ {
385
+ action: 'Check the task ID format',
386
+ description: 'Task IDs should be UUIDs or partial UUIDs (8+ characters)',
387
+ },
388
+ ],
389
+ });
390
+ }
391
+ static invalidPriority(value, suggestedValue) {
392
+ const suggestionText = suggestedValue
393
+ ? `Did you mean "${suggestedValue}"?`
394
+ : 'Use one of the valid priority values';
395
+ return new TodoManagerError(`Invalid priority '${value}'. Must be one of: low, medium, high, critical`, 'INVALID_PRIORITY', {
396
+ field: 'priority',
397
+ value,
398
+ validValues: ['low', 'medium', 'high', 'critical'],
399
+ suggestion: suggestionText,
400
+ suggestions: [
401
+ {
402
+ action: suggestionText,
403
+ description: suggestedValue
404
+ ? `Replace '${value}' with '${suggestedValue}'`
405
+ : 'Choose from: low, medium, high, critical',
406
+ },
407
+ ],
408
+ });
409
+ }
410
+ static taskHasDependencies(taskId, dependentTasks) {
411
+ return new TodoManagerError(`Cannot delete task '${taskId}' because it has active dependencies: ${dependentTasks.join(', ')}`, 'TASK_HAS_DEPENDENCIES', {
412
+ taskId,
413
+ value: dependentTasks,
414
+ suggestions: [
415
+ {
416
+ action: 'Complete or delete dependent tasks first',
417
+ description: 'Tasks that depend on this one must be handled first',
418
+ },
419
+ {
420
+ action: 'Use archiveTask instead of deleteTask',
421
+ description: 'Archiving preserves the task for reference while marking it inactive',
422
+ },
423
+ {
424
+ action: 'Remove dependencies from dependent tasks',
425
+ description: 'Update dependent tasks to remove this dependency',
426
+ },
427
+ ],
428
+ });
429
+ }
430
+ /**
431
+ * Create a circular dependency error with resolution suggestions
432
+ *
433
+ * @param taskIds - Array of task IDs forming the circular dependency chain
434
+ * @returns TodoManagerError with suggestions for breaking the cycle
435
+ */
436
+ static circularDependency(taskIds) {
437
+ const chain = taskIds.join(' → ');
438
+ return new TodoManagerError(`Circular dependency detected: ${chain}`, 'CIRCULAR_DEPENDENCY', {
439
+ value: taskIds,
440
+ suggestions: [
441
+ {
442
+ action: 'Remove one of the dependencies in the chain',
443
+ description: `Break the cycle by removing a dependency from: ${chain}`,
444
+ },
445
+ {
446
+ action: 'Restructure task relationships',
447
+ description: 'Consider breaking down tasks into smaller, independent units',
448
+ },
449
+ {
450
+ action: 'Use task hierarchy instead of dependencies',
451
+ description: 'Consider using parent-child relationships instead of dependencies',
452
+ },
453
+ ],
454
+ });
455
+ }
456
+ static invalidDateFormat(date, field = 'date') {
457
+ return new TodoManagerError(`Invalid date format: '${date}'. Expected ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)`, 'INVALID_DATE_FORMAT', {
458
+ field,
459
+ value: date,
460
+ suggestions: [
461
+ {
462
+ action: 'Use ISO 8601 format',
463
+ description: 'Examples: "2024-01-15", "2024-01-15T10:30:00Z"',
464
+ example: '2024-01-15T10:30:00Z',
465
+ },
466
+ {
467
+ action: 'Use relative dates',
468
+ description: 'Examples: "today", "tomorrow", "+1 week", "+2 days"',
469
+ },
470
+ {
471
+ action: 'Check date validity',
472
+ description: 'Ensure the date exists (e.g., February 30th is invalid)',
473
+ },
474
+ ],
475
+ });
476
+ }
477
+ static invalidStatus(value, suggestedValue) {
478
+ const suggestionText = suggestedValue
479
+ ? `Did you mean "${suggestedValue}"?`
480
+ : 'Use one of the valid status values';
481
+ return new TodoManagerError(`Invalid status '${value}'. Must be one of: pending, in_progress, completed, blocked, cancelled`, 'INVALID_STATUS', {
482
+ field: 'status',
483
+ value,
484
+ validValues: ['pending', 'in_progress', 'completed', 'blocked', 'cancelled'],
485
+ suggestion: suggestionText,
486
+ suggestions: [
487
+ {
488
+ action: suggestionText,
489
+ description: suggestedValue
490
+ ? `Replace '${value}' with '${suggestedValue}'`
491
+ : 'Choose from: pending, in_progress, completed, blocked, cancelled',
492
+ },
493
+ ],
494
+ });
495
+ }
496
+ static requiredFieldMissing(field) {
497
+ return new TodoManagerError(`Required field '${field}' is missing`, 'REQUIRED_FIELD_MISSING', {
498
+ field,
499
+ suggestions: [
500
+ {
501
+ action: `Provide the '${field}' field`,
502
+ description: `The '${field}' field is required for this operation`,
503
+ },
504
+ ],
505
+ });
506
+ }
507
+ static invalidFieldValue(field, value, expectedType) {
508
+ const typeInfo = expectedType ? ` (expected ${expectedType})` : '';
509
+ return new TodoManagerError(`Invalid value for field '${field}': '${value}'${typeInfo}`, 'INVALID_FIELD_VALUE', {
510
+ field,
511
+ value,
512
+ suggestions: [
513
+ {
514
+ action: `Check the '${field}' field value`,
515
+ description: expectedType
516
+ ? `Expected type: ${expectedType}`
517
+ : 'Verify the field value is correct',
518
+ },
519
+ ],
520
+ });
521
+ }
522
+ static taskAlreadyExists(taskId) {
523
+ return new TodoManagerError(`Task with ID '${taskId}' already exists`, 'TASK_ALREADY_EXISTS', {
524
+ taskId,
525
+ suggestions: [
526
+ {
527
+ action: 'Use update_task instead',
528
+ description: 'If you want to modify an existing task, use the update operation',
529
+ },
530
+ {
531
+ action: 'Generate a new task ID',
532
+ description: 'Create a new task with a unique ID',
533
+ },
534
+ {
535
+ action: 'Check if this is a duplicate',
536
+ description: 'Verify you are not accidentally creating the same task twice',
537
+ },
538
+ ],
539
+ });
540
+ }
541
+ static bulkOperationPartialFailure(successful, failed, errors) {
542
+ return new TodoManagerError(`Bulk operation completed with ${successful} successes and ${failed} failures`, 'BULK_OPERATION_PARTIAL_FAILURE', {
543
+ value: { successful, failed, errors },
544
+ suggestions: [
545
+ {
546
+ action: 'Review failed operations',
547
+ description: 'Check the error details for each failed operation',
548
+ },
549
+ {
550
+ action: 'Retry failed operations individually',
551
+ description: 'Process failed items one by one to identify specific issues',
552
+ },
553
+ {
554
+ action: 'Use dry-run mode first',
555
+ description: 'Test bulk operations with dry-run to identify issues beforehand',
556
+ },
557
+ ],
558
+ });
559
+ }
560
+ static operationNotSupported(operation) {
561
+ return new TodoManagerError(`Operation '${operation}' is not supported`, 'OPERATION_NOT_SUPPORTED', {
562
+ value: operation,
563
+ suggestions: [
564
+ {
565
+ action: 'Check available operations',
566
+ description: 'Use get_operations or check documentation for supported operations',
567
+ },
568
+ {
569
+ action: 'Check operation spelling',
570
+ description: 'Verify the operation name is spelled correctly',
571
+ },
572
+ ],
573
+ });
574
+ }
575
+ static concurrencyConflict(taskId) {
576
+ return new TodoManagerError(`Concurrency conflict: Task '${taskId}' was modified by another operation`, 'CONCURRENCY_CONFLICT', {
577
+ taskId,
578
+ suggestions: [
579
+ {
580
+ action: 'Retry the operation',
581
+ description: 'The task may have been updated by another process',
582
+ },
583
+ {
584
+ action: 'Refresh task data',
585
+ description: 'Get the latest task data before making changes',
586
+ },
587
+ {
588
+ action: 'Use force update if necessary',
589
+ description: 'Override the conflict if you are sure about the changes',
590
+ },
591
+ ],
592
+ });
593
+ }
594
+ static dataCorruption(details) {
595
+ return new TodoManagerError(`Data corruption detected: ${details}`, 'DATA_CORRUPTION', {
596
+ value: details,
597
+ suggestions: [
598
+ {
599
+ action: 'Restore from backup',
600
+ description: 'Use the most recent backup to restore data integrity',
601
+ },
602
+ {
603
+ action: 'Run data validation',
604
+ description: 'Check for and repair data inconsistencies',
605
+ },
606
+ {
607
+ action: 'Contact support',
608
+ description: 'If the issue persists, seek technical assistance',
609
+ },
610
+ ],
611
+ });
612
+ }
613
+ static undoNotAvailable(reason) {
614
+ return new TodoManagerError(`Undo operation not available: ${reason}`, 'UNDO_NOT_AVAILABLE', {
615
+ value: reason,
616
+ suggestions: [
617
+ {
618
+ action: 'Check operation history',
619
+ description: 'Use get_undo_history to see available undo operations',
620
+ },
621
+ {
622
+ action: 'Manual recovery',
623
+ description: 'You may need to manually recreate or restore the desired state',
624
+ },
625
+ ],
626
+ });
627
+ }
628
+ static searchQueryInvalid(query, reason) {
629
+ return new TodoManagerError(`Invalid search query '${query}': ${reason}`, 'SEARCH_QUERY_INVALID', {
630
+ value: query,
631
+ suggestions: [
632
+ {
633
+ action: 'Simplify the search query',
634
+ description: 'Try using simpler search terms',
635
+ },
636
+ {
637
+ action: 'Check regex syntax',
638
+ description: 'If using regex search, verify the pattern syntax',
639
+ },
640
+ {
641
+ action: 'Use fuzzy search instead',
642
+ description: 'Fuzzy search is more forgiving of typos and variations',
643
+ },
644
+ ],
645
+ });
646
+ }
647
+ static multipleTasksFound(partialId, matches) {
648
+ return new TodoManagerError(`Multiple tasks found for '${partialId}': ${matches.join(', ')}`, 'MULTIPLE_TASKS_FOUND', {
649
+ value: partialId,
650
+ validValues: matches,
651
+ suggestions: [
652
+ {
653
+ action: 'Use a more specific ID',
654
+ description: 'Provide more characters to uniquely identify the task',
655
+ },
656
+ {
657
+ action: 'Use the full task ID',
658
+ description: 'Copy the complete UUID from the task list',
659
+ },
660
+ {
661
+ action: 'Use find_task to search by title',
662
+ description: 'Search by task title or description instead of ID',
663
+ },
664
+ ],
665
+ });
666
+ }
667
+ }
668
+ //# sourceMappingURL=enhanced-errors.js.map