Skip to content

fix(cli): dedupe userRules from config and markdown rule sources#12926

Open
syf2211 wants to merge 2 commits into
continuedev:mainfrom
syf2211:fix/cli-user-rules-duplicate-12925
Open

fix(cli): dedupe userRules from config and markdown rule sources#12926
syf2211 wants to merge 2 commits into
continuedev:mainfrom
syf2211:fix/cli-user-rules-duplicate-12925

Conversation

@syf2211

@syf2211 syf2211 commented Jul 1, 2026

Copy link
Copy Markdown

Summary

Fixes duplicate .continue/rules content in the Continue CLI system prompt userRules block.

Motivation

Fixes #12925. When using the Continue CLI, markdown rules from .continue/rules/ were rendered twice in the model context. This happened because markdown rules were merged into config.rules in ConfigService, then loaded again in constructSystemMessage(), and deduplication did not cover duplicate entries already present in config or identical rules found in both project and global rule directories.

Changes

  • Add appendUniqueRuleContents() and use it when merging config rules and markdown fallback rules in constructSystemMessage()
  • Deduplicate rule bodies while scanning project and global .continue/rules directories in loadMarkdownRulesWithMetadata()
  • Skip duplicate markdown entries when ConfigService merges rules into config
  • Add regression tests for config+markdown dedupe and project/global directory dedupe

Tests

  • npx vitest run src/systemMessage.test.ts — 24 passed
  • npx vitest run src/services/ConfigService.test.ts — 24 passed

Notes

Composer-2.5 review: APPROVE. Minimal, focused CLI-only change; no behavior change for distinct rule bodies.


Summary by cubic

Deduplicates CLI userRules so markdown rules from .continue/rules aren’t repeated in the system prompt. Fixes #12925 by removing duplicates across config, project, and global rule sources.

  • Bug Fixes
    • Deduplicate at merge time in both ConfigService and constructSystemMessage() using appendUniqueRuleContents().
    • Remove identical markdown rule bodies across rule directories in loadMarkdownRulesWithMetadata(); extract parseAlwaysApplyMarkdownRule() to reduce nesting and satisfy ESLint max-depth.
    • Add regression tests for config + markdown and project + global dedupe; fix ESLint import order in tests.

Written for commit 9279b89. Summary will update on new commits.

Review in cubic

Fixes continuedev#12925

Markdown rules from .continue/rules were merged into the CLI system
prompt twice: once via ConfigService into config.rules and again in
constructSystemMessage. Incomplete deduplication also allowed identical
rules from project and global directories to appear multiple times.

Use appendUniqueRuleContents when building processedRules, dedupe rule
bodies while scanning rule directories, and skip duplicate markdown
entries when ConfigService merges rules into config.
@syf2211 syf2211 requested a review from a team as a code owner July 1, 2026 04:10
@syf2211 syf2211 requested review from sestinj and removed request for a team July 1, 2026 04:10
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 1, 2026
@syf2211

syf2211 commented Jul 1, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@syf2211

syf2211 commented Jul 1, 2026

Copy link
Copy Markdown
Author

recheck

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

- Group sibling imports together in systemMessage.test.ts
- Extract parseAlwaysApplyMarkdownRule helper to reduce nesting depth
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

userRules displayed twice in CLI context

1 participant