Merge 8a014113a4 into ae614d919f
commit
72fcb307c7
|
|
@ -1,6 +1,6 @@
|
|||
import { Server } from "../../server/server"
|
||||
import { cmd } from "./cmd"
|
||||
import { withNetworkOptions, resolveNetworkOptions } from "../network"
|
||||
import { withNetworkOptions, resolveNetworkOptions, applyYoloMode } from "../network"
|
||||
import { Flag } from "../../flag/flag"
|
||||
import { Workspace } from "../../control-plane/workspace"
|
||||
import { Project } from "../../project/project"
|
||||
|
|
@ -11,6 +11,7 @@ export const ServeCommand = cmd({
|
|||
builder: (yargs) => withNetworkOptions(yargs),
|
||||
describe: "starts a headless opencode server",
|
||||
handler: async (args) => {
|
||||
if (args.yolo) applyYoloMode()
|
||||
if (!Flag.OPENCODE_SERVER_PASSWORD) {
|
||||
console.log("Warning: OPENCODE_SERVER_PASSWORD is not set; server is unsecured.")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Server } from "../../server/server"
|
||||
import { UI } from "../ui"
|
||||
import { cmd } from "./cmd"
|
||||
import { withNetworkOptions, resolveNetworkOptions } from "../network"
|
||||
import { withNetworkOptions, resolveNetworkOptions, applyYoloMode } from "../network"
|
||||
import { Flag } from "../../flag/flag"
|
||||
import open from "open"
|
||||
import { networkInterfaces } from "os"
|
||||
|
|
@ -33,6 +33,7 @@ export const WebCommand = cmd({
|
|||
builder: (yargs) => withNetworkOptions(yargs),
|
||||
describe: "start opencode server and open web interface",
|
||||
handler: async (args) => {
|
||||
if (args.yolo) applyYoloMode()
|
||||
if (!Flag.OPENCODE_SERVER_PASSWORD) {
|
||||
UI.println(UI.Style.TEXT_WARNING_BOLD + "! " + "OPENCODE_SERVER_PASSWORD is not set; server is unsecured.")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ const options = {
|
|||
describe: "additional domains to allow for CORS",
|
||||
default: [] as string[],
|
||||
},
|
||||
yolo: {
|
||||
type: "boolean" as const,
|
||||
describe: "auto-approve all permissions (YOLO mode)",
|
||||
default: false,
|
||||
},
|
||||
}
|
||||
|
||||
export type NetworkOptions = InferredOptionTypes<typeof options>
|
||||
|
|
@ -58,3 +63,25 @@ export async function resolveNetworkOptions(args: NetworkOptions) {
|
|||
|
||||
return { hostname, port, mdns, mdnsDomain, cors }
|
||||
}
|
||||
|
||||
export function applyYoloMode() {
|
||||
process.env.OPENCODE_PERMISSION = JSON.stringify({
|
||||
bash: "allow",
|
||||
edit: "allow",
|
||||
read: { "*": "allow" },
|
||||
glob: { "*": "allow" },
|
||||
grep: { "*": "allow" },
|
||||
list: { "*": "allow" },
|
||||
task: "allow",
|
||||
external_directory: { "*": "allow" },
|
||||
todowrite: "allow",
|
||||
todoread: "allow",
|
||||
question: "allow",
|
||||
webfetch: "allow",
|
||||
websearch: "allow",
|
||||
codesearch: "allow",
|
||||
lsp: { "*": "allow" },
|
||||
doom_loop: "allow",
|
||||
skill: { "*": "allow" },
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue