hookedge

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package hookedge is the CLI wire edge: decode/encode provider hooks via agenthooks and forward Invoke to the local daemon.

Owns: provider wire decode/encode, single gRPC Invoke forward, policy.offline when the daemon is unreachable. Must not: full Decide / guards / route compile (daemon dispatch + targets/builtin).

Invariants:

  • Never log to stdout on the hook path.
  • Preserve Event.Raw verbatim.
  • Unreachable daemon → config.OfflineFor; fail_open encodes Neutral / exit 0.

Entry: Run, Notify, Serve. See DESIGN.md §1.5 (invoke_sync).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Notify

func Notify(ctx context.Context, opts Options) int

Notify handles Codex notify-style hooks (argv JSON). Always async semantics on the daemon. Prints no provider decision wire; exit 0 on success.

func ResolveCWD

func ResolveCWD(payload []byte) string

ResolveCWD picks cwd from hook JSON: cwd, then workspace_roots[0], then os.Getwd().

func Run

func Run(ctx context.Context, opts Options) int

Run dials the daemon, invokes HookService, then encodes the decision wire response. Returns a process exit code (0 success, 1 failure). Never writes debug logs to stdout.

func Serve

func Serve(ctx context.Context, opts Options) int

Serve runs the long-lived OpenCode NDJSON bridge: each frame → daemon Invoke → wire reply. Never writes debug logs to stdout.

Types

type Options

type Options struct {
	Socket      string
	ConfigPath  string
	Provider    string
	ArgvPayload bool
	Timeout     time.Duration
	PayloadArg  string
	Stdin       io.Reader
	Stdout      io.Writer
	Stderr      io.Writer
}

Options configures hookedge Run, Notify, and Serve.

Jump to

Keyboard shortcuts

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