hooks

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package hooks installs the Claude Code SESSION hooks that make an agent use Mesh automatically: read the mesh at session start, and get nudged to write back what it learned before finishing. Shared by the `mesh hooks` CLI and the mesh_setup_hooks MCP onboarding tool so both write the exact same config.

These are Claude Code session-lifecycle hooks (.claude/settings.json), NOT git pre/post-push hooks. SessionStart injects an orientation; Stop nudges write-back once per session. SessionEnd cannot enforce anything (cleanup only), so Stop is the enforcement point.

Index

Constants

This section is empty.

Variables

View Source
var Clients = []string{"claude-code", "claude-desktop", "cursor", "vscode", "windsurf", "codex"}

Clients lists the agent clients mesh install can register the MCP server for. claude-code is the only one that also supports session hooks (auto-onboard); the rest get the MCP tools + the server's instructions nudge.

Functions

func ConsumeOnboardPending

func ConsumeOnboardPending(vaultRoot string) bool

ConsumeOnboardPending returns true at most once (clearing the marker), so the welcome fires on exactly the first session after install.

func InstallMCP

func InstallMCP(projectDir, vaultAbs, binPath string) (bool, string, error)

InstallMCP registers the Mesh MCP server in the project's .mcp.json so the agent gets the mesh-* tools without any manual config. Idempotent; preserves other servers. Returns whether it added the entry.

func RegisterMCP

func RegisterMCP(client, projectDir, vaultAbs, binPath string) (bool, string, error)

RegisterMCP registers the Mesh MCP server in the given client's config, in that client's own format and location. Idempotent; preserves other servers.

func SetOnboardPending

func SetOnboardPending(vaultRoot string) error

SetOnboardPending arms a one-time welcome: the next SessionStart orient prepends an onboarding instruction so the agent greets the user and finishes setup itself.

func Uninstall

func Uninstall(projectDir string) (int, string, error)

Uninstall removes the Mesh hook entries, leaving the rest of the settings intact.

Types

type Options

type Options struct {
	ProjectDir       string // project whose .claude/settings.json to edit
	Vault            string // absolute vault path the agent should orient from
	Bin              string // absolute mesh binary path the hooks invoke
	EnforceWriteback bool   // also add the Stop write-back nudge
	AutoExtract      bool   // Stop hook also auto-extracts candidates when the agent did not write back (spawns the BYOAI LLM per such session)
	DryRun           bool   // do not write; return the would-be settings in Preview
}

Options controls an install.

type Result

type Result struct {
	SettingsPath string   `json:"settings_path"`
	Added        []string `json:"added"`
	Preview      string   `json:"preview,omitempty"` // set on DryRun
}

Result describes what an install did.

func Install

func Install(o Options) (Result, error)

Install merges the Mesh session hooks into the project's .claude/settings.json, preserving any existing settings/hooks. Idempotent.

type Status

type Status struct {
	SettingsPath string `json:"settings_path"`
	Installed    bool   `json:"installed"`
	ReadHook     bool   `json:"read_hook"`
	WriteHook    bool   `json:"write_hook"`
}

Status reports whether the hooks are present in a project.

func GetStatus

func GetStatus(projectDir string) (Status, error)

GetStatus reports whether the hooks are installed in a project.

Jump to

Keyboard shortcuts

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