Skip to content

chore: add Prettier formatting for root-level JS files#1200

Merged
cv merged 2 commits intomainfrom
chore/prettier-root-js
Mar 31, 2026
Merged

chore: add Prettier formatting for root-level JS files#1200
cv merged 2 commits intomainfrom
chore/prettier-root-js

Conversation

@cv
Copy link
Copy Markdown
Contributor

@cv cv commented Mar 31, 2026

Summary

Extends the existing Prettier setup (which only covered nemoclaw/src/**/*.ts) to also format the root-level bin/ and test/ JavaScript files.

Changes

File What
.prettierrc New root config — matches the nemoclaw/ plugin style (double quotes, semicolons, 100-char print width, trailing commas)
.prettierignore Ignores node_modules/, dist/, coverage/, blueprint YAML, built docs, and .md files
package.json Added prettier devDependency, format and format:check scripts
.pre-commit-config.yaml Added prettier-js hook at priority 5 for bin/ and test/ JS files
Makefile make format now includes a format-cli subtarget
43 JS files Reformatted to match project style

Validation

  • npx prettier --check 'bin/**/*.js' 'test/**/*.js' — ✅ all clean
  • npm test — ✅ 677 tests pass, 3 skipped
  • All pre-commit hooks pass (including new Prettier (JavaScript) hook)
  • All pre-push hooks pass (tsc, coverage ratchet)

Summary by CodeRabbit

  • Chores

    • Added Prettier configuration and ignore rules
    • Added formatting npm scripts and integrated a CLI format target
    • Enabled a pre-commit hook to auto-run formatting
    • Applied consistent code formatting across the codebase
  • Tests

    • Reformatted many test files to follow the new formatting rules

- Add root .prettierrc matching nemoclaw/ plugin config
- Add .prettierignore for build artifacts and non-JS files
- Add prettier devDependency and format/format:check scripts to root package.json
- Add prettier-js pre-commit hook for bin/ and test/ JS files (priority 5)
- Extend Makefile format target with format-cli subtarget
- Format all 45 JS files in bin/ and test/
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6d5fc31c-05ee-41fa-a843-a5173fe56d8e

📥 Commits

Reviewing files that changed from the base of the PR and between 78a7b6e and 3495872.

📒 Files selected for processing (10)
  • .pre-commit-config.yaml
  • bin/lib/policies.js
  • bin/nemoclaw.js
  • test/cli.test.js
  • test/credentials.test.js
  • test/inference-config.test.js
  • test/local-inference.test.js
  • test/platform.test.js
  • test/policies.test.js
  • test/resolve-openshell.test.js
✅ Files skipped from review due to trivial changes (8)
  • test/resolve-openshell.test.js
  • test/credentials.test.js
  • test/platform.test.js
  • .pre-commit-config.yaml
  • test/local-inference.test.js
  • test/inference-config.test.js
  • test/policies.test.js
  • bin/nemoclaw.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • bin/lib/policies.js
  • test/cli.test.js

📝 Walkthrough

Walkthrough

Added Prettier formatting (config and ignore), a pre-commit hook, npm scripts, and a Makefile target; reformatted many JS source and test files (trailing commas, multiline expressions, try/catch formatting) with no behavioral changes.

Changes

Cohort / File(s) Summary
Prettier & hooks
/.prettierrc, /.prettierignore, /.pre-commit-config.yaml, package.json
Added Prettier config, ignore patterns, a prettier-js local pre-commit hook, prettier devDependency, and npm scripts format / format:check.
Build integration
Makefile
Added format-cli target (runs Prettier on bin/**/*.js and test/**/*.js) and made format depend on both format-ts and format-cli.
CLI & libs (formatting only)
bin/**/*.js
bin/lib/credentials.js, bin/lib/local-inference.js, bin/lib/nim.js, bin/lib/onboard-session.js, bin/lib/onboard.js, bin/lib/policies.js, bin/lib/preflight.js, bin/lib/registry.js, bin/lib/resolve-openshell.js, bin/lib/runner.js, bin/lib/runtime-recovery.js, bin/nemoclaw.js
Widespread syntactic reformatting: added trailing commas, expanded/collapsed multiline expressions, normalized try/catch blocks and argument object formatting. No logic or API signature changes.
Tests (formatting only)
test/**/*.test.js, test/e2e/brev-e2e.test.js
Applied Prettier-driven formatting across tests: trailing commas, multiline assertions, adjusted quoting/escaping in embedded shell stubs, and minor structural reflows. Test behavior and assertions preserved.
Runner / small edits
bin/lib/runner.js
Minor string/templating punctuation formatting change only.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested labels

