File tree Expand file tree Collapse file tree 6 files changed +9
-18
lines changed
packages/opencode/src/cli Expand file tree Collapse file tree 6 files changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import { bootstrap } from "../bootstrap"
33import { cmd } from "./cmd"
44import { AgentSideConnection , ndJsonStream } from "@agentclientprotocol/sdk"
55import { ACP } from "@/acp/agent"
6- import { Config } from "@/config/config"
76import { Server } from "@/server/server"
87import { createOpencodeClient } from "@opencode-ai/sdk/v2"
98import { withNetworkOptions , resolveNetworkOptions } from "../network"
@@ -29,8 +28,7 @@ export const AcpCommand = cmd({
2928 } ,
3029 handler : async ( args ) => {
3130 await bootstrap ( process . cwd ( ) , async ( ) => {
32- const config = await Config . get ( )
33- const opts = resolveNetworkOptions ( args , config )
31+ const opts = await resolveNetworkOptions ( args )
3432 const server = Server . listen ( opts )
3533
3634 const sdk = createOpencodeClient ( {
Original file line number Diff line number Diff line change 1- import { Config } from "../../config/config"
21import { Server } from "../../server/server"
32import { cmd } from "./cmd"
43import { withNetworkOptions , resolveNetworkOptions } from "../network"
@@ -8,8 +7,7 @@ export const ServeCommand = cmd({
87 builder : ( yargs ) => withNetworkOptions ( yargs ) ,
98 describe : "starts a headless opencode server" ,
109 handler : async ( args ) => {
11- const config = await Config . get ( )
12- const opts = resolveNetworkOptions ( args , config )
10+ const opts = await resolveNetworkOptions ( args )
1311 const server = Server . listen ( opts )
1412 console . log ( `opencode server listening on http://${ server . hostname } :${ server . port } ` )
1513 await new Promise ( ( ) => { } )
Original file line number Diff line number Diff line change 11import { cmd } from "@/cli/cmd/cmd"
2- import { Config } from "@/config/config"
32import { Instance } from "@/project/instance"
43import path from "path"
54import { Server } from "@/server/server"
@@ -15,8 +14,7 @@ export const TuiSpawnCommand = cmd({
1514 } ) ,
1615 handler : async ( args ) => {
1716 upgrade ( )
18- const config = await Config . get ( )
19- const opts = resolveNetworkOptions ( args , config )
17+ const opts = await resolveNetworkOptions ( args )
2018 const server = Server . listen ( opts )
2119 const bin = process . execPath
2220 const cmd = [ ]
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import { UI } from "@/cli/ui"
77import { iife } from "@/util/iife"
88import { Log } from "@/util/log"
99import { withNetworkOptions , resolveNetworkOptions } from "@/cli/network"
10- import { Config } from "@/config/config"
1110
1211declare global {
1312 const OPENCODE_WORKER_PATH : string
@@ -78,9 +77,8 @@ export const TuiThreadCommand = cmd({
7877 process . on ( "unhandledRejection" , ( e ) => {
7978 Log . Default . error ( e )
8079 } )
81- const config = await Config . get ( )
82- const networkOpts = resolveNetworkOptions ( args , config )
83- const server = await client . call ( "server" , networkOpts )
80+ const opts = await resolveNetworkOptions ( args )
81+ const server = await client . call ( "server" , opts )
8482 const prompt = await iife ( async ( ) => {
8583 const piped = ! process . stdin . isTTY ? await Bun . stdin . text ( ) : undefined
8684 if ( ! args . prompt ) return piped
Original file line number Diff line number Diff line change 1- import { Config } from "../../config/config"
21import { Server } from "../../server/server"
32import { UI } from "../ui"
43import { cmd } from "./cmd"
@@ -33,8 +32,7 @@ export const WebCommand = cmd({
3332 builder : ( yargs ) => withNetworkOptions ( yargs ) ,
3433 describe : "starts a headless opencode server" ,
3534 handler : async ( args ) => {
36- const config = await Config . get ( )
37- const opts = resolveNetworkOptions ( args , config )
35+ const opts = await resolveNetworkOptions ( args )
3836 const server = Server . listen ( opts )
3937 UI . empty ( )
4038 UI . println ( UI . logo ( " " ) )
Original file line number Diff line number Diff line change 11import type { Argv , InferredOptionTypes } from "yargs"
2- import type { Config } from "../config/config"
2+ import { Config } from "../config/config"
33
44const options = {
55 port : {
@@ -25,7 +25,8 @@ export function withNetworkOptions<T>(yargs: Argv<T>) {
2525 return yargs . options ( options )
2626}
2727
28- export function resolveNetworkOptions ( args : NetworkOptions , config ?: Config . Info ) {
28+ export async function resolveNetworkOptions ( args : NetworkOptions ) {
29+ const config = await Config . global ( )
2930 const portExplicitlySet = process . argv . includes ( "--port" )
3031 const hostnameExplicitlySet = process . argv . includes ( "--hostname" )
3132 const mdnsExplicitlySet = process . argv . includes ( "--mdns" )
You can’t perform that action at this time.
0 commit comments