fix(cli): stop hardcoding opencode in kilo pr (#6824)

* fix(cli): stop hardcoding opencode in kilo pr

* fix(cli): stop hardcoding opencode in kilo pr

* fix pr command cli resolution for subcommand args
This commit is contained in:
hdcode.dev
2026-04-27 12:57:30 +02:00
committed by GitHub
parent 87d1d96487
commit baf4bae91c
2 changed files with 88 additions and 9 deletions
+60
View File
@@ -0,0 +1,60 @@
// kilocode_change - new file
import { expect, test } from "bun:test"
import { cliCommand } from "../../src/cli/cmd/pr"
test("cliCommand uses the current script when argv[1] is a file path", () => {
const result = cliCommand({
execPath: "/usr/bin/node",
argv: ["/usr/bin/node", "/tmp/kilo.js", "pr", "1"],
exists: (file) => file === "/tmp/kilo.js",
})
expect(result).toEqual(["/usr/bin/node", "/tmp/kilo.js"])
})
test("cliCommand falls back to execPath when argv[1] is a subcommand", () => {
const result = cliCommand({
execPath: "/usr/local/bin/kilo",
argv: ["/usr/local/bin/kilo", "pr", "1"],
exists: () => false,
})
expect(result).toEqual(["/usr/local/bin/kilo"])
})
test("cliCommand ignores subcommand token even when it exists on disk", () => {
const result = cliCommand({
execPath: "/usr/local/bin/kilo",
argv: ["/usr/local/bin/kilo", "pr", "1"],
exists: (file) => file === "pr",
})
expect(result).toEqual(["/usr/local/bin/kilo"])
})
test("cliCommand falls back to execPath when argv[1] is missing", () => {
const result = cliCommand({
execPath: "/usr/local/bin/kilo",
argv: ["/usr/local/bin/kilo"],
exists: () => false,
})
expect(result).toEqual(["/usr/local/bin/kilo"])
})
test("cliCommand falls back to execPath for bun virtual script paths", () => {
const unix = cliCommand({
execPath: "/tmp/kilo",
argv: ["/tmp/kilo", "/$bunfs/root/src/index.js", "pr", "1"],
exists: () => true,
})
const win = cliCommand({
execPath: "C:/tmp/kilo.exe",
argv: ["C:/tmp/kilo.exe", "B:/~BUN/root/src/index.js", "pr", "1"],
exists: () => true,
})
expect(unix).toEqual(["/tmp/kilo"])
expect(win).toEqual(["C:/tmp/kilo.exe"])
})