Skip to content

About

Private skill discovery gateway for Codex and MCP clients

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Skills MCP plugin

Clients for the hosted skills MCP at https://skills.inhouse.works/mcp, the only skill source: a BB plugin (composer mentions and per-message selection), a Pi extension, and a Codex plugin. The hosted catalog lives in robertsinke/skills. There is no local skill library or fallback: when the hosted server is unreachable these clients fail with a clear error.

What it provides

  • TypeScript search, ranking, exact-name lookup, and holdout scoring.
  • A prompt hook that returns a short skill shortlist.
  • MCP tools for searching and reading skills.
  • A BB plugin (bb skills-mcp) that adds one advisory skill tag per message and serves ~ composer mentions.
  • Optional Codex plugin packaging with an MCP Apps result widget.

The repository contains the gateway code and public test fixtures. Your personal skill library stays outside the repository. Runtime roots are selected from SKILL_GATEWAY_ROOT, the local skills-manager directory, and the standard agent skill directories. See the code map for module ownership and change-impact paths.

Local setup

Requirements: Node.js 22 or newer.

npm install
npm run build
npm test

The old loopback MCP server (127.0.0.1:8742, npm run start:mcp:http) is retired and no longer run. Its code stays for tests and the legacy Codex pointers.

Codex plugin

The local marketplace and plugin package live under .agents/plugins/. From the repository root:

codex plugin marketplace add "$PWD"
codex plugin add skill-gateway@skill-gateway-local

Set SKILL_GATEWAY_ROOT to this checkout before starting the MCP server or using the prompt hook.

Offline runtime experiments

npm run eval:skill-runtime -- --output <fresh-private-directory> creates a local audit and frozen baseline. npm run eval:skill-runtime:batch prepares paired wording batches, registers prospective windows, and previews scoring locally. External scoring requires a separate exact-batch approval plus --execute. --batch <directory> --report --output <fresh-private-directory> produces a local paired report with regression checks and session-cluster uncertainty; prospective reporting finalizes that batch. No offline report activates a change. See the experiment workflow for commands, privacy boundaries, and safe resume behavior. npm run eval:skill-rerank evaluates explicit per-skill labels, joins recorded live selections, and checks cutoff calibration with entire sessions held out; see the reranker evaluation and trial.

Prompt injection gate

The prompt hook searches the local library first, then sends the current user prompt and up to five candidate names/descriptions (not local paths or full history) to TypeSafe Jev jev-1.13.0. It injects the shortlist only when the Noul probability is at least 0.5; no search hits or a gate error/timeout means no injection. The API key is read from the local secret store. Calls are billed and send prompt text to TypeSafe. The gate times out after 6.5 seconds to stay within the configured 10-second host-hook deadline. Set SKILL_GATEWAY_GATE_MODE=off to bypass the gate and restore unfiltered shortlist injection as a rollback.

Pi now uses the original Jev skill-suggestion trial through a personal default-on loader. It ranks the whole roster and adds one ignorable relevance tag, or none; its active session bypasses the legacy prompt hook below.

Reading hosted skills

Pi, the BB composer mentions and the hosted catalog read skills through the MCP skills extension: skills/list for names, descriptions and URIs (paged, 100 per page), and resources/read on a skill://…/SKILL.md URI for the text. The shared client is src/skills-extension.ts; bb-plugin/skills-extension.ts is an identical copy because the plugin cannot import from outside its directory (a test keeps them equal). The server still offers list_skills and load_skill to clients that do not announce the extension.

BB-owned selection

Selection can live in BB instead of the harness: the BB plugin owns the decision, and a host adapter keeps its provider's skill roster and passes on one ignorable tag. Today the adapter is Pi (--jev-via-bb), which covers Codex models and Cursor ACP because both run through Pi.

The flow is one request per user message: Pi posts the prompt to POST /api/v1/plugins/skills-mcp/http/select, the plugin runs dist/select.js on the BB server, and the gateway calls suggest_skills on the Inhouse skills MCP. It injects the first suggestion as one advisory tag and lists other suggestions in the result reason. The adapter leaves Pi's native skill roster in place. On missing credentials, network errors, HTTP errors, invalid responses, or timeout, selection fails with an error and adds no tag; nothing is ranked locally. A valid empty response adds no tag. The prompt is sent to the MCP service.

