anomalyco / anomalyco/opencode
Skill discovery crashes with ENAMETOOLONG on symlink cycles
Open
@rekram1-node is already working on this.
Since Aug 28, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Problem
When a skill discovery directory (e.g. ~/.agents/skills) resolves to a path inside a source skill collection, ln -s creates a self-referential symlink. OpenCode's skill scanner follows it recursively and crashes with ENAMETOOLONG.
This happens because scan() in packages/opencode/src/skill/index.ts passes symlink: true to glob (which maps to follow: true), and there is no cycle detection or depth limit.
Reproduction
# clone a skills repo
git clone git@github.com:example/skills.git && cd skills
# make the discovery dir point into the source collection
ln -s "$PWD/skills" ~/.agents/skills
# create a skill link -- ln follows the directory symlink and
# creates skills/foo/foo pointing at itself
ln -s "$PWD/skills/foo" ~/.agents/skills/foo
# start opencode -- glob follows the cycle until ENAMETOOLONG
opencode
Suggested fix
Any of these would work (in order of simplicity):
- Add
maxDepthto the glob call. Skill bundles are shallow (skills/<name>/SKILL.md), so a depth of 3-4 prevents infinite traversal without changing behavior. - Catch
ENAMETOOLONGandELOOPin thescanfunction and skip the path with a warning. - Track visited realpaths before descending into each directory.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.