Repository navigation
feat(skills): list skills through the omp binary (omp skill list --json) - #110
Conversation
32ef790 to
9b35514
Compare
9b35514 to
1b0e8b0
Compare
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.
1b0e8b0 to
51020ee
Compare
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.
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.
Adding each listed skill's baseDir as a root also admitted unlisted SKILL.md files nested under it. Authorize the exact listed file paths.
kahme247
left a comment
There was a problem hiding this comment.
Review: changes requested (1 major)
Thanks for the careful exec work — argv array with no shell interpolation, wrapWindowsScript for .cmd/.bat on win32, timeout + maxBuffer + windowsHide, and graceful degradation to the replica scan on every failure path are all correct, and the pure-Node fallback is not regressed.
Blocking — lib/skills-service.ts:261 + :322
skillsFromCliPayload continues past any entry lacking a string name/filePath, but discoverSkills only falls back when the function returns undefined. A payload whose shape drifts upstream therefore yields {skills: [], diagnostics: []} — which is truthy and silently shadows the replica scan: the Skills page renders empty, with no error and no fallback.
Concretely: {skills:[{name:"x", path:"..."}]} (upstream renames filePath → path) returns an empty-but-defined list, not undefined. Note {skills:"many"} is handled correctly; only the partially-valid case leaks.
Fix: return undefined when rawSkills.length > 0 but nothing survived validation. An empty list is still a legitimate answer — the guard must be "we dropped things", not "we got nothing".
Also worth folding in
- No negative caching (
:302-306). EveryGET /api/skills,/check,/update(×2) and every toggle (app/api/skills/route.ts:57) now spawnsomp skill list. On a binary predating the command that is a guaranteed failing spawn per request, forever. Worse, the 15s timeout is paid inline in the PATCH handler before the authorization check, so a hungompblocks a skill toggle for 15s. A short negative cache keyed on the binary fingerprint (likegetOmpVersionalready does) fixes both. - AGENTS.md not updated. The "Plugins and skills" section and the file map still say
/api/skillsuses a "pure-Node scanner mirroring omp's discovery order". After this PR the scanner is a fallback. AGENTS.md is the porting contract — please update it in the same PR. - Zero automated coverage for the security-relevant line (
app/api/skills/route.ts:57). No test file references/api/skillsat all, andlib/skills-service.test.mjs:141-149still claims to be "the exact check the PATCH route runs" — it no longer is. :268—disableModelInvocation: raw.hide === truederives the toggle from omp'shidefield while the PATCH writer persistsdisable-model-invocationfrontmatter. Worth a one-line comment naming that invariant, since reader and writer now depend on it.- Nit
:269/lib/skill-lock.ts:57-61: omp's collision names are namespaced (superpowers/test-driven-development) but lock annotation matches on exact name, so update affordances vanish for exactly the namespaced skills this PR surfaces.
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 (#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.
- One project whose config omp rejects no longer hides omp's listing for every project: misses are keyed by binary fingerprint and cwd. - Realpath the toggle roots once per listing instead of once per skill (existingPathWithinRootsChecker); hundreds of session roots made GET block the event loop. - Show the read-only reason as visible text, not only a disabled button's title. - Tests: GET's togglable flag, the shared roots cache staying untouched, PATCH with and without a cwd (walk-up roots, unallowed cwd), and the miss cache per cwd and across its TTL.
|
Thanks for the review. All of it is addressed in be61232 and 477ab51. Blocking: partially valid payload. 1. Negative caching. A failed 2. AGENTS.md. The file map and the "Plugins and skills" section now describe the CLI listing, the replica fallback, the miss cache and the toggle rule. 3. Coverage for the security-relevant line. That line is gone. I dropped the PATCH widening: authorizing every file omp lists would mean rewriting files under 4. 5. Namespaced lock lookup. Two other things worth knowing:
|
… arg On Windows a .cmd/.bat omp launcher runs through cmd.exe, which would interpret '&' and friends in an argument; a project directory named that way could inject a command. Pass the directory as the child's cwd, which `omp skill list` uses when no dir is given. Test with a project named 'a b&echo pwned'. Also state the toggle ownership rule precisely: it is main's allowlist, and workspaces the user opened count as user-owned.
|
Follow-up c0a9a22, from a bot review on the companion PR: with a Windows |
kahme247
left a comment
There was a problem hiding this comment.
Re-reviewed at head c0a9a22. The MAJOR is resolved: lib/skills-service.ts:277 now returns undefined when entries were dropped, so the replica scan is no longer shadowed (verified end-to-end - a malformed omp payload falls back to the replica skill rather than an empty page). Both MINORs are also addressed: PATCH now uses getSkillToggleRoots (pure Node, no 15s spawn before the authz check), AGENTS.md documents CLI-primary/replica-fallback, and route + regression coverage exists. c0a9a22 passing the directory as process cwd rather than argv is a real hardening against cmd.exe metacharacters. Checks green. One caveat noted for follow-up: the local omp is 18.2.11 and has no 'skill list' action, so the cwd assumption should get one manual smoke test on omp >= 18.3.3. Merging.
What
The skills page now asks the omp binary for its listing:
omp skill list --json, run with the project as its working directory, uses the same discovery sessions use and is parsed into the app's SkillInfo shape (omp's{ skillPath, message }warnings become skill diagnostics). The pure-Node scan stays only as a fallback for installs whose binary predates the command.Toggling still rewrites
disable-model-invocationfrontmatter, andPATCH /api/skillskeepsmain's allowlist logic, now in one helper (getSkillToggleRoots). The Skills page now sends its cwd, so the project walk-up roots thatmain's PATCH already accepted for acwdapply too. Frontmatter is omp's only per-skill "hide from the model, keep/skill:" setting;disabledExtensions: ["skill:<name>"]removes a skill entirely. Skills that omp lists from outside the user's skill folders (plugin packages, registry installs, custom directories) are read-only. Their files belong to an installer, and an update would discard the edit. GET returnstogglable: falsefor them, and the Skills page renders a disabled toggle with a localized hint (en/ja/zh-CN).Why
The page is a pre-session surface: it must list skills with no running session, so a session-keyed source could not be relied on, and the replicated scan rules drift from omp's actual discovery (name-collision namespaces being the concrete case: skills that omp resolves as
namespace/nameare invisible to the replica). Keying the listing on binary capability instead of session liveness keeps the source stable per install, and every exec re-reads disk, so installs, uninstalls and toggles show immediately.Uses
omp skill list --jsonfrom can1357/oh-my-pi#12273, released in OMP v18.3.3; older binaries fall back to the pure-Node scan.Testing
npx tsc --noEmitclean; ESLint clean on changed files;npm test: 923 pass, 0 fail, 4 skippedlib/skills-service.test.mjs: stub-binary test proving the CLI path, its exact argv (skill list --json) and its working directory, using a project nameda b&echo pwned; miss cache: a stub failing for one project is spawned once across two requests, another project still gets omp's listing, and it is probed again after the TTL and after the binary changes; payload mapping, including entries present but none parseable → fallback while{skills: []}stays an answer; GET'stogglable(owned and walk-up skills true, plugin skill false) with the shared allowed-roots cache left untouched;PATCH /api/skillsthrough the route handler: owned → 200, plugin → 403 and untouched, walk-up skill 403 without a cwd and 200 with it, unallowed cwd → 403togglablealways true, mutating the shared roots set, dropping the cwd gatelib/skill-lock.test.mjs: anamespace/namealias gets the same install annotation as its bare nametogglable: false(all under~/.omp/plugins/node_modules), and the~/.agents/skillsone togglablemain, the Settings Skills panel is not reachable (getNormalizedActivemapsskillstomcp), so the disabled toggle could not be opened in a browsernpx tsc --noEmitpassesnpm run lintpasses (release build gate)npm testpasses