feat(cli): add --json flag to nemoclaw list#182
Conversation
|
Hey @dumko2001, a --json flag for would be super useful for scripting and automation. Main has moved forward a lot though — mind rebasing so we can evaluate this with the latest code? |
06a13c6 to
eee0cc3
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
Changes
Sequence Diagram(s)sequenceDiagram
participant User as "User (CLI)"
participant Nemoclaw as "bin/nemoclaw (list cmd)"
participant Registry as "Registry API"
participant Console as "Stdout / Exit"
User->>Nemoclaw: Run `nemoclaw list` with args
Nemoclaw->>Nemoclaw: Validate args against allowlist (--json,--help,-h)
alt invalid args
Nemoclaw->>Console: Print error + usage
Nemoclaw->>Console: Exit non-zero
else help requested
Nemoclaw->>Console: Print list-specific help
Nemoclaw->>Console: Exit 0
else --json present
Nemoclaw->>Registry: Fetch { sandboxes, defaultSandbox }
Registry-->>Nemoclaw: Return data
Nemoclaw->>Console: Print pretty JSON
Nemoclaw->>Console: Exit 0
else no flags
Nemoclaw->>Registry: Fetch sandboxes (existing flow)
Registry-->>Nemoclaw: Return data
Nemoclaw->>Console: Print human-readable list
Nemoclaw->>Console: Exit 0
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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.
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 `@bin/nemoclaw.js`:
- Around line 252-259: The CLI's new --json flag in listSandboxes is not
documented in the help output; update the CLI help text that prints the
"nemoclaw list" usage (the same help generator shown by `nemoclaw help`) to
include the --json option and a short description (e.g., "Output list as JSON");
ensure the help entry references the --json flag and matches the behavior
implemented in listSandboxes so users can discover the flag.
- Around line 252-259: The listSandboxes function currently ignores any flags
other than "--json", which can hide typos; update listSandboxes to validate
args: parse args and allow only the known flag "--json" (and optionally "--help"
if desired), and if any unknown flag is present log an error or throw (e.g., use
console.error and process.exit(1)) so the CLI fails fast; locate the function
listSandboxes and add a validation step that iterates args, accepts only the
allowed flags, and rejects everything else before calling
registry.listSandboxes() or printing JSON.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5a0115b8-5aff-48b0-a294-bc7034dbbad5
📒 Files selected for processing (1)
bin/nemoclaw.js
eee0cc3 to
97c33ef
Compare
|
@cv rebased |
…ifecycle cleanup (NVIDIA#182) * fix(security): add SSH session token expiry, connection limits, and lifecycle cleanup Closes NVIDIA#22 SSH session tokens previously had no TTL and remained valid indefinitely. This adds configurable token expiry (default 24h), per-token (10) and per-sandbox (20) concurrent connection limits, session cleanup on sandbox deletion, and a background reaper for expired/revoked sessions. * fix(security): lower per-token concurrent connection limit from 10 to 3 --------- Co-authored-by: John Myers <johntmyers@users.noreply.github.com>
|
Thanks for this. A new PR adding |
## Summary This adds machine-readable `nemoclaw list --json` output while preserving the existing human-readable list view. It extracts structured inventory generation from the list renderer so future CLI work can reuse the same inventory path. This carries forward the earlier `list --json` proposal from #182 by @dumko2001 (Sidharth Rajmohan). ## Changes - Add `getSandboxInventory()` and `renderSandboxInventoryText()` in `src/lib/inventory-commands.ts` so the sandbox inventory can be reused for both text and JSON output. - Update `src/nemoclaw.ts` so `nemoclaw list` accepts `--json`, emits pretty JSON to stdout, and rejects unsupported `list` flags with list-specific usage guidance. - Add tests in `src/lib/inventory-commands.test.ts` and `test/cli.test.ts` for empty and populated JSON output plus invalid `list` arguments. - Update `docs/reference/commands.md` and regenerate `.agents/skills/nemoclaw-user-reference/references/commands.md` for `nemoclaw list --json`. ## Type of Change - [ ] Code change (feature, bug fix, or refactor) - [x] 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 - [x] 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) ## AI Disclosure - [x] AI-assisted — tool: OpenAI Codex --- Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added `--json` flag to `nemoclaw list` command for machine-readable output containing schema version, default sandbox, recovery metadata, and sandbox inventory. * Added `--help`/`-h` support for list command. * **Documentation** * Updated command documentation with new `--json` flag specification and usage examples. * **Tests** * Added comprehensive test coverage for JSON output and argument validation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Rationale
Users and automated tools need a way to list sandboxes in a structured, machine-readable format for integration and scripting.
Changes
Added a
--jsonflag to thenemoclaw listcommand that outputs the sandbox registry and default sandbox as a JSON object.Verification Results
npm test.Leading Standards
This PR follows the project's 'First Principles' approach, prioritizing deterministic behavior and zero-trust security defaults.
Summary by CodeRabbit
New Features
listcommand now supports a--jsonflag to output sandbox information as pretty-formatted JSON.--help/-hnow shows list-specific usage and options.Bug Fixes