Explorar o código

fix other commands

Brendan Allan hai 1 día
pai
achega
b1db69fdf7

+ 3 - 1
packages/opencode/src/cli/cmd/serve.ts

@@ -2,6 +2,7 @@ import { Server } from "../../server/server"
 import { cmd } from "./cmd"
 import { withNetworkOptions, resolveNetworkOptions } from "../network"
 import { Flag } from "../../flag/flag"
+import { bootstrap } from "../bootstrap"
 
 export const ServeCommand = cmd({
   command: "serve",
@@ -11,7 +12,8 @@ export const ServeCommand = cmd({
     if (!Flag.OPENCODE_SERVER_PASSWORD) {
       console.log("Warning: OPENCODE_SERVER_PASSWORD is not set; server is unsecured.")
     }
-    const opts = await resolveNetworkOptions(args)
+
+    const opts = await bootstrap(process.cwd(), () => resolveNetworkOptions(args))
     const server = await Server.listen(opts)
     console.log(`opencode server listening on http://${server.hostname}:${server.port}`)
 

+ 2 - 1
packages/opencode/src/cli/cmd/web.ts

@@ -5,6 +5,7 @@ import { withNetworkOptions, resolveNetworkOptions } from "../network"
 import { Flag } from "../../flag/flag"
 import open from "open"
 import { networkInterfaces } from "os"
+import { bootstrap } from "../bootstrap"
 
 function getNetworkIPs() {
   const nets = networkInterfaces()
@@ -36,7 +37,7 @@ export const WebCommand = cmd({
     if (!Flag.OPENCODE_SERVER_PASSWORD) {
       UI.println(UI.Style.TEXT_WARNING_BOLD + "!  OPENCODE_SERVER_PASSWORD is not set; server is unsecured.")
     }
-    const opts = await resolveNetworkOptions(args)
+    const opts = await bootstrap(process.cwd(), () => resolveNetworkOptions(args))
     const server = await Server.listen(opts)
     UI.empty()
     UI.println(UI.logo("  "))

+ 14 - 8
packages/opencode/src/project/bootstrap.ts

@@ -7,23 +7,29 @@ import * as Vcs from "./vcs"
 import { Bus } from "../bus"
 import { Command } from "../command"
 import { Instance } from "./instance"
+import { Plugin } from "../plugin"
 import { Log } from "@/util"
 import { FileWatcher } from "@/file/watcher"
 import { ShareNext } from "@/share"
 import * as Effect from "effect/Effect"
+import { Config } from "@/config"
 
 export const InstanceBootstrap = Effect.gen(function* () {
   Log.Default.info("bootstrapping", { directory: Instance.directory })
   yield* Effect.all(
     [
-      LSP.Service,
-      ShareNext.Service,
-      Format.Service,
-      File.Service,
-      FileWatcher.Service,
-      Vcs.Service,
-      Snapshot.Service,
-    ].map((s) => Effect.forkDetach(s.use((i) => i.init()))),
+      Config.Service.use((i) => i.get()),
+      ...[
+        Plugin.Service,
+        LSP.Service,
+        ShareNext.Service,
+        Format.Service,
+        File.Service,
+        FileWatcher.Service,
+        Vcs.Service,
+        Snapshot.Service,
+      ].map((s) => s.use((i) => i.init())),
+    ].map((e) => Effect.forkDetach(e)),
   ).pipe(Effect.withSpan("InstanceBootstrap.init"))
 
   yield* Bus.Service.use((svc) =>