diff --git a/packages/opencode/src/cli/cmd/pr.ts b/packages/opencode/src/cli/cmd/pr.ts index c61d9510271..7bd98ff7a82 100644 --- a/packages/opencode/src/cli/cmd/pr.ts +++ b/packages/opencode/src/cli/cmd/pr.ts @@ -4,27 +4,7 @@ import { AppRuntime } from "@/effect/app-runtime" import { Git } from "@/git" import { Instance } from "@/project/instance" import { Process } from "@/util" -import { existsSync } from "node:fs" // kilocode_change - -const subcommand = "pr" // kilocode_change - -// kilocode_change start - resolve the currently running CLI instead of hardcoding opencode -export function cliCommand( - input = { - execPath: process.execPath, - argv: process.argv, - exists: existsSync, - }, -) { - const script = input.argv[1] - if (!script) return [input.execPath] - if (script === subcommand) return [input.execPath] // kilocode_change - if (script.startsWith("/$bunfs/root/")) return [input.execPath] - if (script.startsWith("B:/~BUN/root/")) return [input.execPath] - if (input.exists(script)) return [input.execPath, script] - return [input.execPath] -} -// kilocode_change end +import { cliCommand, subcommand } from "@/kilocode/cli/cmd/pr-cli" // kilocode_change export const PrCommand = cmd({ command: `${subcommand} `, // kilocode_change diff --git a/packages/opencode/src/kilocode/cli/cmd/pr-cli.ts b/packages/opencode/src/kilocode/cli/cmd/pr-cli.ts new file mode 100644 index 00000000000..ba18357f410 --- /dev/null +++ b/packages/opencode/src/kilocode/cli/cmd/pr-cli.ts @@ -0,0 +1,21 @@ +// kilocode_change - new file +import { existsSync } from "node:fs" + +export const subcommand = "pr" + +// Resolve the currently running CLI instead of hardcoding opencode. +export function cliCommand( + input = { + execPath: process.execPath, + argv: process.argv, + exists: existsSync, + }, +) { + const script = input.argv[1] + if (!script) return [input.execPath] + if (script === subcommand) return [input.execPath] + if (script.startsWith("/$bunfs/root/")) return [input.execPath] + if (script.startsWith("B:/~BUN/root/")) return [input.execPath] + if (input.exists(script)) return [input.execPath, script] + return [input.execPath] +} diff --git a/packages/opencode/test/cli/pr.test.ts b/packages/opencode/test/kilocode/pr-cli.test.ts similarity index 96% rename from packages/opencode/test/cli/pr.test.ts rename to packages/opencode/test/kilocode/pr-cli.test.ts index 6101784d5c5..aa048ea5bde 100644 --- a/packages/opencode/test/cli/pr.test.ts +++ b/packages/opencode/test/kilocode/pr-cli.test.ts @@ -1,6 +1,6 @@ // kilocode_change - new file import { expect, test } from "bun:test" -import { cliCommand } from "../../src/cli/cmd/pr" +import { cliCommand } from "../../src/kilocode/cli/cmd/pr-cli" test("cliCommand uses the current script when argv[1] is a file path", () => { const result = cliCommand({