Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4b7a4a2
refactor(cli): extract sandbox live state helpers
cv May 2, 2026
2ce87dd
refactor(cli): extract sandbox skill install action
cv May 2, 2026
4cd3cf3
refactor(cli): extract sandbox connect action
cv May 3, 2026
e9dd46e
refactor(cli): extract sandbox status action
cv May 3, 2026
aab6c86
refactor(cli): extract sandbox doctor action
cv May 3, 2026
8908521
refactor(cli): extract sandbox destroy action
cv May 3, 2026
56e4f05
refactor(cli): extract sandbox rebuild action
cv May 3, 2026
8bf1958
refactor(cli): extract upgrade sandboxes action
cv May 3, 2026
38eb84d
refactor(cli): remove runtime bridge
cv May 3, 2026
b2ad5da
refactor(cli): remove legacy dispatch fallbacks
cv May 3, 2026
edd2650
refactor(cli): expose explicit main entrypoint
cv May 3, 2026
a15da95
refactor(cli): add oclif examples for utility commands
cv May 3, 2026
4f57ebb
refactor(cli): validate logs flags with oclif
cv May 3, 2026
8b2d077
refactor(cli): improve sandbox diagnostic command metadata
cv May 3, 2026
a09cc51
refactor(cli): tighten policy and channel parser validation
cv May 3, 2026
75857dc
refactor(cli): improve snapshot command metadata
cv May 3, 2026
11c0676
refactor(cli): require skill install path in oclif
cv May 3, 2026
05f9eca
refactor(cli): add lifecycle confirmation flag aliases
cv May 3, 2026
4ebeae4
refactor(cli): split share into oclif subcommands
cv May 3, 2026
7d72437
Revert "refactor(cli): split share into oclif subcommands"
cv May 3, 2026
0ee5ca5
refactor(cli): split share into oclif subcommands
cv May 3, 2026
7a6712d
merge(main): reconcile share subcommands
cv May 5, 2026
3cb1dd8
Merge branch 'main' into refactor/oclif-ux-share-subcommands
prekshivyas May 5, 2026
b492934
fix(cli): keep share help public
cv May 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/command-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const COMMANDS: readonly CommandDef[] = [
{
usage: "nemoclaw <name> rebuild",
description: "Upgrade sandbox to current agent version",
flags: "(--yes to skip prompt)",
flags: "[--yes|-y|--force] [--verbose|-v]",
group: "Sandbox Management",
scope: "sandbox",
},
Expand All @@ -189,7 +189,7 @@ export const COMMANDS: readonly CommandDef[] = [
{
usage: "nemoclaw <name> destroy",
description: "Stop NIM + delete sandbox",
flags: "(--yes to skip prompt)",
flags: "[--yes|-y|--force]",
group: "Sandbox Management",
scope: "sandbox",
},
Expand Down
5 changes: 3 additions & 2 deletions src/lib/destroy-cli-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ export default class DestroyCliCommand extends Command {
static strict = true;
static summary = "Stop NIM and delete sandbox";
static description = "Destroy a sandbox and remove its local registry entry.";
static usage = ["<name> destroy [--yes|--force]"];
static usage = ["<name> destroy [--yes|-y|--force]"];
static examples = ["<%= config.bin %> alpha destroy", "<%= config.bin %> alpha destroy --yes"];
static args = {
sandboxName: Args.string({ name: "sandbox", description: "Sandbox name", required: true }),
};
static flags = {
help: Flags.help({ char: "h" }),
yes: Flags.boolean({ description: "Skip the confirmation prompt" }),
yes: Flags.boolean({ char: "y", description: "Skip the confirmation prompt" }),
force: Flags.boolean({ description: "Skip the confirmation prompt" }),
};

Expand Down
35 changes: 31 additions & 4 deletions src/lib/legacy-oclif-dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function resolveSandboxOclifDispatch(
if (hasHelpFlag(actionArgs)) return { kind: "help", usage: "policy-list" };
return { kind: "oclif", commandId: "sandbox:policy-list", args: [sandboxName, ...actionArgs] };
case "destroy":
if (hasHelpFlag(actionArgs)) return { kind: "help", usage: "destroy [--yes|--force]" };
if (hasHelpFlag(actionArgs)) return { kind: "help", usage: "destroy [--yes|-y|--force]" };
return { kind: "oclif", commandId: "sandbox:destroy", args: [sandboxName, ...actionArgs] };
case "gateway-token":
if (hasHelpFlag(actionArgs)) return { kind: "help", usage: "gateway-token [--quiet|-q]" };
Expand All @@ -141,13 +141,40 @@ export function resolveSandboxOclifDispatch(
return { kind: "oclif", commandId: "sandbox:skill", args: [sandboxName, ...actionArgs] };
}
case "rebuild":
if (hasHelpFlag(actionArgs)) return { kind: "help", usage: "rebuild [--yes|--force] [--verbose|-v]" };
if (hasHelpFlag(actionArgs)) return { kind: "help", usage: "rebuild [--yes|-y|--force] [--verbose|-v]" };
return { kind: "oclif", commandId: "sandbox:rebuild", args: [sandboxName, ...actionArgs] };
case "recover":
if (hasHelpFlag(actionArgs)) return { kind: "help", usage: "recover" };
return { kind: "oclif", commandId: "sandbox:recover", args: [sandboxName, ...actionArgs] };
case "share":
return { kind: "oclif", commandId: "share", args: [sandboxName, ...actionArgs] };
case "share": {
const shareSub = actionArgs[0];
const shareArgs = actionArgs.slice(1);
if (shareSub === "--help" || shareSub === "-h") {
return { kind: "help", usage: "share <mount|unmount|status>" };
}
if (!shareSub) {
return { kind: "oclif", commandId: "sandbox:share", args: [sandboxName] };
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
if (shareSub === "mount") {
if (hasHelpFlag(shareArgs)) {
return { kind: "help", usage: "share mount [sandbox-path] [local-mount-point]" };
}
return { kind: "oclif", commandId: "sandbox:share:mount", args: [sandboxName, ...shareArgs] };
}
if (shareSub === "unmount") {
if (hasHelpFlag(shareArgs)) {
return { kind: "help", usage: "share unmount [local-mount-point]" };
}
return { kind: "oclif", commandId: "sandbox:share:unmount", args: [sandboxName, ...shareArgs] };
}
if (shareSub === "status") {
if (hasHelpFlag(shareArgs)) {
return { kind: "help", usage: "share status [local-mount-point]" };
}
return { kind: "oclif", commandId: "sandbox:share:status", args: [sandboxName, ...shareArgs] };
}
return { kind: "oclif", commandId: "sandbox:share", args: [sandboxName, ...actionArgs] };
}
case "snapshot": {
const snapshotSub = actionArgs[0];
const snapshotArgs = actionArgs.slice(1);
Expand Down
8 changes: 4 additions & 4 deletions src/lib/maintenance-cli-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class UpgradeSandboxesCommand extends Command {
static strict = true;
static summary = "Detect and rebuild stale sandboxes";
static description = "Detect stale sandboxes and optionally rebuild them.";
static usage = ["upgrade-sandboxes [--check] [--auto] [--yes]"];
static usage = ["upgrade-sandboxes [--check] [--auto] [--yes|-y]"];
static examples = [
"<%= config.bin %> upgrade-sandboxes --check",
"<%= config.bin %> upgrade-sandboxes --auto --yes",
Expand All @@ -42,7 +42,7 @@ export class UpgradeSandboxesCommand extends Command {
help: Flags.help({ char: "h" }),
check: Flags.boolean({ description: "Only check whether sandboxes need upgrading" }),
auto: Flags.boolean({ description: "Automatically rebuild running stale sandboxes" }),
yes: Flags.boolean({ description: "Skip confirmation prompts" }),
yes: Flags.boolean({ char: "y", description: "Skip confirmation prompts" }),
};

public async run(): Promise<void> {
Expand All @@ -60,12 +60,12 @@ export class GarbageCollectImagesCommand extends Command {
static strict = true;
static summary = "Remove orphaned sandbox Docker images";
static description = "Remove sandbox Docker images that are not referenced by registered sandboxes.";
static usage = ["gc [--dry-run] [--yes|--force]"];
static usage = ["gc [--dry-run] [--yes|-y|--force]"];
static examples = ["<%= config.bin %> gc --dry-run", "<%= config.bin %> gc --yes"];
static flags = {
help: Flags.help({ char: "h" }),
"dry-run": Flags.boolean({ description: "Show images that would be removed without deleting" }),
yes: Flags.boolean({ description: "Skip the confirmation prompt" }),
yes: Flags.boolean({ char: "y", description: "Skip the confirmation prompt" }),
force: Flags.boolean({ description: "Skip the confirmation prompt" }),
};

Expand Down
11 changes: 9 additions & 2 deletions src/lib/oclif-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ import {
ShieldsStatusCommand,
ShieldsUpCommand,
} from "./shields-cli-commands";
import ShareCommand from "./share-command";
import ShareCommand, {
ShareMountCommand,
ShareStatusCommand,
ShareUnmountCommand,
} from "./share-command";
import SkillInstallCliCommand, { SkillCliCommand } from "./skill-install-cli-command";
import {
SnapshotCommand,
Expand Down Expand Up @@ -90,6 +94,10 @@ export default {
"sandbox:policy-remove": PolicyRemoveCommand,
"sandbox:rebuild": RebuildCliCommand,
"sandbox:recover": RecoverCliCommand,
"sandbox:share": ShareCommand,
"sandbox:share:mount": ShareMountCommand,
"sandbox:share:status": ShareStatusCommand,
"sandbox:share:unmount": ShareUnmountCommand,
"sandbox:shields:down": ShieldsDownCommand,
"sandbox:shields:status": ShieldsStatusCommand,
"sandbox:shields:up": ShieldsUpCommand,
Expand All @@ -102,7 +110,6 @@ export default {
"sandbox:status": SandboxStatusCommand,
setup: SetupCliCommand,
"setup-spark": SetupSparkCliCommand,
share: ShareCommand,
status: StatusCommand,
start: DeprecatedStartCommand,
stop: DeprecatedStopCommand,
Expand Down
8 changes: 6 additions & 2 deletions src/lib/rebuild-cli-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ export default class RebuildCliCommand extends Command {
static strict = true;
static summary = "Upgrade sandbox to current agent version";
static description = "Back up, recreate, and restore a sandbox using the current agent image.";
static usage = ["<name> rebuild [--yes|--force] [--verbose|-v]"];
static usage = ["<name> rebuild [--yes|-y|--force] [--verbose|-v]"];
static examples = [
"<%= config.bin %> alpha rebuild",
"<%= config.bin %> alpha rebuild --yes --verbose",
];
static args = {
sandboxName: Args.string({ name: "sandbox", description: "Sandbox name", required: true }),
};
static flags = {
help: Flags.help({ char: "h" }),
yes: Flags.boolean({ description: "Skip the confirmation prompt" }),
yes: Flags.boolean({ char: "y", description: "Skip the confirmation prompt" }),
force: Flags.boolean({ description: "Skip the confirmation prompt" }),
verbose: Flags.boolean({ char: "v", description: "Show verbose rebuild diagnostics" }),
};
Expand Down
30 changes: 9 additions & 21 deletions src/lib/share-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ vi.mock("child_process", () => ({
spawnSync: spawnSyncMock,
}));

import ShareCommand, {
import {
defaultShareMountDir,
isMountPoint,
resolveLinuxUnmount,
runShareMount,
runShareStatus,
} from "./share-command";
import type { ShareCommandDeps } from "./share-command-deps";

Expand Down Expand Up @@ -167,14 +169,7 @@ describe("ShareCommand mount/status actions", () => {
return { status: 1, stdout: "", stderr: `unexpected ${cmd} ${args.join(" ")}` };
});

await (ShareCommand.prototype as any).mount.call(
{},
"alpha",
["/workspace", localMount],
deps,
"",
"",
);
await runShareMount({ sandboxName: "alpha", remotePath: "/workspace", localMount }, deps);

expect(deps.ensureLive).toHaveBeenCalledWith("alpha");
expect(deps.getSshConfig).toHaveBeenCalledWith("alpha");
Expand Down Expand Up @@ -203,9 +198,9 @@ describe("ShareCommand mount/status actions", () => {
return { status: 1, stdout: "", stderr: "" };
});

await expect(
(ShareCommand.prototype as any).mount.call({}, "alpha", [], deps, "", ""),
).rejects.toThrow("process.exit:1");
await expect(runShareMount({ sandboxName: "alpha" }, deps)).rejects.toThrow(
"process.exit:1",
);

expect(deps.ensureLive).not.toHaveBeenCalled();
expect(errorSpy.mock.calls.map((call: unknown[]) => String(call[0])).join("\n")).toContain(
Expand All @@ -227,14 +222,7 @@ describe("ShareCommand mount/status actions", () => {
});

await expect(
(ShareCommand.prototype as any).mount.call(
{},
"alpha",
["/sandbox", localMount],
deps,
"",
"",
),
runShareMount({ sandboxName: "alpha", remotePath: "/sandbox", localMount }, deps),
).rejects.toThrow("process.exit:1");

const stderr = errorSpy.mock.calls.map((call: unknown[]) => String(call[0])).join("\n");
Expand All @@ -254,7 +242,7 @@ describe("ShareCommand mount/status actions", () => {
return { status: 1, stdout: "", stderr: "" };
});

(ShareCommand.prototype as any).status.call({}, "alpha", [mountDir], "", "");
runShareStatus({ sandboxName: "alpha", localMount: mountDir }, makeDeps());

expect(logSpy.mock.calls.map((call: unknown[]) => String(call[0])).join("\n")).toContain(
`Mounted at ${mountDir}`,
Expand Down
Loading
Loading