ocn-cli 1.0.0__tar.gz

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 (67) hide show
  1. ocn_cli-1.0.0/.github/RELEASE_TEMPLATE.md +57 -0
  2. ocn_cli-1.0.0/AGENTS.md +270 -0
  3. ocn_cli-1.0.0/LICENSE +22 -0
  4. ocn_cli-1.0.0/MANIFEST.in +13 -0
  5. ocn_cli-1.0.0/OFFLINE_UPDATES.md +369 -0
  6. ocn_cli-1.0.0/OFFLINE_UPDATE_SUMMARY.md +207 -0
  7. ocn_cli-1.0.0/PKG-INFO +407 -0
  8. ocn_cli-1.0.0/PUBLISHING.md +515 -0
  9. ocn_cli-1.0.0/PUBLISHING_QUICK_START.md +136 -0
  10. ocn_cli-1.0.0/README.md +370 -0
  11. ocn_cli-1.0.0/ocn_cli/__init__.py +11 -0
  12. ocn_cli-1.0.0/ocn_cli/__main__.py +7 -0
  13. ocn_cli-1.0.0/ocn_cli/auth/__init__.py +8 -0
  14. ocn_cli-1.0.0/ocn_cli/auth/key_manager.py +88 -0
  15. ocn_cli-1.0.0/ocn_cli/cli.py +255 -0
  16. ocn_cli-1.0.0/ocn_cli/commands/__init__.py +31 -0
  17. ocn_cli-1.0.0/ocn_cli/commands/base.py +54 -0
  18. ocn_cli-1.0.0/ocn_cli/commands/diagnose.py +208 -0
  19. ocn_cli-1.0.0/ocn_cli/commands/help.py +84 -0
  20. ocn_cli-1.0.0/ocn_cli/commands/offline_update.py +340 -0
  21. ocn_cli-1.0.0/ocn_cli/commands/registry.py +72 -0
  22. ocn_cli-1.0.0/ocn_cli/commands/status.py +152 -0
  23. ocn_cli-1.0.0/ocn_cli/diagnostics/__init__.py +22 -0
  24. ocn_cli-1.0.0/ocn_cli/diagnostics/base.py +105 -0
  25. ocn_cli-1.0.0/ocn_cli/diagnostics/checks/__init__.py +28 -0
  26. ocn_cli-1.0.0/ocn_cli/diagnostics/checks/containers.py +168 -0
  27. ocn_cli-1.0.0/ocn_cli/diagnostics/checks/dns.py +97 -0
  28. ocn_cli-1.0.0/ocn_cli/diagnostics/checks/docker_install.py +134 -0
  29. ocn_cli-1.0.0/ocn_cli/diagnostics/checks/dpkg_lock.py +151 -0
  30. ocn_cli-1.0.0/ocn_cli/diagnostics/checks/keygen.py +137 -0
  31. ocn_cli-1.0.0/ocn_cli/diagnostics/checks/logs.py +173 -0
  32. ocn_cli-1.0.0/ocn_cli/diagnostics/checks/network.py +305 -0
  33. ocn_cli-1.0.0/ocn_cli/diagnostics/checks/resources.py +470 -0
  34. ocn_cli-1.0.0/ocn_cli/diagnostics/checks/services.py +336 -0
  35. ocn_cli-1.0.0/ocn_cli/diagnostics/checks/time_sync.py +166 -0
  36. ocn_cli-1.0.0/ocn_cli/diagnostics/formatter.py +414 -0
  37. ocn_cli-1.0.0/ocn_cli/diagnostics/result.py +66 -0
  38. ocn_cli-1.0.0/ocn_cli/diagnostics/runner.py +252 -0
  39. ocn_cli-1.0.0/ocn_cli/offline/__init__.py +10 -0
  40. ocn_cli-1.0.0/ocn_cli/offline/uploader.py +125 -0
  41. ocn_cli-1.0.0/ocn_cli/offline/validator.py +123 -0
  42. ocn_cli-1.0.0/ocn_cli/shell/__init__.py +15 -0
  43. ocn_cli-1.0.0/ocn_cli/shell/completer.py +84 -0
  44. ocn_cli-1.0.0/ocn_cli/shell/highlighter.py +158 -0
  45. ocn_cli-1.0.0/ocn_cli/shell/history.py +66 -0
  46. ocn_cli-1.0.0/ocn_cli/shell/interactive.py +193 -0
  47. ocn_cli-1.0.0/ocn_cli/ssh/__init__.py +26 -0
  48. ocn_cli-1.0.0/ocn_cli/ssh/command_executor.py +185 -0
  49. ocn_cli-1.0.0/ocn_cli/ssh/connection.py +209 -0
  50. ocn_cli-1.0.0/ocn_cli/ssh/errors.py +46 -0
  51. ocn_cli-1.0.0/ocn_cli/ui/__init__.py +23 -0
  52. ocn_cli-1.0.0/ocn_cli/ui/formatters.py +148 -0
  53. ocn_cli-1.0.0/ocn_cli/ui/messages.py +87 -0
  54. ocn_cli-1.0.0/ocn_cli/utils/__init__.py +25 -0
  55. ocn_cli-1.0.0/ocn_cli/utils/platform.py +70 -0
  56. ocn_cli-1.0.0/ocn_cli/utils/security.py +91 -0
  57. ocn_cli-1.0.0/ocn_cli/version.py +5 -0
  58. ocn_cli-1.0.0/ocn_cli.egg-info/PKG-INFO +407 -0
  59. ocn_cli-1.0.0/ocn_cli.egg-info/SOURCES.txt +65 -0
  60. ocn_cli-1.0.0/ocn_cli.egg-info/dependency_links.txt +1 -0
  61. ocn_cli-1.0.0/ocn_cli.egg-info/entry_points.txt +2 -0
  62. ocn_cli-1.0.0/ocn_cli.egg-info/requires.txt +12 -0
  63. ocn_cli-1.0.0/ocn_cli.egg-info/top_level.txt +3 -0
  64. ocn_cli-1.0.0/pyproject.toml +85 -0
  65. ocn_cli-1.0.0/requirements.txt +21 -0
  66. ocn_cli-1.0.0/resources/README.md +45 -0
  67. ocn_cli-1.0.0/setup.cfg +4 -0
