mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-02-01 20:23:08 +08:00
- Rewrite all bash hooks to Node.js for Windows/macOS/Linux compatibility - Add package manager auto-detection (npm, pnpm, yarn, bun) - Add scripts/lib/ with cross-platform utilities - Add /setup-pm command for package manager configuration - Add comprehensive test suite (62 tests) Co-authored-by: zerx-lab
61 lines
1.7 KiB
JavaScript
61 lines
1.7 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Strategic Compact Suggester
|
|
*
|
|
* Cross-platform (Windows, macOS, Linux)
|
|
*
|
|
* Runs on PreToolUse or periodically to suggest manual compaction at logical intervals
|
|
*
|
|
* Why manual over auto-compact:
|
|
* - Auto-compact happens at arbitrary points, often mid-task
|
|
* - Strategic compacting preserves context through logical phases
|
|
* - Compact after exploration, before execution
|
|
* - Compact after completing a milestone, before starting next
|
|
*/
|
|
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const {
|
|
getTempDir,
|
|
readFile,
|
|
writeFile,
|
|
log
|
|
} = require('../lib/utils');
|
|
|
|
async function main() {
|
|
// Track tool call count (increment in a temp file)
|
|
// Use a session-specific counter file based on PID from parent process
|
|
// or session ID from environment
|
|
const sessionId = process.env.CLAUDE_SESSION_ID || process.ppid || 'default';
|
|
const counterFile = path.join(getTempDir(), `claude-tool-count-${sessionId}`);
|
|
const threshold = parseInt(process.env.COMPACT_THRESHOLD || '50', 10);
|
|
|
|
let count = 1;
|
|
|
|
// Read existing count or start at 1
|
|
const existing = readFile(counterFile);
|
|
if (existing) {
|
|
count = parseInt(existing.trim(), 10) + 1;
|
|
}
|
|
|
|
// Save updated count
|
|
writeFile(counterFile, String(count));
|
|
|
|
// Suggest compact after threshold tool calls
|
|
if (count === threshold) {
|
|
log(`[StrategicCompact] ${threshold} tool calls reached - consider /compact if transitioning phases`);
|
|
}
|
|
|
|
// Suggest at regular intervals after threshold
|
|
if (count > threshold && count % 25 === 0) {
|
|
log(`[StrategicCompact] ${count} tool calls - good checkpoint for /compact if context is stale`);
|
|
}
|
|
|
|
process.exit(0);
|
|
}
|
|
|
|
main().catch(err => {
|
|
console.error('[StrategicCompact] Error:', err.message);
|
|
process.exit(0);
|
|
});
|