Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

Merge remote-tracking branch 'origin/main' into feat/optimize-biome-hooks

Affaan Mustafad239d873d887
diff --cc tests/hooks/hooks.test.js
index 311ae21fd,5610ed371..154af48f6
--- a/tests/hooks/hooks.test.js
+++ b/tests/hooks/hooks.test.js
@@@ -2017,74 -1753,101 +2040,110 @@@ async function runTests()
console.log('\nShell wrapper portability:');
- if (test('run-with-flags-shell resolves plugin root when CLAUDE_PLUGIN_ROOT is unset', () => {
- const wrapperSource = fs.readFileSync(path.join(scriptsDir, 'run-with-flags-shell.sh'), 'utf8');
- assert.ok(
- wrapperSource.includes('PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-'),
- 'Shell wrapper should derive PLUGIN_ROOT from its own script path'
- );
- })) passed++; else failed++;
-
- if (test('continuous-learning shell scripts use resolved Python command instead of hardcoded python3 invocations', () => {
- const observeSource = fs.readFileSync(path.join(__dirname, '..', '..', 'skills', 'continuous-learning-v2', 'hooks', 'observe.sh'), 'utf8');
- const startObserverSource = fs.readFileSync(path.join(__dirname, '..', '..', 'skills', 'continuous-learning-v2', 'agents', 'start-observer.sh'), 'utf8');
- const detectProjectSource = fs.readFileSync(path.join(__dirname, '..', '..', 'skills', 'continuous-learning-v2', 'scripts', 'detect-project.sh'), 'utf8');
-
- assert.ok(!/python3\s+-c/.test(observeSource), 'observe.sh should not invoke python3 directly');
- assert.ok(!/python3\s+-c/.test(startObserverSource), 'start-observer.sh should not invoke python3 directly');
- assert.ok(observeSource.includes('PYTHON_CMD'), 'observe.sh should resolve Python dynamically');
- assert.ok(startObserverSource.includes('CLV2_PYTHON_CMD'), 'start-observer.sh should reuse detected Python command');
- assert.ok(detectProjectSource.includes('_clv2_resolve_python_cmd'), 'detect-project.sh should provide shared Python resolution');
- })) passed++; else failed++;
-
- if (await asyncTest('detect-project exports the resolved Python command for downstream scripts', async () => {
- const detectProjectPath = path.join(__dirname, '..', '..', 'skills', 'continuous-learning-v2', 'scripts', 'detect-project.sh');
- const shellCommand = [
- `source "${detectProjectPath}" >/dev/null 2>&1`,
- 'printf "%s\\n" "${CLV2_PYTHON_CMD:-}"'
- ].join('; ');
-
- const shell = process.platform === 'win32' ? 'bash' : 'bash';
- const proc = spawn(shell, ['-lc', shellCommand], {
- env: process.env,
- stdio: ['ignore', 'pipe', 'pipe']
- });
+ if (
+ test('run-with-flags-shell resolves plugin root when CLAUDE_PLUGIN_ROOT is unset', () => {
+ const wrapperSource = fs.readFileSync(path.join(scriptsDir, 'run-with-flags-shell.sh'), 'utf8');
+ assert.ok(wrapperSource.includes('PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-'), 'Shell wrapper should derive PLUGIN_ROOT from its own script path');
+ })
+ )
+ passed++;
+ else failed++;
+
+ if (
+ test('continuous-learning shell scripts use resolved Python command instead of hardcoded python3 invocations', () => {
+ const observeSource = fs.readFileSync(path.join(__dirname, '..', '..', 'skills', 'continuous-learning-v2', 'hooks', 'observe.sh'), 'utf8');
+ const startObserverSource = fs.readFileSync(path.join(__dirname, '..', '..', 'skills', 'continuous-learning-v2', 'agents', 'start-observer.sh'), 'utf8');
+ const detectProjectSource = fs.readFileSync(path.join(__dirname, '..', '..', 'skills', 'continuous-learning-v2', 'scripts', 'detect-project.sh'), 'utf8');
+
+ assert.ok(!/python3\s+-c/.test(observeSource), 'observe.sh should not invoke python3 directly');
+ assert.ok(!/python3\s+-c/.test(startObserverSource), 'start-observer.sh should not invoke python3 directly');
+ assert.ok(observeSource.includes('PYTHON_CMD'), 'observe.sh should resolve Python dynamically');
+ assert.ok(startObserverSource.includes('CLV2_PYTHON_CMD'), 'start-observer.sh should reuse detected Python command');
+ assert.ok(detectProjectSource.includes('_clv2_resolve_python_cmd'), 'detect-project.sh should provide shared Python resolution');
+ })
+ )
+ passed++;
+ else failed++;
+
+ if (
+ await asyncTest('detect-project exports the resolved Python command for downstream scripts', async () => {
+ const detectProjectPath = path.join(__dirname, '..', '..', 'skills', 'continuous-learning-v2', 'scripts', 'detect-project.sh');
+ const shellCommand = [`source "${detectProjectPath}" >/dev/null 2>&1`, 'printf "%s\\n" "${CLV2_PYTHON_CMD:-}"'].join('; ');
+
+ const shell = process.platform === 'win32' ? 'bash' : 'bash';
+ const proc = spawn(shell, ['-lc', shellCommand], {
+ env: process.env,
+ stdio: ['ignore', 'pipe', 'pipe']
+ });
- let stdout = '';
- let stderr = '';
- proc.stdout.on('data', data => stdout += data);
- proc.stderr.on('data', data => stderr += data);
+ let stdout = '';
+ let stderr = '';
+ proc.stdout.on('data', data => (stdout += data));
+ proc.stderr.on('data', data => (stderr += data));
- const code = await new Promise((resolve, reject) => {
- proc.on('close', resolve);
- proc.on('error', reject);
- });
+ const code = await new Promise((resolve, reject) => {
+ proc.on('close', resolve);
+ proc.on('error', reject);
+ });
- assert.strictEqual(code, 0, `detect-project.sh should source cleanly, stderr: ${stderr}`);
- assert.ok(stdout.trim().length > 0, 'CLV2_PYTHON_CMD should export a resolved interpreter path');
- })) passed++; else failed++;
+ assert.strictEqual(code, 0, `detect-project.sh should source cleanly, stderr: ${stderr}`);
+ assert.ok(stdout.trim().length > 0, 'CLV2_PYTHON_CMD should export a resolved interpreter path');
+ })
+ )
+ passed++;
+ else failed++;
- if (
- await asyncTest('matches .tsx extension for type checking', async () => {
- const testDir = createTestDir();
- const testFile = path.join(testDir, 'component.tsx');
- fs.writeFileSync(testFile, 'const x: number = 1;');
+ if (await asyncTest('observe.sh falls back to legacy output fields when tool_response is null', async () => {
+ const homeDir = createTestDir();
+ const projectDir = createTestDir();
+ const observePath = path.join(__dirname, '..', '..', 'skills', 'continuous-learning-v2', 'hooks', 'observe.sh');
+ const payload = JSON.stringify({
+ tool_name: 'Bash',
+ tool_input: { command: 'echo hello' },
+ tool_response: null,
+ tool_output: 'legacy output',
+ session_id: 'session-123',
+ cwd: projectDir
+ });
+
+ try {
+ const result = await runShellScript(observePath, ['post'], payload, {
+ HOME: homeDir,
+ CLAUDE_PROJECT_DIR: projectDir
+ }, projectDir);
+
+ assert.strictEqual(result.code, 0, `observe.sh should exit successfully, stderr: ${result.stderr}`);
+
+ const projectsDir = path.join(homeDir, '.claude', 'homunculus', 'projects');
+ const projectIds = fs.readdirSync(projectsDir);
+ assert.strictEqual(projectIds.length, 1, 'observe.sh should create one project-scoped observation directory');
+
+ const observationsPath = path.join(projectsDir, projectIds[0], 'observations.jsonl');
+ const observations = fs.readFileSync(observationsPath, 'utf8').trim().split('\n').filter(Boolean);
+ assert.ok(observations.length > 0, 'observe.sh should append at least one observation');
+
+ const observation = JSON.parse(observations[0]);
+ assert.strictEqual(observation.output, 'legacy output', 'observe.sh should fall back to legacy tool_output when tool_response is null');
+ } finally {
+ cleanupTestDir(homeDir);
+ cleanupTestDir(projectDir);
+ }
+ })) passed++; else failed++;
+
+ if (await asyncTest('matches .tsx extension for type checking', async () => {
+ const testDir = createTestDir();
+ const testFile = path.join(testDir, 'component.tsx');
+ fs.writeFileSync(testFile, 'const x: number = 1;');
- const stdinJson = JSON.stringify({ tool_input: { file_path: testFile } });
- const result = await runScript(path.join(scriptsDir, 'post-edit-typecheck.js'), stdinJson);
- assert.strictEqual(result.code, 0);
- assert.ok(result.stdout.includes('tool_input'), 'Should pass through data for .tsx files');
- cleanupTestDir(testDir);
- })) passed++; else failed++;
+ const stdinJson = JSON.stringify({ tool_input: { file_path: testFile } });
+ const result = await runScript(path.join(scriptsDir, 'post-edit-typecheck.js'), stdinJson);
+ assert.strictEqual(result.code, 0);
+ assert.ok(result.stdout.includes('tool_input'), 'Should pass through data for .tsx files');
+ cleanupTestDir(testDir);
+ })
+ )
+ passed++;
+ else failed++;
// ─── Round 23: Bug fixes & high-priority gap coverage ───
@@@ -2979,17 -2555,14 +3038,18 @@@
console.log('\nRound 29: run-all.js test runner improvements:');
- if (await asyncTest('test runner uses spawnSync to capture stderr on success', async () => {
- const runAllSource = fs.readFileSync(path.join(__dirname, '..', 'run-all.js'), 'utf8');
- assert.ok(runAllSource.includes('spawnSync'), 'Should use spawnSync instead of execSync');
- assert.ok(!runAllSource.includes('execSync'), 'Should not use execSync');
- // Verify it shows stderr
- assert.ok(runAllSource.includes('stderr'), 'Should handle stderr output');
- assert.ok(runAllSource.includes('result.status !== 0'), 'Should treat non-zero child exits as failures');
- })) passed++; else failed++;
+ if (
+ await asyncTest('test runner uses spawnSync to capture stderr on success', async () => {
+ const runAllSource = fs.readFileSync(path.join(__dirname, '..', 'run-all.js'), 'utf8');
+ assert.ok(runAllSource.includes('spawnSync'), 'Should use spawnSync instead of execSync');
+ assert.ok(!runAllSource.includes('execSync'), 'Should not use execSync');
+ // Verify it shows stderr
+ assert.ok(runAllSource.includes('stderr'), 'Should handle stderr output');
++ assert.ok(runAllSource.includes('result.status !== 0'), 'Should treat non-zero child exits as failures');
+ })
+ )
+ passed++;
+ else failed++;
// ── Round 32: post-edit-typecheck special characters & check-console-log ──
console.log('\nRound 32: post-edit-typecheck (special character paths):');
diff --cc tests/run-all.js
index 41a6c7f7b,399de5a7d..a13e2f06d
--- a/tests/run-all.js
+++ b/tests/run-all.js
@@@ -10,25 -10,28 +10,28 @@@ const path = require('path')
const fs = require('fs');
const testsDir = __dirname;
- const testFiles = [
- 'lib/utils.test.js',
- 'lib/package-manager.test.js',
- 'lib/session-manager.test.js',
- 'lib/session-aliases.test.js',
- 'lib/project-detect.test.js',
- 'lib/resolve-formatter.test.js',
- 'hooks/hooks.test.js',
- 'hooks/evaluate-session.test.js',
- 'hooks/suggest-compact.test.js',
- 'integration/hooks.test.js',
- 'ci/validators.test.js',
- 'scripts/claw.test.js',
- 'scripts/setup-package-manager.test.js',
- 'scripts/skill-create-output.test.js'
- ];
+
+ /**
+ * Discover all *.test.js files under testsDir (relative paths for stable output order).
+ */
+ function discoverTestFiles(dir, baseDir = dir, acc = []) {
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
+ for (const e of entries) {
+ const full = path.join(dir, e.name);
+ const rel = path.relative(baseDir, full);
+ if (e.isDirectory()) {
+ discoverTestFiles(full, baseDir, acc);
+ } else if (e.isFile() && e.name.endsWith('.test.js')) {
+ acc.push(rel);
+ }
+ }
+ return acc.sort();
+ }
+
+ const testFiles = discoverTestFiles(testsDir);
const BOX_W = 58; // inner width between ║ delimiters
-const boxLine = (s) => `║${s.padEnd(BOX_W)}║`;
+const boxLine = s => `║${s.padEnd(BOX_W)}║`;
console.log('╔' + '═'.repeat(BOX_W) + '╗');
console.log(boxLine(' Everything Claude Code - Test Suite'));