mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix: address PR review - disable choco/scoop, update brew to Kilo-Org/tap, disable account commands
This commit is contained in:
@@ -192,17 +192,10 @@ async function executeUninstall(method: Installation.Method, targets: RemovalTar
|
||||
const cmd = cmds[method]
|
||||
if (cmd) {
|
||||
spinner.start(`Running ${cmd.join(" ")}...`)
|
||||
const result = await Process.run(method === "choco" ? ["choco", "uninstall", "kilo", "-y", "-r"] : cmd, { // kilocode_change
|
||||
nothrow: true,
|
||||
})
|
||||
const result = await Process.run(cmd, { nothrow: true }) // kilocode_change - removed choco special case
|
||||
if (result.code !== 0) {
|
||||
spinner.stop(`Package manager uninstall failed: exit code ${result.code}`, 1)
|
||||
const text = `${result.stdout.toString("utf8")}\n${result.stderr.toString("utf8")}`
|
||||
if (method === "choco" && text.includes("not running from an elevated command shell")) {
|
||||
prompts.log.warn(`You may need to run '${cmd.join(" ")}' from an elevated command shell`)
|
||||
} else {
|
||||
prompts.log.warn(`You may need to run manually: ${cmd.join(" ")}`)
|
||||
}
|
||||
prompts.log.warn(`You may need to run manually: ${cmd.join(" ")}`)
|
||||
} else {
|
||||
spinner.stop("Package removed")
|
||||
}
|
||||
|
||||
@@ -57,12 +57,7 @@ export const UpgradeCommand = {
|
||||
if (err) {
|
||||
spinner.stop("Upgrade failed", 1)
|
||||
if (err instanceof Installation.UpgradeFailedError) {
|
||||
// necessary because choco only allows install/upgrade in elevated terminals
|
||||
if (method === "choco" && err.data.stderr.includes("not running from an elevated command shell")) {
|
||||
prompts.log.error("Please run the terminal as Administrator and try again")
|
||||
} else {
|
||||
prompts.log.error(err.data.stderr)
|
||||
}
|
||||
prompts.log.error(err.data.stderr) // kilocode_change - removed choco special case
|
||||
} else if (err instanceof Error) prompts.log.error(err.message)
|
||||
prompts.outro("Done")
|
||||
return
|
||||
|
||||
@@ -3,7 +3,8 @@ import { hideBin } from "yargs/helpers"
|
||||
import { RunCommand } from "./cli/cmd/run"
|
||||
import { GenerateCommand } from "./cli/cmd/generate"
|
||||
import { Log } from "./util/log"
|
||||
import { LoginCommand, LogoutCommand, SwitchCommand, OrgsCommand } from "./cli/cmd/account"
|
||||
// kilocode_change - disabled account commands — not part of Kilo
|
||||
// import { LoginCommand, LogoutCommand, SwitchCommand, OrgsCommand } from "./cli/cmd/account"
|
||||
import { ProvidersCommand } from "./cli/cmd/providers"
|
||||
import { AgentCommand } from "./cli/cmd/agent"
|
||||
import { UpgradeCommand } from "./cli/cmd/upgrade"
|
||||
@@ -183,10 +184,12 @@ let cli = yargs(hideBin(process.argv))
|
||||
.command(RunCommand)
|
||||
.command(GenerateCommand)
|
||||
.command(DebugCommand)
|
||||
.command(LoginCommand)
|
||||
.command(LogoutCommand)
|
||||
.command(SwitchCommand)
|
||||
.command(OrgsCommand)
|
||||
// kilocode_change start
|
||||
// .command(LoginCommand)
|
||||
// .command(LogoutCommand)
|
||||
// .command(SwitchCommand)
|
||||
// .command(OrgsCommand)
|
||||
// kilocode_change end
|
||||
.command(ProvidersCommand)
|
||||
.command(AgentCommand)
|
||||
.command(UpgradeCommand)
|
||||
|
||||
@@ -26,7 +26,7 @@ export namespace Installation {
|
||||
}
|
||||
|
||||
async function upgradeCurl(target: string) {
|
||||
const body = await fetch("https://opencode.ai/install").then((res) => {
|
||||
const body = await fetch("https://kilo.ai/install").then((res) => { // kilocode_change
|
||||
if (!res.ok) throw new Error(res.statusText)
|
||||
return res.text()
|
||||
})
|
||||
@@ -120,15 +120,7 @@ export namespace Installation {
|
||||
},
|
||||
{
|
||||
name: "brew" as const,
|
||||
command: () => text(["brew", "list", "--formula", "opencode"]),
|
||||
},
|
||||
{
|
||||
name: "scoop" as const,
|
||||
command: () => text(["scoop", "list", "opencode"]),
|
||||
},
|
||||
{
|
||||
name: "choco" as const,
|
||||
command: () => text(["choco", "list", "--limit-output", "opencode"]),
|
||||
command: () => text(["brew", "list", "--formula", "kilo"]), // kilocode_change
|
||||
},
|
||||
]
|
||||
// kilocode_change end
|
||||
@@ -145,7 +137,7 @@ export namespace Installation {
|
||||
const output = await check.command()
|
||||
// kilocode_change start - check for @kilocode/cli instead of opencode-ai for JS package managers
|
||||
const installedName =
|
||||
check.name === "brew" || check.name === "choco" || check.name === "scoop" ? "opencode" : "@kilocode/cli"
|
||||
check.name === "brew" ? "opencode" : "@kilocode/cli" // kilocode_change - removed choco/scoop
|
||||
// kilocode_change end
|
||||
if (output.includes(installedName)) {
|
||||
return check.name
|
||||
@@ -163,11 +155,13 @@ export namespace Installation {
|
||||
)
|
||||
|
||||
async function getBrewFormula() {
|
||||
const tapFormula = await text(["brew", "list", "--formula", "anomalyco/tap/opencode"])
|
||||
if (tapFormula.includes("opencode")) return "anomalyco/tap/opencode"
|
||||
const coreFormula = await text(["brew", "list", "--formula", "opencode"])
|
||||
if (coreFormula.includes("opencode")) return "opencode"
|
||||
return "opencode"
|
||||
// kilocode_change start
|
||||
const tapFormula = await text(["brew", "list", "--formula", "Kilo-Org/tap/kilo"])
|
||||
if (tapFormula.includes("kilo")) return "Kilo-Org/tap/kilo"
|
||||
const coreFormula = await text(["brew", "list", "--formula", "kilo"])
|
||||
if (coreFormula.includes("kilo")) return "kilo"
|
||||
return "kilo"
|
||||
// kilocode_change end
|
||||
}
|
||||
|
||||
export async function upgrade(method: Method, target: string) {
|
||||
@@ -192,12 +186,12 @@ export namespace Installation {
|
||||
...process.env,
|
||||
}
|
||||
if (formula.includes("/")) {
|
||||
const tap = await Process.run(["brew", "tap", "anomalyco/tap"], { env, nothrow: true })
|
||||
const tap = await Process.run(["brew", "tap", "Kilo-Org/tap/kilo"], { env, nothrow: true }) // kilocode_change
|
||||
if (tap.code !== 0) {
|
||||
result = tap
|
||||
break
|
||||
}
|
||||
const repo = await Process.text(["brew", "--repo", "anomalyco/tap"], { env, nothrow: true })
|
||||
const repo = await Process.text(["brew", "--repo", "Kilo-Org/tap/kilo"], { env, nothrow: true }) // kilocode_change
|
||||
if (repo.code !== 0) {
|
||||
result = repo
|
||||
break
|
||||
@@ -215,18 +209,12 @@ export namespace Installation {
|
||||
break
|
||||
}
|
||||
|
||||
case "choco":
|
||||
result = await Process.run(["choco", "upgrade", "opencode", `--version=${target}`, "-y"], { nothrow: true })
|
||||
break
|
||||
case "scoop":
|
||||
result = await Process.run(["scoop", "install", `opencode@${target}`], { nothrow: true })
|
||||
break
|
||||
// kilocode_change - removed choco/scoop (not supported by Kilo)
|
||||
default:
|
||||
throw new Error(`Unknown method: ${method}`)
|
||||
}
|
||||
if (!result || result.code !== 0) {
|
||||
const stderr =
|
||||
method === "choco" ? "not running from an elevated command shell" : result?.stderr.toString("utf8") || ""
|
||||
const stderr = result?.stderr.toString("utf8") || ""
|
||||
throw new UpgradeFailedError({
|
||||
stderr: stderr,
|
||||
})
|
||||
@@ -281,29 +269,7 @@ export namespace Installation {
|
||||
}
|
||||
// kilocode_change end
|
||||
|
||||
if (detectedMethod === "choco") {
|
||||
return fetch(
|
||||
"https://community.chocolatey.org/api/v2/Packages?$filter=Id%20eq%20%27opencode%27%20and%20IsLatestVersion&$select=Version",
|
||||
{ headers: { Accept: "application/json;odata=verbose" } },
|
||||
)
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error(res.statusText)
|
||||
return res.json()
|
||||
})
|
||||
.then((data: any) => data.d.results[0].Version)
|
||||
}
|
||||
|
||||
if (detectedMethod === "scoop") {
|
||||
return fetch("https://raw.githubusercontent.com/ScoopInstaller/Main/master/bucket/opencode.json", {
|
||||
headers: { Accept: "application/json" },
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error(res.statusText)
|
||||
return res.json()
|
||||
})
|
||||
.then((data: any) => data.version)
|
||||
}
|
||||
|
||||
// kilocode_change - removed choco/scoop version checks (not supported by Kilo)
|
||||
return fetch("https://api.github.com/repos/Kilo-Org/kilocode/releases/latest")
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error(res.statusText)
|
||||
|
||||
@@ -18,30 +18,5 @@ describe("installation", () => {
|
||||
expect(await Installation.latest("unknown")).toBe("1.2.3")
|
||||
})
|
||||
|
||||
test("reads scoop manifest versions", async () => {
|
||||
globalThis.fetch = (async () =>
|
||||
new Response(JSON.stringify({ version: "2.3.4" }), {
|
||||
status: 200,
|
||||
headers: { "content-type": "application/json" },
|
||||
})) as unknown as typeof fetch
|
||||
|
||||
expect(await Installation.latest("scoop")).toBe("2.3.4")
|
||||
})
|
||||
|
||||
test("reads chocolatey feed versions", async () => {
|
||||
globalThis.fetch = (async () =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
d: {
|
||||
results: [{ Version: "3.4.5" }],
|
||||
},
|
||||
}),
|
||||
{
|
||||
status: 200,
|
||||
headers: { "content-type": "application/json" },
|
||||
},
|
||||
)) as unknown as typeof fetch
|
||||
|
||||
expect(await Installation.latest("choco")).toBe("3.4.5")
|
||||
})
|
||||
// kilocode_change - removed scoop and choco tests (not supported by Kilo)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user