feat(cli): add --json output for list, status, and policy-list commands#1475
feat(cli): add --json output for list, status, and policy-list commands#1475ac12644 wants to merge 2 commits intoNVIDIA:mainfrom
Conversation
Add a --json flag to three CLI commands for machine-readable output: - nemoclaw list --json - nemoclaw <name> status --json - nemoclaw <name> policy-list --json JSON mode reads directly from the local registry without requiring a live OpenShell gateway, making it safe for scripting and CI pipelines. Fixes NVIDIA#753 Signed-off-by: Abhishek Chauhan <ac12644@gmail.com>
📝 WalkthroughWalkthroughThis PR adds Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 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)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
bin/nemoclaw.js (1)
1486-1517:⚠️ Potential issue | 🟠 MajorAdd missing
nemoclaw status --jsonsupport to match the stated acceptance scope.The global
statuscommand path still ignores flags (showStatus()is called withoutargs), sonemoclaw status --jsonis not implemented even though it is in the linked objective scope.Suggested patch
-function showStatus() { +function showStatus(args = []) { + const jsonMode = args.includes("--json"); + // Show sandbox registry const { sandboxes, defaultSandbox } = registry.listSandboxes(); + if (jsonMode) { + // Keep this schema stable for automation. + console.log( + JSON.stringify( + { + sandboxes: sandboxes.map((sb) => ({ + name: sb.name, + default: sb.name === defaultSandbox, + model: sb.model || null, + provider: sb.provider || null, + gpuEnabled: sb.gpuEnabled || false, + policies: sb.policies || [], + createdAt: sb.createdAt || null, + })), + defaultSandbox, + }, + null, + 2, + ), + ); + return; + } + if (sandboxes.length > 0) { const live = parseGatewayInference( captureOpenshell(["inference", "get"], { ignoreError: true }).output, @@ case "status": - showStatus(); + showStatus(args); break;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bin/nemoclaw.js` around lines 1486 - 1517, The global "status" branch ignores CLI flags because it calls showStatus() with no arguments; update the switch case to pass the parsed args (call showStatus(args)) and ensure the showStatus function signature/handler accepts and respects flags like --json so `nemoclaw status --json` works; locate the GLOBAL_COMMANDS switch, the cmd variable handling, and the showStatus function to make the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@bin/nemoclaw.js`:
- Around line 1486-1517: The global "status" branch ignores CLI flags because it
calls showStatus() with no arguments; update the switch case to pass the parsed
args (call showStatus(args)) and ensure the showStatus function
signature/handler accepts and respects flags like --json so `nemoclaw status
--json` works; locate the GLOBAL_COMMANDS switch, the cmd variable handling, and
the showStatus function to make the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ac1b1681-baf8-4170-a683-eb8d18c0ae86
📒 Files selected for processing (2)
bin/nemoclaw.jstest/json-output.test.js
Summary
Add a
--jsonflag to three CLI commands for machine-readable output, enabling scripting and CI integration.nemoclaw list --jsonnemoclaw <name> status --jsonnemoclaw <name> policy-list --jsonJSON mode reads directly from the local registry without requiring a live OpenShell gateway, making it safe for offline scripting.
Example
Test plan
test/json-output.test.jscovering all three commandsnemoclaw list --json | jq ...)--jsonis omittedFixes #753
Summary by CodeRabbit
New Features
--jsonflag tolist,status, andpolicy-listcommands for machine-readable JSON output, enabling integration with scripts and external tools.Tests