The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
fix(project-detect): match packageKeys on boundaries, not substrings (#2181)
bymle9c35aef60f2f
diff --git a/scripts/lib/project-detect.js b/scripts/lib/project-detect.jsindex 7c7d605b4..9f1566ada 100644--- a/scripts/lib/project-detect.js+++ b/scripts/lib/project-detect.js@@ -390,7 +390,20 @@ function detectProjectType(projectDir) {depList = elixirDeps;break;}- hasDep = rule.packageKeys.some(key => depList.some(dep => dep.toLowerCase().includes(key.toLowerCase())));+ // Boundary-aware match: a dependency matches a packageKey only when it+ // equals the key, or the key is a prefix immediately followed by a+ // delimiter (/ . _ -). Plain substring matching wrongly classified+ // `preact` / `reactive` as `react`. This still matches the real cases:+ // react-dom, @remix-run/node, spring-boot-starter, org.springframework.boot,+ // github.com/labstack/echo/v4, phoenix_live_view.+ hasDep = rule.packageKeys.some(key => {+ const k = key.toLowerCase();+ return depList.some(dep => {+ const d = dep.toLowerCase();+ if (!d.startsWith(k)) return false;+ return d.length === k.length || /[/._-]/.test(d[k.length]);+ });+ });}if (hasMarker || hasDep) {diff --git a/tests/lib/project-detect.test.js b/tests/lib/project-detect.test.jsindex 94830af91..15382b246 100644--- a/tests/lib/project-detect.test.js+++ b/tests/lib/project-detect.test.js@@ -207,6 +207,39 @@ function runTests() {}})) passed++; else failed++;+ if (test('does not misclassify preact as react (substring guard)', () => {+ const dir = createTempDir();+ try {+ writeTestFile(dir, 'package.json', '{"dependencies":{"preact":"10.0.0"}}');+ const result = detectProjectType(dir);+ assert.ok(!result.frameworks.includes('react'), `preact wrongly detected as react: ${JSON.stringify(result.frameworks)}`);+ } finally {+ cleanupDir(dir);+ }+ })) passed++; else failed++;++ if (test('does not misclassify reactive as react (substring guard)', () => {+ const dir = createTempDir();+ try {+ writeTestFile(dir, 'package.json', '{"dependencies":{"reactive":"1.0.0"}}');+ const result = detectProjectType(dir);+ assert.ok(!result.frameworks.includes('react'), `reactive wrongly detected as react: ${JSON.stringify(result.frameworks)}`);+ } finally {+ cleanupDir(dir);+ }+ })) passed++; else failed++;++ if (test('still detects react from react-dom alone (prefix-delimiter match preserved)', () => {+ const dir = createTempDir();+ try {+ writeTestFile(dir, 'package.json', '{"dependencies":{"react-dom":"18.0.0"}}');+ const result = detectProjectType(dir);+ assert.ok(result.frameworks.includes('react'), `react-dom should still map to react: ${JSON.stringify(result.frameworks)}`);+ } finally {+ cleanupDir(dir);+ }+ })) passed++; else failed++;+if (test('detects angular from angular.json', () => {const dir = createTempDir();try {