diff --git a/src/lib/channels-mutate-cli-commands.ts b/src/lib/channels-mutate-cli-commands.ts index bf2cbf9751a..af2d9b9433e 100644 --- a/src/lib/channels-mutate-cli-commands.ts +++ b/src/lib/channels-mutate-cli-commands.ts @@ -1,8 +1,6 @@ // 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"; type ChannelsRuntimeBridge = { diff --git a/src/lib/connect-cli-command.ts b/src/lib/connect-cli-command.ts index a932374a754..8aed111e336 100644 --- a/src/lib/connect-cli-command.ts +++ b/src/lib/connect-cli-command.ts @@ -1,8 +1,6 @@ // 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 { CLI_NAME } from "./branding"; diff --git a/src/lib/destroy-cli-command.ts b/src/lib/destroy-cli-command.ts index 9a8f23a977f..d242d05fb2d 100644 --- a/src/lib/destroy-cli-command.ts +++ b/src/lib/destroy-cli-command.ts @@ -1,8 +1,6 @@ // 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, Flags } from "@oclif/core"; import { NemoClawCommand } from "./nemoclaw-oclif-command"; diff --git a/src/lib/policy-mutate-cli-commands.ts b/src/lib/policy-mutate-cli-commands.ts index 8ca2fa92f35..adaf2a0fa0c 100644 --- a/src/lib/policy-mutate-cli-commands.ts +++ b/src/lib/policy-mutate-cli-commands.ts @@ -1,8 +1,6 @@ // 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"; type PolicyRuntimeBridge = { diff --git a/src/lib/rebuild-cli-command.ts b/src/lib/rebuild-cli-command.ts index 86aec6449b1..cba7aba142c 100644 --- a/src/lib/rebuild-cli-command.ts +++ b/src/lib/rebuild-cli-command.ts @@ -1,8 +1,6 @@ // 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, Flags } from "@oclif/core"; import { NemoClawCommand } from "./nemoclaw-oclif-command"; diff --git a/src/lib/sandbox-doctor-cli-command.ts b/src/lib/sandbox-doctor-cli-command.ts index b837cee6df9..e300ecf9fc5 100644 --- a/src/lib/sandbox-doctor-cli-command.ts +++ b/src/lib/sandbox-doctor-cli-command.ts @@ -1,8 +1,6 @@ // 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 { runSandboxDoctor } from "./sandbox-doctor-action"; diff --git a/src/lib/sandbox-inspection-cli-command.ts b/src/lib/sandbox-inspection-cli-command.ts index 777175adf02..b7fff5eda4e 100644 --- a/src/lib/sandbox-inspection-cli-command.ts +++ b/src/lib/sandbox-inspection-cli-command.ts @@ -1,8 +1,6 @@ // 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 { CLI_NAME } from "./branding"; diff --git a/src/lib/sandbox-logs-cli-command.ts b/src/lib/sandbox-logs-cli-command.ts index e20312dbf71..520ad2905e5 100644 --- a/src/lib/sandbox-logs-cli-command.ts +++ b/src/lib/sandbox-logs-cli-command.ts @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -/* v8 ignore start -- thin oclif wrapper covered through CLI integration tests. */ - import { Args, Command, Flags } from "@oclif/core"; import { logsSinceDurationFlag } from "./duration-flags"; diff --git a/src/lib/sandbox-oclif-command-adapters.test.ts b/src/lib/sandbox-oclif-command-adapters.test.ts new file mode 100644 index 00000000000..30115ee3f68 --- /dev/null +++ b/src/lib/sandbox-oclif-command-adapters.test.ts @@ -0,0 +1,109 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { beforeEach, describe, expect, it, vi } from "vitest"; + +const mocks = vi.hoisted(() => ({ + configGet: vi.fn(), + connectSandbox: vi.fn().mockResolvedValue(undefined), + destroySandbox: vi.fn().mockResolvedValue(undefined), + listSandboxChannels: vi.fn(), + listSandboxPolicies: vi.fn(), + rebuildSandbox: vi.fn().mockResolvedValue(undefined), + runSandboxDoctor: vi.fn().mockResolvedValue(undefined), + shieldsDown: vi.fn(), + shieldsStatus: vi.fn(), + shieldsUp: vi.fn(), + showSandboxStatus: vi.fn().mockResolvedValue(undefined), +})); + +vi.mock("./sandbox-runtime-actions", () => ({ + connectSandbox: mocks.connectSandbox, + destroySandbox: mocks.destroySandbox, + rebuildSandbox: mocks.rebuildSandbox, + showSandboxStatus: mocks.showSandboxStatus, +})); + +vi.mock("./policy-channel-actions", () => ({ + listSandboxChannels: mocks.listSandboxChannels, + listSandboxPolicies: mocks.listSandboxPolicies, +})); + +vi.mock("./sandbox-config", () => ({ + configGet: mocks.configGet, +})); + +vi.mock("./sandbox-doctor-action", () => ({ + runSandboxDoctor: mocks.runSandboxDoctor, +})); + +vi.mock("./shields", () => ({ + shieldsDown: mocks.shieldsDown, + shieldsStatus: mocks.shieldsStatus, + shieldsUp: mocks.shieldsUp, +})); + +import ConnectCliCommand from "./connect-cli-command"; +import DestroyCliCommand from "./destroy-cli-command"; +import RebuildCliCommand from "./rebuild-cli-command"; +import SandboxDoctorCliCommand from "./sandbox-doctor-cli-command"; +import { + SandboxChannelsListCommand, + SandboxConfigGetCommand, + SandboxPolicyListCommand, + SandboxStatusCommand, +} from "./sandbox-inspection-cli-command"; +import { ShieldsDownCommand, ShieldsStatusCommand, ShieldsUpCommand } from "./shields-cli-commands"; + +const rootDir = process.cwd(); + +describe("sandbox oclif command adapters", () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + it("maps connect and lifecycle flags to typed action options", async () => { + await ConnectCliCommand.run(["alpha", "--probe-only"], rootDir); + await DestroyCliCommand.run(["alpha", "--yes"], rootDir); + await RebuildCliCommand.run(["alpha", "--force", "--verbose"], rootDir); + + expect(mocks.connectSandbox).toHaveBeenCalledWith("alpha", { probeOnly: true }); + expect(mocks.destroySandbox).toHaveBeenCalledWith("alpha", { force: false, yes: true }); + expect(mocks.rebuildSandbox).toHaveBeenCalledWith("alpha", { + force: true, + verbose: true, + yes: false, + }); + }); + + it("maps inspection commands to their action helpers", async () => { + await SandboxStatusCommand.run(["alpha"], rootDir); + await SandboxPolicyListCommand.run(["alpha"], rootDir); + await SandboxChannelsListCommand.run(["alpha"], rootDir); + await SandboxConfigGetCommand.run(["alpha", "--key", "model", "--format", "yaml"], rootDir); + + expect(mocks.showSandboxStatus).toHaveBeenCalledWith("alpha"); + expect(mocks.listSandboxPolicies).toHaveBeenCalledWith("alpha"); + expect(mocks.listSandboxChannels).toHaveBeenCalledWith("alpha"); + expect(mocks.configGet).toHaveBeenCalledWith("alpha", { key: "model", format: "yaml" }); + }); + + it("maps doctor and shields commands to action helpers", async () => { + await SandboxDoctorCliCommand.run(["alpha", "--json"], rootDir); + await ShieldsDownCommand.run( + ["alpha", "--timeout", "5m", "--reason", "debugging", "--policy", "permissive"], + rootDir, + ); + await ShieldsUpCommand.run(["alpha"], rootDir); + await ShieldsStatusCommand.run(["alpha"], rootDir); + + expect(mocks.runSandboxDoctor).toHaveBeenCalledWith("alpha", ["--json"]); + expect(mocks.shieldsDown).toHaveBeenCalledWith("alpha", { + timeout: "5m", + reason: "debugging", + policy: "permissive", + }); + expect(mocks.shieldsUp).toHaveBeenCalledWith("alpha"); + expect(mocks.shieldsStatus).toHaveBeenCalledWith("alpha"); + }); +}); diff --git a/src/lib/shields-cli-commands.ts b/src/lib/shields-cli-commands.ts index 608b0fbbb31..6d985368825 100644 --- a/src/lib/shields-cli-commands.ts +++ b/src/lib/shields-cli-commands.ts @@ -1,8 +1,6 @@ // 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 { shieldsTimeoutDurationFlag } from "./duration-flags"; diff --git a/src/lib/skill-install-cli-command.ts b/src/lib/skill-install-cli-command.ts index 60299a46907..47e26809383 100644 --- a/src/lib/skill-install-cli-command.ts +++ b/src/lib/skill-install-cli-command.ts @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -/* v8 ignore start -- thin oclif wrapper covered through CLI integration tests. */ - import { Args, Command, Flags } from "@oclif/core"; import { installSandboxSkill } from "./sandbox-runtime-actions"; diff --git a/src/lib/snapshot-cli-commands.ts b/src/lib/snapshot-cli-commands.ts index a2251b2f3cf..05c5d0813d9 100644 --- a/src/lib/snapshot-cli-commands.ts +++ b/src/lib/snapshot-cli-commands.ts @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -/* v8 ignore start -- thin oclif wrappers covered through CLI integration tests. */ - import { Args, Command, Flags } from "@oclif/core"; import { runSandboxSnapshot } from "./sandbox-runtime-actions";