Honour `disable-model-invocation` and `user-invocable` in `Skills`, skip stray skill library paths, and find `clai2` repository skills from subdirectories

Merged
DO
2mo ago
+565-99

Covers the decision-free items from #10371, the post-merge review of Agent Skills in harness (#9802) and clai2 (#9803): items 1, 3, 5 (step 1 only), 6 and 8.

[!WARNING]
Compatibility impact: SkillCatalog.skipped (new in harness 0.56.0, released 2026-10-13) now holds SkippedSkill entries instead of strings. Code that compares entries with strings or calls str methods on them breaks. str(entry) and f-strings still give the old message.

Why this can ship in a minor release: Pydantic AI Harness is on 0.x, where the version policy allows API changes between minor releases. The field shipped two days ago, and the review flagged it as cheapest to change now.

Migration: read entry.message for the text, or entry.path and entry.reason instead of parsing it.

What changed, per item

  • 1. A bad library path no longer fails turns or turns skills off. With missing_directories='skip', a library path that is a file or holds a SKILL.md itself is now skipped with a UserWarning and a skipped entry instead of raising ValueError. 'error' still raises the same messages. In clai2, a stray .agents/skills/SKILL.md now prints one notice at startup and the other folders still load. If one appears mid-session, the next turn leaves it out instead of failing. The README's "turns skills off ... until the next /reload" now describes only an unreadable folder at startup, which is the only case that still does that.
  • 8. Structured SkillCatalog.skipped. Each entry is a frozen SkippedSkill(path, reason, message). reason is a SkipReason Literal: 'invalid', 'duplicate_name', 'not_a_directory' or 'skill_package'. Both new types are exported from pydantic_ai_harness.skills.
  • 3. Invocation frontmatter. Harness parses disable-model-invocation and user-invocable (YAML true/false, any letter case; any other value skips the skill as invalid) and exposes them as SkillDefinition.model_invocable and .user_invocable. Both are removed from the ignored-fields list. A run leaves skills with model_invocable=False out of the model's catalog, so there is no load_capability when those are the only skills. Skills.load still returns them for host commands. clai2 registers /commands only for user-invocable skills, and prints the "ignoring unsupported frontmatter fields" advice as a startup notice, since __main__.py hides library warnings.
  • 5, step 1. Subdirectory launches. CoderSettings.skill_libraries(parents=...) puts each relative folder in the launch directory first, then in each parent up to the git root, nearest first. prepare gets the parents from the new repository_directories, next to find_project_file, and stops at the first .git the same way. Outside a git repository, only the launch directory is searched, as before. There is no downward or nested discovery.
  • 6. /skill-name uses the current file. The command reloads the catalog when it runs, so it sends the current SKILL.md, using the same precedence the model's catalog uses. If the skill is gone, it says so, with the skip message when the file became invalid. If the file now has user-invocable: false, it says that instead.

Docs: docs/harness/skills.md and its README twin, the harness agent skill reference, the clai2 README, PLUGINS.md and the AGENTS.md file map.

Not in this PR (need a decision from @DouweM)

Item 2 (project vs personal precedence), item 4 (trust gate for project skills), item 5 step 2 (downward discovery), and items 7 and 9. Nothing here makes them harder. Item 5's walk adds parent folders right after each relative folder, so changing project/personal order (item 2) is still only a change to the folder list.

Verification

  • New regression tests in tests/harness/skills/test_skills.py and tests/clai2/test_coder_skills.py. I checked that each fails against main's source (8 harness, 9 clai2). The git-root and outside-a-repository guards pass both ways, as they should.
  • Focused branch coverage of skills/_loader.py and skills/_capability.py is 100%. The new coder.py and project_settings.py lines are covered too.
  • Single-file Pyright and repo-wide Ruff pass.
  • Manual check in tmux: launching clai2 in repo/sub/src found the repository's skills and printed the skill-package and ignored-frontmatter notices. /help listed the model-disabled skill but not the user-invocable: false one. /deploy after deleting its SKILL.md printed the "gone" message.

Checklist

  • No breaking changes in accordance with the version policy. (Harness 0.x; see the compatibility note above.)
  • Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver. (The API check doesn't cover harness, so there is no waiver.)
  • PR title is fit for the release changelog.

(Claude, Douwe's coding agent)