Files
everything-claude-code/scripts/hooks/session-end.js
Affaan Mustafa a44a0553bb fix: resolve ESLint errors and update tests for project-name fallback
- Fix 16 ESLint no-unused-vars errors across hook scripts and tests
- Add eslint-disable comment for intentional control-regex in ANSI stripper
- Update session file test to use getSessionIdShort() instead of hardcoded 'default'
  (reflects PR #110's project-name fallback behavior)
- Add marketing/ to .gitignore (local drafts)
- Add skill-create-output.js (terminal output formatter)

All 69 tests now pass. CI should be green.
2026-01-29 02:58:51 -08:00

85 lines
1.7 KiB
JavaScript

#!/usr/bin/env node
/**
* Stop Hook (Session End) - Persist learnings when session ends
*
* Cross-platform (Windows, macOS, Linux)
*
* Runs when Claude session ends. Creates/updates session log file
* with timestamp for continuity tracking.
*/
const path = require('path');
const fs = require('fs');
const {
getSessionsDir,
getDateString,
getTimeString,
getSessionIdShort,
ensureDir,
writeFile,
replaceInFile,
log
} = require('../lib/utils');
async function main() {
const sessionsDir = getSessionsDir();
const today = getDateString();
const shortId = getSessionIdShort();
// Include session ID in filename for unique per-session tracking
const sessionFile = path.join(sessionsDir, `${today}-${shortId}-session.tmp`);
ensureDir(sessionsDir);
const currentTime = getTimeString();
// If session file exists for today, update the end time
if (fs.existsSync(sessionFile)) {
const success = replaceInFile(
sessionFile,
/\*\*Last Updated:\*\*.*/,
`**Last Updated:** ${currentTime}`
);
if (success) {
log(`[SessionEnd] Updated session file: ${sessionFile}`);
}
} else {
// Create new session file with template
const template = `# Session: ${today}
**Date:** ${today}
**Started:** ${currentTime}
**Last Updated:** ${currentTime}
---
## Current State
[Session context goes here]
### Completed
- [ ]
### In Progress
- [ ]
### Notes for Next Session
-
### Context to Load
\`\`\`
[relevant files]
\`\`\`
`;
writeFile(sessionFile, template);
log(`[SessionEnd] Created session file: ${sessionFile}`);
}
process.exit(0);
}
main().catch(err => {
console.error('[SessionEnd] Error:', err.message);
process.exit(0);
});