Expand description
skills.* JSON-RPC methods — the daemon’s SKILL CATALOG management
surface (issue #3449), backing the Foundry GUI’s Skills management tab.
Why: the GUI’s Agents tab (crate::agents::protocol) and Skills tab are
siblings in the same issue, but tcode’s skill model is genuinely
narrower than its agent model — worth stating explicitly rather than
papering over with a symmetric-looking API that implies a tier that
doesn’t exist. crate::skills::discover_skill_metadata (the ONLY
consumer of a project’s .claude/skills/, wired at run_task/
task::executor time) recognises exactly TWO tiers: the embedded/bundled
catalog (crate::assets::DEFAULT_SKILLS, trusty-mpm’s universal set
minus tm-* orchestration skills) and ONE project-scoped disk directory
(<project_root>/.claude/skills/<name>/SKILL.md) — there is NO
user-level ~/.claude/skills tier the way crate::agents::agents_dir
has for agents (skills::locate_skills_dir takes a project_root
directly; every call site passes the bound project’s root, never
$HOME). This module’s tier values are therefore "bundled" and
"project" ONLY — never "user" — and skills.create/skills.delete
require an actually-bound project (there is nowhere else on disk for a
projectless daemon to persist a user-added skill); a projectless caller
gets a clear -32003 invalid_argument, not a silent no-op or an
invented user-level path nothing else in this crate would ever read.
What: register wires three methods onto a shared, immutable
SkillsCatalogState (an Option<PathBuf> project skills dir — None
when projectless):
skills.list->{"skills": [{name, tier, description}]}— WHOLE- CATALOG REPLACEMENT, mirroringdiscover_skill_metadata’s ownif !skills.is_empty() { return skills }threshold (see that function’s docs) exactly, at the catalog level rather than per-name: when a project is bound and its disk skills directory has at least one entry, the response is ONLY those disk skills (tier: "project") — the bundled catalog is entirely absent, because that is what actually resolves attask.runtime (FsSkillResolverdiscards the whole bundled set the instant disk has anything). Otherwise (projectless, or a bound project with no/empty disk skills) the response is the full bundled catalog (tier: "bundled"). A per-name bundled-∪-disk overlay would be WRONG here — it would report bundled skills as available for a project whose realuse_skillcatalog resolves only its own custom entries (code-critic PR #3465 re-review, MEDIUM).skills.create{name, content}-> writes<skills_dir>/<name>/SKILL.mdfrom the caller-supplied Markdown+frontmatter body. Same name-validation contract asagents::protocol::validate_agent_name(shared, not reimplemented — see that function’s docs): rejects a name colliding with a bundled skill (-32001 permission_denied, 403) or an already-existing disk skill (-32009 already_exists, 409).-32003 invalid_argument(400) when projectless.skills.delete{name}-> removes<skills_dir>/<name>/recursively.-32002 not_found(404) absent;-32001 permission_denied(403) for a bundled name;-32003 invalid_argument(400) when projectless.
Test: tests::*.
Structs§
- Skills
Catalog State - Shared, immutable state every
skills.*handler in this module closes over: the project-scoped skills directory, orNonewhen projectless.
Functions§
- register
- Register
skills.list,skills.create,skills.deleteontorouter.