anomalyco / anomalyco/opencode
Custom tools in .opencode/tool that import .txt descriptions fail at runtime: ERR_UNKNOWN_FILE_EXTENSION
@jlongster is already working on this.
Since Sep 9, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
Custom tools placed in .opencode/tool/*.ts that import a .txt description file fail at runtime with ERR_UNKNOWN_FILE_EXTENSION, breaking every prompt in the session (the error fires before the request reaches the model).
Repro
The repo itself ships two custom tools that do this:
.opencode/tool/github-triage.ts→import DESCRIPTION from "./github-triage.txt".opencode/tool/github-pr-search.ts→import DESCRIPTION from "./github-pr-search.txt"
With those files present, any chat in the repo fails with:
prompt_async failed: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".txt" for C:\work\opencode\.opencode\tool\github-triage.txt
Root cause
Built-in tools do the same import (packages/opencode/src/tool/glob.ts → import DESCRIPTION from "./glob.txt"), but those are compiled by the build toolchain, which inlines the .txt. Custom tools in .opencode/tool/ are loaded at runtime via dynamic import() in packages/opencode/src/tool/registry.ts (line 46), and the runtime cannot resolve .txt imports → the whole prompt fails.
Workaround
Inline the description as a string constant in the .ts file and drop the .txt import (verified working locally).
Suggested fix
Either:
- Document that custom tools must inline descriptions (and fix the repo's own two tools), or
- Make the runtime loader support
.txtimports for custom tools (e.g., a loader hook that reads the file as text), matching what the build does for built-in tools.
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.