ed9bade863
project-files/: - CLAUDE.md.template (266 lines) - docs/Pravila_raboty_Claude.template.md (720 lines) - docs/Plugin_stack_rules.template.md (916 lines) - docs/Tooling.template.md (613 lines) - docs/CHANGELOG_claude_md.template.md - docs/visualizations/hooks-skills-plugins-map.html (3122 lines) - .mcp.json.template (universal: playwright/github/semgrep; laravel-boost dropped) user-level-files/: - hooks/ (10 Python files: skill-marker, skill-check, economy-* x8) - settings-fragment.json (enabledPlugins + permissions + hooks only) - marketplaces.json (3 sources) - plugins-manifest.json (4 plugins pinned with gitCommitSha) - mcp-user.template.json (magic with <<MAGIC_API_KEY>> placeholder) Gitleaks scan: 0 findings. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
67 lines
2.1 KiB
Python
67 lines
2.1 KiB
Python
"""PostCompact hook: re-inject economy rules after auto-compaction.
|
|
Reads state file (persists on disk after compaction), produces
|
|
additionalContext same as economy-mode.py would on UserPromptSubmit."""
|
|
import json
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
|
|
try:
|
|
sys.stdin.reconfigure(encoding="utf-8", errors="replace")
|
|
except Exception:
|
|
pass
|
|
|
|
|
|
LEVEL_TOPLINE = {
|
|
100: None,
|
|
75: "Жёсткие/мета OFF: НЕ заявлять passed без запуска, НЕ cherry-pick, НЕ anchor на 1й гипотезе",
|
|
50: "Жёсткие/мета OFF + verify memory + ≥2 гипотезы на debug + full test output",
|
|
25: "verify-before-completion на ≥2-step задачах, full reads ≤5000, Grep limit 500",
|
|
0: "ВСЕ паттерны OFF: full reads, full test output, ≥3 гипотезы на debug, verify perceived 'готово'",
|
|
}
|
|
|
|
|
|
def main() -> None:
|
|
try:
|
|
data = json.load(sys.stdin)
|
|
except Exception:
|
|
return
|
|
sid = data.get("session_id")
|
|
if not sid:
|
|
return
|
|
state_path = os.path.join(tempfile.gettempdir(), f"claude-economy-{sid}.json")
|
|
if not os.path.exists(state_path):
|
|
return
|
|
try:
|
|
with open(state_path, encoding="utf-8") as f:
|
|
state = json.load(f)
|
|
except Exception:
|
|
return
|
|
level = state.get("level")
|
|
if level is None or level == 100:
|
|
return
|
|
topline = LEVEL_TOPLINE.get(level)
|
|
if not topline:
|
|
return
|
|
label = state.get("label", f"{level}%")
|
|
tail = state.get("tail", "")
|
|
set_at = state.get("set_at", "unknown time")
|
|
msg = (
|
|
f"=== POST-COMPACTION RE-INJECT ===\n"
|
|
f"Active economy mode: {label} — {tail}\n"
|
|
f"(originally set at: {set_at})\n\n"
|
|
f"Rules summary: {topline}\n\n"
|
|
f"Full rules — re-read state file or check economy-mode.py LEVELS[{level}]['rules']."
|
|
)
|
|
out = {
|
|
"hookSpecificOutput": {
|
|
"hookEventName": "PostCompact",
|
|
"additionalContext": msg,
|
|
}
|
|
}
|
|
sys.stdout.write(json.dumps(out, ensure_ascii=True))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|