Skip to content

Commit 7239b38

Browse files
authored
refactor(skill): remove async facade exports (#22308)
1 parent 9ae8dc2 commit 7239b38

4 files changed

Lines changed: 288 additions & 293 deletions

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { EOL } from "os"
2+
import { Effect } from "effect"
3+
import { AppRuntime } from "@/effect/app-runtime"
24
import { Skill } from "../../../skill"
35
import { bootstrap } from "../../bootstrap"
46
import { cmd } from "../cmd"
@@ -9,7 +11,12 @@ export const SkillCommand = cmd({
911
builder: (yargs) => yargs,
1012
async handler() {
1113
await bootstrap(process.cwd(), async () => {
12-
const skills = await Skill.all()
14+
const skills = await AppRuntime.runPromise(
15+
Effect.gen(function* () {
16+
const skill = yield* Skill.Service
17+
return yield* skill.all()
18+
}),
19+
)
1320
process.stdout.write(JSON.stringify(skills, null, 2) + EOL)
1421
})
1522
},

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { ProviderRoutes } from "./provider"
2424
import { EventRoutes } from "./event"
2525
import { WorkspaceRouterMiddleware } from "./middleware"
2626
import { AppRuntime } from "@/effect/app-runtime"
27+
import { Effect } from "effect"
2728

2829
export const InstanceRoutes = (upgrade: UpgradeWebSocket): Hono =>
2930
new Hono()
@@ -215,7 +216,12 @@ export const InstanceRoutes = (upgrade: UpgradeWebSocket): Hono =>
215216
},
216217
}),
217218
async (c) => {
218-
const skills = await Skill.all()
219+
const skills = await AppRuntime.runPromise(
220+
Effect.gen(function* () {
221+
const skill = yield* Skill.Service
222+
return yield* skill.all()
223+
}),
224+
)
219225
return c.json(skills)
220226
},
221227
)

packages/opencode/src/skill/index.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { NamedError } from "@opencode-ai/util/error"
77
import type { Agent } from "@/agent/agent"
88
import { Bus } from "@/bus"
99
import { InstanceState } from "@/effect/instance-state"
10-
import { makeRuntime } from "@/effect/run-service"
1110
import { Flag } from "@/flag/flag"
1211
import { Global } from "@/global"
1312
import { Permission } from "@/permission"
@@ -262,22 +261,4 @@ export namespace Skill {
262261
.map((skill) => `- **${skill.name}**: ${skill.description}`),
263262
].join("\n")
264263
}
265-
266-
const { runPromise } = makeRuntime(Service, defaultLayer)
267-
268-
export async function get(name: string) {
269-
return runPromise((skill) => skill.get(name))
270-
}
271-
272-
export async function all() {
273-
return runPromise((skill) => skill.all())
274-
}
275-
276-
export async function dirs() {
277-
return runPromise((skill) => skill.dirs())
278-
}
279-
280-
export async function available(agent?: Agent.Info) {
281-
return runPromise((skill) => skill.available(agent))
282-
}
283264
}

0 commit comments

Comments
 (0)