Expand description
Hook system — run user-supplied scripts around yui apply.
Scripts live at $DOTFILES/<config.script> (idiomatic place is
.yui/bin/<name>.sh). They’re plain executables — no yui imports,
no special protocol. yui just decides when to invoke them based on
the [[hook]] config and the persisted state file.
§State
Per-hook outcomes are stored in $DOTFILES/.yui/state.json:
{
"version": 1,
"hooks": {
"install-tools": {
"last_run_at": "2026-04-29T08:30:00+09:00[Asia/Tokyo]",
"last_content_hash": "sha256:abc123..."
}
}
}last_run_at is filled on every successful run; last_content_hash
is only filled for when_run = "onchange" hooks.
Structs§
Enums§
- Hook
Outcome - What happened when we considered running a hook.
Functions§
- build_
hook_ context - Build a Tera context for a hook: standard
template_context+ thescript_*vars thatcommand/argscan interpolate. - run_
hook - Decide whether to run
hookand run it if so. Updatesstatein memory on a successful run — caller is responsible for persisting (typically viastate.save(source)after eachRanoutcome, so a later hook failure doesn’t lose the record of the earlier success). - run_
phase - Run every hook whose phase matches. Stops at the first failure (the
user can investigate, fix, and re-run; we don’t want to silently keep
going after a failed
prehook). - sha256_
hex