Skip to content

feat(agent-core-v2): register plugin skills under qualified names and relax plugin name validation - #4188

Merged
sailist merged 3 commits into
MoonshotAI:mainfrom
oocz:feat/plugin-skill-qualified-names
Oct 13, 2026
Merged

sailist merged 3 commits into
MoonshotAI:mainfrom
oocz:feat/plugin-skill-qualified-names

Conversation

@oocz

@oocz oocz commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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):

 register(skill)
-  byName[bareName] ??= skill        // plugin skill 也占裸名,first-wins
-  indexPluginSkill(skill)           // byPluginAndName 仅供 session-start 查询
+  if skill.plugin !== undefined
+    bareName = 剥离已有的 "<id>:" 前缀   // catalog remerge 会把列表项重新 register,需幂等
+    byPluginAndName[id\0bareName] ??= { ...skill, name: bareName }   // session-start 注入保持不变
+    byName["<id>:<bareName>"] ??= { ...skill, name: qualifiedName }  // 模型列表/调用的唯一入口
+  else
+    byName[bareName] ??= skill

另外两处单行修改:

  • 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 命令:

 resolveSlashCommandInput
   系统命令
-  skill 解析(精确键 + skill: 简写,先于 plugin command)  // 同名 plugin 命令无法触达
-  plugin command
+  精确 skill 键(builtin 裸名 / skill:* 显式形态 / 子 skill 点分名)
+  plugin command            // <pluginId>:<name> 同名输入归还命令
+  skill: 简写               // 同名 skill 仍可经 /skill:<pluginId>:<name> 触达

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

行为 改动前 改动后 依赖旧行为的人群 退路
plugin manifest name 校验 仅接受 [a-z0-9][a-z0-9_-]{0,63},含大写/点号/@ 的 manifest 报错无法安装 接受大写、点号分段、@ 后缀、-/_ 开头 无——旧合法名是新集合的子集,只有此前被拒的 plugin 作者现在可以安装 不需要
plugin skill 的模型列表名与调用名 plugin skill 占用裸名、first-wins:跨 plugin 同名只有胜者可见可调,plugin 裸名还可遮蔽 user/project 同名 skill plugin skill 仅以 <pluginId>:<skillName> 注册与调用,同名 plugin skill 全部可见;裸名空间归还 user/project/extra/builtin 在会话 prompt 或习惯中按裸名调用 plugin skill 的用户与模型;/skill:<name> 手动调用者 改用全限定名(changeset 已写明失去的裸名行为);官方 datasource 插件现为 /skill:kimi-datasource:kimi-datasource,文档已同步
TUI 斜杠输入 /pluginId:name 的解析(plugin 命令与 plugin skill 同名时) skill 简写优先,同名 plugin 命令无法触达 plugin 命令优先;skill 经显式 /skill:pluginId:name 触达 安装了命令与 skill 同名插件的 TUI 用户;streaming 中该输入由排队激活 skill 变为按命令 block 显式 /skill:... 形态(skill 激活不受 busy 限制)
会话 skill 列表中 plugin skill 的 name 字段 裸名 全限定名 TUI skill 选择器、经 kap-server /api/v1 消费 skill 列表的 desktop/web 客户端、@moonshot-ai/kimi-code-sdk 调用方 无(展示层直通内核列表,随列表自然呈现)
Skill 工具 schema 中 skill 参数描述(prompt 文本) spelled as it appears in the current skill listing (e.g. "commit", "pdf")——静态裸名例子诱导模型剥掉 plugin: 前缀再调用而 miss copied verbatim from the current skill listing.——锚定列表、删除静态例子 每个会话的模型请求 由列表中的全限定名本体与该句强指令共同约束
plugin session-start 注入(<plugin_session_start> 块) 按 pluginId + 裸名索引 逐字节不变: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 通过。
  • 验证:agent-core-v2 全量 7104 通过,1 个失败为基线同样失败的既有超时用例(foreground subagent times out,与本次改动无关);tsc --noEmit、oxlint、check-no-comments 通过。

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 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 727a66a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Minor

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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 ⚠️ Failed 2026-10-13T06:26:29.285615Z 727a66a New commits
ℹ️ 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 13, 2026 •

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

commit: 727a66a

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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_-]+)?$/;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@sailist

sailist commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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 });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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_-]+)?$/;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread docs/zh/customization/plugins.md Outdated

`sessionStart.skill` 在会话启动时把一个 plugin Skill 加载到 main agent,适合放置初始化说明、工作流规则,或把其他工具中的术语映射到 Kimi Code CLI。它只注入文本,不执行代码。

Plugin Skill 以全限定名 `<plugin-id>:<skill-name>` 列出和调用(例如 `/skill:my-plugin:using-my-plugin`),与[插件斜杠命令](#插件斜杠命令)的命名方式一致:不同插件的同名 Skill 互不冲突,裸名不会解析到 plugin Skill。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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_-]+)?$/;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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_-]+)?$/;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +90 to +92
const exactSkillName = options.skillCommandMap.get(parsed.name);
if (exactSkillName !== undefined) {
return skillCommandIntent(parsed, exactSkillName);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@oocz
oocz force-pushed the feat/plugin-skill-qualified-names branch from ad7a126 to 727a66a Compare October 13, 2026 06:14
@ZakharYA

Copy link
Copy Markdown

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 <skillName> format, and users might not even notice that something is broken right away.

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.

3 participants