feat: gate skills behind an intent.skills allowlist#156
Conversation
📝 WalkthroughWalkthroughAdds an Changesintent.skills allowlist + skill-level excludes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI command (install/list/load/stale)
participant CLISupport as cli-support.ts
participant SPF as scanForPolicedIntents
participant Scanner as scanForIntents
participant RSC as readSkillSourcesConfig
participant ASP as applySourcePolicy
participant Core as core.ts (listIntentSkills / resolveIntentSkillInCwd)
CLI->>CLISupport: scanIntentsOrFail(IntentCoreOptions)
CLISupport->>SPF: { cwd, scanOptions, coreOptions }
SPF->>Scanner: scanForIntents(scanOptions)
Scanner-->>SPF: ScanResult { packages, warnings, notices: [] }
SPF->>RSC: readSkillSourcesConfig(cwd)
RSC-->>SPF: SkillSourcesConfig (absent/empty/allow-all/explicit)
SPF->>ASP: applySourcePolicy(packages, { config, excludeMatchers })
ASP-->>SPF: SourcePolicyResult { packages, notices }
SPF-->>CLISupport: PolicedScan { scan, excludePatterns }
CLISupport-->>CLI: ScanResult (with notices)
CLI->>Core: listIntentSkills / resolveIntentSkillInCwd
Core-->>CLI: IntentSkillList { skills, warnings, notices }
CLI->>CLI: printWarnings + printNotices (stderr)
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Possibly related issues
Possibly related PRs
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 349014b
☁️ Nx Cloud last updated this comment at |
commit: |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/intent/src/commands/list.ts (1)
95-103:⚠️ Potential issue | 🟠 Major | ⚡ Quick winRoute notices to stderr in JSON mode instead of stdout JSON payload.
Line 95 enters JSON mode and returns on Line 102 before
printNotices(...)runs, so notices are emitted on stdout asjsonResult.noticesrather than the stderr notice channel used elsewhere. This breaks the notice-channel contract and makes JSON mode behavior inconsistent with non-JSON mode.Suggested fix
if (options.json) { const { debug: _debug, packageManager: _packageManager, + notices: _notices, ...jsonResult } = result console.log(JSON.stringify(jsonResult, null, 2)) + printNotices(result.notices) return }🤖 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/commands/list.ts` around lines 95 - 103, In the list command’s JSON branch in list.ts (the options.json handling inside the list command), make sure notices are still routed through the stderr notice channel instead of being left inside the JSON payload; keep JSON output on stdout, but remove notices from the serialized result and call the existing printNotices flow or equivalent stderr path before returning so JSON mode matches the non-JSON notice contract.
🤖 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.
Outside diff comments:
In `@packages/intent/src/commands/list.ts`:
- Around line 95-103: In the list command’s JSON branch in list.ts (the
options.json handling inside the list command), make sure notices are still
routed through the stderr notice channel instead of being left inside the JSON
payload; keep JSON output on stdout, but remove notices from the serialized
result and call the existing printNotices flow or equivalent stderr path before
returning so JSON mode matches the non-JSON notice contract.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 42c78428-fb91-4875-a253-f8d56bd52ea2
📒 Files selected for processing (31)
docs/cli/intent-install.mddocs/cli/intent-list.mddocs/cli/intent-load.mddocs/cli/intent-stale.mddocs/concepts/configuration.mddocs/concepts/trust-model.mddocs/config.jsondocs/getting-started/quick-start-consumers.mddocs/overview.mdeslint.config.jspackages/intent/src/cli-output.tspackages/intent/src/cli-support.tspackages/intent/src/commands/install.tspackages/intent/src/commands/list.tspackages/intent/src/commands/load.tspackages/intent/src/commands/stale.tspackages/intent/src/core.tspackages/intent/src/core/excludes.tspackages/intent/src/core/skill-sources.tspackages/intent/src/core/source-policy.tspackages/intent/src/core/types.tspackages/intent/src/scanner.tspackages/intent/src/types.tspackages/intent/tests/cli.test.tspackages/intent/tests/core.test.tspackages/intent/tests/excludes.test.tspackages/intent/tests/install-writer.test.tspackages/intent/tests/integration/source-policy-surfaces.test.tspackages/intent/tests/resolver.test.tspackages/intent/tests/skill-sources.test.tspackages/intent/tests/source-policy.test.ts
💤 Files with no reviewable changes (1)
- packages/intent/src/commands/load.ts
Summary
Adds
package.json#intent.skillsas an allowlist that decides which discovered packages may contribute skills. Until now, every installed package with askills/directory was trusted and surfaced. A skill is instructions an agent follows, so which packages can contribute is a trust decision — this makes that decision explicit.Extends
intent.excludeto skill-level granularity and routes every surface (list,load,install,stalefallback) through a single policy chokepoint.Closes #145
How it works
intent.skillsis an array of source entries:@scope/pkg/pkg— an npm package in the dependency treeworkspace:@scope/pkg— a workspace membergit:<host>/<repo>#<ref>— reserved, parsed and validated but rejected until M2Three whole-list special forms:
[]): deny-all.["*"]): allow-all, with an acknowledged-risk notice.intent.excludeis applied after the allowlist and now matches skills, not just packages:@scope/pkg#search-params, globs like@scope/pkg#experimental-*, and cross-package*#experimental-*.Design notes
liststdout from ingesting housekeeping messages as data.loadfilters notices out structurally on every path, and--jsonexposesnoticesas a separate field.workspace:fooandfooboth authorize a discoveredfoo, because the scanner does not yet distinguish a workspace member from a same-named npm package. This errs toward permitting a same-named package, never toward denying one you listed. M2 tightens matching tokind+idonce the scanner carries that signal.Deliberately deferred
staledoes not carry the consumer migration notice (it is maintainer-facing).--json; making it stdout-mode-aware belongs with the future require-allowlist work.Tests
Summary by CodeRabbit
intent.skillsandintent.exclude, including allowlist/denylist behavior and new Concepts documentation.intent list,intent load,intent install, andintent stalenow surface notices in addition to warnings.