Skip to content

feat(cli): add --json output for list, status, and policy-list commands#1475

Open
ac12644 wants to merge 2 commits intoNVIDIA:mainfrom
ac12644:feat/json-output
Open

feat(cli): add --json output for list, status, and policy-list commands#1475
ac12644 wants to merge 2 commits intoNVIDIA:mainfrom
ac12644:feat/json-output

Conversation

@ac12644
Copy link
Copy Markdown

@ac12644 ac12644 commented Apr 4, 2026

Summary

Add a --json flag to three CLI commands for machine-readable output, enabling scripting and CI integration.

Command Output
nemoclaw list --json All sandboxes with default flag, model, provider, policies
nemoclaw <name> status --json Sandbox details with NIM health
nemoclaw <name> policy-list --json All presets with applied/unapplied status

JSON mode reads directly from the local registry without requiring a live OpenShell gateway, making it safe for offline scripting.

Example

$ nemoclaw list --json
{
  "sandboxes": [
    {
      "name": "my-assistant",
      "default": true,
      "model": "nvidia/nemotron-3-super-120b-a12b",
      "provider": "nvidia-nim",
      "gpuEnabled": false,
      "policies": ["pypi", "npm"]
    }
  ],
  "defaultSandbox": "my-assistant"
}

$ nemoclaw my-assistant status --json | jq .nim.running
false

Test plan

  • 5 new tests in test/json-output.test.js covering all three commands
  • Full test suite passes (941 tests, 0 failures)
  • Manually verified JSON output with multi-sandbox registry
  • Verified piping works for scripting (nemoclaw list --json | jq ...)
  • Existing human-readable output unchanged when --json is omitted

Fixes #753

Summary by CodeRabbit

  • New Features

    • Added --json output for list, status, and policy-list commands for machine-readable results.
  • Tests

    • Added end-to-end tests validating JSON output structure and help text.
  • Documentation

    • Updated help text for list, status, and policy-list to document the optional --json flag.
  • Chores

    • Added local configuration for a docs server.

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>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 4, 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: 0543bf08-504c-405a-ae27-b55549e6c5cd

📥 Commits

Reviewing files that changed from the base of the PR and between 7d8f116 and d8108e3.

⛔ Files ignored due to path filters (1)
  • firebase-debug.log is excluded by !**/*.log
📒 Files selected for processing (2)
  • .mcp.json
  • bin/nemoclaw.js
✅ Files skipped from review due to trivial changes (1)
  • .mcp.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • bin/nemoclaw.js

📝 Walkthrough

Walkthrough

Adds a --json flag to the CLI for list, <name> status, and <name> policy-list, makes those commands emit structured JSON when requested, updates dispatch and help text to pass args, and adds tests validating the JSON shapes and behavior.

Changes

Cohort / File(s) Summary
CLI JSON Output Support
bin/nemoclaw.js
Expanded listSandboxes, sandboxStatus, and sandboxPolicyList to accept args and a --json mode that emits structured JSON (e.g., sandboxes, defaultSandbox, nim, presets) and returns early; updated CLI dispatch to pass argument arrays and updated command help to document --json.
JSON Output Tests
test/json-output.test.js
New Vitest suite that runs bin/nemoclaw.js with isolated HOME, creates a fixture .nemoclaw/sandboxes.json, and asserts list --json, my-assistant status --json, and my-assistant policy-list --json return the expected JSON shapes and fields. Also checks help text includes --json.
MCP Config (dev tooling)
.mcp.json
Added a local MCP config entry nemoclaw-docs pointing to mcp-docs-server/index.js for a docs server process (dev tooling only).

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI as Nemoclaw CLI
  participant FS as Filesystem (sandboxes.json)
  participant Nim as nim module

  User->>CLI: run `nemoclaw list --json` / `nemoclaw <name> status --json` / `policy-list --json`
  CLI->>FS: read sandbox metadata (e.g., .nemoclaw/sandboxes.json)
  alt status needs nim info
    CLI->>Nim: nimStatusByName or nimStatus(sandboxName)
    Nim-->>CLI: nim status (running/healthy/container)
  end
  CLI-->>User: emit JSON object (sandboxes / defaultSandbox / nim / presets / applied)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through flags and found a prize so fine,
--json for sandboxes, neat data in line.
Machines clap their paws, parsers hum with glee,
A rabbit waves a carrot — structured output, whee! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The PR implements --json for three commands (list, per-sandbox status, policy-list) but issue #753 also requires --json for the global 'nemoclaw status' command, which is not explicitly addressed in the changes. Clarify whether the global 'nemoclaw status' command requires --json support per issue #753, or confirm that it was out of scope for this PR and address it separately.
Out of Scope Changes check ❓ Inconclusive The .mcp.json file addition defining an MCP server configuration is not clearly related to the stated PR objective of adding --json output to CLI commands. Explain the purpose of .mcp.json changes and how it relates to the CLI --json feature, or remove it if it is unrelated work.
✅ 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 accurately describes the main change: adding --json output support to three CLI commands (list, status, and policy-list), which is the primary focus of this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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 | 🟠 Major

Add missing nemoclaw status --json support to match the stated acceptance scope.

The global status command path still ignores flags (showStatus() is called without args), so nemoclaw status --json is 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

📥 Commits

Reviewing files that changed from the base of the PR and between eaef339 and 7d8f116.

📒 Files selected for processing (2)
  • bin/nemoclaw.js
  • test/json-output.test.js

@wscurran wscurran added NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI). enhancement: feature Use this label to identify requests for new capabilities in NemoClaw. labels Apr 6, 2026
@wscurran
Copy link
Copy Markdown
Contributor

wscurran commented Apr 6, 2026

✨ Thanks for submitting this pull request, which proposes a way to enhance the nemoclaw list, status, and policy-list commands with a --json flag for machine-readable output.

@ac12644 ac12644 force-pushed the feat/json-output branch from b0843b7 to d8108e3 Compare April 7, 2026 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement: feature Use this label to identify requests for new capabilities in NemoClaw. NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): add --json output for list and status commands

2 participants