Skip to content

fix(skill): dedupe skills with identical SKILL.md content#890

Open
sailist wants to merge 2 commits into
MoonshotAI:mainfrom
sailist:fix/dedupe-duplicate-skills
Open

fix(skill): dedupe skills with identical SKILL.md content#890
sailist wants to merge 2 commits into
MoonshotAI:mainfrom
sailist:fix/dedupe-duplicate-skills

Conversation

@sailist

@sailist sailist commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

Problem

When a parent skill bundle has has-sub-skill: true, the scanner walks its nested sub-skill directories (e.g. outer/child/SKILL.md) and registers qualified names such as outer.child. Some setups also ship the same sub-skill as a flattened copy (e.g. outer__child/SKILL.md) with byte-identical SKILL.md content. Previously both copies were registered, so the same skill showed up twice — once under the qualified sub-skill name and once under the flattened directory name.

What changed

  • Hash each discovered SKILL.md with SHA-256 and track seen content during discovery.
  • Skip re-registering a skill whose content was already registered.
  • When a duplicate collides, prefer the qualified sub-skill form over a non-sub-skill entry so the canonical name wins.
  • Added a test covering the flattened-copy dedupe case.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

sailist added 2 commits June 18, 2026 16:36
- hash SKILL.md content with sha256 during discovery
- skip re-registering a skill whose content was already seen
- prefer the sub-skill form when a duplicate collides with a parent copy
@changeset-bot

changeset-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 30d87e2

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 Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 18, 2026

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

commit: 30d87e2

@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: 30d87e23e9

ℹ️ 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".

Comment on lines +404 to +408
const existing = input.byContent.get(contentHash);
if (existing !== undefined) {
const preferCurrent =
discovered.metadata.isSubSkill === true && existing.metadata.isSubSkill !== true;
if (!preferCurrent) return undefined;

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 Do not dedupe every identical content hash

When two distinct skills happen to have byte-identical markdown, this returns before onDiscoveredSkill and before adding the second name. That drops legitimate cases such as foo.md and bar.md with the same body but different filename-derived names, and it also prevents SessionSkillRegistry.loadRoots from indexing the second plugin's copy for getPluginSkill when two enabled plugins vendor the same startup SKILL.md; those are not flattened sub-skill duplicates and should remain addressable.

Useful? React with 👍 / 👎.

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.

1 participant