hookconfig

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OvergentMCPTools = []string{
	"mcp__overgent__acknowledge_context",
	"mcp__overgent__begin_work",
	"mcp__overgent__check_coordination",
	"mcp__overgent__finish_work",
	"mcp__overgent__get_resolutions",
	"mcp__overgent__report_checkpoint",
	"mcp__overgent__report_event",
	"mcp__overgent__update_intent",
}

OvergentMCPTools are the coordination tools `overgent mcp` registers, in the permission form Claude Code matches. The MCP server is the source of truth for this list; a test there asserts the two agree, so adding a tool without pre-approving it fails in CI rather than at a member's keyboard.

Functions

func Abandoned

func Abandoned(currentConfigRoot, previousProfile, previousExecutable string) bool

Abandoned reports whether a managed binding owned by previousProfile can be adopted onto currentConfigRoot without asking the member first.

The question this answers is not "is it ours" - every binding this package recognizes is ours - but "is anything still using it". A binding nothing can still be using is not a decision, it is a leftover, and presenting it as a decision is what stranded members behind a Reconnect button that named the same profile on both sides of the arrow.

It is deliberately conservative: an unrecognized previous executable, or a profile that still exists and still holds an enrolled device, is left for an explicit reconnect. False here costs a confirmation; true here silently moves a binding that another live profile depends on.

func AllowTools

func AllowTools(path string, tools []string) error

AllowTools pre-approves exactly Overgent's own coordination tools in the settings file this package already manages.

A member who has just run `setup claude` is then asked to approve begin_work, check_coordination, report_checkpoint and finish_work one at a time, which is four interruptions from the coordination layer before any work happens — and a coordination harness that interrupts more than it prevents is worse than none. These tools publish bounded intent and read back a brief; they do not edit files, run commands, or reach outside the Project.

The grant is deliberately narrow. Only the exact tool names above are added, never a wildcard and never another server's tools, entries a member already wrote are preserved, and `Remove` withdraws exactly what was granted.

func Command

func Command(executable, configRoot, vendor string) (string, error)

Command builds the managed hook command for a vendor.

Cursor is accepted here because it invokes the same executable through the same `agent-hook --vendor` entry point, but it is NOT accepted by this package's file operations: Cursor's configuration is a different document (`.cursor/hooks.json`, a versioned object keyed by camelCase event name with its own per-handler fields) rather than the Claude/Codex settings shape these functions read and write. internal/cursorsetup owns that file and appends the `--event` argument each Cursor hook needs, because two of Cursor's events name themselves nowhere in their payload.

func DisallowTools

func DisallowTools(path string, tools []string) error

DisallowTools withdraws exactly the entries AllowTools granted, leaving every other permission a member configured untouched.

func Install

func Install(path, command string) error

Install structurally adds Overgent's exact managed hooks while preserving all unrelated settings and hooks. The command is intentionally a fixed string assembled from application-owned absolute paths, never user input.

func ParseManagedCommand

func ParseManagedCommand(command string) (executable, configRoot string, ok bool)

ParseManagedCommand splits a managed Overgent hook command into the executable it runs and the Overgent profile it is bound to. A portable command names no profile, so it reports an empty config root.

It fails closed. Anything that is not exactly the shape Command and PortableCommand write is not ours to interpret, and every caller treats ok=false as "leave this alone".

func ParseManagedPrefix added in v0.1.1

func ParseManagedPrefix(prefix string) (executable, configRoot string, ok bool)

ParseManagedPrefix splits the executable and profile out of the head of a managed hook command - everything before ` agent-hook --vendor <vendor>`. An empty configRoot means the portable form, which names no profile.

internal/cursorsetup needs this because Cursor's commands carry an extra `--event` argument and so cannot be handed to ParseManagedCommand whole. It is exported rather than duplicated so that both vendors accept exactly the same quoting forms; a second copy is how one of them silently stops recognizing its own bindings on a platform nobody re-read it for.

func PortableCommand

func PortableCommand(vendor string) (string, error)

func Rebind

func Rebind(path, command string) error

Rebind replaces only structurally recognized Overgent hooks for this vendor. Unrelated hook groups and handlers are preserved byte-semantically through JSON decoding/re-encoding, and unknown managed-looking commands fail closed.

func Remove

func Remove(path, command string) error

func ReplaceFile added in v0.1.1

func ReplaceFile(staged, destination string) error

ReplaceFile atomically activates a staged file in the same directory.

func Status

func Status(path, command string) (bool, error)

Types

type BindingState

type BindingState string
const (
	BindingNotConfigured BindingState = "not_configured"
	BindingCurrent       BindingState = "current"
	BindingPartial       BindingState = "partial"
	BindingOtherProfile  BindingState = "other_profile"
)

type Inspection

type Inspection struct {
	State           BindingState
	ExistingCommand string
}

func Inspect

func Inspect(path, command string) (Inspection, error)

Inspect distinguishes a complete current binding from a partial install and from a structurally valid Overgent binding owned by another local profile. Unknown or conflicting managed-looking commands fail closed.

Jump to

Keyboard shortcuts

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