Documentation
¶
Overview ¶
Package hooks serves the Claude Code SessionStart and UserPromptSubmit hook endpoints and installs/removes their entries in a settings.json. Both handlers authenticate the same static bearer key as MCP, and both fail open: any internal error yields a 200 with empty additionalContext so a broken briefing can never block an agent. Only a bad key returns non-2xx (401).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommandHookEndpoints ¶
CommandHookEndpoints returns the `seam hook <arg>` events the installer wires as command hooks, each mapped to the endpoint that hook must forward to.
It exists for the seam CLI's test. The CLI keeps its own copy of this mapping -- it cannot import this package without dragging the store, the retriever, and SQLite into a binary whose job is one HTTP POST -- and a hook fails open by contract, so drift between the two copies is a silent no-op rather than an error: install-hooks would write a command line the CLI rejects, or forward to a route that is not there, and the only symptom would be a briefing that stopped arriving.
func InstalledEvents ¶
func InstalledEvents() []string
InstalledEvents is the set of hook events Seamless installs, in install order. A caller (doctor) compares InstalledStatus against len(InstalledEvents).
func InstalledStatus ¶
InstalledStatus reports which Seamless-managed hook events are present in the settings.json at path, using the same ownership test as Install: the managed marker, or an unmarked entry that targets the hook's URL under baseURL or runs `... hook <event>` via the seam CLI. The marker alone cannot be trusted: Claude Code re-serializes settings.json through its own schema when the owner edits config or permissions, dropping the seamless_managed key while keeping the functional entries -- those still-firing hooks must count as installed. A missing or empty file yields an empty slice and no error. The result is a subset of InstalledEvents(), in install order.
Types ¶
type Config ¶
type Config struct {
DB *sql.DB
Retrieve *retrieve.Service
Events *events.Recorder
Files *files.Manager
APIKey string
MaxEventChars int
PlanCapture config.PlanCapture
PlansDir string
Logger *slog.Logger
}
Config carries the Handler's dependencies. DB backs ambient sessions and the session-end harvest; Events may be nil (injection telemetry is then skipped); Files may be nil (plan/subagent capture is then skipped). MaxEventChars caps captured prompt/findings text (0 = unlimited); injected content is always stored in full (it is already bounded by the briefing/recall budgets upstream). PlansDir is where Claude Code writes plan-mode files; empty defaults to ~/.claude/plans (tests override it).
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the hook endpoints.
type InstallOptions ¶
type InstallOptions struct {
SettingsPath string // target settings.json (created if absent)
BaseURL string // e.g. http://127.0.0.1:8081
APIKey string // static bearer key written into the Authorization header
SeamBin string // path to the seam CLI for command hooks; "" => "seam" (PATH)
ConfigPath string // abs seamless.yaml passed to command hooks as `--config` so they resolve config from any cwd; "" omits it
}
InstallOptions configures an install.
type InstallResult ¶
type InstallResult struct {
Changed bool
BackupPath string // "" when no backup was written
Actions []string // per-hook: "SessionStart: added|updated|unchanged"
}
InstallResult reports what an install did.
func Install ¶
func Install(opts InstallOptions) (InstallResult, error)
Install merges the Seamless hook entries into the settings.json at opts.SettingsPath, preserving unknown keys, replacing any existing Seamless-managed entries in place, and backing the file up once before the first change. It is idempotent: an already-current file is left untouched.