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 ¶
- Variables
- func ConsumeOnboardPending(vaultRoot string) bool
- func InstallMCP(projectDir, vaultAbs, binPath string) (bool, string, error)
- func RegisterMCP(client, projectDir, vaultAbs, binPath string) (bool, string, error)
- func SetOnboardPending(vaultRoot string) error
- func Uninstall(projectDir string) (int, string, error)
- type Options
- type Result
- type Status
Constants ¶
This section is empty.
Variables ¶
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 ¶
ConsumeOnboardPending returns true at most once (clearing the marker), so the welcome fires on exactly the first session after install.
func InstallMCP ¶
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 ¶
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 ¶
SetOnboardPending arms a one-time welcome: the next SessionStart orient prepends an onboarding instruction so the agent greets the user and finishes setup itself.
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.