Expand description
Lifecycle scripting hooks, executed via the standalone stryke interpreter.
A hook binds a lifecycle event (e.g. scheme-changed) to a stryke script.
When the event fires, fire spawns the script (see crate::stryke_runner),
pipes the event envelope { event, payload } as JSON on stdin, and reads a
{ "actions": [ ... ] } object back on stdout. Recognized actions are
validated and dispatched against the host; unknown actions are ignored.
Storage: ~/.zwire/hooks/hooks.json holds metadata, and each hook’s body
lives next to it as <id>.st.
Ported from the Audio-Haxor engine (src-tauri/src/hooks.rs). The model,
manifest format, id/slug scheme, starter-script scaffolding, and stdout
action-dispatch logic are carried over verbatim. Re-hosted onto zwire-host’s
substrate: Tauri commands become plain functions returning serde_json::Value
(dispatched from session.rs), app.emit becomes bus::publish, and the
app-specific action verbs (tag/favorite/trash tied to the Audio-Haxor DB) are
replaced by zwire-host’s own capabilities — notify/open/exec/pub — dispatched
to the existing osops/exec/bus modules rather than reimplemented here.
Structs§
- Hook
- One configured hook. The script body lives in a sibling
<id>.stfile.
Functions§
- delete
hooks_delete— drop a hook and its script file.- events
hooks_events→ the catalog of lifecycle events + valid action verbs.- fire
- Fire all enabled hooks bound to
event. Returns immediately; scripts run on a background thread. The hot path (no matching hook) is one small manifest read. - fire_
cmd hook_fire— the browser reports a lifecycle event; run matching hooks.- get_
script hooks_get_script— the stryke source of a hook.- list
hooks_list→{ ok, hooks: [Hook] }.- save
hooks_save— create or update a hook; scaffolds a default script for a new one.- script_
path_ of hooks_script_path— absolute path to a hook’s script (for the LSPfile://URI).- set_
enabled hooks_set_enabled— toggle a hook on/off.- set_
script hooks_set_script— write a hook’s stryke source.- test_
run hooks_test_run— dry run: execute with a sample payload and return stdout/stderr plus the parsed actions, but do NOT dispatch them.