discover skills in Yarn Berry PnP projects + speed up skill discovery#151
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR fixes Yarn PnP skill discovery by introducing a pluggable filesystem abstraction throughout the scanner. It captures Yarn's patched filesystem during PnP setup, routes all file reading through that filesystem, optimizes frontmatter parsing to read only the leading region, and validates the fix with real Yarn Berry integration tests. ChangesYarn PnP skill discovery and filesystem abstraction
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit 34b56f9
☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit 6176b8c
☁️ Nx Cloud last updated this comment at |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/intent/tests/parse-frontmatter.test.ts (1)
36-54: 📐 Maintainability & Code Quality | ⚡ Quick winStrengthen this regression by asserting the bounded-read path, not just output.
Right now, these cases still pass if
parseFrontmatterregresses to full-file reads. Add a mocked/injectedReadFsassertion that verifiesopenSync/readSyncare used for the large-body case andreadFileSyncis only used for the overflow fallback case.Proposed test-shape diff
+ it('uses bounded reads when frontmatter fits in the probe window', () => { + const body = 'x'.repeat(64 * 1024) + const path = write('large-body.md', `---\nname: big\n---\n\n${body}\n`) + const calls = { open: 0, read: 0, full: 0 } + const spyFs = { + ...nodeReadFs, + openSync(...args: Parameters<typeof nodeReadFs.openSync>) { + calls.open++ + return nodeReadFs.openSync!(...args) + }, + readSync(...args: Parameters<typeof nodeReadFs.readSync>) { + calls.read++ + return nodeReadFs.readSync!(...args) + }, + readFileSync(...args: Parameters<typeof nodeReadFs.readFileSync>) { + calls.full++ + return nodeReadFs.readFileSync(...args) + }, + } + expect(parseFrontmatter(path, spyFs)).toEqual({ name: 'big' }) + expect(calls.open).toBeGreaterThan(0) + expect(calls.read).toBeGreaterThan(0) + expect(calls.full).toBe(0) + })🤖 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 `@packages/intent/tests/parse-frontmatter.test.ts` around lines 36 - 54, Update the tests in parse-frontmatter.test.ts to assert the bounded-read code path by injecting a mocked ReadFs into parseFrontmatter: for the large-body test replace real fs with a mock that records calls and fails if readFileSync is invoked, and assert openSync/readSync were called; for the large-frontmatter (overflow) test use a mock that records calls and assert that readFileSync was used as the fallback while openSync/readSync may not be called. Make the mocks target the same ReadFs interface/object used by parseFrontmatter and ensure the tests pass the mock into parseFrontmatter (or its factory) so the assertions validate which fs methods were used rather than only the parsed output.
🤖 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 `@packages/intent/tests/integration/pnp-berry-corepack.test.ts`:
- Around line 42-54: The execFileSync calls in berryAvailable (and the other
execFileSync usages in this test file) are unbounded and can hang CI; update
each call (including the corepack check in berryAvailable and the execFileSync
calls around lines 90-109 and 116-132) to pass a timeout option (e.g., a few
seconds or test-appropriate timeout) and increase maxBuffer for commands that
produce install output; modify the options object passed to execFileSync (the
one currently containing cwd, env, stdio) to include timeout and maxBuffer
values so subprocesses are killed and large outputs don't overflow the buffer.
---
Nitpick comments:
In `@packages/intent/tests/parse-frontmatter.test.ts`:
- Around line 36-54: Update the tests in parse-frontmatter.test.ts to assert the
bounded-read code path by injecting a mocked ReadFs into parseFrontmatter: for
the large-body test replace real fs with a mock that records calls and fails if
readFileSync is invoked, and assert openSync/readSync were called; for the
large-frontmatter (overflow) test use a mock that records calls and assert that
readFileSync was used as the fallback while openSync/readSync may not be called.
Make the mocks target the same ReadFs interface/object used by parseFrontmatter
and ensure the tests pass the mock into parseFrontmatter (or its factory) so the
assertions validate which fs methods were used rather than only the parsed
output.
🪄 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
Run ID: dcc7541f-6e9d-4939-a9e3-90f3cd0b3bb2
📒 Files selected for processing (9)
.changeset/yellow-queens-doubt.mdpackages/intent/src/core.tspackages/intent/src/discovery/register.tspackages/intent/src/fs-cache.tspackages/intent/src/scanner.tspackages/intent/src/utils.tspackages/intent/tests/integration/pnp-berry-corepack.test.tspackages/intent/tests/parse-frontmatter.test.tspackages/intent/tests/scanner.test.ts
Summary
Two related changes to skill discovery:
Yarn Berry (PnP) support
With
nodeLinker: pnpand nonode_modules, dependencies live inside.yarn/cache/*.ziparchives that are only readable through Yarn'slibzip-patched filesystem.
intent listandintent loadnow read packagemetadata and
SKILL.mdfiles from those archives, so skills are discoveredand loaded correctly — including when Intent runs via
npx/dlxfrom outsidethe project's PnP graph.
falls back to importing candidate package code.
Intent's process after discovery.
Discovery performance
parseFrontmatterreads only the leading region of eachSKILL.md(boundedreadSyncinto a reused buffer) instead of the whole file, with a full-readfallback when frontmatter exceeds the probe window or the read primitives
are unavailable. ~4x faster on large skill bodies, neutral on small ones.
resolveDepDirmemoizes its module resolver per package instead of rebuildingit for every dependency.
req.resolvestill hits the live filesystem, socached entries never go stale (safe under long-running
mcp serve).existsSyncbeforereaddirSyncin the skill-file walkand avoided per-directory array-spread allocations.
Fixes #144
Summary by CodeRabbit
New Features
Bug Fixes
Performance Improvements
Tests