Support wildcard patterns in intent.skills allowlists#201
Conversation
…ate documentation
|
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 (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough
ChangesWildcard skill allowlists
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant IntentConfig
participant parseSkillSources
participant compileSkillSourcePolicy
participant applySourcePolicy
participant listIntentSkills
IntentConfig->>parseSkillSources: parse wildcard allowlist
parseSkillSources->>compileSkillSourcePolicy: provide pattern and source kind
compileSkillSourcePolicy->>applySourcePolicy: match discovered packages
applySourcePolicy-->>listIntentSkills: return permitted skills and notices
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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 171dd06
☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit da04db4
☁️ Nx Cloud last updated this comment at |
commit: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/intent/src/core/source-policy.ts (1)
56-66: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winMemoize the compiled wildcard pattern.
sourceMatchesPackageis called repeatedly inside loops overscanResult.packagesandconfig.sources. CallingcompileWildcardPattern(source.pattern)on every match check creates a newRegExpeach time, which can become a noticeable performance bottleneck in projects with many packages and wildcard sources.Consider caching the compiled matcher to avoid recompiling the pattern on every invocation.
⚡ Proposed refactor to cache patterns
+const patternCache = new Map<string, (value: string) => boolean>() + function sourceMatchesPackage( source: ExplicitSkillSource, packageName: string, packageKind?: 'npm' | 'workspace', ): boolean { if (source.kind === 'git') return false if (packageKind !== undefined && source.kind !== packageKind) return false - return 'pattern' in source - ? compileWildcardPattern(source.pattern)(packageName) - : source.id === packageName + if ('pattern' in source) { + let matcher = patternCache.get(source.pattern) + if (!matcher) { + matcher = compileWildcardPattern(source.pattern) + patternCache.set(source.pattern, matcher) + } + return matcher(packageName) + } + return source.id === packageName }🤖 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/src/core/source-policy.ts` around lines 56 - 66, Memoize compiled wildcard matchers used by sourceMatchesPackage so each source.pattern is compiled once and reused across repeated package checks. Update the pattern-matching path in sourceMatchesPackage with a cache keyed by the wildcard pattern, while preserving the existing git, packageKind, and exact-id matching behavior.
🤖 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.
Nitpick comments:
In `@packages/intent/src/core/source-policy.ts`:
- Around line 56-66: Memoize compiled wildcard matchers used by
sourceMatchesPackage so each source.pattern is compiled once and reused across
repeated package checks. Update the pattern-matching path in
sourceMatchesPackage with a cache keyed by the wildcard pattern, while
preserving the existing git, packageKind, and exact-id matching behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f8d28147-36b4-4d43-a1e4-7ec1cd89696e
📒 Files selected for processing (11)
.changeset/calm-dingos-match.mddocs/cli/intent-list.mddocs/concepts/configuration.mddocs/concepts/trust-model.mddocs/getting-started/quick-start-consumers.mdpackages/intent/src/core/excludes.tspackages/intent/src/core/skill-sources.tspackages/intent/src/core/source-policy.tspackages/intent/tests/integration/source-policy-surfaces.test.tspackages/intent/tests/skill-sources.test.tspackages/intent/tests/source-policy.test.ts
Summary
*package patterns such as@tanstack/*andworkspace:@scope/*inintent.skills."*"as the trust-all entry.Closes #200.
Summary by CodeRabbit
intent.skillsallowlists to support wildcard patterns like@scope/*andworkspace:@scope/*.["*"]allow-all entry and improved notices for unmatched allowlist patterns/packages.