refactor(cli): convert debug subcommands to effectCmd (#25479)

This commit is contained in:
Kit Langton
2026-05-02 19:22:51 -04:00
committed by GitHub
parent c33722958c
commit 2cfb224ac8
6 changed files with 185 additions and 139 deletions
+13 -14
View File
@@ -1,23 +1,22 @@
import { EOL } from "os"
import { Effect } from "effect"
import { AppRuntime } from "@/effect/app-runtime"
import { Skill } from "../../../skill"
import { bootstrap } from "../../bootstrap"
import { cmd } from "../cmd"
import { effectCmd } from "../../effect-cmd"
import { InstanceRef } from "@/effect/instance-ref"
import { InstanceStore } from "@/project/instance-store"
export const SkillCommand = cmd({
export const SkillCommand = effectCmd({
command: "skill",
describe: "list all available skills",
builder: (yargs) => yargs,
async handler() {
await bootstrap(process.cwd(), async () => {
const skills = await AppRuntime.runPromise(
Effect.gen(function* () {
const skill = yield* Skill.Service
return yield* skill.all()
}),
)
handler: Effect.fn("Cli.debug.skill")(function* () {
const ctx = yield* InstanceRef
if (!ctx) return
const store = yield* InstanceStore.Service
return yield* Effect.gen(function* () {
const skill = yield* Skill.Service
const skills = yield* skill.all()
process.stdout.write(JSON.stringify(skills, null, 2) + EOL)
})
},
}).pipe(Effect.ensuring(store.dispose(ctx)))
}),
})