fix(skill): resolve a skill name clash the same way on every load

Draft
KE
1d ago
+38-16

Issue for this PR

REPL-35247

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Replo sandboxes load skills from two folders: a person's own skills and their project's team skills. When both hold a skill with the same name, the person's own should win. Today the winner is random.

Two things caused that:

  1. loadSkills parsed and registered every SKILL.md concurrently. Each one wrote state.skills[name] when its parse finished, so the slower file won.
  2. In the sandbox, a person's skills sit in opencode's global ~/.agents/skills and the project's team skills in its project folder (OPENCODE_CONFIG_DIR=/workspace/.opencode, so .opencode/skills). opencode reads the global folders first, so in discovery order the team skill comes later and would win. Our opencode.json lists ~/.agents/skills again in skills.paths to put the person's folder last, but the matches set kept a file's first position, so listing it again changed nothing.

The fix:

  • Parse in parallel as before, then register the results in discovery order, so the same files always resolve the same way.
  • When a scan finds a file again, move it to its latest position. With skills.paths listing the personal folder, the personal skill is registered last and wins.

The "duplicate skill name" warning is unchanged.

How did you verify your code works?

  • A new test in test/skill/skill.test.ts puts brand-voice in .opencode/skills and in team/, with skills.paths: ["team", ".opencode/skills"], and expects the personal copy. It fails on dev (3 of 3 runs) and passes with the fix.
  • bun test test/skill/: 26 pass, 0 fail.
  • bun run typecheck is clean.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes skill name clashes so the personal skill always wins over a same-named team skill, instead of the winner being random on each load.

  • Parses in parallel but registers results in discovery order, so the same files always resolve the same way.
  • Moves a file found again during scanning to its latest source, so the source listed last in skills.paths wins.
  • Adds a test that verifies the personal copy of a clashing skill wins.