Skip to content

feat: improve Cursor .mdc file processing with comprehensive frontmatter handling#11

Closed
arrowkato wants to merge 2 commits into
dyoshikawa:mainfrom
arrowkato:fix/cursor-mdc-file-processing
Closed

feat: improve Cursor .mdc file processing with comprehensive frontmatter handling#11
arrowkato wants to merge 2 commits into
dyoshikawa:mainfrom
arrowkato:fix/cursor-mdc-file-processing

Conversation

@arrowkato
Copy link
Copy Markdown
Contributor

Overview

Significantly improved Cursor .mdc file processing with complete bidirectional frontmatter conversion support.

Changes

1. Enhanced Generate Feature (rulesync/*.md → .mdc)

  • Support for 4 rule types: always, manual, auto attached, and agent_request
  • Implemented accurate conversion logic based on 900_generate_siyou.mdc specification
  • Proper handling of frontmatter fields: alwaysApply, description, and globs

2. Enhanced Import Feature (.mdc → rulesync/*.md)

  • Implemented detection logic for 4 patterns: always, manual, auto attached, and agent_request
  • Complete conversion processing based on 901_import_siyou.mdc specification
  • Custom YAML parser to handle Cursor-specific globs format (comma-separated strings)
  • Proper handling of edge cases

Technical Improvements

File Changes

  • src/generators/rules/cursor.ts: Implemented new generation logic
  • src/parsers/cursor.ts: Implemented new parsing logic and custom YAML parser
  • src/core/parser.ts: Allow empty string descriptions
  • Test cases: Added comprehensive test suites

New Features

  • determineCursorRuleType(): Automatic rule type detection
  • convertCursorMdcFrontmatter(): Conversion from .mdc to rulesync format
  • convertGlobsToArray(): Comma-separated string to array conversion
  • Custom YAML parser: Support for Cursor-specific formats

Testing

  • All 16 test cases pass successfully
  • Comprehensive tests for all 4 patterns
  • Edge case handling verified

Impact

  • Significantly improved processing accuracy for Cursor .mdc files
  • No impact on existing functionality (backward compatibility maintained)
  • Both pnpm dev generate --cursor and pnpm dev import --cursor commands improved

Breaking Changes

None. This change maintains full backward compatibility while adding new functionality.

@dyoshikawa
Copy link
Copy Markdown
Owner

@arrowkato Thank for your contribution!

I'll review it tomorrow.

@dyoshikawa
Copy link
Copy Markdown
Owner

@arrowkato

I'm sorry for suggesting a change after you've already implemented it, but I think the proposed specification might be a bit complex for users, so I'd like to reconsider it.

Personally, I think it would be clearer to simply add a optional parameter with a cursor prefix like cursorRuleType.

I've written the specification in the following issue, so please take a look:
#12

I'd definitely like to assign the implementation to you. Thank you!

@dyoshikawa dyoshikawa closed this Jul 4, 2025
dyoshikawa added a commit that referenced this pull request Apr 29, 2026
…ode/cline/qwencode

Addresses 18 reviewer findings raised on PR #1338. Highlights:

- #1 (critical): AugmentCode non-bash categories now fail-closed. A single
  deny rule in `read`/`edit`/`write`/`webfetch`/`websearch` collapses the
  whole tool to a catch-all `deny` entry; non-`*` allow/ask patterns are
  dropped with an aggregated warning instead of being silently downgraded
  to a catch-all `allow` that would shadow a deny.
- #2 (high): `toolPermissions` are sorted to make AugmentCode's
  first-match-wins evaluation safe — entries with `shellInputRegex` come
  before catch-alls, longer regex first, with deny < ask-user < allow as
  the tiebreaker.
- #5 (mid): existing `launch-process` deny entries are preserved across
  regeneration so a user-added shell deny rule cannot be silently
  downgraded; non-deny launch-process entries are still owned by rulesync.
- #3 (mid): Qwencode generation uses `readFileContentOrNull` (no
  `readOrInitializeFileContent`) so dry-run does not create the `.qwen/`
  directory.
- #4 (mid): Kilo schema parsing is deferred and respects `params.validate`,
  so `forDeletion` and dry-run construction never throw on permissive input.
- #7, #16 (mid/low): Cline drops non-bash / ask rules at `logger.error`
  level (rather than warn) and surfaces a defensive warn on allow/deny
  pattern collisions.
- #8, #13 (mid/low): Qwencode pattern parser uses the LAST `)` so nested
  parentheses (e.g. `Bash(echo (a))`) round-trip; malformed entries warn
  and fall back to `*`.
- #9 (low): Augment non-bash warnings are aggregated once per category.
- #11 (low): Kilo's wholesale-replace of the `permission` object is
  documented in `docs/reference/file-formats.md`.
- #10, #6 (low): glob→regex behaviour and round-trip caveats are
  documented.
- #14 (low): `mergedPermissions` is typed as
  `{ allow?: string[]; ask?: string[]; deny?: string[]; [k: string]: unknown }`.
- #15 (low): redundant Qwencode global-mode equivalence assert removed.
- #17 (low): `permissions-processor.test.ts` gains `loadToolFiles` cases
  for AugmentCode, Cline, Kilo, and Qwencode.

Deferred:
- #12 (kilo home-mock migration): the existing kilo global-mode test
  already passes `outputRoot` directly and does not reach
  `getHomeDirectory()`, so introducing the home-mock pattern adds only
  ceremony without coverage.
- #18 (tool-name-mapping helper extraction): postponed to keep this
  fix focused and to avoid touching files outside the permissions
  feature.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants