Repository navigation
feat(agent-mode): ask the agent to fix the last failed command - #1021
Conversation
|
I like this idea! The main point I'm not confident on is do we really need to bypass HistoryManager and use bash's history vec symbol directly? If the reason to bypass HistoryManager is that in some niche scenarios we might use a command from a previous session / a repeated command, then I don't think it is worth the complexity and we should use HistoryManager. when the history backend is bash, flyline reads directly from bash's history vec and when the backend is flyline, we first check |
i think |
abf8259 to
93cc6bf
Compare
Alt+Shift+Enter (or Alt+Enter on an empty prompt) sends the last command in flyline's history, plus $?, to the configured agent. Commands excluded from history never reach the agent. On a non-empty buffer it asks the agent to fix the buffer text instead.
93cc6bf to
6fb806f
Compare
Summary
A thefuck-style fix built on agent mode: one key sends the failed command and its exit status to the configured agent. The suggestions appear in the existing agent-output picker.
The command comes from bash's own history, gated by what this shell just submitted:
So anything bash keeps out of history is never sent to the agent. Reading "the last history entry" directly wasn't enough: on the default Bash backend, entries have no session, so it could be yesterday's line from another terminal.
Evidence
cargo test --lib: 873 passed.cargo clippy --workspace --all-features -D warningsandcargo fmt --checkare clean.HISTCONTROL=ignoreboth, using a stub agent that records the prompt it receives:falseThis Bash command exited with status 1. Fix it:\nfalsesecret-cmd --token=abcls /nopetwice (ignoredups)…status 2. Fix it:\nls /nopefor i in 1; do⏎false; done…status 1. Fix it:\nfor i in 1; do false; donetrue, thensecret2echo hi, then!!(a dup under ignoredups)Appcan't be built in lib tests, and the docker harness has no agent-mode coverage.Merge Danger
Door: two-way
Blast Radius: keybindings
start_agent_modehas a TODO about empty-buffer UX (maybe opening agent-prompt history search); this change takes that slot. @HalFrgrd, is that OK?check_add_historycouldn't be the filter, because it also adds the line to history.