Skip to content

feat(adapters): Cursor adapter — export + enhanced import (#34)#37

Merged
shreyas-lyzr merged 1 commit intoopen-gitagent:mainfrom
nanookclaw:feat/cursor-adapter
Mar 23, 2026
Merged

feat(adapters): Cursor adapter — export + enhanced import (#34)#37
shreyas-lyzr merged 1 commit intoopen-gitagent:mainfrom
nanookclaw:feat/cursor-adapter

Conversation

@nanookclaw
Copy link
Contributor

Implements #34 ([Adapter] Cursor, tagged help wanted).

What this adds

Export: gitagent export --format cursor

Generates .cursor/rules/*.mdc files from a gitagent directory:

Source Output
SOUL.md + RULES.md <agent-name>.mdc with alwaysApply: true
Each skill in skills/ <skill-name>.mdc with alwaysApply: false
metadata.globs in SKILL.md globs: array in .mdc frontmatter

Skills without metadata.globs get no globs field (Cursor applies them globally by default).

Example output for a skill with globs:

---
description: Reviews API handlers for correctness and security
alwaysApply: false
globs:
  - src/api/**
  - '*.route.ts'
---

# API Review

Check all endpoints for auth, input validation, and error handling.

Enhanced Import: gitagent import --from cursor

Reads .cursor/rules/*.mdc directory (not just legacy .cursorrules):

  • alwaysApply: true rules → SOUL.md
  • Scoped skill rules → skills/<name>/SKILL.md
  • Globs preserved in metadata.globs for round-trip fidelity
  • Falls back to .cursorrulesAGENTS.md when no .cursor/rules/ found

Mapping document

gitagent field Cursor output Notes
SOUL.md alwaysApply: true .mdc body Grouped with RULES.md under agent slug
RULES.md alwaysApply: true .mdc body Appended to same global rule
manifest.description description: frontmatter Global rule only
skill.frontmatter.description description: frontmatter Per-skill rule
skill.metadata.globs globs: array Space/comma separated → array
compliance Dropped Cursor has no compliance primitive
knowledge/ Dropped No Cursor equivalent

Tests

14 tests, 5 suites — all pass:

# tests 14
# suites 5
# pass 14
# fail 0

Covers: parseMdcFile, readCursorRules, export global/skill rules, globs, slugification, string output format.

Files changed

  • src/adapters/cursor.ts — new adapter (export + import helpers)
  • src/adapters/cursor.test.ts — 14 tests
  • src/adapters/index.ts — re-export exportToCursorString, exportToCursor
  • src/commands/export.ts — wire cursor case + update format list
  • src/commands/import.ts — enhanced importFromCursor using readCursorRules
  • README.md — add cursor to adapter table

Run: gitagent export --format cursor is not applicable (Cursor is an IDE), so no run adapter — as noted in the issue.

Closes open-gitagent#34.

## Export: gitagent export --format cursor

Generates .cursor/rules/*.mdc files:
- SOUL.md + RULES.md → <agent-name>.mdc (alwaysApply: true)
- Each skill → <skill-name>.mdc (alwaysApply: false)
- Skills with metadata.globs get scoped file patterns in frontmatter

## Enhanced Import: gitagent import --from cursor

Reads .cursor/rules/*.mdc directory (not just legacy .cursorrules):
- alwaysApply: true rules → SOUL.md
- Scoped skill rules → skills/<name>/SKILL.md
- Globs preserved in metadata.globs for round-trip fidelity
- Falls back to .cursorrules / AGENTS.md when no .cursor/rules/ found

## Tests

14 tests across 5 suites covering:
- parseMdcFile (frontmatter + body, missing frontmatter, array globs)
- readCursorRules (empty dir, .mdc filtering)
- exportToCursor (global rule, skill rules, globs, slugification)
- exportToCursorString (file header format)

## Files

- src/adapters/cursor.ts — new adapter (export + import helpers)
- src/adapters/cursor.test.ts — 14 tests, all passing
- src/adapters/index.ts — re-export exportToCursorString, exportToCursor
- src/commands/export.ts — wire cursor case + update format list
- src/commands/import.ts — enhanced importFromCursor using readCursorRules
- README.md — add cursor to adapter table
@shreyas-lyzr shreyas-lyzr merged commit fe1ff02 into open-gitagent:main Mar 23, 2026
@shreyas-lyzr
Copy link
Contributor

Reviewed and merged. Implementation is correct:

  • .mdc file format matches Cursor's docs exactly — all three frontmatter fields (description, alwaysApply, globs) are the complete set per Cursor rules docs
  • Export correctly maps SOUL.md + RULES.md → alwaysApply: true global rule, skills → alwaysApply: false scoped rules
  • Enhanced import reads modern .cursor/rules/*.mdc with fallback to legacy .cursorrules
  • Globs round-trip correctly via metadata.globs
  • 14/14 tests pass, build clean

Nice work @nanookclaw — solid adapter with good test coverage. Thanks for closing #34!

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