Class: CursorFormatter¶
Defined in: formatters/src/formatters/cursor.ts:78
Formatter for Cursor rules.
Supports two versions: - modern (default): .cursor/rules/project.mdc with YAML frontmatter - legacy: .cursorrules plain text (deprecated)
Example¶
# Modern format (default)
targets:
- cursor
# Legacy format for older Cursor versions
targets:
- cursor:
version: legacy
See¶
https://cursor.com/docs/context/rules
Extends¶
Constructors¶
Constructor¶
new CursorFormatter():
CursorFormatter
Returns¶
CursorFormatter
Inherited from¶
Properties¶
defaultConvention¶
readonlydefaultConvention:"markdown"='markdown'
Defined in: formatters/src/formatters/cursor.ts:82
Default convention for this formatter
Overrides¶
BaseFormatter.defaultConvention
description¶
readonlydescription:"Cursor rules (MDC with frontmatter)"='Cursor rules (MDC with frontmatter)'
Defined in: formatters/src/formatters/cursor.ts:81
Human-readable description
Overrides¶
name¶
readonlyname:"cursor"='cursor'
Defined in: formatters/src/formatters/cursor.ts:79
Unique formatter identifier
Overrides¶
outputPath¶
readonlyoutputPath:".cursor/rules/project.mdc"=CURSOR_VERSIONS.modern.outputPath
Defined in: formatters/src/formatters/cursor.ts:80
Default output file path
Overrides¶
Methods¶
createRenderer()¶
protectedcreateRenderer(options?):ConventionRenderer
Defined in: formatters/src/base-formatter.ts:20
Create a convention renderer for this formatter. Uses the provided convention from options or falls back to the default.
Parameters¶
options?¶
Returns¶
Inherited from¶
extractSectionWithCodeBlock()¶
protectedextractSectionWithCodeBlock(text,header):string|null
Defined in: formatters/src/base-formatter.ts:140
Safe extraction of a section that contains a header + content + code block + content Avoids ReDoS by using string search instead of backtracking regex. Matches pattern: Header ... ...
Parameters¶
text¶
string
header¶
string
Returns¶
string | null
Inherited from¶
BaseFormatter.extractSectionWithCodeBlock
extractText()¶
protectedextractText(content):string
Defined in: formatters/src/base-formatter.ts:42
Extract text from block content.
Parameters¶
content¶
Returns¶
string
Inherited from¶
findBlock()¶
protectedfindBlock(ast,name):Block|undefined
Defined in: formatters/src/base-formatter.ts:35
Find a block by name, ignoring internal blocks (starting with __).
Parameters¶
ast¶
name¶
string
Returns¶
Block | undefined
Inherited from¶
format()¶
format(
ast,options?):FormatterOutput
Defined in: formatters/src/formatters/cursor.ts:91
Transform AST to tool-specific format
Parameters¶
ast¶
options?¶
Returns¶
Overrides¶
formatArray()¶
protectedformatArray(arr):string
Defined in: formatters/src/base-formatter.ts:84
Format an array as comma-separated string.
Parameters¶
arr¶
unknown[]
Returns¶
string
Inherited from¶
getArrayElements()¶
protectedgetArrayElements(content):Value[]
Defined in: formatters/src/base-formatter.ts:108
Extract array elements from block content.
Parameters¶
content¶
Returns¶
Value[]
Inherited from¶
BaseFormatter.getArrayElements
getMetaField()¶
protectedgetMetaField(ast,key):string|undefined
Defined in: formatters/src/base-formatter.ts:98
Get meta field value as string.
Parameters¶
ast¶
key¶
string
Returns¶
string | undefined
Inherited from¶
getOutputPath()¶
protectedgetOutputPath(options?):string
Defined in: formatters/src/base-formatter.ts:28
Get the output path, respecting options override.
Parameters¶
options?¶
Returns¶
string
Inherited from¶
getProp()¶
protectedgetProp(content,key):Value|undefined
Defined in: formatters/src/base-formatter.ts:56
Get a specific property from block content.
Parameters¶
content¶
key¶
string
Returns¶
Value | undefined
Inherited from¶
getProps()¶
protectedgetProps(content):Record\<string,Value>
Defined in: formatters/src/base-formatter.ts:70
Get all properties from block content.
Parameters¶
content¶
Returns¶
Record\<string, Value>
Inherited from¶
truncate()¶
protectedtruncate(str,max):string
Defined in: formatters/src/base-formatter.ts:91
Truncate string to max length with ellipsis.
Parameters¶
str¶
string
max¶
number
Returns¶
string
Inherited from¶
valueToString()¶
protectedvalueToString(value):string
Defined in: formatters/src/base-formatter.ts:118
Convert value to string representation.
Parameters¶
value¶
Returns¶
string
Inherited from¶
getSupportedVersions()¶
staticgetSupportedVersions():object
Defined in: formatters/src/formatters/cursor.ts:87
Get supported versions for this formatter.
Returns¶
object
frontmatter¶
readonlyfrontmatter:object
frontmatter.cursorVersion¶
readonlycursorVersion:"0.45+"='0.45+'
frontmatter.description¶
readonlydescription:"Alias for modern format (MDC with YAML frontmatter)"='Alias for modern format (MDC with YAML frontmatter)'
frontmatter.introduced¶
readonlyintroduced:"2024-12"='2024-12'
frontmatter.name¶
readonlyname:"frontmatter"='frontmatter'
frontmatter.outputPath¶
readonlyoutputPath:".cursor/rules/project.mdc"='.cursor/rules/project.mdc'
legacy¶
readonlylegacy:object
legacy.cursorVersion¶
readonlycursorVersion:"< 0.45"='< 0.45'
legacy.deprecated¶
readonlydeprecated:true=true
legacy.deprecatedSince¶
readonlydeprecatedSince:"2024-12"='2024-12'
legacy.description¶
readonlydescription:"Plain text format (.cursorrules) - DEPRECATED"='Plain text format (.cursorrules) - DEPRECATED'
legacy.name¶
readonlyname:"legacy"='legacy'
legacy.outputPath¶
readonlyoutputPath:".cursorrules"='.cursorrules'
modern¶
readonlymodern:object
modern.cursorVersion¶
readonlycursorVersion:"0.45+"='0.45+'
modern.description¶
readonlydescription:"MDC format with YAML frontmatter (.cursor/rules/project.mdc)"='MDC format with YAML frontmatter (.cursor/rules/project.mdc)'
modern.introduced¶
readonlyintroduced:"2024-12"='2024-12'
modern.name¶
readonlyname:"modern"='modern'
modern.outputPath¶
readonlyoutputPath:".cursor/rules/project.mdc"='.cursor/rules/project.mdc'
multifile¶
readonlymultifile:object
multifile.cursorVersion¶
readonlycursorVersion:"0.45+"='0.45+'
multifile.description¶
readonlydescription:"Multiple MDC files with glob-based targeting"='Multiple MDC files with glob-based targeting'
multifile.introduced¶
readonlyintroduced:"2024-12"='2024-12'
multifile.name¶
readonlyname:"multifile"='multifile'
multifile.outputPath¶
readonlyoutputPath:".cursor/rules/project.mdc"='.cursor/rules/project.mdc'