livery.extensions.claude._tasks¶
livery.extensions.claude._tasks ¶
The hook verbs, fm hooks.*: the guards an agent session's tooling runs.
The extension's plugin, mounted while a workspace lists the extension.
Wired from .claude/settings.json through one shim
(.claude/hooks/fm-hook.sh); each event arrives on stdin and the
verdict is the exit code: 0 is quiet, 2 blocks the gated action with
stderr as the agent's feedback. The shim propagates only the hook's
own 2 and turns every other failure into 0, because a guard that
cannot run must not deny.
Classes:
| Name | Description |
|---|---|
ToolInput |
What the agent handed the tool, as the hook event carries it. |
HookEvent |
One Claude Code hook event, parsed from stdin. |
Functions:
| Name | Description |
|---|---|
pre_bash |
Refuse the Bash commands that succeed while silently breaking state. |
post_edit |
Run the fixers over the edited file; never block an edit. |
stop |
Block ending a turn whose last Bash result is a red fm verdict. |
Attributes:
| Name | Type | Description |
|---|---|---|
hooks |
|
hooks
module-attribute
¶
hooks = group('hooks', hidden=True, help='Agent lifecycle hooks (stdin-driven)')
ToolInput
dataclass
¶
HookEvent
dataclass
¶
HookEvent(tool_input: ToolInput = ToolInput(), stop_hook_active: bool = False, session_id: str = '', transcript_path: str = '')
One Claude Code hook event, parsed from stdin.
Attributes:
| Name | Type | Description |
|---|---|---|
tool_input |
ToolInput
|
|
stop_hook_active |
bool
|
|
session_id |
str
|
|
transcript_path |
str
|
|
tool_input
class-attribute
instance-attribute
¶
tool_input: ToolInput = dataclasses.field(default_factory=ToolInput)
pre_bash ¶
Refuse the Bash commands that succeed while silently breaking state.
The two: a footman gate piped into tail/head, and a git push of a branch that conflicts with origin/main. Ported from footman's own loop.
The pipe guard. A gate's exit code is its verdict, and a pipe
replaces it with the filter's, so fm check | tail -4 reports 0
whatever happened and prints the step summary while the failing step
scrolls past above. A red gate has been reported green here exactly
that way.
The push guard. Agent sessions share this repository, so main moves while a branch is being built, and a branch pushed from a stale base opens a conflicting pull request for which GitHub cannot build its test-merge and therefore spawns no CI at all: no red X, no checks, just an absence nothing points at. The guard runs the same test-merge locally (git merge-tree --write-tree) before letting the push through. Tag pushes, deletions, and pushes of main itself pass untouched.
Both are deliberately narrow. Command separators split first, so
fm check && echo done | tail stays legal; quoted spans are data, so
rg "fm check" | head passes. Nudges, not a sandbox.
Source code in packages/extensions/claude/src/livery/extensions/claude/_tasks.py
post_edit ¶
Run the fixers over the edited file; never block an edit.
Best-effort by design: every outcome exits 0 and says nothing, because a formatter problem must never block an edit. The gate, not the hook, is the arbiter; this only saves round trips.
Imports are never removed here: an edit in flight legitimately adds an import before the code that uses it, and a hook firing between the two edits would delete it (measured, twice in one session). The full clean, unused imports included, belongs to the stop hook and the gate.
Source code in packages/extensions/claude/src/livery/extensions/claude/_tasks.py
stop ¶
Block ending a turn whose last Bash result is a red fm verdict.
stop_hook_active (the harness's retry marker) always passes,
so a deliberate stop with a reported failure costs one nudge and
never loops.