fix(search): search across all agents, add --agents filter - #85
Closed
mrrobertkent wants to merge 1 commit into
Closed
fix(search): search across all agents, add --agents filter#85mrrobertkent wants to merge 1 commit into
mrrobertkent wants to merge 1 commit into
Conversation
`readProjectLock` resolved the lockfile via `detectTargetAgent()`, which returns null when a project has more than one agent directory. Search then reported nothing indexed even with a populated index on disk. Reproduces in any project with, say, `.claude/` and `.agents/` when run from a shell with no agent env var set, which is the normal case for a human in a terminal. Indexes are keyed by package and version, never by agent, so scoping the lockfile to one agent only hid skills the project has. Merge every agent dir instead, deduplicated by `mergeLocks`, and add `--agents` to narrow when that is wanted. Moves `readProjectLock` from `commands/search-helpers.ts` to `core/skills.ts`, alongside the other agent-aware project resolution.
Contributor
Author
|
Closing in favour of a clean branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
skilld searchreports nothing indexed when a project has more than one agent directory.readProjectLockresolved the lockfile throughdetectTargetAgent():detectTargetAgent()checks agent env vars first, then falls back to scanning the project and returns null when several match:The project above has
.claude/and.agents/, so detection returns null,listLockPackages()returns[], and search bails. It only worked when run from inside an agent, where the env var short-circuits detection. From a plain terminal it always failed.It also ignores
agent: claude-codein the user's config.Change
Indexes are keyed by package and version (
getPackageDbPath(name, version)), never by agent, so restricting the lockfile to one agent only hides skills the project has. Reading one agent's dir was never the right question.Merge every agent dir instead, deduplicated by the existing
mergeLocks, which already prefers the most recentsyncedAtper skill. A skill installed for two agents resolves to the same index, so the union is deduplicated by construction.--agentsnarrows it when that is wanted:Named
--agentsrather than--agentbecause the root command already owns-a/--agentas an enum, and citty validates parent args.readProjectLockmoves fromcommands/search-helpers.tstocore/skills.ts, which already imports the agent registry and owns the equivalent resolution for skill dirs. It is project state, not a search detail.Testing
test/unit/project-lock.test.ts, 7 tests over a temp project: no lockfile, single agent, merge across agents, dedupe preferring newestsyncedAt,agentFilternarrowing, unknown agent, and shared.skillsdir taking precedence.pnpm typecheckclean. Verified end to end against the reproduction above: default now returns results,--agents codexcorrectly reports nothing for a skill installed only under Claude Code, and an unknown id errors with the available list.Docs
README updated:
--agentsin the command table, an example in the search block, and a note that search spans all agents by default.