Skip to content

feat(mocactl): sbx help opens with what an sbx sandbox is, and lists commands in the order they are used - #871

Merged
webchang merged 4 commits into
rossoctl:mainfrom
webchang:pr/i599-sbx-help
Nov 18, 2026
Merged

webchang merged 4 commits into
rossoctl:mainfrom
webchang:pr/i599-sbx-help

Conversation

@webchang

Copy link
Copy Markdown
Member

Closes #599

What changed and why

  • mocactl sbx --help and a bare mocactl sbx now open with what an sbx sandbox is (SBX_ABOUT in packages/mocactl/src/sbx/cli.ts, printed before the usage (the sandbox service, SBX0): line). It is written in the issue's terms and matches what the commands do:

    • An sbx sandbox is a copy of a local git repository on the sandbox service, where your coding agent works.
    • sbx up copies the working tree into /workspace and 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.
    • Your source files stay as they are, apart from the agent configuration up adds.
    • The copy is not kept in sync: sbx push sends later local edits, and sbx pull --apply applies the agent's edits here as a patch.
    • /workspace is kept between commands, and the sandbox ends after a period without use (7 days by default).
    • It is not the sandbox a bare mocactl session's tools run in (that one is on the server at SH_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 --help and a bare mocactl 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 up and pull among the template commands:

    • a repository's sandbox: login, up, claude, codex, mcp, run, put, pull, push, ls, doctor, rm, logout (pull comes before push because push is refused while the agent's changes have not been pulled);
    • a sandbox by hand: create, get, mode, reset, proc …, token, env, egress;
    • credentials …;
    • templates: templates, quota, policy, hosts, templates create/build/show/follow/cancel/tag/untag/edit/activate/deactivate/retire;
    • admins only: 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 --help line for sbx now names the workflow (login, up, pull, rm) and calls it a remote copy of a repository, instead of listing login, create, ls, rm, token, env.

  • deploy/sbx/smoke.sh used to check that the first line of sbx --help is the usage line, so it could tell whether a mocactl has sbx. It now looks for that exact line anywhere in the output. An older mocactl that prints the line first still passes, and a mocactl without sbx still fails. The mock in deploy/sbx/tests/smoke.test.sh now 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, that up adds the agent configuration, that the copy is not kept in sync (push), how long a sandbox lasts, and that it is not a bare mocactl session's sandbox. The user guide and deploy/sbx/RUNBOOK.md both quoted the help's first line, and both now describe what the help opens with.

Tests

  • New tests in 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 and SH_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.
  • Before the fix (src/sbx/cli.ts from main), the definition test and the order test fail: expected false to be true, and expected [ '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 with expected 'sbx: unknown command \'nope\'\nAn sbx…' not to contain 'An sbx sandbox is'. With the fix, all three pass.
  • sbx-cli.test.ts and cli.test.ts after the review changes: 148/148 passed.
  • @moca/mocactl suite with --minWorkers=1 --maxWorkers=2 on a heavily loaded machine: 2025 passed, 49 failed. Every failure was a timeout in app.test.tsx, sbx-doctor, sbx-push, sbx-record, sbx-templates, sbx-up-cortex or sbx-up (5 s test timeout, or a 1.5 s waitFor). Rerun on their own:
    • app.test.tsx and sbx-up-cortex.test.ts: all passed;
    • the other five with --testTimeout=60000: 322/322 passed.
  • pnpm --filter @moca/mocactl typecheck: clean.
  • deploy/sbx/tests/smoke.test.sh: all passed, including a mocactl without sbx. shellcheck -S warning passes on both scripts.
  • prettier and python3 scripts/check-doc-links.py (0 broken links): clean.

Out of scope

  • The issue's wider point: a bare mocactl session'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

…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]>
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 17, 2026
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 clawgenti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@webchang webchang changed the title docs(mocactl): sbx help opens with what an sbx sandbox is, and lists commands in the order they are used feat(mocactl): sbx help opens with what an sbx sandbox is, and lists commands in the order they are used Nov 17, 2026

@clawgenti clawgenti left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 pdettori left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Comment thread docs/sbx/user-guide.md
(`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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@webchang
webchang merged commit f748ac8 into rossoctl:main Nov 18, 2026
17 checks passed
webchang added a commit that referenced this pull request Nov 18, 2026
…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]>
@pdettori pdettori added this to the v0.11.0 milestone Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: Better terminology around "sandbox"

4 participants