@defai.digital/ax-cli 3.7.2 → 3.8.1

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 (213) hide show
  1. package/README.md +128 -56
  2. package/dist/agent/context-manager.d.ts +15 -1
  3. package/dist/agent/context-manager.js +50 -19
  4. package/dist/agent/context-manager.js.map +1 -1
  5. package/dist/agent/dependency-resolver.js +13 -7
  6. package/dist/agent/dependency-resolver.js.map +1 -1
  7. package/dist/agent/llm-agent.d.ts +35 -0
  8. package/dist/agent/llm-agent.js +137 -4
  9. package/dist/agent/llm-agent.js.map +1 -1
  10. package/dist/agent/status-reporter.d.ts +114 -0
  11. package/dist/agent/status-reporter.js +335 -0
  12. package/dist/agent/status-reporter.js.map +1 -0
  13. package/dist/analyzers/best-practices/rules/typescript/no-magic-numbers.js +8 -2
  14. package/dist/analyzers/best-practices/rules/typescript/no-magic-numbers.js.map +1 -1
  15. package/dist/analyzers/best-practices/rules/typescript/no-unused-vars.js +3 -1
  16. package/dist/analyzers/best-practices/rules/typescript/no-unused-vars.js.map +1 -1
  17. package/dist/analyzers/best-practices/rules/typescript/prefer-const.js +3 -1
  18. package/dist/analyzers/best-practices/rules/typescript/prefer-const.js.map +1 -1
  19. package/dist/analyzers/best-practices/rules/typescript/prefer-readonly.js +3 -1
  20. package/dist/analyzers/best-practices/rules/typescript/prefer-readonly.js.map +1 -1
  21. package/dist/analyzers/code-smells/detectors/duplicate-code-detector.js +9 -3
  22. package/dist/analyzers/code-smells/detectors/duplicate-code-detector.js.map +1 -1
  23. package/dist/analyzers/git/churn-calculator.d.ts +1 -0
  24. package/dist/analyzers/git/churn-calculator.js +25 -6
  25. package/dist/analyzers/git/churn-calculator.js.map +1 -1
  26. package/dist/analyzers/git/hotspot-detector.js +2 -2
  27. package/dist/analyzers/git/hotspot-detector.js.map +1 -1
  28. package/dist/analyzers/metrics/metrics-analyzer.js +1 -1
  29. package/dist/analyzers/metrics/metrics-analyzer.js.map +1 -1
  30. package/dist/analyzers/security/security-analyzer.js +1 -1
  31. package/dist/analyzers/security/security-analyzer.js.map +1 -1
  32. package/dist/checkpoint/manager.d.ts +1 -0
  33. package/dist/checkpoint/manager.js +49 -9
  34. package/dist/checkpoint/manager.js.map +1 -1
  35. package/dist/checkpoint/storage.js +2 -2
  36. package/dist/checkpoint/storage.js.map +1 -1
  37. package/dist/commands/mcp-migrate.d.ts +9 -0
  38. package/dist/commands/mcp-migrate.js +172 -0
  39. package/dist/commands/mcp-migrate.js.map +1 -0
  40. package/dist/commands/status.d.ts +7 -0
  41. package/dist/commands/status.js +211 -0
  42. package/dist/commands/status.js.map +1 -0
  43. package/dist/commands/vscode.d.ts +7 -0
  44. package/dist/commands/vscode.js +363 -0
  45. package/dist/commands/vscode.js.map +1 -0
  46. package/dist/index.js +79 -30
  47. package/dist/index.js.map +1 -1
  48. package/dist/llm/client.js +22 -4
  49. package/dist/llm/client.js.map +1 -1
  50. package/dist/mcp/automatosx-loader.d.ts +84 -0
  51. package/dist/mcp/automatosx-loader.js +238 -0
  52. package/dist/mcp/automatosx-loader.js.map +1 -0
  53. package/dist/mcp/client-mutex-patch.d.ts +36 -0
  54. package/dist/mcp/client-mutex-patch.js +75 -0
  55. package/dist/mcp/client-mutex-patch.js.map +1 -0
  56. package/dist/mcp/client-v2.d.ts +229 -0
  57. package/dist/mcp/client-v2.js +740 -0
  58. package/dist/mcp/client-v2.js.map +1 -0
  59. package/dist/mcp/client.d.ts +111 -13
  60. package/dist/mcp/client.js +168 -253
  61. package/dist/mcp/client.js.map +1 -1
  62. package/dist/mcp/config-detector-v2.d.ts +83 -0
  63. package/dist/mcp/config-detector-v2.js +328 -0
  64. package/dist/mcp/config-detector-v2.js.map +1 -0
  65. package/dist/mcp/config-detector.d.ts +90 -0
  66. package/dist/mcp/config-detector.js +242 -0
  67. package/dist/mcp/config-detector.js.map +1 -0
  68. package/dist/mcp/config-migrator-v2.d.ts +89 -0
  69. package/dist/mcp/config-migrator-v2.js +288 -0
  70. package/dist/mcp/config-migrator-v2.js.map +1 -0
  71. package/dist/mcp/config-migrator.d.ts +63 -0
  72. package/dist/mcp/config-migrator.js +269 -0
  73. package/dist/mcp/config-migrator.js.map +1 -0
  74. package/dist/mcp/config-v2.d.ts +106 -0
  75. package/dist/mcp/config-v2.js +417 -0
  76. package/dist/mcp/config-v2.js.map +1 -0
  77. package/dist/mcp/config.d.ts +12 -1
  78. package/dist/mcp/config.js +95 -10
  79. package/dist/mcp/config.js.map +1 -1
  80. package/dist/mcp/error-formatter.d.ts +46 -0
  81. package/dist/mcp/error-formatter.js +244 -0
  82. package/dist/mcp/error-formatter.js.map +1 -0
  83. package/dist/mcp/health.d.ts +5 -0
  84. package/dist/mcp/health.js +22 -2
  85. package/dist/mcp/health.js.map +1 -1
  86. package/dist/mcp/invariants.d.ts +141 -0
  87. package/dist/mcp/invariants.js +243 -0
  88. package/dist/mcp/invariants.js.map +1 -0
  89. package/dist/mcp/mutex-safe.d.ts +153 -0
  90. package/dist/mcp/mutex-safe.js +260 -0
  91. package/dist/mcp/mutex-safe.js.map +1 -0
  92. package/dist/mcp/mutex.d.ts +73 -0
  93. package/dist/mcp/mutex.js +130 -0
  94. package/dist/mcp/mutex.js.map +1 -0
  95. package/dist/mcp/reconnection.d.ts +4 -0
  96. package/dist/mcp/reconnection.js +15 -0
  97. package/dist/mcp/reconnection.js.map +1 -1
  98. package/dist/mcp/transports-v2.d.ts +152 -0
  99. package/dist/mcp/transports-v2.js +481 -0
  100. package/dist/mcp/transports-v2.js.map +1 -0
  101. package/dist/mcp/type-safety.d.ts +231 -0
  102. package/dist/mcp/type-safety.js +273 -0
  103. package/dist/mcp/type-safety.js.map +1 -0
  104. package/dist/planner/task-planner.js +13 -0
  105. package/dist/planner/task-planner.js.map +1 -1
  106. package/dist/planner/types.d.ts +6 -6
  107. package/dist/schemas/confirmation-schemas.d.ts +2 -2
  108. package/dist/schemas/settings-schemas.d.ts +196 -0
  109. package/dist/schemas/settings-schemas.js +146 -5
  110. package/dist/schemas/settings-schemas.js.map +1 -1
  111. package/dist/sdk/index.d.ts +118 -2
  112. package/dist/sdk/index.js +146 -4
  113. package/dist/sdk/index.js.map +1 -1
  114. package/dist/sdk/testing.d.ts +182 -0
  115. package/dist/sdk/testing.js +231 -0
  116. package/dist/sdk/testing.js.map +1 -1
  117. package/dist/sdk/version.d.ts +114 -15
  118. package/dist/sdk/version.js +137 -15
  119. package/dist/sdk/version.js.map +1 -1
  120. package/dist/tools/bash.js +54 -9
  121. package/dist/tools/bash.js.map +1 -1
  122. package/dist/tools/registry.d.ts +146 -0
  123. package/dist/tools/registry.js +170 -0
  124. package/dist/tools/registry.js.map +1 -0
  125. package/dist/tools/search.js +12 -2
  126. package/dist/tools/search.js.map +1 -1
  127. package/dist/tools/text-editor.js +84 -26
  128. package/dist/tools/text-editor.js.map +1 -1
  129. package/dist/ui/components/chat-history.js +6 -1
  130. package/dist/ui/components/chat-history.js.map +1 -1
  131. package/dist/ui/components/chat-input.d.ts +2 -1
  132. package/dist/ui/components/chat-input.js +5 -2
  133. package/dist/ui/components/chat-input.js.map +1 -1
  134. package/dist/ui/components/chat-interface.js +187 -5
  135. package/dist/ui/components/chat-interface.js.map +1 -1
  136. package/dist/ui/components/context-breakdown.d.ts +23 -0
  137. package/dist/ui/components/context-breakdown.js +124 -0
  138. package/dist/ui/components/context-breakdown.js.map +1 -0
  139. package/dist/ui/components/keyboard-help.d.ts +17 -0
  140. package/dist/ui/components/keyboard-help.js +116 -0
  141. package/dist/ui/components/keyboard-help.js.map +1 -0
  142. package/dist/ui/components/keyboard-hints.js +2 -2
  143. package/dist/ui/components/keyboard-hints.js.map +1 -1
  144. package/dist/ui/components/quick-actions.js +43 -7
  145. package/dist/ui/components/quick-actions.js.map +1 -1
  146. package/dist/ui/components/status-bar.d.ts +3 -0
  147. package/dist/ui/components/status-bar.js +25 -16
  148. package/dist/ui/components/status-bar.js.map +1 -1
  149. package/dist/ui/components/toast-notification.d.ts +42 -0
  150. package/dist/ui/components/toast-notification.js +30 -2
  151. package/dist/ui/components/toast-notification.js.map +1 -1
  152. package/dist/ui/components/tool-group-display.js +34 -4
  153. package/dist/ui/components/tool-group-display.js.map +1 -1
  154. package/dist/ui/components/welcome-panel.js +2 -2
  155. package/dist/ui/components/welcome-panel.js.map +1 -1
  156. package/dist/ui/hooks/use-enhanced-input.d.ts +9 -1
  157. package/dist/ui/hooks/use-enhanced-input.js +486 -41
  158. package/dist/ui/hooks/use-enhanced-input.js.map +1 -1
  159. package/dist/ui/hooks/use-input-handler.d.ts +11 -1
  160. package/dist/ui/hooks/use-input-handler.js +67 -3
  161. package/dist/ui/hooks/use-input-handler.js.map +1 -1
  162. package/dist/ui/hooks/use-input-history.d.ts +1 -1
  163. package/dist/ui/hooks/use-input-history.js +50 -14
  164. package/dist/ui/hooks/use-input-history.js.map +1 -1
  165. package/dist/ui/utils/bracketed-paste-handler.d.ts +97 -0
  166. package/dist/ui/utils/bracketed-paste-handler.js +322 -0
  167. package/dist/ui/utils/bracketed-paste-handler.js.map +1 -0
  168. package/dist/ui/utils/change-summarizer.js +16 -6
  169. package/dist/ui/utils/change-summarizer.js.map +1 -1
  170. package/dist/ui/utils/tool-grouper.d.ts +10 -1
  171. package/dist/ui/utils/tool-grouper.js +143 -30
  172. package/dist/ui/utils/tool-grouper.js.map +1 -1
  173. package/dist/utils/auto-accept-logger.d.ts +173 -0
  174. package/dist/utils/auto-accept-logger.js +420 -0
  175. package/dist/utils/auto-accept-logger.js.map +1 -0
  176. package/dist/utils/background-task-manager.d.ts +11 -0
  177. package/dist/utils/background-task-manager.js +124 -38
  178. package/dist/utils/background-task-manager.js.map +1 -1
  179. package/dist/utils/confirmation-service.d.ts +1 -0
  180. package/dist/utils/confirmation-service.js +6 -1
  181. package/dist/utils/confirmation-service.js.map +1 -1
  182. package/dist/utils/encryption.d.ts +8 -0
  183. package/dist/utils/encryption.js +44 -27
  184. package/dist/utils/encryption.js.map +1 -1
  185. package/dist/utils/enhanced-error-messages.d.ts +33 -0
  186. package/dist/utils/enhanced-error-messages.js +420 -0
  187. package/dist/utils/enhanced-error-messages.js.map +1 -0
  188. package/dist/utils/error-handler.d.ts +13 -3
  189. package/dist/utils/error-handler.js +16 -4
  190. package/dist/utils/error-handler.js.map +1 -1
  191. package/dist/utils/external-editor.d.ts +47 -0
  192. package/dist/utils/external-editor.js +179 -0
  193. package/dist/utils/external-editor.js.map +1 -0
  194. package/dist/utils/history-migration.d.ts +9 -0
  195. package/dist/utils/history-migration.js +36 -0
  196. package/dist/utils/history-migration.js.map +1 -0
  197. package/dist/utils/paste-utils.js +12 -11
  198. package/dist/utils/paste-utils.js.map +1 -1
  199. package/dist/utils/rate-limiter.js +7 -0
  200. package/dist/utils/rate-limiter.js.map +1 -1
  201. package/dist/utils/safety-rules.d.ts +64 -0
  202. package/dist/utils/safety-rules.js +225 -0
  203. package/dist/utils/safety-rules.js.map +1 -0
  204. package/dist/utils/settings-manager.d.ts +89 -1
  205. package/dist/utils/settings-manager.js +359 -3
  206. package/dist/utils/settings-manager.js.map +1 -1
  207. package/dist/utils/token-counter.d.ts +2 -0
  208. package/dist/utils/token-counter.js +17 -4
  209. package/dist/utils/token-counter.js.map +1 -1
  210. package/dist/utils/version.d.ts +11 -2
  211. package/dist/utils/version.js +54 -21
  212. package/dist/utils/version.js.map +1 -1
  213. package/package.json +2 -1
@@ -0,0 +1,420 @@
1
+ /**
2
+ * Enhanced Error Messages
3
+ * Provides user-friendly, actionable error messages with clear recovery paths
4
+ * Phase 5: Error Message Improvements
5
+ */
6
+ import { ErrorCategory } from './error-handler.js';
7
+ /**
8
+ * Common file operation error patterns
9
+ */
10
+ const FILE_ERROR_PATTERNS = {
11
+ ENOENT: {
12
+ title: 'File or Directory Not Found',
13
+ description: 'The specified path does not exist',
14
+ suggestions: [
15
+ 'Check if the file path is correct',
16
+ 'Verify the file exists using: ls <directory>',
17
+ 'Use absolute paths to avoid confusion',
18
+ 'Check for typos in the file name',
19
+ ],
20
+ },
21
+ EACCES: {
22
+ title: 'Permission Denied',
23
+ description: 'You do not have permission to access this file',
24
+ suggestions: [
25
+ 'Check file permissions using: ls -la <file>',
26
+ 'Ensure you have read/write access',
27
+ 'Try running with appropriate permissions',
28
+ 'Contact your system administrator if needed',
29
+ ],
30
+ },
31
+ EISDIR: {
32
+ title: 'Expected File, Got Directory',
33
+ description: 'The path points to a directory, not a file',
34
+ suggestions: [
35
+ 'Specify a file path instead of a directory',
36
+ 'Use ls to list directory contents',
37
+ 'Add a filename to the end of the path',
38
+ ],
39
+ },
40
+ ENOTDIR: {
41
+ title: 'Expected Directory, Got File',
42
+ description: 'The path points to a file, not a directory',
43
+ suggestions: [
44
+ 'Specify a directory path instead of a file',
45
+ 'Remove the filename from the path',
46
+ 'Check the path structure',
47
+ ],
48
+ },
49
+ EEXIST: {
50
+ title: 'File Already Exists',
51
+ description: 'Cannot create file because it already exists',
52
+ suggestions: [
53
+ 'Choose a different filename',
54
+ 'Delete the existing file first (use with caution)',
55
+ 'Use str_replace to modify the existing file instead',
56
+ ],
57
+ },
58
+ EMFILE: {
59
+ title: 'Too Many Open Files',
60
+ description: 'System has reached the limit of open files',
61
+ suggestions: [
62
+ 'Close some open files or processes',
63
+ 'Increase system file descriptor limit',
64
+ 'Check for file handle leaks in running processes',
65
+ ],
66
+ },
67
+ ENOSPC: {
68
+ title: 'No Space Left on Device',
69
+ description: 'The disk is full',
70
+ suggestions: [
71
+ 'Free up disk space by deleting unnecessary files',
72
+ 'Check disk usage with: df -h',
73
+ 'Move files to a different location',
74
+ 'Clean up temporary files',
75
+ ],
76
+ },
77
+ };
78
+ /**
79
+ * API error templates
80
+ */
81
+ const API_ERROR_PATTERNS = {
82
+ 400: {
83
+ title: 'Bad Request',
84
+ description: 'The API request was malformed or invalid',
85
+ suggestions: [
86
+ 'Check the request parameters',
87
+ 'Verify the model name is correct',
88
+ 'Ensure the input is properly formatted',
89
+ 'Review the API documentation',
90
+ ],
91
+ },
92
+ 401: {
93
+ title: 'Authentication Failed',
94
+ description: 'Your API key is invalid or missing',
95
+ suggestions: [
96
+ 'Run "ax setup" to configure your API key',
97
+ 'Verify your API key at the provider dashboard',
98
+ 'Check if your API key has expired',
99
+ 'Ensure the API key matches your provider',
100
+ ],
101
+ learnMore: 'https://docs.ax-cli.dev/configuration#api-keys',
102
+ },
103
+ 403: {
104
+ title: 'Access Forbidden',
105
+ description: 'You do not have permission to access this resource',
106
+ suggestions: [
107
+ 'Verify your account has access to this model',
108
+ 'Check your subscription plan',
109
+ 'Ensure your API key has the correct permissions',
110
+ 'Contact your provider support',
111
+ ],
112
+ },
113
+ 404: {
114
+ title: 'Resource Not Found',
115
+ description: 'The requested model or endpoint does not exist',
116
+ suggestions: [
117
+ 'Verify the model name using: ax models',
118
+ 'Check the base URL in your configuration',
119
+ 'Ensure the provider supports this model',
120
+ 'Update to the latest version of ax-cli',
121
+ ],
122
+ },
123
+ 429: {
124
+ title: 'Rate Limit Exceeded',
125
+ description: 'You have sent too many requests in a short period',
126
+ suggestions: [
127
+ 'Wait a few minutes before retrying',
128
+ 'Check your rate limits at the provider dashboard',
129
+ 'Consider upgrading your API plan',
130
+ 'Reduce the frequency of requests',
131
+ ],
132
+ learnMore: 'https://docs.ax-cli.dev/troubleshooting#rate-limits',
133
+ },
134
+ 500: {
135
+ title: 'Server Error',
136
+ description: 'The API server encountered an internal error',
137
+ suggestions: [
138
+ 'Wait a few moments and try again',
139
+ 'Check provider status page for outages',
140
+ 'Try again with a smaller request',
141
+ 'Contact provider support if it persists',
142
+ ],
143
+ },
144
+ 502: {
145
+ title: 'Bad Gateway',
146
+ description: 'The API gateway received an invalid response',
147
+ suggestions: [
148
+ 'This is a temporary provider issue',
149
+ 'Wait a few moments and try again',
150
+ 'Check provider status page',
151
+ ],
152
+ },
153
+ 503: {
154
+ title: 'Service Unavailable',
155
+ description: 'The API service is temporarily unavailable',
156
+ suggestions: [
157
+ 'The provider may be experiencing high load',
158
+ 'Wait a few minutes and try again',
159
+ 'Check provider status page for updates',
160
+ ],
161
+ },
162
+ 504: {
163
+ title: 'Gateway Timeout',
164
+ description: 'The request took too long to complete',
165
+ suggestions: [
166
+ 'Try reducing the complexity of your request',
167
+ 'Split large operations into smaller chunks',
168
+ 'Check your internet connection',
169
+ 'Try again in a few moments',
170
+ ],
171
+ },
172
+ };
173
+ /**
174
+ * MCP error templates
175
+ */
176
+ const MCP_ERROR_PATTERNS = {
177
+ CONNECTION_FAILED: {
178
+ title: 'MCP Server Connection Failed',
179
+ description: 'Unable to connect to the MCP server',
180
+ suggestions: [
181
+ 'Check if the MCP server is running',
182
+ 'Verify the server configuration in .ax-cli/settings.json',
183
+ 'Ensure the server command/URL is correct',
184
+ 'Check server logs for errors',
185
+ 'Try restarting the MCP server',
186
+ ],
187
+ learnMore: 'https://docs.ax-cli.dev/mcp#troubleshooting',
188
+ },
189
+ INVALID_RESPONSE: {
190
+ title: 'Invalid MCP Server Response',
191
+ description: 'The MCP server returned an unexpected response',
192
+ suggestions: [
193
+ 'Ensure the MCP server is up to date',
194
+ 'Check server logs for errors',
195
+ 'Verify the server implements the MCP protocol correctly',
196
+ 'Try restarting the MCP server',
197
+ ],
198
+ },
199
+ TIMEOUT: {
200
+ title: 'MCP Server Timeout',
201
+ description: 'The MCP server did not respond in time',
202
+ suggestions: [
203
+ 'Check if the server is overloaded',
204
+ 'Increase the timeout in settings',
205
+ 'Verify the server is running properly',
206
+ 'Try restarting the MCP server',
207
+ ],
208
+ },
209
+ };
210
+ /**
211
+ * Bash command error templates
212
+ */
213
+ const BASH_ERROR_PATTERNS = {
214
+ COMMAND_NOT_FOUND: {
215
+ title: 'Command Not Found',
216
+ description: 'The specified command is not available',
217
+ suggestions: [
218
+ 'Install the required command',
219
+ 'Check if the command is in your PATH',
220
+ 'Verify the command name is correct',
221
+ 'Try using the full path to the command',
222
+ ],
223
+ },
224
+ EXIT_CODE_1: {
225
+ title: 'Command Failed',
226
+ description: 'The command exited with an error',
227
+ suggestions: [
228
+ 'Check the command output above for details',
229
+ 'Verify command arguments are correct',
230
+ 'Ensure required files/resources exist',
231
+ 'Try running the command manually to debug',
232
+ ],
233
+ },
234
+ SECURITY_VIOLATION: {
235
+ title: 'Security Restriction',
236
+ description: 'This command is blocked for security reasons',
237
+ suggestions: [
238
+ 'Use allowed commands only',
239
+ 'Check security settings in .ax-cli/settings.json',
240
+ 'Avoid destructive operations without confirmation',
241
+ 'Use safe alternatives when available',
242
+ ],
243
+ learnMore: 'https://docs.ax-cli.dev/security#command-restrictions',
244
+ },
245
+ };
246
+ /**
247
+ * Format an error message with user-friendly structure
248
+ */
249
+ export function formatEnhancedError(category, operation, errorMessage, options) {
250
+ const template = getErrorTemplate(category, errorMessage, options);
251
+ if (!template) {
252
+ // Fallback to standard error message
253
+ return `[${category}] ${operation} failed: ${errorMessage}`;
254
+ }
255
+ // Build enhanced error message
256
+ const parts = [];
257
+ // Header with emoji icon
258
+ const icon = getErrorIcon(category);
259
+ parts.push(`${icon} ${template.title}\n`);
260
+ // Operation context
261
+ parts.push(`Operation: ${operation}`);
262
+ // File path if provided
263
+ if (options?.filePath) {
264
+ parts.push(`File: ${options.filePath}`);
265
+ }
266
+ // Description
267
+ parts.push(`\n${template.description}`);
268
+ // Original error if different from description
269
+ if (!template.description.includes(errorMessage) && errorMessage.length < 200) {
270
+ parts.push(`Error: ${errorMessage}`);
271
+ }
272
+ // Additional details if provided
273
+ if (options?.details) {
274
+ parts.push(`Details: ${options.details}`);
275
+ }
276
+ // Suggestions
277
+ if (template.suggestions.length > 0) {
278
+ parts.push('\n💡 How to fix:');
279
+ template.suggestions.forEach((suggestion, idx) => {
280
+ parts.push(` ${idx + 1}. ${suggestion}`);
281
+ });
282
+ }
283
+ // Learn more link
284
+ if (template.learnMore) {
285
+ parts.push(`\n📚 Learn more: ${template.learnMore}`);
286
+ }
287
+ return parts.join('\n');
288
+ }
289
+ /**
290
+ * Get error template based on category and error message
291
+ */
292
+ function getErrorTemplate(category, errorMessage, options) {
293
+ const lowerError = errorMessage.toLowerCase();
294
+ // File operations
295
+ if (category === ErrorCategory.FILE_OPERATION) {
296
+ // Check for specific error codes
297
+ for (const [code, template] of Object.entries(FILE_ERROR_PATTERNS)) {
298
+ if (lowerError.includes(code.toLowerCase()) ||
299
+ errorMessage.includes(code)) {
300
+ return template;
301
+ }
302
+ }
303
+ // Pattern matching
304
+ if (lowerError.includes('not found') || lowerError.includes('no such file')) {
305
+ return FILE_ERROR_PATTERNS.ENOENT;
306
+ }
307
+ if (lowerError.includes('permission') || lowerError.includes('access denied')) {
308
+ return FILE_ERROR_PATTERNS.EACCES;
309
+ }
310
+ if (lowerError.includes('is a directory')) {
311
+ return FILE_ERROR_PATTERNS.EISDIR;
312
+ }
313
+ if (lowerError.includes('already exists')) {
314
+ return FILE_ERROR_PATTERNS.EEXIST;
315
+ }
316
+ }
317
+ // API errors
318
+ if (category === ErrorCategory.API_ERROR ||
319
+ category === ErrorCategory.AUTHENTICATION ||
320
+ category === ErrorCategory.RATE_LIMIT) {
321
+ if (options?.statusCode && API_ERROR_PATTERNS[options.statusCode]) {
322
+ return API_ERROR_PATTERNS[options.statusCode];
323
+ }
324
+ }
325
+ // MCP errors
326
+ if (category === ErrorCategory.MCP_CONNECTION) {
327
+ if (lowerError.includes('connection') || lowerError.includes('connect')) {
328
+ return MCP_ERROR_PATTERNS.CONNECTION_FAILED;
329
+ }
330
+ if (lowerError.includes('timeout')) {
331
+ return MCP_ERROR_PATTERNS.TIMEOUT;
332
+ }
333
+ if (lowerError.includes('invalid') || lowerError.includes('unexpected')) {
334
+ return MCP_ERROR_PATTERNS.INVALID_RESPONSE;
335
+ }
336
+ }
337
+ // Bash errors
338
+ if (category === ErrorCategory.BASH_COMMAND) {
339
+ if (lowerError.includes('command not found') || lowerError.includes('not found')) {
340
+ return BASH_ERROR_PATTERNS.COMMAND_NOT_FOUND;
341
+ }
342
+ if (lowerError.includes('security') || lowerError.includes('blocked')) {
343
+ return BASH_ERROR_PATTERNS.SECURITY_VIOLATION;
344
+ }
345
+ if (lowerError.includes('exit code 1') || errorMessage.includes('code 1')) {
346
+ return BASH_ERROR_PATTERNS.EXIT_CODE_1;
347
+ }
348
+ }
349
+ return null;
350
+ }
351
+ /**
352
+ * Get emoji icon for error category
353
+ */
354
+ function getErrorIcon(category) {
355
+ switch (category) {
356
+ case ErrorCategory.FILE_OPERATION:
357
+ return '📁';
358
+ case ErrorCategory.BASH_COMMAND:
359
+ return '⚡';
360
+ case ErrorCategory.MCP_CONNECTION:
361
+ return '🔌';
362
+ case ErrorCategory.API_ERROR:
363
+ case ErrorCategory.AUTHENTICATION:
364
+ return '🔑';
365
+ case ErrorCategory.RATE_LIMIT:
366
+ return '⏱️';
367
+ case ErrorCategory.NETWORK:
368
+ return '🌐';
369
+ case ErrorCategory.CONFIGURATION:
370
+ return '⚙️';
371
+ case ErrorCategory.VALIDATION:
372
+ return '✅';
373
+ case ErrorCategory.TIMEOUT:
374
+ return '⌛';
375
+ default:
376
+ return '❌';
377
+ }
378
+ }
379
+ /**
380
+ * Create a user-friendly error for common scenarios
381
+ */
382
+ export function createFriendlyError(category, operation, error, options) {
383
+ // Extract error message and code
384
+ let errorMessage;
385
+ let errorCode;
386
+ let statusCode;
387
+ if (error instanceof Error) {
388
+ errorMessage = error.message;
389
+ // Try to extract error code from Error
390
+ const err = error;
391
+ errorCode = err.code;
392
+ statusCode = err.statusCode || err.status;
393
+ }
394
+ else if (typeof error === 'object' && error !== null) {
395
+ const err = error;
396
+ errorMessage = err.message || err.error?.message || JSON.stringify(error);
397
+ errorCode = err.code || err.error?.code;
398
+ statusCode = err.status || err.statusCode || err.error?.status;
399
+ }
400
+ else {
401
+ errorMessage = String(error);
402
+ }
403
+ return formatEnhancedError(category, operation, errorMessage, {
404
+ ...options,
405
+ errorCode,
406
+ statusCode,
407
+ });
408
+ }
409
+ /**
410
+ * Quick helper functions for common error scenarios
411
+ */
412
+ export const FriendlyErrors = {
413
+ fileNotFound: (filePath) => formatEnhancedError(ErrorCategory.FILE_OPERATION, 'Read file', 'ENOENT', { filePath }),
414
+ permissionDenied: (filePath) => formatEnhancedError(ErrorCategory.FILE_OPERATION, 'Access file', 'EACCES', { filePath }),
415
+ apiKeyInvalid: () => formatEnhancedError(ErrorCategory.AUTHENTICATION, 'API request', 'Invalid API key', { statusCode: 401 }),
416
+ rateLimitExceeded: () => formatEnhancedError(ErrorCategory.RATE_LIMIT, 'API request', 'Rate limit exceeded', { statusCode: 429 }),
417
+ mcpConnectionFailed: (serverName) => formatEnhancedError(ErrorCategory.MCP_CONNECTION, `Connect to ${serverName}`, 'Connection failed', { details: `MCP server "${serverName}" is not responding` }),
418
+ commandNotFound: (command) => formatEnhancedError(ErrorCategory.BASH_COMMAND, `Execute command`, 'command not found', { details: `Command "${command}" is not available` }),
419
+ };
420
+ //# sourceMappingURL=enhanced-error-messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enhanced-error-messages.js","sourceRoot":"","sources":["../../src/utils/enhanced-error-messages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAYnD;;GAEG;AACH,MAAM,mBAAmB,GAAyC;IAChE,MAAM,EAAE;QACN,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE,mCAAmC;QAChD,WAAW,EAAE;YACX,mCAAmC;YACnC,8CAA8C;YAC9C,uCAAuC;YACvC,kCAAkC;SACnC;KACF;IACD,MAAM,EAAE;QACN,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EAAE,gDAAgD;QAC7D,WAAW,EAAE;YACX,6CAA6C;YAC7C,mCAAmC;YACnC,0CAA0C;YAC1C,6CAA6C;SAC9C;KACF;IACD,MAAM,EAAE;QACN,KAAK,EAAE,8BAA8B;QACrC,WAAW,EAAE,4CAA4C;QACzD,WAAW,EAAE;YACX,4CAA4C;YAC5C,mCAAmC;YACnC,uCAAuC;SACxC;KACF;IACD,OAAO,EAAE;QACP,KAAK,EAAE,8BAA8B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,CACjB,aAAa,CAAC,YAAY,EAC1B,iBAAiB,EACjB,mBAAmB,EACnB,EAAE,OAAO,EAAE,YAAY,OAAO,oBAAoB,EAAE,CACrD;CACJ,CAAC"}
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Centralized error handling utilities
3
3
  * Provides consistent error messages and logging
