wkchat ConPTY enter-intercept + rename-first hardlink live-swap
Three techniques for wkchat (wkappbot chat cmd / claude) flow. (1) Enter-intercept uses Func<string, Action?> two-phase decide/commit in PseudoConsoleRunner -- null = passthrough, non-null Action commits ESC + 30ms sleep + dispatch + CR sequence that cleanly clears cmd.exe line buffer and triggers a fresh prompt underneath. (2) User-line echo uses backspace-backspace style-prefix line reset CRLF -- two backspaces overwrite the prompt's trailing > with a colored marker to save one row; CRLF at end forces column=0 so the dispatch output doesnt land offset. (3) Stale-hardlink live-swap: on startup, if exeBase != wkappbot and wkappbot.exe mtime is >2s newer, respawn wkappbot.exe with same argv + inherited stdio + WaitForExit + TerminateSelf. AppBotExit then schedules --heal-link self-dispatch which rename-first the stale link to <name>.old-YYYYMMDD-HHmmss.exe (running exe can be Moved on Windows, only Delete is locked), CreateHardLink to current binary, then up to 10x100ms Delete retry on the rename orphan.
Steps
- two-phase decide then commit on Enter
- ESC then 30ms then dispatch then CR for cmd....
- backspace-backspace overwrites prompt traili...
- live-swap: compare mtime then respawn with i...
- heal: rename-first, CreateHardLink, 10 retry...