install

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 16 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefinitionHash

func DefinitionHash(event, matcher, command string, timeoutSeconds int) string

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

func Fingerprint(m Manifest, t Target) (string, error)

Fingerprint hashes the rendered configuration — the idempotence key for "re-install only when the manifest changed" flows.

func Install

func Install(ctx context.Context, m Manifest, t Target, opts ...InstallOption) error

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.

func Render

func Render(m Manifest, t Target) (fs.FS, error)

Render produces the provider configuration as an in-memory filesystem with target-relative paths. Kinds a provider cannot subscribe to (see the mapping table, §3.4) are skipped; model.request/model.response are excluded from generation by design (§12.3).

Types

type Change

type Change struct {
	Path  string
	State ChangeState
}

Change is one file-level difference between the rendered config and disk.

func Diff

func Diff(m Manifest, t Target) ([]Change, error)

Diff reports what Install would do, without writing.

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

type Identity struct {
	Name        string
	Version     string
	Description string
}

Identity is the plugin name/version/description for plugin-based installs and for Gemini's /hooks enable|disable UX.

type InstallOption

type InstallOption func(*installCfg)

InstallOption configures Install.

func WithDryRun

func WithDryRun() InstallOption

WithDryRun plans without writing.

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 Scope

type Scope string

Scope selects where the configuration lands.

const (
	ScopeUser    Scope = "user"    // provider's user-level config dir
	ScopeProject Scope = "project" // repo-relative config
	ScopePlugin  Scope = "plugin"  // plugin-based install (Claude Code)
)

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL