Refactor OpenCode SDK handling to idiomatic Effect#4092
Draft
cursor[bot] wants to merge 2 commits into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
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.
What Changed
runOpenCodeSdkEffect boundary.OpenCodeRuntimeErroras a serializableSchema.TaggedErrorClassand use a schema-derived guard.Layer.mockand migrate assertions to@effect/vitestasserthelpers.Why
This removes duplicated
Effect.tryPromiseboundaries, keeps SDK tracing and structured error conversion consistent across OpenCode integrations, and makes tests explicit about the service methods they exercise while preserving original SDK causes.Validation
vp check --fix(0 errors)vp run typecheckChecklist
Note
Refactor OpenCode SDK error handling to use Effect Schema idioms
OpenCodeRuntimeErrorfromTaggedErrortoSchema.TaggedErrorClassin opencodeRuntime.ts, replacing the staticispredicate with an exportedisOpenCodeRuntimeErrorpredicate viaSchema.is.Effect.tryPromisecalls aroundclient.session.createandclient.session.promptin OpenCodeTextGeneration.ts withOpenCodeRuntime.runOpenCodeSdk, and sets the reportedcauseon downstream errors to the inner cause from the runtime error.Layer.mockforOpenCodeRuntimeinstead of a concrete test double, and switches assertions fromexpecttoassertfrom@effect/vitest.Macroscope summarized d6a5860.