Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
116111c
refactor(cli): harden oclif bridge
cv Apr 30, 2026
5e997cb
test(cli): relax uninstall helper timeouts
cv Apr 30, 2026
88cd958
refactor(cli): migrate status and tunnel commands to oclif
cv Apr 30, 2026
3f748d6
refactor(cli): migrate debug uninstall and gateway-token to oclif
cv Apr 30, 2026
0bc877a
refactor(cli): migrate credentials commands to oclif
cv Apr 30, 2026
3fd15fc
refactor(cli): migrate sandbox inspection commands to oclif
cv Apr 30, 2026
81c62bb
refactor(cli): migrate maintenance commands to oclif
cv Apr 30, 2026
7d6a6fb
refactor(cli): migrate sandbox logs command to oclif
cv May 1, 2026
3f17a4f
refactor(cli): migrate skill install command to oclif
cv May 1, 2026
0fb3c41
refactor(cli): migrate snapshot list and create to oclif
cv May 1, 2026
d11eeee
refactor(cli): migrate shields commands to oclif
cv May 1, 2026
74806ce
refactor(cli): migrate channels mutation commands to oclif
cv May 1, 2026
e637e84
refactor(cli): migrate policy mutation commands to oclif
cv May 1, 2026
ee20dfb
refactor(cli): migrate snapshot restore command to oclif
cv May 1, 2026
8d3a568
refactor(cli): migrate destroy command to oclif
cv May 1, 2026
b447f36
refactor(cli): migrate rebuild command to oclif
cv May 1, 2026
02431db
refactor(cli): migrate connect command to oclif
cv May 1, 2026
37ce2ff
refactor(cli): migrate deploy command to oclif
cv May 1, 2026
d3e218e
refactor(cli): migrate onboard aliases to oclif
cv May 1, 2026
df05a3e
refactor(cli): migrate help and version commands to oclif
cv May 1, 2026
3edcf2e
refactor(cli): centralize legacy oclif dispatch
cv May 1, 2026
47df3b5
refactor(cli): drop trivial oclif wrapper helpers
cv May 1, 2026
460173c
refactor(cli): centralize sandbox runtime bridge
cv May 1, 2026
31c0195
test(cli): keep dispatch table out of coverage ratchet
cv May 1, 2026
bad424d
refactor(cli): centralize policy and channels runtime bridge
cv May 1, 2026
74b7e74
merge(main): resolve policy channels runtime bridge conflicts
cv May 2, 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
2 changes: 1 addition & 1 deletion bin/nemoclaw.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

require("../dist/nemoclaw");
module.exports = require("../dist/nemoclaw");
2 changes: 1 addition & 1 deletion bin/nemohermes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
//
// NemoHermes — alias for NemoClaw with the Hermes agent pre-selected.
process.env.NEMOCLAW_AGENT = "hermes";
require("../dist/nemoclaw");
module.exports = require("../dist/nemoclaw");
51 changes: 51 additions & 0 deletions src/lib/channels-mutate-cli-commands.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { describe, expect, it, vi } from "vitest";

import {
ChannelsAddCommand,
ChannelsRemoveCommand,
ChannelsStartCommand,
ChannelsStopCommand,
setChannelsRuntimeBridgeFactoryForTest,
} from "./channels-mutate-cli-commands";

const rootDir = process.cwd();

