feat(cli): add and validate nemoclaw update command#2883
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a new global Changesnemoclaw update Implementation & Integration
Linting Config Update (independent)
Sequence DiagramsequenceDiagram
autonumber
actor User
participant CLI as "nemoclaw (CLI)"
participant Parser as "parseUpdateArgs"
participant NPM as "npm registry"
participant Preflight as "Host Preflight (Docker/OpenShell)"
participant Worker as "Detached Update Worker"
participant Install as "npm install -g"
participant Sandbox as "upgrade-sandboxes --auto"
participant Log as "Update Log File"
User->>CLI: nemoclaw update [--check] [--auto]
CLI->>Parser: parseUpdateArgs
Parser-->>CLI: { check, auto }
CLI->>NPM: getLatestNemoClawVersion (with retry)
NPM-->>CLI: latest version
CLI->>CLI: isUpdateAvailable / compute sudo & prefix / plan sandbox sync
alt --check
CLI-->>User: summary (no install)
else --auto
CLI->>Preflight: assessHost (Docker reachable?, OpenShell)
Preflight-->>CLI: preflight results / warnings
CLI->>Worker: startDetachedUpdateWorker(payload)
Worker->>Install: npm install -g nemoclaw@latest (maybe sudo -n)
Install-->>Worker: stdout/stderr/exit
opt Docker reachable
Worker->>Sandbox: upgrade-sandboxes --auto
Sandbox-->>Worker: sync result
end
Worker->>Log: append timestamped output, warnings, status
Worker-->>CLI: detached PID / status
CLI-->>User: detached worker started (PID) / plan info
end
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~60 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
test/cli.test.ts (1)
193-196: ⚡ Quick winKeep asserting the parser-specific failure here.
This case now passes on any exit-1 path, so a regression in onboard option routing could slip through unnoticed. Please keep the
"Unknown onboard option"assertion here as well, like the neighboring cases do.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/cli.test.ts` around lines 193 - 196, The test "unknown onboard option exits 1" currently only asserts exit code; update it to also assert the parser-specific error message by checking that the output (from the run(...) result object returned by run) contains the string "Unknown onboard option" in addition to expect(r.code).toBe(1); locate the test case in test/cli.test.ts (the it block with run("onboard --invalid-opt")) and add an assertion similar to the neighboring cases that inspects r.stdout or r.stderr (whichever run returns parser messages on) for the exact "Unknown onboard option" text.test/update.test.ts (1)
20-23: ⚡ Quick winTighten help assertions to avoid false positives
These checks are very broad (
"update","--check","--auto"anywhere in help output). They can pass even if theupdatecommand row is malformed. Prefer matching the specific update command/help row with a scoped regex.Suggested fix
- expect(output).toContain("update"); + expect(output).toMatch(/^\s+update\b/m); - expect(output).toContain("--check"); + expect(output).toMatch(/^\s+update\b.*--check/m); - expect(output).toContain("--auto"); + expect(output).toMatch(/^\s+update\b.*--auto/m);Also applies to: 44-52
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/update.test.ts` around lines 20 - 23, The test "update command appears in help output" (and the similar assertion around lines 44-52) uses broad substring checks; replace the loose expect(output).toContain(...) checks with assertions that match the specific help row for the update command by using an anchored, line-scoped regular expression that ensures a single help line begins with the "update" command and includes the expected flags (e.g., --check and --auto) and spacing; update the assertions that consume execSync(`node "${CLI}" help`) to use this scoped regex match so the test fails when the update row is malformed rather than when the tokens appear anywhere in help output.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/update.ts`:
- Around line 572-585: The code currently restores credential permissions to a
hard-coded 0o600; instead use the original mode stored in
payload.credentialsMode so we truly preserve original permissions. In the block
that calls chmodSyncImpl(payload.credentialsFilePath, 0o600) replace the
hard-coded mode with payload.credentialsMode, and update the warning messages
that mention "Restored to 0600" or formatMode(currentMode) to use
formatMode(payload.credentialsMode) so the log reflects the actual restored
mode; keep the existing try/catch and error-string logic unchanged and continue
pushing messages into warnings.
- Around line 506-514: The resolveUpdateLogFilePath function currently returns a
path inside baseDir but doesn't ensure baseDir exists; modify
resolveUpdateLogFilePath to create the directory (e.g., using fs.mkdirSync or
fs.promises.mkdir with { recursive: true }) for baseDir before returning the
joined "update.log" path so subsequent appendWorkerLog() calls won't fail with
ENOENT; perform the mkdir in the same function (referencing credentialFilePath,
baseDir, and resolveHomeDirectory) and surface or log any unexpected errors as
appropriate.
In `@src/nemoclaw.ts`:
- Line 3776: The callback passed to printUpdateUsage currently forwards the
possibly-undefined line directly to console.error, which causes literal
"undefined" to appear; update the callback used where printUpdateUsage((line?:
string) => console.error(line)) is called so it normalizes undefined to an empty
string (or only logs when line is defined) before calling console.error (e.g.,
replace direct forwarding with a wrapper that does console.error(line ?? '') or
conditional logging) targeting the invocation that passes the anonymous callback
to printUpdateUsage.
---
Nitpick comments:
In `@test/cli.test.ts`:
- Around line 193-196: The test "unknown onboard option exits 1" currently only
asserts exit code; update it to also assert the parser-specific error message by
checking that the output (from the run(...) result object returned by run)
contains the string "Unknown onboard option" in addition to
expect(r.code).toBe(1); locate the test case in test/cli.test.ts (the it block
with run("onboard --invalid-opt")) and add an assertion similar to the
neighboring cases that inspects r.stdout or r.stderr (whichever run returns
parser messages on) for the exact "Unknown onboard option" text.
In `@test/update.test.ts`:
- Around line 20-23: The test "update command appears in help output" (and the
similar assertion around lines 44-52) uses broad substring checks; replace the
loose expect(output).toContain(...) checks with assertions that match the
specific help row for the update command by using an anchored, line-scoped
regular expression that ensures a single help line begins with the "update"
command and includes the expected flags (e.g., --check and --auto) and spacing;
update the assertions that consume execSync(`node "${CLI}" help`) to use this
scoped regex match so the test fails when the update row is malformed rather
than when the tokens appear anywhere in help output.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 5022d4f0-de0e-4969-98fb-01319a1d17ce
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (12)
.hadolint.yamldocs/reference/commands.mdpackage.jsonsrc/lib/command-registry.test.tssrc/lib/command-registry.tssrc/lib/nim.test.tssrc/lib/update.test.tssrc/lib/update.tssrc/nemoclaw.tstest/cli.test.tstest/onboard.test.tstest/update.test.ts
375d739 to
2acb6b5
Compare
Signed-off-by: Suryaansh <Suryaansh.aa@gmail.com>
Signed-off-by: Suryaansh <Suryaansh.aa@gmail.com>
Signed-off-by: Suryaansh <Suryaansh.aa@gmail.com>
2acb6b5 to
3ad1500
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/update.ts`:
- Around line 506-519: The resolveUpdateLogFilePath function currently calls
resolveHomeDirectory(env) which bypasses the HOME safety checks used by the
credentials code; replace that call with the validated home resolver used by the
credentials module (the same function that enforces HOME safety) so update log
directory creation uses the guarded HOME value, and keep the existing
mkdirSync/error handling around the resulting baseDir; update the import at the
top to bring in the validated resolver and use it instead of
resolveHomeDirectory(env) inside resolveUpdateLogFilePath.
- Around line 479-487: The helper describeWorkerResult currently hides spawn
failures because it only checks status and signal; update it to surface the
SpawnSyncReturns.error when present (check the result.error property on the
SpawnSyncReturns<string>), and return a descriptive string incorporating
error.name, error.code and/or error.message (and optionally error.stack) so
detached-update logs show why npm/sudo failed to start; keep the existing
branches (status -> "exit X", signal -> "signal Y") and only fall back to the
error-derived message before returning "unknown exit".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 0d65e3ab-59e0-427c-b967-e8144adf894b
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (11)
.hadolint.yamldocs/reference/commands.mdpackage.jsonsrc/lib/command-registry.test.tssrc/lib/command-registry.tssrc/lib/nim.test.tssrc/lib/update.test.tssrc/lib/update.tssrc/nemoclaw.tstest/cli.test.tstest/update.test.ts
✅ Files skipped from review due to trivial changes (9)
- .hadolint.yaml
- package.json
- docs/reference/commands.md
- test/update.test.ts
- src/lib/command-registry.test.ts
- src/nemoclaw.ts
- src/lib/nim.test.ts
- src/lib/update.test.ts
- test/cli.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/lib/command-registry.ts
Signed-off-by: Suryaansh <Suryaansh.aa@gmail.com>
|
✨ Thanks for submitting this PR that proposes a new |
ericksoa
left a comment
There was a problem hiding this comment.
Approved after adversarial review and follow-up hardening. The updated command preserves the maintained installer path, handles nemohermes branding/agent selection, avoids npm as release truth, uses pipefail, and keeps the sandbox upgrade boundary explicit.
## Summary Refreshes the release-prep docs for v0.0.39 based on changes merged since the Friday 4pm doc refresh. Updates the source docs, bumps the docs version metadata, and regenerates the NemoClaw user skills from the refreshed docs. ## Changes - #3314 -> `docs/get-started/prerequisites.md`, `docs/get-started/quickstart.md`, `docs/reference/troubleshooting.md`: Documents installer Docker setup, Docker group activation, and retry guidance. - #3317 -> `docs/get-started/quickstart.md`, `docs/reference/commands.md`: Documents the DGX Spark and DGX Station express install prompt and `NEMOCLAW_NO_EXPRESS`. - #3328 and #3329 -> `docs/security/best-practices.md`, `docs/deployment/sandbox-hardening.md`: Updates sandbox capability hardening docs for the stricter bounding-set and `setpriv` step-down behavior. - #3330, #3335, and #3346 -> `docs/inference/use-local-inference.md`: Documents Windows-host Ollama relaunch behavior, NIM key passthrough, early health-fail diagnostics, and mixed-GPU preflight detail. - #2406, #2883, #3001, #3244, #3267, #3318, #3320, and #3354 -> `docs/about/release-notes.md`: Adds the v0.0.39 release-prep section while keeping the v0.0.38 release notes intact. - Advances the release-prep docs metadata from v0.0.38 to v0.0.39. - Regenerates `.agents/skills/nemoclaw-user-*` from the updated source docs. ## Type of Change - [ ] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [x] Doc only (includes code sample changes) ## Verification - [x] `npx prek run --all-files` passes - [ ] `npm test` passes - [ ] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [x] Docs updated for user-facing behavior changes - [x] `make docs` builds without warnings (doc changes only) - [x] 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: Miyoung Choi <miyoungc@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes v0.0.39 * **New Features** * Host alias management commands for easier configuration * Sandbox GPU control options during onboarding * Update command with check and confirmation modes * **Documentation** * Enhanced Linux installer guidance with Docker and group membership handling * Expanded troubleshooting for permission and connectivity issues * Improved capability-dropping security documentation * Updated inference model switching commands * Brev environment-specific troubleshooting * **Improvements** * DGX Spark/Station express install flow * Windows Ollama relay and health-check enhancements * NVIDIA NIM preflight GPU reporting [](https://app.coderabbit.ai/change-stack/NVIDIA/NemoClaw/pull/3375) <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Adds the new
nemoclaw updatefeature end-to-end and integrates all work from Prompt A through Prompt F.This includes core update orchestration, CLI wiring, docs/tests, integration hardening, reviewer/auditor validation.
Changes
upgrade-sandboxes --autofollow-upnemoclaw updateunder Getting Started--checkand--autoflagsnemoclaw update.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Additional Linux-authoritative validation (fresh clone):
npm install --ignore-scriptscd nemoclaw && npm install --ignore-scripts && npm run build && cd ..npm run build:cli->BUILD_EXIT=0npm test->TEST_EXIT=0make check->CHECK_EXIT=0Test Files 143 passed | 2 skipped (145)Tests 2761 passed | 12 skipped (2773)AI Disclosure
Signed-off-by: Suryaansh Suryaansh.aa@gmail.com
Summary by CodeRabbit
New Features
nemoclaw updatecommand with--check(dry-run) and--auto(non-interactive) to upgrade the CLI and optionally synchronize sandboxes.Improvements
Documentation
nemoclaw updateusage and flags.Tests
Dependencies
Chores