Documentation
¶
Overview ¶
Package install renders and installs provider hook configurations from a single Go Manifest: correct hooks.json / settings.json / config.toml / plugin scaffolding per provider, with the per-provider timing/async/ fail-mode workarounds baked in (DESIGN.md §7).
Index ¶
- func DefinitionHash(event, matcher, command string, timeoutSeconds int) string
- func Fingerprint(m Manifest, t Target) (string, error)
- func Install(ctx context.Context, m Manifest, t Target, opts ...InstallOption) error
- func Render(m Manifest, t Target) (fs.FS, error)
- type Change
- type ChangeState
- type HookSpec
- type Identity
- type InstallOption
- type Manifest
- type Scope
- type Target
- type ToolMatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefinitionHash ¶
DefinitionHash reimplements Codex's hook definition fingerprint so installs can pre-seed trusted hashes (quirk #9). Codex hashes a normalized identity rather than source text (codex-rs hooks/engine/discovery.rs command_hook_hash + config/fingerprint.rs version_for_toml): sha256 over the compact, recursively key-sorted JSON of
{"event_name": <label>, "matcher": <m>?, "hooks": [
{"async": false, "command": <cmd>, "timeout": <secs>, "type": "command"}]}
prefixed "sha256:". The matcher is included only when present in the rendered config and never for UserPromptSubmit/Stop (Codex forces it absent there); an absent timeout defaults to 600 and is clamped to >= 1. Verified against codex-cli 0.142.4 trust state.
func Fingerprint ¶
Fingerprint hashes the rendered configuration — the idempotence key for "re-install only when the manifest changed" flows.
func Install ¶
Install renders the manifest and writes it under t.Dir, idempotently: unchanged files are skipped, and JSON settings files are merged so agenthooks-managed entries are replaced while foreign entries survive.
Types ¶
type Change ¶
type Change struct {
Path string
State ChangeState
}
Change is one file-level difference between the rendered config and disk.
type ChangeState ¶
type ChangeState string
ChangeState classifies one file in a Diff.
const ( StateCreate ChangeState = "create" StateUpdate ChangeState = "update" StateUnchanged ChangeState = "unchanged" )
type HookSpec ¶
type HookSpec struct {
Kind agenthooks.EventKind
Tools ToolMatcher
Blocking bool // decision path vs telemetry path
Timeout time.Duration
}
HookSpec subscribes one unified event kind.
type Identity ¶
Identity is the plugin name/version/description for plugin-based installs and for Gemini's /hooks enable|disable UX.
type Manifest ¶
type Manifest struct {
Command []string // how to invoke the consumer binary (abs path or PATH lookup)
Hooks []HookSpec
Identity Identity
// Fail drives fail-mode workarounds in generated config (e.g. Cursor's
// failClosed flag, quirk #7). Match the Policy your Runner uses.
Fail agenthooks.FailMode
}
Manifest is the single source from which every provider config is generated.
type Target ¶
type Target struct {
Provider agenthooks.Provider
Scope Scope
Dir string
}
Target names a provider plus scope; Dir is the filesystem root Install writes under (ignored by Render, which returns a relative fs.FS).
type ToolMatcher ¶
type ToolMatcher = agenthooks.ToolMatcher
ToolMatcher aliases the unified matcher (compiled to provider dialects where expressible, enforced in-process via --filter where not).