feat(opencode): extend NativeToolEngine in OpenCodeEngine#1026
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
nhopeatall
left a comment
There was a problem hiding this comment.
Summary
Clean migration of OpenCodeEngine from implements AgentEngine to extends NativeToolEngine. The abstract method implementations are correct, the removed filterProcessEnv has no remaining consumers, CI is green, and the change follows the same pattern established by the Codex engine migration.
Should Fix (non-blocking)
-
Duplicate env allowlist (
src/backends/opencode/index.ts:420-436/src/backends/opencode/env.ts:15-25):getAllowedEnvExact()in the engine class andALLOWED_ENV_EXACTinenv.tsdefine the same set of env vars (SHARED_ALLOWED_ENV_EXACT + OPENAI_API_KEY, ANTHROPIC_API_KEY, OPENROUTER_API_KEY, SQUINT_DB_PATH). If one is updated without the other,NativeToolEngine.buildEnv()and the standalonebuildEnv()fromenv.ts(used byserver.ts) will diverge silently. This is a pre-existing pattern shared with Codex, so not blocking — but worth a follow-up to makeserver.tsconsume the engine instance'sbuildEnv()instead, establishing a single source of truth. -
Unnecessary
afterExecuteoverride (src/backends/opencode/index.ts:458-460): The override is a pure passthrough — it only callssuper.afterExecute(plan, result)with no additional logic. The base class method would be inherited automatically if removed. The Claude Code engine has a similar override but addscleanupPersistedSession()aftersuper, justifying its existence. Here it adds no behavior, just documentation. Consider removing it to reduce noise — the JSDoc on the base class already documents the contract.
🕵️ claude-code · claude-opus-4-6 · run details
Summary
OpenCodeEngineto extendNativeToolEngineinstead of directly implementingAgentEnginegetAllowedEnvExact(),getExtraEnvVars(),resolveEngineModel()afterExecute()to callsuper.afterExecute()for context file cleanupfilterProcessEnvwrapper fromopencode/env.tsChanges
src/backends/opencode/index.tsimplements AgentEngine→extends NativeToolEnginegetAllowedEnvExact()returningOPENAI_API_KEY,ANTHROPIC_API_KEY,OPENROUTER_API_KEY,SQUINT_DB_PATH(plus shared set)getExtraEnvVars()returning{ CI: 'true' }resolveEngineModel()delegating toresolveOpenCodeModel()cleanupContextFiles()call inafterExecute()withsuper.afterExecute()callsupportsAgentType()andresolveModel()overrides (now handled by base class)AgentEngineimport (no longer needed)src/backends/opencode/env.tsfilterProcessEnvexport (deprecated)buildEnv()for use byserver.tswhich calls it directlyTest plan
npm test)npm run typecheck)npm run lint)Trello card
https://trello.com/c/69c1aa83cf1734b4aa1bab3c
🤖 Generated with Claude Code
🕵️ claude-code · claude-sonnet-4-6 · run details