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.

test: add 3 tests for evaluate-session regex, empty rules/skills dirs (Round 65)

Affaan Mustafa485def8582a4
diff --git a/tests/ci/validators.test.js b/tests/ci/validators.test.js
index d0c69c4fe..679fdd5cd 100644
--- a/tests/ci/validators.test.js
+++ b/tests/ci/validators.test.js
@@ -1866,6 +1866,35 @@ function runTests() {
cleanupTestDir(testDir);
})) passed++; else failed++;
+ // ── Round 65: empty directories for rules and skills ──
+ console.log('\nRound 65: validate-rules.js (empty directory — no .md files):');
+
+ if (test('passes on rules directory with no .md files (Validated 0)', () => {
+ const testDir = createTestDir();
+ // Only non-.md files — readdirSync filter yields empty array
+ fs.writeFileSync(path.join(testDir, 'notes.txt'), 'not a rule');
+ fs.writeFileSync(path.join(testDir, 'config.json'), '{}');
+
+ const result = runValidatorWithDir('validate-rules', 'RULES_DIR', testDir);
+ assert.strictEqual(result.code, 0, 'Should pass on empty rules directory');
+ assert.ok(result.stdout.includes('Validated 0'), 'Should report 0 validated rule files');
+ cleanupTestDir(testDir);
+ })) passed++; else failed++;
+
+ console.log('\nRound 65: validate-skills.js (empty directory — no subdirectories):');
+
+ if (test('passes on skills directory with only files, no subdirectories (Validated 0)', () => {
+ const testDir = createTestDir();
+ // Only files, no subdirectories — isDirectory filter yields empty array
+ fs.writeFileSync(path.join(testDir, 'README.md'), '# Skills');
+ fs.writeFileSync(path.join(testDir, '.gitkeep'), '');
+
+ const result = runValidatorWithDir('validate-skills', 'SKILLS_DIR', testDir);
+ assert.strictEqual(result.code, 0, 'Should pass on skills directory with no subdirectories');
+ assert.ok(result.stdout.includes('Validated 0'), 'Should report 0 validated skill directories');
+ cleanupTestDir(testDir);
+ })) passed++; else failed++;
+
// Summary
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
process.exit(failed > 0 ? 1 : 0);
diff --git a/tests/hooks/evaluate-session.test.js b/tests/hooks/evaluate-session.test.js
index f5c7ddc69..bf01b9fda 100644
--- a/tests/hooks/evaluate-session.test.js
+++ b/tests/hooks/evaluate-session.test.js
@@ -284,6 +284,33 @@ function runTests() {
cleanupTestDir(testDir);
})) passed++; else failed++;
+ // ── Round 65: regex whitespace tolerance in countInFile ──
+ console.log('\nRound 65: regex whitespace tolerance around colon:');
+
+ if (test('counts user messages when JSON has spaces around colon ("type" : "user")', () => {
+ const testDir = createTestDir();
+ const filePath = path.join(testDir, 'spaced.jsonl');
+ // Manually write JSON with spaces around the colon — NOT JSON.stringify
+ // The regex /"type"\s*:\s*"user"/g should match these
+ const lines = [];
+ for (let i = 0; i < 12; i++) {
+ lines.push(`{"type" : "user", "content": "msg ${i}"}`);
+ lines.push(`{"type" : "assistant", "content": "resp ${i}"}`);
+ }
+ fs.writeFileSync(filePath, lines.join('\n') + '\n');
+
+ const result = runEvaluate({ transcript_path: filePath });
+ assert.strictEqual(result.code, 0);
+ // 12 user messages >= 10 threshold → should evaluate (not "too short")
+ assert.ok(!result.stderr.includes('too short'),
+ 'Should NOT say too short for 12 spaced-colon user messages');
+ assert.ok(
+ result.stderr.includes('12 messages') || result.stderr.includes('evaluate'),
+ `Should evaluate session with spaced-colon JSON. Got stderr: ${result.stderr}`
+ );
+ cleanupTestDir(testDir);
+ })) passed++; else failed++;
+
// Summary
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
process.exit(failed > 0 ? 1 : 0);