mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 06:11:24 +00:00
fix: reduce brew noise in onboarding
This commit is contained in:
42
src/agents/skills-status.test.ts
Normal file
42
src/agents/skills-status.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { SkillEntry } from "./skills/types.js";
|
||||
import { buildWorkspaceSkillStatus } from "./skills-status.js";
|
||||
|
||||
describe("buildWorkspaceSkillStatus", () => {
|
||||
it("does not surface install options for OS-scoped skills on unsupported platforms", () => {
|
||||
if (process.platform === "win32") {
|
||||
// Keep this simple; win32 platform naming is already explicitly handled elsewhere.
|
||||
return;
|
||||
}
|
||||
|
||||
const mismatchedOs = process.platform === "darwin" ? "linux" : "darwin";
|
||||
|
||||
const entry: SkillEntry = {
|
||||
skill: {
|
||||
name: "os-scoped",
|
||||
description: "test",
|
||||
source: "test",
|
||||
filePath: "/tmp/os-scoped",
|
||||
baseDir: "/tmp",
|
||||
},
|
||||
frontmatter: {},
|
||||
metadata: {
|
||||
os: [mismatchedOs],
|
||||
requires: { bins: ["fakebin"] },
|
||||
install: [
|
||||
{
|
||||
id: "brew",
|
||||
kind: "brew",
|
||||
formula: "fake",
|
||||
bins: ["fakebin"],
|
||||
label: "Install fake (brew)",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const report = buildWorkspaceSkillStatus("/tmp/ws", { entries: [entry] });
|
||||
expect(report.skills).toHaveLength(1);
|
||||
expect(report.skills[0]?.install).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -111,6 +111,13 @@ function normalizeInstallOptions(
|
||||
entry: SkillEntry,
|
||||
prefs: SkillsInstallPreferences,
|
||||
): SkillInstallOption[] {
|
||||
// If the skill is explicitly OS-scoped, don't surface install actions on unsupported platforms.
|
||||
// (Installers run locally; remote OS eligibility is handled separately.)
|
||||
const requiredOs = entry.metadata?.os ?? [];
|
||||
if (requiredOs.length > 0 && !requiredOs.includes(process.platform)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const install = entry.metadata?.install ?? [];
|
||||
if (install.length === 0) {
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user