fix: avoid cursor nested AGENTS context pollution

This commit is contained in:
Affaan Mustafa 2026-04-30 00:33:51 -04:00 committed by Affaan Mustafa
parent 95ce9eaaeb
commit d49f0329a9
2 changed files with 36 additions and 0 deletions

View File

@ -133,6 +133,12 @@ module.exports = createInstallTargetAdapter({
destinationPath: path.join(targetRoot, 'mcp.json'), destinationPath: path.join(targetRoot, 'mcp.json'),
}); });
if (sourceRelativePath === 'AGENTS.md') {
// Cursor treats nested AGENTS.md files as directory context; do not
// install ECC's root project identity into a host project's .cursor/.
return [];
}
if (sourceRelativePath === 'rules') { if (sourceRelativePath === 'rules') {
return takeUniqueOperations(createFlatRuleOperations({ return takeUniqueOperations(createFlatRuleOperations({
moduleId: module.id, moduleId: module.id,

View File

@ -172,6 +172,36 @@ function runTests() {
); );
})) passed++; else failed++; })) passed++; else failed++;
if (test('does not install root AGENTS.md into Cursor nested context', () => {
const repoRoot = path.join(__dirname, '..', '..');
const projectRoot = '/workspace/app';
const plan = planInstallTargetScaffold({
target: 'cursor',
repoRoot,
projectRoot,
modules: [
{
id: 'agents-core',
paths: ['.agents', 'agents', 'AGENTS.md'],
},
],
});
assert.ok(
!plan.operations.some(operation => (
normalizedRelativePath(operation.sourceRelativePath) === 'AGENTS.md'
)),
'Cursor installs should not copy ECC root AGENTS.md into host project context'
);
assert.ok(
!plan.operations.some(operation => (
operation.destinationPath === path.join(projectRoot, '.cursor', 'AGENTS.md')
)),
'Cursor installs should not create .cursor/AGENTS.md'
);
})) passed++; else failed++;
if (test('plans cursor platform rule files as .mdc and excludes rule README docs', () => { if (test('plans cursor platform rule files as .mdc and excludes rule README docs', () => {
const repoRoot = path.join(__dirname, '..', '..'); const repoRoot = path.join(__dirname, '..', '..');
const projectRoot = '/workspace/app'; const projectRoot = '/workspace/app';