Skip to content

Commit 9581bf0

Browse files
authored
refactor(effect): upgrade opencode to beta.46 context APIs (#21977)
1 parent af8aff3 commit 9581bf0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+195
-209
lines changed

bun.lock

Lines changed: 15 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"packages/slack"
2727
],
2828
"catalog": {
29-
"@effect/platform-node": "4.0.0-beta.43",
29+
"@effect/platform-node": "4.0.0-beta.46",
3030
"@types/bun": "1.3.11",
3131
"@types/cross-spawn": "6.0.6",
3232
"@octokit/rest": "22.0.0",
@@ -47,7 +47,7 @@
4747
"dompurify": "3.3.1",
4848
"drizzle-kit": "1.0.0-beta.19-d95b7a4",
4949
"drizzle-orm": "1.0.0-beta.19-d95b7a4",
50-
"effect": "4.0.0-beta.43",
50+
"effect": "4.0.0-beta.46",
5151
"ai": "6.0.149",
5252
"cross-spawn": "7.0.6",
5353
"hono": "4.10.7",

packages/opencode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
},
4444
"devDependencies": {
4545
"@babel/core": "7.28.4",
46-
"@effect/language-service": "0.79.0",
46+
"@effect/language-service": "0.84.2",
4747
"@octokit/webhooks-types": "7.6.1",
4848
"@opencode-ai/script": "workspace:*",
4949
"@parcel/watcher-darwin-arm64": "2.5.1",

packages/opencode/specs/effect-migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export namespace Foo {
2323
readonly get: (id: FooID) => Effect.Effect<FooInfo, FooError>
2424
}
2525

26-
export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/Foo") {}
26+
export class Service extends Context.Service<Service, Interface>()("@opencode/Foo") {}
2727

2828
export const layer = Layer.effect(
2929
Service,

packages/opencode/src/account/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Cache, Clock, Duration, Effect, Layer, Option, Schema, SchemaGetter, ServiceMap } from "effect"
1+
import { Cache, Clock, Duration, Effect, Layer, Option, Schema, SchemaGetter, Context } from "effect"
22
import {
33
FetchHttpClient,
44
HttpClient,
@@ -181,7 +181,7 @@ export namespace Account {
181181
readonly poll: (input: Login) => Effect.Effect<PollResult, AccountError>
182182
}
183183

184-
export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/Account") {}
184+
export class Service extends Context.Service<Service, Interface>()("@opencode/Account") {}
185185

186186
export const layer: Layer.Layer<Service, never, AccountRepo | HttpClient.HttpClient> = Layer.effect(
187187
Service,

packages/opencode/src/account/repo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { eq } from "drizzle-orm"
2-
import { Effect, Layer, Option, Schema, ServiceMap } from "effect"
2+
import { Effect, Layer, Option, Schema, Context } from "effect"
33

44
import { Database } from "@/storage/db"
55
import { AccountStateTable, AccountTable } from "./account.sql"
@@ -38,7 +38,7 @@ export namespace AccountRepo {
3838
}
3939
}
4040

41-
export class AccountRepo extends ServiceMap.Service<AccountRepo, AccountRepo.Service>()("@opencode/AccountRepo") {
41+
export class AccountRepo extends Context.Service<AccountRepo, AccountRepo.Service>()("@opencode/AccountRepo") {
4242
static readonly layer: Layer.Layer<AccountRepo> = Layer.effect(
4343
AccountRepo,
4444
Effect.gen(function* () {

packages/opencode/src/account/schema.ts

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,22 @@
11
import { Schema } from "effect"
22
import type * as HttpClientError from "effect/unstable/http/HttpClientError"
33

4-
import { withStatics } from "@/util/schema"
5-
6-
export const AccountID = Schema.String.pipe(
7-
Schema.brand("AccountID"),
8-
withStatics((s) => ({ make: (id: string) => s.makeUnsafe(id) })),
9-
)
4+
export const AccountID = Schema.String.pipe(Schema.brand("AccountID"))
105
export type AccountID = Schema.Schema.Type<typeof AccountID>
116

12-
export const OrgID = Schema.String.pipe(
13-
Schema.brand("OrgID"),
14-
withStatics((s) => ({ make: (id: string) => s.makeUnsafe(id) })),
15-
)
7+
export const OrgID = Schema.String.pipe(Schema.brand("OrgID"))
168
export type OrgID = Schema.Schema.Type<typeof OrgID>
179

18-
export const AccessToken = Schema.String.pipe(
19-
Schema.brand("AccessToken"),
20-
withStatics((s) => ({ make: (token: string) => s.makeUnsafe(token) })),
21-
)
10+
export const AccessToken = Schema.String.pipe(Schema.brand("AccessToken"))
2211
export type AccessToken = Schema.Schema.Type<typeof AccessToken>
2312

24-
export const RefreshToken = Schema.String.pipe(
25-
Schema.brand("RefreshToken"),
26-
withStatics((s) => ({ make: (token: string) => s.makeUnsafe(token) })),
27-
)
13+
export const RefreshToken = Schema.String.pipe(Schema.brand("RefreshToken"))
2814
export type RefreshToken = Schema.Schema.Type<typeof RefreshToken>
2915

30-
export const DeviceCode = Schema.String.pipe(
31-
Schema.brand("DeviceCode"),
32-
withStatics((s) => ({ make: (code: string) => s.makeUnsafe(code) })),
33-
)
16+
export const DeviceCode = Schema.String.pipe(Schema.brand("DeviceCode"))
3417
export type DeviceCode = Schema.Schema.Type<typeof DeviceCode>
3518

36-
export const UserCode = Schema.String.pipe(
37-
Schema.brand("UserCode"),
38-
withStatics((s) => ({ make: (code: string) => s.makeUnsafe(code) })),
39-
)
19+
export const UserCode = Schema.String.pipe(Schema.brand("UserCode"))
4020
export type UserCode = Schema.Schema.Type<typeof UserCode>
4121

4222
export class Info extends Schema.Class<Info>("Account")({

packages/opencode/src/agent/agent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { Global } from "@/global"
1919
import path from "path"
2020
import { Plugin } from "@/plugin"
2121
import { Skill } from "../skill"
22-
import { Effect, ServiceMap, Layer } from "effect"
22+
import { Effect, Context, Layer } from "effect"
2323
import { InstanceState } from "@/effect/instance-state"
2424
import { makeRuntime } from "@/effect/run-service"
2525

@@ -67,7 +67,7 @@ export namespace Agent {
6767

6868
type State = Omit<Interface, "generate">
6969

70-
export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/Agent") {}
70+
export class Service extends Context.Service<Service, Interface>()("@opencode/Agent") {}
7171

7272
export const layer = Layer.effect(
7373
Service,

packages/opencode/src/auth/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from "path"
2-
import { Effect, Layer, Record, Result, Schema, ServiceMap } from "effect"
2+
import { Effect, Layer, Record, Result, Schema, Context } from "effect"
33
import { makeRuntime } from "@/effect/run-service"
44
import { zod } from "@/util/effect-zod"
55
import { Global } from "../global"
@@ -49,7 +49,7 @@ export namespace Auth {
4949
readonly remove: (key: string) => Effect.Effect<void, AuthError>
5050
}
5151

52-
export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/Auth") {}
52+
export class Service extends Context.Service<Service, Interface>()("@opencode/Auth") {}
5353

5454
export const layer = Layer.effect(
5555
Service,

packages/opencode/src/bus/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import z from "zod"
2-
import { Effect, Exit, Layer, PubSub, Scope, ServiceMap, Stream } from "effect"
2+
import { Effect, Exit, Layer, PubSub, Scope, Context, Stream } from "effect"
33
import { EffectLogger } from "@/effect/logger"
44
import { Log } from "../util/log"
55
import { BusEvent } from "./bus-event"
@@ -42,7 +42,7 @@ export namespace Bus {
4242
readonly subscribeAllCallback: (callback: (event: any) => unknown) => Effect.Effect<() => void>
4343
}
4444

45-
export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/Bus") {}
45+
export class Service extends Context.Service<Service, Interface>()("@opencode/Bus") {}
4646

4747
export const layer = Layer.effect(
4848
Service,

0 commit comments

Comments
 (0)