Index
hooks
Git hook actions for AXM lifecycle hooks.
Provides BranchDeleteHook, CreateBranchHook, CommitPhaseHook,
MergeSquashHook, PreflightHook, WorktreeAddHook, WorktreeRemoveHook,
PushHook, CreatePRHook, and AwaitMergeHook,
auto-discovered by HookRegistry via the axm.hooks
entry-point group.
AwaitMergeHook
dataclass
Poll a PR until merged or timeout.
Reads pr_number (or pr_url) from context and polls
gh pr view --json state every 30 seconds. Times out after
10 minutes by default.
Source code in packages/axm-git/src/axm_git/hooks/await_merge.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context dictionary (must contain
|
required |
**params
|
object
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/await_merge.py
BranchDeleteHook
dataclass
Delete a branch by name.
Branch name priority:
branchparam (direct override)branchcontext key
Skips gracefully when disabled or when the working directory is not a git repository.
Source code in packages/axm-git/src/axm_git/hooks/branch_delete.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context dictionary. |
required |
**params
|
object
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/branch_delete.py
CommitPhaseHook
dataclass
Commit all changes with message [axm] {phase_name}.
Reads phase_name from context. An optional
message_format can be provided via params
(default "[axm] {phase}"). Skips gracefully when
there is nothing to commit or no git repository.
When from_outputs=True is passed in params, reads
commit_spec from context instead: {message, body?, files}.
Only the listed files are staged (no git add -A).
Source code in packages/axm-git/src/axm_git/hooks/commit_phase.py
| Python | |
|---|---|
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | |
commit_from_outputs(context, working_dir, *, skip_hooks=False, profile=None)
Outputs mode: read commit_spec from context, stage listed files.
Resolves the author identity via :func:resolve_identity and
injects --author into the commit command when a profile is
found. If the commit fails because pre-commit hooks auto-fixed
files (stderr contains "files were modified"), the listed
files are re-staged and the commit is retried once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context containing |
required |
working_dir
|
Path
|
Repository working directory. |
required |
skip_hooks
|
bool
|
When True, append |
False
|
profile
|
str | None
|
Optional identity profile name override. |
None
|
Source code in packages/axm-git/src/axm_git/hooks/commit_phase.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context dictionary. |
required |
**params
|
object
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/commit_phase.py
CreateBranchHook
dataclass
Create a session branch.
Branch name priority:
branchparam (direct override)ticket_id+ticket_titleparams →branch_name_from_ticket(){prefix}/{session_id}(legacy fallback)
Skips gracefully when the working directory is not a git repository.
Source code in packages/axm-git/src/axm_git/hooks/create_branch.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context dictionary (must contain |
required |
**params
|
object
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/create_branch.py
CreatePRHook
dataclass
Create a GitHub PR with auto-merge squash.
Reads branch, commit_spec, and ticket_id from context.
Runs gh pr create followed by gh pr merge --auto --squash.
Skips gracefully when gh is not installed.
Source code in packages/axm-git/src/axm_git/hooks/create_pr.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context dictionary. |
required |
**params
|
object
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/create_pr.py
MergeSquashHook
dataclass
Merge session branch back to main with squash.
Branch name priority: branch param > context["branch"]
{prefix}/{session_id}fallback.
Commit message priority: message param >
[AXM] {protocol_name}: {session_id} fallback.
Source code in packages/axm-git/src/axm_git/hooks/merge_squash.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context dictionary (must contain
|
required |
**params
|
object
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/merge_squash.py
PreflightHook
dataclass
Report working-tree status and diff as a pre-hook.
Designed for injection into protocol briefings via
inject_result + inline: true.
params:
path — project root (default ".").
diff_lines — max diff lines (default 200, 0 to disable).
Source code in packages/axm-git/src/axm_git/hooks/preflight.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context dictionary. |
required |
**params
|
object
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with a compact |
HookResult
|
and metadata containing |
HookResult
|
and |
Source code in packages/axm-git/src/axm_git/hooks/preflight.py
PushHook
dataclass
Push the current branch to origin -u.
Reads branch from context (or detects it from HEAD).
Skips gracefully when the working directory is not a git repository.
Source code in packages/axm-git/src/axm_git/hooks/push.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context dictionary. |
required |
**params
|
object
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/push.py
WorktreeAddHook
dataclass
Create a worktree + branch for a ticket.
Reads ticket_id, ticket_title, ticket_labels, and
repo_path from context. The worktree is placed under
/tmp/axm-worktrees/<ticket_id>/.
Skips gracefully when the working directory is not a git repository or the worktree already exists.
Source code in packages/axm-git/src/axm_git/hooks/worktree_add.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context dictionary. |
required |
**params
|
object
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/worktree_add.py
WorktreeRemoveHook
dataclass
Remove a worktree after merge.
Reads worktree_path and repo_path from context.
Uses git worktree remove --force to handle dirty worktrees.
Skips gracefully when the path doesn't exist or isn't a git repo.
Source code in packages/axm-git/src/axm_git/hooks/worktree_remove.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context (must contain |
required |
**params
|
object
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult on success. |