Repository navigation
feat(mocactl): sbx help opens with what an sbx sandbox is, and lists commands in the order they are used - #871
Conversation
…mands in the order they are used `mocactl sbx --help` and a bare `mocactl sbx` now begin with a short paragraph: an sbx sandbox is a cloud copy of a local git repository where the coding agent works; `sbx up` copies the working tree and points the agents at the sandbox's tools, so their edits and commands run there, not on this machine; the copy is not kept in sync (`push` sends later local edits, `pull --apply` brings the agent's edits back as a patch); and it is not the sandbox a bare `mocactl` session's tools run in. The commands are now grouped, each group in the order a user reaches for them: login, up, claude, codex, mcp, run, put, pull, push, ls, doctor, rm, logout; then a sandbox by hand (create, get, mode, reset, proc, token, env, egress), credentials, templates, and the admins' commands. Every entry's text is unchanged, only moved. Since the usage line is no longer first, smoke.sh's check for a mocactl with sbx looks for that line anywhere in `sbx --help` (an older mocactl, which prints it first, still passes). The user guide and the runbook say what the help opens with; the user guide also says the copy is not kept in sync and is not a bare mocactl session's sandbox. Closes rossoctl#599 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
rossoctl#867 cut COMMAND --help from the usage text. Keep both: bare --help opens with what an sbx sandbox is, COMMAND --help shows that command's entries, and usageEntries now skips the group headings rossoctl#599 added (a line ending in ':' before a head, and the blank line before it), so they neither end the entries nor join one. Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Clear improvement to the sbx help: the definition-first opening, workflow-ordered groups, and the shared usage parser teaching all read the same way, and the three new tests pin definition, usage-error separation, and full command order (I cross-checked the test's ordered list against the SBX_USAGE groups — they match, including the dedup of repeated heads). The #ibm-bob anchor and the moved entries' links all resolve. Two suggestions below. No agent/IDE config files touched, no secrets, all commits signed off, CI green.
Author: webchang (MEMBER — maintainer)
Areas reviewed: TypeScript (mocactl CLI), docs, smoke scripts
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: passing
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| // `sbx COMMAND --help`: that command's syntax, not every command's (the words before `--`). | ||
| io.out((sbxCommandUsage(words) ?? SBX_USAGE) + '\n'); | ||
| // Bare `sbx --help` opens with what an sbx sandbox is (#599). | ||
| io.out((sbxCommandUsage(words) ?? `${SBX_ABOUT}\n\n${SBX_USAGE}`) + '\n'); |
There was a problem hiding this comment.
suggestion — the PR is typed docs(mocactl) but this is a behavior change, not a docs-only one: SBX_ABOUT now prints on --help and bare sbx (lines 808/812), and core/usage.ts changes the shared parser every command uses. A reviewer or changelog tooling filtering by the docs prefix would miss the runtime change. Consider retitling (e.g. feat(mocactl):) or splitting the code change out.
There was a problem hiding this comment.
Agreed: retitled to feat(mocactl):, since --help and bare sbx now print the definition and the shared usage parser changed.
| if (!line.startsWith(' ')) break; | ||
| const lines = usage.split('\n').slice(1); | ||
| const heading = (i: number): boolean => | ||
| lines[i]?.endsWith(':') === true && lines[i + 1]?.startsWith(head) === true; |
There was a problem hiding this comment.
suggestion — the heading heuristic (endsWith(':') followed by an indented head line) now applies to every usage string, not just sbx. A future non-indented note line that happens to end in `:" before an indented command (e.g. "see the commands below:") would be misparsed as a group heading and silently produce bogus entries. Consider a comment pinning the assumption, or gating the heading logic behind a flag the sbx usage passes.
There was a problem hiding this comment.
Pinned in cf2f41d: the comment now says the rule applies to every usage text, and that a note ending in : must not sit directly before a command line (notes go after the last command). Every usage text in the tree follows that today, and the per-command --help tests cover both mocactl and mocactl sbx.
Review follow-up: the group-heading rule applies to every usage text, so the comment now says what a usage text must not do (a note ending in ':' right before a command line) for the rule to hold. Refs rossoctl#599 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
There was a problem hiding this comment.
Summary
Reviewed the sbx help rework: the new SBX_ABOUT text, the usage-order command grouping, and the usageEntries heading heuristic, plus the smoke-test and docs updates that track them. The changes are internally consistent — the grep -qxF smoke-test migration covers both old and new outputs, and the new tests pin the about-text, its absence on usage errors, and the command order. One suggestion below on guarding the new parser heuristic; the rest is clean.
Author: webchang (MEMBER — maintainer)
Areas reviewed: TypeScript CLI, shell smoke test, docs
Agent/IDE config (.claude/.vscode): none
Commits: 3 commits, all signed-off: yes
CI status: passing
Generated by RepoMan github-pr-review@9672454 (https://github.com/rossoctl/agent-skills/blob/96724547c162978f58d845b9a8331a679bf39444/skills/github-pr-review/SKILL.md).
| lines[i]?.endsWith(':') === true && lines[i + 1]?.startsWith(head) === true; | ||
| for (const [i, line] of lines.entries()) { | ||
| if (!line.startsWith(' ')) { | ||
| if (heading(i) || (line === '' && heading(i + 1))) { |
There was a problem hiding this comment.
suggestion — The new heading heuristic (a non-indented line ending in : before a command line becomes a group heading) silently swallows a command from the parsed entries if a future usage-text edit puts a note line ending in : directly above a command. The constraint is documented in the doc comment, but nothing enforces it.
Suggested fix: add a test (or a dev-time assertion) that every mocactl sbx command appears in the parsed entries, so an edit that trips the constraint fails CI instead of quietly dropping a command from completions and COMMAND --help.
There was a problem hiding this comment.
Added in 59c4e7e: usage-coverage.test.ts checks that every command line of mocactl's and mocactl sbx's usage comes back from commandUsage for its own words, so an edit that ends the entries early or misreads a line fails CI. A third test inserts a note mid-list to show the check catches it.
Review follow-up: the entry parser's heading rule is a convention the usage texts must keep, so pin it. For mocactl's and mocactl sbx's usage, every command line must come back from commandUsage for its own words; a note that ended the entries early (shown by a test that inserts one) would drop the commands below it and fail this. Refs rossoctl#599 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
pdettori
left a comment
There was a problem hiding this comment.
Summary
The sbx help now opens with a definition that matches what the commands actually do. The workflow-ordered groups read well. The heading rule in the shared usage parser is now guarded by usage-coverage.test.ts for both mocactl and mocactl sbx, and that test has a negative case showing it catches a misplaced note. Earlier review points (title prefix, guarding the parser rule) are resolved. Three wording nits below; nothing blocking.
Verified locally at 59c4e7e: deploy/sbx/tests/smoke.test.sh under macOS /bin/bash 3.2.57 (35/35 ok, including the new ${help%%$'\n'*} expansion), and vitest on sbx-cli, usage-coverage and cli (166/166 passed).
Author: webchang (MEMBER — maintainer)
Areas reviewed: TypeScript (mocactl CLI, shared usage parser), shell (smoke.sh and its test), docs
Agent/IDE config (.claude/.vscode): none
Commits: 4 commits (1 merge), all signed off: yes
CI status: passing; deploy-scripts and deploy-scripts-bash32 still pending
Assisted-By: Claude Code
| agent does its work. \`mocactl sbx up\` copies the working tree into the sandbox's /workspace and | ||
| points Claude Code, OpenCode and IBM Bob, in this repository, at the sandbox's tools: their reads, | ||
| edits and commands then run in the sandbox service's VMs, not on this machine (Bob's local tools | ||
| stay available: it has no deny list). Your source files stay as they are, apart from the agent |
There was a problem hiding this comment.
nit: "Your source files stay as they are, apart from the agent configuration up adds" leaves out .sbx/sandbox.json, which up also writes. rm's own entry lists the two separately ("the agent configuration sbx up added, and .sbx/"). Suggest: "apart from the agent configuration and the .sbx/ binding up adds".
| (`mocactl sbx pull --apply`). | ||
| edits and tests your code there, in a copy of your repository at `/workspace`. (IBM Bob has no | ||
| deny list, so its local tools stay available: see [IBM Bob](#ibm-bob).) **Your laptop's source | ||
| files are untouched**, apart from the agent configuration `mocactl sbx up` adds, until you take the |
There was a problem hiding this comment.
nit: same omission as in SBX_ABOUT: "apart from the agent configuration mocactl sbx up adds" should also mention .sbx/sandbox.json.
| * local tools are said to stay. Not printed after a usage error, where it would only bury the error. | ||
| */ | ||
| export const SBX_ABOUT = `An sbx sandbox is a copy of a local git repository on the sandbox service, where your coding | ||
| agent does its work. \`mocactl sbx up\` copies the working tree into the sandbox's /workspace and |
There was a problem hiding this comment.
nit (optional): "copies the working tree into the sandbox's /workspace": .env*, *.pem, *.key and id_* are not copied unless --include-secrets is given. This is the paragraph a new user reads first, so it might be worth half a sentence; otherwise they may expect their .env to be in the sandbox.
| * configuration, and the agent's edits come back only through `pull`. Bob has no deny list, so its | ||
| * local tools are said to stay. Not printed after a usage error, where it would only bury the error. | ||
| */ | ||
| export const SBX_ABOUT = `An sbx sandbox is a copy of a local git repository on the sandbox service, where your coding |
There was a problem hiding this comment.
suggestion: This defines the sandbox by the up workflow, but a sandbox doesn't need a local repository. sbx create --template ID makes one, and run, put and proc use it by ID. Only up, push and pull need git. Consider defining the sandbox itself, with up as the common way in:
| export const SBX_ABOUT = `An sbx sandbox is a copy of a local git repository on the sandbox service, where your coding | |
| export const SBX_ABOUT = `An sbx sandbox is a workspace on the sandbox service, made from a template, where your coding |
Line 94 would then go on with something like "agent's commands run in isolated VMs. In a git repository, `mocactl sbx up` creates one and copies…". The same framing applies to cli.ts:62 ("a remote copy of a repository"), and the startsWith assertion in sbx-cli.test.ts would need updating.
There was a problem hiding this comment.
Agreed, thanks, and sorry this landed after the merge. Taken up in #877: the definition now opens with the sandbox itself, in your wording, then up in a git repository as the common way in, and ends with create --template ID for use without one; the mocactl sbx … row in mocactl --help no longer says "a remote copy of a repository", and the test follows.
…mmon way in Review follow-up to #871 (evaline-ju): the help defined a sandbox by the `up` workflow, as a copy of a local git repository, but a sandbox needs no repository: `sbx create --template ID` makes one, and `run`, `put` and `proc` use it by ID; only `up`, `push` and `pull` need git. The definition now opens with the sandbox itself (a workspace on the sandbox service, made from a template, where the agent's commands run in isolated VMs), then `up` in a git repository, and ends with `create` for use without one. The top-level `mocactl sbx …` line no longer says "a remote copy of a repository". The help test follows the new wording. Refs #599 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
Closes #599
What changed and why
mocactl sbx --helpand a baremocactl sbxnow open with what an sbx sandbox is (SBX_ABOUTinpackages/mocactl/src/sbx/cli.ts, printed before theusage (the sandbox service, SBX0):line). It is written in the issue's terms and matches what the commands do:sbx upcopies the working tree into/workspaceand points Claude Code, OpenCode and IBM Bob at the sandbox's tools, so their reads, edits and commands run in the service's VMs, not on this machine. Bob's local tools stay available, because Bob has no deny list.upadds.sbx pushsends later local edits, andsbx pull --applyapplies the agent's edits here as a patch./workspaceis kept between commands, and the sandbox ends after a period without use (7 days by default).mocactlsession's tools run in (that one is on the server atSH_CONTROL_PLANE_URL). This is the confusion the issue describes.Usage errors are unchanged: about 30 of them print the usage after the error, and they still show only the error and the usage. The definition is printed only for
--helpand a baremocactl sbx.The commands are grouped, and each group follows the order a user works in. I chose workflow order over alphabetical order because the everyday commands have a clear order and alphabetical order would bury
upandpullamong the template commands:login,up,claude,codex,mcp,run,put,pull,push,ls,doctor,rm,logout(pullcomes beforepushbecausepushis refused while the agent's changes have not been pulled);create,get,mode,reset,proc …,token,env,egress;credentials …;templates,quota,policy,hosts,templates create/build/show/follow/cancel/tag/untag/edit/activate/deactivate/retire;templates transfer,templates quota,admin subjects ….Every entry's text is unchanged. The entries were only moved, and all 28 command blocks are still there.
The top-level
mocactl --helpline forsbxnow names the workflow (login, up, pull, rm) and calls it a remote copy of a repository, instead of listinglogin, create, ls, rm, token, env.deploy/sbx/smoke.shused to check that the first line ofsbx --helpis the usage line, so it could tell whether amocactlhassbx. It now looks for that exact line anywhere in the output. An oldermocactlthat prints the line first still passes, and amocactlwithoutsbxstill fails. The mock indeploy/sbx/tests/smoke.test.shnow prints a paragraph before the usage line, as the real help does.In
docs/sbx/user-guide.md, §1 already defined the sandbox. It now also says that Bob's local tools stay available, thatupadds the agent configuration, that the copy is not kept in sync (push), how long a sandbox lasts, and that it is not a baremocactlsession's sandbox. The user guide anddeploy/sbx/RUNBOOK.mdboth quoted the help's first line, and both now describe what the help opens with.Tests
packages/mocactl/test/sbx-cli.test.ts:opens its usage with what an sbx sandbox is, on --help and bare (#599): both outputs start with the definition, and the text before the usage line contains the sentences about up, Bob, the agent configuration, the sync, push, pull, the lifetime andSH_CONTROL_PLANE_URL.keeps the definition out of a usage error, which shows the error and the usage (#599): covers an unknown command, an unknown option and a flag conflict.lists its commands in the order a user reaches for them, every one present (#599): pins the full ordered list of commands in the listing.src/sbx/cli.tsfrom main), the definition test and the order test fail:expected false to be true, andexpected [ 'login', 'logout', …(26) ] to deeply equal [ 'login', 'up', 'claude', …(25) ]. Against the first draft of this change, which printed the definition on every usage error, the usage-error test fails withexpected 'sbx: unknown command \'nope\'\nAn sbx…' not to contain 'An sbx sandbox is'. With the fix, all three pass.sbx-cli.test.tsandcli.test.tsafter the review changes: 148/148 passed.--minWorkers=1 --maxWorkers=2on a heavily loaded machine: 2025 passed, 49 failed. Every failure was a timeout inapp.test.tsx,sbx-doctor,sbx-push,sbx-record,sbx-templates,sbx-up-cortexorsbx-up(5 s test timeout, or a 1.5 swaitFor). Rerun on their own:app.test.tsxandsbx-up-cortex.test.ts: all passed;--testTimeout=60000: 322/322 passed.pnpm --filter @moca/mocactl typecheck: clean.deploy/sbx/tests/smoke.test.sh: all passed, includinga mocactl without sbx.shellcheck -S warningpasses on both scripts.prettierandpython3 scripts/check-doc-links.py(0 broken links): clean.Out of scope
mocactlsession's sandbox and the sbx sandbox share one word. This change explains the difference in the sbx help and the user guide. It does not rename either.Every commit is signed off (DCO).
Assisted-By: Claude Code