mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-05-17 06:13:08 +08:00
feat: add ECC statusline observability hooks
Salvages the useful statusline/context monitor work from stale PR #1504 while preserving the current continuous-learning hook runner wiring. Adds the metrics bridge, context monitor, statusline script, shared cost/session bridge utilities, and tests. Fixes the reviewed false loop-detection hash collision for non-file tools, avoids default-session cost inflation, sanitizes statusline task lookup, and records hook payload session IDs in cost-tracker.
This commit is contained in:
committed by
Affaan Mustafa
parent
e9c8845833
commit
940135ea47
@@ -152,6 +152,28 @@ function runTests() {
|
||||
fs.rmSync(tmpHome, { recursive: true, force: true });
|
||||
}) ? passed++ : failed++);
|
||||
|
||||
// 7. Uses sanitized hook input session_id when environment session IDs are absent
|
||||
(test('uses input session_id for session correlation when env vars are absent', () => {
|
||||
const tmpHome = makeTempDir();
|
||||
const input = {
|
||||
session_id: 'hook-session-abc',
|
||||
model: 'claude-sonnet-4-20250514',
|
||||
usage: { input_tokens: 120, output_tokens: 30 },
|
||||
};
|
||||
const result = runScript(input, {
|
||||
...withTempHome(tmpHome),
|
||||
ECC_SESSION_ID: '',
|
||||
CLAUDE_SESSION_ID: '',
|
||||
});
|
||||
assert.strictEqual(result.code, 0, `Expected exit code 0, got ${result.code}`);
|
||||
|
||||
const metricsFile = path.join(tmpHome, '.claude', 'metrics', 'costs.jsonl');
|
||||
const row = JSON.parse(fs.readFileSync(metricsFile, 'utf8').trim());
|
||||
assert.strictEqual(row.session_id, 'hook-session-abc', 'Expected input session_id to be recorded');
|
||||
|
||||
fs.rmSync(tmpHome, { recursive: true, force: true });
|
||||
}) ? passed++ : failed++);
|
||||
|
||||
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
|
||||
process.exit(failed > 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user