Repository navigation
feat(agent-core-v2): register plugin skills under qualified names and relax plugin name validation - #4188
Conversation
🦋 Changeset detectedLatest commit: 727a66a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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: d62b330be7
ℹ️ 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 (options.replace === true || !this.byPluginAndName.has(key)) { | ||
| this.byPluginAndName.set(key, skill); | ||
| const prefix = `${plugin.id}:`; | ||
| const bareName = skill.name.startsWith(prefix) ? skill.name.slice(prefix.length) : skill.name; |
There was a problem hiding this comment.
Preserve pre-qualified names in plugin lookup
When an existing plugin already names a skill demo:review and sets sessionStart.skill to that accepted name, this strips it to review only in byPluginAndName; PluginManager.enabledSessionStarts() still emits demo:review, so renderPluginSessionStartReminder() can no longer find it and silently omits the startup block. Preserve an alias for the original name or normalize the session-start lookup as well.
AGENTS.md reference: AGENTS.md:L99-L99
Useful? React with 👍 / 👎.
| const qualifiedName = `${prefix}${bareName}`; | ||
| const qualifiedKey = normalizeSkillName(qualifiedName); | ||
| if (options.replace === true || !this.byName.has(qualifiedKey)) { | ||
| this.byName.set(qualifiedKey, { ...skill, name: qualifiedName }); |
There was a problem hiding this comment.
Let exact plugin commands win over skill aliases
When a plugin exposes both a Skill and slash command named deploy, this qualified catalog name makes the TUI's skill map contain skill:my-plugin:deploy; resolveSlashCommandInput() then resolves the existing /my-plugin:deploy command through its skill:${commandName} fallback before consulting pluginCommandMap. The previously working plugin command therefore silently activates the Skill instead, so exact plugin-command matches need to precede that shorthand fallback.
AGENTS.md reference: AGENTS.md:L99-L99
Useful? React with 👍 / 👎.
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "@moonshot-ai/kimi-code": patch | |||
There was a problem hiding this comment.
Mark bare plugin-skill removal as a major change
This changeset explicitly removes a previously supported CLI/SDK input while publishing it as a patch: scripts or clients that retained a plugin's bare skill name and call /skill:<name> or activateSkill(name) will start failing after a supposedly compatible upgrade. Either retain a compatibility path or, after the required confirmation, record this as a major change.
AGENTS.md reference: AGENTS.md:L62-L62
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| export const PLUGIN_NAME_REGEX = /^[a-z0-9][a-z0-9_-]{0,63}$/; | ||
| export const PLUGIN_NAME_REGEX = /^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*(?:@[A-Za-z0-9_-]+)?$/; |
There was a problem hiding this comment.
Retain a filesystem-safe plugin ID length limit
On filesystems with the common 255-byte component limit, an ASCII name of 249 characters now passes validation but can never be installed: copyPluginToManagedRoot() feeds ${id}- to mkdtemp(), which appends six characters and produces a 256-byte basename. Keep an explicit maximum (accounting for the staging suffix) so accepted manifests do not fail later with ENAMETOOLONG.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d62b330be7
ℹ️ 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".
| const qualifiedName = `${prefix}${bareName}`; | ||
| const qualifiedKey = normalizeSkillName(qualifiedName); | ||
| if (options.replace === true || !this.byName.has(qualifiedKey)) { | ||
| this.byName.set(qualifiedKey, { ...skill, name: qualifiedName }); |
There was a problem hiding this comment.
Preserve plugin lookup across qualified-name collisions
When a project or user skill is already named demo:review and plugin demo contributes review, WorkspaceSkillCatalogService.remerge() registers the lower-priority plugin first and then calls register(..., { replace: true }) for the project/user skill, so this shared byName entry is overwritten. Before this change the plugin was invocable as review while the other skill remained demo:review; afterward the documented /skill:demo:review resolves only the non-plugin skill and the plugin disappears from listing/model invocation. Keep plugin-qualified resolution separate or provide a non-destructive collision path.
AGENTS.md reference: AGENTS.md:L99-L99
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| export const PLUGIN_NAME_REGEX = /^[a-z0-9][a-z0-9_-]{0,63}$/; | ||
| export const PLUGIN_NAME_REGEX = /^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*(?:@[A-Za-z0-9_-]+)?$/; |
There was a problem hiding this comment.
Update the MCP notifier's plugin-id parser
For a newly accepted official plugin ID such as lark.docs, MCP tool use never triggers update notices: apps/kimi-code/src/tui/controllers/plugin-update-notifier.ts still parses runtime names with ^plugin-([a-z0-9][a-z0-9_-]{0,63}):, so loadMcpServerPluginIds() drops plugin-lark.docs:<server> and handleMcpToolCompleted() silently gives up. Share or expand that parser when broadening manifest validation so MCP-only plugins with dots, @ suffixes, or leading punctuation still receive update checks.
AGENTS.md reference: AGENTS.md:L119-L119
Useful? React with 👍 / 👎.
|
|
||
| `sessionStart.skill` 在会话启动时把一个 plugin Skill 加载到 main agent,适合放置初始化说明、工作流规则,或把其他工具中的术语映射到 Kimi Code CLI。它只注入文本,不执行代码。 | ||
|
|
||
| Plugin Skill 以全限定名 `<plugin-id>:<skill-name>` 列出和调用(例如 `/skill:my-plugin:using-my-plugin`),与[插件斜杠命令](#插件斜杠命令)的命名方式一致:不同插件的同名 Skill 互不冲突,裸名不会解析到 plugin Skill。 |
There was a problem hiding this comment.
Separate the Chinese link from surrounding text
This new sentence places [插件斜杠命令] directly after 与, so the rendered Chinese violates the repository's mixed-content spacing rule and is inconsistent with the surrounding localized documentation. Insert a space before the link.
AGENTS.md reference: docs/AGENTS.md:L127-L127
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad7a126dd5
ℹ️ 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".
| } | ||
|
|
||
| export const PLUGIN_NAME_REGEX = /^[a-z0-9][a-z0-9_-]{0,63}$/; | ||
| export const PLUGIN_NAME_REGEX = /^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*(?:@[A-Za-z0-9_-]+)?$/; |
There was a problem hiding this comment.
Normalize marketplace IDs before comparing uppercase names
When a marketplace entry and its now-valid manifest both use an uppercase ID such as My.Plugin, PluginManager.install() stores it as my.plugin, but PluginsSelector.isMarketplaceEntryInstalled() and the kap-server marketplace merge both join entries to installed records with case-sensitive entry.id lookups. After installation the marketplace therefore still labels the row installable (and the server response omits its installed/update state), allowing repeated installs and suppressing update UI; normalize the marketplace key before these joins.
AGENTS.md reference: AGENTS.md:L97-L99
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| export const PLUGIN_NAME_REGEX = /^[a-z0-9][a-z0-9_-]{0,63}$/; | ||
| export const PLUGIN_NAME_REGEX = /^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*(?:@[A-Za-z0-9_-]+)?$/; |
There was a problem hiding this comment.
Keep new plugin IDs distinct in MCP tool namespaces
When the existing valid plugin lark_docs and a newly accepted plugin lark.docs both declare MCP server api with tool search, their runtime names are distinct but sanitizeMcpNamePart() converts both qualified tool names to mcp__plugin-lark_docs_api__search; AgentMcpService.registerMcpServer() then treats the second as a collision and skips registering its tool. Installing a dotted or @-suffixed plugin can therefore make one plugin's MCP tools unavailable, so encode the newly accepted punctuation injectively (or reject IDs that collapse to an existing namespace).
AGENTS.md reference: AGENTS.md:L97-L99
Useful? React with 👍 / 👎.
| const exactSkillName = options.skillCommandMap.get(parsed.name); | ||
| if (exactSkillName !== undefined) { | ||
| return skillCommandIntent(parsed, exactSkillName); |
There was a problem hiding this comment.
Check plugin commands before exact sub-skill entries
The fresh remaining collision is plugin sub-skills: buildSkillSlashCommands() puts every isSubSkill at its exact listed name, so plugin demo contributes demo:parent.review as an exact map key. If that plugin also has a command named parent.review (command frontmatter names permit this), these lines return the skill before the plugin-map check, so /demo:parent.review can no longer execute the command; unlike the top-level shorthand case just fixed, no /skill:... alias is generated for sub-skills. Check plugin commands first for this exact qualified shape or add the explicit skill alias.
AGENTS.md reference: AGENTS.md:L97-L99
Useful? React with 👍 / 👎.
ad7a126 to
727a66a
Compare
|
Guys, please provide users with a migration path for changes like this in the future. This breaks backward compatibility: Kimi Code can no longer invoke plugin skills using the old |
Requirement or Bug
将 v1 内核已验证的三项 plugin 修复移植到 agent-core-v2:放宽 plugin 名校验、同名 plugin skill 仅以全限定名可见、修正 Skill 工具的名称引导文案。无关联 issue(内核 parity 移植)。
Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
InMemorySkillCatalog.register()的注册逻辑(packages/agent-core-v2/src/features/skill/catalog/registry.ts):另外两处单行修改:
packages/agent-core-v2/src/app/plugin/types.ts:PLUGIN_NAME_REGEX由^[a-z0-9][a-z0-9_-]{0,63}$放宽为^[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*(@[A-Za-z0-9_-]+)?$(允许大写、点号分段、@后缀、-/_开头;@后缀内不含点号,与 v1 一致)。packages/agent-core-v2/src/features/skill/tools/skill.ts:Skill 工具skill参数描述改为The exact name of the skill to invoke, copied verbatim from the current skill listing.TUI 侧配套修复
apps/kimi-code/src/tui/commands/resolve.ts的斜杠命令解析顺序——plugin skill 获得全限定名后与 plugin 命令(<pluginId>:<command>)命名形态相同,旧顺序下 skill 简写会彻底遮蔽同名 plugin 命令:docs/en|zh/customization/plugins.md同步:name字段规则、Skills 与会话启动一节补全限定名与同名优先级说明、datasource 调用示例改为/skill:kimi-datasource:kimi-datasource;docs/en|zh/reference/slash-commands.md简写前提补充"或插件命令"。Behavior Changes and Affected Users
name校验[a-z0-9][a-z0-9_-]{0,63},含大写/点号/@的 manifest 报错无法安装@后缀、-/_开头<pluginId>:<skillName>注册与调用,同名 plugin skill 全部可见;裸名空间归还 user/project/extra/builtin/skill:<name>手动调用者/skill:kimi-datasource:kimi-datasource,文档已同步/pluginId:name的解析(plugin 命令与 plugin skill 同名时)/skill:pluginId:name触达/skill:...形态(skill 激活不受 busy 限制)name字段/api/v1消费 skill 列表的 desktop/web 客户端、@moonshot-ai/kimi-code-sdk调用方skill参数描述(prompt 文本)spelled as it appears in the current skill listing (e.g. "commit", "pdf")——静态裸名例子诱导模型剥掉plugin:前缀再调用而 misscopied verbatim from the current skill listing.——锚定列表、删除静态例子<plugin_session_start>块)byPluginAndName仍存裸名副本sessionStart.skill的 plugin受影响模块与测试覆盖:
src/app/plugin/types.ts:test/app/plugin/types.test.ts更新为新规则的 accept/reject 用例(含@后缀不含点号的边界)。src/features/skill/catalog/registry.ts:test/features/skill/catalog/registry.test.ts新增 4 个用例(跨 plugin 同名仅以全限定名可见、plugin 不遮蔽其他来源裸名、全限定名保留 plugin 上下文使 instructions 注入正常、catalog remerge 重复注册幂等无双前缀);test/features/skill/workspace/skillCatalog.test.ts两处裸名断言改为全限定名;test/features/skill/catalog/plugin-session-start.test.ts未改动并全部通过,钉住 session-start 路径不变。src/features/skill/tools/skill.ts:test/tool/tool.test.ts、test/agent/loop/loop.test.ts的llm.tools_snapshot快照更新,钉住新 schema 文案。apps/kimi-code/src/tui/commands/resolve.ts:test/tui/commands/resolve.test.ts新增 5 个优先级用例(简写解析、无命令时的全限定名简写、同名时命令优先、显式/skill:仍可达 skill、streaming 中同名输入按命令 block),26 个用例全过;oxlint、tsc --noEmit通过。foreground subagent times out,与本次改动无关);tsc --noEmit、oxlint、check-no-comments通过。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.