Skip to content

fix(coding-agent): preserve .agents provenance in skill metadata#4028

Closed
aliou wants to merge 1 commit into
earendil-works:mainfrom
aliou:fix/resource-location-in-config-tui
Closed

fix(coding-agent): preserve .agents provenance in skill metadata#4028
aliou wants to merge 1 commit into
earendil-works:mainfrom
aliou:fix/resource-location-in-config-tui

Conversation

@aliou

@aliou aliou commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Hello! This closes #3978.

Initially, I had a bandaid fix that simply handled this edgecase, but decided instead to split how we discover skills so that we can keep their source and use it to group in the ui and display it in the header.

Let me know if you need additional changes!

Before

Screenshot 2026-04-30 at 07 24 21 PM@2x

After

Screenshot 2026-04-30 at 07 24 35 PM@2x

Investigation: https://pi.dev/session/#a4b89b5a3f90a4cd7d3ff99e11e24a73
Implementation: https://pi.dev/session/#7fe2ed220359a79a8e9f8d9841edc446


Summary by moonshotai/Kimi-K2.5:

Fixes #3978

Problem
pi config grouped auto-discovered skills from ~/.agents/skills under User (~/.pi/agent/) because both directories received identical metadata (baseDir: ~/.pi/agent, source: "auto"). The same issue existed for project .agents/skills.

Root Cause
In addAutoDiscoveredResources(), all auto-discovered skills were flattened into single addResources() calls before assigning metadata, losing provenance information about which root directory each skill came from.

Changes

packages/coding-agent/src/core/package-manager.ts:

  • Split auto-discovered skill handling to preserve provenance
  • User ~/.agents/skills now gets baseDir: ~/.agents (was ~/.pi/agent)
  • Each project .agents/skills directory gets its own baseDir pointing to its parent .agents dir
  • Skills from .pi directories continue to use their .pi baseDir as before

packages/coding-agent/src/modes/interactive/components/config-selector.ts:

  • Added baseDir to group key to prevent collapsing different sources
  • Added cross-platform formatBaseDir() helper that normalizes Windows backslashes
  • Updated group labels to show actual baseDir (e.g., User (~/.agents/))

packages/coding-agent/test/package-manager.test.ts:

  • Added HOME environment mocking to symlink test to prevent interference from real ~/.agents directory

Verification

  • All 99 package-manager tests pass
  • npm run check passes (lint, format, typecheck)
  • Four new tests verify correct metadata assignment for each skill source type

@aliou aliou force-pushed the fix/resource-location-in-config-tui branch from 407263e to ee94e65 Compare April 30, 2026 21:30
@aliou aliou force-pushed the fix/resource-location-in-config-tui branch from ee94e65 to 0f95975 Compare May 6, 2026 07:41
@aliou aliou closed this by deleting the head repository May 8, 2026
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.

pi config hardcodes ~/.pi/agent/ path in group label, ignores actual resource location

1 participant