Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<id>/` (`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/<id>/` (`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/<id>/.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/<id>/` one run)
Expand Down
20 changes: 12 additions & 8 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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/<id> (manual landing)`, or `(diverged from main)` when the run diverged from its target), what to type next (`autohelix land`, or `git merge autohelix/<id>` 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/<id>/.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.

Expand Down
13 changes: 7 additions & 6 deletions scripts/console_screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"))
Expand All @@ -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)

Expand Down
9 changes: 5 additions & 4 deletions src/autohelix/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]}")]
Expand Down
18 changes: 9 additions & 9 deletions src/autohelix/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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])):
Expand Down
2 changes: 1 addition & 1 deletion src/autohelix/run_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Loading
Loading