Documentation
¶
Overview ¶
Package hooksetup writes the files the coding agents call the runtime through: the port file, the status hook and status line scripts Claude Code runs, the Codex hook script, the `--settings` file with the hooks, the MCP config, the prompt editor Claude gets as VISUAL, and the Codex launcher. Running agents keep the paths and scripts they were started with, so the file names and the scripts' curl contract stay as they were; what names the product (the data folder as scripts spell it, header names, the MCP server, the editor) comes from Config.
Index ¶
- Constants
- type Config
- type Prompts
- type Result
- type Writer
- func (w *Writer) CodexHookPath() string
- func (w *Writer) CodexLauncher() (string, error)
- func (w *Writer) EditorEnv(path string) string
- func (w *Writer) EditorPath() string
- func (w *Writer) Ensure(port int, token string) (Result, error)
- func (w *Writer) EnsureEditor() (string, error)
- func (w *Writer) EnsureToken() (string, error)
- func (w *Writer) HandoffDir() string
- func (w *Writer) HookSettings() []byte
- func (w *Writer) HooksPath() string
- func (w *Writer) LauncherPath() string
- func (w *Writer) MCPConfigPath() string
- func (w *Writer) PortPath() string
- func (w *Writer) RemovePortFile() error
- func (w *Writer) StatusHookPath() string
- func (w *Writer) StatuslinePath() string
- func (w *Writer) TokenPath() string
Constants ¶
const ( PortFile = "port" TokenFile = "cli-token" StatusHookFile = "status-hook.sh" StatuslineFile = "statusline.sh" CodexHookFile = "codex-hook.sh" HooksFile = "hooks.json" MCPConfigFile = "preview-mcp.json" LauncherFile = "codex-launcher.js" HandoffDir = "prompt-handoff" BinDir = "bin" )
File names in the data folder; agents started earlier hold these paths.
const WorkspaceIDPlaceholder = "{{workspaceId}}"
WorkspaceIDPlaceholder stands for the workspace's id in a prompt template.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// DataDir is the runtime's data folder (absolute).
DataDir string
// ScriptDataDir is the data folder as the scripts spell it, read by the shell at run time ("$HOME/.<name>"): the
// scripts do not follow an overridden data folder, as before.
ScriptDataDir string
// TokenHeaders carry the CLI token in the scripts' requests, the current name first.
TokenHeaders []string
// MCPServer is the runtime's MCP server name, MCPPath its route; its header is TokenHeaders[0].
MCPServer string
MCPPath string
// Allow are the permissions granted in the hook settings (the MCP server under its current and former names).
Allow []string
// EditorName is the prompt editor script's file name under bin/, EditorTitle the name its comment gives it.
EditorName string
EditorTitle string
// Editor and Handoff, when set, are the editor script's path and its hand-off folder instead of the data folder's
// bin/<EditorName> and prompt-handoff.
Editor, Handoff string
// HumanEditorVar is the variable the editor finds the person's own editor in.
HumanEditorVar string
// LegacyTmuxSocket: a pane on this server keys its hand-off file by pane id alone, on any other by socket and id.
LegacyTmuxSocket string
// Codex is what the Codex launcher script needs; nil writes none.
Codex *codex.LauncherScriptConfig
}
Config names the product's parts.
func (Config) CodexHookScript ¶
CodexHookScript is what Codex runs for every hook: the payload goes to the runtime as it is, with the tmux session.
func (Config) EditorScript ¶
EditorScript is the prompt editor Claude runs for Ctrl+G: a hand-off file the runtime left for the pane is appended to Claude's buffer, so the text counts as typed; without one the person's own editor opens.
func (Config) MCPConfig ¶
MCPConfig is the `claude --mcp-config` file: the runtime's MCP server on loopback with the token in its header.
func (Config) StatusHookScript ¶
StatusHookScript is what Claude's lifecycle hooks run (`sh <script> <event>`): it reports the event, the tmux session, a notification's type and when the hook fired, in the background, and returns at once (a hook Claude cancels on its timeout under load would leave the tab unaware of the turn).
func (Config) StatuslineScript ¶
StatuslineScript is Claude's status line command: Claude's JSON goes to the runtime, the answer is the line shown.
type Prompts ¶
Prompts are the per-workspace system prompts of the agent CLIs by provider ("claude", "codex"). Their text is the platform's own, so it comes from a file the deployment names: a JSON object of templates.
func LoadPrompts ¶
LoadPrompts reads the templates file.
type Result ¶
type Result struct {
// CodexHookFailed: the Codex hook script could not be written; Codex launches report nothing (tell the person).
CodexHookFailed bool
}
Result reports what Ensure could not write without failing the start.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer writes the files of one data folder.
func (*Writer) CodexHookPath ¶
func (*Writer) CodexLauncher ¶
CodexLauncher writes the Codex launcher script when it differs and returns its path.
func (*Writer) EditorEnv ¶
EditorEnv is the environment prefix giving Claude the prompt editor at path.
func (*Writer) EditorPath ¶
func (*Writer) Ensure ¶
Ensure writes the port file (always) and every script and settings file whose content changed, at runtime start.
func (*Writer) EnsureEditor ¶
EnsureEditor writes the prompt editor script (and its hand-off folder) once per process, replacing whatever an older release left, and returns its path; it fits claude.LaunchConfig.EditorScript. A failed write is tried again next time.
func (*Writer) EnsureToken ¶
EnsureToken is the CLI token the scripts send: the token file's, or a new random one written to it (0600).
func (*Writer) HandoffDir ¶
func (*Writer) HookSettings ¶
HookSettings is the `--settings` file Claude is launched with.
func (*Writer) LauncherPath ¶
func (*Writer) MCPConfigPath ¶
func (*Writer) RemovePortFile ¶
RemovePortFile removes the port file at shutdown, so the scripts stop calling a runtime that is gone.