The selector reads ~/.config/skills-mcp/api_key and ~/.config/skills-mcp/cf_access (header lines, environment assignments, or two unlabeled lines). SKILLS_MCP_URL overrides https://skills.inhouse.works/mcp. The call has a seven-second total timeout. Explicit skill mentions bypass selection.

cd bb-plugin && bb plugin install . --yes      # then: bb plugin token skills-mcp
pi --jev-via-bb                                # default; one selector runs

The BB plugin no longer registers a Skills MCP panel. Composer mentions use https://skills.inhouse.works/mcp. Manage skills at https://skills.inhouse.works. The plugin does not start or stop the old dashboard listener. A listener that is already running is left to whoever started it.

Seeing what was suggested

The composer chip and the Selection panel read the dashboard listener, so both are retired with that panel. Selection still appends one gate_decision row to the local ledger. Pi keeps its hosted catalog status and /skill-gate view.

Cursor models keep their own roster

Cursor's agent process advertises its own skills, and Pi cannot suppress that from the adapter: measured with a sentinel skill, cursor-agent listed it by name in a plain run, and CURSOR_CONFIG_DIR isolation still listed every skill. Only an isolated HOME removes them, which also removes authentication. Hiding one skill does work: adding disable-model-invocation: true to its SKILL.md dropped it from the roster while the other sentinel stayed. Pi keeps the roster it serves. Cursor models still list their own skills as well, which this adapter does not control.

The selection core is src/select.ts (selectSkill, plus the select.js stdin entrypoint). Rebuild with npm run build and redeploy dist/ before relying on it: the plugin shells out to ~/.local/share/skill-gateway/dist/select.js by default. Both the entrypoint and the library are read on the BB server machine, so a thread whose Pi session runs on another host needs that host's files shared first. Roll back with --jev-via-bb=false (local chooser returns) or bb plugin disable skills-mcp.

The legacy prompt hook retains a per-skill reranking experiment in the local hooks manifest. When not bypassed by the original-Jev trial, it uses a stable 50/50 session split: control retains the gated shortlist; the approved conservative treatment uses relevance-v2 at 0.1. This remains exploratory, not independently validated evidence of improved selection. See the rerank experiment notes for decision framing, limitations, logged signals, and privacy.

Gate decisions are appended to local, mode-0600 usage-events.jsonl: candidate names and retrieval scores, pass/reject/error, probability, threshold, latency, request-size/token/cost metrics, session/turn IDs, and a prompt hash (not the prompt itself). A PostToolUse observer registered in ~/.hooks/manifest.json records verified reads/invocations of library SKILL.md files as skill_load events for Claude Code, Codex, and OpenCode; it stores only the skill name and correlation IDs, not file paths, tool arguments, or output. The Pi extension records reads against the exact active user-message turn because queued messages do not start a new agent run; the generic hook skips Pi to avoid attaching those reads to the prior run ID. Other runtimes need equivalent adapters before their loads are counted. Existing queries.jsonl retains the prompt and follow-up/reaction fields and is mode-0600; the learning dataset excludes follow-ups and reactions.

In Pi, the footer status shows the gate decision, Jev's single any_skill probability, injected count, input-token usage, cumulative calculated cost across the configured local usage-event log, and top local retrieval ranks (these are not per-skill Jev scores). That total adds gate-decision list costs and rerank request costs; it is the log total, not this turn's charge. A ~ on the cumulative amount means at least one included request cost was estimated. When the decision records an experiment arm, the footer also shows rerank control or the treatment's selected count. At agent start, the Rate injected skills row appears above the editor; it refreshes when queued/steered user messages are delivered, after skill reads, and at turn end. An unanswered prior-turn form remains in its own row until rated or a fresh run begins. Queued messages bypass before_agent_start, so their feedback rows are explicitly marked not_evaluated (no gate ran and no skills were injected) rather than being attributed to the previous prompt. For mid-run queued inputs, Pi-expanded text is matched to its mirror by delivery order and the delivered text is recorded for that exact turn; at a fresh gated start, unmatched stale mirrors are discarded. The form first asks whether any skills should have been injected at all, then lets you label each exact injected skill as relevant, not relevant, or unsure; skipping leaves it unknown. The overall question also appears when no skills were injected. /skill-feedback provides the keyboard path (mouse clicks are handled in fullscreen TUI). The row also shows which injected skills the agent explicitly read; verified reads are an automatic behavior proxy for relevance, not ground truth or a replacement for your labels. /skill-gate opens a scrollable view of the current request reconstruction, this request's cost, the same log total, and token metrics. Prompt text is held in extension memory for that view and is not added to usage-events.jsonl; candidate descriptions are reconstructed from the current local library, and the request body is hidden if its candidate list no longer matches the recorded shortlist. Jev-reported token usage is used when returned; otherwise the view labels a rough byte-based estimate. Cost uses TypeSafe's published Jev 1.13 rate of $0.042 per million input tokens; output tokens are free. The cost is calculated from reported or estimated input tokens, not copied from a provider invoice. Source: TypeSafe models and pricing.

