guards

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package guards turns institutional gotchas into candidate enforcement: for a gotcha with a concrete anti-pattern, the BYOAI LLM proposes a grep-style pre-commit check (pattern + file globs + message). The human pastes the ones that fit into the hook, closing the loop from "we learned this" to "the repo enforces it". BYOAI via the existing llm.Client (claude -p); the model proposes, the human decides.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShellSnippet

func ShellSnippet(guards []Guard) string

ShellSnippet renders applicable guards as a copy-paste bash block for a pre-commit hook: each greps the staged-relevant globs for its pattern and fails with the message. Only guards that applies==true and have a pattern + globs are emitted.

Types

type Guard

type Guard struct {
	GotchaID string `json:"gotcha_id"`
	Title    string `json:"title"`
	Applies  bool   `json:"applies"`  // false = not mechanically checkable (judgment/architecture)
	Pattern  string `json:"pattern"`  // RE2/grep -E regex flagging the anti-pattern
	Globs    string `json:"globs"`    // comma file globs the check applies to (e.g. "*.go,*.ts" or "Dockerfile")
	Message  string `json:"message"`  // one-line failure message
	Severity string `json:"severity"` // block | warn
	Reason   string `json:"reason"`   // why applies is true/false
}

Guard is a proposed enforcement for a gotcha.

func Suggest

func Suggest(ctx context.Context, client llm.Client, g index.GotchaRow) (Guard, error)

Suggest asks the model to propose a guard for one gotcha.

Jump to

Keyboard shortcuts

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