Repository navigation
feat: isolate plugin availability by client - #4653
Conversation
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4b3970e35
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b021e620c3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (!Array.isArray(value)) return []; | ||
| return [...new Set(value.filter((client): client is PluginClient => | ||
| PLUGIN_MARKETPLACE_CLIENTS.includes(client as PluginClient) | ||
| ))]; |
There was a problem hiding this comment.
Reject malformed client constraints before caching them
When a managed or custom catalog sends clients as a scalar, an empty array, or an array containing only unknown values, this silently converts the field to [] instead of rejecting the catalog. The resulting availability entry matches neither host, so a successful catalog refresh hides the plugin and disables its runtime capabilities without reporting the malformed configuration; validate the field like platforms rather than filtering invalid values away.
AGENTS.md reference: AGENTS.md:L130-L132
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ba94cccff
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 904823bbcc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2d29ffb869
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
* fix(tui): read welcome cwd and footer git status from the session environment (#4649) * fix(tui): show remote cwd in welcome panel * fix(tui): read footer git status through the session environment The footer ran git and gh on the local machine, so a remote-bound session hid the git badge. Read branch, working-tree, and pull request state through the SDK instead: a live session's own environment, or the local work dir before the lazy session exists. The local HEAD poll stays as a refresh trigger only. Core git commands now time out after 30s, and the pull request cache is keyed by branch so a branch switch no longer serves the previous branch's pull request. * fix(agent-core-v2): resolve local git and gh outside the working directory GitService spawned bare git and gh with the workspace as cwd. On Windows a bare name is looked up in the cwd before PATH, so a binary planted in the workspace could run, and the TUI footer now reads git status at startup, before the workspace trust gate. Resolve both through PATH for the local environment and refuse any match inside the working directory. * chore: merge changesets for remote cwd and git status * fix(tui): drop the startup Ready. row once startup succeeds The startup progress row turned into a permanent "Ready." line under the welcome panel. Remove it on success; a failed startup still leaves the "Startup failed." row. * fix(agent-core-v2): compare workspace containment case-insensitively on Windows resolveProgramPath compared the PATH candidate against the working directory case-sensitively, so on Windows a PATH entry spelled with different casing (c:\repo\bin vs C:\Repo) let a workspace-local executable through. * fix(tui): keep the footer git badge through a remote disconnect The git cache key included the environment status, so a remote dropping to connecting or disconnected rebuilt the cache and lost the last badge. Key the cache by session and work dir only, and refresh it when the environment turns ready again. * feat: isolate plugin availability by client (#4653) * fix: preserve marketplace descriptions * fix: preserve localized plugin display names * feat: isolate plugin availability by client * fix: preserve cli marketplace loading * fix: harden plugin availability reconciliation * fix: hash plugin marketplace provenance * fix: complete plugin availability reconciliation * fix(transcript): keep realigned turn ids unique when folding cold facts (#4658) * fix(transcript): keep realigned turn ids unique when folding cold facts Realigning base turns to their wire ids only skipped ordinals held by turns without a wire id. When an inherited turn held a forked turn's wire id, that turn kept its base ordinal, and the next turn's wire id could land on the same ordinal, so two turns shared a turn id and the later one replaced the earlier in clients. Claim ordinals in order: turns without a wire id or already at their wire id first, then each realigned turn takes its wire id when free, else keeps its ordinal or moves to the next free one. * chore: add changeset for side chat turn order fix * fix(kap-server): wait for an agent's history before accepting its prompt (#4659) * fix(kap-server): backfill a side chat fork before replying to :btw A fork's inherited history folds into a cold turn at t0, while the live transcript only records it as markers. When the fork's first prompt started before anything read the fork transcript, its live turn took t0; the history backfill then merged the inherited main turn into it by turn id, so the first side chat turn carried the main answer and the real answer landed in a duplicate turn. Finish the fork's history backfill before :btw replies, so the inherited turn holds t0 before the first prompt can start. * fix(kap-server): wait for an agent's history before accepting its prompt Delaying the :btw reply did not order the fork's first prompt after its history backfill: other clients learn the fork from the agent roster as soon as it is created, and checking for a live transcript with forSessionLive created one, so every :btw also waited for the whole main history. Move the wait to prompt submission: a prompt for a non-main agent awaits that agent's history backfill before it is enqueued, which covers every client and leaves :btw unchanged. The backfill is cached per agent, so later prompts do not wait again. * fix: safely launch Windows SSH executors (#4664) * feat: support Windows SSH remote environments * Delete .changeset/windows-remote-environments.md Signed-off-by: 7Sageer <[email protected]> --------- Signed-off-by: 7Sageer <[email protected]> * fix(agent-core-v2): match regional plugin locales (#4666) * fix(plugins): confirm stopping Windows CU processes before install (#4670) * fix(plugins): confirm stopping Windows CU processes before install * test(plugins): cover capability install confirmation contract * fix(plugins): preserve bodyless installs and plugin-only repairs * chore: sync web dist from code-app (#4667) * chore: sync web dist from code-app code-app: 63661fc449e2ec0ce024bc08fe87f2c757d483e8 * chore: sync web dist from code-app code-app: d0e913a6c9607be778c62f0c74ee7310bfb8862a * chore: sync web dist from code-app code-app: b306f4a2f9be8944e5a8064ecb076e3137c968f1 --------- Co-authored-by: kimi-agent-bot <[email protected]> * ci: release packages (#4672) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Signed-off-by: 7Sageer <[email protected]> Co-authored-by: 7Sageer <[email protected]> Co-authored-by: liruifengv <[email protected]> Co-authored-by: qer <[email protected]> Co-authored-by: kimi-agent-bot <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Fifteen rows enter the ledger: the six commits that landed on upstream/main after the last refresh, and the nine commits that reach main only through the release/2026-11-04 sync (MoonshotAI#4674), which is where the 2.5.0 changelog entries come from. Each 2.5.0 row records what it needs from this tree, so the next batch starts from the blocker instead of rediscovering it: - MoonshotAI#4658 and MoonshotAI#4659 are ported (79a4199, 7a531f5) with tests that fail on the pre-change tree. - MoonshotAI#4649 is in_progress: its agent-core-v2 half landed in 2fa7b6b, while the footer and welcome half needs the pull-request API of MoonshotAI#4527 and the session workdir of MoonshotAI#4062. - MoonshotAI#4653, MoonshotAI#4666 and MoonshotAI#4670 build on the MoonshotAI#4525 plugin marketplace, absent here; MoonshotAI#4670 additionally needs isError2. - MoonshotAI#4664 needs the MoonshotAI#4062 remote environments. - MoonshotAI#4667 and MoonshotAI#4672 are generated-bundle and release commits; settling them as not-applicable needs a signature. Rows were appended by a one-off writer because --refresh fetches and that fetch does not complete on this network; the file still parses under the tool's own column contract, and --verify --batch B5 passes both new probes.
Second slice of upstream 8019337 (MoonshotAI#4525), and the seam MoonshotAI#4653 needs. An entry can now declare the clients it serves and the platforms it runs on; `marketplaceEntryInstallableOnHost` requires both to match the host, while `marketplaceEntryVisibleOnHost` also shows a cloud-only entry anywhere without making it installable there. `pluginClientForIdentity` maps the desktop identity to `desktop` and every other host to `cli`. Parsing keeps an absent `clients` list open to everyone, drops unknown client names, and turns a non-array into an empty list rather than silently admitting the entry — the three behaviours upstream pins. Verified: agent-core-v2 typecheck clean, check-no-comments clean; `marketplace.test.ts` 13 pass.
Fourth slice of upstream 8019337 (MoonshotAI#4525), and the provenance MoonshotAI#4653's availability cache keys on. `PluginRecord` and `PluginSummary` now carry `origin` (`marketplace` | `custom` | `unknown`) and an optional `catalogId`. The installed-file record keeps both fields optional and `recordFrom` defaults a missing origin to `unknown`, so an `installed.json` written before this change still loads and is not mislabelled as marketplace or custom. No rewrite of existing files is needed; the next persist simply writes the new fields. Classifying a fresh install is deliberately left out: the marketplace install path that knows the catalog entry does not exist in the fork yet, so every install would be labelled from a guess. `install()` therefore still produces `unknown` until that path passes the entry. Verified: agent-core-v2 typecheck clean, check-no-comments clean; plugin suites 129 pass, including two new cases — a pre-origin record reads as `unknown`, and a marketplace origin with its catalog id survives a reload.
The availability half of upstream 45e8f0e0f0e (MoonshotAI#4653), built on the fields the MoonshotAI#4525 slices added. `PluginAvailabilityStore` keeps `<home>/plugins/availability.json`: per marketplace source, each catalog entry's client list, platform list, artifact digest and check time. `update()` writes only when a value actually changed and reports whether it did; `refresh()` reloads; `entryFor()` resolves an installed record back to its catalog entry by source and catalog id, and `supports()` answers whether this host may install it. Resolution follows the record's provenance: a `custom` plugin is always allowed, a `marketplace` plugin is matched through the source it came from, and an `unknown` plugin must match the artifact digest it was installed from — when several catalog entries claim the same id the lookup returns a restrictive empty entry rather than guessing. Local-form divergence: upstream locks with `proper-lockfile`, which is not a dependency here. The equivalent is an `open(..., 'wx')` lock file with a 50 ms retry, a 10 s wait and a 5 s stale reclaim, so a crashed writer cannot block the next one; the write itself is still temp-file plus rename. Corrupt JSON throws instead of being read as an empty cache. Verified: agent-core-v2 typecheck clean, check-no-comments clean; plugin suite 137 pass including the new availability cases (single change signal, concurrent writers, stale-lock reclaim, provenance matching, corrupt cache).
The engine half of MoonshotAI#4653: the marketplace catalog route now records every entry's clients, platforms and artifact digest into `<home>/plugins/availability.json` after reading the catalog, and hides entries whose `clients`/`platforms` exclude this host. The fork has no `PluginMarketplaceService` — it reads the catalog in this route and in the TUI helper — so this is where upstream's service-side `availability.update()` and `marketplaceEntryInstallableOnHost` check land. `PluginAvailabilityStore` is exported from the engine entry so the route (and later the install path) can reach it. Verified: agent-core-v2 and kap-server typecheck clean, check-no-comments clean; kap-server plugins suite 13 pass, including a new case that the catalog read writes one source section carrying the catalog ids and that no entry without client/platform metadata disappears from the response.
Completes the provenance chain of MoonshotAI#4653. The install request carries only a source URL, so the record could not say whether it came from the catalog; the availability cache can, because each entry stores the digest of the artifact it points at. `PluginAvailabilityStore.matchByArtifact()` turns an install source back into its marketplace source and catalog id, and `installPlugin` passes that to `manager.install(source, provenance)`, which now threads origin/catalogId/marketplaceSource into the record, the persisted file and the summary. An install the cache does not recognise keeps `origin: 'unknown'` — the previous behaviour — rather than being guessed as custom, and a custom plugin stays custom through the availability store's own rule. Verified: agent-core-v2 typecheck clean, check-no-comments clean; plugin suites 141 pass, including a new case that a cached catalog source produces a marketplace record with its catalog id, and that the id lands in installed.json.
The klient plugin summary schema had drifted behind the engine: `origin`, `catalogId` and `marketplaceSource` were added to `PluginSummary` by the MoonshotAI#4653 provenance slices, and the wire schema did not list them, so the contract parity assertion was failing on both summary and info. The schema now carries the origin enum and the two optional provenance fields, plus the three description fields upstream exposes (`description`, `shortDescription`, `longDescription`), which `recordToSummary` fills from the manifest and its `interface` block — a schema field the engine never populates would have been a wire field that is always absent. Verified: agent-core-v2 and klient typecheck clean (contract-parity included), check-no-comments clean; plugin suites 140 pass, kap-server plugins 13, klient facade 32.
Closes the TUI half of MoonshotAI#4653. Loading the marketplace from the CLI now records the catalog in `$KIMI_CODE_HOME/plugins/availability.json` before returning, and a changed catalog re-reads the installed list so a plugin the catalog just stopped targeting for this host disappears from `/plugins`; an unchanged catalog does no extra work. The plugin selector filters rows through the shared `marketplaceEntryVisibleOnHost` predicate instead of its own copy, so the panel and the server agree on what this host may see. Cache read and write failures degrade to "no cache" rather than failing the marketplace load: the file is an optimisation, and a corrupt or unwritable cache must not take `/plugins` down with it. The entry it feeds still drives the installed list on the next successful write. Docs describe the new catalog fields and the cache in both locales: `customization/plugins.md` for entry-level `clients`/`platforms` and what hiding/restoring an installation means, `reference/server-api.md` for the filtered marketplace response, the availability file, and the `origin`/ `catalogId` fields plugin summaries now carry. The marketplace loader test compares with `toMatchObject` now: the parser returns the full entry shape, so a strict equality assertion would have to restate every optional field the catalog may carry. Verified: apps/kimi-code typecheck clean; check-no-comments and check-no-hardcoded-prose pass by exit status; the four marketplace/selector/ notifier suites 110 pass.
需求或 Bug
插件后台需要控制插件可用于 Desktop、CLI,还是同时可用于两端。当前 Desktop 和 CLI 共享安装记录与运行能力,因此在 Desktop 安装 Desktop-only 插件后,CLI 仍可能看到并运行它。
本 PR 在保留共享安装的前提下,按 server 宿主过滤市场并隔离运行能力;目录配置变化后,可以隐藏或恢复已有安装,无需重新安装。Web 和 Remote Control 跟随所连接 server 的宿主身份。
Bug 复现步骤
N/A
根本原因
N/A
代码变更
核心思路
使用
clients表示产品宿主可用性,继续使用platforms表示 server 操作系统可用性,两个条件必须同时满足。installed.json与托管插件文件仍共享,根据当前宿主计算管理可见性和运行资格。最近一次成功获取的可用性配置缓存到plugins/availability.json,使重启和离线启动保持相同行为。未提供
clients时表示双端可用,因此现有目录和安装行为不变。自定义插件与共享enabled状态也保持现状。flowchart LR Catalog[插件市场目录] --> Availability[统一客户端与 OS 可用性] Identity[server 宿主身份] --> Availability Availability --> Marketplace[过滤市场与安装校验] Availability --> Installed[过滤安装记录与运行能力] Catalog --> Cache[plugins/availability.json] Cache --> Installed Web[Web / Remote Control] --> Identity可用性规则统一放在 Core,不再由 Vue、kap-server 和 TUI 分别实现。缓存只保存可用性,不是市场响应缓存,也不会减少目录请求。
关键决策
enabledenabled行为典型生命周期
sequenceDiagram participant Desktop participant Catalog as 插件后台 participant CLI Desktop->>Catalog: 读取 clients=["desktop"] 的目录 Desktop->>Desktop: 安装并缓存可用性 CLI->>CLI: 读取共享安装,隐藏并排除运行能力 CLI->>Catalog: clients 变为 ["desktop","cli"] 后刷新 CLI->>CLI: 重新计算可用性并显示已有安装 CLI->>Catalog: clients 变为 ["desktop"] 后刷新 CLI->>CLI: 再次隐藏,但不删除安装只有可用性实际变化才触发 reconcile。新规则必须在目录成功刷新后生效;目录不可访问时继续使用最后已知配置。
阅读指南
packages/agent-core-v2/src/app/plugin/marketplace.ts:clients解析,以及统一的客户端 / OS 判断。packages/agent-core-v2/src/app/plugin/availability.ts:持久化最后已知可用性,以及安装记录匹配。packages/agent-core-v2/src/app/plugin/manager.ts:已安装列表过滤、写操作保护,以及所有运行能力边界。packages/agent-core-v2/src/app/plugin/pluginService.ts与marketplaceService.ts:宿主接入、最终安装校验和目录刷新后的 reconcile。packages/kap-server/src/routes/plugins.ts:server 侧市场过滤和安装状态合并。apps/kimi-code/src/utils/plugin-marketplace.ts:CLI 通过 SDK 使用同一可用性实现。其余改动包括 SDK 导出、CLI 更新检查接线、测试桩、回归测试和中英文文档。
行为变化与受影响用户
clients的目录clients配置为同时支持双端clients配置并刷新installed.json加载enabled影响模块包括
agent-core-v2插件管理、kap-server插件 REST 路由、node-sdk导出、CLI/TUI 市场加载和更新检查,以及中英文插件与 server API 文档。覆盖场景包括 Desktop 与 CLI 管理器共享 home、全部运行能力入口、预解析安装、Desktop/CLI server 的 REST 安装、目录配置扩展/移除/恢复、自定义插件、可用性缺失、CLI 过滤和更新检查。本 PR 不改变视觉布局,因此无需截图。
验证结果
pnpm exec vitest run packages/agent-core-v2/test/app/plugin packages/kap-server/test/plugins.test.ts:170 项通过。pnpm exec vitest run apps/kimi-code/test/utils/plugin-marketplace.test.ts apps/kimi-code/test/tui/components/dialogs/plugins-selector.test.ts apps/kimi-code/test/tui/commands/plugin-commands.test.ts apps/kimi-code/test/tui/controllers/plugin-update-notifier.test.ts:105 项通过。pnpm exec vitest run packages/app-client/test/usePlugins.test.ts packages/app-components/test/pluginsPanel.test.ts:125 项通过。agent-core-v2、kap-server、node-sdk和apps/kimi-code类型检查通过。pnpm --filter kimi-code-docs run build通过。node scripts/check-no-comments.mjs和git diff --check通过。Checklist
/approve)。gen-changesetsskill,或本 PR 无需 changeset。gen-docsskill,并完成相关文档更新。