Find a file
liruifengv 34d47a22bc
feat(desktop): unify the host identity and mark OAuth logins as desktop-originated (#159)
* feat(desktop): add kimi-code:// deep link to surface the app after OAuth login

The OAuth device-flow completion page can now link to
kimi-code://auth/success to bring the desktop window to the front once
the user finishes authorizing in the browser. No credentials ride the
URL: the daemon's device-flow poll completes the login on its own and
the renderer converges through its existing daemon polling, so the only
deep-link action is showing the main window.

- main/deep-link.ts: scheme constant, a strict URL whitelist (any
  webpage can fire the scheme), dev-only setAsDefaultProtocolClient,
  and the showMainWindow handler
- main/app.ts: macOS open-url listener registered before ready, queued
  until launch routing is up (same pattern as second-instance argv);
  Windows/Linux deliver the URL via argv and are covered by the existing
  second-instance / cold-start paths
- electron-builder.config.cjs: top-level protocols so packaged builds
  register the scheme (macOS Info.plist, Windows registry, Linux
  x-scheme-handler in the desktop file)

* fix(desktop): gate second-instance deep links through the URL whitelist

Windows/Linux deliver deep links as plain argv, and the second-instance
handler surfaced the window unconditionally — any webpage could fire
kimi-code://anything to steal focus. Route those argv through
handleDeepLink so only whitelisted URLs focus the window; plain
relaunches (no URL in argv) keep the existing always-show behavior,
including launches queued before the window is ready.

Also redact rejected deep-link URLs with redactUrlForLog before they
reach the persistent log, so a malformed auth link cannot persist codes
or tokens from its query or fragment.

* feat(desktop): unify the host identity and mark OAuth logins as desktop-originated

Resolve the desktop host identity once (main/identity.ts) and pass it to
the embedded server through kap-server's new typed hostIdentity option:
the OAuth device flow, model, and WebSearch requests now all carry the
desktop's User-Agent + X-Msh-* set (kimi_code_desktop) with headers
derived downstream — the manual X-Msh-Platform override, the header-seed
plumbing, and the device-id scraping are gone. The engine version keeps
traveling as serverVersion.

first_launch now means the desktop product's first launch: a marker in
ui-state.json instead of the shared device_id file, whose existence only
proves some kimi-code product ran before (the CLI could silently swallow
the desktop's first launch). No migration for existing installs.

The OAuth verification URL opened from the login dialog and onboarding
wizard gains from=kimi_code_desktop, so the authorization page can offer
an "open the desktop app" handoff only for desktop-originated flows;
CLI and web URLs stay bare.

Design doc: docs/plans/2026-07-29-host-identity-unification.md. Requires
the kimi-code host-identity unification (submodule bump follows its
merge).

* chore: bump kimi-code submodule to the host-identity branch

Point the submodule at feat/host-identity-unification HEAD (f2a293c02)
so the desktop builds against the new kap-server hostIdentity API.
Update to the main merge commit once MoonshotAI/kimi-code#2382 lands.

* docs(desktop): trim the host-identity native-todos entry to the divergence essentials

* docs(desktop): drop the native-todos entries for deep link and host identity

* docs: drop the review-tool mention from the host-identity plan

* chore: bump kimi-code submodule to the merged host-identity commit

Point the submodule at the main merge commit of the host-identity
unification (MoonshotAI/kimi-code#2382), replacing the temporary pointer
at the feature branch head.

* chore: sync the lockfile with long-declared workspace deps

kap-server's minidb and node-sdk's agent-core-v2/klient links were
declared in package.json by earlier PRs but never written into the
lockfile; pnpm install registers them now.

* chore: drop the desktop host-identity changeset
2026-07-30 14:00:41 +08:00
.agents/skills feat(desktop): bilingual release notes and opt-in background auto-download (#87) 2026-07-23 16:20:58 +08:00
.changeset feat(desktop): add kimi-code:// deep link to surface the app after OAuth login (#156) 2026-07-30 12:27:02 +08:00
.github feat(desktop): add auto-update via CDN generic feed (#26) 2026-07-18 16:34:23 +08:00
apps feat(desktop): unify the host identity and mark OAuth logins as desktop-originated (#159) 2026-07-30 14:00:41 +08:00
docs feat(desktop): unify the host identity and mark OAuth logins as desktop-originated (#159) 2026-07-30 14:00:41 +08:00
KIMI CODE LOGO feat(desktop): theme-following Dock icon, app-icon picker, v2 brand kit (#92) 2026-07-24 06:31:53 +08:00
kimi-code@40172c7ca9 feat(desktop): unify the host identity and mark OAuth logins as desktop-originated (#159) 2026-07-30 14:00:41 +08:00
packages fix(markdown): restore streaming code highlight via markstream-vue 1.0.7 (#155) 2026-07-29 21:38:46 +08:00
release-notes chore: add release notes for v0.0.13 2026-07-29 18:30:42 +08:00
scripts feat(desktop): add a custom Windows title bar (#123) 2026-07-27 17:23:03 +08:00
.env.example feat(desktop): add local signed macOS packaging script 2026-07-15 16:36:48 +08:00
.gitignore fix(desktop): leave full-screen before hiding the window on close (#82) 2026-07-22 21:50:21 +08:00
.gitmodules feat(desktop): migrate embedded server to v2 kap-server 2026-07-15 11:33:25 +08:00
.npmrc chore: scaffold root workspace tooling 2026-07-10 11:35:53 +08:00
.oxlintrc.json feat: bump kimi-code submodule and sync upstream web changes (#47) 2026-07-20 16:23:36 +08:00
AGENTS.md docs: trim AGENTS.md to hot-path rules and one-line directory map 2026-07-29 17:41:16 +08:00
LICENSE chore: initialize code-app repository 2026-07-10 11:29:38 +08:00
package.json feat(desktop): theme-following Dock icon, app-icon picker, v2 brand kit (#92) 2026-07-24 06:31:53 +08:00
pnpm-lock.yaml feat(desktop): unify the host identity and mark OAuth logins as desktop-originated (#159) 2026-07-30 14:00:41 +08:00
pnpm-workspace.yaml ci: migrate desktop packaging to GitHub Actions and add changesets release flow (#1) 2026-07-16 22:45:14 +08:00
publish-desktop-cdn.sh feat(desktop): dual-publish CDN artifacts and move version dirs under binaries/ 2026-07-28 20:51:08 +08:00
README.md feat(desktop): add kimi-code:// deep link to surface the app after OAuth login (#156) 2026-07-30 12:27:02 +08:00
tsconfig.base.json chore: scaffold root workspace tooling 2026-07-10 11:35:53 +08:00
vitest.config.ts fix(desktop): serve index.html for renderer SPA routes on reload 2026-07-16 09:59:09 +00:00

code-app

Kimi Code 客户端仓库:桌面端(apps/desktop+ Web UIapps/web+ 共享包(packages/*)。 核心仓 kimi-code 以 git submodule 引入。

现状与仓库关系

  • 本仓库是 Web UI 和桌面端源码的主仓库。这两个应用此前住在 kimi-code 仓库(apps/kimi-web / apps/kimi-desktop),今后 web/desktop 的开发都在本仓库进行。
  • kimi-code 是 CLI / server / agent 的主仓库,以 submodule 钉在本仓库根目录,其 packages/* 通过 pnpm workspace 直接以源码链接进来——desktop 的 Electron 主进程会把其中的 serverkap-serveragent-core-v2 等)打包为内嵌 server。
  • web 产物分发pnpm sync:webscripts/sync-web-to-kimi-code.mjs)把 apps/web/dist 拷贝到一个 kimi-code checkout 的 apps/kimi-code/dist-web,用 KIMI_CODE_REPO 指定目标 checkout必传

下载

桌面端最新安装包CDN 固定入口,永远指向最新版本):

macOS · Apple Silicon

https://code.kimi.com/kimi-code/desktop/download/KimiCode-mac-arm64.dmg

macOS · Intel

https://code.kimi.com/kimi-code/desktop/download/KimiCode-mac-x64.dmg

Windows

https://code.kimi.com/kimi-code/desktop/download/KimiCode-win-x64.exe

Linux · AppImage

https://code.kimi.com/kimi-code/desktop/download/KimiCode-linux-x86_64.AppImage

Linux · deb

https://code.kimi.com/kimi-code/desktop/download/KimiCode-linux-amd64.deb

历史版本与完整产物见 GitHub Releases

快速开始

pnpm run sync      # 初始化/更新 submodule
pnpm install       # 安装依赖,并在 postinstall 下载、校验及转换缺失的共享字体
pnpm dev:desktop   # 桌面端renderer HMR + 默认启动内嵌 server
pnpm dev:desktop:debug  # 桌面端,并开启 Electron remote debugging端口 9222供 agent-browser 连接)
pnpm dev:web       # Web UIVite dev server/api/v1 代理到 127.0.0.1:58627

用 agent-browser 自动化桌面端

桌面端支持通过 Chrome DevTools Protocol 被外部工具控制,方便做自动化测试或 UI 操作。

  1. 安装 agent-browser

    npm i -g agent-browser && agent-browser install
    
  2. 用 debug 模式启动桌面端(默认开启 127.0.0.1:9222

    pnpm dev:desktop:debug
    
  3. 在另一个终端连接并操作:

    agent-browser connect 9222
    agent-browser snapshot -i     # 查看可交互元素
    agent-browser click @e2       # 例如点击 New Chat
    agent-browser screenshot app.png
    

更多用法见 agent-browser skills get electron

Desktop 自定义协议

kimi-code://auth/success

OAuth 授权完成页唤起桌面端窗口(登录态由 daemon 轮询完成,协议不携带凭证)。对外契约,改动需与授权页团队同步。

开发

  • 联调 kimi-code 的 server 改动:在你的 kimi-code 工作克隆里 pnpm dev:server,然后 KIMI_SERVER_URL=http://127.0.0.1:58627 pnpm dev:desktopdesktop 不再启动内嵌 server。完整流程见 AGENTS.md 的"双仓工作流"。
  • web 改动同步到 kimi-code:先 pnpm --filter kimi-code-web run build,再 KIMI_CODE_REPO=<kimi-code checkout 路径> pnpm sync:web
  • 升级 submodule:在 kimi-code/ 内 checkout 目标 commit然后在根目录提交 submodule 指针;新克隆或拉取后跑 pnpm run sync 对齐。
  • 常用检查pnpm testpnpm lintpnpm typecheckpnpm build
  • 更新品牌图标:设计源文件在 KIMI CODE LOGO/(设计师交付,整目录替换后跑 pnpm build:icons,重新生成 apps/desktop/build/ 图标、web favicon 与组件内联品牌标几何约定见脚本头注释。macOS Tahoe 深色/玻璃图标需另在 Icon ComposerXcode 26手工制作 AppIcon.icon 放入 apps/desktop/build/,打包时自动编译嵌入;没有该文件则全平台保持 .icns 静态图标。
  • 本地打包并签名 macOS 包pnpm package:macosCI 不可用时的替代arm64凭证与流程见 apps/desktop/scripts/package-local-macos.sh 头注释)。
  • 改动约束依赖方向、UI 设计系统与样式 token、主进程双语文案、提交与 changeset 规范等一律以 AGENTS.md 为准desktop 专属原生功能分叉见 apps/desktop/docs/native-todos.md

发布

桌面端发版与产物分发(不发 npm

  1. changeset:功能 PR 按 .agents/skills/changeset/SKILL.md 生成 changeset只选 kimi-code-app,早期一律 patch合入 main 后 CI 自动维护 ci: release desktop 版本 PR。

  2. 打包:合并版本 PRCI 自动打四平台签名包macOS arm64/x64、Windows、Linuxlatest*.yml 自动更新元数据)并创建 GitHub Releasetag v<version>)。完整流程见 .changeset/README.md

  3. 双语更新说明:按 .agents/skills/release-notes/SKILL.md 生成该版本的中英双语 changelog——从 apps/desktop/CHANGELOG.md 抽取中文案、翻译成英文review 后存档到 release-notes/<version>/changelog.{zh,en}.md 并提交;发布脚本会随版本目录一并上传,更新弹窗按系统语言展示(旧版本无此文件,弹窗不显示更新说明)。

  4. CDN 分发本地手动TOS 凭证限内网):

    ./publish-desktop-cdn.sh            # 拉最新 Release传产物 + 切自动更新指针 + 刷新下载入口
    ./publish-desktop-cdn.sh 0.0.3      # 指定版本rebuild / 补传 / 回滚切指针)
    ./publish-desktop-cdn.sh 0.0.3 --artifacts-only   # 只传产物,先验证再切流量
    

    产物双推两条 CDN 链路——国内 code.kimi.com/kimi-code/desktop/TOS kimi-code)与海外 code.kimi.ai/kimi-code/desktop/TOS kimi-code-oversea),内容一致:版本目录 binaries/<version>/immutable含安装包与双语更新说明 changelog.{zh,en}.md;过渡期 changelog 会同时往旧布局 <version>/ 传一份副本供未升级客户端拉取,两个版本后停)、自动更新指针 latest*.ymlno-cache、固定下载入口 download/(官网链接见上方"下载"一节)。

目录

  • apps/desktopElectron 桌面端(kimi-code-app
  • apps/web:浏览器 Web UIkimi-code-web
  • packages/*web 共享包web-core / web-i18n / web-markdown / web-ui / vite-preset
  • kimi-code/:核心仓 submoduleCLI / server / agent / packages
  • KIMI CODE LOGO/品牌设计源文件SVG/PNG下游图标资源由 pnpm build:icons 生成
  • scripts/:字体准备(prepare-fonts.mjs)、品牌图标生成(build-brand-icons.mjs、web 产物同步(sync-web-to-kimi-code.mjs)等