Repository navigation
Discover nested and linked Pi skills like Pi does - #5519
Merged
Merged
Conversation
Pi scans its skill roots recursively and follows symlinked bundles; bb declared them shallow, so nested skills never appeared. Declare Pi's declared and resolved skill roots recursive, and make the recursive walker follow user-origin directory links (with a cycle guard), stop at the first SKILL.md, and skip dot directories and node_modules, matching Pi's loader. Fixes #5364 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pi reads .agents/skills from the cwd up to the repository root, so the project root now walks ancestors. Cursor, Grok, and Hermes keep scanning inside skill folders and only skip a few known directories, so the recursive walker no longer stops at the first SKILL.md and skips only .git and node_modules; following user-origin links stays, as every one of these agents does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 15, 2026
ymichael
added a commit
that referenced
this pull request
Oct 17, 2026
## Human comments ## What was wrong Imported skills discovered through a symlinked directory retain their logical path. The Skills detail page and CLI then use that directory as the root for `host.read_file_relative` and `host.list_files`, whose host-side validation rejects symlink roots. A listed, readable Pi skill therefore shows `Failed to load SKILL.md.`; both `bb skill show` and `bb skill files` return HTTP 502. This remains reproducible with the file handler from upstream `main` at `05771e3c82404328854468f0fff7f0f8203e2076`. The reproduction and investigation are in #5555. Merged #5519 fixes discovery, while this change fixes the subsequent detail reads. ## What changed - Add a required `followRootSymlink` boolean to the two host file RPCs. The server opts in for skill content and file-list reads; other callers explicitly pass `false`. - When opted in, the host resolves the root before using the existing directory and relative-file validation. Relative reads stay confined to the resolved skill directory, dotfiles remain denied, and file listings continue to skip nested symlinks. Linked skills remain non-manageable. - Increment `HOST_DAEMON_PROTOCOL_VERSION` from **240 to 241** for the required wire fields, update existing callers and contract fixtures, and document the policy in `docs/debugging-and-qa.md`. - A followed root that no longer exists (removed target or dangling link) returns the usual missing-file `ENOENT` error instead of a raw filesystem error. - The existing SDK and CLI skill operations use the same server paths; there are no new user-facing flags or configuration. ## How you verified - Reproduced the installed BB 0.46.0 failure using both `bb skill show` and `bb skill files` against a real Pi directory link. The target `SKILL.md` exists and resolves successfully. - Added an owner-boundary regression covering listing a linked directory, reading `SKILL.md` and a nested reference, hiding dotfiles, rejecting `..`, and rejecting a nested link escaping the resolved root. With `host-files.ts` taken from latest upstream `main`, it fails with `Path "…/research" must not be a symlink`; it passes with this fix. - Extended the server skill-detail test to check that both RPCs receive the explicit opt-in. Existing generic file-root rejection tests continue to pass with `false`. - After rebasing onto the checked upstream `main`, all **168 focused tests passed**: ```sh pnpm exec turbo run test --filter=@bb/host-daemon -- test/command/workspace-dispatch.test.ts src/command-handlers/host-files.test.ts src/command-handlers/list-skills.test.ts pnpm exec turbo run test --filter=@bb/server -- test/public/public-project-skills.test.ts test/files/host-file-routes.test.ts test/internal/internal-environment-change.test.ts pnpm exec turbo run test --filter=@bb/host-daemon-contract -- test/contract.test.ts pnpm exec turbo run lint typecheck --filter=@bb/host-daemon --filter=@bb/server --filter=@bb/host-daemon-contract ``` - Formatting and `git diff --check` passed. Source verification used Node 22.19.0 and pnpm 9.15.0 on macOS arm64. The installed desktop app was not replaced; post-fix browser/desktop UI verification has not been run. - Commandeered by a maintainer: merged current `main` (protocol 240 → 241) and added the missing-root handling above, with a dangling-link case in the regression test. Re-ran the focused host-daemon, server (8 files touching these RPCs), and contract suites plus lint/typecheck; all pass. Fixes #5555 > AGENT GENERATED --------- Co-authored-by: Michael Yong <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
3 tasks done
2 tasks done
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.
Human comments
What was wrong
Pi discovers skills at any depth under its skill roots and follows symlinked folders (its loader has done so since at least 0.27.1). BB's Pi plugin declared its four skill roots as plain strings, which default to
recursive: false, so BB only scanned one level. Skills in grouping folders (~/.pi/agent/skills/team/<skill>/SKILL.md) and linked bundles (~/.pi/agent/skills/pstack → …/skills/<skill>) were missing from the/menu, the Skills page, andbb project commands. Flipping the flag alone was not enough: the daemon's recursive walker skipped every symlink, so turning recursion on would have hidden skills that users link in today (the shallow scan follows user-origin links). That regression is why the issue's autopilot attempt was reverted. Pi also reads project.agents/skillsfrom the cwd up to the repository root, which the plugin did not declare.What changed
Pi plugin (
plugins/provider-pi/src/native-roots.ts):~/.pi/agent/skills,~/.agents/skills,.pi/skills,.agents/skills) and resolved roots (moved agent dir,settings.jsonskill paths) are nowrecursive: true..agents/skillsnow walks ancestors up to the repository root, as Pi does..pi/skillsstays cwd-only, matching Pi.Recursive skill walker (
apps/host-daemon/src/command-discovery.ts):.gitandnode_modules.I checked these rules against each agent that uses recursive roots:
2bdd1d6)b5be2a3c)SKILL.md.gitonlynode_modulesFollowing links is common to all four. The other rules follow the majority, so Pi may list a skill nested inside another skill's folder, or under a dot folder, that Pi itself ignores. Making these rules declarable per root would need new plugin API; this PR avoids that.
Other providers: Cursor, Grok, and Hermes already declare recursive roots. For them, linked skill folders under user roots now appear, where they were silently skipped before, and
.git/node_modulesare no longer walked.Wire:
HOST_DAEMON_PROTOCOL_VERSION236 → 237. No fields changed, but the meaning ofrecursivedid: recursive scans now follow user-origin links. Without the bump, an older daemon would scan Pi roots recursively while skipping links, which hides linked Pi skills.Docs (
docs/configuration.md): Pi is listed among the recursively scanned providers, and its project-root row matches the declaration.Not changed:
name; Cursor uses the folder name for slash ids..gitignorehandling is not mirrored.How you verified
main, native Pi 1.1.0loadSkillsfinds 4 andbb project commands --provider pifinds 0. On this branch, BB finds all 4./demoin the Pi composer onmainlists only the top-level control skill. On this branch, the nested skills one and two levels deep are listed too..git/node_modulesskipped.linkedflag tests now run with bothrecursive: falseandrecursive: true..agents/skillsancestors.main's walker and pass here.pnpm exec turbo run typecheck lint test --continue --filter='...[origin/main]'.Fixes #5364
🤖 Generated with Claude Code