Skip to content

fix: improve skill discovery and list output#17

Open
KirioXX wants to merge 8 commits into
Karanjot786:mainfrom
KirioXX:fix/improve-skill-discovery
Open

fix: improve skill discovery and list output#17
KirioXX wants to merge 8 commits into
Karanjot786:mainfrom
KirioXX:fix/improve-skill-discovery

Conversation

@KirioXX

@KirioXX KirioXX commented Jun 4, 2026

Copy link
Copy Markdown

Description

Fix skill discovery so skills list can find skills installed via skills install across canonical storage (~/.skills, ./.skills) and agent-specific directories. Also adds
source paths to skills list output for easier inspection, and updates docs/tests accordingly.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring

Testing

  • npm run build passes
  • Tested with skills --help
  • Tested relevant commands

Checklist

  • Code follows existing style
  • Self-reviewed my code
  • Added comments for complex code
  • Updated docs if needed

Fixes #15

Summary by CodeRabbit

  • New Features

    • Expanded skill discovery to check canonical locations (~/.skills, ./.skills) and agent-specific directories
    • Skills list now shows each skill’s source path (JSON/table includes a “Source” column); descriptions shown only in verbose mode
    • Duplicate skills across locations are deduplicated, preferring the canonical path
  • Tests

    • Added tests covering discovery paths and deduplication
  • Documentation

    • README and planning docs updated with skill discovery path details

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8f1a0a42-7b44-4061-be73-18d4ce20840c

📥 Commits

Reviewing files that changed from the base of the PR and between df37628 and eb8a3f1.

📒 Files selected for processing (5)
  • README.md
  • docs/superpowers/plans/2026-06-01-skill-discovery-paths.md
  • src/cli/commands/list.ts
  • src/core/loader.test.ts
  • src/core/loader.ts
✅ Files skipped from review due to trivial changes (1)
  • docs/superpowers/plans/2026-06-01-skill-discovery-paths.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/core/loader.test.ts
  • src/cli/commands/list.ts

📝 Walkthrough

Walkthrough

Expands discovery to include canonical (~/.skills, ./​.skills) and agent-specific directories, deduplicates discovered skills by metadata.name, exposes agent discovery helpers, integrates merged search paths into skills list output (including source paths), and adds tests and documentation.

Changes

Skill Discovery Path Expansion and Deduplication

Layer / File(s) Summary
Core loader discovery paths and deduplication
src/core/loader.ts
getDefaultSkillPaths(cwd, home) centralizes discovery roots; DEFAULT_SKILL_PATHS is derived from it. discoverSkills() globs **/SKILL.md per-root (cwd roots, dot files, maxDepth), loads metadata, and deduplicates results by metadata.name, returning one SkillRef per name.
Loader regression tests
src/core/loader.test.ts
Tests assert default search paths include ~/.skills and ./.skills, and that two identical skills under different roots are deduplicated to a single canonical path.
Agent-specific discovery configuration
src/cli/agents.ts
AgentConfig gains optional discoveryDirs?: string[]. getAgentDiscoveryPaths(agent) aggregates globalDir, projectDir, and discoveryDirs with legacy fallbacks for unknown agents; getAllAgentDiscoveryPaths() unions deduped roots across agents.
List command integration and output formatting
src/cli/commands/list.ts, src/cli/commands/list.test.ts
Add ListedSkill type and helpers: getListSearchPaths() (merges DEFAULT_SKILL_PATHS + getAllAgentDiscoveryPaths()), formatSkillSourcePath(), getListJsonEntry(), getListDisplayLines(). registerListCommand() uses merged search paths for discoverSkills, includes sourcePath in JSON, adds a “Source” table column, always prints Source in default output, and prints description only with --verbose. Tests verify search path contents and sourcePath presence.
Documentation and implementation plan
README.md, docs/superpowers/plans/2026-06-01-skill-discovery-paths.md
README adds a discovery note describing canonical and agent-specific search paths. The plan document details tasks: tests, production changes (getDefaultSkillPaths, DEFAULT_SKILL_PATHS, updated discoverSkills with dedupe), and verification steps.

Sequence Diagram

sequenceDiagram
  participant User
  participant ListCmd as registerListCommand
  participant SearchPaths as getListSearchPaths
  participant Discovery as discoverSkills
  participant Output as formatters
  User->>ListCmd: skills list [--verbose]
  ListCmd->>SearchPaths: getListSearchPaths()
  SearchPaths->>Discovery: DEFAULT_SKILL_PATHS + getAllAgentDiscoveryPaths()
  Discovery->>Discovery: glob **/SKILL.md (per-root), load metadata, dedupe by metadata.name
  Discovery-->>ListCmd: SkillRef[] (deduped)
  ListCmd->>Output: getListJsonEntry() / getListDisplayLines()
  Output-->>ListCmd: formatted entries (include sourcePath)
  ListCmd-->>User: JSON/table/default output
