Documentation
¶
Overview ¶
Package shim is the hook shim logic shared by the caprock-hook binary and the hidden `caprock hook` fallback command. It reads a hook payload from stdin, POSTs it to the local daemon, and never fails: every error path is silent and the caller exits 0. See .ai/03-contracts.md § Hook shim.
Index ¶
Constants ¶
const CursorArg = "cursor"
CursorArg is the argument that makes the shim answer Cursor rather than Claude Code: hooks.json registers `"<shim>" cursor` (ADR-095).
const (
// DebugEnv, when set, appends diagnostics to <data_dir>/hook-debug.log.
DebugEnv = "CAPROCK_HOOK_DEBUG"
)
const GeminiArg = "gemini"
GeminiArg is the argument that makes the shim answer Gemini CLI: the settings file Caprock gives a Gemini session it starts registers `"<shim>" gemini` for SessionStart and BeforeAgent (ADR-115).
Variables ¶
This section is empty.
Functions ¶
func IsBrainArg ¶ added in v0.206.0
IsBrainArg reports whether a shim argument names an agent RunBrain answers.
func RunBrain ¶ added in v0.206.0
RunBrain is one 2nd Brain hook of an agent other than Claude Code and Cursor (ADR-115): it forwards the payload to the daemon, which answers in that agent's own reply shape or not at all, and prints the answer, or `{}` — valid JSON that asks the agent for nothing — on every other path. It never fails and never takes longer than the budget (rule 3).
func RunCursor ¶ added in v0.177.0
RunCursor is one Cursor hook invocation. Its first act is to print the neutral reply, so Cursor has its answer whatever happens next; then it forwards the payload to the daemon within the same budget as a Claude Code hook, and every failure is silent (rule 3). sessionStart is the one exception: the daemon may answer it with the 2nd Brain preamble (ADR-115), so its reply is printed once the daemon has answered, or the neutral one when it has not within the budget.
Types ¶
This section is empty.