describe("channels mutation oclif commands", () => {
it("maps add flags to the legacy argv shape", async () => {
const runtime = {
sandboxChannelsAdd: vi.fn().mockResolvedValue(undefined),
sandboxChannelsRemove: vi.fn().mockResolvedValue(undefined),
sandboxChannelsStart: vi.fn().mockResolvedValue(undefined),
sandboxChannelsStop: vi.fn().mockResolvedValue(undefined),
};
setChannelsRuntimeBridgeFactoryForTest(() => runtime);

await ChannelsAddCommand.run(["alpha", "telegram", "--dry-run"], rootDir);

expect(runtime.sandboxChannelsAdd).toHaveBeenCalledWith("alpha", ["telegram", "--dry-run"]);
});

it("maps remove/start/stop to the legacy argv shape", async () => {
const runtime = {
sandboxChannelsAdd: vi.fn().mockResolvedValue(undefined),
sandboxChannelsRemove: vi.fn().mockResolvedValue(undefined),
sandboxChannelsStart: vi.fn().mockResolvedValue(undefined),
sandboxChannelsStop: vi.fn().mockResolvedValue(undefined),
};
setChannelsRuntimeBridgeFactoryForTest(() => runtime);

await ChannelsRemoveCommand.run(["alpha", "telegram"], rootDir);
await ChannelsStartCommand.run(["alpha", "telegram", "--dry-run"], rootDir);
await ChannelsStopCommand.run(["alpha", "slack"], rootDir);

expect(runtime.sandboxChannelsRemove).toHaveBeenCalledWith("alpha", ["telegram"]);
expect(runtime.sandboxChannelsStart).toHaveBeenCalledWith("alpha", [
"telegram",
"--dry-run",
]);
expect(runtime.sandboxChannelsStop).toHaveBeenCalledWith("alpha", ["slack"]);
});
});
105 changes: 105 additions & 0 deletions src/lib/channels-mutate-cli-commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- thin oclif adapters covered through CLI integration tests. */

import { Args, Command, Flags } from "@oclif/core";