Loading

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 A discovery quest begins, no more hiding spots!
Paths now merge, dedupes abound, skill names unite,
List command shines with source paths and verbose delight!
Home to agents, canonical to custom, all searching as one,
Agent skills CLI just got its discovery done! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: improve skill discovery and list output' is concise, clear, and accurately summarizes the primary changes: fixing skill discovery and improving the list command output.
Linked Issues check ✅ Passed All key requirements from issue #15 are addressed: discovery paths now include canonical storage (~/.skills, ./.skills), agent-specific directories are supported, and installed skills are now discoverable via skills list.
Out of Scope Changes check ✅ Passed All changes are directly related to resolving issue #15: skill discovery path alignment, list command improvements, supporting tests, documentation, and README updates are all in scope.
Docstring Coverage ✅ Passed Docstring coverage is 94.12% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai 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.

Actionable comments posted: 6

🧹 Nitpick comments (1)
docs/superpowers/plans/2026-06-01-skill-discovery-paths.md (1)

44-61: 💤 Low value

Plan test code differs from actual implementation.

The test structure in the plan uses paths like join(root, 'home', '.skills', 'demo-skill') and join(root, 'repo', '.agent', 'skills', 'demo-skill') (lines 46-47, 55), but the actual implementation shown in context snippets uses simpler paths like join(root, 'canonical', 'demo-skill') and join(root, 'agent', 'demo-skill').

While the test logic is equivalent, the discrepancy between plan and implementation could confuse readers referencing this document.

📝 Optional update to match actual implementation
-    const canonical = join(root, 'home', '.skills', 'demo-skill');
-    const agentDir = join(root, 'repo', '.agent', 'skills', 'demo-skill');
+    const canonical = join(root, 'canonical', 'demo-skill');
+    const agentDir = join(root, 'agent', 'demo-skill');
 
     await mkdir(canonical, { recursive: true });
     await mkdir(agentDir, { recursive: true });
@@ -52,7 +52,7 @@
     await writeFile(join(agentDir, 'SKILL.md'), skillMd);
 
     const skills = await discoverSkills({
-      searchPaths: [join(root, 'home', '.skills'), join(root, 'repo', '.agent', 'skills')],
+      searchPaths: [join(root, 'canonical'), join(root, 'agent')],
       maxDepth: 3,
     });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/superpowers/plans/2026-06-01-skill-discovery-paths.md` around lines 44 -
61, Test path literals in the plan differ from the actual implementation which
uses simpler directories; update the plan's example test to match the
implementation by replacing occurrences of join(root, 'home', '.skills',
'demo-skill') and join(root, 'repo', '.agent', 'skills', 'demo-skill') with the
actual canonical/agent layout used by discoverSkills (e.g., join(root,
'canonical', 'demo-skill') and join(root, 'agent', 'demo-skill')), and likewise
adjust the created directory variables (canonical, agentDir) and the searchPaths
passed to discoverSkills so the example matches the real code paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/superpowers/plans/2026-06-01-skill-discovery-paths.md`:
- Around line 99-107: The plan's getDefaultSkillPaths implementation is missing
two entries present in the real loader: add join(home, ".gemini", "antigravity",
"skills") and the ".agent/skills" path to the returned array in
getDefaultSkillPaths so the plan matches the actual implementation; locate the
getDefaultSkillPaths function and update its returned list to include these two
paths in the appropriate order to mirror the loader.
- Around line 1-12: Add an H2 heading "## Implementation Tasks" immediately
after the existing H1 "Skill Discovery Paths Implementation Plan" and before the
current Task 1 section (the first H3), so the document follows proper Markdown
heading hierarchy; update any references or anchors that assume the previous
structure if needed.

In `@README.md`:
- Around line 251-252: The discovery note block (the quoted line starting with
"**Discovery note:** `skills list`...") was inserted between table rows and
breaks the Markdown table; move that entire quote out of the table body and
place it either immediately above or below the table (for example after the
table closure) so the table rows (including the OpenCode row and subsequent
agent information) render correctly; update the README.md by removing the quote
from inside the table and inserting it as a standalone paragraph outside the
table boundaries.

In `@src/cli/commands/list.ts`:
- Around line 63-69: The printed skill-paths are hardcoded; update the block in
src/cli/commands/list.ts to print the actual computed search paths instead.
Locate where the skill discovery array is built (e.g., variable or function name
like searchPaths, skillSearchPaths, or getSkillSearchPaths) and replace the
fixed console.log lines with code that logs the header ("Skills are searched
in:") then iterates over that array and logs each path with chalk.gray. Ensure
you reference the existing computed array name
(searchPaths/skillSearchPaths/getSkillSearchPaths) so the output always reflects
the real discovery locations.

In `@src/core/loader.test.ts`:
- Around line 17-21: The test is using process.env.HOME which can differ from
the OS homedir used in production; update the assertion to use homedir() instead
of process.env.HOME so DEFAULT_SKILL_PATHS is compared against join(homedir(),
".skills"); ensure you import homedir from 'os' at the top of the test file if
it's not already imported and keep the rest of the assertions (e.g.,
join(process.cwd(), ".skills")) unchanged.

In `@src/core/loader.ts`:
- Line 63: The discovery config currently sets maxDepth using the
falsy-coalescing pattern (config.maxDepth || 3) which ignores an explicit 0;
change this to use an undefined-only fallback so 0 is respected (e.g., use the
nullish coalescing operator or an explicit undefined check). Update the location
where maxDepth is assigned (the object property maxDepth in loader/discovery
setup that references config.maxDepth) to use config.maxDepth ?? 3 or
(config.maxDepth !== undefined ? config.maxDepth : 3) so an explicit maxDepth: 0
is honored.

---

Nitpick comments:
In `@docs/superpowers/plans/2026-06-01-skill-discovery-paths.md`:
- Around line 44-61: Test path literals in the plan differ from the actual
implementation which uses simpler directories; update the plan's example test to
match the implementation by replacing occurrences of join(root, 'home',
'.skills', 'demo-skill') and join(root, 'repo', '.agent', 'skills',
'demo-skill') with the actual canonical/agent layout used by discoverSkills
(e.g., join(root, 'canonical', 'demo-skill') and join(root, 'agent',
'demo-skill')), and likewise adjust the created directory variables (canonical,
agentDir) and the searchPaths passed to discoverSkills so the example matches
the real code paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dcd1f777-149d-4405-bbbb-0fd75524954a

📥 Commits

Reviewing files that changed from the base of the PR and between 956140b and 909c1ce.

📒 Files selected for processing (7)
  • README.md
  • docs/superpowers/plans/2026-06-01-skill-discovery-paths.md
  • src/cli/agents.ts
  • src/cli/commands/list.test.ts
  • src/cli/commands/list.ts
  • src/core/loader.test.ts
  • src/core/loader.ts

Comment thread docs/superpowers/plans/2026-06-01-skill-discovery-paths.md Outdated
Comment thread docs/superpowers/plans/2026-06-01-skill-discovery-paths.md Outdated
Comment thread README.md Outdated
Comment thread src/cli/commands/list.ts Outdated
Comment thread src/core/loader.test.ts Outdated
Comment thread src/core/loader.ts Outdated
KirioXX added 7 commits June 4, 2026 16:33
…nstallPath docs

Add proper JSDoc documentation to functions in list.ts:
- getListSearchPaths
- formatSkillSourcePath
- getListJsonEntry
- getListDisplayLines

Improve getInstallPath docstring in agents.ts with param and return documentation.

Fixes CodeRabbit docstring coverage warning (70.59% → 80%+ threshold)
Add h2 '## Implementation Tasks' section heading between h1 and Task 1 (h3)
to fix markdownlint heading hierarchy violation.

Fixes CodeRabbit minor issue: heading jump from h1 to h3
…tion

Update the getDefaultSkillPaths code snippet in the implementation plan
to match the actual code:
- Add missing join(home, '.gemini', 'antigravity', 'skills') path
- Add missing '.agent/skills' path
- Add clarifying comments for path categories

Fixes CodeRabbit minor issue: plan/implementation mismatch
The discovery note was inserted between table rows (after Antigravity,
before OpenCode), which broke the Markdown table structure. Moved the
note outside the table after the '+32 more agents' line.

Fixes CodeRabbit major issue: broken table rendering
Replace the hardcoded list of search paths in the 'No skills found'
message with a dynamic loop over config.searchPaths. This ensures
output always reflects the actual discovery locations including
agent-specific directories.

Fixes CodeRabbit minor issue: stale hardcoded paths
Use the homedir() function from the 'os' module instead of
process.env.HOME to align test path resolution with production code.
This prevents environment-dependent test failures.

Fixes CodeRabbit minor issue: environment-dependent path resolution
Change maxDepth fallback from || (falsy) to ?? (nullish) so that
an explicit maxDepth: 0 is respected instead of being replaced with 3.

Fixes CodeRabbit minor issue: falsy-coalescing ignored explicit 0
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.

[BUG] skills list does not discover installed skills because discovery paths differ from install paths

1 participant