summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKit Langton <[email protected]>2026-05-02 23:40:59 -0400
committerGitHub <[email protected]>2026-05-02 23:40:59 -0400
commit1717d636a24c0100d36c39deacbd875e0fe93b40 (patch)
tree81fe8165c44ca363a281e81d00105f5ddffc4fcc
parent8e016b4703a37dadaafc5de0a1ba17176b1a06a0 (diff)
downloadopencode-1717d636a24c0100d36c39deacbd875e0fe93b40.tar.gz
opencode-1717d636a24c0100d36c39deacbd875e0fe93b40.zip
refactor(cli/mcp+agent): Stage 4 — drop AppRuntime.runPromise bridges (#25530)
-rw-r--r--packages/opencode/src/cli/cmd/agent.ts6
-rw-r--r--packages/opencode/src/cli/cmd/mcp.ts24
2 files changed, 10 insertions, 20 deletions
diff --git a/packages/opencode/src/cli/cmd/agent.ts b/packages/opencode/src/cli/cmd/agent.ts
index a5bcd7873..2026d8232 100644
--- a/packages/opencode/src/cli/cmd/agent.ts
+++ b/packages/opencode/src/cli/cmd/agent.ts
@@ -1,6 +1,5 @@
import { cmd } from "./cmd"
import * as prompts from "@clack/prompts"
-import { AppRuntime } from "@/effect/app-runtime"
import { UI } from "../ui"
import { Global } from "@opencode-ai/core/global"
import { Agent } from "../../agent/agent"
@@ -66,6 +65,7 @@ const AgentCreateCommand = effectCmd({
const maybeCtx = yield* InstanceRef
if (!maybeCtx) return yield* Effect.die("InstanceRef not provided")
const ctx = maybeCtx
+ const agentSvc = yield* Agent.Service
yield* Effect.promise(async () => {
const cliPath = args.path
const cliDescription = args.description
@@ -127,9 +127,7 @@ const AgentCreateCommand = effectCmd({
const spinner = prompts.spinner()
spinner.start("Generating agent configuration...")
const model = args.model ? Provider.parseModel(args.model) : undefined
- const generated = await AppRuntime.runPromise(
- Agent.Service.use((svc) => svc.generate({ description, model })),
- ).catch((error) => {
+ const generated = await Effect.runPromise(agentSvc.generate({ description, model })).catch((error) => {
spinner.stop(`LLM failed to generate agent: ${error.message}`, 1)
if (isFullyNonInteractive) process.exit(1)
throw new UI.CancelledError()
diff --git a/packages/opencode/src/cli/cmd/mcp.ts b/packages/opencode/src/cli/cmd/mcp.ts
index d9927e287..2ae7cece6 100644
--- a/packages/opencode/src/cli/cmd/mcp.ts
+++ b/packages/opencode/src/cli/cmd/mcp.ts
@@ -19,7 +19,6 @@ import { Global } from "@opencode-ai/core/global"
import { modify, applyEdits } from "jsonc-parser"
import { Filesystem } from "@/util/filesystem"
import { Bus } from "../../bus"
-import { AppRuntime } from "../../effect/app-runtime"
import { Effect } from "effect"
function getAuthStatusIcon(status: MCP.AuthStatus): string {
@@ -606,11 +605,13 @@ export const McpDebugCommand = effectCmd({
demandOption: true,
}),
handler: Effect.fn("Cli.mcp.debug")(function* (args) {
+ const config = yield* Config.Service.use((cfg) => cfg.get())
+ const mcp = yield* MCP.Service
+ const auth = yield* McpAuth.Service
yield* Effect.promise(async () => {
UI.empty()
prompts.intro("MCP OAuth Debug")
- const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.get()))
const mcpServers = config.mcp ?? {}
const serverName = args.name
@@ -636,15 +637,11 @@ export const McpDebugCommand = effectCmd({
prompts.log.info(`Server: ${serverName}`)
prompts.log.info(`URL: ${serverConfig.url}`)
- // Check stored auth status
- const { authStatus, entry } = await AppRuntime.runPromise(
- Effect.gen(function* () {
- const mcp = yield* MCP.Service
- const auth = yield* McpAuth.Service
- return {
- authStatus: yield* mcp.getAuthStatus(serverName),
- entry: yield* auth.get(serverName),
- }
+ // Check stored auth status — services already in hand, run inline.
+ const { authStatus, entry } = await Effect.runPromise(
+ Effect.all({
+ authStatus: mcp.getAuthStatus(serverName),
+ entry: auth.get(serverName),
}),
)
prompts.log.info(`Auth status: ${getAuthStatusIcon(authStatus)} ${getAuthStatusText(authStatus)}`)
@@ -704,11 +701,6 @@ export const McpDebugCommand = effectCmd({
// Try to discover OAuth metadata
const oauthConfig = typeof serverConfig.oauth === "object" ? serverConfig.oauth : undefined
- const auth = await AppRuntime.runPromise(
- Effect.gen(function* () {
- return yield* McpAuth.Service
- }),
- )
const authProvider = new McpOAuthProvider(
serverName,
serverConfig.url,