CI/CD

Suggested reviewers

  • kjw3
  • ericksoa

Poem

🐰 Soft commas hop in tidy rows,
Lines wrapped neat where cold wind blows,
Prettier carrots, trimmed and bright,
Code snug, formatted through the night,
a tiny rabbit stamps delight 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: add Prettier formatting for root-level JS files' accurately summarizes the main change: adding Prettier configuration and formatting for JavaScript files in bin/ and test/ directories.

✏️ 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 chore/prettier-root-js

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
bin/nemoclaw.js (1)

253-255: Complexity suppressions should be paid down in these touched command paths.

These branch-heavy functions are still bypassing the complexity threshold; splitting state classification/recovery/message emission into helpers would align this file with repo limits.

As per coding guidelines "**/*.{js,ts,tsx}: Maintain cyclomatic complexity limit of 20 (target: ratchet down to 15) for all functions."

Also applies to: 438-439, 698-699

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/nemoclaw.js` around lines 253 - 255, The function
getReconciledSandboxGatewayState is bypassing the cyclomatic complexity limit
due to branching; split its responsibilities into smaller helpers: extract state
classification logic into a classifySandboxGatewayState(sandboxName, rawState)
helper, move recovery/repair branching into a
recoverSandboxGatewayState(classifiedState) helper, and move message emission
into emitSandboxGatewayStateEvents(recoveredState); update
getReconciledSandboxGatewayState to orchestrate these three calls and return the
final state. Apply the same decomposition pattern to the other branch-heavy
command functions in this file so each top-level command becomes a thin
orchestrator calling focused helpers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bin/lib/onboard.js`:
- Around line 2749-2759: The code assigns the entire result of
validateOpenAiLikeSelection(...) to preferredInferenceApi but
validateOpenAiLikeSelection returns an object { ok, api }; change the assignment
to destructure the result (e.g., const { ok, api } = await
validateOpenAiLikeSelection(...)), then set preferredInferenceApi = api only
when ok is true, and keep the existing break and continue selectionLoop
behavior; reference validateOpenAiLikeSelection, preferredInferenceApi,
selectionLoop, and the call parameters (remoteConfig.label, endpointUrl, model,
credentialEnv, retryMessage) to locate and fix the code.

---

Nitpick comments:
In `@bin/nemoclaw.js`:
- Around line 253-255: The function getReconciledSandboxGatewayState is
bypassing the cyclomatic complexity limit due to branching; split its
responsibilities into smaller helpers: extract state classification logic into a
classifySandboxGatewayState(sandboxName, rawState) helper, move recovery/repair
branching into a recoverSandboxGatewayState(classifiedState) helper, and move
message emission into emitSandboxGatewayStateEvents(recoveredState); update
getReconciledSandboxGatewayState to orchestrate these three calls and return the
final state. Apply the same decomposition pattern to the other branch-heavy
command functions in this file so each top-level command becomes a thin
orchestrator calling focused helpers.
🪄 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: Pro

Run ID: b65119ae-0499-4316-b0e2-041f7e4686ab

📥 Commits

