Skip to content

refactor(cli): normalize policy command ids - #2918

Merged
cv merged 28 commits into
mainfrom
refactor/oclif-arch-normalize-policy-ids
May 5, 2026
Merged

cv merged 28 commits into
mainfrom
refactor/oclif-arch-normalize-policy-ids

Conversation

@cv

@cv cv commented May 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Start normalizing sandbox-scoped internal command IDs by moving policy commands to topic-style IDs. Public CLI syntax stays unchanged (policy-add, policy-remove, policy-list).

Stack Navigation

Changes

  • Renamed internal policy command IDs to sandbox:policy:add, sandbox:policy:remove, and sandbox:policy:list.
  • Updated dispatch routing and oclif command registration for the new IDs.
  • Updated dispatch tests for the normalized IDs.

Type of Change

  • 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

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • 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 (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Carlos Villela cvillela@nvidia.com

Summary by CodeRabbit

  • New Features

    • Added sandbox:doctor CLI command
  • Improvements

    • Updated sandbox policy command naming: sandbox:policy:add, sandbox:policy:list, sandbox:policy:remove
    • Enhanced sandbox:config get with JSON and YAML format options
    • Added CLI usage examples for sandbox status, policy list, channels list, and config commands

cv added 27 commits May 2, 2026 13:36
@cv cv self-assigned this May 3, 2026
@copy-pr-bot

copy-pr-bot Bot commented May 3, 2026

Copy link
Copy Markdown

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.

@coderabbitai

coderabbitai Bot commented May 3, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 902b503a-204a-40b9-bfd9-044d0eea7db3

📥 Commits

Reviewing files that changed from the base of the PR and between 9499ca6 and 944b9aa.

📒 Files selected for processing (3)
  • src/lib/oclif-commands.ts
  • src/lib/oclif-dispatch.test.ts
  • src/lib/oclif-dispatch.ts

📝 Walkthrough

Walkthrough

This PR modernizes the CLI command registry and routing by adding a new sandbox:doctor command, renaming policy command keys from hyphenated to colon-delimited format, removing the legacy dispatch fallback mechanism, and enhancing command metadata with examples and usage strings for improved UX.

Changes

CLI Command Routing Modernization

Layer / File(s) Summary
Command Registry
src/lib/oclif-commands.ts
Added sandbox:doctor command. Renamed policy command keys from sandbox:policy-add|list|remove to sandbox:policy:add|list|remove while preserving handler references.
Routing Logic
src/lib/oclif-dispatch.ts
Removed LegacyDispatch mechanism from DispatchResult union. Updated resolveSandboxOclifDispatch to route doctor, policy-add, skill, and snapshot directly through oclif adapters instead of legacy fallbacks. Expanded help and usage strings for logs, destroy, rebuild, and policy-add.
Command Metadata
src/lib/policy-mutate-cli-commands.ts, src/lib/sandbox-inspection-cli-command.ts
Added static examples arrays to PolicyAddCommand, PolicyRemoveCommand, SandboxStatusCommand, SandboxPolicyListCommand, SandboxChannelsListCommand, and SandboxConfigGetCommand. Updated usage declarations and expanded SandboxConfigGetCommand.flags.format with explicit options: ["json", "yaml"] constraint.
Tests & Validation
src/lib/oclif-dispatch.test.ts
Added test cases verifying status, doctor, recover, logs routing and help behavior; confirming policy-add --from-file, skill, and snapshot route through oclif with correct command IDs and forwarded arguments.

Sequence Diagram

sequenceDiagram
    participant User
    participant Dispatch as resolveSandboxOclifDispatch
    participant Handlers as Oclif Handlers
    
    User->>Dispatch: sandbox doctor [args]
    Dispatch->>Dispatch: Check action == "doctor"
    Dispatch->>Handlers: Route to sandbox:doctor command
    Handlers->>Handlers: Execute SandboxDoctorCliCommand
    Handlers-->>User: Result
    
    User->>Dispatch: sandbox policy-add --from-file file.yaml
    Dispatch->>Dispatch: Check action == "policy-add"
    Dispatch->>Handlers: Route to sandbox:policy:add command
    Handlers->>Handlers: Execute PolicyAddCommand
    Handlers-->>User: Result
    
    User->>Dispatch: sandbox doctor --help
    Dispatch->>Dispatch: Detect --help flag
    Dispatch-->>User: Return help usage (public, not routed)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 The doctor's in—no more legacy ways!
Commands now routed through modern displays,
With : delimiters, policies refined,
Examples and options beautifully aligned,
The sandbox shines bright in its freshly oclif'd days! 🌟

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/oclif-arch-normalize-policy-ids

Comment @coderabbitai help to get the list of available commands and usage tips.

@cjagwani cjagwani left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved as part of stack from #2886 (auto-approve: CI green, no scope/behavior flags).

@cv cv added v0.0.35 refactor PR restructures code without intended behavior change and removed v0.0.34 labels May 5, 2026
cv added a commit that referenced this pull request May 5, 2026
## 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>
@cv
cv marked this pull request as ready for review May 5, 2026 17:32
@cv
cv changed the base branch from refactor/oclif-arch-dispatch-module to main May 5, 2026 17:32
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv enabled auto-merge (squash) May 5, 2026 17:36
@cv
cv merged commit 01b9191 into main May 5, 2026
11 checks passed
cv added a commit that referenced this pull request May 5, 2026
## Summary
Make oclif command metadata the enforced source for public command help
basics. This adds a metadata guard and fills the remaining missing
example on the deprecated deploy adapter.

## Stack Navigation
- Position: 26 of 60
- Previous PR: [#2918 — refactor(cli): normalize policy command
ids](#2918)
- Next PR: [#2920 — refactor(cli): return typed debug parse
results](#2920)

## Changes
- Added a command metadata test for registered public oclif commands.
- Required each public command class to provide summary, description,
usage, and examples.
- Added a deploy command example to satisfy the metadata contract.

## 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 diagnostic command for health checks and troubleshooting
* Enhanced log viewing with tail count, duration filtering, and follow
options
* Improved command structure with new dedicated commands for share,
skill, and snapshot operations

* **Documentation**
* Updated CLI reference with additional flag options across multiple
commands, including shorthand variants (`-y`, `-q`, `-v`) and new
parameters

* **Improvements**
  * Enhanced error handling and validation for CLI arguments
  * Expanded command examples throughout the interface

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv deleted the refactor/oclif-arch-normalize-policy-ids branch May 27, 2026 21:17
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output and removed NemoClaw CLI labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output refactor PR restructures code without intended behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants