Skip to content

refactor(cli): add shared oclif command base - #2926

Merged
cv merged 36 commits into
mainfrom
refactor/oclif-first-command-base
May 5, 2026
Merged

refactor(cli): add shared oclif command base#2926
cv merged 36 commits into
mainfrom
refactor/oclif-first-command-base

Conversation

@cv

@cv cv commented May 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Introduce a shared NemoClaw oclif command base so common parser conventions live in one place instead of every command class redefining them.

Stack Navigation

Changes

  • Added NemoClawCommand with common -h/--help base flag handling.
  • Centralized JSON formatting used by oclif JSON-enabled commands.
  • Migrated low-risk list, status, and maintenance command adapters to the shared base.

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

  • Refactor
    • Restructured CLI command architecture for backup, upgrade, garbage collection, list, and status operations. All commands continue to function with consistent help and JSON output support.

cv added 30 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

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 85c9f684-e5fa-4b4d-92a1-9296610c505e

📥 Commits

Reviewing files that changed from the base of the PR and between cd56a9e and 4222730.

📒 Files selected for processing (4)
  • src/lib/list-command.ts
  • src/lib/maintenance-cli-commands.ts
  • src/lib/nemoclaw-oclif-command.ts
  • src/lib/status-command.ts

📝 Walkthrough

Walkthrough

A new shared base class NemoClawCommand is introduced, consolidating help flag definition and JSON logging behavior previously duplicated across CLI commands. Four command classes are refactored to extend this base class and remove redundant implementations.

Changes

CLI Command Consolidation

Layer / File(s) Summary
Base Class Introduction
src/lib/nemoclaw-oclif-command.ts
New NemoClawCommand extends @oclif/core's Command, defines baseFlags with -h/--help, and provides protected logJson(json: unknown) helper for formatted JSON output.
Command Migration
src/lib/list-command.ts, src/lib/status-command.ts, src/lib/maintenance-cli-commands.ts
Four command classes (ListCommand, StatusCommand, BackupAllCommand, UpgradeSandboxesCommand, GarbageCollectImagesCommand) updated to extend NemoClawCommand instead of Command.
Flag & Method Cleanup
src/lib/list-command.ts, src/lib/status-command.ts, src/lib/maintenance-cli-commands.ts
static flags changed from declaring help flag to empty objects; protected logJson() methods removed from individual commands (now provided by base class).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Commands once scattered, now they're neat,
A base class brings them all to meet.
Help and JSON, shared with care,
Less duplication in the air!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor(cli): add shared oclif command base' accurately describes the primary change: introducing a shared NemoClawCommand base class for oclif commands to centralize common conventions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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-first-command-base

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

@cv cv added the v0.0.34 label May 4, 2026
@wscurran wscurran added NemoClaw CLI refactor PR restructures code without intended behavior change and removed v0.0.34 labels May 4, 2026

@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 and removed v0.0.34 labels May 5, 2026
cv added a commit that referenced this pull request May 5, 2026
## Summary
Introduce a public oclif help renderer for sandbox-scoped help paths
that still use compatibility routing. This lets those paths display
public NemoClaw syntax while pulling summaries and examples from oclif
command metadata.

## Stack Navigation
- Position: 32 of 60
- Previous PR: [#2924 — refactor(cli): normalize gateway token command
id](#2924)
- Next PR: [#2926 — refactor(cli): add shared oclif command
base](#2926)

## Changes
- Added a public help renderer that combines public usage with
registered oclif metadata.
- Extended help dispatch results with the oclif command ID that owns the
help text.
- Updated the top-level dispatcher to render public oclif help when
command metadata is available.
- Added coverage that public help output avoids internal command IDs.

## 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>

---------

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv marked this pull request as ready for review May 5, 2026 19:12
@cv
cv changed the base branch from refactor/oclif-arch-public-help-renderer to main May 5, 2026 19:12
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv enabled auto-merge (squash) May 5, 2026 19:15
@cv
cv merged commit a21e08d into main May 5, 2026
14 of 15 checks passed
cv added a commit that referenced this pull request May 5, 2026
## Summary
Move simple cross-flag validation into oclif metadata so NemoClaw does
not maintain duplicate parser logic for relationships oclif already
supports.

## Stack Navigation
- Position: 34 of 60
- Previous PR: [#2926 — refactor(cli): add shared oclif command
base](#2926)
- Next PR: [#2928 — refactor(cli): pass lifecycle typed
options](#2928)

## Changes
- Made onboard `--resume` and `--fresh` mutually exclusive through oclif
flag metadata.
- Made policy `--from-file` and `--from-dir` mutually exclusive through
oclif flag metadata.
- Added command-level tests showing invalid flag combinations fail
before action dispatch.
- Updated policy CLI expectations for oclif's relationship validation
wording.

## 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 comprehensive health diagnostics
* Enhanced logs streaming with `--follow`, `--tail`, and `--since`
filtering options

## Improvements
* Added short flag aliases: `-y` for `--yes`, `-q` for `--quick`, `-n`
for `--tail`, `-v` for `--verbose`, `-o` for `--output`
* Improved CLI help output with command examples across all subcommands
* Enhanced error messages and argument validation for better user
guidance
* Extended sandbox rebuild workflow with credential preflight and
workspace backup/restore

## Documentation
* Updated documented CLI flag syntax for all major commands with new
short forms and options

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

---------

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv deleted the refactor/oclif-first-command-base branch May 27, 2026 21:18
@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