Reviewing files that changed from the base of the PR and between 909a803 and 78a7b6e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (47)
  • .pre-commit-config.yaml
  • .prettierignore
  • .prettierrc
  • Makefile
  • bin/lib/credentials.js
  • bin/lib/local-inference.js
  • bin/lib/nim.js
  • bin/lib/onboard-session.js
  • bin/lib/onboard.js
  • bin/lib/policies.js
  • bin/lib/preflight.js
  • bin/lib/registry.js
  • bin/lib/resolve-openshell.js
  • bin/lib/runner.js
  • bin/lib/runtime-recovery.js
  • bin/nemoclaw.js
  • package.json
  • test/cli.test.js
  • test/credential-exposure.test.js
  • test/credentials.test.js
  • test/dns-proxy.test.js
  • test/e2e/brev-e2e.test.js
  • test/gateway-cleanup.test.js
  • test/inference-config.test.js
  • test/install-preflight.test.js
  • test/local-inference.test.js
  • test/nemoclaw-cli-recovery.test.js
  • test/nemoclaw-start.test.js
  • test/nim.test.js
  • test/onboard-readiness.test.js
  • test/onboard-selection.test.js
  • test/onboard-session.test.js
  • test/onboard.test.js
  • test/platform.test.js
  • test/policies.test.js
  • test/preflight.test.js
  • test/registry.test.js
  • test/runner.test.js
  • test/runtime-recovery.test.js
  • test/runtime-shell.test.js
  • test/security-binaries-restriction.test.js
  • test/security-c2-dockerfile-injection.test.js
  • test/security-c4-manifest-traversal.test.js
  • test/security-method-wildcards.test.js
  • test/service-env.test.js
  • test/setup-sandbox-name.test.js
  • test/uninstall.test.js

Comment on lines +2749 to +2759
preferredInferenceApi = await validateOpenAiLikeSelection(
remoteConfig.label,
endpointUrl,
model,
credentialEnv,
retryMessage,
remoteConfig.helpUrl
);
if (preferredInferenceApi) {
break;
}
continue selectionLoop;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Bedrock validation result is assigned incorrectly to preferredInferenceApi.

validateOpenAiLikeSelection(...) returns an object ({ ok, api }), but this block assigns the entire object to preferredInferenceApi and only checks truthiness. That can store a non-string object and corrupt downstream inference API config.

