livery.extensions.agents._tasks¶
livery.extensions.agents._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 (Claude Code) and
.agents/hooks.json (Antigravity) through one shim (fm-hook.sh).
Under Claude Code each event arrives on stdin and the verdict is the
exit code: 0 is quiet, 2 blocks the gated action with stderr as
feedback. Under Antigravity each event arrives on stdin as camelCase
JSON and the verdict is JSON on stdout. The shim turns infrastructure
failures into a pass, because a guard that cannot run must not deny.
Classes:
| Name | Description |
|---|---|
ToolInput |
What Claude Code handed the tool, as the hook event carries it. |
ToolCall |
What Antigravity handed the tool, as the hook event carries it. |
HookEvent |
One agent hook event, parsed from stdin. |
Functions:
| Name | Description |
|---|---|
pre_bash |
Refuse shell 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 |
|
|
Harness |
|
hooks
module-attribute
¶
hooks = group('hooks', hidden=True, help='Agent lifecycle hooks (stdin-driven)')
ToolInput
dataclass
¶
ToolCall
dataclass
¶
HookEvent
dataclass
¶
HookEvent(tool_input: ToolInput = ToolInput(), toolCall: ToolCall = ToolCall(), stop_hook_active: bool = False, session_id: str = '', transcript_path: str = '', cwd: str = '')
One agent hook event, parsed from stdin.
Accepts both Claude Code's snake_case payload (tool_input,
stop_hook_active, transcript_path) and Antigravity's
camelCase payload (toolCall, cwd).
Methods:
| Name | Description |
|---|---|
command |
The shell command the tool call is about to run, or empty. |
file_path |
The path the edit or write tool call targets, or empty. |
Attributes:
| Name | Type | Description |
|---|---|---|
tool_input |
ToolInput
|
|
toolCall |
ToolCall
|
|
stop_hook_active |
bool
|
|
session_id |
str
|
|
transcript_path |
str
|
|
cwd |
str
|
|
tool_input
class-attribute
instance-attribute
¶
tool_input: ToolInput = dataclasses.field(default_factory=ToolInput)
toolCall
class-attribute
instance-attribute
¶
toolCall: ToolCall = dataclasses.field(default_factory=ToolCall)
command ¶
command() -> str
The shell command the tool call is about to run, or empty.
Source code in packages/extensions/agents/src/livery/extensions/agents/_tasks.py
pre_bash ¶
pre_bash(event: Annotated[HookEvent, stdin], harness: Annotated[Harness, doc('the hook protocol to answer in: claude or antigravity')] = 'claude') -> Stdout[str]
Refuse shell commands that succeed while silently breaking state.
Guards two patterns: a footman command piped into tail or
head, and a git push of a branch that conflicts with
origin/main.
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.
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. The guard runs
git merge-tree --write-tree locally 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.
Source code in packages/extensions/agents/src/livery/extensions/agents/_tasks.py
post_edit ¶
post_edit(event: Annotated[HookEvent, stdin], harness: Annotated[Harness, doc('the hook protocol to answer in: claude or antigravity')] = 'claude') -> Stdout[str]
Run the fixers over the edited file; never block an edit.
Best-effort by design: every outcome exits 0 and says nothing under
Claude Code (or answers {} under Antigravity), 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. The full clean, unused imports included, belongs to the stop hook and the gate.
Source code in packages/extensions/agents/src/livery/extensions/agents/_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.