Skip to content

feat: rename the dev release channel to canary - #4490

Merged
Grapedge merged 1 commit into
mainfrom
kimi-code-canary
Oct 28, 2026
Merged

Grapedge merged 1 commit into
mainfrom
kimi-code-canary

Conversation

@Grapedge

Copy link
Copy Markdown
Collaborator

Requirement or Bug

dev 渠道(#4425)正式上线前,改名为 canary,并把 0.0.0-dev.<run> 换成能看出 base、发布时间和 commit 的版本号。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

新的 canary 版本号:

<base>-canary.<YYYYMMDDHHmmss>-<sha7>
例:2.3.3-canary.20261028095900-62399b3
 version()
-  version = 0.0.0-dev.<GITHUB_RUN_NUMBER>
+  base    = apps/kimi-code/package.json#version          # 必须是纯 x.y.z,否则直接失败
+  time    = run.created_at,按 UTC 格式化为 YYYYMMDDHHmmss  # 重跑同一个 run 时不变
+  version = <base>-canary.<time>-<GITHUB_SHA 前 7 位>
   tag     = @moonshot-ai/kimi-code@<version>
  • 时间和 hash 用 - 连成同一个 prerelease 标识符。时间在前且定长,semver 按字符串比较这一段时就等于按发布时间排序;hash 不单独成为标识符,全是数字或以 0 开头时也不会让版本号变成非法 semver。
  • base 带预发布段(如 2.4.0-beta.0)时,拼出来的 prerelease()[0] 不是 canary,客户端会把这个构建当成 stable 而且没有任何提示,所以脚本直接报错。
  • 发布脚本在安装依赖之前运行,用不了 semver 包,比较函数是手写的:先按数值比 base,再比时间,最后比 commit。本地用 semver.compare 随机对拍过 20 万对版本,结果一致(对拍脚本没有提交)。
 .github/workflows/
-├── dev-release.yml             # dist-tag dev、dev.json、KIMI_CODE_DEV_NPM_PUBLISH
+├── canary-release.yml          # dist-tag canary、canary.json、KIMI_CODE_CANARY_NPM_PUBLISH
 └── ci.yml                      # 改跑 canary-release.test.mjs
 scripts/
-├── dev-release.mjs
+├── canary-release.mjs          # 新的版本格式与比较,其余流程不变
-└── dev-release.test.mjs
+└── canary-release.test.mjs
 apps/kimi-code/src/
 ├── cli/update/types.ts         # UPDATE_CHANNELS = ['stable', 'canary']
 ├── cli/update/select.ts        # 按 prerelease()[0] === 'canary' 识别渠道;env 接受 canary
 ├── cli/update/preflight.ts     # 手动升级命令与 --channel canary
 ├── cli/update/cdn.ts           # 读 channels/canary.json
 ├── cli/sub/update-download.ts  # 渠道校验改用 UPDATE_CHANNELS
 └── constant/app.ts             # kimiCodeCdnCanaryChannelUrl()

Behavior Changes and Affected Users

#4425 的客户端代码还没进任何正式版本(最新的 2.3.3 不包含),所以正式版用户没有变化。受影响的只有从 main 构建出的 dev 版本,以及手动设了 KIMI_CODE_UPDATE_CHANNEL=dev 的人,目前只有作者本人。

行为 之前 之后 谁依赖旧行为 退路
选择预发布渠道的 env 值 KIMI_CODE_UPDATE_CHANNEL=dev KIMI_CODE_UPDATE_CHANNEL=canary;dev 当作无效值,打印警告并沿用当前安装的渠道 设了 dev 的人 改为 canary
从版本号识别渠道 prerelease 第一段是 dev 第一段是 canary 已安装的 0.0.0-dev.N 构建 手动重装一次 canary 构建
预发布渠道指针 CDN channels/dev.json channels/canary.json 已安装的 dev 构建只读 dev.json,不会自动迁移 同上
native 安装的手动升级命令 KIMI_CODE_UPDATE_CHANNEL=dev kimi update --yes KIMI_CODE_UPDATE_CHANNEL=canary kimi update --yes 无 不需要
隐藏命令 __update_download --channel 接受 stable / dev 接受 stable / canary;dev 报错并以 1 退出 无,只由同一个二进制自己拉起 不需要
本地持久化的 channel 字段(更新缓存、native 暂存记录) 可以是 dev dev 不再合法:缓存当作空并重新拉取,暂存记录当作不存在 旧 dev 构建留下的文件 不需要
canary 版本号 0.0.0-dev.<run number> <base>-canary.<UTC 时间>-<sha7> 无;remote 上唯一的旧 tag 0.0.0-dev.2 会被新脚本忽略 不需要
发布 workflow 与产物命名 dev-release.yml,dist-tag dev,资产 dev.json,变量 KIMI_CODE_DEV_NPM_PUBLISH canary-release.yml,dist-tag canary,资产 canary.json,变量 KIMI_CODE_CANARY_NPM_PUBLISH 仓库外触发 nightly 的调度、把 release 资产同步到 CDN 的流程 这两处需要同步修改;npm 上从没有过 dev dist-tag

旧发布流程的能力清单,以及它们在新脚本里的位置:

  • 只发布 main 上最新且 CI 通过的 commit:selectCanaryCommit,逻辑未改。
  • commit 已有完整 release 就跳过,只有部分资产就续传:select() 和 isCompleteCanaryRelease,资产清单里的 dev.json 换成 canary.json。
  • 同一个 run 重跑时续传同一个 tag,首次运行时 tag 已存在则失败:version()。版本号仍然只由这个 run 内不变的输入算出,之前是 run number,现在是 created_at 和 commit。
  • 拒绝发布比已发布版本更旧的 run(看 git tag,开启 npm 发布时也看 dist-tag):guard(),比较规则换成 base → 时间 → commit。
  • 写渠道指针:record() 写 canary.json,字段不变。

测试覆盖:

  • env 取值和警告,包括 dev 被当作无效值:select.test.ts、preflight.test.ts、upgrade.test.ts
  • 版本识别与排序(时间更晚但 hash 更小的仍算更新),同 base 的 stable 和 canary 之间算切换渠道而不是降级:select.test.ts、rollout.test.ts、native-swap.test.ts
  • 渠道指针地址:cdn.test.ts
  • 手动升级命令与 --channel canary:preflight.test.ts、upgrade.test.ts
  • 隐藏命令拒绝 dev:update-download.test.ts
  • 持久化字段读写 canary:cache.test.ts、native-stage.test.ts。dev 值解析失败后的回退沿用已有逻辑(readUpdateCache 出错返回空缓存,parseStagedNativeUpdate 失败返回 null),没有为它单独加测试
  • 版本格式、base 校验、排序、stale guard:scripts/canary-release.test.mjs

没有写 changeset:被移除的 dev 渠道从未进入正式版本,正式版用户感知不到变化;去掉它是作者的明确决定。release/2026-10-28 已经包含 #4425,如果它先于本 PR 发布,下一个正式版就会带上 dev 命名,届时需要给本 PR 补 changeset,或者把客户端部分 cherry-pick 到该分支。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 354eb2c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T10:13:23.104676Z 354eb2c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Oct 28, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@354eb2c
npx https://pkg.pr.new/@moonshot-ai/kimi-code@354eb2c

commit: 354eb2c

@Grapedge
Grapedge merged commit 84a392e into main Oct 28, 2026
17 checks passed
@Grapedge
Grapedge deleted the kimi-code-canary branch October 28, 2026 10:20
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 5, 2026
Port of upstream MoonshotAI/kimi-code 9793044 (MoonshotAI#4425) with the rest of
the chain it opened: b9fa2b1 (MoonshotAI#4469), 84a392e (MoonshotAI#4490),
ebe14e1 (MoonshotAI#4504) and f695b1f (MoonshotAI#4512). They land together because each
one rewrites files the previous introduced, and the dev->canary rename in
the middle would otherwise create and delete the same script twice.

A release channel is now part of every update decision. `stable` keeps the
existing CDN /latest + /latest.json feed; `canary` reads the
/channels/canary.json pointer and never falls back to stable, because the two
are different release lines. The rename from `dev` to `canary` (MoonshotAI#4490) is
part of this landing, so the channel name, the CDN pointer and the canary
release script's `-canary.` version suffix all agree. The channel comes from the installed version's prerelease
tag, KIMI_CODE_UPDATE_CHANNEL, or the homebrew install source (always
stable); an unusable value warns and keeps the installed channel. A pointer
for another channel is a switch, not an upgrade, and only the interactive
prompt can act on it.

The update cache and the staged native record both carry the channel, so a
stage downloaded for one line is never adopted by the other, and the hidden
downloader takes --channel / --switch-channel alongside --manual. Rollout
gating stays off for a switch. The canary release script derives its base
version from `changeset status` and refuses a run that would replace a
newer published canary.

CI gains a scripts-tests job: the root test run covers the workspace
packages only, so scripts/test (release trigger, canary release) had no job
running it anywhere.

Local-form notes:
- The fork's update tree was restructured by 8c865f4 (MoonshotAI#2994 staged
  swap): preflight injects spawn/clock through PreflightDeps, the install
  lock and auto-install gates live in install-lock.ts / auto-install.ts,
  and main() moved to cli/main.ts. The ported code keeps that shape
  instead of upstream's parameter lists.
- All new copy goes through t() with en/zh keys (14 new keys) rather than
  upstream's literals, because check:no-hardcoded-prose is a baseline gate
  here. Regenerating that baseline after the change lowers sub/upgrade.ts
  from 8 to 7 literals (the install failure message is localized now) and
  rewrites the digests of update/cdn.ts and update/native-swap.ts for
  reworded diagnostics.
- The CDN URL helpers live in constant/region-urls.ts here, not
  constant/app.ts, so kimiCodeCdnDevChannelUrl is added there.
- The fork prompts from the cache and revalidates after the user accepts,
  so the tests pin the prompt at the cached plan and the install at the
  refreshed one; upstream refreshes before prompting.
- ci.yml gets a bun scripts-tests job instead of upstream's node
  release-workflow-tests, and the canary workflow uses bun plus
  `bun pm pkg set` / `bun publish` in place of pnpm and node. The canary
  publish keeps upstream's repository_owner guard, so this fork's CI never
  publishes; per AGENTS.md the release/publish commands themselves are
  still not run from this repository.
- native-stage's two new guards are localized too, since the baseline is
  shrink-only and may not absorb new literals.

Verified: apps/kimi-code typecheck clean apart from two untouched TUI test
files (footer/welcome) that are already red at HEAD; test/cli/update 14
files 215 pass, update-download 20, upgrade 17, native-stage 34/1 skip,
scripts suite 228; oxlint --type-aware 0 errors on the touched files;
check:no-comments, check:no-hardcoded-prose, check:locale-keys,
check:locale-placeholders, check:t-coverage and check:status-surface-i18n
green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants