windsurf

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 5 Imported by: 0

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

View Source
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

func ReadUserConfig() (*core.Config, error)

ReadUserConfig reads the user-level ~/.codeium/windsurf/hooks.json.

func ReadWorkspaceConfig

func ReadWorkspaceConfig() (*core.Config, error)

ReadWorkspaceConfig reads the workspace .windsurf/hooks.json.

func UserConfigPath

func UserConfigPath() (string, error)

UserConfigPath returns the user hooks config path.

func WorkspaceConfigPath

func WorkspaceConfigPath() string

WorkspaceConfigPath returns the workspace hooks config path.

func WriteWorkspaceConfig

func WriteWorkspaceConfig(cfg *core.Config) error

WriteWorkspaceConfig writes to the workspace .windsurf/hooks.json.

Types

type Adapter

type Adapter struct{}

Adapter implements core.Adapter for Windsurf hooks.

func NewAdapter

func NewAdapter() *Adapter

NewAdapter creates a new Windsurf hooks adapter.

func (*Adapter) DefaultPaths

func (a *Adapter) DefaultPaths() []string

DefaultPaths returns the default config file paths for Windsurf hooks.

func (*Adapter) FromCore

func (a *Adapter) FromCore(cfg *core.Config) *Config

FromCore converts canonical config to Windsurf format.

func (*Adapter) Marshal

func (a *Adapter) Marshal(cfg *core.Config) ([]byte, error)

Marshal converts canonical config to Windsurf format.

func (*Adapter) Name

func (a *Adapter) Name() string

Name returns the adapter name.

func (*Adapter) Parse

func (a *Adapter) Parse(data []byte) (*core.Config, error)

Parse parses Windsurf hooks config data into the canonical format.

func (*Adapter) ReadFile

func (a *Adapter) ReadFile(path string) (*core.Config, error)

ReadFile reads a Windsurf hooks config file.

func (*Adapter) SupportedEvents

func (a *Adapter) SupportedEvents() []core.Event

SupportedEvents returns the events supported by Windsurf.

func (*Adapter) ToCore

func (a *Adapter) ToCore(windsurfCfg *Config) *core.Config

ToCore converts Windsurf hooks config to canonical format.

func (*Adapter) WriteFile

func (a *Adapter) WriteFile(cfg *core.Config, path string) error

WriteFile writes canonical config to a Windsurf format file.

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.

func NewConfig

func NewConfig() *Config

NewConfig creates a new empty Windsurf hooks config.

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"
)

Jump to

Keyboard shortcuts

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