Skip to content

Skills: browse the organization's library, and add skills on the agent - #802

Draft
alex-clickhouse wants to merge 2 commits into
mainfrom
asoff/skills-p2-browse
Draft

alex-clickhouse wants to merge 2 commits into
mainfrom
asoff/skills-p2-browse

Conversation

@alex-clickhouse

Copy link
Copy Markdown
Collaborator

In external mode with an MCP gateway that offers a library, a person can now browse every skill that the organization offers, open its files, and add or remove a skill on this agent. The Skills page says how each library skill got on the agent. Standalone Nerve is unchanged.

What changes

  • Browse library, a new page at /library, reached from the Skills page: a search that runs after a short pause, a tag filter with the count of results for each tag, cards with tags, the release and "Used by N agents", pages, a read-only viewer of the files of an item, and Add or Remove.
  • Skills page: each library skill says "Installed by default", "Installed from the console" (with the link to the console) or "Added on this agent". An added item has Remove. An item whose files Nerve could not get shows Failed; before, it was not shown.
  • API under /api/skills/library/: browse, items/{id}, and PUT and DELETE of added/{id}. GET /api/skills has a library member.

How

  • Added items. The ids are rows of the new table library_added (migration v077), so the gateway process and a one-shot command such as nerve sync send the same list. Nerve sends them in the query parameter added of the document request: valid ids, in byte order, no repeat, at most 100.
  • An add or a remove stores the change, then forces a new read of the document and one skill scan, under one lock, so the scan of the last change runs last. A new add and a remove delete the stored on or off choice, so an added item starts on.
  • The document. Nerve serves the availability values available, default and required, and the installedBy values required, default, console and agent. An item whose installedBy does not go with its availability is left out. withdrawn is checked and kept; supersedes is not read. The report has the member pinned, false for every item.
  • Rebuilds. Live clients build again only when the served library skills change: an item that comes or goes, or a new id, version, digest, name or description. A change of tags, of withdrawn, or of the revision alone builds no client again.
  • Browse forwards a checked query to GET <mcp_gateway_url>/library/browse and checks the answer strictly. An answer that contradicts itself is refused; a result with an unknown kind or availability is left out, as in the document.
  • The detail of an item that is not on the agent asks the gateway at each request whether the organization offers it now (browse?id=). Its files come from its archive, fetched by digest, with the size, digest, entry type and path checks of an installed item. The cache holds bytes, never an offer.
  • No library, no change. While Nerve has no current or last good library document, every library route answers 404 no_library, sends nothing and changes nothing.
  • Locked instance. Add and remove are refused, as the on/off switch is.

Trust boundaries

  • The Nerve process parses all new input: the queries of the browser, the answers of the gateway, and archives. It holds the workspace and the agent's tools already. Each input is bounded and checked before use, no pattern is built from it, and library text is shown as text.
  • No error body of the gateway reaches the browser. Each gateway failure becomes an error code of Nerve (no_library, invalid_request, rate_limited, library_unavailable).
  • Known gap, as before this PR: the archive is unpacked in the Nerve process. A helper process without access to the workspace would limit a defect of the unpack code.

Rollout

Active only in external mode with a gateway that offers /library. A gateway that does not know added or /library/browse answers as "no library" or ignores the parameter; Nerve then shows no browser.

Verification

  • Two independent review rounds (all findings fixed) and an independent verification of the tip.
  • The full backend suite with a temporary home: 12,100 collected, 12,061 passed, 39 skipped, 0 failed. npm run build; npm test: 3,246 passed. The migration number check. ruff --select F: no new finding.
  • The contract fixtures (tests/fixtures/library/) are byte-for-byte copies of the examples of the gateway side.
  • Each rule was broken on purpose once, and a test failed each time.

Screenshots

Taken at an earlier commit of this branch; the pages look the same now. The images are on the branch asoff/skills-p2-browse-screenshots (images only, never merge).

Light Dark
Library browser, desktop
Item detail, desktop
Skills page, desktop
Library browser, phone
Item detail, phone
Skills page, phone

🤖 Generated with Claude Code

…er API

In external mode with an MCP gateway that offers a library, a person can add
an item that the organization offers on this agent, remove it again, and
search the whole library.

- The document request names the added items in the query parameter
  `added` (valid `@nerve/<slug>` ids, byte order, no repeat, at most 100).
  The ids are rows of the new table `library_added` (migration v077), so the
  gateway process and a one-shot command such as `nerve sync` send the same
  list. The parameter is not part of `library_url`, so the report URL stays
  as it is.
