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.
[[paths]] rules (paths in :class:Config) come from the files only. They adjust
the pass mark and difficulty for the files a diff touches, after everything above is
resolved; see :meth:Config.for_files.
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.
PathRule
dataclass
¶
One [[paths]] table: a different bar for the files that match it.
Source code in src/grip_hook/config.py
match
instance-attribute
¶
Globs, read like exclude. A file matches when any of them does.
passing_score
class-attribute
instance-attribute
¶
Pass mark for diffs that touch a matching file. None keeps the repository's.
difficulty
class-attribute
instance-attribute
¶
Difficulty for diffs that touch a matching file. None keeps the repository's.
skip
class-attribute
instance-attribute
¶
Matching files need no quiz; a diff made only of them is not quizzed at all.
matches ¶
describe ¶
services/api/** (passing_score 90, hard) style text for display.
Source code in src/grip_hook/config.py
Config
dataclass
¶
Resolved grip configuration.
Source code in src/grip_hook/config.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
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).
include_commit_messages
class-attribute
instance-attribute
¶
Send the messages of the commits being quizzed (push, --unpushed, --branch,
--range) to the model with the diff, as data, so it can ask and grade "why".
skip_paths
class-attribute
instance-attribute
¶
Path globs (docs/**, *.md) with nothing to quiz about: a diff that touches
only these paths is skipped. Unlike exclude, a diff that also touches other files
is quizzed whole.
min_changed_lines
class-attribute
instance-attribute
¶
Skip diffs that add and remove fewer lines than this in total. 0 disables.
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.
retry_questions
class-attribute
instance-attribute
¶
What a retry after a failed quiz asks: same reuses the questions (or board)
written for the diff, within cache_hours; new forgets them on a failure, so
the next try on the same diff gets new ones from the model. Either way the grading
feedback says where to look, not what the rubric expected.
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.
paths
class-attribute
instance-attribute
¶
[[paths]] rules: a pass mark, difficulty or skip for part of the repository.
provider_name
property
¶
The provider that will actually run: auto resolved on this machine.
skips ¶
Whether every one of files matches a skip = true rule (and there is one).
Source code in src/grip_hook/config.py
for_files ¶
This configuration with the [[paths]] rules for files applied.
Each file gets the strictest pass mark and the hardest difficulty of the rules it
matches, or the repository's own when no matching rule sets one; files matched by a
skip rule do not count. The diff then takes the strictest over its files, so a
rule that lowers the bar for docs/ never lowers it for code in the same diff.
Source code in src/grip_hook/config.py
validate ¶
Raise :class:ConfigError for out-of-range values and return self.
Source code in src/grip_hook/config.py
Resolved
dataclass
¶
The effective :class:Config, and where each of its values came from.
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
path_matches ¶
Whether path or a directory above it matches pattern.
path is /-separated and relative to the repository root. Matching the
directories too is what lets services/api cover every file under it.
Source code in src/grip_hook/config.py
resolve_config ¶
resolve_config(root: Path | None, *, env: dict[str, str] | None = None, overrides: dict[str, Any] | None = None) -> Resolved
Build the effective :class:Config for a repository and record each value's source.
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
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.