11import { intro , log , outro , spinner } from "@clack/prompts"
2- import type { Argv } from "yargs "
2+ import { Effect } from "effect "
33
44import { ConfigPaths } from "@/config/paths"
55import { Global } from "@opencode-ai/core/global"
66import { installPlugin , patchPluginConfig , readPluginManifest } from "../../plugin/install"
77import { resolvePluginTarget } from "../../plugin/shared"
8- import { Instance } from "../../project/instance"
98import { errorMessage } from "../../util/error"
109import { Filesystem } from "@/util/filesystem"
1110import { Process } from "@/util/process"
1211import { UI } from "../ui"
13- import { cmd } from "./cmd"
12+ import { effectCmd } from "../effect-cmd"
13+ import { InstanceRef } from "@/effect/instance-ref"
1414
1515type Spin = {
1616 start : ( msg : string ) => void
@@ -175,12 +175,12 @@ export function createPlugTask(input: PlugInput, dep: PlugDeps = defaultPlugDeps
175175 }
176176}
177177
178- export const PluginCommand = cmd ( {
178+ export const PluginCommand = effectCmd ( {
179179 command : "plugin <module>" ,
180180 aliases : [ "plug" ] ,
181181 describe : "install plugin and update config" ,
182- builder : ( yargs : Argv ) => {
183- return yargs
182+ builder : ( yargs ) =>
183+ yargs
184184 . positional ( "module" , {
185185 type : "string" ,
186186 describe : "npm module name" ,
@@ -196,9 +196,8 @@ export const PluginCommand = cmd({
196196 type : "boolean" ,
197197 default : false ,
198198 describe : "replace existing plugin version" ,
199- } )
200- } ,
201- handler : async ( args ) => {
199+ } ) ,
200+ handler : Effect . fn ( "Cli.plug" ) ( function * ( args ) {
202201 const mod = String ( args . module ?? "" ) . trim ( )
203202 if ( ! mod ) {
204203 UI . error ( "module is required" )
@@ -214,20 +213,18 @@ export const PluginCommand = cmd({
214213 global : Boolean ( args . global ) ,
215214 force : Boolean ( args . force ) ,
216215 } )
217- let ok = true
218-
219- await Instance . provide ( {
220- directory : process . cwd ( ) ,
221- fn : async ( ) => {
222- ok = await run ( {
223- vcs : Instance . project . vcs ,
224- worktree : Instance . worktree ,
225- directory : Instance . directory ,
226- } )
227- } ,
228- } )
216+
217+ const ctx = yield * InstanceRef
218+ if ( ! ctx ) return
219+ const ok = yield * Effect . promise ( ( ) =>
220+ run ( {
221+ vcs : ctx . project . vcs ,
222+ worktree : ctx . worktree ,
223+ directory : ctx . directory ,
224+ } ) ,
225+ )
229226
230227 outro ( "Done" )
231228 if ( ! ok ) process . exitCode = 1
232- } ,
229+ } ) ,
233230} )
0 commit comments