Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions packages/opencode/src/cli/cmd/pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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} <number>`, // kilocode_change
Expand Down
21 changes: 21 additions & 0 deletions packages/opencode/src/kilocode/cli/cmd/pr-cli.ts
Original file line number Diff line number Diff line change
@@ -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]
}
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
Loading