- Nerve serves the availability values `available`, `default` and
  `required`, and the installedBy values `required`, `default`, `console`
  and `agent`. An item whose installedBy does not go with its availability
  is left out. Each item has `withdrawn` (at most 20 versions below
  `version`, highest first), which Nerve checks and keeps; `supersedes` is
  not read. Tags must be in byte order with no repeat.
- `GatewayLibrary.refresh(force=True)` reads again after a read in progress,
  because that read can have started before an add or a remove. The forced
  read and the skill scan of one change of the added items run under one
  lock (`AgentEngine.library_added_changed`), so the scan of the last change
  runs last.
- Live clients build again only when the library skills of the scan change
  (an item that comes or goes, or a new id, version, digest, name or
  description). A change of tags, of `withdrawn`, of installedBy or of the
  revision alone builds no client again.
- The report has the member `pinned` after `digest`, `false` for every item.
- `nerve/skills/library_browse.py` sends the search to
  `GET <mcp_gateway_url>/library/browse`, checks the answer strictly within
  bounds, and maps each failure to an error code of Nerve (`no_library`,
  `invalid_request`, `rate_limited`, `library_unavailable`): no body of the
  gateway reaches the browser. An answer that contradicts itself (counts
  while `agentCounts` is false, more results than `total`, items on a page
  above `pages`) is refused; a result with an unknown kind or availability
  is left out, as in the document.
- The detail of an item that is not on the agent asks
  `GET /library/browse?id=<item id>` at each request, which gives only that
  item when the organization offers it now. Its files come from its
  archive, fetched by digest with the checks of an item of the document,
  into the same cache. The cache holds bytes, never an offer: an item that
  the organization stops offering gets 404 also when its files are cached.
  The detail of an item of the set has no use count.
- Routes under `/api/skills/library/`: `browse`, `items/{id}`, and `PUT` and
  `DELETE` of `added/{id}`. A new add and a remove delete the on or off
  choice of the item, so an added item starts on; a repeated add of an item
  that is added changes nothing. An add and a remove are refused on a
  locked instance and for an id that is not `@nerve/<slug>`; an add is also
  refused above 100 items. The browse route refuses an empty `page` and a
  parameter given twice with its own `400 invalid_request`. While Nerve has
  no current or last good library document (the gateway answers 404, or no
  read succeeded), every library route answers 404 `no_library` and reads
  and changes nothing. `GET /api/skills` has a `library` member (offered,
  managed_by, changes_allowed, added), and a row with `failed: true` for an
  item whose archive Nerve could not get. `/api/skills/library` with no
  further segment stays the detail of a workspace skill with the id
  `library`.

The fixtures document.json, report.json and browse.json are the examples
of the wire contract of the control plane, byte for byte. Nerve reads a
browse answer of at most 4 MiB. docs/config.md, docs/api.md and
docs/architecture.md describe the protocol, the routes and the design.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When `GET /api/skills` says that the MCP gateway offers a library, the
Skills page has **Browse library**, which opens the page `/library`. The
page is not below `/skills/`, so a workspace skill with the id `library`
keeps its detail page.

- The browser has a search field (the search runs 300 ms after the last key
  press), a tag filter with the count of results of each tag (at most 5
  tags), result cards with the tags, the release and "Used by N agents"
  (when the gateway has counts), and pages. A result says how it is on the
  agent ("Required", "Installed by default", "Installed from the console",
  "Added") or has **Add**, which is disabled on a locked instance with the
  reason. The name of a result opens a dialog with the files of the item in
  a read-only viewer, with **Add** or **Remove**, and the use count of the
  result. The page shows the results of the current query only: while a
  new search runs and after a failed one, no earlier result is shown.
- On the Skills page each library skill says how it got on the agent:
  "Installed by default", "Installed from the console" with the console
  link, or "Added on this agent". Every added item has **Remove**, also
  when a console install or the organization's setting supplies it now,
  and the text says that the install or the setting stays. An item whose
  files Nerve could not get shows the badge **Failed**, with no switch and
  no detail view; a required one still says who requires it. Added items
  that the organization does not offer now are listed under **Added, not
  offered now**, with **Remove**.
- Each error shows the `detail.message` of Nerve. A done add or remove
  shows on the page also when the reload of the list after it fails.

The specs assert roles, names and states. docs/web-ui.md describes the page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

AI review gate — Draft pull request — AI review not started

  • Cursor Bugbot does not review draft pull requests, so the gate cannot pass yet.

What to do:

  • Mark the pull request Ready for review. Bugbot then reviews it.
  • The bot re-runs this gate automatically when you mark the pull request ready or the review lands; or comment /ai-gate check.

Re-run the gate with “Re-run jobs” after an approval or a finished review. A push re-runs it automatically.

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.

1 participant