mcp-ssh-manager 3.0.0 → 3.1.2
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.
- package/.claude/settings.local.json +10 -1
- package/CHANGELOG.md +63 -0
- package/CLAUDE.md +16 -0
- package/README.md +117 -4
- package/cli/commands/server.sh +27 -5
- package/cli/commands/tools.sh +603 -0
- package/cli/lib/config.sh +104 -14
- package/cli/lib/menu.sh +124 -0
- package/cli/ssh-manager +17 -7
- package/context-test.txt +1 -0
- package/docs/SOCIAL_MEDIA_ANNOUNCEMENT.md +385 -0
- package/docs/TOOL_MANAGEMENT.md +473 -0
- package/docs/TROUBLESHOOTING.md +143 -0
- package/package.json +5 -4
- package/scripts/validate.sh +12 -0
- package/src/backup-manager.js +12 -12
- package/src/command-aliases.js +16 -16
- package/src/config-loader.js +1 -1
- package/src/config.js +70 -0
- package/src/database-manager.js +38 -40
- package/src/deploy-helper.js +12 -13
- package/src/health-monitor.js +26 -26
- package/src/hooks-system.js +43 -43
- package/src/index.js +899 -841
- package/src/logger.js +53 -53
- package/src/profile-loader.js +14 -14
- package/src/server-aliases.js +11 -11
- package/src/server-groups.js +98 -97
- package/src/session-manager.js +59 -58
- package/src/ssh-key-manager.js +4 -3
- package/src/ssh-manager.js +46 -24
- package/src/tool-config-manager.js +434 -0
- package/src/tool-registry.js +196 -0
- package/src/tunnel-manager.js +98 -98
package/src/hooks-system.js
CHANGED
|
@@ -73,15 +73,15 @@ export async function initializeHooks() {
|
|
|
73
73
|
if (!fs.existsSync(HOOKS_DIR)) {
|
|
74
74
|
fs.mkdirSync(HOOKS_DIR, { recursive: true });
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
// Merge profile hooks with defaults
|
|
78
78
|
const mergedHooks = { ...DEFAULT_HOOKS, ...profileHooks };
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
// Create hooks configuration if it doesn't exist
|
|
81
81
|
if (!fs.existsSync(HOOKS_CONFIG_FILE)) {
|
|
82
82
|
saveHooksConfig(mergedHooks);
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
return true;
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -92,12 +92,12 @@ export function loadHooksConfig() {
|
|
|
92
92
|
try {
|
|
93
93
|
// Start with profile hooks
|
|
94
94
|
let hooks = { ...profileHooks };
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
// Merge with custom hooks from file
|
|
97
97
|
if (fs.existsSync(HOOKS_CONFIG_FILE)) {
|
|
98
98
|
const data = fs.readFileSync(HOOKS_CONFIG_FILE, 'utf8');
|
|
99
99
|
const customHooks = JSON.parse(data);
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
// Deep merge hooks
|
|
102
102
|
for (const [hookName, hookConfig] of Object.entries(customHooks)) {
|
|
103
103
|
if (hooks[hookName]) {
|
|
@@ -112,7 +112,7 @@ export function loadHooksConfig() {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
return hooks;
|
|
117
117
|
} catch (error) {
|
|
118
118
|
console.error(`Error loading hooks config: ${error.message}`);
|
|
@@ -139,14 +139,14 @@ export function saveHooksConfig(config) {
|
|
|
139
139
|
export async function executeHook(hookName, context = {}) {
|
|
140
140
|
const config = loadHooksConfig();
|
|
141
141
|
const hook = config[hookName];
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
if (!hook || !hook.enabled) {
|
|
144
144
|
return { success: true, skipped: true };
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
console.error(`🎣 Executing hook: ${hookName}`);
|
|
148
148
|
const results = [];
|
|
149
|
-
|
|
149
|
+
|
|
150
150
|
for (const action of hook.actions) {
|
|
151
151
|
try {
|
|
152
152
|
// Check environment variables if required
|
|
@@ -160,25 +160,25 @@ export async function executeHook(hookName, context = {}) {
|
|
|
160
160
|
continue;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
|
|
163
|
+
|
|
164
164
|
// Replace placeholders in command
|
|
165
165
|
let command = action.command || action.remoteCommand || '';
|
|
166
166
|
for (const [key, value] of Object.entries(context)) {
|
|
167
167
|
command = command.replace(new RegExp(`{${key}}`, 'g'), value);
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
// Execute action based on type
|
|
171
171
|
const result = await executeAction(action, command, context);
|
|
172
172
|
results.push(result);
|
|
173
|
-
|
|
173
|
+
|
|
174
174
|
// Check validation results
|
|
175
175
|
if (action.type === 'validation' && !result.success && !action.optional) {
|
|
176
176
|
const errorMsg = action.errorMessage || `Validation failed: ${action.name}`;
|
|
177
177
|
throw new Error(errorMsg);
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
|
|
180
180
|
console.error(` ✅ ${action.name}: completed`);
|
|
181
|
-
|
|
181
|
+
|
|
182
182
|
} catch (error) {
|
|
183
183
|
if (!action.optional) {
|
|
184
184
|
console.error(` ❌ ${action.name}: ${error.message}`);
|
|
@@ -193,7 +193,7 @@ export async function executeHook(hookName, context = {}) {
|
|
|
193
193
|
console.error(` ⚠️ ${action.name}: ${error.message} (optional, continuing)`);
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
|
|
196
|
+
|
|
197
197
|
return {
|
|
198
198
|
success: true,
|
|
199
199
|
hook: hookName,
|
|
@@ -210,61 +210,61 @@ async function executeAction(action, command, context) {
|
|
|
210
210
|
type: action.type,
|
|
211
211
|
timestamp: new Date().toISOString()
|
|
212
212
|
};
|
|
213
|
-
|
|
213
|
+
|
|
214
214
|
try {
|
|
215
215
|
if (action.remoteCommand && context.sshConnection) {
|
|
216
216
|
// Execute on remote server
|
|
217
217
|
const output = await context.sshConnection.execCommand(command, {
|
|
218
218
|
cwd: context.cwd || context.defaultDir
|
|
219
219
|
});
|
|
220
|
-
|
|
220
|
+
|
|
221
221
|
result.output = output.stdout;
|
|
222
222
|
result.error = output.stderr;
|
|
223
223
|
result.success = output.code === 0;
|
|
224
|
-
|
|
224
|
+
|
|
225
225
|
if (action.expectEmpty && output.stdout.trim()) {
|
|
226
226
|
result.success = false;
|
|
227
227
|
}
|
|
228
228
|
} else if (action.command) {
|
|
229
229
|
// Execute locally
|
|
230
230
|
const { stdout, stderr } = await execAsync(command);
|
|
231
|
-
|
|
231
|
+
|
|
232
232
|
result.output = stdout;
|
|
233
233
|
result.error = stderr;
|
|
234
234
|
result.success = true;
|
|
235
|
-
|
|
235
|
+
|
|
236
236
|
if (action.expectEmpty && stdout.trim()) {
|
|
237
237
|
result.success = false;
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
|
|
240
|
+
|
|
241
241
|
// Handle specific action types
|
|
242
242
|
switch (action.type) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
243
|
+
case 'backup':
|
|
244
|
+
result.backupInfo = {
|
|
245
|
+
timestamp: new Date().toISOString(),
|
|
246
|
+
command: command
|
|
247
|
+
};
|
|
248
|
+
break;
|
|
249
|
+
|
|
250
|
+
case 'notification':
|
|
251
|
+
result.notified = true;
|
|
252
|
+
break;
|
|
253
|
+
|
|
254
|
+
case 'validation':
|
|
255
|
+
result.validated = result.success;
|
|
256
|
+
break;
|
|
257
|
+
|
|
258
|
+
case 'verification':
|
|
259
|
+
result.verified = result.success;
|
|
260
|
+
break;
|
|
261
261
|
}
|
|
262
|
-
|
|
262
|
+
|
|
263
263
|
} catch (error) {
|
|
264
264
|
result.success = false;
|
|
265
265
|
result.error = error.message;
|
|
266
266
|
}
|
|
267
|
-
|
|
267
|
+
|
|
268
268
|
return result;
|
|
269
269
|
}
|
|
270
270
|
|
|
@@ -316,7 +316,7 @@ export function listHooks() {
|
|
|
316
316
|
*/
|
|
317
317
|
export async function createHookScript(scriptName, scriptContent) {
|
|
318
318
|
const scriptPath = path.join(HOOKS_DIR, scriptName);
|
|
319
|
-
|
|
319
|
+
|
|
320
320
|
try {
|
|
321
321
|
fs.writeFileSync(scriptPath, scriptContent);
|
|
322
322
|
fs.chmodSync(scriptPath, '755');
|
|
@@ -324,4 +324,4 @@ export async function createHookScript(scriptName, scriptContent) {
|
|
|
324
324
|
} catch (error) {
|
|
325
325
|
throw new Error(`Failed to create hook script: ${error.message}`);
|
|
326
326
|
}
|
|
327
|
-
}
|
|
327
|
+
}
|