fix(anthropic-subscription): rewrite skill_roots entries to Claude skill dirs

Merged
CO
4d ago
+163-11

Fixes #4518

What

rewriteSkillsLocations (Claude subscription lane, preset-append) rewrites the <rN> entries of the catalog's <skill_roots> table again:

  • a root at or under the global skills root becomes ~/.claude/skills[/<sub>], one at or under the project skills root becomes .claude/skills[/<sub>]; every other root is untouched;
  • this covers both the XML catalog and the one-line catalog from #4456, because both resolve rN through the same table;
  • the absolute <location> rewrite for a catalog without the table is kept;
  • roots are matched by path containment (path.relative), so a sibling directory such as <agent>/skills-extra is no longer treated as inside skills (the old startsWith check had no boundary).

Tests

RED -> GREEN test/suite/regressions/4518-subscription-skill-roots-rewrite.test.ts (renders a real catalog with formatSkillsForPrompt, runs it through buildAnthropicSubscriptionQueryOptions, reads the appended <skill_roots>):

  • XML catalog with a roots table: global and project roots rewritten, unrelated roots untouched: RED on main (roots kept as <agent>/skills, <cwd>/.senpi/skills) -> GREEN
  • one-line catalog: ... (101 skills): RED on main -> GREEN
  • legacy XML catalog with absolute locations: ...: green before and after (kept behavior)

Rows cover the global root, a nested global root (skills/team), the project root, an unrelated plugin root, and the skills-extra sibling.

Push gates (each its own process via gated-push, all rc=0 at this head): git diff --check origin/main...HEAD; bun run check; the new test plus test/anthropic-subscription-options.test.ts and test/anthropic-subscription-project-instructions.test.ts (3 files, 67 tests); node scripts/check-pr-changelog.mjs --base origin/main.


Summary by cubic

Fixes the Claude subscription lane's skill-roots rewrite so catalogs that list their roots in the <skill_roots> table—both the XML and the one-line format—point at ~/.claude/skills and .claude/skills again. The old rewrite only touched absolute <location> paths, so these catalogs kept senpi's own skill paths (#4518).

  • Rewrites <rN> entries for roots at or under the global or project skills root, keeping the path below the root; all other roots are untouched.
  • Matches roots by path containment, so a sibling directory like skills-extra is no longer treated as inside skills.
  • Keeps the absolute <location> rewrite for catalogs without the table.
  • Adds a regression test covering the XML catalog, the one-line catalog, and the legacy absolute-location case.