hooks

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package hooks provides integration with AI coding assistants via assistantkit.

This package defines api-style-spec hooks that can be exported to multiple AI assistant formats (Claude Code, Kiro, Cursor, Windsurf, etc.).

Example hooks:

  • AfterFileWrite: Auto-lint OpenAPI specs when saved
  • BeforePrompt: Inject API style context when working on APIs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPaths

func DefaultPaths() map[string]string

DefaultPaths returns the default output paths for each supported format.

func EventSupport

func EventSupport() map[string][]core.Event

EventSupport returns which events are supported by which tools.

func FindGitDir added in v0.2.0

func FindGitDir() (string, error)

FindGitDir searches for the .git directory starting from the current directory.

func GeneratePreCommitScript added in v0.2.0

func GeneratePreCommitScript(opts *PreCommitOptions) (string, error)

GeneratePreCommitScript generates the pre-commit hook script.

func InstallPreCommit added in v0.2.0

func InstallPreCommit(opts *InstallOptions) error

InstallPreCommit installs the pre-commit hook in the git repository.

func SupportedFormats

func SupportedFormats() []string

SupportedFormats returns the list of supported output formats.

func UninstallPreCommit added in v0.2.0

func UninstallPreCommit() error

UninstallPreCommit removes the pre-commit hook if it was installed by api-style.

Types

type Config

type Config struct {
	// Profile is the style profile to use for linting.
	Profile string

	// AutoLint enables automatic linting on file save.
	AutoLint bool

	// AutoLintPatterns are glob patterns for files to auto-lint.
	// Defaults to common OpenAPI patterns if empty.
	AutoLintPatterns []string

	// InjectContext enables injecting style context before prompts.
	InjectContext bool
}

Config represents the api-style-spec hooks configuration.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default hooks configuration.

func (*Config) Generate

func (c *Config) Generate() *hooks.Config

Generate creates an assistantkit hooks.Config from the api-style-spec configuration.

func (*Config) MarshalFormat

func (c *Config) MarshalFormat(format string) ([]byte, error)

MarshalFormat converts the configuration to a specific format.

func (*Config) WriteToFile

func (c *Config) WriteToFile(path, format string) error

WriteToFile writes the hooks configuration to a file in the specified format.

type InstallOptions added in v0.2.0

type InstallOptions struct {
	// PreCommitOptions configures the hook behavior.
	*PreCommitOptions

	// Force overwrites an existing hook.
	Force bool

	// GitDir is the path to the .git directory.
	// If empty, FindGitDir is used to locate it.
	GitDir string
}

InstallOptions configures pre-commit hook installation.

func DefaultInstallOptions added in v0.2.0

func DefaultInstallOptions() *InstallOptions

DefaultInstallOptions returns default installation options.

type PreCommitOptions added in v0.2.0

type PreCommitOptions struct {
	// Profile is the style profile to use for linting.
	Profile string

	// Level is the conformance level to enforce.
	Level string

	// FailOnWarnings causes the hook to fail on warnings, not just errors.
	FailOnWarnings bool
}

PreCommitOptions configures the pre-commit hook.

func DefaultPreCommitOptions added in v0.2.0

func DefaultPreCommitOptions() *PreCommitOptions

DefaultPreCommitOptions returns default pre-commit options.

Jump to

Keyboard shortcuts

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