Skip to content

feat(skills): list skills through the omp binary (omp skill list --json) - #110

Merged
kahme247 merged 7 commits into
ompweb-dev:mainfrom
andrebrait:feat/skills-list-cli
Oct 2, 2026
Merged

kahme247 merged 7 commits into
ompweb-dev:mainfrom
andrebrait:feat/skills-list-cli

Conversation

@andrebrait

@andrebrait andrebrait commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

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-invocation frontmatter, and PATCH /api/skills keeps main's allowlist logic, now in one helper (getSkillToggleRoots). The Skills page now sends its cwd, so the project walk-up roots that main's PATCH already accepted for a cwd apply 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 returns togglable: false for 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/name are 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 --json from can1357/oh-my-pi#12273, released in OMP v18.3.3; older binaries fall back to the pure-Node scan.

Testing

  • npx tsc --noEmit clean; ESLint clean on changed files; npm test: 923 pass, 0 fail, 4 skipped
  • lib/skills-service.test.mjs: stub-binary test proving the CLI path, its exact argv (skill list --json) and its working directory, using a project named a 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's togglable (owned and walk-up skills true, plugin skill false) with the shared allowed-roots cache left untouched; PATCH /api/skills through the route handler: owned → 200, plugin → 403 and untouched, walk-up skill 403 without a cwd and 200 with it, unallowed cwd → 403
  • Mutation check: each of these fails a test: no miss cache, miss cache ignoring cwd, no drift guard, togglable always true, mutating the shared roots set, dropping the cwd gate
  • lib/skill-lock.test.mjs: a namespace/name alias gets the same install annotation as its bare name
  • Live dev server (disposable agent dir) against omp 18.4.5: GET listed 111 skills, 110 of them togglable: false (all under ~/.omp/plugins/node_modules), and the ~/.agents/skills one togglable
  • Not visually verified: on main, the Settings Skills panel is not reachable (getNormalizedActive maps skills to mcp), so the disabled toggle could not be opened in a browser

  • npx tsc --noEmit passes
  • npm run lint passes (release build gate)
  • npm test passes

@andrebrait
andrebrait force-pushed the feat/skills-list-cli branch 4 times, most recently from 32ef790 to 9b35514 Compare September 28, 2026 13:09
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.
@andrebrait
andrebrait force-pushed the feat/skills-list-cli branch from 1b0e8b0 to 51020ee Compare October 1, 2026 00:10
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.
@andrebrait andrebrait changed the title feat(skills): list skills through the omp binary (skills --json) feat(skills): list skills through the omp binary (omp skill list --json) Oct 1, 2026
@andrebrait
andrebrait marked this pull request as ready for review October 1, 2026 15:14
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 kahme247 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. No negative caching (:302-306). Every GET /api/skills, /check, /update (×2) and every toggle (app/api/skills/route.ts:57) now spawns omp 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 hung omp blocks a skill toggle for 15s. A short negative cache keyed on the binary fingerprint (like getOmpVersion already does) fixes both.
  2. AGENTS.md not updated. The "Plugins and skills" section and the file map still say /api/skills uses 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.
  3. Zero automated coverage for the security-relevant line (app/api/skills/route.ts:57). No test file references /api/skills at all, and lib/skills-service.test.mjs:141-149 still claims to be "the exact check the PATCH route runs" — it no longer is.
  4. :268 — disableModelInvocation: raw.hide === true derives the toggle from omp's hide field while the PATCH writer persists disable-model-invocation frontmatter. Worth a one-line comment naming that invariant, since reader and writer now depend on it.
  5. 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.

Happy to re-review once #1 and #2 land.

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.
@andrebrait

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. All of it is addressed in be61232 and 477ab51.

Blocking: partially valid payload. skillsFromCliPayload now returns undefined when entries were present but none parsed, so {skills:[{name:"x", path:"..."}]} falls back to the replica scan. {skills: []} is still a valid empty answer. If some entries parse and others don't, the ones that parse are kept. That way one malformed entry doesn't hide every plugin skill.

1. Negative caching. A failed omp skill list is cached for 5 minutes. The key is the binary's on-disk fingerprint (the same one getOmpVersion uses) plus the cwd. An old or hung binary is spawned at most once per project per 5 minutes, and a binary update clears the cache. Keying by cwd matters: omp exits 1 for a project with an invalid .omp/config.yml, and a binary-only key would have pushed every other project onto the replica as well. The toggle no longer spawns omp at all (see below).

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 ~/.omp/plugins/node_modules, registry installs and custom directories. An installer owns those files and the next update would discard the edit. PATCH keeps main's allowlist logic, now in getSkillToggleRoots(), and GET uses the same helper to return togglable on each skill. The Skills page shows a disabled toggle for the rest, with a visible, localized reason. The tests go through the real PATCH handler: an owned skill returns 200, a plugin skill returns 403, a walk-up skill returns 403 without a cwd and 200 with one, and an unallowed cwd returns 403. Another test checks the GET flag and that the shared roots cache is not mutated. The stale "exact check the PATCH route runs" comment now checks getSkillToggleRoots(), so it is accurate again.

4. hide ↔ disable-model-invocation. There is now a comment at the mapping. omp normalizes the kebab key and reports hide for hide, disableModelInvocation and disable-model-invocation. I confirmed this against omp 18.4.5.

5. Namespaced lock lookup. annotateSkillsWithInstallInfo matches lock entries by the bare name, so agents/edge-tts gets edge-tts's install info. A test covers it.

Two other things worth knowing:

  • Listing runs omp's normal startup, so it has omp's side effects. For example, omp renames an unparseable config.yml aside, as a session would. This is documented in AGENTS.md.
  • On main the Settings Skills panel can't be reached (getNormalizedActive maps skills to mcp), so the disabled toggle could not be checked in a browser. GET's flags were verified against a live dev server: 110 of 111 skills on a plugin-heavy install come back read-only.

… 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.
@andrebrait

Copy link
Copy Markdown
Collaborator Author

Follow-up c0a9a22, from a bot review on the companion PR: with a Windows .cmd/.bat launcher, omp runs through cmd.exe, so a project directory passed as an argument could inject a command (e.g. a folder named x&calc). The directory is now the child's working directory instead (omp skill list --json lists the cwd when no dir is given), and the test uses a project named a b&echo pwned. CI is green on Ubuntu and Windows.

@kahme247 kahme247 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kahme247
kahme247 merged commit d035251 into ompweb-dev:main Oct 2, 2026
3 checks passed
@andrebrait
andrebrait deleted the feat/skills-list-cli branch October 2, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants