Skip to content
Apothem
Referensi

Hook

Penangan event alat yang terpicu pada SessionStart, PreToolUse, dan Stop, memuat konteks pesan yang menegakkan isolasi git dan disiplin rencana.

Hook terpicu pada event alat dan memuat konteks pesan yang diperlakukan asisten sebagai prompt sistem tambahan. Pengabelan berada di blok hook settings.json Claude Code, file hook hooks.json Codex, dan peta hook settings.json Qwen Code.

EventTimeoutTujuan
SessionStart30 detikBaca memori, periksa status rencana, laporkan kesiapan
PreCompact30 detikVerifikasi status telah dieksternalisasi sebelum pemadatan
PostCompact30 detikPulihkan status kerja setelah pemadatan
Stop60 detikEksternalisasi di akhir sesi
PreToolUse (Bash)10 detikValidasi Bash — isolasi artefak git
PreToolUse (Write/Edit/NotebookEdit/apply_patch)10 detikIsolasi referensi rencana, pemeriksaan frontmatter

Dispatcher

Entri hook yang terpasang memanggil dispatcher melalui jalur skrip absolut. Template pengaturan membawa token ${HARNESS_ROOT}python "${HARNESS_ROOT}/apothem/hooks/dispatch.py" <event> [<message-name>] — yang dirender oleh pemasang menjadi jalur asli root harness pada saat pemasangan (Claude Code dan Qwen Code mematerialkan dispatcher di bawah <harness-root>/apothem/hooks/; Codex di bawah <harness-root>/hooks/). Dispatcher adalah skrip pustaka standar yang mandiri: ia mem-bootstrap sys.path-nya sendiri, sehingga tidak diperlukan paket apothem yang dapat diimpor pada host. Dari sebuah checkout sumber, bentuk modul python -m apothem.hooks.dispatch <event> (dengan PYTHONPATH=src) menjalankan kode yang sama untuk pengembangan. Dispatcher memuat hooks/lib/resolve_root.py untuk resolusi root ekosistem dan mendelegasikan ke hooks/emit_hook_context.py dan hooks/session_start_bootstrap.py.

Konteks pesan

Konteks Markdown per-event berada di bawah src/apothem/hooks/messages/:

  • postcompact.md, precompact.md, stop.md
  • pretooluse-bash.md, pretooluse-write.md, pretooluse-edit.md, pretooluse-notebookedit.md

Setiap file konteks dimuat oleh dispatcher ketika event-nya terpicu dan argumen konteksnya terdaftar dalam file pengaturan.

Inventaris Pesan Hook yang Dihasilkan

NameDescriptionSource
postcompactPost-compaction Blind Bootstrap (CM-24 §6.2). Restore working state from durable files; conversation context is now compressed.src/apothem/hooks/messages/postcompact.md
posttooluse-proactive-compactionProactive-compaction tracker for PostToolUse tool calls.src/apothem/hooks/messages/posttooluse-proactive-compaction.md
precompactPre-compaction protocol (CM-24 §2.3). Externalize all in-conversation state BEFORE the harness compresses context.src/apothem/hooks/messages/precompact.md
pretooluse-askuserquestion-recommendedCall-time (Recommended)-marker guard for AskUserQuestion tool calls.src/apothem/hooks/messages/pretooluse-askuserquestion-recommended.md
pretooluse-bash-plan-guardPlans-Discipline write guard for Bash tool calls (companion to pretooluse-write-plan-guard.md).src/apothem/hooks/messages/pretooluse-bash-plan-guard.md
pretooluse-bashCM-7 git-artifact isolation + M12 numeric-prefix discipline + M15 human-only authorship.src/apothem/hooks/messages/pretooluse-bash.md
pretooluse-conformity> Advisory: this hook reports; it does not block. Mechanical enforcement runs in CI.src/apothem/hooks/messages/pretooluse-conformity.md
pretooluse-dependency-guardDependency-manifest supply-chain guard (advisory).src/apothem/hooks/messages/pretooluse-dependency-guard.md
pretooluse-edit-header-guardSPDX-header inject guard for Edit tool calls.src/apothem/hooks/messages/pretooluse-edit-header-guard.md
pretooluse-editCodebase isolation (Edit scope).src/apothem/hooks/messages/pretooluse-edit.md
pretooluse-eval-guardDynamic-eval / unsafe-deserialization guard — advisory prompt-injection defense.src/apothem/hooks/messages/pretooluse-eval-guard.md
pretooluse-notebookeditCodebase isolation (notebook scope).src/apothem/hooks/messages/pretooluse-notebookedit.md
pretooluse-write-header-guardSPDX-header inject guard for Write tool calls.src/apothem/hooks/messages/pretooluse-write-header-guard.md
pretooluse-write-plan-guardPlans-Discipline write guard for Write / Edit / NotebookEdit tool calls.src/apothem/hooks/messages/pretooluse-write-plan-guard.md
pretooluse-writeCodebase isolation + frontmatter compliance.src/apothem/hooks/messages/pretooluse-write.md
sessionstartSession-start conformity posture.src/apothem/hooks/messages/sessionstart.md
stopSession-end protocol (CM-14 + CM-24 §2.5 + CM-26 + CM-22 §2/§4).src/apothem/hooks/messages/stop.md

On this page