Commit 730f28f
authored
feat(onboard): add --name flag for explicit sandbox naming (#2591)
## Summary
`nemoclaw onboard` had no `--name` flag, so picking a sandbox name in
non-interactive or no-TTY runs required the undiscoverable
`NEMOCLAW_SANDBOX_NAME` env var, and `--from <Dockerfile>` without a TTY
silently fell back to the `my-assistant` default — clobbering the
default sandbox. This adds `--name <sandbox>`, plumbed through
`OnboardCommandOptions` and `OnboardOptions`. The flag wins over the env
var. When prompting is impossible (no TTY or `--non-interactive`) the
env var is now seeded into the same path the flag takes, so it actually
flows through to `createSandbox` instead of being dropped silently.
`--from` runs that cannot prompt and have no resolved name now error
cleanly. Both the flag and the env-var seed go through the same
`validateName` + reserved-name guard the interactive prompt enforces, so
a name like `status` is rejected before it can shadow a CLI command.
## Related Issues
Fixes #2543
Fixes #2534
## Changes
- `src/lib/onboard-command.ts`: parse `--name <sandbox>`, validate the
value, surface it on `OnboardCommandOptions.sandboxName`, list it in the
usage line.
- `src/lib/onboard.ts`: add `sandboxName` to `OnboardOptions`; lift
`RESERVED_SANDBOX_NAMES` out of `promptValidatedSandboxName` so the flag
and env-var paths share it; resolve the requested name early (flag, then
env var when prompting is impossible), validate once, and seed it into
the local `sandboxName` so `createSandbox` receives the override; reject
`--from` runs that cannot prompt and have no resolved name; teach
`getRequestedSandboxNameHint` / `getResumeSandboxConflict` /
`getResumeConfigConflicts` to prefer `opts.sandboxName` over the env
var; thread it through the resume-conflict caller. Re-check
`RESERVED_SANDBOX_NAMES` against the resumed `session?.sandboxName` so a
stale pre-PR session whose recorded name now collides with a CLI command
(e.g. `status`) is rejected before any sandbox operation runs.
- `src/lib/onboard-command.test.ts`: positive test for `--name` parsing
alongside `--from`, plus the missing-value and flag-as-value error
paths.
- `test/onboard.test.ts`: cover hint precedence (option over env) and
the resume conflict produced when `--name` diverges from the recorded
sandbox; static-source assertion that the resumed-session reserved-name
guard stays in place.
- `docs/reference/commands.md`: add `--name <sandbox>` to the `onboard`
usage line, document the flag with its precedence and reserved-name
semantics next to `--from`, and update the non-interactive `--from`
example to set `NEMOCLAW_SANDBOX_NAME` so the new no-prompt guard is
satisfied.
## Type of Change
- [x] 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)
- [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)
## AI Disclosure
- [x] AI-assisted — tool: Claude Code, Codex
---
Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Added a --name <sandbox> flag to specify sandbox names during
onboarding; explicit name now takes precedence over env var.
* **Bug Fixes**
* Onboarding fails early with clear messaging and exit code when a
sandbox name is required but missing or invalid (non-interactive/--from
cases); reserved names are rejected.
* **Tests**
* Added tests for parsing, help text, validation, precedence,
reserved-name checks, and non-interactive failure cases.
* **Documentation**
* Updated command reference to document the new flag, validation rules,
precedence, and failure behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Tinson Lai <tinsonl@nvidia.com>1 parent 771edeb commit 730f28f
5 files changed
Lines changed: 292 additions & 34 deletions
File tree
- docs/reference
- src/lib
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
| 174 | + | |
174 | 175 | | |
175 | 176 | | |
176 | | - | |
| 177 | + | |
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
181 | 195 | | |
182 | 196 | | |
183 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| |||
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| 94 | + | |
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
| |||
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
| 118 | + | |
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
| |||
138 | 142 | | |
139 | 143 | | |
140 | 144 | | |
| 145 | + | |
141 | 146 | | |
142 | 147 | | |
143 | 148 | | |
| |||
163 | 168 | | |
164 | 169 | | |
165 | 170 | | |
| 171 | + | |
166 | 172 | | |
167 | 173 | | |
168 | 174 | | |
| |||
187 | 193 | | |
188 | 194 | | |
189 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
190 | 260 | | |
191 | 261 | | |
192 | 262 | | |
| |||
260 | 330 | | |
261 | 331 | | |
262 | 332 | | |
| 333 | + | |
263 | 334 | | |
264 | 335 | | |
265 | 336 | | |
| |||
394 | 465 | | |
395 | 466 | | |
396 | 467 | | |
| 468 | + | |
397 | 469 | | |
398 | 470 | | |
399 | 471 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
84 | 98 | | |
85 | 99 | | |
86 | 100 | | |
| |||
141 | 155 | | |
142 | 156 | | |
143 | 157 | | |
| 158 | + | |
144 | 159 | | |
145 | 160 | | |
146 | 161 | | |
| |||
0 commit comments