fix(tool): empty .opencode/tool/index.ts barrel to unblock opencode 1.14.49#316
Open
kunickiaj wants to merge 5 commits into
Open
fix(tool): empty .opencode/tool/index.ts barrel to unblock opencode 1.14.49#316kunickiaj wants to merge 5 commits into
kunickiaj wants to merge 5 commits into
Conversation
….14.49
opencode 1.14.49 introduced a regression in ToolRegistry.state() that
calls Object.entries() on the result of scanning each .opencode/tool/*.ts
file. The current barrel re-exports from ./gemini and ./env, which
opencode tries to register as tools and crashes with:
TypeError: Object.entries requires that input parameter not be null or undefined
at ToolRegistry.state
at ToolRegistry.all
at ToolRegistry.tools
at SessionPrompt.resolveTools
This surfaces to users as "Unexpected server error. Check server logs
for details." on the very first prompt — opencode never even gets to
the LLM call.
The barrel adds nothing functional: opencode auto-discovers tools per
subdirectory (.opencode/tool/gemini/, .opencode/tool/template/) and
nothing else in this repo imports from the barrel. validate-registry.ts
already explicitly skips tool/index.ts. Empty it so it stops crashing
opencode while remaining a no-op marker file.
Repro:
opencode --version # 1.14.49
cd <project with .opencode/tool/index.ts that re-exports>
opencode run ping
# → "Unexpected server error" with the trace above in --print-logs
Workaround for users on older fork versions:
echo 'export {}' > .opencode/tool/index.ts
opencode 1.14.48 silently tolerated the same barrel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
opencode1.14.49 introduced a regression inToolRegistry.state()that callsObject.entries()on the result of scanning each.opencode/tool/*.tsfile. The current.opencode/tool/index.tsre-exports from./geminiand./env, whichopencodetries to register as tools and crashes with:For users this surfaces as
Unexpected server error. Check server logs for details.on the very first prompt —opencodenever even reaches the LLM call.opencode --print-logs run …is needed to see the underlying stack trace.Why empty?
The barrel adds nothing functional:
opencodeauto-discovers tools per-subdirectory (.opencode/tool/gemini/,.opencode/tool/template/).scripts/registry/validate-registry.tsalready explicitly skipstool/index.ts.I tried keeping only the actual tool re-exports (dropping just the env helpers) —
opencode1.14.49 still crashes. The scanner appears to fail on any re-export fromtool/index.ts, not just non-tool ones. So the barrel has to be empty (or removed) to be safe on 1.14.49+.opencode1.14.48 silently tolerated the same barrel, which is why this hasn't surfaced before.Repro
User-side workaround until merged:
Test plan
opencode 1.14.49 run pingfails with the existingtool/index.tsgemini,template) still auto-discovered and usablegrepacross.opencode/,scripts/,docs/)