Skip to content

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

Merged
badlogic merged 1 commit into
earendil-works:mainfrom
aliou:fix/resource-location-in-config-tui
May 8, 2026
Merged

fix(coding-agent): preserve .agents provenance in skill metadata#4299
badlogic merged 1 commit into
earendil-works:mainfrom
aliou:fix/resource-location-in-config-tui

Conversation

@aliou

@aliou aliou commented May 8, 2026

Copy link
Copy Markdown
Contributor

Note

This is a re-open of #4028 , deleted my fork without thinking

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

@badlogic badlogic merged commit dfb9ffa into earendil-works:main May 8, 2026
4 checks passed
@badlogic

badlogic commented May 8, 2026

Copy link
Copy Markdown
Collaborator

cheers!

@aliou aliou deleted the fix/resource-location-in-config-tui branch May 8, 2026 15:59
larsboes pushed a commit to larsboes/pi-mono that referenced this pull request May 17, 2026
…on-in-config-tui

fix(coding-agent): preserve .agents provenance in skill metadata
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

2 participants