fix(skill): resolve a skill name clash the same way on every load
Draft
KE
1d ago+38+38+01234567890123456789-16-16-01234567890123456789
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:
loadSkillsparsed and registered everySKILL.mdconcurrently. Each one wrotestate.skills[name]when its parse finished, so the slower file won.- In the sandbox, a person's skills sit in opencode's global
~/.agents/skillsand 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. Ouropencode.jsonlists~/.agents/skillsagain inskills.pathsto put the person's folder last, but thematchesset 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.pathslisting 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.tsputsbrand-voicein.opencode/skillsand inteam/, withskills.paths: ["team", ".opencode/skills"], and expects the personal copy. It fails ondev(3 of 3 runs) and passes with the fix. bun test test/skill/: 26 pass, 0 fail.bun run typecheckis 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.pathswins. - Adds a test that verifies the personal copy of a clashing skill wins.