mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-01-31 19:53:07 +08:00
- Add session ID to session filenames (Issue #62) - Add getSessionIdShort() helper for unique per-session tracking - Add async hooks documentation with example - Create iterative-retrieval skill for progressive context refinement - Add continuous-learning-v2 skill with instinct-based learning - Add ecc.tools ecosystem section to README - Update skills list in README All 67 tests passing.
63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* SessionStart Hook - Load previous context on new session
|
|
*
|
|
* Cross-platform (Windows, macOS, Linux)
|
|
*
|
|
* Runs when a new Claude session starts. Checks for recent session
|
|
* files and notifies Claude of available context to load.
|
|
*/
|
|
|
|
const path = require('path');
|
|
const {
|
|
getSessionsDir,
|
|
getLearnedSkillsDir,
|
|
findFiles,
|
|
ensureDir,
|
|
log
|
|
} = require('../lib/utils');
|
|
const { getPackageManager, getSelectionPrompt } = require('../lib/package-manager');
|
|
|
|
async function main() {
|
|
const sessionsDir = getSessionsDir();
|
|
const learnedDir = getLearnedSkillsDir();
|
|
|
|
// Ensure directories exist
|
|
ensureDir(sessionsDir);
|
|
ensureDir(learnedDir);
|
|
|
|
// Check for recent session files (last 7 days)
|
|
// Match both old format (YYYY-MM-DD-session.tmp) and new format (YYYY-MM-DD-shortid-session.tmp)
|
|
const recentSessions = findFiles(sessionsDir, '*-session.tmp', { maxAge: 7 });
|
|
|
|
if (recentSessions.length > 0) {
|
|
const latest = recentSessions[0];
|
|
log(`[SessionStart] Found ${recentSessions.length} recent session(s)`);
|
|
log(`[SessionStart] Latest: ${latest.path}`);
|
|
}
|
|
|
|
// Check for learned skills
|
|
const learnedSkills = findFiles(learnedDir, '*.md');
|
|
|
|
if (learnedSkills.length > 0) {
|
|
log(`[SessionStart] ${learnedSkills.length} learned skill(s) available in ${learnedDir}`);
|
|
}
|
|
|
|
// Detect and report package manager
|
|
const pm = getPackageManager();
|
|
log(`[SessionStart] Package manager: ${pm.name} (${pm.source})`);
|
|
|
|
// If package manager was detected via fallback, show selection prompt
|
|
if (pm.source === 'fallback' || pm.source === 'default') {
|
|
log('[SessionStart] No package manager preference found.');
|
|
log(getSelectionPrompt());
|
|
}
|
|
|
|
process.exit(0);
|
|
}
|
|
|
|
main().catch(err => {
|
|
console.error('[SessionStart] Error:', err.message);
|
|
process.exit(0); // Don't block on errors
|
|
});
|