Skip to content

refactor(cli): extract policy channel helpers#2966

Merged
cv merged 74 commits intomainfrom
refactor/retry-policy-channel-helpers
May 5, 2026
Merged

refactor(cli): extract policy channel helpers#2966
cv merged 74 commits intomainfrom
refactor/retry-policy-channel-helpers

Conversation

@cv
Copy link
Copy Markdown
Contributor

@cv cv commented May 4, 2026

Summary

Extract pure policy-add argument parsing helpers from the policy/channel action module.

Stack Navigation

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

  • 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

    • Improved internal organization of policy argument handling with better validation for policy sources and confirmation flags.
  • Tests

    • Added comprehensive test coverage for policy source parsing and confirmation logic.

cv added 30 commits May 2, 2026 13:36
@cv cv added the v0.0.34 Release target label May 4, 2026
@wscurran wscurran added CI/CD Use this label to identify issues with NemoClaw CI/CD pipeline or GitHub Actions. 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. 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 the v0.0.35 Release target label 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 sandbox log option and argv helpers from the log streaming
action module.

## Stack Navigation
- Position: 50 of 60
- Previous PR: [#2964 — refactor(cli): extract sandbox destroy
helpers](#2964)
- Next PR: [#2966 — refactor(cli): extract policy channel
helpers](#2966)

## Changes
- Added `sandbox-logs-helpers.ts` for option normalization, timeout
parsing, probe descriptions, signal exit codes, and OpenShell argv
builders.
- Updated `sandbox-logs-action.ts` to import the helper logic and focus
on subprocess orchestration.
- Moved helper tests to target the extracted helper module directly.

## 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]>
Base automatically changed from refactor/retry-sandbox-logs-helpers to main May 5, 2026 23:24
@cv cv marked this pull request as ready for review May 5, 2026 23:27
@cv cv enabled auto-merge (squash) May 5, 2026 23:27
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. Same extraction pattern as #2962/#2963/#2964/#2965 — 3 files / +130 / -25.

Three pure helpers in new policy-channel-helpers.ts:

  • parseCustomPolicySource — tagged union (none/file/dir/error) covering mutual-exclusion + missing-value parsing. Error messages preserved verbatim.
  • shouldSkipPolicyConfirmation — wraps the inline --yes/-y/--force/NEMOCLAW_NON_INTERACTIVE=1 check, env injectable.
  • parsePolicyAddArgs — composes the above + dryRun + presetArg.

addSandboxPolicy simplifies from ~17 lines of inline arg parsing to a single call. Error messages, exit codes, flag semantics, env vars all preserved verbatim. applyExternalPreset call uses destructured values cleanly.

+52 lines of focused tests — happy paths, error paths (missing values, mutual exclusion), confirmation bypass (with env), and combined parsing.

CI: pr.yaml fully green (lint/dco/check-hash/legacy-path-guard/macos-e2e/changes/checks/test-e2e-ollama-proxy PASS); pr-self-hosted builds still in flight at review time. No failures.

@cv cv merged commit 89427ba into main May 5, 2026
11 checks passed
cv added a commit that referenced this pull request May 5, 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
- Position: 52 of 60
- Previous PR: [#2966 — refactor(cli): extract policy channel
helpers](#2966)
- Next PR: [#2970 — refactor(cli): split oclif commands by command
tree](#2970)

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


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

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

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

---------

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

Labels

CI/CD Use this label to identify issues with NemoClaw CI/CD pipeline or GitHub Actions. 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