refactor(cli): add oclif examples for utility commands - #2902
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR refactors sandbox operation logic from a centralized ChangesSandbox Runtime Actions Extraction
CLI Routing & Command Updates
CLI Examples & Metadata
Sequence Diagram(s)sequenceDiagram
actor User
participant CLI as CLI Handler
participant State as Gateway State
participant Recovery as Process Recovery
participant OpenShell as OpenShell Runtime
User->>CLI: sandbox destroy <name>
CLI->>State: ensureLiveSandboxOrExit(name)
State->>OpenShell: sandbox list
OpenShell-->>State: live sandbox data
State-->>CLI: { present: true }
CLI->>Recovery: checkAndRecoverSandboxProcesses(name)
Recovery->>OpenShell: health probe
OpenShell-->>Recovery: RUNNING
Recovery-->>CLI: { checked, wasRunning, recovered }
CLI->>OpenShell: sandbox delete <name>
OpenShell-->>CLI: delete result
CLI->>CLI: getSandboxDeleteOutcome(result)
CLI->>CLI: removeSandboxRegistryEntry(name)
CLI-->>User: ✓ Sandbox destroyed
sequenceDiagram
actor User
participant CLI as Rebuild CLI
participant Backup as Backup System
participant OpenShell as OpenShell Runtime
participant Onboard as Onboard Engine
User->>CLI: sandbox rebuild <name>
CLI->>CLI: Load registry entry
CLI->>CLI: Confirm with user
CLI->>Backup: backupSandboxState(name)
Backup-->>CLI: backup manifest
CLI->>OpenShell: sandbox delete <name>
OpenShell-->>CLI: delete result
CLI->>Onboard: onboard({ resume: true, recreateSandbox: true })
Onboard->>OpenShell: create sandbox
OpenShell-->>Onboard: sandbox ready
Onboard-->>CLI: recreation complete
CLI->>Backup: restoreSandboxState(name, manifest)
Backup-->>CLI: restore complete
CLI->>CLI: applyPreset(...) for each policy
CLI-->>User: ✓ Rebuild complete
sequenceDiagram
participant Test as Test Suite
participant Cache as require.cache
participant GlobalActions as global-cli-actions
participant Runtime as Mock Runtime
Test->>Test: Create mock runtime
Test->>GlobalActions: require(GLOBAL_ACTIONS_PATH)
Test->>GlobalActions: setGlobalCliActionRuntimeHooksForTest(mockRuntime)
GlobalActions->>GlobalActions: Store runtime in module state
Test->>GlobalActions: recoverNamedGatewayRuntime()
GlobalActions->>GlobalActions: Check if hook present
GlobalActions->>Runtime: Use injected hook
Runtime-->>GlobalActions: result
GlobalActions-->>Test: return result
Test->>Cache: delete require.cache[GLOBAL_ACTIONS_PATH]
Cache-->>Test: cache cleared
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Comment |
## Summary Introduce an explicit `main(argv)` entrypoint for the CLI module. The existing `mainPromise` export remains as a thin compatibility shim for in-process test harnesses that still require and await the CLI module. ## Stack Navigation - Position: 11 of 60 - Previous PR: [#2899 — refactor(cli): remove legacy dispatch fallbacks](#2899) - Next PR: [#2902 — refactor(cli): add oclif examples for utility commands](#2902) ## Changes - Moved top-level argv parsing into `main(argv = process.argv.slice(2))`. - Exported `main` for new in-process harnesses and future launcher cleanup. - Kept `mainPromise = main()` compatibility with a comment directing new callers to `main(argv)`. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Verification - [x] `npx prek run --all-files` passes - [x] `npm test` passes - [ ] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [ ] Docs updated for user-facing behavior changes - [ ] `make docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added `sandbox doctor` command for comprehensive health diagnostics across CLI, Docker, gateway, inference, and messaging systems. * Introduced enhanced sandbox management workflows including connection, destruction, and rebuild operations. * Added `sandbox upgrade` to automatically rebuild sandboxes with outdated agent versions. * Improved sandbox status reporting with live gateway state and inference health visibility. * Added sandbox skill install functionality for local skill deployment. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
prekshivyas
left a comment
There was a problem hiding this comment.
LGTM. Pure additive metadata change — static examples arrays added to oclif Command classes for list, status, gateway-token, credentials*, backup-all, upgrade-sandboxes, gc, uninstall, tunnel start/stop, and the deprecated start/stop aliases. No run() body, flag, or arg changes anywhere.
The one slightly-non-cosmetic change — adding Flags.help({ char: "h" }) to UninstallCliCommand — brings its metadata into parity with peer utility commands. Strictly a UX improvement (explicit -h/--help), not a regression.
Public CLI surface unchanged (examples only render in --help output). src/nemoclaw.ts untouched, so the cumulative ~16-orphan debt is unaffected.
CI: pr.yaml mostly green (commit-lint, dco-check, check-hash, legacy-path-guard, changes PASS; macos-e2e and checks still in progress at review time). For an examples-only change with zero behavioral surface, lightweight gates are adequate signal.
## Summary Move the sandbox logs command's `--tail`, `-n`, `--since`, and `--follow` option shape into the oclif adapter so invalid flag values fail before any OpenShell calls. This also carries the log filter options through the logs action and updates help/registry metadata for the new flags. ## Stack Navigation - Position: 13 of 60 - Previous PR: [#2902 — refactor(cli): add oclif examples for utility commands](#2902) - Next PR: [#2906 — refactor(cli): improve sandbox diagnostic command metadata](#2906) ## Changes - Added `SandboxLogsOptions` and wired `sandbox:logs` to pass structured log options instead of a bare follow boolean. - Modeled `--tail`/`-n` with `Flags.integer({ min: 1 })` and kept custom `--since` duration validation in the oclif command. - Updated log source argument construction so tail counts flow to both OpenClaw and OpenShell logs, while `--since` avoids an unfiltered gateway tail. - Expanded logs help metadata and root command registry flags. - Added CLI and command-adapter coverage for tail, since, follow, help, malformed values, and unknown flags. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Verification - [x] `npx prek run --all-files` passes - [x] `npm test` passes - [x] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [ ] Docs updated for user-facing behavior changes - [ ] `make docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * The `sandbox:logs` command now supports `--tail/-n` flag to display a specific number of log lines * Added `--since` flag to filter logs from a specified duration with validation and helpful error messages * Updated command documentation with usage examples <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Summary
Add oclif examples to low-risk global and utility commands so generated help has concrete usage snippets. This starts the oclif UX pass without changing command behavior.
Stack Navigation
Changes
list, globalstatus,gateway-token,credentials,credentials list, andcredentials reset.backup-all,upgrade-sandboxes, andgc.uninstall,tunnel start,tunnel stop, and deprecatedstart/stopaliases.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
Release Notes
New Features
sandbox doctorcommand for comprehensive health diagnostics across sandbox infrastructure, gateway, and servicesDocumentation