Help us shape the future of Go! Take the 2026 Go Developer Survey

shellhook

package
v0.0.0-...-c703685 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Source: internal/router/app_server_guard_hook.go:64:137@[2ba2151a] effective-hook validation.

Source: internal/vcsguard/hook.go:18:106@[2ba2151a] native hook protocol.

Index

Constants

View Source
const DefaultCompactPrompt = `` /* 426-byte string literal not displayed */

Source: codex-rs/prompts/templates/compact/prompt.md:1:10@0df4aa677. DefaultCompactPrompt is the stock plaintext handover prompt, pinned for launch.

View Source
const Environment = "MEKUGI_VCS_GUARD_HOOK"
View Source
const Flag = "--guard-hook"
View Source
const Key = "/<session-flags>/config.toml:pre_tool_use:0:0"

Variables

This section is empty.

Functions

func Config

func Config(helper, directory, sudoDirectory, tracker string, prior Invocation, disabled []string) (config, state, identityHash string, err error)

Config uses the native session-layer hook and exact trust identity. It neither changes user files nor grants sandbox permissions.

func Rewrite

func Rewrite(request Input) (any, error)

Rewrite only instruments the command. Approval occurs in the shell's helper when the command is actually reached, never for an unexecuted branch.

func Validate

func Validate(data []byte, cwd, hash string) error

Types

type Input

type Input struct {
	Helper        string `json:"helper"`
	Directory     string `json:"directory"`
	SudoDirectory string `json:"sudo_directory"`
	Tracker       string `json:"tracker"`
	Event         string `json:"hook_event_name"`
	Tool          string `json:"tool_name"`
	Item          string `json:"tool_use_id"`
	Input         struct {
		Command *string `json:"command"`
	} `json:"tool_input"`
}

Input binds session resources in the trusted hook configuration. The remaining fields are expanded from Codex's native hook event, not router cwd.

type Invocation

type Invocation struct {
	CompactPrompt string                    `json:"-"`
	PreToolUse    []jsontext.Value          `json:"PreToolUse"`
	State         map[string]jsontext.Value `json:"state"`
}

Invocation retains the selected compaction prompt and only the host-resolved sessionFlags hook layer. Copying merged hooks would duplicate other layers.

func Discover

func Discover(ctx context.Context, command *exec.Cmd) (Invocation, []string, error)

Discover starts no thread or turn. The process resolves caller configuration and is joined before the caller starts its final, guarded invocation.

func DiscoverCompact

func DiscoverCompact(ctx context.Context, command *exec.Cmd) (Invocation, error)

Jump to

Keyboard shortcuts

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