4
+ * Phase 5: Enhanced with user-friendly error messages
4
5
  */
5
6
  import { ToolResult } from '../types/index.js';
6
7
  /**
@@ -23,13 +24,22 @@ export declare enum ErrorCategory {
23
24
  }
24
25
  /**
25
26
  * Create a standardized error message
26
- * Phase 3: Enhanced with actionable suggestions
27
+ * Phase 5: Enhanced with user-friendly formatting
27
28
  */
28
- export declare function createErrorMessage(category: ErrorCategory, operation: string, error: unknown): string;
29
+ export declare function createErrorMessage(category: ErrorCategory, operation: string, error: unknown, options?: {
30
+ filePath?: string;
31
+ details?: string;
32
+ useEnhancedFormat?: boolean;
33
+ }): string;
29
34
  /**
30
35
  * Create a standardized ToolResult error
36
+ * Phase 5: Enhanced with optional file path
31
37
  */
32
- export declare function createToolError(category: ErrorCategory, operation: string, error: unknown): ToolResult;
38
+ export declare function createToolError(category: ErrorCategory, operation: string, error: unknown, options?: {
39
+ filePath?: string;
40
+ details?: string;
41
+ useEnhancedFormat?: boolean;
42
+ }): ToolResult;
33
43
  /**
34
44
  * Create a standardized ToolResult success
35
45
  */
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Centralized error handling utilities
3
3
  * Provides consistent error messages and logging
4
+ * Phase 5: Enhanced with user-friendly error messages
4
5
  */
6
+ import { createFriendlyError } from './enhanced-error-messages.js';
5
7
  /**
6
8
  * Standard error categories
7
9
  */
@@ -69,9 +71,18 @@ function getErrorSuggestion(category, errorMessage) {
69
71
  }
70
72
  /**
71
73
  * Create a standardized error message
72
- * Phase 3: Enhanced with actionable suggestions
74
+ * Phase 5: Enhanced with user-friendly formatting
73
75
  */
74
- export function createErrorMessage(category, operation, error) {
76
+ export function createErrorMessage(category, operation, error, options) {
77
+ // Use enhanced formatting by default for better UX
78
+ const useEnhanced = options?.useEnhancedFormat !== false;
79
+ if (useEnhanced) {
80
+ return createFriendlyError(category, operation, error, {
81
+ filePath: options?.filePath,
82
+ details: options?.details,
83
+ });
84
+ }
85
+ // Legacy format (kept for backwards compatibility)
75
86
  const errorMsg = extractErrorMessage(error);
76
87
  const baseMessage = `[${category}] ${operation} failed: ${errorMsg}`;
77
88
  // Add suggestion if available
@@ -83,11 +94,12 @@ export function createErrorMessage(category, operation, error) {
83
94
  }
84
95
  /**
85
96
  * Create a standardized ToolResult error
97
+ * Phase 5: Enhanced with optional file path
86
98
  */
87
- export function createToolError(category, operation, error) {
99
+ export function createToolError(category, operation, error, options) {
88
100
  return {
89
101
  success: false,
90
- error: createErrorMessage(category, operation, error),
102
+ error: createErrorMessage(category, operation, error, options),
91
103
  };
92
104
  }
93
105
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,CAAN,IAAY,aAcX;AAdD,WAAY,aAAa;IACvB,kDAAiC,CAAA;IACjC,8CAA6B,CAAA;IAC7B,kDAAiC,CAAA;IACjC,kDAAiC,CAAA;IACjC,0CAAyB,CAAA;IACzB,oCAAmB,CAAA;IACnB,gDAA+B,CAAA;IAC/B,wCAAuB,CAAA;IACvB,kDAAiC,CAAA;IACjC,0CAAyB,CAAA;IACzB,wDAAuC,CAAA;IACvC,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;AACrB,CAAC,EAdW,aAAa,KAAb,aAAa,QAcxB;AAED;;;GAGG;AACH,SAAS,kBAAkB,CAAC,QAAuB,EAAE,YAAoB;IACvE,MAAM,UAAU,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC;IAE9C,wBAAwB;IACxB,IAAI,QAAQ,KAAK,aAAa,CAAC,cAAc,EAAE,CAAC;QAC9C,IAAI,UAAU,CAAC,QAAQ,CA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E,IAAI;QACb,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAY;IAEZ,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;QACnC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC;SAClC,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAuB,EACvB,SAAiB,EACjB,EAAoB;IAEpB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;QAC1B,OAAO,iBAAiB,CACtB,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAC7D,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,eAAe,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * External Editor Integration (Phase 2: P2.3)
3
+ *
4
+ * Opens user's preferred $EDITOR to compose or edit messages.
5
+ * Supports safety checks and temporary file cleanup.
6
+ */
7
+ /**
8
+ * Result of external editor operation
9
+ */
10
+ export interface ExternalEditorResult {
11
+ success: boolean;
12
+ content?: string;
13
+ error?: string;
14
+ cancelled?: boolean;
15
+ }
16
+ /**
17
+ * Options for opening external editor
18
+ */
19
+ export interface ExternalEditorOptions {
20
+ initialContent?: string;
21
+ editor?: string;
22
+ fileExtension?: string;
23
+ timeout?: number;
24
+ }
25
+ /**
26
+ * Get the preferred editor from environment
27
+ * Falls back to sensible defaults based on platform
28
+ */
29
+ export declare function getPreferredEditor(): string;
30
+ /**
31
+ * Open external editor and return edited content
32
+ *
33
+ * @param options Editor options
34
+ * @returns Result containing edited content or error
35
+ */
36
+ export declare function openExternalEditor(options?: ExternalEditorOptions): Promise<ExternalEditorResult>;
37
+ /**
38
+ * Check if external editor is available
39
+ *
40
+ * @param editor Optional specific editor to check
41
+ * @returns True if editor is available
42
+ */
43
+ export declare function isEditorAvailable(editor?: string): Promise<boolean>;
44
+ /**
45
+ * Get user-friendly editor name for display
46
+ */
47
+ export declare function getEditorDisplayName(editor?: string): string;