Repository navigation
refactor(cli): migrate skill install command to oclif #2797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
116111c
5e997cb
88cd958
3f748d6
0bc877a
3fd15fc
81c62bb
7d6a6fb
3f17a4f
e615567
54263d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 -- thin oclif adapter covered through CLI integration tests. */ | ||
|
|
||
|
Comment on lines
+4
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win Avoid file-wide coverage ignore for behaviorful debug logic. Line 4 suppresses coverage for the entire module, including default-sandbox resolution and OpenShell probe warning paths. That makes regressions harder to catch in this command. ♻️ Proposed fix-/* v8 ignore start -- thin oclif adapter covered through CLI integration tests. */🤖 Prompt for AI Agents |
||
| import { Command } from "@oclif/core"; | ||
|
|
||
| import type { CaptureOpenshellResult } from "./openshell"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // 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 SandboxLogsCommand, { | ||
| setSandboxLogsRuntimeBridgeFactoryForTest, | ||
| } from "./sandbox-logs-cli-command"; | ||
|
|
||
| const rootDir = process.cwd(); | ||
|
|
||
| describe("SandboxLogsCommand", () => { | ||
| it("runs sandbox logs with the follow flag", async () => { | ||
| const sandboxLogs = vi.fn(); | ||
| setSandboxLogsRuntimeBridgeFactoryForTest(() => ({ sandboxLogs })); | ||
|
|
||
| await SandboxLogsCommand.run(["alpha", "--follow"], rootDir); | ||
|
|
||
| expect(sandboxLogs).toHaveBeenCalledWith("alpha", true); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // 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"; | ||
|
|
||
| type RuntimeBridge = { | ||
| sandboxLogs: (sandboxName: string, follow: boolean) => void; | ||
| }; | ||
|
|
||
| let runtimeBridgeFactory = (): RuntimeBridge => require("../nemoclaw") as RuntimeBridge; | ||
|
|
||
| export function setSandboxLogsRuntimeBridgeFactoryForTest( | ||
| factory: () => RuntimeBridge, | ||
| ): void { | ||
| runtimeBridgeFactory = factory; | ||
| } | ||
|
|
||
| function getRuntimeBridge(): RuntimeBridge { | ||
| return runtimeBridgeFactory(); | ||
| } | ||
|
|
||
| export default class SandboxLogsCommand extends Command { | ||
| static id = "sandbox:logs"; | ||
| static strict = true; | ||
| static summary = "Stream sandbox logs"; | ||
| static description = "Show OpenClaw gateway logs and OpenShell audit logs for a sandbox."; | ||
| static usage = ["<name> logs [--follow]"]; | ||
| static args = { | ||
| sandboxName: Args.string({ | ||
| name: "sandbox", | ||
| description: "Sandbox name", | ||
| required: true, | ||
| }), | ||
| }; | ||
| static flags = { | ||
| help: Flags.help({ char: "h" }), | ||
| follow: Flags.boolean({ description: "Follow logs until interrupted" }), | ||
| }; | ||
|
|
||
| public async run(): Promise<void> { | ||
| const { args, flags } = await this.parse(SandboxLogsCommand); | ||
| getRuntimeBridge().sandboxLogs(args.sandboxName, flags.follow === true); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // 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 SkillInstallCliCommand, { | ||
| setSkillInstallRuntimeBridgeFactoryForTest, | ||
| } from "./skill-install-cli-command"; | ||
|
|
||
| const rootDir = process.cwd(); | ||
|
|
||
| describe("SkillInstallCliCommand", () => { | ||
| it("runs skill install with the legacy install argv shape", async () => { | ||
| const sandboxSkillInstall = vi.fn().mockResolvedValue(undefined); | ||
| setSkillInstallRuntimeBridgeFactoryForTest(() => ({ sandboxSkillInstall })); | ||
|
|
||
| await SkillInstallCliCommand.run(["alpha", "/tmp/my-skill"], rootDir); | ||
|
|
||
| expect(sandboxSkillInstall).toHaveBeenCalledWith("alpha", ["install", "/tmp/my-skill"]); | ||
| }); | ||
|
|
||
| it("lets legacy skill install validation report a missing path", async () => { | ||
| const sandboxSkillInstall = vi.fn().mockResolvedValue(undefined); | ||
| setSkillInstallRuntimeBridgeFactoryForTest(() => ({ sandboxSkillInstall })); | ||
|
|
||
| await SkillInstallCliCommand.run(["alpha"], rootDir); | ||
|
|
||
| expect(sandboxSkillInstall).toHaveBeenCalledWith("alpha", ["install"]); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // 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"; | ||
|
|
||
| type RuntimeBridge = { | ||
| sandboxSkillInstall: (sandboxName: string, args?: string[]) => Promise<void>; | ||
| }; | ||
|
|
||
| let runtimeBridgeFactory = (): RuntimeBridge => require("../nemoclaw") as RuntimeBridge; | ||
|
|
||
| export function setSkillInstallRuntimeBridgeFactoryForTest( | ||
| factory: () => RuntimeBridge, | ||
| ): void { | ||
| runtimeBridgeFactory = factory; | ||
| } | ||
|
|
||
| function getRuntimeBridge(): RuntimeBridge { | ||
| return runtimeBridgeFactory(); | ||
| } | ||
|
|
||
| export default class SkillInstallCliCommand extends Command { | ||
| static id = "sandbox:skill:install"; | ||
| static strict = true; | ||
| static summary = "Deploy a skill directory to the sandbox"; | ||
| static description = "Validate a local SKILL.md directory and upload it to a running sandbox."; | ||
| static usage = ["<name> skill install <path>"]; | ||
| static args = { | ||
| sandboxName: Args.string({ | ||
| name: "sandbox", | ||
| description: "Sandbox name", | ||
| required: true, | ||
| }), | ||
| skillPath: Args.string({ | ||
| name: "path", | ||
| description: "Skill directory or direct path to SKILL.md", | ||
| required: false, | ||
| }), | ||
| }; | ||
| static flags = { | ||
| help: Flags.help({ char: "h" }), | ||
| }; | ||
|
|
||
| public async run(): Promise<void> { | ||
| const { args } = await this.parse(SkillInstallCliCommand); | ||
| await getRuntimeBridge().sandboxSkillInstall( | ||
| args.sandboxName, | ||
| args.skillPath ? ["install", args.skillPath] : ["install"], | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
Narrow the coverage suppression scope in this file.
Line 4 starts a file-wide ignore region, but this module contains non-trivial runtime and error-path logic. Blanket suppression here will hide useful branch coverage signals.
♻️ Proposed fix
-/* v8 ignore start -- thin oclif adapter covered through CLI integration tests. */🤖 Prompt for AI Agents