mcp-ssh-manager 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/.claude/settings.local.json +87 -0
  2. package/.flake8 +15 -0
  3. package/.hooks-config.json +131 -0
  4. package/.pre-commit-config.yaml +105 -0
  5. package/CHANGELOG.md +137 -0
  6. package/CLAUDE.md +190 -0
  7. package/CONTRIBUTING.md +114 -0
  8. package/DESCRIPTION +1 -0
  9. package/INSTALLATION.md +180 -0
  10. package/LICENSE +21 -0
  11. package/QUICKSTART.md +77 -0
  12. package/README.md +718 -0
  13. package/cli/README.md +286 -0
  14. package/cli/build.sh +199 -0
  15. package/cli/commands/server.sh +284 -0
  16. package/cli/demo.sh +107 -0
  17. package/cli/install.sh +164 -0
  18. package/cli/lib/colors.sh +174 -0
  19. package/cli/lib/config.sh +284 -0
  20. package/cli/lib/menu.sh +430 -0
  21. package/cli/migrate.sh +168 -0
  22. package/cli/ssh-manager +525 -0
  23. package/docs/ALIASES_AND_HOOKS.md +285 -0
  24. package/docs/BACKUP_GUIDE.md +500 -0
  25. package/docs/DEPLOYMENT_GUIDE.md +241 -0
  26. package/docs/SEO.md +257 -0
  27. package/examples/backup-workflow.js +481 -0
  28. package/examples/claude-code-config.example.json +40 -0
  29. package/examples/codex-ssh-config.example.toml +71 -0
  30. package/examples/deploy-workflow.py +183 -0
  31. package/glama.json +6 -0
  32. package/package.json +85 -0
  33. package/profiles/README.md +40 -0
  34. package/profiles/default.json +52 -0
  35. package/profiles/docker.json +62 -0
  36. package/profiles/frappe.json +107 -0
  37. package/profiles/nodejs.json +63 -0
  38. package/pyproject.toml +17 -0
  39. package/scripts/setup-hooks.sh +60 -0
  40. package/scripts/validate.sh +76 -0
  41. package/src/backup-manager.js +469 -0
  42. package/src/command-aliases.js +151 -0
  43. package/src/config-loader.js +281 -0
  44. package/src/database-manager.js +555 -0
  45. package/src/deploy-helper.js +176 -0
  46. package/src/health-monitor.js +428 -0
  47. package/src/hooks-system.js +327 -0
  48. package/src/index.js +4499 -0
  49. package/src/logger.js +276 -0
  50. package/src/profile-loader.js +187 -0
  51. package/src/server-aliases.js +150 -0
  52. package/src/server-groups.js +409 -0
  53. package/src/session-manager.js +410 -0
  54. package/src/ssh-key-manager.js +378 -0
  55. package/src/ssh-manager.js +435 -0
  56. package/src/tunnel-manager.js +576 -0
