Skip to main content

Module git_hooks

Module git_hooks 

Source
Expand description

Global git hooks that book a commit when the runner has no prompt hook.

When core.hooksPath is unset, install writes a stub for every standard git hook and points the global config at ljos’s directory. The stub calls ljos git-hook <name>, then runs the repository’s .git/hooks/<name> or the previous path an older install recorded, with the same arguments. post-rewrite copies stdin first, so ljos git-hook and the chained hook both see the old and new shas.

When core.hooksPath already names a directory, install leaves that setting alone and appends a delimited block to each hook there. The block calls ljos git-hook <name>. A missing hook file is created executable. Text that was already in the file is kept. Uninstall removes only that block, and deletes a file that held nothing else.

post-commit and post-rewrite book the commit. Booking never fails the hook. pre-commit and pre-push run the sitting gate under an agent runner: a commit needs a live sitting, and a push onto a protected branch also needs the sitting’s ticket to clear it. That refusal fails the hook. pre-push copies stdin like post-rewrite.

pre-commit install follows core.hooksPath and would replace stubs ljos owns. Install the framework into the repository, then let the stub chain to it:

dir=$(git rev-parse --git-dir)
git config --local core.hooksPath "$dir/hooks"
pre-commit install
git config --local --unset core.hooksPath

A commit is booked only when a seat resolves from LJOS_SEAT, then seats.toml through CURSOR_CONVERSATION_ID, then grokbot-<id8>, then an agy or opencode conversation id. The process tree is not a seat. The holder is SEAT@TAG, the same name ljos claim uses. Paths in [git_hooks] skip of ljos.toml, plus /tmp, /var/tmp, /dev/shm, the tracker, CLAIMDAG_DIR and the deedar store, are not booked. An amend or a rebase moves the citation onto the new sha.

Constants§

HOOKS_ENV_LINE
The LJOS_GIT_HOOKS line ljos onboard writes into a shell runner’s env file. It names the same directory install writes.
HOOKS_FIX
The one command that installs the hooks doctor checks.
HOOKS_UNSET
The start of the doctor’s git hooks state when core.hooksPath is unset. That row is info: a seat that has not onboarded books no commits, and nothing else is wrong.

Functions§

doctor_row
The doctor’s git hooks row. It passes when ljos git-hook runs from the directory core.hooksPath names: ljos’s own stubs, or a block in each hook of a directory the user already set. It does not ask to take that path over. An env file that sets LJOS_GIT_HOOKS to another directory fails the row.
doctor_state
doctor_row for a chosen hooks directory, the global core.hooksPath, and the config directory that holds env files.
env_hooks_drift
An env file under config_dir that sets LJOS_GIT_HOOKS to a directory other than onboard_dir. The expression HOOKS_ENV_LINE writes is the same directory and is not a mismatch. None when every assignment agrees.
hooks_state
doctor_row’s verdict for the onboard hooks at ours and the global core.hooksPath git reports.
install
Install the hooks ljos doctor checks.
run
install, uninstall, or status.
run_git_commit
Book the commit that just landed. Always succeeds: the commit stands.
run_named
Run the ljos part of git hook name.
status
Where the hooks are, and what core.hooksPath says.
uninstall
Remove ljos from the hooks git runs.