npm run build:usage-dataset joins gate decisions, verified loads, queries, and explicit feedback only by exact user/session/turn IDs. It writes ~/.local/share/skill-gateway/usage-turn-dataset-v5.jsonl and metadata with mode 0600. Each row keeps the agent's verified reads separate from the user's overall injection decision and per-injected-skill relevance labels; reads are a behavior proxy, while labels are human judgments. Legacy coarse and interim skill-need labels are retained as legacy fields, not reinterpreted. Passive reactions and follow-ups remain excluded; prior v1/v2/v3/v4 artifacts are left untouched. The Pi hooks-use bridge supplies run-start turn IDs; the Pi extension assigns exact IDs to queued messages and records their verified skill reads itself. Queued-message gate rows use not_evaluated, which is not counted as an evaluated gate decision. Older records missing turn IDs are counted as unlinked, not guessed into turns.

The local MCP tools search_turns and update_turns support exact-turn search, an overall injection decision, and per-skill relevance labels. Search reads local event/query/feedback JSONLs and reuses the exact user/session/turn join, returning IDs and gate/load/label metadata—not stored prompt or comment text. Update appends a feedback snapshot to ~/.local/share/skill-gateway/skill-usage-feedback.jsonl with mode 0600, preserving raw logs. User relevance labels must match exact injected skill names; verified agent reads and explicit user relevance remain distinct. Exact injected skills marked unwanted and exact verified loads marked unwanted remain separate labels. Legacy coarse ratings and prior skill-need feedback are retained under legacy fields, not recoded. The private v5 dataset joins the overall injection decision, per-skill labels, and optional comments; later snapshots replace the current label state without deleting history. The globally deployed skill-usage-feedback skill directly uses search_turns and update_turns from the existing skill_gateway MCP server; no additional skill-loading step is required. Pi and the Codex plugin register the same server as skill_gateway.

For hosts without the Skill Gateway MCP connection, the same search/update logic is available through the local CLI at ~/.local/share/skill-gateway/dist/skill-usage-feedback-cli.js; pass a JSON object on stdin (search - or update -). The CLI returns sanitized JSON, and update writes only the private feedback snapshot. Rebuild and deploy after source changes; restart the MCP host to expose updated MCP tool definitions.

Pi cache-prefix experiment

A controlled Pi run used openai-codex/gpt-6-luna, identical synthetic prompts and a fixed cache key. The treatment added a 1,307-character synthetic before_agent_start custom message, matching the observed injection size without sending user history or skill descriptions. Cache-read share is cacheRead / (cacheRead + input) from Pi's usage record. On repeated requests:

Case Cached-read tokens Uncached input tokens Cache-read share
No injected context 8,960 198 97.8%
Injected context 8,960 417 95.5%

The injection added 219 uncached tokens; the cached prefix stayed at 8,960. In this test, it lowered the cache-read share by 2.3 percentage points by enlarging the uncached suffix, not by flushing the prefix. This confirms Pi's before_agent_start custom-message path preserves the prefix for this model and setup; it is not a measurement of real-session hit rates.

Keeping the library private

The local library and query log are ignored by Git. Before making a repository public, scan the working tree and history for credentials, personal paths, and private skill content. Never commit .env files, tokens, or copied skill-library directories.

License

Add a license before distributing this repository.

About

Private skill discovery gateway for Codex and MCP clients

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages