Skip to content

Unify skill discovery and dedupe; pass picked skills to Codex - #6185

Merged
ymichael merged 5 commits into
mainfrom
bb/swing-7a-one-skills-index-thr_rbpr4bpfnt
Oct 23, 2026
Merged

ymichael merged 5 commits into
mainfrom
bb/swing-7a-one-skills-index-thr_rbpr4bpfnt

Conversation

@ymichael

@ymichael ymichael commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Skill discovery was implemented four times (daemon command discovery, daemon skill listing, workspace context reads, server catalogs/staging), each with its own symlink, traversal and frontmatter rules. Listings had no cross-root identity, so the same skill showed 2–3 times (#3774), and Claude received injected copies of skills it already loads natively (#4164). Symlinked skill folders and SKILL.md files were skipped or rejected (#3238, #2602). Codex received a picked /skill as plain text, never as a structured skill input (#5201).

What changed

  • New @bb/skill-index package: one scanner for every skill and command root. Real paths are resolved; links are followed for user roots and bounded to the workspace for project roots. Cycles stop. Each recursive skill root reads at most 1,000 folders and each command root at most 1,000 entries; files inside skill folders never count, so one large root no longer hides later ones (Pi skill listing drops most user skills: the recursive scan shares one 1,000-entry budget across all roots #6173). Frontmatter parsing lives in the core-only @bb/skill-index/metadata subpath.
  • Daemon discovery, workspace context reads, server catalogs and staging all use the scanner. Linked skill roots and SKILL.md entries now work; supporting files inside an injected tree must still be ordinary files.
  • Listings collapse registrations that share a name and identical SKILL.md bytes, preferring the widest scope as Same skill listed 2-3x when registered under both a shared root and a provider's native root #3774 asks. Hidden registration IDs still resolve for read/write/delete. Runtime staging collapses same-name identical trees.
  • Claude Code: injected skills already present under the same name and content in its native user/project roots are omitted.
  • Codex: a picked skill is sent as a structured skill input with the path from Codex's skills/list, for turn start and steer. Matching is by catalog name, then by skill folder name. A selected skill missing from Codex's catalog is sent as plain text only, as before.
  • Plugin SDK (provider-bridge, 0.6.77): experimental_scanSkillFiles, experimental_selectedSkillMentions, ExperimentalSkillScanRoot, ExperimentalIndexedSkillFile. Entry in docs/api_to_audit.md; Plugin Guide surface and authoring skill updated.
  • Wire change: DiscoveredSkill gains realPath and contentSha256. HOST_DAEMON_PROTOCOL_VERSION 251 → 252, and the compatible list drops 250.
  • Docs: docs/configuration.md and the bb guide's agent-configuration chapter.
  • Server tests that asserted straight after a single setImmediate flush now wait for the outcome. Skill-root reads are async, so dispatch settles one I/O turn later.

How you verified

  • New tests: shared scanner (linked roots, boundaries, command links, budget). The entry-cap tests fail on the previous scanner: a skill with 1,005 asset files hid its nested skill, and a root with 1,005 folders hid the next root's skill. Also daemon same-content aliases, listing alias/hidden-ID reads and writes, Claude native-overlap filtering, and Codex structured input and folder-name fallback. Native-roots goldens for Cursor and Grok are regenerated: a skill reached through a linked .cursor/skills → .agents/skills root, or a Claude-plugin skill folder that was also listed unprefixed, now appears once instead of twice.
  • pnpm exec turbo run lint typecheck build --filter='...[origin/main]': 213/213 tasks pass.
  • turbo run test on skill-index, host-daemon, server, host-daemon-contract, plugin-sdk, templates, provider-claude-code, provider-codex, provider-pi, bb-guide and plugin-api-docs. Failures seen under machine load (5–15 s timeouts) pass when rerun alone.
  • Real Codex 0.164 skills/list confirmed it names skills by frontmatter name, which is why the folder-name fallback exists.
  • Manual, on this branch in a start:worktree app: a skill registered five ways (real file plus links from .bb/skills, .claude/skills, .claude/commands and the data dir) lists once in the composer's / menu, and a same-content link under another name lists separately (project skills appear in the composer, not on the Skills page, which shows the personal scope). In a Codex thread, picking /swing-folder-name (frontmatter name: swing-frontmatter-name) delivered the skill: the reply was the skill's token instead of a "Selected skill is unavailable" error.

Fixes #3774
Fixes #4164
Fixes #3238
Fixes #2602
Fixes #5201
Fixes #6173

AGENT GENERATED

🤖 Generated with Claude Code

@ymichael ymichael changed the title Unify skill indexing and explicit provider selection Unify skill discovery and dedupe; pass picked skills to Codex Oct 23, 2026
ymichael and others added 5 commits October 23, 2026 15:49
Drop the SDK ESM load test: it needs dist output that the test task does
not build, and runtime-entries.test.mjs already guards the require shim.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A picked skill missing from Codex's skills/list no longer fails the turn;
the prompt text still carries the mention, as before structured inputs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Recursive skill roots charged every supporting file against one 1,000-entry
budget shared by all roots, so a normal Pi library hid most skills and every
later root. Each root now gets its own cap, and recursive skill roots count
only folders.

Fixes #6173

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/swing-7a-one-skills-index-thr_rbpr4bpfnt branch from e6cf3f6 to 70fa7fc Compare October 23, 2026 22:49
@ymichael
ymichael merged commit f1f26b3 into main Oct 23, 2026
89 of 91 checks passed
@ymichael
ymichael deleted the bb/swing-7a-one-skills-index-thr_rbpr4bpfnt branch October 23, 2026 23:06
@ymichael ymichael mentioned this pull request Oct 24, 2026
ymichael added a commit that referenced this pull request Oct 24, 2026
## Human comments

## What was wrong

`main` has 14 commits since 0.47.0, including #6195, which fixes the
timeline staying detached at the bottom (a regression from #5951 that
shipped in 0.47.0). `bb-app` and `@bb/desktop` were still at 0.47.0, so
the publish and desktop workflows can't ship them.

## What changed

- `packages/bb-app/package.json`, `apps/desktop/package.json`: 0.47.0 →
0.47.1 (`node scripts/bump-version.mjs --patch`).
- No `CHANGELOG.md` or `RELEASE_META` entry: like earlier fix-only
patches, these changes go into the 0.48.0 notes.

The release commit sits directly on `b17bfc8fdd` (#6217). Everything
below was tested on `22d41249ee`, and the sidebar was tested again on
`b17bfc8fdd`. This release includes the daemon protocol bump from #6185
(251 → 252), so enrolled machines will update their daemon.

## How you verified

- `node .github/workflows/check-version-lockstep.mjs`: `bb-app=0.47.1
@bb/desktop=0.47.1`.
- Typecheck, tests and the `bb-app` tarball smoke run in CI on this PR,
instead of locally.
- `git diff --check`, and `oxfmt --check` on the changed files: clean.
- Manual QA of `22d41249ee` with `pnpm start:worktree` (production
bundle) and headless Chrome, on a fresh data dir:
- **Timeline (#6195):** a long unread reply stops at NEW, detached. A
short unread reply opens at the end with no jump arrow. Scrolling up 150
px and growing the viewport 900 → 1200 attaches. Scrolling up 400 px and
growing it stays detached. Sending after scrolling up 1,800 px jumps to
the end and follows the streamed Claude Code reply. The view is still at
the end after a reload.
- **Docs (#6146):** typing in a note while `bb docs pull`/`push`
appended a paragraph kept both edits on disk and in the editor. A stale
push after a UI edit was refused as a conflict. A new note was renamed
from its first line and kept its Markdown after a reload.
- **Skills (#6185):** `bb project commands` lists project skills from
the documented roots for Claude Code and Codex, with no duplicate names.
A Codex `/skill` turn ran the skill.
- **Storage & retention (#6190, #6205):** two outside worktrees were
listed. Bulk removal removed the clean one, kept its branch, and kept
the dirty one. The table fits a 390 px viewport.
- **Sidebar multi-select (#6191, #6217), on `b17bfc8fdd`:** with the
experiment on, Cmd+Shift-click selected a second thread without
navigating ("Actions for 2 threads"). Pressing it again on the same
thread deselected it. Shift-click selected a range of 4. Escape cleared
the selection. Cmd-click cleared the selection and opened a split. Bulk
Pin applied to the two selected threads (checked with `bb thread list`).
With the experiment off, Cmd-click opens a split.
- **omp (#6186):** the picker labels GPT-5.6 Terra rows `openai` and
`openai-codex`.

Not exercised: the Ultrafast icon (#6198), because no Codex model on the
test account offers Ultrafast. Also not exercised: the Android
touch-drag attach, the desktop app, the SDK realtime reconnect (#6183)
and retryable host RPCs (#6184). Those last two are covered by unit
tests only.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Oct 29, 2026
## Human comments

## What was wrong

Every turn start (and the project command list and plugin skill listing)
calls `resolveSkillCatalog`, and `SkillTreeRegistry.readTree` streamed
and SHA-256-hashed every file of every skill tree on every call, even
when nothing had changed. The registry already recorded a per-file
`statKey` (dev, inode, size, mtime, ctime) in each manifest for the
tree-content endpoint, but never consulted it before rehashing. On a
real `~/.bb` plus the repo's plugin skill roots, each resolve re-read 74
files (576 KB).

Reproduction and root-cause report:
https://get-bb.github.io/reports/issues/5963.html

## What changed

This replaces the original commit on this branch, which targeted the old
synchronous skill code and no longer applied after #6330, #6335 and
#6185.

- `apps/server/src/services/skills/injected-skills.ts`: `readTree` looks
up the root's previous manifest and reuses a file's `sha256` when its
`statKey` is unchanged, instead of reading it again. Mode, size and path
still come from the fresh `lstat`/`stat`, and symlink and
non-regular-file rejection are unchanged.
- Racy timestamps: on filesystems with coarse timestamps (the Linux CI
runner), a same-size rewrite can land in the same ctime tick as the
version already hashed and produce an identical `statKey`. Following
Git's racy-clean rule, a hash is reusable only if the file's ctime is at
least 2 s older than the moment hashing started
(`HASH_REUSE_SETTLE_NS`). Recently changed files are rehashed until they
settle.
- `hashReusable` is a server-only field on `SkillTreeFile`; the
`/skills/tree/:hash` route projects fields explicitly, so the wire
format is unchanged. There are no protocol, public API, schema, CLI or
config changes.

## How you verified

- New `apps/server/test/skills/skill-catalog-cache.test.ts` (8 tests):
- Settled unchanged files are not reread on the second resolve
(`createReadStream` not called). This fails on `origin/main` (2 reads).
- Unchanged files changed too recently to trust are reread. This fails
on the previous commit, which had no settle window and failed CI on
Linux.
- Content (size change with restored mtime), replacement (new inode),
rename, mode, addition and removal changes to settled files each produce
the same tree hash as a fresh registry.
- Real-data repro (`resolveSkillCatalogEntries` over `~/.bb` plus repo
plugin skill roots, one shared registry): before, 74 reads / 576,146
bytes per resolve, ~12 ms warm median; after, 0 reads / 0 bytes on
repeat resolves, ~7 ms, with an identical catalog.
- End to end on `pnpm start:worktree`: a Claude Code thread read a
`qa-canary` user skill's reference file (`ALPHA`). The file was then
rewritten at the same size with its mtime restored (`BRAVO`), and the
next turn read `BRAVO`. This still held after a server restart on the
final commit.
- `pnpm exec turbo run test --filter=@bb/server -- test/skills
test/internal test/threads/thread-runtime-config.test.ts`: 296 tests
pass in 26 files.
- `pnpm exec turbo run typecheck lint --filter=@bb/server`: passes.
`oxfmt --check`: passes.

Fixes #5963

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- slopcop:rule=new-issue-autopilot run=run_ju693husmvhjw9nc
sha=issue-5963 kind=summary -->

---------

Co-authored-by: Michael Yong <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment