Files
ewoooc/.claude/hooks/suggest-compact.js
ogt cac7303e46 feat(devteam): 引進 my-claude-devteam 架構 V11.0
- CLAUDE.md 升版至 V11.0:整合 P7/P9/P10 工作模式、12 人專家團隊、
  委派鐵律、三條紅線(保留狙擊手模式精神)
- .claude/hooks/:新增 8 個 Hook(momo-prod-guard / commit-quality /
  large-file-warner / mcp-health / audit-log / suggest-compact /
  cost-tracker / session-summary)
- .claude/agents/:新增 11 個 Agent 定義(critic / debugger / db-expert /
  vuln-verifier / fullstack-engineer / planner / refactor-specialist /
  migration-engineer / onboarder / tool-expert / web-researcher)
- .claude/settings.json:啟用 bypassPermissions + Hook 自動政策架構
- .gitignore:加入 settings.local.json 防止 Secret 意外 commit

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 22:13:57 +08:00

23 lines
933 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* suggest-compact.js — PostToolUse Hook
* 工具呼叫達 50 次建議 /compact之後每 25 次再提示。
*/
const fs = require('fs');
const os = require('os');
const path = require('path');
let d = '';
process.stdin.on('data', c => d += c);
process.stdin.on('end', () => {
try {
const sid = (process.env.CLAUDE_SESSION_ID || 'default').replace(/[^a-zA-Z0-9_-]/g, '_').substring(0, 64);
const f = path.join(os.tmpdir(), `claude-tool-count-${sid}`);
let count = 0;
try { count = parseInt(fs.readFileSync(f, 'utf8')) || 0; } catch (e) {}
count++;
fs.writeFileSync(f, String(count));
if (count === 50) process.stderr.write('[suggest-compact] context 偵測達 50 次工具呼叫,建議執行 /compact\n');
else if (count > 50 && (count - 50) % 25 === 0) process.stderr.write('[suggest-compact] context 持續累積,建議 /compact\n');
} catch (e) {}
process.stdout.write(d);
});