refactor(cli): extract policy channel helpers#2966
Merged
Conversation
This reverts commit 4ebeae4.
This was referenced May 4, 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]>
Signed-off-by: Carlos Villela <[email protected]>
prekshivyas
approved these changes
May 5, 2026
Contributor
prekshivyas
left a comment
There was a problem hiding this comment.
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=1check, 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
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extract pure policy-add argument parsing helpers from the policy/channel action module.
Stack Navigation
Changes
policy-channel-helpers.tsfor custom policy source parsing, confirmation bypass detection, and policy-add argument normalization.addSandboxPolicyto use the extracted parser helpers while keeping filesystem and policy application logic in the action module.--from-file,--from-dir, mutual exclusion, missing values, confirmation aliases, and preset argument parsing.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela [email protected]
Summary by CodeRabbit
Refactor
Tests