grip_hook.config¶
grip_hook.config ¶
Configuration loading.
Precedence, highest first:
- Command-line flags.
GRIP_*environment variables..grip.tomlat the repository root.[tool.grip]inpyproject.tomlat the repository root.- Built-in defaults.
AGENT_PROVIDERS
module-attribute
¶
AGENT_PROVIDERS: tuple[tuple[str, str], ...] = (('claude-code', 'claude'), ('codex', 'codex'), ('gemini', 'gemini'))
Coding-agent providers auto tries, in order, with the command each one needs.
Config
dataclass
¶
Resolved grip configuration.
Source code in src/grip_hook/config.py
passing_score
class-attribute
instance-attribute
¶
Minimum Grip Score (0-100) required to let the commit or push through.
provider
class-attribute
instance-attribute
¶
Provider name: auto, anthropic, openai, ollama, claude-code,
codex, gemini or fake. auto picks an installed coding agent, else
anthropic; see :func:auto_provider.
model
class-attribute
instance-attribute
¶
Model identifier passed to the provider. Empty means the provider's default.
effort
class-attribute
instance-attribute
¶
Reasoning effort for providers that support it. none disables the parameter.
api_key_env
class-attribute
instance-attribute
¶
Environment variable holding the API key. Empty means the provider's default.
base_url
class-attribute
instance-attribute
¶
Override the provider's API base URL (Ollama, proxies, OpenAI-compatible servers).
difficulty
class-attribute
instance-attribute
¶
How demanding the questions and grading are.
max_diff_bytes
class-attribute
instance-attribute
¶
Diffs larger than this are truncated before being sent to the provider.
exclude
class-attribute
instance-attribute
¶
Path globs excluded from the diff (lockfiles, generated code).
remember_passes_hours
class-attribute
instance-attribute
¶
How long a passed diff stays valid without re-quizzing. 0 disables.
cache_hours
class-attribute
instance-attribute
¶
How long the questions and boards written for a diff are reused when the same diff
is quizzed again, so a retry after a failed quiz costs one grading call. 0 asks
the model every time; --fresh does so once.
hook_mode
class-attribute
instance-attribute
¶
What the git hook asks for: quiz (questions in the terminal) or whiteboard
(defend a board of the change in the browser, as grip whiteboard --defend does).
The whiteboard falls back to the terminal quiz when no browser can be opened.
require_tty
class-attribute
instance-attribute
¶
Fail instead of skipping when no interactive terminal is available.
fail_open
class-attribute
instance-attribute
¶
Let the commit or push through when the provider errors out instead of blocking.
timeout
class-attribute
instance-attribute
¶
Per-request timeout in seconds for provider calls.
provider_name
property
¶
The provider that will actually run: auto resolved on this machine.
validate ¶
Raise :class:ConfigError for out-of-range values and return self.
Source code in src/grip_hook/config.py
auto_provider ¶
What provider = "auto" means on this machine.
A coding agent that is installed (and so, usually, signed in) needs no API key and adds
no bill, so the first of Claude Code, Codex and Gemini CLI on PATH wins; without
one, the Anthropic API.
Source code in src/grip_hook/config.py
load_config ¶
load_config(root: Path | None, *, env: dict[str, str] | None = None, overrides: dict[str, Any] | None = None) -> Config
Build the effective :class:Config for a repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path | None
|
Repository root (where |
required |
env
|
dict[str, str] | None
|
Environment mapping. Defaults to :data: |
None
|
overrides
|
dict[str, Any] | None
|
Values from command-line flags. |
None
|
Source code in src/grip_hook/config.py
render_template ¶
render_template(*, provider: str, passing_score: int = DEFAULT_PASSING_SCORE, difficulty: str = 'normal') -> str
The commented .grip.toml that grip init writes.
Source code in src/grip_hook/config.py
describe ¶
Return (name, value) pairs for display.