Skip to content

fix(tool): empty .opencode/tool/index.ts barrel to unblock opencode 1.14.49#316

Open
kunickiaj wants to merge 5 commits into
darrenhinde:mainfrom
kunickiaj:fix/tool-barrel-opencode-1.14.49
Open

fix(tool): empty .opencode/tool/index.ts barrel to unblock opencode 1.14.49#316
kunickiaj wants to merge 5 commits into
darrenhinde:mainfrom
kunickiaj:fix/tool-barrel-opencode-1.14.49

Conversation

@kunickiaj

Copy link
Copy Markdown

Summary

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 .opencode/tool/index.ts 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
  at SessionPrompt.run

For users this surfaces as Unexpected server error. Check server logs for details. on the very first prompt — opencode never even reaches the LLM call. opencode --print-logs run … is needed to see the underlying stack trace.

Why empty?

The barrel adds nothing functional:

  • opencode auto-discovers tools per-subdirectory (.opencode/tool/gemini/, .opencode/tool/template/).
  • Nothing in this repo imports from the barrel; tools are referenced via their subpaths.
  • scripts/registry/validate-registry.ts already explicitly skips tool/index.ts.

I tried keeping only the actual tool re-exports (dropping just the env helpers) — opencode 1.14.49 still crashes. The scanner appears to fail on any re-export from tool/index.ts, not just non-tool ones. So the barrel has to be empty (or removed) to be safe on 1.14.49+.

opencode 1.14.48 silently tolerated the same barrel, which is why this hasn't surfaced before.

Repro

# install latest opencode
curl -fsSL https://opencode.ai/install | bash
opencode --version  # 1.14.49

# from any directory with this repo's .opencode/tool/index.ts in scope:
opencode --print-logs run "ping"
# → "Unexpected server error" with the trace above

User-side workaround until merged:

echo 'export {}' > .opencode/tool/index.ts

Test plan

  • opencode 1.14.49 run ping fails with the existing tool/index.ts
  • Same command succeeds after applying this patch
  • Tool subdirectories (gemini, template) still auto-discovered and usable
  • No other code imports the barrel (grep across .opencode/, scripts/, docs/)

kunickiaj and others added 5 commits March 6, 2026 14:15
….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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant