Skip to content

Commit 893ef29

Browse files
kitlangtonmrsimpson
authored andcommitted
refactor(config): remove async facade exports (anomalyco#22325)
1 parent c5725bd commit 893ef29

16 files changed

Lines changed: 117 additions & 132 deletions

File tree

packages/opencode/script/seed-e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const seed = async () => {
2525
directory: dir,
2626
init: () => AppRuntime.runPromise(InstanceBootstrap),
2727
fn: async () => {
28-
await Config.waitForDependencies()
28+
await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.waitForDependencies()))
2929
await AppRuntime.runPromise(
3030
Effect.gen(function* () {
3131
const registry = yield* ToolRegistry.Service

packages/opencode/src/cli/cmd/debug/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { EOL } from "os"
22
import { Config } from "../../../config/config"
3+
import { AppRuntime } from "@/effect/app-runtime"
34
import { bootstrap } from "../../bootstrap"
45
import { cmd } from "../cmd"
56

@@ -9,7 +10,7 @@ export const ConfigCommand = cmd({
910
builder: (yargs) => yargs,
1011
async handler() {
1112
await bootstrap(process.cwd(), async () => {
12-
const config = await Config.get()
13+
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.get()))
1314
process.stdout.write(JSON.stringify(config, null, 2) + EOL)
1415
})
1516
},

packages/opencode/src/cli/cmd/mcp.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Global } from "../../global"
1515
import { modify, applyEdits } from "jsonc-parser"
1616
import { Filesystem } from "../../util/filesystem"
1717
import { Bus } from "../../bus"
18+
import { AppRuntime } from "@/effect/app-runtime"
1819

1920
function getAuthStatusIcon(status: MCP.AuthStatus): string {
2021
switch (status) {
@@ -75,7 +76,7 @@ export const McpListCommand = cmd({
7576
UI.empty()
7677
prompts.intro("MCP Servers")
7778

78-
const config = await Config.get()
79+
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.get()))
7980
const mcpServers = config.mcp ?? {}
8081
const statuses = await MCP.status()
8182

@@ -152,7 +153,7 @@ export const McpAuthCommand = cmd({
152153
UI.empty()
153154
prompts.intro("MCP OAuth Authentication")
154155

155-
const config = await Config.get()
156+
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.get()))
156157
const mcpServers = config.mcp ?? {}
157158

158159
// Get OAuth-capable servers (remote servers with oauth not explicitly disabled)
@@ -289,7 +290,7 @@ export const McpAuthListCommand = cmd({
289290
UI.empty()
290291
prompts.intro("MCP OAuth Status")
291292

292-
const config = await Config.get()
293+
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.get()))
293294
const mcpServers = config.mcp ?? {}
294295

295296
// Get OAuth-capable servers
@@ -595,7 +596,7 @@ export const McpDebugCommand = cmd({
595596
UI.empty()
596597
prompts.intro("MCP OAuth Debug")
597598

598-
const config = await Config.get()
599+
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.get()))
599600
const mcpServers = config.mcp ?? {}
600601
const serverName = args.name
601602

packages/opencode/src/cli/cmd/providers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export const ProvidersLoginCommand = cmd({
326326
}
327327
await ModelsDev.refresh(true).catch(() => {})
328328

329-
const config = await Config.get()
329+
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.get()))
330330

331331
const disabled = new Set(config.disabled_providers ?? [])
332332
const enabled = config.enabled_providers ? new Set(config.enabled_providers) : undefined

packages/opencode/src/cli/cmd/tui/worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const rpc = {
8181
})
8282
},
8383
async reload() {
84-
await Config.invalidate(true)
84+
await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.invalidate(true)))
8585
},
8686
async shutdown() {
8787
Log.Default.info("worker shutting down")

packages/opencode/src/cli/network.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Argv, InferredOptionTypes } from "yargs"
22
import { Config } from "../config/config"
3+
import { AppRuntime } from "@/effect/app-runtime"
34

45
const options = {
56
port: {
@@ -37,7 +38,7 @@ export function withNetworkOptions<T>(yargs: Argv<T>) {
3738
}
3839

3940
export async function resolveNetworkOptions(args: NetworkOptions) {
40-
const config = await Config.getGlobal()
41+
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.getGlobal()))
4142
const portExplicitlySet = process.argv.includes("--port")
4243
const hostnameExplicitlySet = process.argv.includes("--hostname")
4344
const mdnsExplicitlySet = process.argv.includes("--mdns")

packages/opencode/src/cli/upgrade.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Flag } from "@/flag/flag"
55
import { Installation } from "@/installation"
66

77
export async function upgrade() {
8-
const config = await Config.getGlobal()
8+
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.getGlobal()))
99
const method = await AppRuntime.runPromise(Installation.Service.use((svc) => svc.method()))
1010
const latest = await AppRuntime.runPromise(Installation.Service.use((svc) => svc.latest(method))).catch(() => {})
1111
if (!latest) return

packages/opencode/src/config/config.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import { ConfigPaths } from "./paths"
3333
import type { ConsoleState } from "./console-state"
3434
import { AppFileSystem } from "@/filesystem"
3535
import { InstanceState } from "@/effect/instance-state"
36-
import { makeRuntime } from "@/effect/run-service"
3736
import { Context, Duration, Effect, Exit, Fiber, Layer, Option } from "effect"
3837
import { Flock } from "@/util/flock"
3938
import { isPathPluginSpec, parsePluginSpecifier, resolvePathPluginTarget } from "@/plugin/shared"
@@ -1661,42 +1660,4 @@ export namespace Config {
16611660
Layer.provide(Auth.defaultLayer),
16621661
Layer.provide(Account.defaultLayer),
16631662
)
1664-
1665-
const { runPromise } = makeRuntime(Service, defaultLayer)
1666-
1667-
export async function get() {
1668-
return runPromise((svc) => svc.get())
1669-
}
1670-
1671-
export async function getGlobal() {
1672-
return runPromise((svc) => svc.getGlobal())
1673-
}
1674-
1675-
export async function getConsoleState() {
1676-
return runPromise((svc) => svc.getConsoleState())
1677-
}
1678-
1679-
export async function installDependencies(dir: string, input?: InstallInput) {
1680-
return runPromise((svc) => svc.installDependencies(dir, input))
1681-
}
1682-
1683-
export async function update(config: Info) {
1684-
return runPromise((svc) => svc.update(config))
1685-
}
1686-
1687-
export async function updateGlobal(config: Info) {
1688-
return runPromise((svc) => svc.updateGlobal(config))
1689-
}
1690-
1691-
export async function invalidate(wait = false) {
1692-
return runPromise((svc) => svc.invalidate(wait))
1693-
}
1694-
1695-
export async function directories() {
1696-
return runPromise((svc) => svc.directories())
1697-
}
1698-
1699-
export async function waitForDependencies() {
1700-
return runPromise((svc) => svc.waitForDependencies())
1701-
}
17021663
}

packages/opencode/src/config/tui.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Flag } from "@/flag/flag"
1010
import { Log } from "@/util/log"
1111
import { isRecord } from "@/util/record"
1212
import { Global } from "@/global"
13+
import { AppRuntime } from "@/effect/app-runtime"
1314

1415
export namespace TuiConfig {
1516
const log = Log.create({ service: "tui.config" })
@@ -51,7 +52,7 @@ export namespace TuiConfig {
5152
}
5253

5354
function installDeps(dir: string): Promise<void> {
54-
return Config.installDependencies(dir)
55+
return AppRuntime.runPromise(Config.Service.use((cfg) => cfg.installDependencies(dir)))
5556
}
5657

5758
async function mergeFile(acc: Acc, file: string) {

packages/opencode/src/server/instance/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const ConfigRoutes = lazy(() =>
3232
},
3333
}),
3434
async (c) => {
35-
return c.json(await Config.get())
35+
return c.json(await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.get())))
3636
},
3737
)
3838
.patch(
@@ -56,7 +56,7 @@ export const ConfigRoutes = lazy(() =>
5656
validator("json", Config.Info),
5757
async (c) => {
5858
const config = c.req.valid("json")
59-
await Config.update(config)
59+
await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.update(config)))
6060
return c.json(config)
6161
},
6262
)

0 commit comments

Comments
 (0)