Answer principles round 1: 0 🔴, 6 🟡; read the plan from the fetched default branch for routing and the preflight alike and drop the fast-forward, name no item where the release after the last tag has none, tell an empty items table from none, time out the fetch, return run_python's errors as exit codes, test the error paths and the gh rows, assert facts in place of sentences, keep the open-PR sentence in every fresh prompt, name the item branch in CLAUDE.md, and measure item 175 against five chunks with counter-signals
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
"""The lines the preflight prints, stated from what it gathered."""
|
||||
from todo_table import bundle_candidates, Item
|
||||
from failure import Failure
|
||||
from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, Plan, pulls_command, Ran, Release
|
||||
from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, NoItem, Plan, PULLS_LIST, Ran, Release, version
|
||||
from markdown_text import quoted, sections
|
||||
|
||||
|
||||
def render(found: Gathered) -> list[str]:
|
||||
"""One `- ` line per fact, then the item's tagline and detail, and what each tool printed."""
|
||||
note = [f"- {found.note}"] if found.note else []
|
||||
checkout = f"- The checkout was not fast-forwarded: {found.kept_as_is}" if found.kept_as_is else f"- The checkout was fast-forwarded to {found.default}."
|
||||
head = [*note, checkout, f"- {last_release(found.default, found.release)}"]
|
||||
if isinstance(found.item, str):
|
||||
return [*head, f"- No plan item: {found.item}, so no worktree was made."]
|
||||
return [*head, *item_lines(found.item)]
|
||||
head = [*note, f"- {last_release(found.default, found.release)}"]
|
||||
if isinstance(found.item, NoItem):
|
||||
return [*head, f"- No plan item: {found.item.why} No worktree was made."]
|
||||
return [*head, *item_lines(found.default, found.item)]
|
||||
|
||||
|
||||
def last_release(default: str, release: Release) -> str:
|
||||
@@ -22,9 +21,10 @@ def last_release(default: str, release: Release) -> str:
|
||||
entries = unreleased_entries(release.changelog) if isinstance(release.changelog, str) else None
|
||||
if entries is not None:
|
||||
return f"{cut} Unreleased: {counted(entries, 'entry', 'entries')} under CHANGELOG.md → ## Unreleased."
|
||||
commits = release.commits.reason if isinstance(release.commits, Failure) else counted(release.commits, "commit", "commits")
|
||||
since = f"since {release.tag}" if release.tag else f"on {default}"
|
||||
return f"{cut} Unreleased: {commits} {since}, and no ## Unreleased in CHANGELOG.md."
|
||||
commits = f"the commits {since} cannot be counted: {release.commits.reason}" if isinstance(release.commits, Failure) else f"{counted(release.commits, 'commit', 'commits')} {since}"
|
||||
changelog = f"CHANGELOG.md cannot be read: {release.changelog.reason}" if isinstance(release.changelog, Failure) else "no ## Unreleased in CHANGELOG.md"
|
||||
return f"{cut} Unreleased: {commits}; {changelog}."
|
||||
|
||||
|
||||
def unreleased_entries(changelog: str) -> int | None:
|
||||
@@ -33,11 +33,11 @@ def unreleased_entries(changelog: str) -> int | None:
|
||||
return None if found is None else sum(line.startswith("- ") for line in found[0].splitlines())
|
||||
|
||||
|
||||
def item_lines(item: ItemFacts) -> list[str]:
|
||||
def item_lines(default: str, item: ItemFacts) -> list[str]:
|
||||
first = item.plan.first
|
||||
worktree = item.worktree.reason if isinstance(item.worktree, Failure) else f"{item.worktree.path}, {item.worktree.how}"
|
||||
return [
|
||||
f"- Next release, in the checkout's todo.md: {release_name(first)}. Its first item that does not wait: item {first.id}, {levels(first)}.",
|
||||
f"- The earliest release in {default}'s todo.md: {version(first.release)}. Its first item that does not wait: item {first.id}, {levels(first)}.",
|
||||
f"- Worktree: {worktree}",
|
||||
f"- Open pull requests from {item.plan.branch}: {pulls_text(item.pulls, item.plan.branch)}",
|
||||
*bundled(item.plan),
|
||||
@@ -52,7 +52,7 @@ def pulls_text(pulls: tuple[Forge, Ran | Failure] | None, branch: str) -> str:
|
||||
if pulls is None:
|
||||
return "none, as the checkout has no origin remote."
|
||||
forge, done = pulls
|
||||
shown = " ".join(pulls_command(forge, branch)[:3])
|
||||
shown = " ".join(PULLS_LIST[forge])
|
||||
if isinstance(done, Failure):
|
||||
return f"cannot be listed: `{shown}` {done.reason}"
|
||||
if done.code:
|
||||
@@ -71,9 +71,9 @@ def open_pulls(stdout: str, forge: Forge, branch: str) -> list[str]:
|
||||
def bundled(plan: Plan) -> list[str]:
|
||||
first, candidates = plan.first, bundle_candidates(plan.items, plan.first)
|
||||
if not candidates:
|
||||
return [f"- No other item of release {release_name(first)} may join item {first.id}'s chunk."]
|
||||
listed = [f" - item {item.id}, {levels(item)}, S {item.scores.get('S', 'unscored')}: {item.tagline}" for item in candidates]
|
||||
return [f'- The items of release {release_name(first)} that may join the chunk of item {first.id}, where `~/.claude/CLAUDE.md` → "Working loop" lets them share it:', *listed]
|
||||
return [f"- No other item of release {version(first.release)} may join item {first.id}'s chunk."]
|
||||
listed = [f" - item {item.id}, {levels(item)}, S {item.scores['S']}: {item.tagline}" for item in candidates]
|
||||
return [f'- The items of release {version(first.release)} that may join the chunk of item {first.id}, where `~/.claude/CLAUDE.md` → "Working loop" lets them share it:', *listed]
|
||||
|
||||
|
||||
def named_lines(named: list[NamedPath] | Failure) -> list[str]:
|
||||
@@ -104,9 +104,5 @@ def levels(item: Item) -> str:
|
||||
return f"L {item.likelihood or 'unscored'}, E + I {item.escape_and_impact or 'unscored'}"
|
||||
|
||||
|
||||
def release_name(item: Item) -> str:
|
||||
return ".".join(map(str, item.release))
|
||||
|
||||
|
||||
def counted(count: int, one: str, many: str) -> str:
|
||||
return f"{count} {one if count == 1 else many}"
|
||||
|
||||
Reference in New Issue
Block a user