Skip to content

fix(search): search installed skills across all agents - #87

Merged
harlan-zw merged 2 commits into
skilld-dev:mainfrom
mrrobertkent:fix/search-across-agents
Aug 13, 2026
Merged

fix(search): search installed skills across all agents#87
harlan-zw merged 2 commits into
skilld-dev:mainfrom
mrrobertkent:fix/search-across-agents

Conversation

@mrrobertkent

Copy link
Copy Markdown
Contributor

Problem

skilld search reports nothing indexed when a project has more than one agent directory.

$ skilld search "config file" -p unlighthouse
▲  No docs indexed for "unlighthouse". Run `skilld add unlighthouse` first.

$ skilld list
unlighthouse-skilld  0.18.0  harlan-zw/unlighthouse/tree/v0.18.0/docs  today

readProjectLock resolved the lockfile through detectTargetAgent():

const agent = detectTargetAgent()
if (!agent)
  return null
return readLock(`${cwd}/${agents[agent].skillsDir}`)

detectTargetAgent() checks agent env vars first, then scans the project and returns null when several match:

return projectMatches.length === 1 ? projectMatches[0]! : null

A project with .claude/ and .agents/ produces null, so listLockPackages() returns [] and search bails. It only worked when run from inside an agent, where the env var short-circuits detection. From an ordinary terminal it always failed.

Change

Indexes are keyed by package and version:

export function getPackageDbPath(name: string, version: string): string {
  return join(getReferencesDir(name, version), 'search.db')
}

Nothing about them is agent-specific, so scoping the lockfile to one agent only hides skills the project has. iterateSkills in the same module already reads every agent by default, which is why skilld list works:

const agentTypes = opts.agents ?? (Object.keys(agents) as AgentType[])

Search now does the same, merged through the existing mergeLocks, which prefers the most recent syncedAt per skill. A skill installed for two agents resolves to one index, so the union deduplicates by construction.

--agents narrows when that is wanted:

skilld search "routing"
skilld search "routing" --agents claude-code
skilld search "routing" --agents claude-code,codex

Named --agents because the root command owns -a/--agent as an enum and citty validates parent args.

readProjectLock moves from commands/search-helpers.ts to core/skills.ts, next to the equivalent skill-directory resolution.

Coverage

test/unit/project-lock.test.ts covers no lockfile, a single agent, merging across agents, deduplication by newest syncedAt, narrowing by agent, an agent with no lockfile, and a shared .skills directory taking precedence.

Docs

README documents --agents in the command table, adds an example, and notes that search spans every agent by default.

mrrobertkent and others added 2 commits August 12, 2026 11:58
Search resolved the project lockfile through `detectTargetAgent()`, which
returns null when a project contains more than one agent directory. With
`.claude/` and `.agents/` both present it reported no indexed docs, even
though the index existed.

Indexes are keyed by package and version, not by agent, so scoping the
lockfile to a single agent hid skills the project has. Read every agent's
lockfile and merge, matching `iterateSkills`. `--agents` narrows to specific
agents when that is wanted.

`readProjectLock` moves to `core/skills.ts`, alongside the equivalent
skill-directory resolution.
@harlan-zw
harlan-zw merged commit fb18517 into skilld-dev:main Aug 13, 2026
1 check passed
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.

2 participants