This commit is contained in:
Dax Raad
2025-10-14 14:56:21 -04:00
parent 289783f627
commit 61f6091de1
6 changed files with 23 additions and 24 deletions

View File

@@ -156,8 +156,7 @@ export const TuiCommand = cmd({
})
;(async () => {
if (Installation.isDev()) return
if (Installation.isPreview()) return
if (Installation.isLocal()) return
const config = await Config.global()
if (config.autoupdate === false || Flag.OPENCODE_DISABLE_AUTOUPDATE) return
const latest = await Installation.latest().catch(() => {})
@@ -214,7 +213,7 @@ function getOpencodeCommand(): string[] {
const execPath = process.execPath.toLowerCase()
if (Installation.isDev()) {
if (Installation.isLocal()) {
// In development, use bun to run the TypeScript entry point
return [execPath, "run", process.argv[1]]
}

View File

@@ -138,7 +138,7 @@ export namespace Config {
}
async function installDependencies(dir: string) {
if (Installation.isDev()) return
if (Installation.isLocal()) return
const pkg = path.join(dir, "package.json")
@@ -151,7 +151,7 @@ export namespace Config {
if (!hasGitIgnore) await Bun.write(gitignore, ["node_modules", "package.json", "bun.lock", ".gitignore"].join("\n"))
await BunProc.run(
["add", "@opencode-ai/plugin@" + (Installation.isDev() ? "latest" : Installation.VERSION), "--exact"],
["add", "@opencode-ai/plugin@" + (Installation.isLocal() ? "latest" : Installation.VERSION), "--exact"],
{
cwd: dir,
},

View File

@@ -51,10 +51,10 @@ const cli = yargs(hideBin(process.argv))
.middleware(async (opts) => {
await Log.init({
print: process.argv.includes("--print-logs"),
dev: Installation.isDev(),
dev: Installation.isLocal(),
level: (() => {
if (opts.logLevel) return opts.logLevel as Log.Level
if (Installation.isDev()) return "DEBUG"
if (Installation.isLocal()) return "DEBUG"
return "INFO"
})(),
})

View File

@@ -42,11 +42,11 @@ export namespace Installation {
}
export function isPreview() {
return VERSION.startsWith("0.0.0")
return CHANNEL !== "latest"
}
export function isDev() {
return VERSION === "dev"
export function isLocal() {
return typeof OPENCODE_CHANNEL !== "string"
}
export async function method() {

View File

@@ -67,7 +67,7 @@ export namespace Share {
export const URL =
process.env["OPENCODE_API"] ??
(Installation.isPreview() || Installation.isDev() ? "https://api.dev.opencode.ai" : "https://api.opencode.ai")
(Installation.isPreview() || Installation.isLocal() ? "https://api.dev.opencode.ai" : "https://api.opencode.ai")
export async function create(sessionID: string) {
return fetch(`${URL}/share_create`, {