From d49f0329a9d07d06bd64aa08205ba0634e6aec30 Mon Sep 17 00:00:00 2001 From: Affaan Mustafa Date: Thu, 30 Apr 2026 00:33:51 -0400 Subject: [PATCH] fix: avoid cursor nested AGENTS context pollution --- scripts/lib/install-targets/cursor-project.js | 6 ++++ tests/lib/install-targets.test.js | 30 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/scripts/lib/install-targets/cursor-project.js b/scripts/lib/install-targets/cursor-project.js index 66fd19df..617bbcc0 100644 --- a/scripts/lib/install-targets/cursor-project.js +++ b/scripts/lib/install-targets/cursor-project.js @@ -133,6 +133,12 @@ module.exports = createInstallTargetAdapter({ 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') { return takeUniqueOperations(createFlatRuleOperations({ moduleId: module.id, diff --git a/tests/lib/install-targets.test.js b/tests/lib/install-targets.test.js index e0908a62..98c021dc 100644 --- a/tests/lib/install-targets.test.js +++ b/tests/lib/install-targets.test.js @@ -172,6 +172,36 @@ function runTests() { ); })) 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', () => { const repoRoot = path.join(__dirname, '..', '..'); const projectRoot = '/workspace/app';