@@ -11,6 +11,8 @@ import { Flag } from "../flag/flag"
1111export namespace Plugin {
1212 const log = Log . create ( { service : "plugin" } )
1313
14+ const BUILTIN = [ "opencode-copilot-auth@0.0.9" , "opencode-anthropic-auth@0.0.5" ]
15+
1416 const state = Instance . state ( async ( ) => {
1517 const client = createOpencodeClient ( {
1618 baseUrl : "http://localhost:4096" ,
@@ -29,16 +31,19 @@ export namespace Plugin {
2931 }
3032 const plugins = [ ...( config . plugin ?? [ ] ) ]
3133 if ( ! Flag . OPENCODE_DISABLE_DEFAULT_PLUGINS ) {
32- plugins . push ( "opencode-copilot-auth@0.0.9" )
33- plugins . push ( "opencode-anthropic-auth@0.0.5" )
34+ plugins . push ( ...BUILTIN )
3435 }
3536 for ( let plugin of plugins ) {
3637 log . info ( "loading plugin" , { path : plugin } )
3738 if ( ! plugin . startsWith ( "file://" ) ) {
3839 const lastAtIndex = plugin . lastIndexOf ( "@" )
3940 const pkg = lastAtIndex > 0 ? plugin . substring ( 0 , lastAtIndex ) : plugin
4041 const version = lastAtIndex > 0 ? plugin . substring ( lastAtIndex + 1 ) : "latest"
41- plugin = await BunProc . install ( pkg , version )
42+ plugin = await BunProc . install ( pkg , version ) . catch ( ( err ) => {
43+ if ( BUILTIN . includes ( pkg ) ) return ""
44+ throw err
45+ } )
46+ if ( ! plugin ) continue
4247 }
4348 const mod = await import ( plugin )
4449 for ( const [ _name , fn ] of Object . entries < PluginInstance > ( mod ) ) {
0 commit comments