diff --git a/CHANGELOG.md b/CHANGELOG.md index 0601a638..3ccaa546 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `do-epic --status` says which chunk asks you a question, and since when each parked chunk has awaited its gate. - do-epic moves a chunk's issue to done in Jira when the chunk finishes, and the split item it belongs to once its last sub-task is done, so no finished chunk starts again and the chunks it blocks start. It moves them by the transition `jira-finish-transition` and `jira-finish-status` name, so set both; without them a finishing chunk stops with that reason. - Describe do-epic in the README: its entry under Tools, and its machine settings and `repo-rule.md` under Set up a project. - do-epic finishes an epic: once none of its issues is open, a finishing chunk files a release review of each repo the epic changed, as an issue labelled `do-epic-release-review`, and asks you to confirm each goal. `do-epic --close-epic` then posts the summary piped in as a comment on the epic and closes it in Jira, by the transition `jira-finish-transition` names, to the status `jira-finish-status` names. diff --git a/bin/agent_cycle/tmux.py b/bin/agent_cycle/tmux.py index 704caaec..0af21917 100644 --- a/bin/agent_cycle/tmux.py +++ b/bin/agent_cycle/tmux.py @@ -51,6 +51,8 @@ class Listed: dead: bool # What its name says its parked chunk awaits, as the words after PARKED; empty for a chunk that isn't parked. awaits: str = "" + # Whether its name ended in WAITS: its loop asks the human something. + asks: bool = False @property def parked(self) -> bool: @@ -90,7 +92,7 @@ def listed(session: str, run: Tmux) -> list[Listed]: def as_listed(shown: str, id: str, pane_dead: str) -> Listed: """The window tmux shows under the name shown, with the ID id and `#{pane_dead}` as pane_dead.""" name, _, awaits = shown.removesuffix(WAITS).partition(PARKED) - return Listed(name, id, pane_dead == "1", awaits) + return Listed(name, id, pane_dead == "1", awaits, shown.endswith(WAITS)) def everywhere(run: Tmux) -> list[Placed]: diff --git a/bin/do_epic/main.py b/bin/do_epic/main.py index 8a0e928c..318028dc 100644 --- a/bin/do_epic/main.py +++ b/bin/do_epic/main.py @@ -9,7 +9,7 @@ import sys import typing from loop_claude.loop.chunk_start import archived_route, routed -from do_epic import chunk_prompt, findings, finish, gates, parked, scheduler, split +from do_epic import chunk_prompt, findings, finish, gates, parked, scheduler, split, status from do_epic.repo_pick import ClaudeWork, HumanTask, recorded, Repo from loop_claude.loop.close import closed_cycle from loop_claude.project.records import CONSEQUENCE, read_records @@ -53,7 +53,7 @@ A chunk whose worker ends its run while its pull request waits on its checks, an is parked: it frees its place for the next chunk, and its window's name says what it awaits. Its worker goes on once the checks pass, the approval comes or a reviewer comments, and a place is free; until one is, the name says `awaits a slot`. A parked chunk survives a reboot: run do-epic again to go on polling. ---status starts no chunk: it prints each open issue with whether its chunk runs, or why it waits. +--status doesn't start any chunk. It prints a line per open issue: that its chunk runs or asks you a question, or why it waits, such as the gate a parked chunk awaits and since when. {findings.HELP} {finish.HELP} The Jira site and its credentials are set in ~/.claude-projects/do-epic/config.toml.""" @@ -110,8 +110,8 @@ def main(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: def run(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: pathlib.Path, effects: Effects, backend: Backend, stdin: typing.TextIO, forge_at: typing.Callable[[str], Run]) -> Stop: chunk, words = (argv[1], argv[2:]) if len(argv) >= 2 and argv[0] == scheduler.CHUNK_FLAG else (None, argv) - status = chunk is None and words[1:] == [STATUS_FLAG] - words = words[:1] if status else words + status_asked = chunk is None and words[1:] == [STATUS_FLAG] + words = words[:1] if status_asked else words # What the words after the epic's key write into the epic, where they are a filing or a decision. writes = findings.parsed(words[1:]) if chunk is None else None closes = chunk is None and words[1:] == [finish.CLOSE] @@ -127,7 +127,7 @@ def run(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: return Stop(1, config.reason) store, record = backend(config, words[0]) epic = EpicRun(words[0], config, store, record, paths, env, launcher, effects, forge_at) - if status: + if status_asked: return status_printed(epic) return windows_opened(epic) if chunk is None else chunk_run(chunk, epic) @@ -135,7 +135,7 @@ def run(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: def status_printed(epic: EpicRun) -> Stop: """What `do-epic --status` does: prints a line per open issue, and doesn't start anything.""" issues = epic.store.read() - lines = issues if isinstance(issues, Failure) else scheduler.status(epic.key, epic.paths.home, issues, epic.effects.tmux) + lines = issues if isinstance(issues, Failure) else status.lines(epic.key, epic.paths.home, issues, epic.effects.tmux) return Stop(1, lines.reason) if isinstance(lines, Failure) else Stop(0, "\n".join(lines) or f"the epic {epic.key} has no open issue") diff --git a/bin/do_epic/scheduler.py b/bin/do_epic/scheduler.py index af65b832..843b2505 100644 --- a/bin/do_epic/scheduler.py +++ b/bin/do_epic/scheduler.py @@ -197,21 +197,3 @@ def resume(epic: Epic, repo: str, window: tmux.Window, run: tmux.Tmux) -> str | return None except OSError as failure: return f"cannot lock {failure.filename or epic.folder / LOCK}: {failure.strerror}" - - -def status(key: str, home: pathlib.Path, issues: list[EpicIssue], run: tmux.Tmux) -> list[str] | Failure: - """A line per open issue of the epic called key, in the tracker's rank order: that its chunk runs, or why it waits. It doesn't start anything and checks no limit, so the line of a chunk that has yet to start doesn't say which limit holds it back.""" - found, waits = chunks(issues) - parked = parked_chunks(home / STATE / key) - if isinstance(parked, Failure): - return parked - windows = tmux.listed(tmux.session_name(tmux.EPIC, key), run) - live = {window.name: window for window in windows if not window.dead} - again = f"run `do-epic {key}` to start it again" - reasons = {wait.issue: wait.reason for wait in waits} - for chunk in found: - if chunk.issue in parked: - reasons[chunk.issue] = parked[chunk.issue].waits(live[chunk.issue].awaits) if chunk.issue in live else f"{parked[chunk.issue].waits('')}, and its window stopped; {again}" - elif chunk.issue not in live: - reasons[chunk.issue] = f"its window stopped; {again}" if chunk.issue in {window.name for window in windows} else f"it has not started; `do-epic {key}` starts it once the epic and its repo have room" - return [f"{issue.key} waits: {reasons[issue.key]}" if issue.key in reasons else f"{issue.key} runs" for issue in issues if issue.key in reasons or issue.key in live] diff --git a/bin/do_epic/status.py b/bin/do_epic/status.py new file mode 100644 index 00000000..6098a621 --- /dev/null +++ b/bin/do_epic/status.py @@ -0,0 +1,48 @@ +"""What `do-epic --status` prints: a line per open issue of the epic (docs/decisions.md → `do-epic: drives one Jira epic …`).""" +import datetime +import pathlib + +from do_epic.scheduler import chunks, STATE +from do_epic.backend.protocol import EpicIssue +from failure import Failure +from do_epic.parked import file_of, Parked, parked_chunks, SLOT +from agent_cycle import tmux + + +def since(folder: pathlib.Path, chunk: Parked) -> str: + """`, since