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 ¶
- func DefaultPaths() map[string]string
- func EventSupport() map[string][]core.Event
- func FindGitDir() (string, error)
- func GeneratePreCommitScript(opts *PreCommitOptions) (string, error)
- func InstallPreCommit(opts *InstallOptions) error
- func SupportedFormats() []string
- func UninstallPreCommit() error
- type Config
- type InstallOptions
- type PreCommitOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPaths ¶
DefaultPaths returns the default output paths for each supported format.
func EventSupport ¶
EventSupport returns which events are supported by which tools.
func FindGitDir ¶ added in v0.2.0
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 ¶
Generate creates an assistantkit hooks.Config from the api-style-spec configuration.
func (*Config) MarshalFormat ¶
MarshalFormat converts the configuration to a specific format.
func (*Config) WriteToFile ¶
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.