mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
fix: migrate hooks to stdin JSON input, fix duplicate main() calls, add threshold validation
- Migrate session-end.js and evaluate-session.js from CLAUDE_TRANSCRIPT_PATH env var to stdin JSON transcript_path (correct hook input mechanism) - Remove duplicate main() calls that ran before stdin was read, causing session files to be created with empty data - Add range validation (1-10000) on COMPACT_THRESHOLD in suggest-compact.js to prevent negative or absurdly large thresholds - Add integration/hooks.test.js to tests/run-all.js so CI runs all 97 tests - Update evaluate-session.sh to parse transcript_path from stdin JSON - Update hooks.test.js to pass transcript_path via stdin instead of env var - Sync .cursor/ copies
This commit is contained in:
@@ -232,9 +232,8 @@ async function runTests() {
|
||||
const transcript = Array(5).fill('{"type":"user","content":"test"}\n').join('');
|
||||
fs.writeFileSync(transcriptPath, transcript);
|
||||
|
||||
const result = await runScript(path.join(scriptsDir, 'evaluate-session.js'), '', {
|
||||
CLAUDE_TRANSCRIPT_PATH: transcriptPath
|
||||
});
|
||||
const stdinJson = JSON.stringify({ transcript_path: transcriptPath });
|
||||
const result = await runScript(path.join(scriptsDir, 'evaluate-session.js'), stdinJson);
|
||||
|
||||
assert.ok(
|
||||
result.stderr.includes('Session too short'),
|
||||
@@ -252,9 +251,8 @@ async function runTests() {
|
||||
const transcript = Array(15).fill('{"type":"user","content":"test"}\n').join('');
|
||||
fs.writeFileSync(transcriptPath, transcript);
|
||||
|
||||
const result = await runScript(path.join(scriptsDir, 'evaluate-session.js'), '', {
|
||||
CLAUDE_TRANSCRIPT_PATH: transcriptPath
|
||||
});
|
||||
const stdinJson = JSON.stringify({ transcript_path: transcriptPath });
|
||||
const result = await runScript(path.join(scriptsDir, 'evaluate-session.js'), stdinJson);
|
||||
|
||||
assert.ok(
|
||||
result.stderr.includes('15 messages'),
|
||||
|
||||
@@ -13,7 +13,8 @@ const testsDir = __dirname;
|
||||
const testFiles = [
|
||||
'lib/utils.test.js',
|
||||
'lib/package-manager.test.js',
|
||||
'hooks/hooks.test.js'
|
||||
'hooks/hooks.test.js',
|
||||
'integration/hooks.test.js'
|
||||
];
|
||||
|
||||
console.log('╔══════════════════════════════════════════════════════════╗');
|
||||
|
||||
Reference in New Issue
Block a user