Merge pull request #2870 from actus7/consolidate/hooks-observer-v3

fix(hooks): consolidate hooks and observer fixes (5 PRs)
This commit is contained in:
haelyra
2026-08-28 18:29:03 -04:00
committed by GitHub
15 changed files with 469 additions and 45 deletions
+24 -12
View File
@@ -181,6 +181,29 @@ async function main() {
}
}
// ECC's LLM summary helper launches a one-shot Claude subprocess whose Stop
// hooks inherit this dedicated marker. Skip that known internal session
// before touching session state. Transcript cardinality is not a safe proxy:
// an ordinary user session may legitimately contain one prompt and no tools.
if (process.env.ECC_LLM_SUMMARY_SUBPROCESS === '1') {
log('[SessionEnd] Skipped ECC LLM summary subprocess');
return;
}
// Read known transcripts before resolving session metadata or touching the
// session directory. Missing, unreadable, or unparseable transcript data keeps
// the established fallback behavior because it cannot be classified reliably.
let summary = null;
let transcriptExists = false;
if (transcriptPath) {
transcriptExists = fs.existsSync(transcriptPath);
if (transcriptExists) {
summary = extractSessionSummary(transcriptPath);
} else {
log(`[SessionEnd] Transcript not found: ${transcriptPath}`);
}
}
const sessionsDir = getSessionsDir();
const today = getDateString();
// Derive shortId from transcript_path UUID when available, using the SAME
@@ -211,21 +234,10 @@ async function main() {
const currentTime = getTimeString();
// Try to extract summary from transcript
let summary = null;
if (transcriptPath) {
if (fs.existsSync(transcriptPath)) {
summary = extractSessionSummary(transcriptPath);
} else {
log(`[SessionEnd] Transcript not found: ${transcriptPath}`);
}
}
// Decide whether to call LLM for a richer summary.
// Triggers: context remaining < 20%, or every 50 user messages as a baseline.
let llmSummary = null;
if (transcriptPath && summary && fs.existsSync(transcriptPath)) {
if (transcriptPath && summary && transcriptExists) {
const contextPct = getContextRemainingPct(transcriptPath);
const isContextLow = contextPct !== null && contextPct < getContextThreshold();
const interval = parseInt(process.env.ECC_LLM_SUMMARY_INTERVAL || '50', 10);
+2 -1
View File
@@ -156,7 +156,8 @@ function generateSessionSummary(transcriptPath) {
env: {
...process.env,
CLAUDECODE: '',
ECC_SKIP_LLM_SUMMARY: '1'
ECC_SKIP_LLM_SUMMARY: '1',
ECC_LLM_SUMMARY_SUBPROCESS: '1'
},
timeout: LLM_TIMEOUT_MS,
shell: process.platform === 'win32'