refactor: consolidate duplicated hook-root resolver into shared resolveEccRoot() (#2368) (#2410)

* fix(ci): resync lockfiles with package.json (eslint 10) + migrate yarn.lock to Yarn 4 format

package.json requires eslint@^10.6.0 but the committed locks pinned 9.39.2, so
npm ci aborted and Yarn 4 hardened mode rejected the stale v1-classic yarn.lock
(YN0028). Regenerate package-lock.json and rewrite yarn.lock in Yarn 4 (berry)
format so npm ci and immutable yarn installs both pass.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ci): require clean probe exit for Windows shell/bash detection; add pyyaml dev dep

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor: consolidate duplicated hook-root resolver into shared resolveEccRoot() (#2368)

The inline node -e resolver blob was duplicated ~60x across hooks.json,
command docs, and translations. Each copy inlined the full ~700-char
plugin-root search using a spread over nested array literals
(p.join(d,'plugins',...s) over [['ecc'],...]), which breaks Windows hook
execution due to shell quoting (#2368).

Collapse every copy to a 250-char locator that loads the committed
resolve-ecc-root module and delegates to resolveEccRoot() — no spread, no
nested array literals, no escaped double quotes. The real search logic now
lives in one tested module. Also route session-start-bootstrap.js through
resolveEccRoot() instead of its own duplicated reimplementation, and fix
the auto-update.md 'marketplace' (singular) typo along the way.

Guard tests updated: discovery behavior is asserted against resolveEccRoot();
the inline is asserted to delegate and to contain no Windows-fragile
constructs.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(resolve-ecc-root): restore full env-unset discovery in inline resolver

Address Greptile review on #2410: when CLAUDE_PLUGIN_ROOT is unset the
delegating inline could only load the resolver module from ~/.claude,
returning ~/.claude without ever reaching the plugin/cache search. Restore
the old inline's discovery breadth (exact plugin roots + versioned cache)
Windows-safely (no spread, nested arrays, or escaped quotes), then delegate
the authoritative decision to resolveEccRoot(). Add regression tests for
plugin-subdir and versioned-cache bootstrap with env unset.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: affaan <affaan@itomarkets.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
devin-ai-integration[bot] 2026-07-03 20:01:17 -07:00 committed by GitHub
parent 6fac227f7a
commit 3af4676e99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 222 additions and 204 deletions

View file

@ -2,6 +2,7 @@
const fs = require('fs');
const path = require('path');
const os = require('os');
const assert = require('assert');
const { INLINE_RESOLVE } = require('../../scripts/lib/resolve-ecc-root');
@ -26,23 +27,17 @@ const instinctStatusDoc = fs.readFileSync(path.join(__dirname, '..', '..', 'comm
test('sessions command uses shared inline resolver in all node scripts', () => {
assert.strictEqual((sessionsDoc.match(/const _r = /g) || []).length, 6);
assert.strictEqual((sessionsDoc.match(/\['marketplaces','ecc'\]/g) || []).length, 6);
assert.strictEqual((sessionsDoc.match(/\['marketplaces','everything-claude-code'\]/g) || []).length, 6);
assert.strictEqual((sessionsDoc.match(/\['ecc','everything-claude-code'\]/g) || []).length, 6);
assert.strictEqual((sessionsDoc.match(/scripts','lib','resolve-ecc-root/g) || []).length, 6);
});
test('skill-health command uses shared inline resolver in all shell snippets', () => {
assert.strictEqual((skillHealthDoc.match(/var r=/g) || []).length, 3);
assert.strictEqual((skillHealthDoc.match(/\['marketplaces','ecc'\]/g) || []).length, 3);
assert.strictEqual((skillHealthDoc.match(/\['marketplaces','everything-claude-code'\]/g) || []).length, 3);
assert.strictEqual((skillHealthDoc.match(/\['ecc','everything-claude-code'\]/g) || []).length, 3);
assert.strictEqual((skillHealthDoc.match(/var r=\(function/g) || []).length, 3);
assert.strictEqual((skillHealthDoc.match(/scripts','lib','resolve-ecc-root/g) || []).length, 3);
});
test('instinct-status command uses shared inline resolver (no stale legacy fallback) (#2037)', () => {
assert.strictEqual((instinctStatusDoc.match(/var r=/g) || []).length, 1);
assert.strictEqual((instinctStatusDoc.match(/\['marketplaces','ecc'\]/g) || []).length, 1);
assert.strictEqual((instinctStatusDoc.match(/\['marketplaces','everything-claude-code'\]/g) || []).length, 1);
assert.strictEqual((instinctStatusDoc.match(/\['ecc','everything-claude-code'\]/g) || []).length, 1);
assert.strictEqual((instinctStatusDoc.match(/var r=\(function/g) || []).length, 1);
assert.strictEqual((instinctStatusDoc.match(/scripts','lib','resolve-ecc-root/g) || []).length, 1);
// The pre-fix template hard-coded the legacy path as a fallback when
// CLAUDE_PLUGIN_ROOT was unset. Asserting its absence prevents regression.
assert.ok(
@ -51,10 +46,32 @@ test('instinct-status command uses shared inline resolver (no stale legacy fallb
);
});
test('inline resolver covers current and legacy marketplace plugin roots', () => {
assert.ok(INLINE_RESOLVE.includes("'marketplaces','ecc'"));
assert.ok(INLINE_RESOLVE.includes("'marketplaces','everything-claude-code'"));
test('resolveEccRoot module covers current and legacy marketplace plugin roots', () => {
const { resolveEccRoot } = require('../../scripts/lib/resolve-ecc-root');
assert.ok(typeof resolveEccRoot === 'function');
const legacyHomeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-marketplace-legacy-'));
try {
const legacyRoot = path.join(legacyHomeDir, '.claude', 'plugins', 'marketplaces', 'ecc');
fs.mkdirSync(path.join(legacyRoot, 'scripts', 'lib'), { recursive: true });
fs.writeFileSync(path.join(legacyRoot, 'scripts', 'lib', 'utils.js'), '// stub');
assert.strictEqual(resolveEccRoot({ envRoot: '', homeDir: legacyHomeDir }), legacyRoot);
} finally {
fs.rmSync(legacyHomeDir, { recursive: true, force: true });
}
const cacheHomeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-marketplace-cache-'));
try {
const cacheRoot = path.join(cacheHomeDir, '.claude', 'plugins', 'cache', 'ecc', 'affaan-m', '1.0.0');
fs.mkdirSync(path.join(cacheRoot, 'scripts', 'lib'), { recursive: true });
fs.writeFileSync(path.join(cacheRoot, 'scripts', 'lib', 'utils.js'), '// stub');
assert.strictEqual(resolveEccRoot({ envRoot: '', homeDir: cacheHomeDir }), cacheRoot);
} finally {
fs.rmSync(cacheHomeDir, { recursive: true, force: true });
}
assert.ok(!INLINE_RESOLVE.includes('\\"'), 'Inline resolver should not require escaped double quotes');
assert.ok(INLINE_RESOLVE.includes("scripts','lib','resolve-ecc-root"));
});
console.log(`Passed: ${passed}`);