Compare commits

...

5 Commits

Author SHA1 Message Date
Brendan Allan
4c72bfd7b1 fix other commands 2026-04-16 15:16:09 +08:00
Brendan Allan
b670d12bec fix tui 2026-04-16 10:54:55 +08:00
Brendan Allan
2a84e6ab6a address feedback 2026-04-16 10:53:29 +08:00
Brendan Allan
6544f91956 rename layer 2026-04-16 10:53:29 +08:00
Brendan Allan
2fb8a1ccee core: move plugin intialisation to config layer override 2026-04-16 10:53:28 +08:00
5 changed files with 30 additions and 7 deletions

View File

@@ -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}`)

View File

@@ -177,12 +177,14 @@ export const TuiThreadCommand = cmd({
}
const prompt = await input(args.prompt)
const config = await Instance.provide({
const { config, network } = await Instance.provide({
directory: cwd,
fn: () => TuiConfig.get(),
fn: async () => ({
config: await TuiConfig.get(),
network: await resolveNetworkOptions(args),
}),
})
const network = await resolveNetworkOptions(args)
const external =
process.argv.includes("--port") ||
process.argv.includes("--hostname") ||

View File

@@ -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(" "))

View File

@@ -47,13 +47,31 @@ import { Pty } from "@/pty"
import { Installation } from "@/installation"
import { ShareNext } from "@/share/share-next"
import { SessionShare } from "@/share/session"
import * as Effect from "effect/Effect"
// Adjusts the default Config layer to ensure that plugins are always initialised before
// any other layers read the current config
const ConfigWithPluginPriority = Layer.effect(
Config.Service,
Effect.gen(function* () {
const config = yield* Config.Service
const plugin = yield* Plugin.Service
return {
...config,
get: () => Effect.andThen(plugin.init(), config.get),
getGlobal: () => Effect.andThen(plugin.init(), config.getGlobal),
getConsoleState: () => Effect.andThen(plugin.init(), config.getConsoleState),
}
}),
).pipe(Layer.provide(Layer.merge(Plugin.defaultLayer, Config.defaultLayer)))
export const AppLayer = Layer.mergeAll(
AppFileSystem.defaultLayer,
Bus.defaultLayer,
Auth.defaultLayer,
Account.defaultLayer,
Config.defaultLayer,
ConfigWithPluginPriority,
Git.defaultLayer,
Ripgrep.defaultLayer,
FileTime.defaultLayer,

View File

@@ -15,9 +15,9 @@ import * as Effect from "effect/Effect"
export const InstanceBootstrap = Effect.gen(function* () {
Log.Default.info("bootstrapping", { directory: Instance.directory })
yield* Plugin.Service.use((svc) => svc.init())
yield* Effect.all(
[
Plugin.Service,
LSP.Service,
ShareNext.Service,
Format.Service,