Files
tanweai__pua/hooks/hooks.json
T
xxnbyy 7c217b80b0 fix(security): address issues #97-100 — hooks consent, sanitize, loop escape, privacy disclosure
## Issue #97 — Hooks fire without user consent
- PreCompact hook now checks for PUA activation markers before writing files
- Stop feedback hook skips if PUA was never triggered this session

## Issue #98 — Session sanitization incomplete
- Sanitize script upgraded; rate limiting migration added (0003_feedback_rate_limiting.sql)

## Issue #99 — PUA Loop no in-session escape
- Default max iterations changed from unlimited to 30
- Added <loop-abort> (terminate) and <loop-pause> (pause for manual intervention) signals
- Loop hook supports active:false for pause state; session self-binding on resume
- Added /cancel-pua-loop command; guide.html and README updated
- PUA pressure escalation injected per iteration via system message

## Issue #100 — Upload endpoint undisclosed PII
- Privacy/data-usage disclosure added to contribute.html (ZH+EN bilingual)
- Contribute.tsx updated with same disclosure

## Additional fixes
- Rename commands/loop.md → commands/pua-loop.md; add cancel-pua-loop.md
- Replace "Ralph Loop × PUA" with "PUA Loop" across all user-facing docs
- Fix nav active-state highlighting on all sub-pages
- Fix logout button (GET method); redirect to /contribute.html
- Add JA language support to leaderboard.html
- Add "how to find session file" guide to contribute.html
- Unify nav-r gap (1rem) across all pages

Closes #97
Closes #98
Closes #99
Closes #100
2026-03-22 18:54:58 +08:00

55 lines
2.7 KiB
JSON

{
"description": "PUA v2 hooks: PreCompact state dump, SessionStart restore + always-on, Stop feedback",
"hooks": {
"PreCompact": [
{
"matcher": "*",
"hooks": [
{
"type": "prompt",
"prompt": "[PUA v2 PreCompact — State Checkpoint]\n\nCheck FIRST: did PUA actually trigger this session? Look for ANY of these markers in your recent output:\n- [PUA生效 🔥] (Chinese skill)\n- [Auto-select: ...] or [PIP-REPORT] (English skill)\n- [PUA-REPORT] (Japanese skill)\nIf NONE of these markers appear, skip everything below and do nothing.\n\nIf PUA WAS active: Context compaction is about to happen. You MUST immediately dump your PUA v2 runtime state to ~/.pua/builder-journal.md using the Write tool BEFORE compaction erases it.\n\nWrite the following to ~/.pua/builder-journal.md (create ~/.pua/ if needed):\n\n```markdown\n# PUA v2 Builder Journal — Compaction Checkpoint\n\n## Timestamp\n{current ISO timestamp}\n\n## Runtime State\n- pressure_level: L{0-4}\n- failure_count: {number}\n- current_flavor: {flavor name}\n- pua_triggered_count: {number of [PUA生效 🔥] this session}\n\n## Active Task\n{what you were working on — 1-2 sentences}\n\n## Tried Approaches\n{list of approaches tried and their outcomes}\n\n## Excluded Possibilities\n{what has been ruled out}\n\n## Next Hypothesis\n{what you planned to try next}\n\n## Key Context\n{any critical information that would be lost in compaction — file paths, error messages, architectural decisions}\n```\n\nThis is NOT optional. Compaction without state dump = losing pressure level and failure history = cheating. The pressure doesn't reset just because context got compressed.\n\nAfter writing, output: > [PUA Checkpoint] State saved to builder-journal.md. Pressure level and failure history preserved."
}
]
}
],
"SessionStart": [
{
"matcher": "compact",
"hooks": [
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/session-restore.sh",
"timeout": 5
}
]
},
{
"matcher": "startup|resume",
"hooks": [
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/session-restore.sh",
"timeout": 5
}
]
}
],
"Stop": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/pua-loop-hook.sh"
},
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/stop-feedback.sh",
"timeout": 10
}
]
}
]
}
}