import type { NemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge";
import { getNemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge";

type ChannelsRuntimeBridge = Pick<
NemoClawRuntimeBridge,
"sandboxChannelsAdd" | "sandboxChannelsRemove" | "sandboxChannelsStart" | "sandboxChannelsStop"
>;

let runtimeBridgeFactory = (): ChannelsRuntimeBridge => getNemoClawRuntimeBridge();

export function setChannelsRuntimeBridgeFactoryForTest(
factory: () => ChannelsRuntimeBridge,
): void {
runtimeBridgeFactory = factory;
}

function getRuntimeBridge(): ChannelsRuntimeBridge {
return runtimeBridgeFactory();
}

const sandboxNameArg = Args.string({ name: "sandbox", description: "Sandbox name", required: true });
const channelArg = Args.string({ name: "channel", description: "Messaging channel", required: false });

function buildArgs(channel: string | undefined, flags: { "dry-run"?: boolean }): string[] {
const args: string[] = [];
if (channel) args.push(channel);
if (flags["dry-run"]) args.push("--dry-run");
return args;
}

const channelMutationArgs = {
sandboxName: sandboxNameArg,
channel: channelArg,
};
const channelMutationFlags = {
help: Flags.help({ char: "h" }),
"dry-run": Flags.boolean({ description: "Preview the change without applying it" }),
};

export class ChannelsAddCommand extends Command {
static id = "sandbox:channels:add";
static strict = true;
static summary = "Save messaging channel credentials and rebuild";
static description = "Store credentials for a messaging channel and queue a sandbox rebuild.";
static usage = ["<name> channels add <channel> [--dry-run]"];
static args = channelMutationArgs;
static flags = channelMutationFlags;

public async run(): Promise<void> {
const { args, flags } = await this.parse(ChannelsAddCommand);
await getRuntimeBridge().sandboxChannelsAdd(args.sandboxName, buildArgs(args.channel, flags));
}
}

export class ChannelsRemoveCommand extends Command {
static id = "sandbox:channels:remove";
static strict = true;
static summary = "Clear messaging channel credentials and rebuild";
static description = "Remove credentials for a messaging channel and queue a sandbox rebuild.";
static usage = ["<name> channels remove <channel> [--dry-run]"];
static args = channelMutationArgs;
static flags = channelMutationFlags;

public async run(): Promise<void> {
const { args, flags } = await this.parse(ChannelsRemoveCommand);
await getRuntimeBridge().sandboxChannelsRemove(args.sandboxName, buildArgs(args.channel, flags));
}
}

export class ChannelsStopCommand extends Command {
static id = "sandbox:channels:stop";
static strict = true;
static summary = "Disable channel without wiping credentials";
static description = "Disable a messaging channel while keeping credentials in the gateway.";
static usage = ["<name> channels stop <channel> [--dry-run]"];
static args = channelMutationArgs;
static flags = channelMutationFlags;

public async run(): Promise<void> {
const { args, flags } = await this.parse(ChannelsStopCommand);
await getRuntimeBridge().sandboxChannelsStop(args.sandboxName, buildArgs(args.channel, flags));
}
}

export class ChannelsStartCommand extends Command {
static id = "sandbox:channels:start";
static strict = true;
static summary = "Re-enable a stopped messaging channel";
static description = "Re-enable a previously stopped messaging channel.";
static usage = ["<name> channels start <channel> [--dry-run]"];
static args = channelMutationArgs;
static flags = channelMutationFlags;

public async run(): Promise<void> {
const { args, flags } = await this.parse(ChannelsStartCommand);
await getRuntimeBridge().sandboxChannelsStart(args.sandboxName, buildArgs(args.channel, flags));
}
}
2 changes: 2 additions & 0 deletions src/lib/command-registry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- command metadata is covered by registry unit tests. */

/**
* Typed command registry — single source of truth for all CLI commands.
*
Expand Down
27 changes: 27 additions & 0 deletions src/lib/connect-cli-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- thin oclif adapter covered through CLI integration tests. */

import { Args, Command, Flags } from "@oclif/core";

import { getNemoClawRuntimeBridge } from "./nemoclaw-runtime-bridge";

export default class ConnectCliCommand extends Command {
static id = "sandbox:connect";
static strict = true;
static summary = "Shell into a running sandbox";
static description = "Connect to a running sandbox.";
static usage = ["<name> connect"];
static args = {
sandboxName: Args.string({ name: "sandbox", description: "Sandbox name", required: true }),
};
static flags = {
help: Flags.help({ char: "h" }),
};

public async run(): Promise<void> {
const { args } = await this.parse(ConnectCliCommand);
await getNemoClawRuntimeBridge().sandboxConnect(args.sandboxName);
}
}
81 changes: 81 additions & 0 deletions src/lib/coverage-hotspots.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { describe, expect, it } from "vitest";

import { parseDuration } from "./duration";
import { parseGatewayTokenArgs, runGatewayTokenCommand } from "./gateway-token-command";
import { resolveDefaultSandboxName, runStartCommand, runStopCommand } from "./services-command";
import { getVersion } from "./version";

// Narrow coverage guard for small helper modules that are otherwise only
// exercised through subprocess CLI flows in this migration stack.
describe("small CLI helper coverage", () => {
it("parses durations and rejects invalid values", () => {
expect(parseDuration("5m")).toBe(300);
expect(() => parseDuration("31m")).toThrow(/exceeds maximum/);
});

it("parses and runs gateway-token helpers", () => {
expect(parseGatewayTokenArgs(["--quiet", "extra"])).toEqual({
options: { quiet: true },
unknown: ["extra"],
});

const output: string[] = [];
const warnings: string[] = [];
expect(
runGatewayTokenCommand(
"alpha",
{ quiet: false },
{
fetchToken: () => "token-123",
log: (message) => output.push(message),
error: (message) => warnings.push(message),
},
),
).toBe(0);
expect(output).toEqual(["token-123"]);
expect(warnings.join("\n")).toContain("Treat this token like a password");

expect(
runGatewayTokenCommand(
"alpha",
{},
{ fetchToken: () => null, log: () => undefined, error: (message) => warnings.push(message) },
),
).toBe(1);
});

it("resolves service command sandbox names", async () => {
expect(resolveDefaultSandboxName(() => ({ defaultSandbox: "alpha" }))).toBe("alpha");
expect(resolveDefaultSandboxName(() => ({ defaultSandbox: "bad name" }))).toBeUndefined();

const startCalls: Array<{ sandboxName?: string }> = [];
await runStartCommand({
listSandboxes: () => ({ defaultSandbox: "alpha" }),
startAll: async (options) => {
startCalls.push(options);
},
});
expect(startCalls).toEqual([{ sandboxName: "alpha" }]);

const stopCalls: Array<{ sandboxName?: string }> = [];
runStopCommand({
listSandboxes: () => ({ defaultSandbox: null }),
stopAll: (options) => {
stopCalls.push(options);
},
});
expect(stopCalls).toEqual([{}]);
});

it("reads version fallback files", () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-version-"));
fs.writeFileSync(path.join(root, "package.json"), JSON.stringify({ version: "9.8.7" }));
expect(getVersion({ rootDir: root })).toBe("9.8.7");
});
});
Loading
Loading