From 3ea1e8f400a621c6f881e2b8fb26088ebf5c0fc6 Mon Sep 17 00:00:00 2001 From: "kiloconnect[bot]" <240665456+kiloconnect[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 14:27:42 +0000 Subject: [PATCH 1/3] feat(cli): publish CLI as npm prerelease when pre_release flag is set When the publish workflow is dispatched with pre_release=true, the CLI and SDK packages are now published to npm under the "rc" dist-tag with a semver prerelease version (e.g. 7.1.24-rc.202604081425) instead of going to the "latest" tag as a stable release. This ensures that pre-release VS Code extension builds ship with a matching pre-release CLI on npm, so users on the stable channel are never affected by pre-release publishes. --- .github/workflows/publish.yml | 4 ++- packages/script/src/index.ts | 46 ++++++++++++++++++++++++++--------- script/publish.ts | 5 +++- script/version.ts | 6 +++-- 4 files changed, 45 insertions(+), 16 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8b64bf4ed5..9fc57f520d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,7 +23,7 @@ on: required: false type: string pre_release: - description: "Publish as pre-release (VS Code marketplace)" + description: "Publish as pre-release (VS Code marketplace + npm rc channel)" required: false type: boolean default: false @@ -58,6 +58,7 @@ jobs: GH_REPO: ${{ github.repository }} KILO_BUMP: ${{ inputs.bump }} KILO_VERSION: ${{ inputs.version }} + KILO_PRE_RELEASE: ${{ inputs.pre_release }} KILO_API_KEY: ${{ secrets.KILO_API_KEY }} KILO_ORG_ID: ${{ secrets.KILO_ORG_ID }} outputs: @@ -83,6 +84,7 @@ jobs: env: KILO_VERSION: ${{ needs.version.outputs.version }} KILO_RELEASE: ${{ needs.version.outputs.release }} + KILO_PRE_RELEASE: ${{ inputs.pre_release }} GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} diff --git a/packages/script/src/index.ts b/packages/script/src/index.ts index 5fcdae3d5f..699260d297 100644 --- a/packages/script/src/index.ts +++ b/packages/script/src/index.ts @@ -21,30 +21,52 @@ const env = { KILO_BUMP: process.env["KILO_BUMP"], KILO_VERSION: process.env["KILO_VERSION"], KILO_RELEASE: process.env["KILO_RELEASE"], + KILO_PRE_RELEASE: process.env["KILO_PRE_RELEASE"], } // kilocode_change end const CHANNEL = await (async () => { if (env.KILO_CHANNEL) return env.KILO_CHANNEL // kilocode_change + // kilocode_change start - publish to "rc" channel for pre-releases + if (env.KILO_BUMP && env.KILO_PRE_RELEASE === "true") return "rc" + // kilocode_change end if (env.KILO_BUMP) return "latest" // kilocode_change if (env.KILO_VERSION && !env.KILO_VERSION.startsWith("0.0.0-")) return "latest" // kilocode_change return await $`git branch --show-current`.text().then((x) => x.trim()) })() const IS_PREVIEW = CHANNEL !== "latest" +// kilocode_change start - shared helpers for version computation +async function fetchLatest() { + const data: any = await fetch("https://registry.npmjs.org/@kilocode/cli/latest").then((res) => { + if (!res.ok) throw new Error(res.statusText) + return res.json() + }) + return data.version as string +} + +function bumpVersion(current: string, type: string) { + const [major, minor, patch] = current.split(".").map((x: string) => Number(x) || 0) + if (type === "major") return `${major + 1}.0.0` + if (type === "minor") return `${major}.${minor + 1}.0` + return `${major}.${minor}.${patch + 1}` +} +// kilocode_change end + const VERSION = await (async () => { if (env.KILO_VERSION) return env.KILO_VERSION // kilocode_change - if (IS_PREVIEW) return `0.0.0-${CHANNEL}-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}` - const version = await fetch("https://registry.npmjs.org/@kilocode/cli/latest") // kilocode_change - .then((res) => { - if (!res.ok) throw new Error(res.statusText) - return res.json() - }) - .then((data: any) => data.version) - const [major, minor, patch] = version.split(".").map((x: string) => Number(x) || 0) - const t = env.KILO_BUMP?.toLowerCase() // kilocode_change - if (t === "major") return `${major + 1}.0.0` - if (t === "minor") return `${major}.${minor + 1}.0` - return `${major}.${minor}.${patch + 1}` + if (IS_PREVIEW) { + // kilocode_change start - compute semver prerelease for rc channel + if (env.KILO_BUMP && env.KILO_PRE_RELEASE === "true") { + const current = await fetchLatest() + const base = bumpVersion(current, env.KILO_BUMP.toLowerCase()) + const stamp = new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "") + return `${base}-rc.${stamp}` + } + // kilocode_change end + return `0.0.0-${CHANNEL}-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}` + } + const version = await fetchLatest() // kilocode_change + return bumpVersion(version, env.KILO_BUMP?.toLowerCase() ?? "patch") // kilocode_change })() // kilocode_change start diff --git a/script/publish.ts b/script/publish.ts index 8b99c91841..14b75965ec 100755 --- a/script/publish.ts +++ b/script/publish.ts @@ -72,7 +72,10 @@ if (Script.release) { // await import(`../packages/desktop-electron/scripts/finalize-latest-yml.ts`) // kilocode_change end - await $`gh release edit v${Script.version} --draft=false --repo ${process.env.GH_REPO}` + // kilocode_change start - mark prerelease GitHub releases accordingly + const flags = Script.preview ? ["--draft=false", "--prerelease"] : ["--draft=false"] + await $`gh release edit v${Script.version} ${flags} --repo ${process.env.GH_REPO}` + // kilocode_change end } console.log("\n=== cli ===\n") diff --git a/script/version.ts b/script/version.ts index 71619f4618..40a2e61777 100755 --- a/script/version.ts +++ b/script/version.ts @@ -17,12 +17,14 @@ if (!Script.preview) { const release = await $`gh release view v${Script.version} --json tagName,databaseId`.json() output.push(`release=${release.databaseId}`) output.push(`tag=${release.tagName}`) -} else if (Script.channel === "beta") { - await $`gh release create v${Script.version} -d --title "v${Script.version}" --repo ${process.env.GH_REPO}` + // kilocode_change start - handle both beta and rc preview channels +} else if (Script.channel === "beta" || Script.channel === "rc") { + await $`gh release create v${Script.version} -d --prerelease --title "v${Script.version}" --repo ${process.env.GH_REPO}` const release = await $`gh release view v${Script.version} --json tagName,databaseId --repo ${process.env.GH_REPO}`.json() output.push(`release=${release.databaseId}`) output.push(`tag=${release.tagName}`) + // kilocode_change end } output.push(`repo=${process.env.GH_REPO}`) From 501fb340f16486398251069eaeff74905b0119f4 Mon Sep 17 00:00:00 2001 From: "kiloconnect[bot]" <240665456+kiloconnect[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 14:42:31 +0000 Subject: [PATCH 2/3] chore: trigger CI re-run From 5ea872e4a89394d0814d231ce36f029d24d23c7f Mon Sep 17 00:00:00 2001 From: "kiloconnect[bot]" <240665456+kiloconnect[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 14:49:44 +0000 Subject: [PATCH 3/3] fix: handle pre_release flag with explicit version override When KILO_PRE_RELEASE is true, always use the rc channel regardless of whether KILO_VERSION or KILO_BUMP is set. This prevents manual version-override pre-releases from being published to the latest npm dist-tag. --- packages/script/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/script/src/index.ts b/packages/script/src/index.ts index 699260d297..5ea9d757a6 100644 --- a/packages/script/src/index.ts +++ b/packages/script/src/index.ts @@ -27,7 +27,7 @@ const env = { const CHANNEL = await (async () => { if (env.KILO_CHANNEL) return env.KILO_CHANNEL // kilocode_change // kilocode_change start - publish to "rc" channel for pre-releases - if (env.KILO_BUMP && env.KILO_PRE_RELEASE === "true") return "rc" + if (env.KILO_PRE_RELEASE === "true") return "rc" // kilocode_change end if (env.KILO_BUMP) return "latest" // kilocode_change if (env.KILO_VERSION && !env.KILO_VERSION.startsWith("0.0.0-")) return "latest" // kilocode_change