input.ts
This file
Path
apps/cli/src/hook/input.ts
27 lines · 1.0 KiB · TypeScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 878da37 point at it.
Merge build/420-release-downloads: the CLI installs from the platform itself, with no GitHub in the release pathoscabrielbefore adoption878da37
lines 1–27why, one step back1/**2 * What a harness hands a hook on stdin, in Claude Code's hook format (which3 * Cursor and Copilot CLI also read), decoded at the boundary. Only the fields4 * the hook policy reads; the rest of the payload is ignored.5 */6import { Schema } from "effect";78export const HookInput = Schema.Struct({9 /** The folder the harness runs in. */10 cwd: Schema.String,11 hook_event_name: Schema.String,12 /** The harness's session: holds and facts are kept per session. */13 session_id: Schema.NonEmptyString,14 /** Claude Code: `true` when this stop follows a Stop hook's hold. */15 stop_hook_active: Schema.optionalKey(Schema.Boolean),16 /** PreToolUse: the tool's arguments. */17 tool_input: Schema.optionalKey(Schema.Record(Schema.String, Schema.Unknown)),18 /** PreToolUse: the tool about to run. */19 tool_name: Schema.optionalKey(Schema.String),20});2122export type HookInput = typeof HookInput.Type;2324/** The whole of stdin, as JSON text, to a `HookInput`. */25export const decodeHookInput = Schema.decodeUnknownEffect(26 Schema.fromJsonString(HookInput)27);