@@ -0,0 +1,285 @@
1
+ # Aliases and Hooks Guide 🚀
2
+
3
+ ## Profiles System
4
+
5
+ SSH Manager uses profiles to provide project-specific configurations. Profiles define command aliases and hooks tailored to different project types.
6
+
7
+ ### Available Profiles
8
+
9
+ - **default** - Basic SSH operations (minimal setup)
10
+ - **frappe** - Frappe/ERPNext framework commands
11
+ - **docker** - Docker container management
12
+ - **nodejs** - Node.js application deployment
13
+
14
+ ### Setting Active Profile
15
+
16
+ 1. **Environment Variable**:
17
+ ```bash
18
+ export SSH_MANAGER_PROFILE=frappe
19
+ ```
20
+
21
+ 2. **Configuration File**:
22
+ Create `.ssh-manager-profile` in project root:
23
+ ```
24
+ frappe
25
+ ```
26
+
27
+ 3. **Via Claude Code**:
28
+ ```
29
+ "Switch to frappe profile"
30
+ "Show current profile"
31
+ "List available profiles"
32
+ ```
33
+
34
+ ## Command Aliases
35
+
36
+ ### Overview
37
+ Command aliases are shortcuts for frequently used commands. They are loaded from your active profile.
38
+
39
+ ### Profile-Specific Aliases
40
+
41
+ Each profile provides relevant aliases:
42
+
43
+ #### Default Profile
44
+ - `check-memory` → Display memory usage
45
+ - `check-disk` → Display disk usage
46
+ - `system-info` → System information
47
+ - `tail-logs` → Tail logs with 100 lines
48
+
49
+ #### Frappe Profile
50
+ - `bench-update` → Full bench update with all flags
51
+ - `bench-restart` → Restart all bench services
52
+ - `bench-migrate` → Run migrations
53
+ - `bench-clear-cache` → Clear cache
54
+ - And 20+ more Frappe-specific commands
55
+
56
+ #### Docker Profile
57
+ - `docker-ps` → List all containers
58
+ - `docker-logs` → View container logs
59
+ - `docker-restart` → Restart containers
60
+ - `docker-clean` → Clean unused resources
61
+
62
+ #### Node.js Profile
63
+ - `npm-install` → Production install
64
+ - `pm2-restart` → Restart PM2 apps
65
+ - `npm-build` → Build application
66
+ - `audit-fix` → Fix security issues
67
+
68
+ ### Using Command Aliases in Claude Code
69
+
70
+ ```
71
+ "Execute bench-update on production server"
72
+ "Run bench-restart on dmis"
73
+ "Execute check-memory on develop"
74
+ ```
75
+
76
+ ### Managing Command Aliases
77
+
78
+ #### List all aliases
79
+ ```
80
+ "List all command aliases"
81
+ ```
82
+
83
+ #### Add custom alias
84
+ ```
85
+ "Add command alias 'my-backup' for command 'bench --site mysite.com backup --with-files'"
86
+ ```
87
+
88
+ #### Remove alias
89
+ ```
90
+ "Remove command alias 'my-backup'"
91
+ ```
92
+
93
+ #### Suggest aliases for a command
94
+ ```
95
+ "Suggest aliases for 'bench'"
96
+ ```
97
+
98
+ ## Hooks System
99
+
100
+ ### Overview
101
+ Hooks provide automated actions that run before, after, or on error during SSH operations. Like aliases, hooks are loaded from your active profile.
102
+
103
+ ### Profile-Specific Hooks
104
+
105
+ Each profile defines relevant hooks:
106
+
107
+ #### Default Profile
108
+ - **on-error**: Logs errors to file
109
+
110
+ #### Frappe Profile
111
+ - **pre-bench-update**: Creates backup, checks disk space
112
+ - **post-bench-update**: Verifies services, clears cache
113
+ - **pre-deploy**: Validates bench status
114
+ - **post-deploy**: Restarts workers, clears cache
115
+
116
+ #### Docker Profile
117
+ - **pre-deploy**: Checks Docker, backs up volumes
118
+ - **post-deploy**: Verifies containers, restarts if needed
119
+
120
+ #### Node.js Profile
121
+ - **pre-deploy**: Checks Node.js, runs tests
122
+ - **post-deploy**: Installs dependencies, restarts app
123
+
124
+ ### Managing Hooks in Claude Code
125
+
126
+ #### List all hooks
127
+ ```
128
+ "List all SSH hooks"
129
+ ```
130
+
131
+ #### Check hook status
132
+ ```
133
+ "Show SSH hooks status"
134
+ ```
135
+
136
+ #### Enable a hook
137
+ ```
138
+ "Enable pre-connect hook"
139
+ ```
140
+
141
+ #### Disable a hook
142
+ ```
143
+ "Disable post-connect hook"
144
+ ```
145
+
146
+ ## Configuration Files
147
+
148
+ ### Profile Selection
149
+ - Location: `.ssh-manager-profile`
150
+ - Contains the active profile name
151
+
152
+ ### Custom Command Aliases
153
+ - Location: `.command-aliases.json`
154
+ - Contains custom aliases (overrides profile aliases)
155
+
156
+ ### Custom Hooks Configuration
157
+ - Location: `.hooks-config.json`
158
+ - Contains custom hook definitions (overrides profile hooks)
159
+
160
+ ### Profile Definitions
161
+ - Location: `profiles/` directory
162
+ - JSON files defining profile-specific configurations
163
+
164
+ ### Hook Scripts
165
+ - Location: `hooks/` directory
166
+ - Custom scripts can be placed here
167
+
168
+ ## Environment Variables for Hooks
169
+
170
+ Some hooks require environment variables:
171
+
172
+ ### Slack Notifications
173
+ ```bash
174
+ export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
175
+ ```
176
+
177
+ ## Creating Custom Profiles
178
+
179
+ You can create your own profile for specific project types:
180
+
181
+ 1. Create a JSON file in `profiles/` directory
182
+ 2. Define your aliases and hooks
183
+ 3. Switch to your profile
184
+
185
+ Example: `profiles/my-project.json`
186
+ ```json
187
+ {
188
+ "name": "my-project",
189
+ "description": "Custom profile for my project",
190
+ "commandAliases": {
191
+ "deploy": "git pull && make install && systemctl restart myapp",
192
+ "logs": "journalctl -u myapp -f",
193
+ "status": "systemctl status myapp"
194
+ },
195
+ "hooks": {
196
+ "pre-deploy": {
197
+ "enabled": true,
198
+ "actions": [
199
+ {
200
+ "type": "validation",
201
+ "name": "run-tests",
202
+ "command": "make test"
203
+ }
204
+ ]
205
+ }
206
+ }
207
+ }
208
+ ```
209
+
210
+ ## Examples
211
+
212
+ ### Switching Profiles
213
+
214
+ ```
215
+ # For a Frappe project
216
+ "Switch to frappe profile"
217
+ "Execute bench-update on production"
218
+
219
+ # For a Docker project
220
+ "Switch to docker profile"
221
+ "Execute docker-logs on staging"
222
+
223
+ # For a Node.js project
224
+ "Switch to nodejs profile"
225
+ "Execute pm2-restart on production"
226
+ ```
227
+
228
+ ### Typical Workflow with Hooks
229
+
230
+ 1. **Deployment with validation**
231
+ ```
232
+ "Deploy config.json to production:/etc/app/config.json"
233
+ ```
234
+ This will:
235
+ - Run `pre-deploy` hook (check Git status)
236
+ - Deploy the file
237
+ - Run `post-deploy` hook (log and notify)
238
+
239
+ 2. **Bench update with safety**
240
+ ```
241
+ "Execute bench-update on production"
242
+ ```
243
+ This will:
244
+ - Run `pre-bench-update` hook (backup and check disk)
245
+ - Execute the update
246
+ - Run `post-bench-update` hook (verify services)
247
+
248
+ ### Creating Custom Workflows
249
+
250
+ You can combine aliases and hooks for powerful automation:
251
+
252
+ 1. Create a custom alias for your deployment command
253
+ 2. Enable appropriate hooks for validation
254
+ 3. Execute with a simple command
255
+
256
+ Example:
257
+ ```
258
+ "Add command alias 'safe-deploy' for 'bench --site all migrate && bench build && bench restart'"
259
+ "Execute safe-deploy on production"
260
+ ```
261
+
262
+ ## Best Practices
263
+
264
+ 1. **Always keep backups enabled** for production deployments
265
+ 2. **Use aliases** for complex commands to avoid errors
266
+ 3. **Enable pre-deployment hooks** to catch issues early
267
+ 4. **Configure notifications** for production deployments
268
+ 5. **Test hooks** on staging before enabling on production
269
+
270
+ ## Troubleshooting
271
+
272
+ ### Hooks not executing
273
+ - Check if hook is enabled: `"Show SSH hooks status"`
274
+ - Verify required environment variables are set
275
+ - Check `.hooks-config.json` for proper configuration
276
+
277
+ ### Command aliases not working
278
+ - List aliases to verify: `"List all command aliases"`
279
+ - Check `.command-aliases.json` for syntax errors
280
+ - Ensure the base command is valid
281
+
282
+ ### Deployment failures
283
+ - Check `deployments.log` for history
284
+ - Review `errors.log` for error details
285
+ - Verify disk space and permissions on target server