fix(rules): deliver a folded rule once to providers that also read AGENTS.md - #261
Conversation
…ENTS.md Cursor reads AGENTS.md, so a rule targeted at both Codex and Cursor reached Cursor twice: natively in .cursor/rules and via the block folded for Codex. The placement plan now records which native-rules providers already read every file a rule is folded into; install skips their native file and prune removes a stale one. When the fold is a root "Applies to" fallback, a scope-widened warning is emitted even under scope: best-effort. Closes #260 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
PR Summary by QodoPrevent duplicate folded rule delivery to native-rule providers
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1.
|
…lly gets Address review on #261: - Coverage now checks only the provider's own instructions file, so an isolated GEMINI.md copy no longer blocks deduping Cursor. - A nested folded placement only counts once its directory exists and is capa-owned (same checks install uses), so prune never deletes a Cursor rule whose replacement won't be written. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Summary
Cursor reads
AGENTS.md, so a rule sent to both Codex and Cursor reached Cursor twice: once from.cursor/rules/<id>.mdcand once from the block capa folds intoAGENTS.mdfor Codex. This happened for any shared rule, not just scoped ones. Closes #260.What changed
planRulePlacementnow returnsnativeCovered: for each provider with its own rules dir, the rules it already gets because it reads every file the rule is folded into. The folded copy is always at least as broad as the native one, so the native file only added a duplicate.installRulesskips those native files, andpruneRulesremoves a stale one (for example when Codex is added to a Cursor-only project).scope-widenedwarning: if the fold is a root> Applies to:fallback (for example**/*.py), the Cursor-side reader loses its nativeappliesToscope. This warns even underscope: best-effort, since that opt-in was made for the providers doing the folding. It's always a warning and never skips the rule, so Codex's only copy is never dropped.Not covered: per-provider instruction filenames and native Codex scoped rules both depend on upstream support (openai/codex#34002, Cursor
AGENTS.mdopt-out).Screenshots / logs
New warning:
Test plan
rules-shared-instructions.test.ts: unscoped andservices/**rules land once for codex+cursor;**/*.pybest-effort warnsscope-widened; a cursor-only rule keeps its.mdc; prune removes a now-duplicate.mdcbun test src/cli src/sharedhas no new failures vsdevelopon Windows (the existing EBUSY/symlink failures are unchanged)bunx tsc --noEmitpassesChecklist
bunx tsc --noEmitpassescapa-docs/resources/rules.mdx) lives in content-management-infra and needs a follow-up there🤖 Generated with Claude Code