Skip to content

refactor(cli): group oclif core modules#2967

Merged
cv merged 75 commits intomainfrom
refactor/layer-cli-core-modules
May 5, 2026
Merged

refactor(cli): group oclif core modules#2967
cv merged 75 commits intomainfrom
refactor/layer-cli-core-modules

Conversation

@cv
Copy link
Copy Markdown
Contributor

@cv cv commented May 4, 2026

Summary

Start the CLI layer directory structure by grouping oclif core/runtime modules under src/lib/cli/. This makes argv normalization, dispatch, oclif runtime helpers, metadata lookup, public help rendering, and the shared command base visibly part of the CLI boundary.

Stack Navigation

Changes

  • Moved oclif core modules and their tests into src/lib/cli/.
  • Updated imports from src/nemoclaw.ts, root help, and existing command adapters.
  • Kept command behavior unchanged; this PR is a file-structure/import move only.

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 [email protected]

Summary by CodeRabbit

  • Refactor
    • Reorganized internal CLI module structure by moving related components into a dedicated subdirectory for improved code organization and maintainability. Updated import paths across multiple files to reflect the new hierarchy. Enhanced command metadata resolution to support additional packaging layouts. No changes to user-facing functionality or CLI behavior.

cv added 30 commits May 2, 2026 13:36
@cv cv self-assigned this May 4, 2026
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 4, 2026

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
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

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: 03b6854b-8bcf-4d99-9579-7f6d43a2f03d

📥 Commits

Reviewing files that changed from the base of the PR and between 89427ba and 15a4664.

📒 Files selected for processing (18)
  • src/lib/cli/argv-normalizer.test.ts
  • src/lib/cli/argv-normalizer.ts
  • src/lib/cli/nemoclaw-oclif-command.ts
  • src/lib/cli/oclif-dispatch.test.ts
  • src/lib/cli/oclif-dispatch.ts
  • src/lib/cli/oclif-metadata.test.ts
  • src/lib/cli/oclif-metadata.ts
  • src/lib/cli/oclif-runner.test.ts
  • src/lib/cli/oclif-runner.ts
  • src/lib/cli/public-oclif-help.test.ts
  • src/lib/cli/public-oclif-help.ts
  • src/lib/destroy-cli-command.ts
  • src/lib/list-command.ts
  • src/lib/maintenance-cli-commands.ts
  • src/lib/rebuild-cli-command.ts
  • src/lib/root-help-action.ts
  • src/lib/status-command.ts
  • src/nemoclaw.ts

📝 Walkthrough

Walkthrough

This PR reorganizes CLI-related modules by consolidating imports under a lib/cli/ namespace and updating import paths across the codebase. Additionally, module resolution for Oclif command metadata is expanded to support multiple packaging layouts.

Changes

CLI Module Reorganization

Layer / File(s) Summary
Runtime Module Resolution
src/lib/cli/oclif-metadata.ts
Search path candidates for oclif command metadata expanded from two locations to three: ../oclif-commands, ../oclif-commands.js, and ../../../dist/lib/oclif-commands.js to support additional packaging layouts.
CLI Submodule Imports
src/lib/cli/argv-normalizer.test.ts, src/lib/cli/oclif-runner.ts, src/lib/cli/public-oclif-help.ts
Import paths updated within the cli directory: test imports adjusted to ./argv-normalizer; oclif-runner.ts and public-oclif-help.ts imports for CLI_NAME changed from ./branding to ../branding.
Parent Lib Imports
src/lib/destroy-cli-command.ts, src/lib/list-command.ts, src/lib/maintenance-cli-commands.ts, src/lib/rebuild-cli-command.ts, src/lib/status-command.ts
Import paths for NemoClawCommand updated from ./nemoclaw-oclif-command to ./cli/nemoclaw-oclif-command across five command files.
Helper Module Imports
src/lib/root-help-action.ts
Import path for getRegisteredOclifCommandSummary changed from ./oclif-metadata to ./cli/oclif-metadata.
Entry Point
src/nemoclaw.ts
Main entry point updated with reorganized imports: oclif-runner from ./lib/oclif-runner to ./lib/cli/oclif-runner; cli-related modules consolidated under lib/cli/ namespace (argv-normalizer, public-oclif-help, oclif-dispatch).

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Hoppy hop, files rearranged,
CLI modules neatly exchanged,
Paths adjusted left and right,
Namespace tidy, structure tight!
Metadata searches far and wide,
Organization as our guide.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: grouping oclif core modules into src/lib/cli/. All file changes involve moving or updating imports for CLI modules into the cli subdirectory.
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/layer-cli-core-modules

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

