@paulduvall/claude-dev-toolkit 0.0.1-alpha.2 → 0.0.1-alpha.21

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 (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88 -37
  3. package/bin/claude-commands +307 -65
  4. package/commands/active/xarchitecture.md +393 -0
  5. package/commands/active/xconfig.md +127 -0
  6. package/commands/active/xcontinue.md +92 -0
  7. package/commands/active/xdebug.md +130 -0
  8. package/commands/active/xdocs.md +178 -0
  9. package/commands/active/xexplore.md +94 -0
  10. package/commands/active/xgit.md +149 -0
  11. package/commands/active/xpipeline.md +152 -0
  12. package/commands/active/xquality.md +96 -0
  13. package/commands/active/xrefactor.md +198 -0
  14. package/commands/active/xrelease.md +142 -0
  15. package/commands/active/xsecurity.md +92 -0
  16. package/commands/active/xspec.md +174 -0
  17. package/commands/active/xtdd.md +151 -0
  18. package/commands/active/xtest.md +89 -0
  19. package/commands/active/xverify.md +80 -0
  20. package/commands/experiments/xact.md +742 -0
  21. package/commands/experiments/xanalytics.md +113 -0
  22. package/commands/experiments/xanalyze.md +70 -0
  23. package/commands/experiments/xapi.md +161 -0
  24. package/commands/experiments/xatomic.md +112 -0
  25. package/commands/experiments/xaws.md +85 -0
  26. package/commands/experiments/xcicd.md +337 -0
  27. package/commands/experiments/xcommit.md +122 -0
  28. package/commands/experiments/xcompliance.md +182 -0
  29. package/commands/experiments/xconstraints.md +89 -0
  30. package/commands/experiments/xcoverage.md +90 -0
  31. package/commands/experiments/xdb.md +102 -0
  32. package/commands/experiments/xdesign.md +121 -0
  33. package/commands/experiments/xdevcontainer.md +238 -0
  34. package/commands/experiments/xevaluate.md +111 -0
  35. package/commands/experiments/xfootnote.md +12 -0
  36. package/commands/experiments/xgenerate.md +117 -0
  37. package/commands/experiments/xgovernance.md +149 -0
  38. package/commands/experiments/xgreen.md +66 -0
  39. package/commands/experiments/xiac.md +118 -0
  40. package/commands/experiments/xincident.md +137 -0
  41. package/commands/experiments/xinfra.md +115 -0
  42. package/commands/experiments/xknowledge.md +115 -0
  43. package/commands/experiments/xmaturity.md +120 -0
  44. package/commands/experiments/xmetrics.md +118 -0
  45. package/commands/experiments/xmonitoring.md +128 -0
  46. package/commands/experiments/xnew.md +903 -0
  47. package/commands/experiments/xobservable.md +114 -0
  48. package/commands/experiments/xoidc.md +165 -0
  49. package/commands/experiments/xoptimize.md +115 -0
  50. package/commands/experiments/xperformance.md +112 -0
  51. package/commands/experiments/xplanning.md +131 -0
  52. package/commands/experiments/xpolicy.md +115 -0
  53. package/commands/experiments/xproduct.md +98 -0
  54. package/commands/experiments/xreadiness.md +75 -0
  55. package/commands/experiments/xred.md +55 -0
  56. package/commands/experiments/xrisk.md +128 -0
  57. package/commands/experiments/xrules.md +124 -0
  58. package/commands/experiments/xsandbox.md +120 -0
  59. package/commands/experiments/xscan.md +102 -0
  60. package/commands/experiments/xsetup.md +123 -0
  61. package/commands/experiments/xtemplate.md +116 -0
  62. package/commands/experiments/xtrace.md +212 -0
  63. package/commands/experiments/xux.md +171 -0
  64. package/commands/experiments/xvalidate.md +104 -0
  65. package/commands/experiments/xworkflow.md +113 -0
  66. package/hooks/.smellrc.example.json +19 -0
  67. package/hooks/README.md +263 -0
  68. package/hooks/check-commit-signing.py +127 -0
  69. package/hooks/check-complexity.py +38 -0
  70. package/hooks/check-security.py +37 -0
  71. package/hooks/claude-wrapper.sh +29 -0
  72. package/hooks/config.py +110 -0
  73. package/hooks/file-logger.sh +100 -0
  74. package/hooks/lib/argument-parser.sh +427 -0
  75. package/hooks/lib/config-constants.sh +230 -0
  76. package/hooks/lib/context-manager.sh +560 -0
  77. package/hooks/lib/error-handler.sh +423 -0
  78. package/hooks/lib/execution-engine.sh +444 -0
  79. package/hooks/lib/execution-results.sh +113 -0
  80. package/hooks/lib/execution-simulation.sh +114 -0
  81. package/hooks/lib/field-validators.sh +104 -0
  82. package/hooks/lib/file-utils.sh +398 -0
  83. package/hooks/lib/subagent-discovery.sh +468 -0
  84. package/hooks/lib/subagent-validator.sh +407 -0
  85. package/hooks/lib/validation-reporter.sh +134 -0
  86. package/hooks/on-error-debug.sh +226 -0
  87. package/hooks/pre-commit-quality.sh +204 -0
  88. package/hooks/pre-commit-test-runner.sh +132 -0
  89. package/hooks/pre-write-security.sh +115 -0
  90. package/hooks/prevent-credential-exposure.sh +279 -0
  91. package/hooks/security_bandit.py +177 -0
  92. package/hooks/security_checks.py +97 -0
  93. package/hooks/security_secrets.py +81 -0
  94. package/hooks/security_trojan.py +61 -0
  95. package/hooks/settings.example.json +52 -0
  96. package/hooks/smell_checks.py +238 -0
  97. package/hooks/smell_javascript.py +231 -0
  98. package/hooks/smell_python.py +110 -0
  99. package/hooks/smell_ruff.py +70 -0
  100. package/hooks/smell_types.py +72 -0
  101. package/hooks/subagent-trigger-simple.sh +202 -0
  102. package/hooks/subagent-trigger.sh +253 -0
  103. package/hooks/suppression.py +82 -0
  104. package/hooks/tab-color.sh +70 -0
  105. package/hooks/verify-before-edit.sh +135 -0
  106. package/lib/backup-restore-command.js +140 -0
  107. package/lib/base/base-command.js +252 -0
  108. package/lib/base/command-result.js +184 -0
  109. package/lib/config/constants.js +255 -0
  110. package/lib/config.js +48 -6
  111. package/lib/configure-command.js +428 -0
  112. package/lib/dependency-validator.js +64 -5
  113. package/lib/hook-installer-core.js +2 -2
  114. package/lib/installation-instruction-generator.js +213 -495
  115. package/lib/installer.js +134 -56
  116. package/lib/oidc-command.js +740 -0
  117. package/lib/services/backup-list-service.js +226 -0
  118. package/lib/services/backup-service.js +230 -0
  119. package/lib/services/command-installer-service.js +217 -0
  120. package/lib/services/logger-service.js +201 -0
  121. package/lib/services/package-manager-service.js +319 -0
  122. package/lib/services/platform-instruction-service.js +294 -0
  123. package/lib/services/recovery-instruction-service.js +348 -0
  124. package/lib/services/restore-service.js +221 -0
  125. package/lib/setup-command.js +359 -0
  126. package/lib/setup-wizard.js +155 -262
  127. package/lib/uninstall-command.js +100 -0
  128. package/lib/utils/claude-path-config.js +184 -0
  129. package/lib/utils/file-system-utils.js +152 -0
  130. package/lib/utils.js +8 -4
  131. package/lib/verify-command.js +430 -0
  132. package/package.json +7 -3
  133. package/scripts/postinstall.js +172 -157
  134. package/subagents/debug-specialist.md +7 -0
  135. package/templates/README.md +115 -0
  136. package/templates/basic-settings.json +30 -0
  137. package/templates/comprehensive-settings.json +57 -0
  138. package/templates/global-claude.md +344 -0
  139. package/templates/hybrid-hook-config.yaml +132 -0
  140. package/templates/security-focused-settings.json +62 -0
  141. package/templates/subagent-hooks.yaml +188 -0
  142. package/lib/package-manager-service.js +0 -270
  143. package/subagents/debug-context.md +0 -197
@@ -0,0 +1,294 @@
1
+ /**
2
+ * Platform Instruction Service
3
+ * Handles platform-specific installation instructions
4
+ */
5
+
6
+ const { DOWNLOAD_LINKS, PACKAGE_MANAGERS } = require('../config/constants');
7
+
8
+ class PlatformInstructionService {
9
+ constructor() {
10
+ this.downloadLinks = DOWNLOAD_LINKS;
11
+ this.packageManagers = PACKAGE_MANAGERS;
12
+ }
13
+
14
+ /**
15
+ * Generate platform-specific installation instructions
16
+ * @param {string} platform - Target platform
17
+ * @param {Object} dependency - Dependency information
18
+ * @returns {Object} Platform-specific instructions
19
+ */
20
+ generatePlatformInstructions(platform, dependency) {
21
+ const instructions = this._initializePlatformInstructions(platform);
22
+
23
+ this._addPlatformPackageManagers(instructions, platform, dependency);
24
+ this._setDefaultPackageManager(instructions, platform);
25
+ this._addPlatformSpecificNotes(instructions, platform, dependency);
26
+
27
+ return instructions;
28
+ }
29
+
30
+ /**
31
+ * Initialize platform-specific instruction structure
32
+ * @param {string} platform - Target platform
33
+ * @returns {Object} Initialized instructions
34
+ * @private
35
+ */
36
+ _initializePlatformInstructions(platform) {
37
+ return {
38
+ platform,
39
+ packageManagerOptions: [],
40
+ downloadLinks: this._getPlatformDownloadLinks(platform),
41
+ notes: [],
42
+ troubleshooting: []
43
+ };
44
+ }
45
+
46
+ /**
47
+ * Get download links for platform
48
+ * @param {string} platform - Target platform
49
+ * @returns {Object} Platform download links
50
+ * @private
51
+ */
52
+ _getPlatformDownloadLinks(platform) {
53
+ const links = {};
54
+
55
+ Object.keys(this.downloadLinks).forEach(tool => {
56
+ if (this.downloadLinks[tool][platform]) {
57
+ links[tool] = this.downloadLinks[tool][platform];
58
+ } else if (this.downloadLinks[tool].all) {
59
+ links[tool] = this.downloadLinks[tool].all;
60
+ }
61
+ });
62
+
63
+ return links;
64
+ }
65
+
66
+ /**
67
+ * Add platform-specific package managers
68
+ * @param {Object} instructions - Instructions object to modify
69
+ * @param {string} platform - Target platform
70
+ * @param {Object} dependency - Dependency information
71
+ * @private
72
+ */
73
+ _addPlatformPackageManagers(instructions, platform, dependency) {
74
+ const availableManagers = this._getAvailablePackageManagers(platform);
75
+
76
+ availableManagers.forEach(manager => {
77
+ const managerInfo = this.packageManagers[manager];
78
+ if (this._isManagerSupportedOnPlatform(manager, platform)) {
79
+ instructions.packageManagerOptions.push({
80
+ name: managerInfo.name,
81
+ command: this._buildInstallCommand(managerInfo, dependency),
82
+ checkCommand: managerInfo.checkCommand,
83
+ installUrl: managerInfo.installUrl,
84
+ global: dependency.global || false
85
+ });
86
+ }
87
+ });
88
+ }
89
+
90
+ /**
91
+ * Get available package managers for platform
92
+ * @param {string} platform - Target platform
93
+ * @returns {Array} Available package managers
94
+ * @private
95
+ */
96
+ _getAvailablePackageManagers(platform) {
97
+ const platformManagers = {
98
+ linux: ['npm', 'yarn', 'pnpm', 'apt', 'yum'],
99
+ darwin: ['npm', 'yarn', 'pnpm', 'brew'],
100
+ win32: ['npm', 'yarn', 'pnpm', 'chocolatey', 'winget']
101
+ };
102
+
103
+ return platformManagers[platform] || ['npm', 'yarn', 'pnpm'];
104
+ }
105
+
106
+ /**
107
+ * Check if package manager is supported on platform
108
+ * @param {string} manager - Package manager name
109
+ * @param {string} platform - Target platform
110
+ * @returns {boolean} Is supported
111
+ * @private
112
+ */
113
+ _isManagerSupportedOnPlatform(manager, platform) {
114
+ const managerInfo = this.packageManagers[manager];
115
+ if (!managerInfo) return false;
116
+
117
+ if (managerInfo.platforms) {
118
+ return managerInfo.platforms.includes(platform);
119
+ }
120
+
121
+ return true; // Universal managers like npm
122
+ }
123
+
124
+ /**
125
+ * Build installation command for dependency
126
+ * @param {Object} managerInfo - Package manager information
127
+ * @param {Object} dependency - Dependency information
128
+ * @returns {string} Installation command
129
+ * @private
130
+ */
131
+ _buildInstallCommand(managerInfo, dependency) {
132
+ const baseCommand = dependency.global ? managerInfo.globalInstall : managerInfo.install;
133
+ const packageName = dependency.packageName || dependency.name;
134
+ const version = dependency.version ? `@${dependency.version}` : '';
135
+
136
+ return `${baseCommand} ${packageName}${version}`;
137
+ }
138
+
139
+ /**
140
+ * Set default package manager based on platform
141
+ * @param {Object} instructions - Instructions object to modify
142
+ * @param {string} platform - Target platform
143
+ * @private
144
+ */
145
+ _setDefaultPackageManager(instructions, platform) {
146
+ if (instructions.packageManagerOptions.length === 0) return;
147
+
148
+ const platformDefaults = {
149
+ linux: 'apt',
150
+ darwin: 'brew',
151
+ win32: 'npm'
152
+ };
153
+
154
+ const defaultManager = platformDefaults[platform] || 'npm';
155
+ const defaultOption = instructions.packageManagerOptions.find(opt =>
156
+ opt.name.toLowerCase() === defaultManager
157
+ ) || instructions.packageManagerOptions[0];
158
+
159
+ if (defaultOption) {
160
+ defaultOption.default = true;
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Add platform-specific notes and warnings
166
+ * @param {Object} instructions - Instructions object to modify
167
+ * @param {string} platform - Target platform
168
+ * @param {Object} dependency - Dependency information
169
+ * @private
170
+ */
171
+ _addPlatformSpecificNotes(instructions, platform, dependency) {
172
+ switch (platform) {
173
+ case 'linux':
174
+ instructions.notes.push('You may need to use sudo for system-wide installations');
175
+ if (dependency.name === 'node') {
176
+ instructions.notes.push('Consider using a Node version manager like nvm');
177
+ }
178
+ break;
179
+
180
+ case 'darwin':
181
+ instructions.notes.push('Homebrew is the recommended package manager for macOS');
182
+ if (dependency.name === 'python') {
183
+ instructions.notes.push('macOS comes with Python 2.7, but Python 3+ is recommended');
184
+ }
185
+ break;
186
+
187
+ case 'win32':
188
+ instructions.notes.push('Run PowerShell or Command Prompt as Administrator if needed');
189
+ instructions.notes.push('Windows Subsystem for Linux (WSL) may provide better compatibility');
190
+ break;
191
+ }
192
+
193
+ // Add dependency-specific notes
194
+ this._addDependencySpecificNotes(instructions, dependency);
195
+ }
196
+
197
+ /**
198
+ * Add dependency-specific notes
199
+ * @param {Object} instructions - Instructions object to modify
200
+ * @param {Object} dependency - Dependency information
201
+ * @private
202
+ */
203
+ _addDependencySpecificNotes(instructions, dependency) {
204
+ switch (dependency.name) {
205
+ case 'git':
206
+ instructions.notes.push('Git is required for version control operations');
207
+ instructions.troubleshooting.push('If git command not found, add Git to your system PATH');
208
+ break;
209
+
210
+ case 'node':
211
+ instructions.notes.push('Node.js includes npm package manager');
212
+ instructions.troubleshooting.push('Use "node --version" to verify installation');
213
+ break;
214
+
215
+ case 'python':
216
+ instructions.notes.push('Python 3.8+ is recommended for modern development');
217
+ instructions.troubleshooting.push('Use "python3" instead of "python" on some systems');
218
+ break;
219
+
220
+ case 'docker':
221
+ instructions.notes.push('Docker requires system virtualization to be enabled');
222
+ instructions.troubleshooting.push('Restart your system after Docker installation');
223
+ break;
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Generate troubleshooting guide for platform
229
+ * @param {string} platform - Target platform
230
+ * @param {string} dependencyName - Dependency that failed
231
+ * @returns {Array} Troubleshooting steps
232
+ */
233
+ generateTroubleshootingGuide(platform, dependencyName) {
234
+ const guide = [];
235
+
236
+ // Platform-specific troubleshooting
237
+ switch (platform) {
238
+ case 'linux':
239
+ guide.push('Check if dependency is available in your distribution\'s package repository');
240
+ guide.push('Update package lists: sudo apt update (Ubuntu/Debian) or sudo yum update (RHEL/CentOS)');
241
+ guide.push('Verify PATH environment variable includes installation directory');
242
+ break;
243
+
244
+ case 'darwin':
245
+ guide.push('Install Xcode Command Line Tools: xcode-select --install');
246
+ guide.push('Update Homebrew: brew update && brew upgrade');
247
+ guide.push('Check for conflicting installations in /usr/local/bin');
248
+ break;
249
+
250
+ case 'win32':
251
+ guide.push('Run installation as Administrator');
252
+ guide.push('Disable Windows Defender temporarily during installation');
253
+ guide.push('Check Windows PATH environment variable');
254
+ guide.push('Consider using Windows Subsystem for Linux (WSL)');
255
+ break;
256
+ }
257
+
258
+ // Dependency-specific troubleshooting
259
+ guide.push(...this._getDependencyTroubleshooting(dependencyName));
260
+
261
+ return guide;
262
+ }
263
+
264
+ /**
265
+ * Get dependency-specific troubleshooting steps
266
+ * @param {string} dependencyName - Name of the dependency
267
+ * @returns {Array} Troubleshooting steps
268
+ * @private
269
+ */
270
+ _getDependencyTroubleshooting(dependencyName) {
271
+ const troubleshooting = {
272
+ git: [
273
+ 'Download from official Git website if package manager fails',
274
+ 'Configure Git after installation: git config --global user.name "Your Name"'
275
+ ],
276
+ node: [
277
+ 'Use Node Version Manager (nvm) for easier version management',
278
+ 'Clear npm cache: npm cache clean --force'
279
+ ],
280
+ python: [
281
+ 'Use pyenv for Python version management',
282
+ 'Install pip separately if not included: python -m ensurepip --upgrade'
283
+ ],
284
+ docker: [
285
+ 'Enable Hyper-V on Windows or ensure virtualization is enabled in BIOS',
286
+ 'Join docker group on Linux: sudo usermod -aG docker $USER'
287
+ ]
288
+ };
289
+
290
+ return troubleshooting[dependencyName] || [];
291
+ }
292
+ }
293
+
294
+ module.exports = PlatformInstructionService;
@@ -0,0 +1,348 @@
1
+ /**
2
+ * Recovery Instruction Service
3
+ * Generates recovery and troubleshooting instructions for failed installations
4
+ */
5
+
6
+ const { ERROR_MESSAGES } = require('../config/constants');
7
+
8
+ class RecoveryInstructionService {
9
+ constructor() {
10
+ this.errorMessages = ERROR_MESSAGES;
11
+ this.commonRecoverySteps = this._initializeCommonRecoverySteps();
12
+ }
13
+
14
+ /**
15
+ * Generate recovery suggestions for failed dependency
16
+ * @param {Object} failedDependency - Dependency that failed validation
17
+ * @returns {Object} Recovery suggestions
18
+ */
19
+ generateRecoverySuggestions(failedDependency) {
20
+ const suggestions = {
21
+ immediate: [],
22
+ alternative: [],
23
+ troubleshooting: [],
24
+ additionalResources: []
25
+ };
26
+
27
+ if (!failedDependency || !failedDependency.error) {
28
+ return this._getGenericRecoverySuggestions(failedDependency);
29
+ }
30
+
31
+ // Generate error-specific suggestions
32
+ this._addErrorSpecificSuggestions(suggestions, failedDependency);
33
+
34
+ // Add dependency-specific suggestions
35
+ this._addDependencySpecificSuggestions(suggestions, failedDependency);
36
+
37
+ // Add platform-specific suggestions
38
+ this._addPlatformSpecificSuggestions(suggestions, failedDependency);
39
+
40
+ // Add general troubleshooting steps
41
+ this._addGeneralTroubleshootingSteps(suggestions);
42
+
43
+ return suggestions;
44
+ }
45
+
46
+ /**
47
+ * Initialize common recovery steps
48
+ * @returns {Object} Common recovery steps by category
49
+ * @private
50
+ */
51
+ _initializeCommonRecoverySteps() {
52
+ return {
53
+ permissions: [
54
+ 'Run command prompt or terminal as administrator/sudo',
55
+ 'Check file and directory permissions',
56
+ 'Ensure user has installation privileges'
57
+ ],
58
+ network: [
59
+ 'Check internet connection',
60
+ 'Try using a different network or VPN',
61
+ 'Configure proxy settings if behind corporate firewall',
62
+ 'Clear DNS cache: ipconfig /flushdns (Windows) or sudo dscacheutil -flushcache (macOS)'
63
+ ],
64
+ cache: [
65
+ 'Clear package manager cache',
66
+ 'Remove temporary installation files',
67
+ 'Reset package manager configuration'
68
+ ],
69
+ environment: [
70
+ 'Check system PATH environment variable',
71
+ 'Verify required environment variables are set',
72
+ 'Restart terminal/command prompt after installation',
73
+ 'Reboot system if necessary'
74
+ ]
75
+ };
76
+ }
77
+
78
+ /**
79
+ * Add error-specific recovery suggestions
80
+ * @param {Object} suggestions - Suggestions object to modify
81
+ * @param {Object} failedDependency - Failed dependency information
82
+ * @private
83
+ */
84
+ _addErrorSpecificSuggestions(suggestions, failedDependency) {
85
+ const errorCode = failedDependency.error.code || 'UNKNOWN';
86
+
87
+ switch (errorCode) {
88
+ case 'NOT_FOUND':
89
+ suggestions.immediate.push(`Install ${failedDependency.name} using your system package manager`);
90
+ suggestions.immediate.push(`Add ${failedDependency.name} to your system PATH`);
91
+ suggestions.alternative.push(`Download and install ${failedDependency.name} manually`);
92
+ suggestions.alternative.push(`Use portable version of ${failedDependency.name}`);
93
+ suggestions.troubleshooting.push(`Verify ${failedDependency.name} installation directory`);
94
+ suggestions.troubleshooting.push(`Check if ${failedDependency.name} was installed with different name`);
95
+ break;
96
+
97
+ case 'VERSION_MISMATCH':
98
+ suggestions.immediate.push(`Update ${failedDependency.name} to version ${failedDependency.requiredVersion || 'latest'}`);
99
+ suggestions.immediate.push(`Use version manager to install specific version`);
100
+ suggestions.alternative.push(`Install required version manually`);
101
+ suggestions.alternative.push(`Use Docker container with required version`);
102
+ suggestions.troubleshooting.push(`Check if multiple versions are installed`);
103
+ suggestions.troubleshooting.push(`Verify which version is in PATH`);
104
+ break;
105
+
106
+ case 'PERMISSION_DENIED':
107
+ suggestions.immediate.push(...this.commonRecoverySteps.permissions);
108
+ suggestions.alternative.push(`Install to user directory instead of system-wide`);
109
+ suggestions.alternative.push(`Use package manager that doesn't require admin rights`);
110
+ break;
111
+
112
+ case 'NETWORK_ERROR':
113
+ suggestions.immediate.push(...this.commonRecoverySteps.network);
114
+ suggestions.alternative.push(`Download installation files manually`);
115
+ suggestions.alternative.push(`Use offline installer if available`);
116
+ break;
117
+
118
+ case 'DISK_SPACE':
119
+ suggestions.immediate.push('Free up disk space by removing unnecessary files');
120
+ suggestions.immediate.push('Clean temporary files and caches');
121
+ suggestions.alternative.push('Install to different drive with more space');
122
+ suggestions.alternative.push('Use symbolic links to move installation');
123
+ break;
124
+
125
+ case 'CORRUPTED_DOWNLOAD':
126
+ suggestions.immediate.push('Clear download cache and retry');
127
+ suggestions.immediate.push('Download from different mirror or source');
128
+ suggestions.alternative.push('Verify download integrity with checksums');
129
+ suggestions.alternative.push('Use different download method');
130
+ break;
131
+
132
+ default:
133
+ suggestions.immediate.push(`Reinstall ${failedDependency.name} from scratch`);
134
+ suggestions.immediate.push('Check system logs for more details');
135
+ suggestions.troubleshooting.push('Run installation in verbose mode');
136
+ suggestions.troubleshooting.push('Check for conflicting software');
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Add dependency-specific recovery suggestions
142
+ * @param {Object} suggestions - Suggestions object to modify
143
+ * @param {Object} failedDependency - Failed dependency information
144
+ * @private
145
+ */
146
+ _addDependencySpecificSuggestions(suggestions, failedDependency) {
147
+ const dependencyName = failedDependency.name.toLowerCase();
148
+
149
+ switch (dependencyName) {
150
+ case 'node':
151
+ case 'nodejs':
152
+ suggestions.immediate.push('Install Node.js from official website: https://nodejs.org');
153
+ suggestions.alternative.push('Use Node Version Manager (nvm) for easier management');
154
+ suggestions.alternative.push('Install via package manager: brew install node (macOS)');
155
+ suggestions.troubleshooting.push('Check if Node.js is installed as "nodejs" instead of "node"');
156
+ suggestions.additionalResources.push('https://nodejs.org/en/download/package-manager/');
157
+ break;
158
+
159
+ case 'npm':
160
+ suggestions.immediate.push('npm comes with Node.js - install Node.js first');
161
+ suggestions.alternative.push('Install npm separately: npm install -g npm@latest');
162
+ suggestions.troubleshooting.push('Check npm configuration: npm config list');
163
+ suggestions.troubleshooting.push('Reset npm to defaults: npm config delete prefix');
164
+ break;
165
+
166
+ case 'git':
167
+ suggestions.immediate.push('Install Git from official website: https://git-scm.com');
168
+ suggestions.alternative.push('Install via package manager based on your OS');
169
+ suggestions.troubleshooting.push('Configure Git after installation with user name and email');
170
+ suggestions.additionalResources.push('https://git-scm.com/book/en/v2/Getting-Started-Installing-Git');
171
+ break;
172
+
173
+ case 'python':
174
+ case 'python3':
175
+ suggestions.immediate.push('Install Python from official website: https://python.org');
176
+ suggestions.alternative.push('Use Python version manager like pyenv');
177
+ suggestions.alternative.push('Install Anaconda for scientific computing');
178
+ suggestions.troubleshooting.push('Check if python3 command is available instead of python');
179
+ suggestions.troubleshooting.push('Verify pip is installed: python -m ensurepip');
180
+ suggestions.additionalResources.push('https://docs.python.org/3/using/index.html');
181
+ break;
182
+
183
+ case 'docker':
184
+ suggestions.immediate.push('Install Docker Desktop from official website');
185
+ suggestions.alternative.push('Use Docker CE for server installations');
186
+ suggestions.troubleshooting.push('Enable virtualization in BIOS settings');
187
+ suggestions.troubleshooting.push('Restart Docker service after installation');
188
+ suggestions.additionalResources.push('https://docs.docker.com/get-docker/');
189
+ break;
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Add platform-specific recovery suggestions
195
+ * @param {Object} suggestions - Suggestions object to modify
196
+ * @param {Object} failedDependency - Failed dependency information
197
+ * @private
198
+ */
199
+ _addPlatformSpecificSuggestions(suggestions, failedDependency) {
200
+ const platform = process.platform;
201
+
202
+ switch (platform) {
203
+ case 'win32':
204
+ suggestions.troubleshooting.push('Try Windows Subsystem for Linux (WSL) for better compatibility');
205
+ suggestions.troubleshooting.push('Use PowerShell instead of Command Prompt');
206
+ suggestions.troubleshooting.push('Temporarily disable Windows Defender during installation');
207
+ suggestions.alternative.push('Use Chocolatey package manager: https://chocolatey.org');
208
+ suggestions.alternative.push('Use winget package manager if available');
209
+ break;
210
+
211
+ case 'darwin':
212
+ suggestions.alternative.push('Use Homebrew package manager: https://brew.sh');
213
+ suggestions.troubleshooting.push('Install Xcode Command Line Tools: xcode-select --install');
214
+ suggestions.troubleshooting.push('Check for conflicting installations in /usr/local');
215
+ break;
216
+
217
+ case 'linux':
218
+ suggestions.alternative.push('Use distribution package manager (apt, yum, pacman, etc.)');
219
+ suggestions.troubleshooting.push('Update package lists before installation');
220
+ suggestions.troubleshooting.push('Check if package is available in distribution repositories');
221
+ suggestions.troubleshooting.push('Consider using Snap or Flatpak for universal packages');
222
+ break;
223
+ }
224
+ }
225
+
226
+ /**
227
+ * Add general troubleshooting steps
228
+ * @param {Object} suggestions - Suggestions object to modify
229
+ * @private
230
+ */
231
+ _addGeneralTroubleshootingSteps(suggestions) {
232
+ suggestions.troubleshooting.push(...this.commonRecoverySteps.environment);
233
+ suggestions.troubleshooting.push('Check system logs for error details');
234
+ suggestions.troubleshooting.push('Try installation in safe mode or clean environment');
235
+ suggestions.troubleshooting.push('Verify system meets minimum requirements');
236
+ }
237
+
238
+ /**
239
+ * Get generic recovery suggestions when error details are not available
240
+ * @param {Object} failedDependency - Failed dependency information
241
+ * @returns {Object} Generic recovery suggestions
242
+ * @private
243
+ */
244
+ _getGenericRecoverySuggestions(failedDependency) {
245
+ const name = failedDependency?.name || 'dependency';
246
+
247
+ return {
248
+ immediate: [
249
+ `Try reinstalling ${name}`,
250
+ `Check if ${name} is in your system PATH`,
251
+ 'Restart your terminal or command prompt'
252
+ ],
253
+ alternative: [
254
+ `Install ${name} using different package manager`,
255
+ `Download ${name} manually from official website`,
256
+ `Use portable version of ${name}`
257
+ ],
258
+ troubleshooting: [
259
+ 'Check system requirements',
260
+ 'Verify internet connection',
261
+ 'Run installation as administrator if needed',
262
+ 'Check for system updates'
263
+ ],
264
+ additionalResources: []
265
+ };
266
+ }
267
+
268
+ /**
269
+ * Generate step-by-step recovery guide
270
+ * @param {Object} failedDependency - Failed dependency information
271
+ * @returns {Array} Step-by-step recovery instructions
272
+ */
273
+ generateStepByStepGuide(failedDependency) {
274
+ const guide = [];
275
+ const suggestions = this.generateRecoverySuggestions(failedDependency);
276
+
277
+ // Step 1: Immediate actions
278
+ if (suggestions.immediate.length > 0) {
279
+ guide.push({
280
+ step: 1,
281
+ title: 'Try these immediate solutions first:',
282
+ actions: suggestions.immediate.slice(0, 3) // Top 3 immediate suggestions
283
+ });
284
+ }
285
+
286
+ // Step 2: Alternative approaches
287
+ if (suggestions.alternative.length > 0) {
288
+ guide.push({
289
+ step: 2,
290
+ title: 'If immediate solutions don\'t work, try these alternatives:',
291
+ actions: suggestions.alternative.slice(0, 3) // Top 3 alternatives
292
+ });
293
+ }
294
+
295
+ // Step 3: Troubleshooting
296
+ if (suggestions.troubleshooting.length > 0) {
297
+ guide.push({
298
+ step: 3,
299
+ title: 'For advanced troubleshooting:',
300
+ actions: suggestions.troubleshooting.slice(0, 3) // Top 3 troubleshooting steps
301
+ });
302
+ }
303
+
304
+ // Step 4: Additional resources
305
+ if (suggestions.additionalResources.length > 0) {
306
+ guide.push({
307
+ step: 4,
308
+ title: 'Additional resources:',
309
+ actions: suggestions.additionalResources
310
+ });
311
+ }
312
+
313
+ return guide;
314
+ }
315
+
316
+ /**
317
+ * Generate recovery instructions for multiple failed dependencies
318
+ * @param {Array} failedDependencies - Array of failed dependencies
319
+ * @returns {Object} Consolidated recovery instructions
320
+ */
321
+ generateBulkRecoveryInstructions(failedDependencies) {
322
+ const consolidated = {
323
+ immediate: new Set(),
324
+ alternative: new Set(),
325
+ troubleshooting: new Set(),
326
+ additionalResources: new Set()
327
+ };
328
+
329
+ failedDependencies.forEach(dependency => {
330
+ const suggestions = this.generateRecoverySuggestions(dependency);
331
+
332
+ suggestions.immediate.forEach(item => consolidated.immediate.add(item));
333
+ suggestions.alternative.forEach(item => consolidated.alternative.add(item));
334
+ suggestions.troubleshooting.forEach(item => consolidated.troubleshooting.add(item));
335
+ suggestions.additionalResources.forEach(item => consolidated.additionalResources.add(item));
336
+ });
337
+
338
+ return {
339
+ immediate: Array.from(consolidated.immediate),
340
+ alternative: Array.from(consolidated.alternative),
341
+ troubleshooting: Array.from(consolidated.troubleshooting),
342
+ additionalResources: Array.from(consolidated.additionalResources),
343
+ affectedDependencies: failedDependencies.map(dep => dep.name)
344
+ };
345
+ }
346
+ }
347
+
348
+ module.exports = RecoveryInstructionService;