Skip to content

fix(core): prefer nearest skill source - #41788

Merged
kitlangton merged 1 commit into
v2from
nearest-skill-source
Aug 11, 2026
Merged

kitlangton merged 1 commit into
v2from
nearest-skill-source

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Ensure duplicate discovered skill IDs resolve to the source nearest the session directory. In a nested git worktree, the worktree copy now wins over a farther parent checkout copy, keeping the selected skill on the checked-out branch and inside the session directory.

Closes #39871

Before / After

Before: Config ancestor discovery returned nearby .agents and .claude directories first. The skill plugin applies later-source precedence, so a duplicate skill from the farther parent checkout replaced the worktree copy and could trigger an external_directory permission request.

After: Discovered .agents and .claude directories are ordered from farthest to nearest. Existing later-source precedence deterministically selects the nearest duplicate skill, including its local SKILL.md location.

How

  • Order ancestor .agents and .claude config entries from low to high priority, consistent with direct config and .opencode discovery.
  • Add a filesystem regression shaped like a parent checkout and nested linked worktree, with duplicate skill IDs in both locations.
  • Update the existing cross-project-boundary config assertion to reflect the corrected source priority.

Scope

This preserves the cross-git/project-boundary ancestor discovery introduced by #36577. It does not restore a git-root stop boundary: farther parent checkout config and skills are still discovered when no nearer source overrides them.

Testing

  • bun run test test/config/skill.test.ts from packages/core (9 passed)
  • bun run test test/config/config.test.ts from packages/core (33 passed)
  • bun typecheck from packages/core (passed)
  • Pre-push bun turbo typecheck --concurrency=3 (33 tasks passed)
  • bunx prettier --check src/config.ts test/config/config.test.ts test/config/skill.test.ts from packages/core (passed)

The new regression was run before the implementation change and failed with Expected: "Worktree", Received: "Parent checkout"; it passes after the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant