g1t/crates/runner/src/revise.rs
Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Agents as a team: lifecycle, merge queue, billing and a new shell | 1 | //! Sends the author back to a pull request that is already ready for |
| 2 | //! review, to address what its acceptance checks or a review found. | |
| 3 | //! | |
| 4 | //! The work is the same as making the change in the first place (see | |
| 5 | //! `main`): clone the fork, run the agent on `PROMPT`, commit and push. | |
| 6 | //! What differs is the ending. The pull request stays as it is, with the | |
| 7 | //! agent's account of what it changed added to its session, and a failure | |
| 8 | //! leaves it open for a person to look at. | |
| 9 | ||
| 10 | use crate::report::{Entry, Reporter}; | |
| 11 | ||
| Agents asked while not at work are woken to answer | 12 | /// The author woken to answer what other agents asked it while it was not |
| 13 | /// at work: the same run, which pushes only if it took on handed-over work. | |
| 14 | pub fn answer() -> i32 { | |
| 15 | finish(crate::run, "Answering failed") | |
| 16 | } | |
| 17 | ||
| Agents as a team: lifecycle, merge queue, billing and a new shell | 18 | pub fn main() -> i32 { |
| Agents asked while not at work are woken to answer | 19 | finish(crate::run, "The revision failed") |
| 20 | } | |
| 21 | ||
| 22 | fn finish(run: fn(&mut Reporter) -> anyhow::Result<String>, failed: &str) -> i32 { | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 23 | let mut reporter = match Reporter::from_env() { |
| 24 | Ok(reporter) => reporter, | |
| 25 | Err(error) => { | |
| 26 | eprintln!("g1t-runner: {error:#}"); | |
| 27 | return 2; | |
| 28 | } | |
| 29 | }; | |
| Agents asked while not at work are woken to answer | 30 | let outcome = run(&mut reporter); |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 31 | // On success the agent's account is already in the session: the harness |
| 32 | // records its messages as they arrive. | |
| 33 | if let Err(error) = &outcome { | |
| 34 | eprintln!("g1t-runner: {error:#}"); | |
| 35 | reporter.record(Entry::new( | |
| 36 | "note", | |
| Agents asked while not at work are woken to answer | 37 | &format!("{failed}: {error:#}. Nothing was pushed."), |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 38 | )); |
| 39 | } | |
| 40 | reporter.flush(); | |
| 41 | i32::from(outcome.is_err()) | |
| 42 | } |