From 51020ee61bd61e19d4f9f22ec36b3c5ba59f1d51 Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Wed, 16 Sep 2026 19:32:04 +0000 Subject: [PATCH 1/7] feat(skills): list skills through the omp binary (skills --json) The skills page must list skills with no running session, so a session-keyed RPC source could not be relied on and the pure-Node replica had to stay correct by hand. Ask the omp binary instead: 'omp skills --json' runs the same discovery sessions use, is fresh from disk on every load, and needs no session. The pure-Node scan stays only as a fallback for installs whose binary predates the command. --- lib/skills-service.test.mjs | 46 ++++++++++++++++++++++++++ lib/skills-service.ts | 65 +++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) diff --git a/lib/skills-service.test.mjs b/lib/skills-service.test.mjs index 7c85cee4a..2f034cee7 100644 --- a/lib/skills-service.test.mjs +++ b/lib/skills-service.test.mjs @@ -15,6 +15,7 @@ const { parseSkillFrontmatter, readDisableModelInvocation, setDisableModelInvocation, + skillsFromRpcPayload, } = await jiti.import("./skills-service.ts"); // The toggle route authorizes existing files through the consolidated facade. const { isExistingFilePathAllowed } = await jiti.import("./file-access.ts"); @@ -153,3 +154,48 @@ test("discovery honors all three frontmatter spellings", async () => { rmSync(dir, { recursive: true, force: true }); } }); + +test("maps a skills_list RPC payload onto SkillInfo", () => { + const mapped = skillsFromRpcPayload({ + skills: [ + { + name: "calendar", + description: "Calendar skill.", + filePath: "/home/me/.omp/skills/calendar/SKILL.md", + baseDir: "/home/me/.omp/skills/calendar", + source: "native:user", + hide: false, + }, + { + name: "superpowers/test-driven-development", + description: "TDD.", + filePath: "/cache/test-driven-development/SKILL.md", + source: "claude-plugins:user", + hide: true, + }, + ], + warnings: [{ skillPath: "", message: "boom" }], + }); + assert.equal(mapped.skills.length, 2); + assert.deepEqual(mapped.skills[0], { + name: "calendar", + description: "Calendar skill.", + filePath: "/home/me/.omp/skills/calendar/SKILL.md", + baseDir: "/home/me/.omp/skills/calendar", + disableModelInvocation: false, + sourceInfo: { source: ".omp", scope: "user" }, + }); + // BaseDir falls back to the filePath when absent, provider labels fall + // through for providers the replica has no directory for, and `hide` + // maps onto disableModelInvocation. + assert.equal(mapped.skills[1].baseDir, "/cache/test-driven-development"); + assert.equal(mapped.skills[1].sourceInfo.source, "claude-plugins"); + assert.equal(mapped.skills[1].disableModelInvocation, true); + assert.deepEqual(mapped.diagnostics, [{ skillPath: "", message: "boom" }]); +}); + +test("rejects a malformed skills_list payload", () => { + assert.equal(skillsFromRpcPayload(null), undefined); + assert.equal(skillsFromRpcPayload("nope"), undefined); + assert.deepEqual(skillsFromRpcPayload({ skills: "many", warnings: [] }), { skills: [], diagnostics: [] }); +}); diff --git a/lib/skills-service.ts b/lib/skills-service.ts index d46b31a50..ecc8ae05f 100644 --- a/lib/skills-service.ts +++ b/lib/skills-service.ts @@ -3,6 +3,8 @@ import { homedir } from "os"; import * as path from "path"; import { parse as parseYaml } from "yaml"; import { getAgentDir } from "@/lib/omp/paths"; +import { getRpcSession, getRunningRpcSessions } from "@/lib/rpc-manager"; +import { isRecord } from "@/lib/type-guards"; import type { SkillInfo } from "@/lib/api-types"; import { annotateSkillsWithInstallInfo } from "@/lib/skill-lock"; @@ -233,9 +235,72 @@ async function scanRoot(root: SkillScanRoot, diagnostics: SkillDiagnostic[]): Pr return skills; } +/** omp provider id (the `source` field is "provider:level") mapped to the + * provider label the UI renders (the owning directory). */ +const SOURCE_LABEL_BY_PROVIDER: Record = { + native: ".omp", + claude: ".claude", + agents: ".agents", + codex: ".codex", + github: ".github", + "omp-managed": "managed", +}; + +/** + * Ask a running omp session for its skill listing (RPC `skills_list`, omp + * >= 18.2.2-patched). The session listing is authoritative — it is the same + * resolution omp uses for `skill://` and `/skill:`, including namespaced + * collision aliases the replica scan below cannot know about. Returns + * undefined when no running session covers cwd, when the child predates the + * command, or on any transport hiccup, letting the caller fall back to the + * local replica scan. The listing reflects the session's last discovery: + * like the CLI, changes on disk show up after the session restarts. + */ +/** + * Map a `skills_list` RPC payload onto the app's SkillInfo shape. Returns + * undefined for anything that is not a successful skills_list data object. + */ +export function skillsFromRpcPayload(data: unknown): SkillsWithDiagnostics | undefined { + if (!isRecord(data)) return undefined; + const rawSkills = Array.isArray(data.skills) ? data.skills : []; + const warnings = Array.isArray(data.warnings) ? data.warnings : []; + const skills: SkillInfo[] = []; + for (const raw of rawSkills) { + if (!isRecord(raw) || typeof raw.name !== "string" || typeof raw.filePath !== "string") continue; + const [provider = "", scope = ""] = typeof raw.source === "string" ? raw.source.split(":") : []; + skills.push({ + name: raw.name, + description: typeof raw.description === "string" ? raw.description : "", + filePath: raw.filePath, + baseDir: typeof raw.baseDir === "string" ? raw.baseDir : raw.filePath.replace(/[\\/]SKILL\.md$/, ""), + disableModelInvocation: raw.hide === true, + sourceInfo: { source: SOURCE_LABEL_BY_PROVIDER[provider] ?? provider, scope }, + }); + } + return { skills, diagnostics: warnings as SkillDiagnostic[] }; +} + +async function discoverSkillsViaRpc(cwd: string): Promise { + const candidates = getRunningRpcSessions().filter((session) => session.cwd === cwd); + for (const running of candidates) { + const session = getRpcSession(running.id); + if (!session) continue; + try { + const response = (await session.send({ type: "skills_list" })) as unknown; + if (!isRecord(response) || response.success !== true) continue; + return skillsFromRpcPayload(response.data); + } catch { + // Restarting or stale child — try the next candidate, else fall back. + } + } + return undefined; +} + /** Discover skills for a cwd the way omp does. Name collisions resolve to the * highest-priority provider (scan-root order); result is sorted by name. */ export async function discoverSkills(cwd: string): Promise { + const viaRpc = await discoverSkillsViaRpc(cwd); + if (viaRpc) return viaRpc; const diagnostics: SkillDiagnostic[] = []; const byName = new Map(); for (const root of buildScanRoots(cwd)) { From ea259bb3c4b9ba1ed76bf99735fe6bf73af5af6a Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Thu, 1 Oct 2026 15:02:30 +0000 Subject: [PATCH 2/7] fix(skills): list through the released `omp skill list --json` The branch still carried the earlier skills_list RPC variant, which no released omp implements. can1357/oh-my-pi#12273 shipped the listing as `omp skill list [dir] --json` (omp >= 18.3.3); exec that, map its { skillPath, message } warnings onto SkillDiagnostic, and keep the replica scan as the fallback for older binaries. --- lib/skills-service.test.mjs | 27 ++++++++----- lib/skills-service.ts | 81 ++++++++++++++++++++++--------------- 2 files changed, 66 insertions(+), 42 deletions(-) diff --git a/lib/skills-service.test.mjs b/lib/skills-service.test.mjs index 2f034cee7..aba762156 100644 --- a/lib/skills-service.test.mjs +++ b/lib/skills-service.test.mjs @@ -15,7 +15,7 @@ const { parseSkillFrontmatter, readDisableModelInvocation, setDisableModelInvocation, - skillsFromRpcPayload, + skillsFromCliPayload, } = await jiti.import("./skills-service.ts"); // The toggle route authorizes existing files through the consolidated facade. const { isExistingFilePathAllowed } = await jiti.import("./file-access.ts"); @@ -113,9 +113,13 @@ test("scan roots cover the compat directories the app installs into", () => { test("discovery honors all three frontmatter spellings", async () => { const previousAgentDir = process.env.PI_CODING_AGENT_DIR; const previousClaudeDir = process.env.CLAUDE_CONFIG_DIR; + const previousOmpBin = process.env.OMP_WEB_OMP_BIN; const dir = mkdtempSync(join(tmpdir(), "omp-web-skill-scan-")); process.env.PI_CODING_AGENT_DIR = join(dir, ".omp", "agent"); process.env.CLAUDE_CONFIG_DIR = join(dir, ".claude"); + // A binary without `skill list` (node itself) fails the exec, so this + // exercises the replica-scan fallback regardless of the host's omp. + process.env.OMP_WEB_OMP_BIN = process.execPath; try { const fixtures = [ [join(process.env.PI_CODING_AGENT_DIR, "skills", "kebab"), "kebab", "disable-model-invocation: true\n", true], @@ -151,12 +155,14 @@ test("discovery honors all three frontmatter spellings", async () => { else process.env.PI_CODING_AGENT_DIR = previousAgentDir; if (previousClaudeDir === undefined) delete process.env.CLAUDE_CONFIG_DIR; else process.env.CLAUDE_CONFIG_DIR = previousClaudeDir; + if (previousOmpBin === undefined) delete process.env.OMP_WEB_OMP_BIN; + else process.env.OMP_WEB_OMP_BIN = previousOmpBin; rmSync(dir, { recursive: true, force: true }); } }); -test("maps a skills_list RPC payload onto SkillInfo", () => { - const mapped = skillsFromRpcPayload({ +test("maps an `omp skill list --json` payload onto SkillInfo", () => { + const mapped = skillsFromCliPayload({ skills: [ { name: "calendar", @@ -174,7 +180,7 @@ test("maps a skills_list RPC payload onto SkillInfo", () => { hide: true, }, ], - warnings: [{ skillPath: "", message: "boom" }], + warnings: [{ skillPath: "/x/SKILL.md", message: "boom" }, { skillPath: "", message: "bare" }, "junk"], }); assert.equal(mapped.skills.length, 2); assert.deepEqual(mapped.skills[0], { @@ -191,11 +197,14 @@ test("maps a skills_list RPC payload onto SkillInfo", () => { assert.equal(mapped.skills[1].baseDir, "/cache/test-driven-development"); assert.equal(mapped.skills[1].sourceInfo.source, "claude-plugins"); assert.equal(mapped.skills[1].disableModelInvocation, true); - assert.deepEqual(mapped.diagnostics, [{ skillPath: "", message: "boom" }]); + assert.deepEqual(mapped.diagnostics, [ + { type: "warning", message: "boom", path: "/x/SKILL.md" }, + { type: "warning", message: "bare" }, + ]); }); -test("rejects a malformed skills_list payload", () => { - assert.equal(skillsFromRpcPayload(null), undefined); - assert.equal(skillsFromRpcPayload("nope"), undefined); - assert.deepEqual(skillsFromRpcPayload({ skills: "many", warnings: [] }), { skills: [], diagnostics: [] }); +test("rejects a malformed `omp skill list --json` payload", () => { + assert.equal(skillsFromCliPayload(null), undefined); + assert.equal(skillsFromCliPayload("nope"), undefined); + assert.deepEqual(skillsFromCliPayload({ skills: "many", warnings: [] }), { skills: [], diagnostics: [] }); }); diff --git a/lib/skills-service.ts b/lib/skills-service.ts index ecc8ae05f..5063781d2 100644 --- a/lib/skills-service.ts +++ b/lib/skills-service.ts @@ -1,9 +1,11 @@ +import { execFile } from "child_process"; import { existsSync, promises as fs } from "fs"; import { homedir } from "os"; import * as path from "path"; +import { promisify } from "util"; import { parse as parseYaml } from "yaml"; +import { resolveOmpBin } from "@/lib/omp/omp-cli"; import { getAgentDir } from "@/lib/omp/paths"; -import { getRpcSession, getRunningRpcSessions } from "@/lib/rpc-manager"; import { isRecord } from "@/lib/type-guards"; import type { SkillInfo } from "@/lib/api-types"; import { annotateSkillsWithInstallInfo } from "@/lib/skill-lock"; @@ -247,23 +249,13 @@ const SOURCE_LABEL_BY_PROVIDER: Record = { }; /** - * Ask a running omp session for its skill listing (RPC `skills_list`, omp - * >= 18.2.2-patched). The session listing is authoritative — it is the same - * resolution omp uses for `skill://` and `/skill:`, including namespaced - * collision aliases the replica scan below cannot know about. Returns - * undefined when no running session covers cwd, when the child predates the - * command, or on any transport hiccup, letting the caller fall back to the - * local replica scan. The listing reflects the session's last discovery: - * like the CLI, changes on disk show up after the session restarts. + * Map an `omp skill list --json` payload onto the app's SkillInfo shape. + * Returns undefined for anything that is not a skills data object. */ -/** - * Map a `skills_list` RPC payload onto the app's SkillInfo shape. Returns - * undefined for anything that is not a successful skills_list data object. - */ -export function skillsFromRpcPayload(data: unknown): SkillsWithDiagnostics | undefined { +export function skillsFromCliPayload(data: unknown): SkillsWithDiagnostics | undefined { if (!isRecord(data)) return undefined; const rawSkills = Array.isArray(data.skills) ? data.skills : []; - const warnings = Array.isArray(data.warnings) ? data.warnings : []; + const rawWarnings = Array.isArray(data.warnings) ? data.warnings : []; const skills: SkillInfo[] = []; for (const raw of rawSkills) { if (!isRecord(raw) || typeof raw.name !== "string" || typeof raw.filePath !== "string") continue; @@ -277,30 +269,53 @@ export function skillsFromRpcPayload(data: unknown): SkillsWithDiagnostics | und sourceInfo: { source: SOURCE_LABEL_BY_PROVIDER[provider] ?? provider, scope }, }); } - return { skills, diagnostics: warnings as SkillDiagnostic[] }; + // omp warnings are { skillPath, message }. + const diagnostics: SkillDiagnostic[] = []; + for (const raw of rawWarnings) { + if (!isRecord(raw) || typeof raw.message !== "string") continue; + diagnostics.push({ + type: "warning", + message: raw.message, + ...(typeof raw.skillPath === "string" && raw.skillPath ? { path: raw.skillPath } : {}), + }); + } + return { skills, diagnostics }; } -async function discoverSkillsViaRpc(cwd: string): Promise { - const candidates = getRunningRpcSessions().filter((session) => session.cwd === cwd); - for (const running of candidates) { - const session = getRpcSession(running.id); - if (!session) continue; - try { - const response = (await session.send({ type: "skills_list" })) as unknown; - if (!isRecord(response) || response.success !== true) continue; - return skillsFromRpcPayload(response.data); - } catch { - // Restarting or stale child — try the next candidate, else fall back. - } +const execFileAsync = promisify(execFile); +const SKILLS_CLI_TIMEOUT_MS = 15_000; + +/** + * Ask the omp binary for its skill listing (`omp skill list --json`, + * omp >= 18.3.3). The binary is the authoritative source — the same discovery + * sessions use, including namespaced collision aliases this replica cannot + * reproduce — and every exec re-reads disk, so installs, uninstalls and + * toggles show immediately. Returns undefined when no binary is available, + * when the binary predates the command, or on any exec/parse failure, letting + * the caller fall back to the replica scan. + */ +async function discoverSkillsViaCli(cwd: string): Promise { + const ompBin = resolveOmpBin(); + if (!ompBin) return undefined; + try { + const { stdout } = await execFileAsync(ompBin, ["skill", "list", cwd, "--json"], { + timeout: SKILLS_CLI_TIMEOUT_MS, + maxBuffer: 16 * 1024 * 1024, + }); + return skillsFromCliPayload(JSON.parse(stdout)); + } catch { + // Missing/old binary, exec or parse failure — fall back to the replica. + return undefined; } - return undefined; } -/** Discover skills for a cwd the way omp does. Name collisions resolve to the - * highest-priority provider (scan-root order); result is sorted by name. */ +/** Discover skills for a cwd the way omp does: through the omp binary when it + * supports `skill list`, else the replica scan below. In the replica, name + * collisions resolve to the highest-priority provider (scan-root order); + * result is sorted by name. */ export async function discoverSkills(cwd: string): Promise { - const viaRpc = await discoverSkillsViaRpc(cwd); - if (viaRpc) return viaRpc; + const viaCli = await discoverSkillsViaCli(cwd); + if (viaCli) return viaCli; const diagnostics: SkillDiagnostic[] = []; const byName = new Map(); for (const root of buildScanRoots(cwd)) { From 76b7fdd4903544c60f0d54117e92c1a445fb3cbf Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Thu, 1 Oct 2026 15:07:45 +0000 Subject: [PATCH 3/7] fix(skills): let every omp-listed skill be toggled Review follow-ups for the omp skill list path: - PATCH /api/skills also authorizes the skill dirs omp itself lists for the request cwd (plugin, custom-directory and registry skills sit outside the replica roots), and the Skills page now sends that cwd. - Wrap Windows .cmd/.bat launchers and hide the console window, as the version probe does; pass an absolute cwd. - Treat a payload without a skills array as unsupported so discovery falls back to the replica instead of listing nothing. - Tests pass the binary explicitly: the replica test pins an incompatible one, and a stub binary proves the CLI path and its argv. - Changelog entry. --- CHANGELOG.md | 1 + app/api/skills/route.ts | 4 ++++ components/SkillsConfig.tsx | 3 ++- lib/skills-service.test.mjs | 40 ++++++++++++++++++++++++++++--------- lib/skills-service.ts | 23 ++++++++++++--------- 5 files changed, 52 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38b92f011..3dfaea3dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f ### Fixes & Improvements +- The Skills page lists exactly what omp resolves, through `omp skill list --json` (omp 18.3.3 or later): plugin, custom-directory and registry skills appear, colliding names show as `namespace/name`, and every listed skill can be toggled. Older omp binaries keep the built-in scan. - On phones, the top bar's **⋯** menu no longer repeats the session name already shown in the title, and its theme and language pickers open fully instead of being cut off at the bar's edge. - Keep **Collapse input** available after expanding a long user message with **Show full input**, so the message can be collapsed again. - Agent host tools (`open_url`, `notify`, `open_file`) no longer fail when you switch to another session mid-run. Any open omp-web tab now answers them, and a URL or file from a session you are not viewing opens only after you confirm it in a dialog. diff --git a/app/api/skills/route.ts b/app/api/skills/route.ts index 313c64b1c..f3815669a 100644 --- a/app/api/skills/route.ts +++ b/app/api/skills/route.ts @@ -2,6 +2,7 @@ import { NextResponse } from "next/server"; import { existsSync, readFileSync, realpathSync, writeFileSync } from "fs"; import { basename } from "path"; import { + discoverSkills, getSkillScanRootDirs, loadSkillsWithInstallInfo, parseSkillFrontmatter, @@ -50,6 +51,9 @@ export async function PATCH(req: Request) { // project walk-up roots discovery visits above the session directory. const scanCwd = cwd && isExistingFilePathAllowed(cwd, allowedRoots) ? cwd : undefined; for (const dir of getSkillScanRootDirs(scanCwd)) allowedRoots.add(dir); + // omp's own listing also covers plugin, custom-directory and registry + // skills outside the replica roots; anything it lists must be togglable. + if (scanCwd) for (const skill of (await discoverSkills(scanCwd)).skills) allowedRoots.add(skill.baseDir); // Resolve symlinks once up front and authorize the resolved path: the // read/write below then operate on the same resolved path, so a symlink // swapped between the authorization check and the write cannot redirect diff --git a/components/SkillsConfig.tsx b/components/SkillsConfig.tsx index c2cba45fe..a157299b8 100644 --- a/components/SkillsConfig.tsx +++ b/components/SkillsConfig.tsx @@ -861,6 +861,7 @@ export function SkillsConfig({ body: JSON.stringify({ filePath: skill.filePath, disableModelInvocation: next, + cwd, }), }); const d = (await res.json()) as { success?: boolean; error?: string }; @@ -889,7 +890,7 @@ export function SkillsConfig({ return n; }); } - }, [t]); + }, [cwd, t]); const selectedSkill = skills.find((s) => s.filePath === selected) ?? null; diff --git a/lib/skills-service.test.mjs b/lib/skills-service.test.mjs index aba762156..621e7eb12 100644 --- a/lib/skills-service.test.mjs +++ b/lib/skills-service.test.mjs @@ -1,5 +1,5 @@ import assert from "node:assert/strict"; -import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { homedir, tmpdir } from "node:os"; import { join } from "node:path"; import test from "node:test"; @@ -113,13 +113,9 @@ test("scan roots cover the compat directories the app installs into", () => { test("discovery honors all three frontmatter spellings", async () => { const previousAgentDir = process.env.PI_CODING_AGENT_DIR; const previousClaudeDir = process.env.CLAUDE_CONFIG_DIR; - const previousOmpBin = process.env.OMP_WEB_OMP_BIN; const dir = mkdtempSync(join(tmpdir(), "omp-web-skill-scan-")); process.env.PI_CODING_AGENT_DIR = join(dir, ".omp", "agent"); process.env.CLAUDE_CONFIG_DIR = join(dir, ".claude"); - // A binary without `skill list` (node itself) fails the exec, so this - // exercises the replica-scan fallback regardless of the host's omp. - process.env.OMP_WEB_OMP_BIN = process.execPath; try { const fixtures = [ [join(process.env.PI_CODING_AGENT_DIR, "skills", "kebab"), "kebab", "disable-model-invocation: true\n", true], @@ -138,7 +134,9 @@ test("discovery honors all three frontmatter spellings", async () => { const cwd = join(dir, "project"); mkdirSync(cwd, { recursive: true }); - const { skills } = await discoverSkills(cwd); + // A binary without `skill list` (node itself) fails the exec, so this + // exercises the replica-scan fallback regardless of the host's omp. + const { skills } = await discoverSkills(cwd, process.execPath); const byName = new Map(skills.map((s) => [s.name, s])); const allowedRoots = new Set(getSkillScanRootDirs(cwd)); for (const [, name, , expected] of fixtures) { @@ -155,8 +153,31 @@ test("discovery honors all three frontmatter spellings", async () => { else process.env.PI_CODING_AGENT_DIR = previousAgentDir; if (previousClaudeDir === undefined) delete process.env.CLAUDE_CONFIG_DIR; else process.env.CLAUDE_CONFIG_DIR = previousClaudeDir; - if (previousOmpBin === undefined) delete process.env.OMP_WEB_OMP_BIN; - else process.env.OMP_WEB_OMP_BIN = previousOmpBin; + rmSync(dir, { recursive: true, force: true }); + } +}); + +test("discovery uses `omp skill list --json` when the binary supports it", async () => { + const dir = mkdtempSync(join(tmpdir(), "omp-web-skill-cli-")); + try { + const payload = join(dir, "payload.json"); + const argsOut = join(dir, "args.txt"); + writeFileSync(payload, JSON.stringify({ + skills: [{ name: "only-from-cli", description: "", filePath: join(dir, "x", "SKILL.md"), source: "native:user", hide: false }], + warnings: [], + })); + let bin; + if (process.platform === "win32") { + bin = join(dir, "omp.cmd"); + writeFileSync(bin, `@echo %*> "${argsOut}"\r\n@type "${payload}"\r\n`); + } else { + bin = join(dir, "omp"); + writeFileSync(bin, `#!/bin/sh\necho "$*" > '${argsOut}'\ncat '${payload}'\n`, { mode: 0o755 }); + } + const { skills } = await discoverSkills(dir, bin); + assert.deepEqual(skills.map((s) => s.name), ["only-from-cli"]); + assert.equal(readFileSync(argsOut, "utf8").trim(), `skill list ${dir} --json`); + } finally { rmSync(dir, { recursive: true, force: true }); } }); @@ -206,5 +227,6 @@ test("maps an `omp skill list --json` payload onto SkillInfo", () => { test("rejects a malformed `omp skill list --json` payload", () => { assert.equal(skillsFromCliPayload(null), undefined); assert.equal(skillsFromCliPayload("nope"), undefined); - assert.deepEqual(skillsFromCliPayload({ skills: "many", warnings: [] }), { skills: [], diagnostics: [] }); + assert.equal(skillsFromCliPayload({ skills: "many", warnings: [] }), undefined); + assert.equal(skillsFromCliPayload({ error: "x" }), undefined); }); diff --git a/lib/skills-service.ts b/lib/skills-service.ts index 5063781d2..855f798a6 100644 --- a/lib/skills-service.ts +++ b/lib/skills-service.ts @@ -4,7 +4,7 @@ import { homedir } from "os"; import * as path from "path"; import { promisify } from "util"; import { parse as parseYaml } from "yaml"; -import { resolveOmpBin } from "@/lib/omp/omp-cli"; +import { resolveOmpBin, wrapWindowsScript } from "@/lib/omp/omp-cli"; import { getAgentDir } from "@/lib/omp/paths"; import { isRecord } from "@/lib/type-guards"; import type { SkillInfo } from "@/lib/api-types"; @@ -253,8 +253,8 @@ const SOURCE_LABEL_BY_PROVIDER: Record = { * Returns undefined for anything that is not a skills data object. */ export function skillsFromCliPayload(data: unknown): SkillsWithDiagnostics | undefined { - if (!isRecord(data)) return undefined; - const rawSkills = Array.isArray(data.skills) ? data.skills : []; + if (!isRecord(data) || !Array.isArray(data.skills)) return undefined; + const rawSkills = data.skills; const rawWarnings = Array.isArray(data.warnings) ? data.warnings : []; const skills: SkillInfo[] = []; for (const raw of rawSkills) { @@ -294,13 +294,15 @@ const SKILLS_CLI_TIMEOUT_MS = 15_000; * when the binary predates the command, or on any exec/parse failure, letting * the caller fall back to the replica scan. */ -async function discoverSkillsViaCli(cwd: string): Promise { - const ompBin = resolveOmpBin(); +async function discoverSkillsViaCli(cwd: string, ompBin: string | null): Promise { if (!ompBin) return undefined; + // Windows .cmd/.bat launchers need cmd.exe, as in the version probe. + const target = wrapWindowsScript(ompBin, ["skill", "list", path.resolve(cwd), "--json"]); try { - const { stdout } = await execFileAsync(ompBin, ["skill", "list", cwd, "--json"], { + const { stdout } = await execFileAsync(target.file, target.args, { timeout: SKILLS_CLI_TIMEOUT_MS, maxBuffer: 16 * 1024 * 1024, + windowsHide: true, }); return skillsFromCliPayload(JSON.parse(stdout)); } catch { @@ -312,9 +314,12 @@ async function discoverSkillsViaCli(cwd: string): Promise { - const viaCli = await discoverSkillsViaCli(cwd); + * result is sorted by name. `ompBin` is a test seam. */ +export async function discoverSkills( + cwd: string, + ompBin: string | null = resolveOmpBin(), +): Promise { + const viaCli = await discoverSkillsViaCli(cwd, ompBin); if (viaCli) return viaCli; const diagnostics: SkillDiagnostic[] = []; const byName = new Map(); From 625f1880c45e45f1dd0ea272020b4c9c04fedaed Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Thu, 1 Oct 2026 15:36:41 +0000 Subject: [PATCH 4/7] fix(skills): authorize only the SKILL.md files omp lists Adding each listed skill's baseDir as a root also admitted unlisted SKILL.md files nested under it. Authorize the exact listed file paths. --- app/api/skills/route.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/api/skills/route.ts b/app/api/skills/route.ts index f3815669a..832c57089 100644 --- a/app/api/skills/route.ts +++ b/app/api/skills/route.ts @@ -53,7 +53,8 @@ export async function PATCH(req: Request) { for (const dir of getSkillScanRootDirs(scanCwd)) allowedRoots.add(dir); // omp's own listing also covers plugin, custom-directory and registry // skills outside the replica roots; anything it lists must be togglable. - if (scanCwd) for (const skill of (await discoverSkills(scanCwd)).skills) allowedRoots.add(skill.baseDir); + // Authorize exactly the listed SKILL.md files, not their whole dirs. + if (scanCwd) for (const skill of (await discoverSkills(scanCwd)).skills) allowedRoots.add(skill.filePath); // Resolve symlinks once up front and authorize the resolved path: the // read/write below then operate on the same resolved path, so a symlink // swapped between the authorization check and the write cannot redirect From be61232b67f58ee9ccc02afb8ccfdc63d9dc0c23 Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Thu, 1 Oct 2026 17:51:19 +0000 Subject: [PATCH 5/7] fix(skills): keep plugin skills read-only; address review Toggling rewrites SKILL.md frontmatter, omp's only per-skill "hide from model" knob. That is right for the user's own skills but not for files an installer owns (plugin packages, registry installs, custom dirs): an update discards the edit. Revert the PATCH widening to every skill omp lists; getSkillToggleRoots() is now the single allowlist for PATCH and a new `togglable` flag on GET, and the Skills page renders a disabled toggle with a localized hint for the rest. Review (kahme247/ompweb#110): - Fall back to the replica when listed entries exist but none parse, instead of rendering an empty list. - Negative-cache a failing `omp skill list` per binary fingerprint (5 min) so old or hung binaries are not spawned per request. - AGENTS.md describes the CLI listing, replica fallback and toggle rule. - Tests: PATCH 200/403 through the route, the toggle-root check, the miss cache, and partial-drift payloads. - Comment the hide <-> disable-model-invocation invariant. - Match lock entries by the bare name of namespaced collision aliases. --- AGENTS.md | 7 +-- CHANGELOG.md | 2 +- app/api/skills/route.ts | 28 +++++------ components/SkillsConfig.tsx | 16 ++++-- lib/api-types.ts | 3 ++ lib/i18n/locales/en.json | 1 + lib/i18n/locales/ja.json | 1 + lib/i18n/locales/zh-CN.json | 1 + lib/omp/omp-cli.ts | 3 +- lib/skill-lock.test.mjs | 3 ++ lib/skill-lock.ts | 7 ++- lib/skills-service.test.mjs | 98 ++++++++++++++++++++++++++++++++----- lib/skills-service.ts | 44 ++++++++++++++--- 13 files changed, 166 insertions(+), 48 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 048f56abf..949c2e78f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -103,7 +103,7 @@ lib/ session-reader.ts session .jsonl parsing + path cache + buildSessionContext session-resume.ts running-session list for auto-resume after a restart web-settings.ts omp-web server settings (~/.omp/agent/omp-web-settings.json) - skills-service.ts pure-Node skill discovery mirroring omp's providers + skills-service.ts skill listing via `omp skill list --json`; pure-Node replica scan as fallback tool-presets.ts PRESET_NONE/DEFAULT/FULL + getToolNamesForPreset() types.ts shared TypeScript types normalize.ts normalizeToolCalls() — field name mismatch between file format and our types @@ -362,8 +362,9 @@ handled or safely ignored. ### Plugins and skills - `/api/plugins` shells out to the user's `omp plugin` CLI (`list/install/uninstall/enable/disable/upgrade`, `--json` where available) — never the Bun-only SDK. -- `/api/skills` uses `lib/skills-service.ts`, a pure-Node scanner mirroring omp's discovery order: project `.omp/skills` (walk-up), `~/.omp/agent/skills`, then the `.claude` / `.agent(s)` / `.codex` / `.github` compat dirs and managed skills. -- Skill toggling edits only the `disable-model-invocation` frontmatter key on the target `SKILL.md`; keep that surgical so user formatting survives. +- `/api/skills` lists through `lib/skills-service.ts`, which execs `omp skill list --json` (omp ≥ 18.3.3) — the same discovery sessions use, including `namespace/name` collision aliases and plugin/registry/custom-directory skills. A pure-Node replica scan (project `.omp/skills` walk-up, `~/.omp/agent/skills`, the `.claude` / `.agent(s)` / `.codex` / `.github` compat dirs, managed skills) is only the fallback for older binaries and failed or malformed output. A failed binary is negative-cached per on-disk fingerprint (5 min) so old installs don't spawn per request. +- Skill toggling edits only the `disable-model-invocation` frontmatter key on the target `SKILL.md`; keep that surgical so user formatting survives. omp reports it back as `hide` (it reads `hide`/`disableModelInvocation`/`disable-model-invocation`). Frontmatter is omp's only per-skill "hide from model, keep `/skill:`" knob; `disabledExtensions: ["skill:"]` removes the skill entirely. +- Only user-owned skills are togglable: `getSkillToggleRoots()` (allowed file roots + replica scan roots) is the single allowlist for both PATCH and the `togglable` flag GET returns. Skills omp lists from elsewhere (plugin packages, registry installs, custom directories) render a disabled toggle — their files belong to an installer and an update would discard the edit. Never widen PATCH to whatever omp lists. - `/api/skills/install` shells through `npx skills add ... --agent universal`, which installs into the ecosystem-standard `.agents/skills` dirs omp reads; project installs run with the selected cwd. ### Update notifications (`/api/omp-update`, `/api/app-update`) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dfaea3dd..e9c94766b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f ### Fixes & Improvements -- The Skills page lists exactly what omp resolves, through `omp skill list --json` (omp 18.3.3 or later): plugin, custom-directory and registry skills appear, colliding names show as `namespace/name`, and every listed skill can be toggled. Older omp binaries keep the built-in scan. +- The Skills page lists exactly what omp resolves, through `omp skill list --json` (omp 18.3.3 or later): plugin, custom-directory and registry skills appear, and colliding names show as `namespace/name`. Skills that live outside omp-web's skill folders, such as plugin installs, show a disabled toggle because an update would undo the edit. Older omp binaries keep the built-in scan. - On phones, the top bar's **⋯** menu no longer repeats the session name already shown in the title, and its theme and language pickers open fully instead of being cut off at the bar's edge. - Keep **Collapse input** available after expanding a long user message with **Show full input**, so the message can be collapsed again. - Agent host tools (`open_url`, `notify`, `open_file`) no longer fail when you switch to another session mid-run. Any open omp-web tab now answers them, and a URL or file from a session you are not viewing opens only after you confirm it in a dialog. diff --git a/app/api/skills/route.ts b/app/api/skills/route.ts index 832c57089..2df37184e 100644 --- a/app/api/skills/route.ts +++ b/app/api/skills/route.ts @@ -2,8 +2,7 @@ import { NextResponse } from "next/server"; import { existsSync, readFileSync, realpathSync, writeFileSync } from "fs"; import { basename } from "path"; import { - discoverSkills, - getSkillScanRootDirs, + getSkillToggleRoots, loadSkillsWithInstallInfo, parseSkillFrontmatter, readDisableModelInvocation, @@ -14,8 +13,9 @@ import { getAllowedFileRoots, isExistingFilePathAllowed } from "@/lib/file-acces export const dynamic = "force-dynamic"; // GET /api/skills?cwd= -// Scans the same skill roots omp discovers (~/.omp/agent/skills, project -// .omp/skills, and the .claude/.agents/.codex/.github compat directories). +// Lists what omp resolves (`omp skill list --json`), falling back to a scan +// of omp's skill roots on binaries that predate the command. Each skill +// carries `togglable`, the same check PATCH applies. export async function GET(req: Request) { const { searchParams } = new URL(req.url); const cwd = searchParams.get("cwd"); @@ -42,19 +42,13 @@ export async function PATCH(req: Request) { return NextResponse.json({ error: "not a SKILL.md file", code: "not_a_skill_file" }, { status: 400 }); } if (!existsSync(filePath)) return NextResponse.json({ error: "file not found", code: "file_not_found" }, { status: 404 }); - // Every root the scanner reads must be writable here, or skills in the - // compat dirs (~/.agents/skills — where the app's own global installs land, - // ~/.claude/skills, ~/.codex/skills, managed-skills) could be listed but - // never toggled. Session cwds cover the project-scope roots. - const allowedRoots = new Set(await getAllowedFileRoots()); - // An optional cwd (already an allowed root) additionally covers the - // project walk-up roots discovery visits above the session directory. - const scanCwd = cwd && isExistingFilePathAllowed(cwd, allowedRoots) ? cwd : undefined; - for (const dir of getSkillScanRootDirs(scanCwd)) allowedRoots.add(dir); - // omp's own listing also covers plugin, custom-directory and registry - // skills outside the replica roots; anything it lists must be togglable. - // Authorize exactly the listed SKILL.md files, not their whole dirs. - if (scanCwd) for (const skill of (await discoverSkills(scanCwd)).skills) allowedRoots.add(skill.filePath); + // Every user-owned root the scanner reads must be writable here, or skills + // in the compat dirs (~/.agents/skills — where the app's own global + // installs land, ~/.claude/skills, ~/.codex/skills, managed-skills) could + // be listed but never toggled. Session cwds cover the project-scope roots; + // an optional cwd (already an allowed root) adds the project walk-up roots. + // Plugin/registry skills stay read-only (see getSkillToggleRoots). + const allowedRoots = await getSkillToggleRoots(cwd); // Resolve symlinks once up front and authorize the resolved path: the // read/write below then operate on the same resolved path, so a symlink // swapped between the authorization check and the write cannot redirect diff --git a/components/SkillsConfig.tsx b/components/SkillsConfig.tsx index a157299b8..64e971010 100644 --- a/components/SkillsConfig.tsx +++ b/components/SkillsConfig.tsx @@ -61,10 +61,12 @@ function shortVersion(version: string | undefined, t: (key: string) => string): function Toggle({ enabled, loading, + readOnly = false, onToggle, }: { enabled: boolean; loading: boolean; + readOnly?: boolean; onToggle: () => void; }) { const { t } = useI18n(); @@ -72,12 +74,14 @@ function Toggle({