diff --git a/CLAUDE.md b/CLAUDE.md index 50a9eaf..685648f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -36,7 +36,7 @@ uv pip install -e ".[dev,examples]" # examples: the bundled examples' tests ne - `src/autohelix/runs.py` - run identity/paths and selection, ownership locks, ref recovery, landing, archive/delete, copies sweep - `src/autohelix/workspace.py` - candidate copies (`Repo`, `Copy`, `Fingerprint`), tree snapshots, write scope and judge guard - `src/autohelix/display.py` - live Rich display -- `src/autohelix/terminal.py` - what `run`/`resume`/bare `autohelix` print (header, rows, end block: its `next` line ends with the run folder, `.autohelix/runs//` (`shown_path`, like the page and summary lines: relative to the current folder when inside it, else absolute), as the web run page's `#run-folder` names it, common.js `runFolder`), and every screen's one warning form (`warning`/`warn`: ` ! message`) and one wrap helper (`wrap`/`hanging`/`show`: breaks at spaces only, never inside a word such as a path or branch name) +- `src/autohelix/terminal.py` - what `run`/`resume`/bare `autohelix` print (header, rows, end block: its `next` lines, one command each with what it does (`command_lines`, `command_hint`; the live row's steering commands, `steer_lines`, the same way), then its `folder` line, `.autohelix/runs//` (`shown_path`, like the page and summary lines: relative to the current folder when inside it, else absolute), as the web run page's `#run-folder` names it, common.js `runFolder`), and every screen's one warning form (`warning`/`warn`: ` ! message`) and one wrap helper (`wrap`/`hanging`/`show`: breaks at spaces only, never inside a word such as a path or branch name) - `src/autohelix/run_status.py` - live run status (`.autohelix/runs//.internal/status.json`) - `src/autohelix/live.py` - `view --terminal` (run table + the log the run status points at, or the running iteration's latest ask/review transcript) - `src/autohelix/viewer.py` + `viewer_resources/` - `autohelix view`'s web app (`/` run list, `/run//` one run) diff --git a/docs/cli.md b/docs/cli.md index b96880a..300d5fc 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -256,16 +256,20 @@ VPN alive. out-of-scope paths. - **While an iteration runs**, a live row shows its time and phase (`agent`, `gates`, `observe · bench` with the entry running, `stop`). Under it, after a - blank line, the commands that steer the run, dim: `autohelix view krp3 · hint - --run krp3 "…" · stop krp3 · Ctrl-C now` (`stop` ends it after the current - iteration; Ctrl-C interrupts it now, progress kept), then two blank lines. - Piped, the header has them as its `Steer` line instead. + blank line, the commands that steer the run from another terminal, one per + line with what each does (`autohelix view krp3`, `autohelix hint --run krp3 + "…"`, `autohelix stop krp3`: after the current iteration), then what Ctrl-C + does here: it stops the run now (accepted work is kept: the running iteration + is recorded as rejected, the accepted ones stay and land), then two blank + lines. Piped, the + header has the commands as its `Steer` line instead. - **The end block** says how the segment ended (`Done`, `Stopped`, `Interrupted`, `Error`), each metric from the baseline to the run's tip, the totals, what landed (`landing failed: …` in yellow when auto landing - couldn't, the commits then waiting for `autohelix land`), what to type next, - then the run's folder (`report.md`, `history.jsonl`, `iterations/` are in - it; on its own line when it doesn't fit), and the files written. + couldn't, the commits then waiting for `autohelix land`), what to type next + (one command per line, with what it does; left out when it doesn't fit), the + run's `folder` (`report.md`, `history.jsonl`, `iterations/` are in it), and + the files written. - **`resume`** shows the baseline and the last 5 rows before `resumed HH:MM`. Wide terminals (where a reason still fits after the values) space the columns out; @@ -853,7 +857,7 @@ A section you open or close stays so as you move between iterations. Notes that - once the run stopped, its end block, as in `run`: how it ended, each metric's baseline → latest accepted value, totals, what landed (commits still waiting read `unlanded 3 commits on autohelix/ (manual landing)`, or `(diverged from main)` when the run diverged from its target), what to type next (`autohelix land`, or `git merge autohelix/` for a diverged run, since `autohelix land` only fast-forwards), and the run's report.html and report.md once written. 2. Live output (tool calls, text, elapsed time) of the agent during an iteration, of the latest `autohelix ask` or `review` call while gates, observe entries or stop commands make one (followed live, then from its stored transcript), and of the summary agent at the end. Works with Claude Code, Codex and OpenCode logs. 3. A status line: the iteration, the phase (in the live row's words: agent, gates, observe, stop) and time in that phase, read from `.autohelix/runs//.internal/status.json`. -4. While the run goes, a last line: `Ctrl-C quits this view · autohelix stop krp3 stops the run · hint --run krp3 "…"`. Ctrl-C quits the view, never the run. +4. While the run goes, what steers it from another terminal (`autohelix hint --run krp3 "…"`, `autohelix stop krp3`, one per line with what each does), then `Ctrl-C here quits this view (the run goes on)`. Ctrl-C quits the view, never the run. On a short terminal the live output gets fewer lines first, then the oldest iteration rows are left out (the baseline stays). When the run stops, the view says how and when, and waits for the next segment. diff --git a/scripts/console_screens.py b/scripts/console_screens.py index 5884974..e0da358 100644 --- a/scripts/console_screens.py +++ b/scripts/console_screens.py @@ -219,7 +219,8 @@ def run_in_pty(argv, cwd, env, width, *, keys=(), frame_when=None, timeout=180): return snapshot(screen), live, code -MENU = "(q: quit)" # the last line the entry screen's menu draws +MENU = "(q: quit)" # the last line a menu draws ("Which agent?") +QUESTION = "Enter/q" # the entry screen's one question def showing(*texts: str): @@ -357,11 +358,11 @@ def mid_iteration_3(text): run_in_pty([*cli, "run", "-n", "3", "--no-report"], project, env, width, keys=[(4.0, b"\x03")], timeout=60) # With runs, as drawn while choosing; q quits (exit 0). - _, live, code = run_in_pty([*cli], project, env, width, keys=[(MENU, b"q")], - frame_when=showing(MENU), timeout=30) + _, live, code = run_in_pty([*cli], project, env, width, keys=[(QUESTION, b"q")], + frame_when=showing(QUESTION), timeout=30) record(f"entry-runs-{width}", live or [], width, f"autohelix · runs (then q) · {width} cols", code) # The same, Enter: the first option starts the (fake) agent with its first prompt. - final, _, code = run_in_pty([*cli], project, env, width, keys=[(MENU, b"\r")], timeout=30) + final, _, code = run_in_pty([*cli], project, env, width, keys=[(QUESTION, b"\r")], timeout=30) record(f"entry-ask-{width}", final, width, f"autohelix · runs, Enter · {width} cols", code) # Two agents: the labels say "an agent", then "Which agent?"; q there quits. two = environment(root, width, ("claude", "codex")) @@ -372,8 +373,8 @@ def mid_iteration_3(text): f"autohelix · two agents, ↓ Enter (then q) · {width} cols", code) configs = make_project(root, "half-done", True) # autohelix/sorting/config.yaml, no runs yet - _, live, code = run_in_pty([*cli], configs, env, width, keys=[(MENU, b"q")], - frame_when=showing(MENU), timeout=30) + _, live, code = run_in_pty([*cli], configs, env, width, keys=[(QUESTION, b"q")], + frame_when=showing(QUESTION), timeout=30) record(f"entry-config-{width}", live or [], width, f"autohelix · a config, no runs (then q) · {width} cols", code) diff --git a/src/autohelix/harness.py b/src/autohelix/harness.py index af4152a..7a0518e 100644 --- a/src/autohelix/harness.py +++ b/src/autohelix/harness.py @@ -519,7 +519,7 @@ def _print_header(self, budget: Budget, start_iter: int = 1) -> None: getattr(self.agent, "executable", None)) fields = terminal.run_fields(self.config, budget_text(budget, start_iter - 1), agent) if not self.console.is_terminal: # no live row to show them under - fields.append(("Steer", terminal.steer_text(short_id(self.paths.run_id), interrupt=False))) + fields.append(("Steer", terminal.steer_text(short_id(self.paths.run_id)))) terminal.print_lines(self.console, terminal.header(title, fields, width, terminal.shows_mark(self.console))) self._table = terminal.Table.of(self.config, width) if start_iter > 1: # resuming: the rows so far, for context @@ -553,8 +553,8 @@ def _showing(self, renderable): already showing (the whole iteration's, so its row stays up between phases), else in a new one.""" # Not on the terminal's last line; under it, the commands that steer the run. - steer = terminal.steer_line(short_id(self.paths.run_id), self.console.width or 100) - renderable = terminal.with_room(renderable, steer if self.console.is_terminal else None) + steer = terminal.steer_lines(short_id(self.paths.run_id), self.console.width or 100) + renderable = terminal.with_room(renderable, steer if self.console.is_terminal else []) outer = getattr(self, "_live_display", None) if outer is not None: previous = outer.renderable @@ -1917,7 +1917,8 @@ def _print_ending(self, error: BaseException | None) -> None: commands = terminal.next_commands(short, also=self._relation()[1].commands) lines = table.ending(outcome, spent=format_total_cost(self.history.cost_usages), landing=self._landing, commands=commands, files=self._files, - folder=terminal.shown_path(self.paths.run_dir) + "/") + folder=terminal.shown_path(self.paths.run_dir) + "/", + target=self.run_info.get("target_branch") or "") except Exception as e: # noqa: BLE001 - the outcome line still shows self.log.warn(f"Could not render the ending: {e}") lines = [Text(f" {outcome[0]} {outcome[1]}")] diff --git a/src/autohelix/live.py b/src/autohelix/live.py index c08a45f..7bf6d6a 100644 --- a/src/autohelix/live.py +++ b/src/autohelix/live.py @@ -17,7 +17,7 @@ from rich.live import Live from rich.text import Text -from autohelix import run_table +from autohelix import run_table, terminal from autohelix.display import LiveDisplay from autohelix.formatting import clean, format_duration from autohelix.replay import LogTail @@ -157,19 +157,19 @@ def poll(self, status: dict | None) -> None: def render(self, status: dict | None, height: int | None = None) -> list: """The panel (at most `height` lines, none below MIN_LOG_LINES), if there is a log, then the status line; while the run goes, what Ctrl-C does here and the commands - that steer the run (`steer_line`).""" + that steer the run (`steer_lines`).""" running = bool(status) and status.get("state") == "running" # A crashed run has no stopped_at; its last status update is when it was last alive. end = time.time() if running or not status else ( status.get("stopped_at") or status.get("updated_at") or time.time()) show = self.display and (height is None or height >= MIN_LOG_LINES) parts = [self.display.render(elapsed=int(end - self.started), height=height)] if show else [] - return parts + [Text(status_line(status), style="dim")] + [self.steer_line()] * running + return parts + [Text(status_line(status), style="dim"), *self.steer_lines() * running] - def steer_line(self) -> Text: - short = short_id(self.run_id) - return cut(Text(f'Ctrl-C quits this view · autohelix stop {short} stops the run · hint --run {short} "…"', - style="dim"), self.console.width or 100) + def steer_lines(self) -> list[Text]: + """What steers the run from another terminal, and what Ctrl-C does here.""" + return terminal.steer_lines(short_id(self.run_id), self.console.width or 100, indent="", view=False, + ctrl_c="quits this view (the run goes on)") def fit(parts: tuple[list, list[list], list], height: int) -> list: @@ -239,9 +239,9 @@ def view_screen(data: tuple[dict, run_table.Saved] | str | None, log: LogFollowe folded = lambda lines: [piece for line in lines for piece in fold(line, width)] # noqa: E731 parts = (folded(head), [folded(row) for row in rows], folded(tail)) running = bool(status) and status.get("state") == "running" - # The status line (and the steer line under a live run), a spare line so the terminal + # The status line (and the steer lines under a live run), a spare line so the terminal # doesn't scroll, the blank lines under a live run. - room = height - 2 - (1 + ROOM) * running + room = height - 2 - (len(log.steer_lines()) + ROOM) * running lines = fit(parts, room - (MIN_LOG_LINES if log.display else 0)) if parts else [] log_height = room - len(lines) if parts and (log_height < MIN_LOG_LINES or (parts[2] and lines[-1] is not parts[2][-1])): diff --git a/src/autohelix/run_table.py b/src/autohelix/run_table.py index 57117c1..eff4aba 100644 --- a/src/autohelix/run_table.py +++ b/src/autohelix/run_table.py @@ -265,7 +265,7 @@ def view_parts(data: dict, saved: Saved, width: int = 100, now: float | None = N tail = table.ending(_outcome(run), spent=terminal.money(run["progress"]["cost_usd"], run["progress"]["cost_incomplete"]), landing=_landed(run, accepted), commands=commands, files=list(saved.files), - folder=saved.folder) + folder=saved.folder, target=run.get("target_branch") or "") return head, rows, tail diff --git a/src/autohelix/terminal.py b/src/autohelix/terminal.py index 1615205..c567d46 100644 --- a/src/autohelix/terminal.py +++ b/src/autohelix/terminal.py @@ -549,12 +549,14 @@ def outcome_lines(self, outcome: tuple[str, str, str | None], width: int = 0) -> width or self._label_width(word)) def ending(self, outcome: tuple[str, str, str | None], *, spent: str, landing: tuple[str, str, str | None] | None, - commands: list[str], files: list[tuple[str, str]], folder: str = "") -> list[Text]: + commands: list[str], files: list[tuple[str, str]], folder: str = "", target: str = "" + ) -> list[Text]: """After a rule: the outcome, each metric's baseline → tip value with its change, the run's totals, what landed (`landing`: label, text, style; the commits' - summaries are on the run page), then what to type next, ending with the run's - `folder` (`.autohelix/runs//`; on a line of its own when it doesn't fit), and - the files written (label, path).""" + summaries are on the run page), then what to type next (one command per line, + with what it does: `command_hint`, `target` the branch the run lands on), the + run's `folder` (`.autohelix/runs//`), and the files + written (label, path).""" iterations = [row for row in self.rows if row.iteration > 0] accepted = sum(row.accepted for row in iterations) seconds = sum(row.seconds or 0 for row in iterations) @@ -582,18 +584,10 @@ def field(label: str, *parts: tuple[str, str | None], style: str | None = "dim") if landing: label, text, landing_style = landing lines += self._wrapped(label, text, landing_style, "dim", width) - if 2 + width + len(" · ".join(commands)) <= self.width: - parts: list[tuple[str, str | None]] = [] - for i, command in enumerate(commands): - parts += [(" · ", "dim")] * bool(i) + [(command, TEAL)] - if folder and 2 + width + len(" · ".join([*commands, folder])) <= self.width: - parts += [(" · ", "dim")] * bool(commands) + [(clean(folder), None)] - folder = "" - lines.append(field("next", *parts)) - else: # one per line - lines += [field("next" if i == 0 else "", (command, TEAL)) for i, command in enumerate(commands)] + lines += command_lines(Text(f" {'next':<{width}}", style="dim"), " " * (2 + width), + [(command, command_hint(command, target)) for command in commands], self.width) if folder: # not cut: a path is only useful whole - lines.append(_parts((" ", None), (" " * width, None), (clean(folder), None))) + lines.append(_parts((" ", None), (f"{'folder':<{width}}", "dim"), (clean(folder), None))) for label, path in files: # not cut: a path is only useful whole lines.append(_parts((" ", None), (f"{label:<{width}}", "dim"), (clean(path), None))) return lines @@ -608,23 +602,55 @@ def live_line(label: str, seconds: float, what: str, frame: int = 0, width: int width) -def with_room(renderable, under: Text | None = None) -> Group: - """`renderable` (then a blank line and the line `under` it) with `ROOM` blank lines +def with_room(renderable, under: list[Text] = ()) -> Group: + """`renderable` (then a blank line and the lines `under` it) with `ROOM` blank lines under it: a live row shown at the bottom of the terminal doesn't sit on its last lines (gone with the live display).""" - return Group(renderable, *[Text(), under] * (under is not None), *[Text() for _ in range(ROOM)]) - - -def steer_text(short: str, interrupt: bool = True) -> str: - """The commands that steer a running run: `autohelix view krp3 · hint --run krp3 "…" · - stop krp3` (after this iteration), then `Ctrl-C now` (interrupt, progress kept) in - the terminal that runs it.""" - return f'autohelix view {short} · hint --run {short} "…" · stop {short}' + " · Ctrl-C now" * interrupt - - -def steer_line(short: str, width: int) -> Text: - """`run`/`resume`'s line under the live row (the header has long scrolled away).""" - return cut(Text(" " + steer_text(short), style="dim"), width) + return Group(renderable, *[Text(), *under] * bool(under), *[Text() for _ in range(ROOM)]) + + +def steer_commands(short: str, view: bool = True) -> list[tuple[str, str]]: + """The commands that steer a running run from another terminal, each with what it + does: look at it (`view`: not from the view itself), send its agent a hint, stop it + after the current iteration.""" + return ([(f"autohelix view {short}", "watch it in your browser")] if view else []) + [ + (f'autohelix hint --run {short} "…"', "tell the agent something (next iteration)"), + (f"autohelix stop {short}", "stop after this iteration")] + + +def steer_text(short: str) -> str: + """The steering commands on one line (a piped run's `Steer` header field).""" + return " · ".join(command for command, _ in steer_commands(short)) + + +def steer_lines(short: str, width: int, indent: str = " ", view: bool = True, + ctrl_c: str = "stops now (accepted work is kept)") -> list[Text]: + """What steers a running run, under its live row (`run`/`resume`: the header has + long scrolled away; `view --terminal`, without `view`): `from another terminal:`, + the commands with what they do (`command_lines`), then what Ctrl-C does here.""" + return [cut(Text(f"{indent}from another terminal:", style="dim"), width), + *command_lines(Text(indent + " "), indent + " ", steer_commands(short, view), width), + cut(Text(f"{indent}Ctrl-C here {ctrl_c}", style="dim"), width)] + + +def command_lines(first: Text, rest: str, commands: list[tuple[str, str]], width: int) -> list[Text]: + """Commands one per line, after `first` (the next ones after `rest`, as wide), each + with what it does, dim, in one column after the widest `autohelix` command (a longer + command, `git merge autohelix/`, has its hint after it). The hints are left out + when one doesn't fit; a command is cut only past the terminal's width.""" + gap = 4 + column = max((len(c) for c, _ in commands if c.startswith("autohelix ")), + default=max((len(c) for c, _ in commands), default=0)) + ends = [max(column, len(c)) + gap + len(hint) for c, hint in commands if hint] + hints = first.cell_len + max(ends, default=0) <= width + lines = [] + for i, (command, hint) in enumerate(commands): + line = first.copy() if i == 0 else Text(rest) + line.append(command, style=TEAL) + if hints and hint: + line.append(" " * (max(column, len(command)) - len(command) + gap)).append(hint, style="dim") + lines.append(cut(line, width)) + return lines def outcome(stop: dict | None, error: BaseException | None, interrupted_at: int | None) -> tuple[str, str, str | None]: @@ -708,6 +734,24 @@ def next_commands(short: str, view: bool = True, also=()) -> list[str]: return ([f"autohelix view {short}"] if view else []) + [f"autohelix resume {short}", *also] +def command_hint(command: str, target: str = "") -> str: + """What a command `next_commands` suggests does, in a few words: the end block's + column after it. The landing commands are `runs.landing_words`' three shapes; + `target`, the branch they land on (else `the branch`).""" + branch = target or "the branch" + if command.startswith("autohelix view "): + return "the run's page in your browser" + if command.startswith("autohelix resume "): + return "one more iteration (-n N for more)" + if command.startswith("autohelix land "): + return f"put its commits on {branch}" + if command.startswith("git merge "): + return f"merge its commits into {branch} by hand" + if command.startswith("git cherry-pick "): + return f"apply its newer commits to {branch} by hand" + return "" + + def shown_path(path) -> str: """A file the end block names: relative to the current folder when inside it.""" from pathlib import Path diff --git a/tests/snapshots/resume-120.txt b/tests/snapshots/resume-120.txt index 607bbc2..73c89ed 100644 --- a/tests/snapshots/resume-120.txt +++ b/tests/snapshots/resume-120.txt @@ -24,6 +24,8 @@ mem_mb 120 → 94 -22% iter 8 run 8 iterations · 4 accepted · 40m 21s · $2.92 landed 1 commit on main - next autohelix view krp3 · autohelix resume krp3 · .autohelix/runs/20261115-1402-sorting-krp3/ + next autohelix view krp3 the run's page in your browser + autohelix resume krp3 one more iteration (-n N for more) + folder .autohelix/runs/20261115-1402-sorting-krp3/ page .autohelix/runs/20261115-1402-sorting-krp3/report.html summary .autohelix/runs/20261115-1402-sorting-krp3/report.md diff --git a/tests/snapshots/resume-80.txt b/tests/snapshots/resume-80.txt index 2f5f640..f7345e4 100644 --- a/tests/snapshots/resume-80.txt +++ b/tests/snapshots/resume-80.txt @@ -25,7 +25,8 @@ mem_mb 120 → 94 -22% iter 8 run 8 iterations · 4 accepted · 40m 21s · $2.92 landed 1 commit on main - next autohelix view krp3 · autohelix resume krp3 - .autohelix/runs/20261115-1402-sorting-krp3/ + next autohelix view krp3 the run's page in your browser + autohelix resume krp3 one more iteration (-n N for more) + folder .autohelix/runs/20261115-1402-sorting-krp3/ page .autohelix/runs/20261115-1402-sorting-krp3/report.html summary .autohelix/runs/20261115-1402-sorting-krp3/report.md diff --git a/tests/snapshots/run-120.txt b/tests/snapshots/run-120.txt index 0525859..9ee1b42 100644 --- a/tests/snapshots/run-120.txt +++ b/tests/snapshots/run-120.txt @@ -23,6 +23,8 @@ mem_mb 120 → 95 -21% iter 6 run 7 iterations · 3 accepted · 38m 43s · $2.65 landed 3 commits on main - next autohelix view krp3 · autohelix resume krp3 · .autohelix/runs/20261115-1402-sorting-krp3/ + next autohelix view krp3 the run's page in your browser + autohelix resume krp3 one more iteration (-n N for more) + folder .autohelix/runs/20261115-1402-sorting-krp3/ page .autohelix/runs/20261115-1402-sorting-krp3/report.html summary .autohelix/runs/20261115-1402-sorting-krp3/report.md diff --git a/tests/snapshots/run-80.txt b/tests/snapshots/run-80.txt index 45f13d6..7153b01 100644 --- a/tests/snapshots/run-80.txt +++ b/tests/snapshots/run-80.txt @@ -24,7 +24,8 @@ mem_mb 120 → 95 -21% iter 6 run 7 iterations · 3 accepted · 38m 43s · $2.65 landed 3 commits on main - next autohelix view krp3 · autohelix resume krp3 - .autohelix/runs/20261115-1402-sorting-krp3/ + next autohelix view krp3 the run's page in your browser + autohelix resume krp3 one more iteration (-n N for more) + folder .autohelix/runs/20261115-1402-sorting-krp3/ page .autohelix/runs/20261115-1402-sorting-krp3/report.html summary .autohelix/runs/20261115-1402-sorting-krp3/report.md diff --git a/tests/snapshots/run-live-120.txt b/tests/snapshots/run-live-120.txt index 0bc5419..f72829d 100644 --- a/tests/snapshots/run-live-120.txt +++ b/tests/snapshots/run-live-120.txt @@ -13,4 +13,8 @@ ✓ 3 2m 06s $0.32 35,310.7 753× 96 -20% ⠋ 4 1m 12s agent - autohelix view krp3 · hint --run krp3 "…" · stop krp3 · Ctrl-C now + from another terminal: + autohelix view krp3 watch it in your browser + autohelix hint --run krp3 "…" tell the agent something (next iteration) + autohelix stop krp3 stop after this iteration + Ctrl-C here stops now (accepted work is kept) diff --git a/tests/snapshots/run-live-80.txt b/tests/snapshots/run-live-80.txt index 96734ca..7077c53 100644 --- a/tests/snapshots/run-live-80.txt +++ b/tests/snapshots/run-live-80.txt @@ -13,4 +13,8 @@ ✓ 3 2m 06s $0.32 35,310.7 753× 96 -20% ⠋ 4 1m 12s agent - autohelix view krp3 · hint --run krp3 "…" · stop krp3 · Ctrl-C now + from another terminal: + autohelix view krp3 watch it in your browser + autohelix hint --run krp3 "…" tell the agent something (next iteration) + autohelix stop krp3 stop after this iteration + Ctrl-C here stops now (accepted work is kept) diff --git a/tests/snapshots/run-piped.txt b/tests/snapshots/run-piped.txt index 46bcd28..b7f751b 100644 --- a/tests/snapshots/run-piped.txt +++ b/tests/snapshots/run-piped.txt @@ -5,7 +5,7 @@ Observe bench (speed ↑, mem_mb ↓) Scope editable: sort.py Budget 7 iterations · $10.00 · 30m each - Steer autohelix view krp3 · hint --run krp3 "…" · stop krp3 + Steer autohelix view krp3 · autohelix hint --run krp3 "…" · autohelix stop krp3 ──────────────────────────────────────────────────────────────────────────────────────────────── time cost speed ↑ mem_mb ↓ · base 46.9 120 @@ -25,7 +25,8 @@ mem_mb 120 → 95 -21% iter 6 run 7 iterations · 3 accepted · 38m 43s · $2.65 landed 3 commits on main - next autohelix view krp3 · autohelix resume krp3 - .autohelix/runs/20261115-1402-sorting-krp3/ + next autohelix view krp3 the run's page in your browser + autohelix resume krp3 one more iteration (-n N for more) + folder .autohelix/runs/20261115-1402-sorting-krp3/ page .autohelix/runs/20261115-1402-sorting-krp3/report.html summary .autohelix/runs/20261115-1402-sorting-krp3/report.md diff --git a/tests/snapshots/view-120.txt b/tests/snapshots/view-120.txt index 75299fa..887e4e2 100644 --- a/tests/snapshots/view-120.txt +++ b/tests/snapshots/view-120.txt @@ -23,6 +23,7 @@ mem_mb 120 → 95 -21% iter 6 run 7 iterations · 3 accepted · 38m 43s · $2.65 landed 3 commits on main - next autohelix resume krp3 · .autohelix/runs/20261115-1402-sorting-krp3/ + next autohelix resume krp3 one more iteration (-n N for more) + folder .autohelix/runs/20261115-1402-sorting-krp3/ page .autohelix/runs/20261115-1402-sorting-krp3/report.html summary .autohelix/runs/20261115-1402-sorting-krp3/report.md diff --git a/tests/snapshots/view-80.txt b/tests/snapshots/view-80.txt index c05b2c0..8638c59 100644 --- a/tests/snapshots/view-80.txt +++ b/tests/snapshots/view-80.txt @@ -24,6 +24,7 @@ mem_mb 120 → 95 -21% iter 6 run 7 iterations · 3 accepted · 38m 43s · $2.65 landed 3 commits on main - next autohelix resume krp3 · .autohelix/runs/20261115-1402-sorting-krp3/ + next autohelix resume krp3 one more iteration (-n N for more) + folder .autohelix/runs/20261115-1402-sorting-krp3/ page .autohelix/runs/20261115-1402-sorting-krp3/report.html summary .autohelix/runs/20261115-1402-sorting-krp3/report.md diff --git a/tests/test_console.py b/tests/test_console.py index 3a8bcda..5a779fa 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -288,10 +288,12 @@ def test_ending_after_landing(project, monkeypatch): assert ending[1] == " speed 3" # no accepted change measured it again assert ending[2].startswith(" run 1 iteration · 1 accepted") assert ending[3] == " landed 1 commit on main" - assert ending[4] == f" next autohelix view {short} · autohelix resume {short}" - assert ending[5] == f" .autohelix/runs/{run_id}/" # the run's folder: too long for the line above - assert ending[6].startswith(" page ") and ending[6].endswith(f"{run_id}/report.html") - assert len(ending) == 7 + # One command per line, with what it does in a column after the widest. + assert ending[4] == f" next autohelix view {short} the run's page in your browser" + assert ending[5] == f" autohelix resume {short} one more iteration (-n N for more)" + assert ending[6] == f" folder .autohelix/runs/{run_id}/" + assert ending[7].startswith(" page ") and ending[7].endswith(f"{run_id}/report.html") + assert len(ending) == 8 def test_ending_from_a_subfolder_names_the_run_folder_absolutely(project, monkeypatch): @@ -322,7 +324,9 @@ def test_ending_with_manual_landing(project): assert result.exit_code == 0, result.output ending = _ending(result.output) assert ending[2] == f" unlanded 1 commit on autohelix/{run_id} (manual landing)" - assert ending[3] == f" next autohelix view {short} · autohelix resume {short} · autohelix land {short}" + assert ending[3:6] == [f" next autohelix view {short} the run's page in your browser", + f" autohelix resume {short} one more iteration (-n N for more)", + f" autohelix land {short} put its commits on main"] def test_ending_when_landing_fails(project, monkeypatch): @@ -359,8 +363,8 @@ def test_an_error_heads_the_ending_then_landing_and_the_run_page(project): totals = next(i for i, line in enumerate(ending) if line.startswith(" run ")) assert " ".join(" ".join(ending[:totals]).split()) == f"Error {message}" # wrapped, not cut # Run from outside the project: the run's folder is absolute, as the page is. - assert [line.split()[0] for line in ending[totals:]] == ["run", "landed", "next", - f"{project / '.autohelix' / 'runs' / run_id}/", "page"] + assert [line.split()[0] for line in ending[totals:]] == ["run", "landed", "next", "autohelix", "folder", "page"] + assert ending[-2].split() == ["folder", f"{project / '.autohelix' / 'runs' / run_id}/"] assert result.output.count("Error") == 1 # not repeated by the CLI diff --git a/tests/test_live.py b/tests/test_live.py index 817e0fb..a8a0f37 100644 --- a/tests/test_live.py +++ b/tests/test_live.py @@ -348,8 +348,12 @@ def test_a_live_view_keeps_a_blank_line_at_the_bottom(tmp_path): log = W.LogFollower(tmp_path, None, Console(file=io.StringIO()), "test") data = (_running(_run_data(3), time.time()), W.run_table.Saved()) running = W.view_screen(data, log, {"state": "running", "phase": "agent", "iteration": 3}, 40).renderables - assert [line.plain for line in running[-2:]] == ["", ""] and running[-4].plain.startswith("Running") - assert running[-3].plain == 'Ctrl-C quits this view · autohelix stop test stops the run · hint --run test "…"' + assert [line.plain for line in running[-2:]] == ["", ""] and running[-7].plain.startswith("Running") + assert [line.plain for line in running[-6:-2]] == [ + "from another terminal:", + ' autohelix hint --run test "…" tell the agent something (next iteration)', + " autohelix stop test stop after this iteration", + "Ctrl-C here quits this view (the run goes on)"] stopped = W.view_screen((_run_data(3), W.run_table.Saved()), log, {"state": "finished"}, 40).renderables assert stopped[-1].plain.startswith("Finished") diff --git a/tests/test_runs.py b/tests/test_runs.py index 3ff2794..6670e6f 100644 --- a/tests/test_runs.py +++ b/tests/test_runs.py @@ -822,11 +822,11 @@ def agent(cwd, prompt, iteration): monkeypatch.setattr(harness, "run_agent", agent) harness.run(Budget(until=1), report=False) - out = " ".join(capsys.readouterr().out.replace(" · ", " ").split()) # the next line wraps + out = " ".join(capsys.readouterr().out.split()) run_id, short = harness.paths.run_id, short_id(harness.paths.run_id) assert f"unlanded 1 commit on autohelix/{run_id} (diverged from {target})" in out assert (f"next autohelix view {short} autohelix resume {short} git merge autohelix/{run_id} " - f".autohelix/runs/{run_id}/ page") in out + f"folder .autohelix/runs/{run_id}/ page") in out # too wide for the hints: none assert "changed during this segment" not in out and f"autohelix land {short}" not in out diff --git a/tests/test_snapshots.py b/tests/test_snapshots.py index c6ce661..f6a6066 100644 --- a/tests/test_snapshots.py +++ b/tests/test_snapshots.py @@ -63,7 +63,7 @@ def _header(width: int, budget: Budget, done: int = 0, show_mark: bool = True) - """`Harness._print_header`: piped (no mark), with the Steer field (no live row to show it under).""" title = terminal.title("run krp3", "sorting", terminal.clock(NOW), version="0.3.0") fields = terminal.run_fields(CONFIG, terminal.budget_text(budget, done)) - fields += [] if show_mark else [("Steer", terminal.steer_text("krp3", interrupt=False))] + fields += [] if show_mark else [("Steer", terminal.steer_text("krp3"))] return terminal.header(title, fields, width, show_mark) @@ -98,7 +98,7 @@ def live_screen(width: int) -> list: lines += table.add(row) from rich.text import Text - return lines + [table.live(4, 72, "agent"), Text(), terminal.steer_line("krp3", width)] + return lines + [table.live(4, 72, "agent"), Text(), *terminal.steer_lines("krp3", width)] def resume_screen(width: int) -> list: @@ -312,7 +312,8 @@ def test_view_says_what_waits_for_a_manual_landing(): run = {**_run_payload(False), "land": "manual", "landing": {"relation": "ahead", "commits": 3, "behind": 0, "fast_forward": True}} text = _text(view_lines({**PROJECT, "run": with_words(run)}, Saved(CONFIG, ROWS, []), 120, now=T)) assert " unlanded 3 commits on autohelix/20261115-1402-sorting-krp3 (manual landing)\n" in text - assert " next autohelix resume krp3 · autohelix land krp3\n" in text + assert (" next autohelix resume krp3 one more iteration (-n N for more)\n" + " autohelix land krp3 put its commits on main\n") in text def test_view_offers_git_merge_for_a_diverged_run(): @@ -324,7 +325,10 @@ def test_view_offers_git_merge_for_a_diverged_run(): "fast_forward": False}} text = _text(view_lines({**PROJECT, "run": with_words(run)}, Saved(CONFIG, ROWS, []), 140, now=T)) assert " unlanded 2 commits on autohelix/20261115-1402-sorting-krp3 (diverged from main)\n" in text - assert " next autohelix resume krp3 · git merge autohelix/20261115-1402-sorting-krp3\n" in text + # The hints line up after the `autohelix` commands; the longer merge has its own after it. + assert (" next autohelix resume krp3 one more iteration (-n N for more)\n" + " git merge autohelix/20261115-1402-sorting-krp3 merge its commits into main by hand\n" + ) in text assert "moved on" not in text and "autohelix land" not in text diff --git a/tests/test_viewer.py b/tests/test_viewer.py index 747a48e..f86af3d 100644 --- a/tests/test_viewer.py +++ b/tests/test_viewer.py @@ -612,11 +612,11 @@ def test_view_json_and_once(measured_project, monkeypatch): assert " Done iteration budget reached (2)" in lines assert " speed 100 → 120 +20% iter 2" in lines assert f" landed 2 commits on {data['branch']}" in lines - assert f" next autohelix resume {short_id(first)} · .autohelix/runs/{first}/" in lines + assert f" next autohelix resume {short_id(first)} one more iteration (-n N for more)" in lines + assert f" folder .autohelix/runs/{first}/" in lines manual = [line.rstrip() for line in _cli("view", second, "-p", project, "--once").output.splitlines()] assert f" unlanded 1 commit on autohelix/{second} (manual landing)" in manual # as run says it - assert (f" next autohelix resume {short_id(second)} · autohelix land {short_id(second)} · " - f".autohelix/runs/{second}/") in manual + assert f" autohelix land {short_id(second)} put its commits on {data['branch']}" in manual missing = _cli("view", "missing-zzzz", "-p", project, "--json") assert missing.exit_code == 1 and "missing-zzzz" in missing.output