Skip to main content

Module protocol

Module protocol 

Source
Expand description

Gate wire protocol — versioned, env-var-keyed.

Design: [docs/design.md §3.3, §7]. The schema version is held in the KLASP_GATE_SCHEMA environment variable exported by the generated hook script, not in the JSON stdin payload — this defends against a malicious agent that crafts a tool_input field claiming an arbitrary schema version.

Versioning is independent of klasp’s semver: most binary releases will not bump the schema. Bumping is reserved for genuine wire-format changes (renamed fields, required-field additions, exit-code semantics).

Structs§

GateInput
The Claude Code PreToolUse payload klasp consumes from stdin.
GateProtocol
ToolInput
The subset of Claude Code’s tool_input klasp inspects. Only the Bash tool’s command field matters in v0.1; future fields can be added behind #[serde(default)] without bumping the schema.

Enums§

GateError

Constants§

GATE_SCHEMA_VERSION
Wire-protocol schema version. Bump only when the JSON shape, exit-code semantics, or env-var contract changes — never for cosmetic releases.
KLASP_OUTPUT_SCHEMA
klasp gate --format json output schema version.
PLUGIN_PROTOCOL_VERSION
Plugin subprocess protocol version. Separate from GATE_SCHEMA_VERSION so plugin upgrades and gate upgrades evolve independently.