🐛 Suggested fix
-              preferredInferenceApi = await validateOpenAiLikeSelection(
+              const validation = await validateOpenAiLikeSelection(
                 remoteConfig.label,
                 endpointUrl,
                 model,
                 credentialEnv,
                 retryMessage,
               );
-              if (preferredInferenceApi) {
+              if (validation.ok) {
+                preferredInferenceApi = validation.api;
                 break;
               }
+              if (validation.retry === "credential" || validation.retry === "retry") {
+                continue;
+              }
               continue selectionLoop;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
preferredInferenceApi = await validateOpenAiLikeSelection(
remoteConfig.label,
endpointUrl,
model,
credentialEnv,
retryMessage,
remoteConfig.helpUrl
);
if (preferredInferenceApi) {
break;
}
continue selectionLoop;
const validation = await validateOpenAiLikeSelection(
remoteConfig.label,
endpointUrl,
model,
credentialEnv,
retryMessage,
);
if (validation.ok) {
preferredInferenceApi = validation.api;
break;
}
if (validation.retry === "credential" || validation.retry === "retry") {
continue;
}
continue selectionLoop;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/lib/onboard.js` around lines 2749 - 2759, The code assigns the entire
result of validateOpenAiLikeSelection(...) to preferredInferenceApi but
validateOpenAiLikeSelection returns an object { ok, api }; change the assignment
to destructure the result (e.g., const { ok, api } = await
validateOpenAiLikeSelection(...)), then set preferredInferenceApi = api only
when ok is true, and keep the existing break and continue selectionLoop
behavior; reference validateOpenAiLikeSelection, preferredInferenceApi,
selectionLoop, and the call parameters (remoteConfig.label, endpointUrl, model,
credentialEnv, retryMessage) to locate and fix the code.

@cv cv enabled auto-merge (squash) March 31, 2026 20:22
Copy link
Copy Markdown
Contributor

@ericksoa ericksoa left a comment

Choose a reason for hiding this comment

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

LGTM. Prettier config matches the existing plugin style, .prettierignore is sensible, and the pre-commit hook is wired in at the right priority. Thanks for extending formatting coverage to the CLI and test code.

@cv cv merged commit 82789a6 into main Mar 31, 2026
8 checks passed
@cv cv deleted the chore/prettier-root-js branch March 31, 2026 22:08
realkim93 added a commit to realkim93/NemoClaw that referenced this pull request Apr 1, 2026
Merge origin/main to resolve conflicts from recent changes:
- NVIDIA#1208 core blocker lifecycle regressions
- NVIDIA#1200 Prettier formatting
- NVIDIA#836 GPU VRAM checks

Jetson detection now leverages main's UNIFIED_MEMORY_GPU_TAGS
(Orin/Thor/Xavier) with added jetson flag and /proc/device-tree
fallback. All 118 tests pass.
realkim93 added a commit to realkim93/NemoClaw that referenced this pull request Apr 1, 2026
Merge origin/main into feat/jetson-orin-nano-support to resolve
conflicts from recent changes (NVIDIA#1208, NVIDIA#1200, NVIDIA#836, NVIDIA#1221, NVIDIA#1223).

Jetson detection now leverages main's UNIFIED_MEMORY_GPU_TAGS
with added jetson flag and /proc/device-tree fallback.

All 116 tests pass.
laitingsheng pushed a commit that referenced this pull request Apr 2, 2026
## Summary

Extends the existing Prettier setup (which only covered
`nemoclaw/src/**/*.ts`) to also format the root-level `bin/` and `test/`
JavaScript files.

## Changes

| File | What |
|------|------|
| `.prettierrc` | New root config — matches the `nemoclaw/` plugin style
(double quotes, semicolons, 100-char print width, trailing commas) |
| `.prettierignore` | Ignores `node_modules/`, `dist/`, `coverage/`,
blueprint YAML, built docs, and `.md` files |
| `package.json` | Added `prettier` devDependency, `format` and
`format:check` scripts |
| `.pre-commit-config.yaml` | Added `prettier-js` hook at priority 5 for
`bin/` and `test/` JS files |
| `Makefile` | `make format` now includes a `format-cli` subtarget |
| 43 JS files | Reformatted to match project style |

## Validation

- `npx prettier --check 'bin/**/*.js' 'test/**/*.js'` — ✅ all clean
- `npm test` — ✅ 677 tests pass, 3 skipped
- All pre-commit hooks pass (including new `Prettier (JavaScript)` hook)
- All pre-push hooks pass (tsc, coverage ratchet)

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

## Summary by CodeRabbit

## Release Notes

* **Chores**
  * Added standardized code formatting configuration with Prettier
  * Introduced npm scripts for code formatting and format verification
  * Enabled pre-commit hooks to automatically format code
  * Applied consistent formatting throughout the codebase

* **Tests**
  * Updated test files to adhere to new formatting standards

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
lakamsani pushed a commit to lakamsani/NemoClaw that referenced this pull request Apr 4, 2026
## Summary

Extends the existing Prettier setup (which only covered
`nemoclaw/src/**/*.ts`) to also format the root-level `bin/` and `test/`
JavaScript files.

## Changes

| File | What |
|------|------|
| `.prettierrc` | New root config — matches the `nemoclaw/` plugin style
(double quotes, semicolons, 100-char print width, trailing commas) |
| `.prettierignore` | Ignores `node_modules/`, `dist/`, `coverage/`,
blueprint YAML, built docs, and `.md` files |
| `package.json` | Added `prettier` devDependency, `format` and
`format:check` scripts |
| `.pre-commit-config.yaml` | Added `prettier-js` hook at priority 5 for
`bin/` and `test/` JS files |
| `Makefile` | `make format` now includes a `format-cli` subtarget |
| 43 JS files | Reformatted to match project style |

## Validation

- `npx prettier --check 'bin/**/*.js' 'test/**/*.js'` — ✅ all clean
- `npm test` — ✅ 677 tests pass, 3 skipped
- All pre-commit hooks pass (including new `Prettier (JavaScript)` hook)
- All pre-push hooks pass (tsc, coverage ratchet)

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

## Summary by CodeRabbit

## Release Notes

* **Chores**
  * Added standardized code formatting configuration with Prettier
  * Introduced npm scripts for code formatting and format verification
  * Enabled pre-commit hooks to automatically format code
  * Applied consistent formatting throughout the codebase

* **Tests**
  * Updated test files to adhere to new formatting standards

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants