refactor(cli): extract public argv normalizer - #2916
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 failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new CLI argv normalizer module is introduced that formalizes the parsing of command-line arguments into a discriminated union type ( ChangesCLI Argument Normalization
Sequence DiagramsequenceDiagram
participant CLI as CLI Input
participant NormAr as Argv Normalizer
participant Main as Main Dispatcher
participant GCmd as Global Command<br/>Handler
participant SBx as Sandbox Action<br/>Handler
CLI->>NormAr: argv: string[]
activate NormAr
alt Empty or --help
NormAr-->>NormAr: { kind: "rootHelp" }
else --dump-commands
NormAr-->>NormAr: { kind: "dumpCommands" }
else Known global command
NormAr-->>NormAr: { kind: "global", command, args }
else Sandbox invocation
NormAr-->>NormAr: { kind: "sandbox",<br/>sandboxName, action,<br/>actionArgs, connectHelpRequested }
end
NormAr-->>Main: NormalizedArgv
deactivate NormAr
activate Main
alt kind = "rootHelp" | "dumpCommands"
Main->>Main: Handle early
else kind = "global"
Main->>GCmd: Dispatch command
activate GCmd
GCmd-->>Main: Result
deactivate GCmd
else kind = "sandbox"
alt connectHelpRequested
Main->>Main: Show connect help
else
Main->>SBx: Execute action
activate SBx
SBx-->>Main: Result
deactivate SBx
end
end
deactivate Main
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
## 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>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
## Summary Remove the stale legacy naming from the oclif dispatch helper now that sandbox and global commands route through explicit oclif adapters. This is a small naming cleanup in the architecture follow-up stack. ## Stack Navigation - Position: 24 of 60 - Previous PR: [#2916 — refactor(cli): extract public argv normalizer](#2916) - Next PR: [#2918 — refactor(cli): normalize policy command ids](#2918) ## Changes - Renamed `legacy-oclif-dispatch` to `oclif-dispatch`. - Updated the CLI entrypoint and dispatch tests to import the renamed module. - Kept dispatch behavior unchanged. ## 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 `doctor` command for health diagnostics across Host, Gateway, Sandbox, Inference, Messaging, and Local services. * Enhanced logs command with `--tail/-n`, `--since` filtering, and `--follow` output controls. * Onboard now supports `--non-interactive` and `--fresh` flags. * Debug command adds `--quick/-q` option. * **Improvements** * Channel mutation, destroy, rebuild, and maintenance commands now support `-y` shorthand flag. * Share command refactored with dedicated `mount`, `unmount`, `status` subcommands. * Stricter argument validation across CLI commands. * Added command usage examples throughout CLI. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Summary
Start the post-UX architecture cleanup by extracting public argv normalization out of
src/nemoclaw.ts. The top-level entrypoint still owns registry recovery and user-facing routing errors, but command classification now lives in a focused helper with unit coverage.Stack Navigation
Changes
src/lib/cli-argv-normalizer.tsfor root/global/sandbox argv normalization and typo suggestions.src/nemoclaw.tswith the normalizer.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
Tests
Refactor