diff --git a/AGENTS.md b/AGENTS.md index 048f56abf..0b0762ab3 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` with the project as the process cwd (omp ≥ 18.3.3; never pass the directory as an argument — Windows `.cmd` launchers run through `cmd.exe`, which would interpret `&` in it). That is 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 run is negative-cached per binary fingerprint **and cwd** (5 min) so old installs don't spawn per request while one broken project config cannot degrade the others. Listing runs omp's normal startup, so it has omp's side effects (e.g. omp renames an unparseable `config.yml` aside, as a session would). +- 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 — workspaces the user opened — plus replica scan roots) is the single allowlist for both PATCH and the `togglable` flag GET returns; it is `main`'s pre-CLI allowlist, unchanged. Skills omp lists from anywhere else (the plugin cache, registry installs, custom directories outside a workspace) 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 38b92f011..e9c94766b 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, 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 313c64b1c..2df37184e 100644 --- a/app/api/skills/route.ts +++ b/app/api/skills/route.ts @@ -2,7 +2,7 @@ import { NextResponse } from "next/server"; import { existsSync, readFileSync, realpathSync, writeFileSync } from "fs"; import { basename } from "path"; import { - getSkillScanRootDirs, + getSkillToggleRoots, loadSkillsWithInstallInfo, parseSkillFrontmatter, readDisableModelInvocation, @@ -13,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"); @@ -41,15 +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); + // 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 c2cba45fe..6f88b9d80 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({