Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/agents/CursorAgent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import * as path from 'path';
import { AbstractAgent } from './AbstractAgent';
import { IAgentConfig } from './IAgent';

// Cursor-specific configuration extending the base config
interface CursorAgentConfig extends IAgentConfig {
description?: string;
globs?: string[];
alwaysApply?: boolean;
}
import {
backupFile,
writeGeneratedFile,
Expand Down Expand Up @@ -30,9 +37,26 @@ export class CursorAgent extends AbstractAgent {
agentConfig?.outputPath ?? this.getDefaultOutputPath(projectRoot);
const absolutePath = path.resolve(projectRoot, output);

const cursorConfig = agentConfig as CursorAgentConfig | undefined;
const alwaysApply = cursorConfig?.alwaysApply ?? true;
const description = cursorConfig?.description ?? '';
const globs = cursorConfig?.globs ?? [];

// Cursor expects a YAML front-matter block with an `alwaysApply` flag.
// See: https://docs.cursor.com/context/rules#rule-anatomy
const frontMatter = ['---', 'alwaysApply: true', '---', ''].join('\n');
const frontMatterLines = ['---'];

if (description) {
frontMatterLines.push(`description: ${description}`);
}

if (globs.length > 0) {
frontMatterLines.push('globs:');
}

frontMatterLines.push(`alwaysApply: ${alwaysApply}`);
frontMatterLines.push('---', '');
const frontMatter = frontMatterLines.join('\n');
const content = `${frontMatter}${concatenatedRules.trimStart()}`;

await ensureDirExists(path.dirname(absolutePath));
Expand Down
12 changes: 12 additions & 0 deletions src/core/ConfigLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,18 @@ export async function loadConfig(
}
cfg.mcp = mcpCfg;
}
// Handle Cursor-specific configuration
if (name === 'cursor') {
if (typeof sectionObj.always_apply === 'boolean') {
(cfg as any).alwaysApply = sectionObj.always_apply;
}
if (typeof sectionObj.description === 'string') {
(cfg as any).description = sectionObj.description;
}
if (Array.isArray(sectionObj.globs)) {
(cfg as any).globs = sectionObj.globs.filter(g => typeof g === 'string');
}
}
agentConfigs[name] = cfg;
}
}
Expand Down