Skip to content

Commit 1e9a140

Browse files
steipetePeter Steinberger
andauthored
fix(skills): preserve profile in ClawHub command hints (#117555)
Co-authored-by: Peter Steinberger <[email protected]>
1 parent b0ec8bb commit 1e9a140

2 files changed

Lines changed: 63 additions & 2 deletions

File tree

‎src/cli/skills-cli.format.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ function appendClawHubHint(output: string, json?: boolean): string {
3636
if (json) {
3737
return output;
3838
}
39-
return `${output}\n\nTip: use \`openclaw skills search\`, \`openclaw skills install\`, and \`openclaw skills update\` for ClawHub-backed skills.`;
39+
const command = formatCliCommand("openclaw skills");
40+
return `${output}\n\nTip: use \`${command} search\`, \`${command} install\`, and \`${command} update\` for ClawHub-backed skills.`;
4041
}
4142

4243
function formatSkillStatus(skill: SkillStatusEntry): string {

‎src/cli/skills-cli.test.ts‎

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Skills CLI tests cover skill listing, install, and command output behavior.
2-
import { describe, expect, it, vi } from "vitest";
2+
import { afterEach, describe, expect, it, vi } from "vitest";
33
import type { SkillStatusEntry, SkillStatusReport } from "../skills/discovery/status.js";
44
import { createEmptyInstallChecks } from "./requirements-test-fixtures.js";
55
import { formatSkillInfo, formatSkillsCheck, formatSkillsList } from "./skills-cli.format.js";
@@ -51,6 +51,66 @@ function createMockReport(skills: SkillStatusEntry[]): SkillStatusReport {
5151
}
5252

5353
describe("skills-cli", () => {
54+
afterEach(() => {
55+
vi.unstubAllEnvs();
56+
});
57+
58+
describe("ClawHub command hints", () => {
59+
it.each([
60+
{
61+
name: "named profile",
62+
profile: "work",
63+
container: "",
64+
prefix: "openclaw --profile work",
65+
},
66+
{
67+
name: "managed container",
68+
profile: "",
69+
container: "demo",
70+
prefix: "openclaw --container demo",
71+
},
72+
{
73+
name: "default profile",
74+
profile: "default",
75+
container: "",
76+
prefix: "openclaw",
77+
},
78+
])("preserves the $name on every human skill surface", ({ profile, container, prefix }) => {
79+
vi.stubEnv("OPENCLAW_PROFILE", profile);
80+
vi.stubEnv("OPENCLAW_CONTAINER_HINT", container);
81+
const report = createMockReport([]);
82+
const outputs = [
83+
formatSkillsList(report, {}),
84+
formatSkillInfo(report, "missing-skill", {}),
85+
formatSkillsCheck(report, {}),
86+
];
87+
88+
for (const output of outputs) {
89+
for (const action of ["search", "install", "update"]) {
90+
expect(output).toContain(`${prefix} skills ${action}`);
91+
}
92+
}
93+
});
94+
95+
it("keeps profile and container guidance out of machine-readable skill output", () => {
96+
vi.stubEnv("OPENCLAW_PROFILE", "work");
97+
vi.stubEnv("OPENCLAW_CONTAINER_HINT", "demo");
98+
const report = createMockReport([]);
99+
const outputs = [
100+
formatSkillsList(report, { json: true }),
101+
formatSkillInfo(report, "missing-skill", { json: true }),
102+
formatSkillsCheck(report, { json: true }),
103+
];
104+
105+
for (const output of outputs) {
106+
expect(() => JSON.parse(output)).not.toThrow();
107+
expect(output).not.toContain("Tip:");
108+
expect(output).not.toContain("openclaw --profile");
109+
expect(output).not.toContain("openclaw --container");
110+
}
111+
});
112+
});
113+
54114
describe("formatSkillsList", () => {
55115
it("formats empty skills list", () => {
56116
const report = createMockReport([]);

0 commit comments

Comments
 (0)