Skip to content
Merged
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
7 changes: 7 additions & 0 deletions .changeset/fix-upgrade-curl-version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@kilocode/cli": patch
---

Fix `kilo upgrade` for curl installs resolving the wrong latest version

The upgrade command's version resolution for curl-detected installations used GitHub's `/releases/latest` endpoint, which now returns JetBrains plugin releases (e.g. `jetbrains/v7.0.4`) instead of the latest CLI release. This caused `kilo upgrade` to fail for curl installs. Version resolution now uses the npm `latest` dist-tag, matching the install script fix.
14 changes: 11 additions & 3 deletions packages/opencode/src/installation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,19 @@ export const layer: Layer.Layer<Service, never, HttpClient.HttpClient | AppProce
return data.version
}

// kilocode_change start - curl/unknown fallback: resolve from the public npm
// dist-tag instead of GitHub /releases/latest, which is polluted by non-CLI
// (e.g. JetBrains) releases and returns a tag like "jetbrains/v7.0.4" that
// breaks version resolution. Use the public registry directly: a curl-
// installed binary is not tied to any project's npm config.
const response = yield* httpOk.execute(
HttpClientRequest.get(KiloRelease.api).pipe(HttpClientRequest.acceptJson), // kilocode_change
HttpClientRequest.get(`https://registry.npmjs.org/${KiloNpm.path}/${InstallationChannel}`).pipe(
HttpClientRequest.acceptJson,
),
)
const data = yield* HttpClientResponse.schemaBodyJson(GitHubRelease)(response)
return data.tag_name.replace(/^v/, "")
const data = yield* HttpClientResponse.schemaBodyJson(NpmPackage)(response)
return data.version
// kilocode_change end
}, Effect.orDie),
upgrade: Effect.fn("Installation.upgrade")(function* (m: Method, target: string) {
let upgradeResult: { code: number; stdout: string; stderr: string } | undefined
Expand Down
1 change: 0 additions & 1 deletion packages/opencode/src/kilocode/installation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ export const Scoop = {
}

export const Release = {
api: "https://api.github.com/repos/Kilo-Org/kilocode/releases/latest",
install: "https://kilo.ai/cli/install",
}
24 changes: 16 additions & 8 deletions packages/opencode/test/installation/installation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,31 @@ function testLayer(

describe("installation", () => {
describe("latest", () => {
testEffect(testLayer(() => jsonResponse({ tag_name: "v1.2.3" }))).effect(
"reads release version from GitHub releases",
() =>
Effect.gen(function* () {
const result = yield* Installation.use.latest("unknown")
expect(result).toBe("1.2.3")
}),
// kilocode_change start - curl/unknown fallback now resolves from the public npm
// registry instead of GitHub /releases/latest (which is polluted by JetBrains releases)
const curlCalls: string[] = []
testEffect(
testLayer((request) => {
curlCalls.push(request.url)
return jsonResponse({ version: "1.2.3" })
}),
).effect("reads release version from GitHub releases", () =>
Effect.gen(function* () {
const result = yield* Installation.use.latest("unknown")
expect(result).toBe("1.2.3")
expect(curlCalls).toContain("https://registry.npmjs.org/@kilocode%2fcli/local")
}),
)

testEffect(testLayer(() => jsonResponse({ tag_name: "v4.0.0-beta.1" }))).effect(
testEffect(testLayer(() => jsonResponse({ version: "4.0.0-beta.1" }))).effect(
"strips v prefix from GitHub release tag",
() =>
Effect.gen(function* () {
const result = yield* Installation.use.latest("curl")
expect(result).toBe("4.0.0-beta.1")
}),
)
// kilocode_change end

const npmCalls: string[] = []
testEffect(
Expand Down
6 changes: 3 additions & 3 deletions packages/opencode/test/kilocode/installation/upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ describe("Kilo installation upgrade", () => {
() => "",
(request) => {
release.push(request.url)
return json({ tag_name: "v8.8.8" })
return json({ version: "8.8.8" })
},
),
).effect("reads fallback versions from Kilo GitHub releases", () =>
).effect("reads fallback versions from the Kilo npm registry", () =>
Effect.gen(function* () {
const result = yield* Installation.Service.use((svc) => svc.latest("unknown"))
expect(result).toBe("8.8.8")
expect(release).toContain("https://api.github.com/repos/Kilo-Org/kilocode/releases/latest")
expect(release).toContain(`https://registry.npmjs.org/@kilocode%2fcli/${InstallationChannel}`)
}),
)

Expand Down
Loading