Documentation
¶
Overview ¶
Package windsurf provides an adapter for Windsurf (Codeium) hooks configuration.
Windsurf hooks are configured in hooks.json files:
- Workspace: .windsurf/hooks.json
- User: ~/.codeium/windsurf/hooks.json
- System: /Library/Application Support/Windsurf/hooks.json (macOS)
Windsurf hook events:
- pre_read_code: Before file reads (can block)
- post_read_code: After successful reads
- pre_write_code: Before code modifications (can block)
- post_write_code: After code changes
- pre_run_command: Before terminal execution (can block)
- post_run_command: After command completion
- pre_mcp_tool_use: Before MCP invocation (can block)
- post_mcp_tool_use: After MCP success
- pre_user_prompt: Before prompt processing (can block)
Index ¶
- Constants
- func ReadUserConfig() (*core.Config, error)
- func ReadWorkspaceConfig() (*core.Config, error)
- func UserConfigPath() (string, error)
- func WorkspaceConfigPath() string
- func WriteWorkspaceConfig(cfg *core.Config) error
- type Adapter
- func (a *Adapter) DefaultPaths() []string
- func (a *Adapter) FromCore(cfg *core.Config) *Config
- func (a *Adapter) Marshal(cfg *core.Config) ([]byte, error)
- func (a *Adapter) Name() string
- func (a *Adapter) Parse(data []byte) (*core.Config, error)
- func (a *Adapter) ReadFile(path string) (*core.Config, error)
- func (a *Adapter) SupportedEvents() []core.Event
- func (a *Adapter) ToCore(windsurfCfg *Config) *core.Config
- func (a *Adapter) WriteFile(cfg *core.Config, path string) error
- type Config
- type Hook
- type WindsurfEvent
Constants ¶
const ( // AdapterName is the identifier for this adapter. AdapterName = "windsurf" // ConfigFileName is the hooks config file name. ConfigFileName = "hooks.json" // UserConfigDir is the user config directory relative to home. UserConfigDir = ".codeium/windsurf" // WorkspaceConfigDir is the workspace config directory. WorkspaceConfigDir = ".windsurf" )
Variables ¶
This section is empty.
Functions ¶
func ReadUserConfig ¶
ReadUserConfig reads the user-level ~/.codeium/windsurf/hooks.json.
func ReadWorkspaceConfig ¶
ReadWorkspaceConfig reads the workspace .windsurf/hooks.json.
func UserConfigPath ¶
UserConfigPath returns the user hooks config path.
func WorkspaceConfigPath ¶
func WorkspaceConfigPath() string
WorkspaceConfigPath returns the workspace hooks config path.
func WriteWorkspaceConfig ¶
WriteWorkspaceConfig writes to the workspace .windsurf/hooks.json.
Types ¶
type Adapter ¶
type Adapter struct{}
Adapter implements core.Adapter for Windsurf hooks.
func (*Adapter) DefaultPaths ¶
DefaultPaths returns the default config file paths for Windsurf hooks.
func (*Adapter) SupportedEvents ¶
SupportedEvents returns the events supported by Windsurf.
type Config ¶
type Config struct {
// Hooks maps event names to hook definitions.
Hooks map[WindsurfEvent][]Hook `json:"hooks"`
}
Config represents Windsurf's hooks.json configuration.
type Hook ¶
type Hook struct {
// Command is the shell command to execute.
Command string `json:"command"`
// ShowOutput displays hook output in the Cascade UI.
ShowOutput bool `json:"show_output,omitempty"`
// WorkingDirectory is the execution directory (defaults to workspace root).
WorkingDirectory string `json:"working_directory,omitempty"`
}
Hook represents a single Windsurf hook definition.
type WindsurfEvent ¶
type WindsurfEvent string
WindsurfEvent represents Windsurf-specific hook event names.
const ( PreReadCode WindsurfEvent = "pre_read_code" PostReadCode WindsurfEvent = "post_read_code" PreWriteCode WindsurfEvent = "pre_write_code" PostWriteCode WindsurfEvent = "post_write_code" PreRunCommand WindsurfEvent = "pre_run_command" PostRunCommand WindsurfEvent = "post_run_command" PreMCPToolUse WindsurfEvent = "pre_mcp_tool_use" PostMCPToolUse WindsurfEvent = "post_mcp_tool_use" PreUserPrompt WindsurfEvent = "pre_user_prompt" )