get_history_correction aligns a failed script with near-identical
history commands segment by segment (shell_ast words with byte-true
offsets) and splices the corrected tokens back in place. It only
returns a fix when exactly one candidate matches the structure with
at most two diverged tokens, each at least 80 percent similar;
looser or ambiguous matches decline so the asking history rule
stays in charge of them.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Consult a PATH-resolved binary's own --help (mtime-cached, LC_ALL=C,
2s timeout with kill) when a segment's first non-flag token is not a
listed subcommand, and splice the unique close match (ratio >= 0.8,
same first character). Ambiguity, sudo heads, flat-fallback artifact
heads, valid subcommands and nested levels all decline to the rest of
the chain; only <binary> --help is ever run.