@cv cv added the v0.0.34 Release target label May 4, 2026
@wscurran wscurran added NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI). refactor This is a refactor of the code and/or architecture. v0.0.34 Release target and removed v0.0.34 Release target labels May 4, 2026
@cv cv requested a review from prekshivyas May 5, 2026 00:27
@cv cv added v0.0.35 Release target and removed v0.0.34 Release target labels May 5, 2026
@prekshivyas prekshivyas self-assigned this May 5, 2026
cv added a commit that referenced this pull request May 5, 2026
## Summary
Extract pure policy-add argument parsing helpers from the policy/channel
action module.

## Stack Navigation
- Position: 51 of 60
- Previous PR: [#2965 — refactor(cli): extract sandbox logs
helpers](#2965)
- Next PR: [#2967 — refactor(cli): group oclif core
modules](#2967)

## Changes
- Added `policy-channel-helpers.ts` for custom policy source parsing,
confirmation bypass detection, and policy-add argument normalization.
- Updated `addSandboxPolicy` to use the extracted parser helpers while
keeping filesystem and policy application logic in the action module.
- Added direct helper coverage for `--from-file`, `--from-dir`, mutual
exclusion, missing values, confirmation aliases, and preset argument
parsing.

## 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 <[email protected]>

---------

Signed-off-by: Carlos Villela <[email protected]>
Co-authored-by: Prekshi Vyas <[email protected]>
@cv cv marked this pull request as ready for review May 5, 2026 23:38
@cv cv changed the base branch from refactor/retry-policy-channel-helpers to main May 5, 2026 23:38
@cv cv enabled auto-merge (squash) May 5, 2026 23:38
Copy link
Copy Markdown
Contributor

@prekshivyas prekshivyas left a comment

Choose a reason for hiding this comment

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

LGTM. Pure file-organization PR — 18 files / +18 / -14, with all renames tracked by git at 97–100% similarity.

Six oclif-core modules move src/lib/<name>.tssrc/lib/cli/<name>.ts. The only substantive content change is in oclif-metadata.ts: dynamic-require fallback paths shift to account for the new subdir location, plus a new ../oclif-commands.js entry to handle compiled-dist packaging layouts. Consumer files (6 + nemoclaw.ts) have one-line import-path updates.

Public CLI surface unchanged. Test files renamed alongside their sources.

CI: fully green across every check — pr.yaml (lint/dco/check-hash/legacy-path-guard/macos-e2e/changes/checks/test-e2e-ollama-proxy) + pr-self-hosted (build-sandbox-images/arm64, test-e2e-sandbox/gateway-isolation/port-overrides) + CodeRabbit. Cleanest hash on the stack.

@cv cv merged commit 5b89381 into main May 5, 2026
12 checks passed
cv added a commit that referenced this pull request May 6, 2026
## Summary
Split the oclif command adapter layer out of the flat `src/lib/`
directory and mirror the command tree under `src/lib/commands/**`.

## Stack Navigation
- Position: 53 of 60
- Previous PR: [#2967 — refactor(cli): group oclif core
modules](#2967)
- Next PR: [#2984 — refactor(cli): group pure domain
helpers](#2984)

## Changes
- Moved the explicit oclif registry to `src/lib/commands/index.ts` and
updated the oclif target in `package.json`.
- Split registered oclif command classes to one command per production
file, grouped by command family and sandbox scope.
- Moved command adapter tests beside the new command tree and updated
imports/mocks.
- Kept behavior unchanged; command IDs, public syntax, parser flags, and
action calls are preserved.

## 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 --stage pre-push` passes
- [x] `npm run clean:cli && npm run build:cli && npm run
dist:sourcemaps:check`
- [x] `npm run typecheck:cli`
- [x] Command adapter and metadata tests pass
- [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 (doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

---
Signed-off-by: Carlos Villela <[email protected]>

---------

Signed-off-by: Carlos Villela <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI). refactor This is a refactor of the code and/or architecture. v0.0.35 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants