refactor(cli): model onboard flags with oclif - #2913
Conversation
This reverts commit 4ebeae4.
|
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 📝 WalkthroughWalkthroughThree CLI commands (onboard, setup, setup-spark) switch from forwarding raw argv to strict Oclif Flags parsing. A shared typed flag schema and a converter produce legacy-style ChangesCLI Strict Flag Parsing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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)
Comment |
## Summary Move `debug` flag parsing into its oclif adapter so unknown flags and missing flag values fail through the parser before diagnostic collection. The debug action helpers remain available for existing unit tests and now also accept already-parsed options. ## Stack Navigation - Position: 20 of 60 - Previous PR: [#2911 — refactor(cli): split share into oclif subcommands](#2911) - Next PR: [#2913 — refactor(cli): model onboard flags with oclif](#2913) ## Changes - Modeled `--quick`/`-q`, `--output`/`-o`, and `--sandbox` as oclif flags. - Added debug command examples. - Added `runDebugCommandWithOptions` for adapters that already have parsed options. - Updated CLI and unit tests for oclif-owned parse errors and parsed-option execution. ## 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 * **New Features** * Added sandbox diagnostics (`doctor` command) to troubleshoot sandbox and gateway health. * Enhanced logs command with `--tail`, `--since`, and `--follow` options. * Expanded skill installation workflow for sandbox customization. * **Improvements** * Added CLI usage examples and shorthand flags (e.g., `-y`, `-v`) across commands. * Improved command validation and error messaging for required arguments. * Enhanced sandbox lifecycle management and recovery workflows. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <cvillela@nvidia.com> Co-authored-by: Prekshi Vyas <34834085+prekshivyas@users.noreply.github.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/cli.test.ts (1)
908-910: ⚡ Quick winAssert parser-owned failure code explicitly in unknown-flag tests
These checks now only require “non-zero,” which can pass for downstream action failures. Since this suite is validating parser ownership, assert the parser exit code directly.
Suggested fix
- expect(r.code).not.toBe(0); + expect(r.code).toBe(2); expect(r.out).toContain("Nonexistent flag: --non-interactiv");Apply this to each updated unknown-flag test in this block.
Also applies to: 914-916, 920-922, 934-935
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/cli.test.ts` around lines 908 - 910, Replace the loose "expect(r.code).not.toBe(0)" assertions in the unknown-flag tests with a strict assertion against the parser's specific exit code (e.g., expect(r.code).toBe(PARSER_EXIT_CODE)); reference the test result variables r.code and r.out and either use an existing parser exit-code constant or define one (PARSER_EXIT_CODE) near the tests so the assertion verifies parser-owned failures; apply the same change to the other occurrences mentioned (the blocks around assertions for lines 914-916, 920-922, and 934-935).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/onboard-cli-commands.ts`:
- Around line 63-65: The current truthy checks drop empty-string flag values
when rebuilding argv; update the conditions for flags.from, flags.name, and
flags.agent so they test for undefined (or null) instead of truthiness. Replace
the three checks that read "if (flags.from) ..." / "if (flags.name) ..." / "if
(flags.agent) ..." with explicit presence checks (e.g., if (flags.from !==
undefined) args.push("--from", flags.from); and similarly for flags.name and
flags.agent) so "" is preserved and the action layer receives the flag value.
---
Nitpick comments:
In `@test/cli.test.ts`:
- Around line 908-910: Replace the loose "expect(r.code).not.toBe(0)" assertions
in the unknown-flag tests with a strict assertion against the parser's specific
exit code (e.g., expect(r.code).toBe(PARSER_EXIT_CODE)); reference the test
result variables r.code and r.out and either use an existing parser exit-code
constant or define one (PARSER_EXIT_CODE) near the tests so the assertion
verifies parser-owned failures; apply the same change to the other occurrences
mentioned (the blocks around assertions for lines 914-916, 920-922, and
934-935).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: fbadc1d8-2d18-430f-bbbf-fcb65a2651b5
📒 Files selected for processing (2)
src/lib/onboard-cli-commands.tstest/cli.test.ts
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
|
Addressed CodeRabbit feedback in
Validation run locally:
|
prekshivyas
left a comment
There was a problem hiding this comment.
LGTM. Three onboard-family commands (onboard/setup/setup-spark) flip strict=true with explicit oclif Flags declarations for the full flag surface; toLegacyOnboardArgs helper rebuilds the legacy argv so the existing action layer keeps all domain validation. Setup/setup-spark preserve their deprecation help via an early --help shortcut.
Three intentional, tested public-surface deltas (all declared in PR description):
- Unknown flags now exit 2 (oclif's
Nonexistent flag: --foo) instead of 1 (Unknown onboard option(s)). Tests refactored withPARSER_EXIT_CODE = 2. - Help heading is oclif's
USAGEinstead ofUsage:. Test updated. --control-ui-portnow hasmin: 1024, max: 65535. Defensible (avoids privileged ports / out-of-range integers) but not covered by an explicit boundary test in this diff — worth a callout if any user was relying on lower ports.
Scope hygiene clean — only onboard-cli-commands.ts + test/cli.test.ts. src/nemoclaw.ts untouched.
CI: pr.yaml mostly green (lint/dco/check-hash/legacy-path-guard/changes PASS); macos-e2e/wsl-e2e/checks + pr-self-hosted builds still in flight at review time. No failures.
## Summary Sync the CLI command reference with the oclif UX changes in the stacked parser/help PRs. This updates documented usage for new aliases, parser-owned flags, and recent command examples. ## Stack Navigation - Position: 22 of 60 - Previous PR: [#2913 — refactor(cli): model onboard flags with oclif](#2913) - Next PR: [#2916 — refactor(cli): extract public argv normalizer](#2916) ## Changes - Documented `--resume | --fresh` in onboard usage. - Added logs `--tail`/`-n` and `--since` usage. - Updated lifecycle confirmation aliases and debug short flags. - Updated `gc` and `upgrade-sandboxes` confirmation alias references. ## Type of Change - [ ] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [x] 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 - [x] Docs updated for user-facing behavior changes - [ ] `make docs` builds without warnings (doc changes only) - [x] 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 * **New Features** * Added `sandbox doctor` command for sandbox and gateway health diagnostics * Enhanced `sandbox logs` with `--tail/-n <lines>` and `--since <duration>` options * Added new `sandbox share` subcommands (`mount`, `unmount`, `status`) * Added short flag aliases: `-y` for `--yes`, `-v` for `--verbose`, `-q` for `--quick`, `-o` for `--output` * Added `--fresh` option to `onboard` command * **Improvements** * Made required arguments mandatory (skill path, channel name) with early validation * Enhanced debug command with `-q` and `-o` short aliases * Added CLI usage examples to multiple commands for better discoverability <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Summary
Model the onboard/setup/setup-spark flag surface in oclif while preserving the existing onboarding action validation for Dockerfile paths, agents, sessions, and third-party notice semantics. This lets oclif own unknown flags and missing flag values before the onboarding action runs.
Stack Navigation
Changes
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
Refactor
Documentation
Tests