@@ -0,0 +1,57 @@
1
+ # OCN CLI Release vX.Y.Z
2
+
3
+ ## What's New
4
+
5
+ <!-- Describe the main features/fixes in this release -->
6
+
7
+ ### New Features
8
+ - Feature 1
9
+ - Feature 2
10
+
11
+ ### Bug Fixes
12
+ - Fix 1
13
+ - Fix 2
14
+
15
+ ### Improvements
16
+ - Improvement 1
17
+ - Improvement 2
18
+
19
+ ---
20
+
21
+ ## Installation
22
+
23
+ Install or upgrade to this version:
24
+
25
+ ```bash
26
+ pip install --upgrade ocn-cli
27
+ ```
28
+
29
+ Verify installation:
30
+ ```bash
31
+ ocn-cli --version
32
+ ```
33
+
34
+ Should show: `OCN CLI version X.Y.Z`
35
+
36
+ ---
37
+
38
+ ## Breaking Changes
39
+
40
+ <!-- List any breaking changes that require user action -->
41
+
42
+ - None
43
+
44
+ ---
45
+
46
+ ## Documentation
47
+
48
+ - [README](https://github.com/your-org/ocn/blob/main/cli/README.md)
49
+ - [Diagnostics Guide](https://github.com/your-org/ocn/blob/main/cli/DIAGNOSTICS.md)
50
+ - [Changelog](https://github.com/your-org/ocn/blob/main/cli/CHANGELOG.md)
51
+
52
+ ---
53
+
54
+ ## Full Changelog
55
+
56
+ See [CHANGELOG.md](https://github.com/your-org/ocn/blob/main/cli/CHANGELOG.md) for complete version history.
57
+
@@ -0,0 +1,270 @@
1
+ # OCN CLI - Agent Guidelines
2
+
3
+ This document provides guidelines for AI agents working on the OCN CLI diagnostic tool.
4
+
5
+ ## Project Overview
6
+
7
+ The OCN CLI is a Python-based command-line interface for remote diagnostics of OCN servers. It provides:
8
+ - Secure SSH connections with key-based authentication
9
+ - Interactive shell with history, autocomplete, and syntax highlighting
10
+ - Built-in helper commands for common diagnostic operations
11
+ - Cross-platform compatibility (Windows, macOS, Linux)
12
+
13
+ ## Tech Stack
14
+
15
+ - **Python 3.9+** - Modern Python with type hints
16
+ - **Typer** - CLI framework with automatic help generation
17
+ - **Paramiko** - SSH client library
18
+ - **prompt_toolkit** - Interactive shell with REPL features
19
+ - **Rich** - Terminal output formatting
20
+
21
+ ## Architecture
22
+
23
+ ```
24
+ ocn_cli/
25
+ ├── cli.py # Main entry point (Typer app)
26
+ ├── version.py # Version metadata
27
+ ├── auth/ # Authentication layer
28
+ │ └── key_manager.py # SSH key loading and validation
29
+ ├── ssh/ # SSH connection layer
30
+ │ ├── connection.py # SSH connection management
31
+ │ ├── command_executor.py # Remote command execution
32
+ │ └── errors.py # SSH error types
33
+ ├── shell/ # Interactive shell layer
34
+ │ ├── interactive.py # Main REPL loop
35
+ │ ├── completer.py # Autocomplete
36
+ │ ├── highlighter.py # Syntax highlighting
37
+ │ └── history.py # Command history
38
+ ├── commands/ # Helper commands layer
39
+ │ ├── base.py # Command protocol
40
+ │ ├── registry.py # Command registry
41
+ │ ├── help.py # Help command
42
+ │ ├── status.py # Status command
43
+ │ └── diagnose.py # Comprehensive diagnostics command
44
+ ├── diagnostics/ # Diagnostics framework
45
+ │ ├── base.py # Base diagnostic check classes
46
+ │ ├── runner.py # Diagnostic execution engine
47
+ │ ├── result.py # Result data structures
48
+ │ ├── formatter.py # Report formatters (text, JSON, HTML)
49
+ │ └── checks/ # Individual diagnostic checks
50
+ │ ├── network.py # Network connectivity checks
51
+ │ ├── dns.py # DNS resolution checks
52
+ │ ├── keygen.py # keygen.sh accessibility
53
+ │ ├── docker_install.py # Docker installation validation
54
+ │ ├── containers.py # Container status checks
55
+ │ ├── dpkg_lock.py # dpkg lock detection
56
+ │ ├── resources.py # CPU, memory, disk checks
57
+ │ ├── services.py # Critical service checks
58
+ │ ├── logs.py # Log file size monitoring
59
+ │ └── time_sync.py # NTP time synchronization
60
+ ├── offline/ # Offline update support
61
+ │ ├── uploader.py # SFTP file upload with progress
62
+ │ └── validator.py # Package validation
63
+ ├── ui/ # User interface layer
64
+ │ ├── messages.py # Message templates
65
+ │ └── formatters.py # Rich formatting
66
+ └── utils/ # Utilities layer
67
+ ├── platform.py # Cross-platform helpers
68
+ └── security.py # Security utilities
69
+ ```
70
+
71
+ ## Code Conventions
72
+
73
+ ### Type Hints
74
+ - **Always use type hints** for all function parameters and return types
75
+ - Use `from typing import` for complex types (List, Dict, Optional, etc.)
76
+ - Use modern syntax where possible: `list[str]` instead of `List[str]` (Python 3.11+)
77
+
78
+ ### Error Handling
79
+ - Use specific exception types from `ssh/errors.py`
80
+ - Always provide helpful error messages with troubleshooting hints
81
+ - Never expose sensitive data (passwords, keys) in error messages
82
+
83
+ ### Security
84
+ - Never log or persist credentials to disk
85
+ - Validate file permissions on SSH keys
86
+ - Use context managers for automatic cleanup
87
+
88
+ ### UI/UX
89
+ - Use Rich for all terminal output (colors, tables, panels)
90
+ - Keep messages user-friendly and actionable
91
+ - Provide troubleshooting hints for all errors
92
+ - Use icons/emojis sparingly for visual clarity
93
+
94
+ ## Development Workflow
95
+
96
+ ### Local Testing
97
+
98
+ ```bash
99
+ # Install in development mode
100
+ pip install -e .
101
+
102
+ # Run directly
103
+ ocn-cli --help
104
+
105
+ # Or as module
106
+ python -m ocn_cli --help
107
+ ```
108
+
109
+ ### Adding New Helper Commands
110
+
111
+ 1. Create new command class in `commands/`
112
+ 2. Implement `HelperCommand` protocol:
113
+ - `name` property
114
+ - `description` property
115
+ - `aliases` property
116
+ - `execute(executor, args)` method
117
+ 3. Register in `commands/__init__.py`
118
+
119
+ Example:
120
+
121
+ ```python
122
+ class MyCommand:
123
+ @property
124
+ def name(self) -> str:
125
+ return "mycommand"
126
+
127
+ @property
128
+ def description(self) -> str:
129
+ return "Description of what it does"
130
+
131
+ @property
132
+ def aliases(self) -> List[str]:
133
+ return ["mc", "mycmd"]
134
+
135
+ def execute(self, executor: CommandExecutor, args: List[str]) -> str:
136
+ result = executor.execute("remote command")
137
+ return f"Output: {result.stdout}"
138
+ ```
139
+
140
+ ### Adding New Diagnostic Checks
141
+
142
+ 1. Create new check class in `diagnostics/checks/`
143
+ 2. Inherit from `DiagnosticCheck` abstract base class
144
+ 3. Implement required methods:
145
+ - `name`, `category`, `severity` properties
146
+ - `async def execute(self) -> CheckResult`
147
+ 4. Register in `diagnostics/runner.py` → `register_all_checks()`
148
+
149
+ Example:
150
+
151
+ ```python
152
+ from ocn_cli.diagnostics.base import DiagnosticCheck, CheckResult, CheckSeverity
153
+
154
+ class MyDiagnosticCheck(DiagnosticCheck):
155
+ def __init__(self, executor: CommandExecutor) -> None:
156
+ self.executor = executor
157
+
158
+ @property
159
+ def name(self) -> str:
160
+ return "my_check"
161
+
162
+ @property
163
+ def category(self) -> str:
164
+ return "system"
165
+
166
+ @property
167
+ def severity(self) -> CheckSeverity:
168
+ return CheckSeverity.WARNING
169
+
170
+ async def execute(self) -> CheckResult:
171
+ result = self.executor.execute("some command", stream=False)
172
+
173
+ if result.exit_code != 0:
174
+ return CheckResult(
175
+ check_name=self.name,
176
+ category=self.category,
177
+ passed=False,
178
+ severity=self.severity,
179
+ message="Check failed",
180
+ remediation=["How to fix this issue"]
181
+ )
182
+
183
+ return CheckResult(
184
+ check_name=self.name,
185
+ category=self.category,
186
+ passed=True,
187
+ severity=self.severity,
188
+ message="Check passed"
189
+ )
190
+ ```
191
+
192
+ ### SSH Key Management
193
+
194
+ The CLI uses standard SSH key-based authentication:
195
+
196
+ 1. Users provide their SSH private key via `--key` argument
197
+ 2. KeyManager validates the key format and permissions
198
+ 3. Paramiko loads the key (supports RSA, Ed25519, ECDSA, DSS)
199
+ 4. Key must be authorized on the OCN server's `~/.ssh/authorized_keys`
200
+
201
+ ## Testing
202
+
203
+ - Use `pytest` for unit and integration tests
204
+ - Mock SSH connections for unit tests
205
+ - Test error paths and edge cases
206
+ - Verify cross-platform compatibility
207
+
208
+ ## Common Tasks
209
+
210
+ ### Update Version
211
+
212
+ Edit `ocn_cli/version.py`:
213
+ ```python
214
+ __version__ = "1.1.0"
215
+ ```
216
+
217
+ ### Add New Dependency
218
+
219
+ 1. Add to `pyproject.toml` dependencies array
220
+ 2. Add to `requirements.txt` with pinned version
221
+ 3. Update documentation if needed
222
+
223
+ ### Debug Issues
224
+
225
+ - Check `~/.cursor/projects/.../terminals/` for command output
226
+ - Use Rich console for debug prints: `console.print("[debug]...")`
227
+ - Test with verbose SSH logging if needed
228
+
229
+ ### Offline Update Support
230
+
231
+ The CLI supports updating offline OCN servers:
232
+
233
+ 1. Upload update packages via SFTP
234
+ 2. Validate package structure
235
+ 3. Apply updates without internet
236
+ 4. Based on existing `update.sh` workflow
237
+
238
+ **Phase 1 Limitations:**
239
+ - Docker CE must already be installed
240
+ - No Docker migration in offline mode
241
+ - No system package updates
242
+
243
+ **See:** `OFFLINE_UPDATES.md` for usage guide
244
+
245
+ ## Future Enhancements
246
+
247
+ Planned features for future versions:
248
+ - Offline Docker migration support
249
+ - System package updates offline
250
+ - Configuration file support for server profiles
251
+ - Session recording and playback
252
+ - Remote script execution
253
+ - Multi-server management
254
+ - Passphrase-protected key support
255
+
256
+ ## Rules for AI Agents
257
+
258
+ 1. **Preserve existing patterns** - Follow the established architecture and code style
259
+ 2. **Type everything** - All functions must have type hints
260
+ 3. **Security first** - Never compromise security for convenience
261
+ 4. **User experience** - Error messages must be helpful and actionable
262
+ 5. **Cross-platform** - Test changes on all supported platforms
263
+ 6. **No breaking changes** - Maintain backward compatibility
264
+ 7. **Document changes** - Update README and CHANGELOG for user-facing changes
265
+
266
+ ## Contact
267
+
268
+ For questions or issues:
269
+ - GitHub: https://github.com/your-org/ocn/issues
270
+ - Documentation: /Users/max/Documents/GitHub/ocn/cli/
ocn_cli-1.0.0/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Strato Automation Software Development Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,13 @@
1
+ # Include resources directory
2
+ recursive-include resources *
3
+
4
+ # Include documentation
5
+ include README.md
6
+ include LICENSE
7
+
8
+ # Exclude development files
9
+ exclude .gitignore
10
+ recursive-exclude tests *
11
+ recursive-exclude * __pycache__
12
+ recursive-exclude * *.py[co]
13
+