From f5b1867268222f02c56154bb6cd72a7db174ef45 Mon Sep 17 00:00:00 2001 From: huangpz6 Date: Wed, 4 Nov 2026 11:21:21 +0800 Subject: [PATCH 1/3] fix(skills-health): explain a missing scripts/lib instead of a module stack (#3259) A managed plugin install can lack scripts/lib/skill-evolution, which made skills-health fail on the first require with Cannot find module. Catch that specific resolution failure and print the install-apply remedy; other errors still propagate. Co-Authored-By: TRAE --- scripts/skills-health.js | 22 +++++++- .../scripts/skills-health-missing-lib.test.js | 51 +++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 tests/scripts/skills-health-missing-lib.test.js diff --git a/scripts/skills-health.js b/scripts/skills-health.js index 4cea9ec50..d3144644a 100644 --- a/scripts/skills-health.js +++ b/scripts/skills-health.js @@ -1,8 +1,26 @@ #!/usr/bin/env node 'use strict'; -const { collectSkillHealth, formatHealthReport } = require('./lib/skill-evolution/health'); -const { renderDashboard } = require('./lib/skill-evolution/dashboard'); +let collectSkillHealth; +let formatHealthReport; +let renderDashboard; +try { + ({ collectSkillHealth, formatHealthReport } = require('./lib/skill-evolution/health')); + ({ renderDashboard } = require('./lib/skill-evolution/dashboard')); +} catch (error) { + // The Claude Code plugin marketplace clones the repo but does not run + // npm/install-apply, so scripts/lib can be missing from a managed install. + // Fail with the remedy instead of a bare module-resolution stack (#3259). + if (error && error.code === 'MODULE_NOT_FOUND' && /skill-evolution/.test(error.message)) { + console.error( + 'skills-health requires scripts/lib/skill-evolution, which is missing from this installation.\n' + + 'Reinstall ECC with the commands-core module (node scripts/install-apply.js --target ) ' + + 'or run this script from a full checkout of the repository.' + ); + process.exit(1); + } + throw error; +} function showHelp() { console.log(` diff --git a/tests/scripts/skills-health-missing-lib.test.js b/tests/scripts/skills-health-missing-lib.test.js new file mode 100644 index 000000000..104f63dbf --- /dev/null +++ b/tests/scripts/skills-health-missing-lib.test.js @@ -0,0 +1,51 @@ +/** + * A managed install without scripts/lib must get the remedy, not a stack trace + * (#3259). + */ + +const assert = require('assert'); +const fs = require('fs'); +const os = require('os'); +const path = require('path'); +const { spawnSync } = require('child_process'); + +const script = path.join(__dirname, '..', '..', 'scripts', 'skills-health.js'); + +function test(name, fn) { + try { + fn(); + console.log(` ✓ ${name}`); + return true; + } catch (error) { + console.log(` ✗ ${name}`); + console.log(` Error: ${error.message}`); + return false; + } +} + +let passed = 0; +let failed = 0; + +const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-health-missing-lib-')); +fs.mkdirSync(path.join(tmp, 'scripts'), { recursive: true }); +fs.copyFileSync(script, path.join(tmp, 'scripts', 'skills-health.js')); + +if ( + test('missing scripts/lib prints the install remedy instead of a stack trace', () => { + const result = spawnSync('node', [path.join(tmp, 'scripts', 'skills-health.js')], { + encoding: 'utf8', + timeout: 15000 + }); + assert.strictEqual(result.status, 1); + assert.match(result.stderr, /missing from this installation/i); + assert.match(result.stderr, /install-apply\.js/); + assert.doesNotMatch(result.stderr, /Cannot find module/); + }) +) + passed++; +else failed++; + +fs.rmSync(tmp, { recursive: true, force: true }); + +console.log(`\n ${passed} passed, ${failed} failed\n`); +process.exit(failed > 0 ? 1 : 0); From a496ab1686a398b0411d880f24663542ab294c2a Mon Sep 17 00:00:00 2001 From: huangpz6 Date: Wed, 4 Nov 2026 21:37:57 +0800 Subject: [PATCH 2/3] fix(skills-health): name the missing module and give an executable remedy (#3865) The diagnostic always blamed scripts/lib/skill-evolution, hiding a nested failure such as a missing lib/utils.js, and the printed installer command selected no module. Include the module from the resolution error and point at a full-checkout install with --modules commands-core. Co-Authored-By: TRAE --- scripts/skills-health.js | 8 ++--- .../scripts/skills-health-missing-lib.test.js | 34 +++++++++++++++++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/scripts/skills-health.js b/scripts/skills-health.js index d3144644a..a70884d63 100644 --- a/scripts/skills-health.js +++ b/scripts/skills-health.js @@ -11,11 +11,11 @@ try { // The Claude Code plugin marketplace clones the repo but does not run // npm/install-apply, so scripts/lib can be missing from a managed install. // Fail with the remedy instead of a bare module-resolution stack (#3259). - if (error && error.code === 'MODULE_NOT_FOUND' && /skill-evolution/.test(error.message)) { + const missing = (String(error && error.message).match(/Cannot find module '([^']+)'/) || [])[1]; + if (error && error.code === 'MODULE_NOT_FOUND' && missing && /skill-evolution/.test(error.message)) { console.error( - 'skills-health requires scripts/lib/skill-evolution, which is missing from this installation.\n' + - 'Reinstall ECC with the commands-core module (node scripts/install-apply.js --target ) ' + - 'or run this script from a full checkout of the repository.' + `skills-health could not load ${missing}; this installation is missing part of scripts/lib/skill-evolution.\n` + + 'Run this from a full ECC checkout: node scripts/install-apply.js --target --modules commands-core' ); process.exit(1); } diff --git a/tests/scripts/skills-health-missing-lib.test.js b/tests/scripts/skills-health-missing-lib.test.js index 104f63dbf..bfd20646a 100644 --- a/tests/scripts/skills-health-missing-lib.test.js +++ b/tests/scripts/skills-health-missing-lib.test.js @@ -37,8 +37,37 @@ if ( timeout: 15000 }); assert.strictEqual(result.status, 1); - assert.match(result.stderr, /missing from this installation/i); - assert.match(result.stderr, /install-apply\.js/); + assert.match(result.stderr, /could not load \.\/lib\/skill-evolution\/health/); + assert.match(result.stderr, /--modules commands-core/); + assert.match(result.stderr, /full ECC checkout/); + assert.doesNotMatch(result.stderr, /Cannot find module/); + }) +) + passed++; +else failed++; + +const nested = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-health-nested-missing-')); +fs.mkdirSync(path.join(nested, 'scripts', 'lib'), { recursive: true }); +fs.copyFileSync(script, path.join(nested, 'scripts', 'skills-health.js')); +fs.cpSync( + path.join(__dirname, '..', '..', 'scripts', 'lib', 'skill-evolution'), + path.join(nested, 'scripts', 'lib', 'skill-evolution'), + { recursive: true } +); +// Keep skill-evolution in place but drop the shared helper it requires via +// `require('../utils')`; the error message must name that module, not claim +// the whole skill-evolution directory is absent. +fs.rmSync(path.join(nested, 'scripts', 'lib', 'utils.js'), { force: true }); + +if ( + test('a nested missing helper names the real module instead of the directory', () => { + const result = spawnSync('node', [path.join(nested, 'scripts', 'skills-health.js')], { + encoding: 'utf8', + timeout: 15000 + }); + assert.strictEqual(result.status, 1); + assert.match(result.stderr, /could not load \.\.\/utils/); + assert.match(result.stderr, /--modules commands-core/); assert.doesNotMatch(result.stderr, /Cannot find module/); }) ) @@ -46,6 +75,7 @@ if ( else failed++; fs.rmSync(tmp, { recursive: true, force: true }); +fs.rmSync(nested, { recursive: true, force: true }); console.log(`\n ${passed} passed, ${failed} failed\n`); process.exit(failed > 0 ? 1 : 0); From 0c2a542d203e89cd65918f8da8701d1ae58d12a1 Mon Sep 17 00:00:00 2001 From: huangpz6 Date: Wed, 4 Nov 2026 21:54:03 +0800 Subject: [PATCH 3/3] fix(skills-health): make the one-off checkout fallback explicit (#3865) commands-core copies scripts/lib into the Claude config root, so it does not repair a marketplace plugin installation. Lead with a direct dashboard run from a full checkout and keep commands-core as the non-marketplace reinstall path. Co-Authored-By: TRAE --- scripts/skills-health.js | 3 ++- tests/scripts/skills-health-missing-lib.test.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/skills-health.js b/scripts/skills-health.js index a70884d63..aefbe82ee 100644 --- a/scripts/skills-health.js +++ b/scripts/skills-health.js @@ -15,7 +15,8 @@ try { if (error && error.code === 'MODULE_NOT_FOUND' && missing && /skill-evolution/.test(error.message)) { console.error( `skills-health could not load ${missing}; this installation is missing part of scripts/lib/skill-evolution.\n` + - 'Run this from a full ECC checkout: node scripts/install-apply.js --target --modules commands-core' + 'For a one-off report, run from a full ECC checkout: node scripts/skills-health.js --dashboard. ' + + 'For a non-marketplace install, select commands-core: node scripts/install-apply.js --target --modules commands-core.' ); process.exit(1); } diff --git a/tests/scripts/skills-health-missing-lib.test.js b/tests/scripts/skills-health-missing-lib.test.js index bfd20646a..578a190fa 100644 --- a/tests/scripts/skills-health-missing-lib.test.js +++ b/tests/scripts/skills-health-missing-lib.test.js @@ -38,6 +38,7 @@ if ( }); assert.strictEqual(result.status, 1); assert.match(result.stderr, /could not load \.\/lib\/skill-evolution\/health/); + assert.match(result.stderr, /skills-health\.js --dashboard/); assert.match(result.stderr, /--modules commands-core/); assert.match(result.stderr, /full ECC checkout/); assert.doesNotMatch(result.stderr, /Cannot find module/); @@ -67,6 +68,7 @@ if ( }); assert.strictEqual(result.status, 1); assert.match(result.stderr, /could not load \.\.\/utils/); + assert.match(result.stderr, /skills-health\.js --dashboard/); assert.match(result.stderr, /--modules commands-core/); assert.doesNotMatch(result.stderr, /Cannot find module/); })