From 246bad04cbba86c67bee54cca05792a0e8a04a4b Mon Sep 17 00:00:00 2001 From: deepslit <731369471@qq.com> Date: Fri, 4 Dec 2026 23:08:17 +0800 Subject: [PATCH 01/28] fix(docs): rewrite unmirrored website relative links to GitHub Signed-off-by: deepslit <731369471@qq.com> --- CHANGELOG.md | 5 + KNOWN_ISSUES.md | 3 +- docs/ARCHITECTURE.md | 2 +- docs/CHARACTER.md | 2 +- docs/USAGE.md | 4 +- scripts/ci/generate_website_docs.py | 147 +++++++++++++------- tests/scripts/test_generate_website_docs.py | 92 +++++++++++- website/docs/ACCOUNT_SAFETY.md | 6 +- website/docs/ARCHITECTURE.md | 20 +-- website/docs/BROWSER_MODES.md | 8 +- website/docs/CHARACTER.md | 14 +- website/docs/CONFIGURATION.md | 4 +- website/docs/DATA_LAYER.md | 16 +-- website/docs/DEBUGGING.md | 8 +- website/docs/DEVELOPMENT.md | 22 +-- website/docs/E2E_TESTING.md | 4 +- website/docs/ERRORS.md | 2 +- website/docs/INSTRUCTIONS.md | 2 +- website/docs/KNOWN_ISSUES.md | 5 +- website/docs/MCP.md | 8 +- website/docs/MEDIA_LIBRARY.md | 6 +- website/docs/MOVIE.md | 4 +- website/docs/PROMPT_EXPANSION.md | 12 +- website/docs/SECURITY.md | 4 +- website/docs/TOOLS.md | 16 +-- website/docs/USAGE.md | 22 +-- 26 files changed, 292 insertions(+), 146 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebfffff2c..45248f251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Published documentation now links to GitHub for repository files and directories outside + the site mirror. CI reports broken relative links with their page and line number (#1755). + ## [0.114.0] — 2026-12-04 ### Added diff --git a/KNOWN_ISSUES.md b/KNOWN_ISSUES.md index 8b113e77a..bb59f0117 100644 --- a/KNOWN_ISSUES.md +++ b/KNOWN_ISSUES.md @@ -794,8 +794,7 @@ endpoint, a different surface from the `labs.google` tRPC API. > because it sends cookies but not that token. The `gflow scene` groundwork now > fetches+caches the token and attaches the Bearer to the **`page.request` REST > path** (`_post_json` / `_patch_json`, host-scoped to `aisandbox-pa`) so -> `uploadImage` / `scenes` / `commit` authenticate — see -> [`docs/superpowers/plans/2026-05-31-l0-bearer-pivot.md`](docs/superpowers/plans/2026-05-31-l0-bearer-pivot.md). +> `uploadImage` / `scenes` / `commit` authenticate. > **Live-verified 2026-05-31:** REST `uploadImage` returns 200 > (`tests/e2e/test_aisandbox_auth_live.py`, credit-free). > **Liberating follow-up:** the same Bearer likely unlocks the `evaluate_fetch` diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index af64fe9b6..265b78c97 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -326,7 +326,7 @@ Process-boundary contextvars bind once: `correlation_id` (UUID4 per CLI invocati Format defaults to **human-readable on TTY**, **JSON when piped or `GFLOW_CLI_LOG_FORMAT=json`**. JSON exceptions use `structlog.tracebacks.ExceptionDictTransformer(show_locals=False)` so frame locals (which may contain auth cookies and signed URLs) are never serialized. TEXT exceptions are formatted by `ConsoleRenderer` with `structlog.dev.plain_traceback`, which omits frame locals; its default Rich formatter would print them. -Pipes cleanly into `jq` / Loki / Datadog without configuration. See [`docs/USER_GUIDE.md` § Journey 6](USER_GUIDE.md#journey-6--read-the-structured-logs) for `jq` recipes. +Pipes cleanly into `jq` / Loki / Datadog without configuration. See [`docs/USER_GUIDE.md` § Journey 6](USER_GUIDE.md#journey-6--reading-structured-logs-jq-recipes) for `jq` recipes. ## Incident diagnostics (shipped, v0.43.0) diff --git a/docs/CHARACTER.md b/docs/CHARACTER.md index 35daa65bf..ea35330d2 100644 --- a/docs/CHARACTER.md +++ b/docs/CHARACTER.md @@ -3,7 +3,7 @@ > **Status:** SHIPPED (live-verified 2026-06-02) · **Issue:** [#145](https://github.com/ffroliva/gflow-cli/issues/145) · **Branch:** `feature/character-creation` > **Living document.** Evolve this as the feature and Flow's API evolve. Raw capture provenance lives in > [`CHARACTER_RECON.md`](CHARACTER_RECON.md); the cross-feature decision lens is -> [the REST-path capability matrix](#capability--cost). +> [the REST-path capability matrix](#3-capability--cost). > **Credit:** pattern-references @kittinan's avatar PR #123 (attach-flow idiom + CLI scaffolding shape) — but > built **greenfield off `develop`, NOT stacked on #123** (that branch is CONFLICTING and likeness-specific; > see [Design decisions](#11-design-decisions-post-predict)). diff --git a/docs/USAGE.md b/docs/USAGE.md index 3edb4832f..030564091 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -923,7 +923,7 @@ All prompts in a batch share one Flow project. The editor is opened once and sta - `MAX_BATCH_PROMPTS = 5` (defined in `src/gflow_cli/image_batch.py`). To raise, edit the constant. -### Exit codes +### Batch exit codes - `0` — all rows succeeded. - `1` — invalid manifest (file not found, parse error, unknown aspect/model). @@ -1142,7 +1142,7 @@ gflow video i2v ./hero.png "Slow camera arc, soft golden light" Local frame files follow the [`gflow image upload`](#gflow-image-upload) rules (header check, 20 MB cap), and a UUID must be catalogued in the same `--project` (exit 36 otherwise, see -[exit codes](#exit-codes-1)). Start+end submits were measured with Veo 3.1 Fast and Lite, and with +[exit codes](#exit-codes)). Start+end submits were measured with Veo 3.1 Fast and Lite, and with Omni 1.2 (which accepts at most 10 s with an end frame); Veo 3.1 Quality uses the same key family as Fast but was not run live (#1594). Whether the two frames must share an aspect ratio has not been measured (#1603). diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index c50581cb5..28fd01cae 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -18,9 +18,12 @@ from __future__ import annotations +import posixpath import re import sys +from collections.abc import Iterator from pathlib import Path +from urllib.parse import quote, unquote, urlsplit _REPO = Path(__file__).resolve().parents[2] _DOCS = _REPO / "docs" @@ -59,17 +62,6 @@ # maintainer's email in SECURITY's reporting table becomes actionable GitHub # private-reporting steps, not a placeholder address. FILE_OVERRIDES: dict[str, tuple[tuple[str, str], ...]] = { - # The RPC catalog is a contributor reference and is not mirrored; link it on GitHub. - "E2E_TESTING.md": ( - ( - "](FLOW_WIRE_RPCS.md)", - "](https://github.com/ffroliva/gflow-cli/blob/main/docs/FLOW_WIRE_RPCS.md)", - ), - ( - "](superpowers/spikes/", - "](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/", - ), - ), # The privacy notice must name its controller; the site names the public handle, not # the private name the token pass would otherwise mangle into "your.name Oliva". "TELEMETRY.md": ( @@ -114,51 +106,96 @@ def _source_for(dest_name: str) -> Path | None: return None -_GITHUB_DOCS_BLOB = "https://github.com/ffroliva/gflow-cli/blob/main/docs/" +_FENCE = re.compile(r"^[ \t>]*(`{3,}|~{3,})(.*)") +_CODE_SPAN = re.compile(r"(?\n]+)>|((?:[^\s()]|\([^()\s]*\))+))(?=\s|\))") + +def _mask_code(text: str) -> str: + """Hide code without shifting the positions of link destinations in the source.""" + lines = [] + fence = "" + for line in text.splitlines(keepends=True): + marker = _FENCE.match(line) + inside = bool(fence) + if marker: + run, info = marker.groups() + if fence and run.startswith(fence) and not info.strip(): + fence = "" + elif not fence and (run.startswith("~") or "`" not in info): + fence = run + lines.append(re.sub(r"[^\n]", " ", line) if inside or fence else line) + return _CODE_SPAN.sub(lambda m: " " * len(m[0]), "".join(lines)) -def _rewrite_root_doc_links(text: str) -> str: - """Repo-root canonical files (KNOWN_ISSUES.md) link sibling docs as - ``docs/X.md``; mirrored into ``website/docs/`` that resolves to a - nonexistent ``docs/docs/`` path (#507). Targets that are themselves - mirrored become sibling-relative links; everything else (release - evidence, recon specs, plans — deliberately unpublished) becomes an - absolute GitHub link so the published page never 404s.""" - def repl(match: re.Match[str]) -> str: - target = match.group(1) - path_part = target.split("#", 1)[0] - if "/" not in path_part and (_WEB / path_part).is_file(): - return f"]({target})" - return f"]({_GITHUB_DOCS_BLOB}{target})" +def _relative_links(text: str) -> Iterator[tuple[int, int, str]]: + """Yield (start, end, target), including both destinations in a linked image.""" + prose = _mask_code(text) + depth = 0 + for bracket in re.finditer(r"\\[\\\[\]]|\[|\]|\n[ \t]*\n", prose): + if bracket[0] == "[": + depth += 1 + elif bracket[0].startswith("\n"): + depth = 0 + elif bracket[0] == "]" and depth: + depth -= 1 + match = _DESTINATION.match(prose, bracket.end()) + if match: + start, end = match.span(1 if match[1] is not None else 2) + target = text[start:end] + if not target.startswith("/") and not urlsplit(target).scheme: + yield start, end, target - return re.sub(r"\]\(docs/([^)]+)\)", repl, text) + +def _site_files() -> set[str]: + # URLs are case-sensitive even on Windows (docs/INDEX.md and the bespoke index.md). + return {p.relative_to(_WEB).as_posix() for p in _WEB.rglob("*") if p.is_file()} + + +def _site_link(target: str, source_dir: Path, dest_dir: Path, published: dict[Path, Path]) -> str: + url = urlsplit(target) + site_path = url.path + if site_path: + canonical = (source_dir / unquote(site_path)).resolve() + destination = published.get(canonical) + if destination is not None: + site_path = quote(posixpath.relpath(destination.as_posix(), dest_dir.as_posix())) + elif canonical.exists(): + if not canonical.is_relative_to(_REPO): + return target + kind = "tree" if canonical.is_dir() else "blob" + path = quote(canonical.relative_to(_REPO).as_posix()) + suffix = target.removeprefix(url.path) # Keep GitHub's query and fragment verbatim. + return f"https://github.com/ffroliva/gflow-cli/{kind}/main/{path}{suffix}" + elif (dest_dir / unquote(site_path)).resolve() not in published: + return target # Leave the unresolved destination intact for --check. + return url._replace(path=site_path, fragment=re.sub("-{2,}", "-", url.fragment)).geturl() def render(dest_name: str, source_text: str) -> str: - """Apply per-file overrides, root-link rewriting, then the global token map.""" + """Apply per-file overrides, resolve published links, then anonymize.""" text = source_text for old, new in FILE_OVERRIDES.get(dest_name, ()): if old not in text: msg = f"{dest_name}: override target not found (canonical changed?): {old[:60]!r}" raise ValueError(msg) text = text.replace(old, new) - if _source_for(dest_name) == _REPO / dest_name: - text = _rewrite_root_doc_links(text) - else: - # docs/X.md links a mirrored root file as ../NAME.md; on the site it is a sibling. - text = re.sub( - r"\]\(\.\./([^/)#?]+\.md)", - lambda m: f"]({m.group(1)}" if (_WEB / m.group(1)).is_file() else m.group(0), - text, - ) - # MkDocs' toc slug collapses a run of hyphens that GitHub keeps (`Ports & adapters` is - # `ports--adapters` on GitHub, `ports-adapters` on the site). Relative links only. - text = re.sub( - r"\]\((?!https?:)([^)#\s]*)#([^)\s]+)\)", - lambda m: f"]({m.group(1)}#{re.sub('-{2,}', '-', m.group(2))})", - text, - ) + source = _source_for(dest_name) or _DOCS / dest_name + dest_dir = (_WEB / dest_name).parent + published: dict[Path, Path] = {} + for name in _site_files(): + destination = _WEB / name + published[destination] = destination + if canonical := _source_for(name): + published[canonical] = destination + pieces = [] + previous = 0 + for start, end, target in _relative_links(text): + pieces.append(text[previous:start]) + pieces.append(_site_link(target, source.parent, dest_dir, published)) + previous = end + pieces.append(text[previous:]) + text = "".join(pieces) for pattern, repl in TOKEN_SUBS: text = pattern.sub(repl, text) return text @@ -171,7 +208,7 @@ def _mirrored_targets() -> list[Path]: for path in sorted(_WEB.rglob("*")): if not path.is_file() or path.suffix.lower() not in (".md", ".html"): continue - if _source_for(path.name) is not None: + if _source_for(path.relative_to(_WEB).as_posix()) is not None: targets.append(path) return targets @@ -197,14 +234,27 @@ def _nav_orphans() -> list[str]: return sorted(p.name for p in _WEB.glob("*.md") if p.name not in nav and p.name != "index.md") +def _unresolved_relative_links() -> Iterator[str]: + site_files = _site_files() + for page in sorted(_WEB.rglob("*.md")): + text = page.read_text(encoding="utf-8") + for start, _, target in _relative_links(text): + path = unquote(urlsplit(target).path) + parent = page.parent.relative_to(_WEB).as_posix() + if path and posixpath.normpath(posixpath.join(parent, path)) not in site_files: + line = text.count("\n", 0, start) + 1 + yield f"UNRESOLVED-LINK: {page.relative_to(_REPO).as_posix()}:{line}: {target}" + + def main(argv: list[str]) -> int: check = "--check" in argv drift: list[str] = [] written = 0 for dest in _mirrored_targets(): - source = _source_for(dest.name) + name = dest.relative_to(_WEB).as_posix() + source = _source_for(name) assert source is not None # _mirrored_targets guarantees it - rendered = render(dest.name, source.read_text(encoding="utf-8")) + rendered = render(name, source.read_text(encoding="utf-8")) current = dest.read_text(encoding="utf-8") if rendered == current: continue @@ -216,7 +266,8 @@ def main(argv: list[str]) -> int: if check: orphans = _nav_orphans() - if drift or orphans: + unresolved = list(_unresolved_relative_links()) + if drift or orphans or unresolved: if drift: print("website/docs mirror is stale — regenerate with:") print(" python scripts/ci/generate_website_docs.py") @@ -224,6 +275,8 @@ def main(argv: list[str]) -> int: print(f" DRIFT: {d}") for o in orphans: print(f" NAV-ORPHAN: {o} is published but absent from website/mkdocs.yml nav") + for problem in unresolved: + print(problem) return 1 print(f"website/docs mirror in sync ({len(_mirrored_targets())} files), nav complete.") return 0 diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index 184a05ef3..7155a23c5 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -102,7 +102,7 @@ def test_a_docs_link_to_a_mirrored_root_file_becomes_a_sibling_link() -> None: so `../` would leave the docs tree (PR #1237 review). Fragment and query survive.""" out = _gen.render("USAGE.md", "see [KI](../KNOWN_ISSUES.md#a-b) and [C](../CHANGELOG.md)") assert "](KNOWN_ISSUES.md#a-b)" in out - assert "](../CHANGELOG.md)" in out # not mirrored: left as it was + assert "](https://github.com/ffroliva/gflow-cli/blob/main/CHANGELOG.md)" in out def test_a_relative_anchor_takes_the_mkdocs_slug() -> None: @@ -113,3 +113,93 @@ def test_a_relative_anchor_takes_the_mkdocs_slug() -> None: assert "](#ports-adapters)" in out assert "](USER_GUIDE.md#a-b)" in out assert "](https://github.com/x#a--b)" in out + + +@pytest.mark.parametrize( + ("source", "target", "expected"), + [ + ("SYNTHETIC.md", "../PLAN.md#phase--7", "blob/main/PLAN.md#phase--7"), + ("USAGE.md", "../src/gflow_cli/cli.py", "blob/main/src/gflow_cli/cli.py"), + ("USAGE.md", "../src/gflow_cli/mcp/", "tree/main/src/gflow_cli/mcp"), + ("USAGE.md", "FLOW_WIRE_RPCS.md", "blob/main/docs/FLOW_WIRE_RPCS.md"), + ( + "USAGE.md", + "superpowers/spikes/2026-11-10-rpc-descriptor-churn.md", + "blob/main/docs/superpowers/spikes/2026-11-10-rpc-descriptor-churn.md", + ), + ("KNOWN_ISSUES.md", "PLAN.md", "blob/main/PLAN.md"), + ( + "KNOWN_ISSUES.md", + "docs/INDEX.md#topic--shortcuts", + "blob/main/docs/INDEX.md#topic--shortcuts", + ), + ], +) +def test_repository_links_use_the_canonical_target(source: str, target: str, expected: str) -> None: + assert _gen.render(source, f"[`ref`]({target})") == ( + f"[`ref`](https://github.com/ffroliva/gflow-cli/{expected})" + ) + + +def test_root_source_links_to_mirrored_page_and_site_asset() -> None: + text = "[Guide](docs/USER_GUIDE.md?q=1#a--b) [CSS](website/docs/stylesheets/extra.css)" + assert _gen.render("KNOWN_ISSUES.md", text) == ( + "[Guide](USER_GUIDE.md?q=1#a-b) [CSS](stylesheets/extra.css)" + ) + + +def test_nested_site_assets_resolve_relative_to_the_published_page( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + docs = tmp_path / "docs" + web = tmp_path / "website" / "docs" + for base in (docs, web): + (base / "images").mkdir(parents=True) + (base / "images" / "diagram.svg").touch() + monkeypatch.setattr(_gen, "_REPO", tmp_path) + monkeypatch.setattr(_gen, "_DOCS", docs) + monkeypatch.setattr(_gen, "_WEB", web) + text = "![diagram](../images/diagram.svg#a--b) and [missing](absent.md#a--b)" + assert _gen.render("guides/example.md", text) == ( + "![diagram](../images/diagram.svg#a-b) and [missing](absent.md#a--b)" + ) + + +def test_link_examples_in_inline_code_and_fences_are_literal() -> None: + example = "[plan](../PLAN.md) [anchor](#a--b)" + literal = ( + f"`{example}` and ``a ` {example}``\n" + f"````md\n```\n{example}\n````\n" + f"> ~~~markdown\n> {example}\n> ~~~~\n" + ) + assert _gen.render("USAGE.md", literal + "[`real`](#a--b)") == literal + "[`real`](#a-b)" + + +@pytest.mark.parametrize( + "scheme", ["http", "https", "mailto", "tel", "data", "gflow", "capabilities"] +) +def test_non_file_schemes_keep_their_fragments(scheme: str) -> None: + text = f"[example]({scheme}:example#a--b)" + assert _gen.render("SYNTHETIC.md", text) == text + + +def test_check_reports_unresolved_links_on_bespoke_pages( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str] +) -> None: + web = tmp_path / "website" / "docs" + web.mkdir(parents=True) + monkeypatch.setattr(_gen, "_REPO", tmp_path) + monkeypatch.setattr(_gen, "_DOCS", tmp_path / "docs") + monkeypatch.setattr(_gen, "_WEB", web) + (web.parent / "private.txt").touch() + (web / "index.md").write_text( + "```md\n[example](missing.md)\n```\n`[example](missing.md)`\n" + "[bad](missing.md#a--b) and [outside](../private.txt)\n[case](INDEX.md)\n", + encoding="utf-8", + ) + assert _gen.main(["--check"]) == 1 + assert capsys.readouterr().out.splitlines() == [ + "UNRESOLVED-LINK: website/docs/index.md:5: missing.md#a--b", + "UNRESOLVED-LINK: website/docs/index.md:5: ../private.txt", + "UNRESOLVED-LINK: website/docs/index.md:6: INDEX.md", + ] diff --git a/website/docs/ACCOUNT_SAFETY.md b/website/docs/ACCOUNT_SAFETY.md index f13718d31..1ec30f8e3 100644 --- a/website/docs/ACCOUNT_SAFETY.md +++ b/website/docs/ACCOUNT_SAFETY.md @@ -10,7 +10,7 @@ > five files, so a reasonable person could not find it before deciding to install > ([#602](https://github.com/ffroliva/gflow-cli/issues/602)). -Read [DISCLAIMER.md](../DISCLAIMER.md) first — it is the legal statement. This +Read [DISCLAIMER.md](https://github.com/ffroliva/gflow-cli/blob/main/DISCLAIMER.md) first — it is the legal statement. This page is the operational one. ## Two different things people mean by "will I get banned?" @@ -30,7 +30,7 @@ evidence of absence, and Google's terms are Google's to enforce. The cost model matters too: **credits are only spent on Veo video.** Images and composition operations bill against a per-model daily quota rather than credits, so most failure modes cost you nothing but time — see the cost note in the -[README](../README.md#why-gflow-cli). +[README](https://github.com/ffroliva/gflow-cli/blob/main/README.md#why-gflow-cli). ## What gflow-cli does to stay unremarkable @@ -46,7 +46,7 @@ headed, except `video extend` on flow.google.com, the page fallback of `media tr `media restore`, the video download-menu upscales (4K unmeasured), image-to-image from one local `--ref` file in an existing project on an otherwise direct request, a credit-capped text-to-video of an explicit measured key, reference-to-video from one local image, and a `movie run` with no characters and no instruction cards, which run headless under `auto` (`GFLOW_CLI_TRANSPORT=ui_automation` keeps them headed); `GFLOW_CLI_BROWSER_VISIBILITY=headed` shows the window for every command. The per-command list is in [BROWSER_MODES](BROWSER_MODES.md). The headless mint was measured as accepted on two accounts on Windows -([spike](superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md)); macOS, +([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md)); macOS, Linux and accounts Flow serves on labs.google are unmeasured. **Except credit reads.** On Windows and Linux, `gflow credits` and `gflow_get_credits` send diff --git a/website/docs/ARCHITECTURE.md b/website/docs/ARCHITECTURE.md index 34c492dbd..cd74f0f0d 100644 --- a/website/docs/ARCHITECTURE.md +++ b/website/docs/ARCHITECTURE.md @@ -1,6 +1,6 @@ # Architecture -This document is the steady-state reference for how `gflow-cli` is organised. The intent and sequencing live in [PLAN.md](../PLAN.md) — this file describes the **shape** that PLAN converges on. +This document is the steady-state reference for how `gflow-cli` is organised. The intent and sequencing live in [PLAN.md](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md) — this file describes the **shape** that PLAN converges on. ## Layers @@ -72,7 +72,7 @@ The hexagonal target above is the steady state. The **current** package — and **Phase 4 does NOT:** - Restructure existing modules beyond minimal dedup (shared CLI helpers were promoted to `gflow_cli._cli_helpers` at the package top level — kept flat to avoid a `cli.py` file / `cli/` package collision). -- Introduce dependency-injection containers, command/query buses, or any DDD/CQRS scaffolding (deferred per [PLAN ADR #2](../PLAN.md#5-decision-log-adrs-in-miniature)). +- Introduce dependency-injection containers, command/query buses, or any DDD/CQRS scaffolding (deferred per [PLAN ADR #2](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md#5-decision-log-adrs-in-miniature)). **v0.6.0a2 module additions — auth strategy package:** @@ -120,8 +120,8 @@ When the project converges on the hexagonal target above, modules graduate to la ## Folder layout > **Note: this document describes the TARGET architecture, not the current -> package layout.** The current shape (per [PLAN.md § 2](../PLAN.md#2-architecture-steady-state) -> and [ADR #2](../PLAN.md#5-decision-log-adrs-in-miniature)) is the simpler +> package layout.** The current shape (per [PLAN.md § 2](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md#2-architecture-steady-state) +> and [ADR #2](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md#5-decision-log-adrs-in-miniature)) is the simpler > `src/gflow_cli/{_errors/, api/, auth/, data/, flow_selectors/, mcp/, services/, tools/, > ui/, worker/}` packages plus flat modules — the `cli*.py` adapters, `_cli_helpers.py`, > `_win_owner_only.py`, `browser_manager.py`, `chain*.py`, `composition.py`, `config.py`, @@ -326,7 +326,7 @@ Process-boundary contextvars bind once: `correlation_id` (UUID4 per CLI invocati Format defaults to **human-readable on TTY**, **JSON when piped or `GFLOW_CLI_LOG_FORMAT=json`**. JSON exceptions use `structlog.tracebacks.ExceptionDictTransformer(show_locals=False)` so frame locals (which may contain auth cookies and signed URLs) are never serialized. TEXT exceptions are formatted by `ConsoleRenderer` with `structlog.dev.plain_traceback`, which omits frame locals; its default Rich formatter would print them. -Pipes cleanly into `jq` / Loki / Datadog without configuration. See [`docs/USER_GUIDE.md` § Journey 6](USER_GUIDE.md#journey-6-read-the-structured-logs) for `jq` recipes. +Pipes cleanly into `jq` / Loki / Datadog without configuration. See [`docs/USER_GUIDE.md` § Journey 6](USER_GUIDE.md#journey-6-reading-structured-logs-jq-recipes) for `jq` recipes. ## Incident diagnostics (shipped, v0.43.0) @@ -421,8 +421,8 @@ The dependency direction is inviolate. Everything else is preference, not religi ## See also -- [PLAN.md](../PLAN.md) — phasing, exit criteria, ADRs -- [CONTRIBUTING.md](../CONTRIBUTING.md) — TDD discipline, test categories +- [PLAN.md](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md) — phasing, exit criteria, ADRs +- [CONTRIBUTING.md](https://github.com/ffroliva/gflow-cli/blob/main/CONTRIBUTING.md) — TDD discipline, test categories - [AUTHENTICATION.md](AUTHENTICATION.md) — full auth flow lifecycle --- @@ -454,7 +454,7 @@ The dependency direction is inviolate. Everything else is preference, not religi aisandbox-pa.googleapis.com (Google's private Flow API) ``` -The `Provider` interface keeps backends interchangeable. v0.1 shipped `FlowProvider`. Google's separately billed Gemini / Vertex AI generation APIs are out of scope ([ROADMAP](../ROADMAP.md#out-of-scope)). +The `Provider` interface keeps backends interchangeable. v0.1 shipped `FlowProvider`. Google's separately billed Gemini / Vertex AI generation APIs are out of scope ([ROADMAP](https://github.com/ffroliva/gflow-cli/blob/main/ROADMAP.md#out-of-scope)). ## Auth strategy @@ -505,7 +505,7 @@ used only where it is strictly necessary. reCAPTCHA Enterprise token, and the request goes to Flow over direct HTTP. A refusal Flow reports as `PUBLIC_ERROR_UNUSUAL_ACTIVITY`, which is not billed, is retried once from a new headless browser process ([KNOWN_ISSUES](KNOWN_ISSUES.md)). The evidence is - [the direct video and headless mint spike](superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md): + [the direct video and headless mint spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md): 15/15 headless cold mints accepted on two accounts (30/30 counting both visibilities), and headless and headed video submits accepted 6/6 each on fresh browsers. - **Video extend on flow.google.com drives Flow's page headless.** It is a UI surface, but a @@ -561,7 +561,7 @@ shell carries no `at`. Caveats and controls: Until v0.108.0 every generation drove Flow's page in a headed Chrome window: reCAPTCHA Enterprise rejected the earlier headless approaches, and the UI transport was the only path that produced a video. v0.108.0 measured a headless mint as accepted and moved the measured request -shapes to direct HTTP ([spike](superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md), +shapes to direct HTTP ([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md), [#1371](https://github.com/ffroliva/gflow-cli/issues/1371)). This section records the earlier design and why it was chosen; it does not describe the current product. diff --git a/website/docs/BROWSER_MODES.md b/website/docs/BROWSER_MODES.md index b8dd87133..b933c05c1 100644 --- a/website/docs/BROWSER_MODES.md +++ b/website/docs/BROWSER_MODES.md @@ -6,7 +6,7 @@ reCAPTCHA token. The request itself goes to Flow over direct HTTP. Surfaces that Flow's own interface open a **headed** (visible) Chrome window. Local commands open no browser. This page is the single source of the per-command list. The wire details of the direct path are -in [DIRECT_TRANSPORT](DIRECT_TRANSPORT.md); the settings are in +in [DIRECT_TRANSPORT](https://github.com/ffroliva/gflow-cli/blob/main/docs/DIRECT_TRANSPORT.md); the settings are in [CONFIGURATION](CONFIGURATION.md#gflow_cli_browser_visibility). All rows below describe the default, `GFLOW_CLI_BROWSER_VISIBILITY=auto`. @@ -44,7 +44,7 @@ browser has been measured, so `auto` runs them headless. | `video upscale --scale 4k` | headless on `flow.google.com` (not measured) | Ultra only, so not measured: it follows the measured video download-menu path by an explicit decision ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). It spends credits on the click, and a failure after the click is never retried. `--browser-visibility headed` shows the window | | `video t2v --max-credits` | headless when only the cap needs the UI | A capped text-to-video whose uncapped request is an explicit measured key (for example `--model omni-1.2-flash --duration 4 --resolution 360p`; with no `--model` the key is the account's selection and it stays headed) reads Flow's quote in a headless browser: it reached the submit 2/2 headless matching a headed control with the submit aborted, and billed headless runs of that key on one account completed at the quoted 4 credits (3/3), and the other measured keys follow it by decision; an account that refused it headless refused the headed control too ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). A capped video of any other shape and a capped image-to-video stay headed; a capped reference-to-video follows the `video r2v --ref` row. `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | | `video r2v --ref` | headless with one local image | A reference-to-video from exactly one local image (no saved asset, character, voice or `@` mention, one output) drives Flow's composer in a headless browser: it reached the submit 2/2 headless matching a headed control with the submit aborted, and a billed headless run (Omni 1.2 Flash, 4 s, 360p) completed at the quoted 4 credits; other models and durations follow it by decision, and a configured proxy is unmeasured ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). An MCP reference given as a catalogued asset id resolves to its local file and counts as that file. An explicit `GFLOW_CLI_FLOW_HOST=labs.google` or `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | -| `movie run` | headless for a plain movie | A manifest with no characters and no instruction cards drives each scene, on any model, through Flow's composer in a headless browser, and the retry loop's UI fallback keeps that browser: a billed one-scene headless run (Omni 1.2 Flash, 4 s) completed at 4 credits, and the e2e completed headless ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554), [spike](superpowers/spikes/2026-11-30-headless-movie-and-agent-only.md)). Characters or instruction cards keep the whole run headed; an explicit `GFLOW_CLI_FLOW_HOST=labs.google` or `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | +| `movie run` | headless for a plain movie | A manifest with no characters and no instruction cards drives each scene, on any model, through Flow's composer in a headless browser, and the retry loop's UI fallback keeps that browser: a billed one-scene headless run (Omni 1.2 Flash, 4 s) completed at 4 credits, and the e2e completed headless ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554), [spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-30-headless-movie-and-agent-only.md)). Characters or instruction cards keep the whole run headed; an explicit `GFLOW_CLI_FLOW_HOST=labs.google` or `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | ## Headed (Flow's UI) @@ -54,7 +54,7 @@ browser has been measured, so `auto` runs them headless. | `image batch` | headed | The stay-mounted UI batch drives the composer; on an account served flow.google.com, gflow cannot drive it yet in either mode (exit 36, [#639](https://github.com/ffroliva/gflow-cli/issues/639)), so headless is unmeasured | | `image upscale --scale 2k` | headed | Headless was refused on one of two accounts while headed passed: after a day of runs, `SPrCad` answered `PUBLIC_ERROR_UNUSUAL_ACTIVITY` to three headless 2K upscales and accepted the headed one (unbilled); the other account passed both ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). `--scale 4k` (Ultra) follows the same path and stays headed | | `movie run` (with characters or instruction cards) | headed | Characters are created or attached and instruction cards are synced in Flow's UI, which is not measured headless; scene requests carry no resolution, so no scene goes direct | -| agent-only composer | the command's own launch (unmeasured) | gflow recognises the agent-only composer ([#799](https://github.com/ffroliva/gflow-cli/issues/799)) only after the page loads, so it runs in the browser the command launched: headed for most UI commands, headless for a measured headless surface such as a plain `movie run`. No account available was served it, so headless on it is unmeasured ([spike](superpowers/spikes/2026-11-30-headless-movie-and-agent-only.md)). `--browser-visibility headed` shows the window | +| agent-only composer | the command's own launch (unmeasured) | gflow recognises the agent-only composer ([#799](https://github.com/ffroliva/gflow-cli/issues/799)) only after the page loads, so it runs in the browser the command launched: headed for most UI commands, headless for a measured headless surface such as a plain `movie run`. No account available was served it, so headless on it is unmeasured ([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-30-headless-movie-and-agent-only.md)). `--browser-visibility headed` shows the window | | `video r2v` (other shapes) | headed | Two or more references, a saved asset, a character, an `@` mention, more than one output or `--ui-mode agentic` is not measured headless; reference-to-video is not measured over direct HTTP | | `video edit` | headed | On an account served flow.google.com, editing an existing clip by media id exits 23 in either mode ([#1605](https://github.com/ffroliva/gflow-cli/issues/1605)); a local clip reached the checked `jIps6` request in a $0 e2e with the submit aborted (2026-12-01); headless is unmeasured | | `video i2v --end-frame` | headed | An end frame, or a start frame that is already in the project, is not a measured shape. A billed headless run was refused as unusual activity (unbilled) while the headed control completed ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)) | @@ -167,5 +167,5 @@ below (the in-flight count, the start history, the armed page) carries from one `GFLOW_CLI_HEADLESS=true`) also runs the other Flow UI shapes headless at the user's choice; this is unsupported, see [#1554](https://github.com/ffroliva/gflow-cli/issues/1554). -Evidence: [the direct video and headless mint spike](superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md) +Evidence: [the direct video and headless mint spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md) ([#1371](https://github.com/ffroliva/gflow-cli/issues/1371)). diff --git a/website/docs/CHARACTER.md b/website/docs/CHARACTER.md index 91a1526c3..152a7ec78 100644 --- a/website/docs/CHARACTER.md +++ b/website/docs/CHARACTER.md @@ -2,15 +2,15 @@ > **Status:** SHIPPED (live-verified 2026-06-02) · **Issue:** [#145](https://github.com/ffroliva/gflow-cli/issues/145) · **Branch:** `feature/character-creation` > **Living document.** Evolve this as the feature and Flow's API evolve. Raw capture provenance lives in -> [`CHARACTER_RECON.md`](CHARACTER_RECON.md); the cross-feature decision lens is -> [the REST-path capability matrix](#capability-cost). +> [`CHARACTER_RECON.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/CHARACTER_RECON.md); the cross-feature decision lens is +> [the REST-path capability matrix](#3-capability-cost). > **Credit:** pattern-references @kittinan's avatar PR #123 (attach-flow idiom + CLI scaffolding shape) — but > built **greenfield off `develop`, NOT stacked on #123** (that branch is CONFLICTING and likeness-specific; > see [Design decisions](#11-design-decisions-post-predict)). > **Shipped scope:** `gflow character create` + `list` + `show` + `voices` + `rm`. Name-based reuse via > `@Name` prompt mentions is **shipped** (v0.40.0, [#344](https://github.com/ffroliva/gflow-cli/issues/344)) -> for both `image` and `video` paths — see [REFERENCE_STRATEGIES](REFERENCE_STRATEGIES.md). An explicit +> for both `image` and `video` paths — see [REFERENCE_STRATEGIES](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md). An explicit > `--character ` **flag** on `gflow video` (a separate, repeatable-ref delivery mechanism) remains > **not yet implemented** — see [Backlog](#14-backlog-not-yet-implemented). @@ -310,7 +310,7 @@ is **shipped** (see the table below). | `gflow video … --character ` *(repeatable → multi-ref, explicit flag)* | **not yet implemented** (Phase 3) — `referenceEntities` on `video:batchAsyncGenerateVideoReferenceImages` | | `gflow character rm` (`--id`/`--name`) | On `flow.google.com`, moves the character to the project's Trash. Restore it from Trash in Flow. On `labs.google`, deletes the character through `flow:batchDeleteAssets`. Neither action spends credits. | | `gflow image … --character ` *(explicit flag)* | id-based reuse **shipped** as `gflow image t2i/i2i --reference-entity ` (wire captured 2026-06-08, `api/image.py`) | -| `@Name` in a t2i/i2i/video prompt | name-based mention resolution **shipped v0.40.0 (#344)** — resolves to the staged character entity, works on both image and video paths (on flow.google.com, video `@Name` works on `r2v` alongside a `--ref` or `--reference-entity`; other video modes on that host refuse character references before submit, exit 36); see [REFERENCE_STRATEGIES](REFERENCE_STRATEGIES.md) | +| `@Name` in a t2i/i2i/video prompt | name-based mention resolution **shipped v0.40.0 (#344)** — resolves to the staged character entity, works on both image and video paths (on flow.google.com, video `@Name` works on `r2v` alongside a `--ref` or `--reference-entity`; other video modes on that host refuse character references before submit, exit 36); see [REFERENCE_STRATEGIES](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md) | All commands take **`--project ` (required)** — every endpoint (`createEntity`, `projectInitialData`, reuse) is project-scoped; mirrors `gflow scene` / `gflow data` ergonomics. Use `--id`/`--name` flags, never a @@ -344,7 +344,7 @@ never hard-code wire names in user-facing help — see [[cli-model-aliases-verif - **Data layer.** Persist `entityId`, `workflowId`s, `primaryMediaId`s, voice, personality so a character is recoverable and reusable across sessions (mirrors the scene persistence + migration pattern). - **Docs are first-class.** This document is the living spec; update it in the same PR as any behavioural - change. Indexed in [`docs/INDEX.md`](INDEX.md). + change. Indexed in [`docs/INDEX.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/INDEX.md). ## 10. Open items @@ -426,7 +426,7 @@ convenience later. > Two of three generative routes accept a `TokenMinter` token. Treat the wall as a **per-route measurement**, > never an inherited assumption — and re-measure before citing it. The `batchGenerateImages` 403 has not been > re-tested since 2026-06-02 and may itself be stale. -> Evidence: [superpowers/spikes/2026-08-31-veo-extend-route-recon.md](superpowers/spikes/2026-08-31-veo-extend-route-recon.md). +> Evidence: [superpowers/spikes/2026-08-31-veo-extend-route-recon.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-08-31-veo-extend-route-recon.md). - **✅ Decision = Option B (UI-driven generation; structural ops stay REST).** Generation (character image create AND video reuse) **must** ride Flow's native UI so Flow's JS issues the WAF-valid request, which gflow passive-captures — identical mechanism to the existing `generate_image`/`generate_video`. Revised @@ -573,7 +573,7 @@ The following are explicitly **out of the shipped scope** and tracked for future (`services/mentions.py`), on both image and video paths for character references. The image-path wire shape (`gflow image t2i/i2i --reference-entity `) shipped earlier (live capture 2026-06-08, `api/image.py`; asserted by `_assert_image_entities_attached`). See - [REFERENCE_STRATEGIES](REFERENCE_STRATEGIES.md) for the decision guide across all three mechanisms. + [REFERENCE_STRATEGIES](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md) for the decision guide across all three mechanisms. (`gflow character rm` is now shipped, #150.) - **Set the Flow editor title field** so the editor isn't "Untitled Character" (see [§13.1 Known issues](#131-known-issues)). Investigate either the UI title box (with a Ctrl+A merge-bug workaround) or finding the dedicated title diff --git a/website/docs/CONFIGURATION.md b/website/docs/CONFIGURATION.md index 7b8127ac8..9e0a907a5 100644 --- a/website/docs/CONFIGURATION.md +++ b/website/docs/CONFIGURATION.md @@ -624,7 +624,7 @@ per-command `--proxy` flags (the setting covers one-off runs: ### `GFLOW_CLI_FLOW_HOST` -**What:** Which Flow frontend gflow drives. Google has moved Flow from `labs.google/fx/tools/flow` onto `flow.google.com` ([#639](https://github.com/ffroliva/gflow-cli/issues/639)) — measured 2026-09-14, the old labs URL answers **HTTP 308 Permanent Redirect** on every account we tested. The two are the same product (the new frontend's own root element is `aisandbox-root`) on different widget toolkits and different wire protocols, so each has its own driver. Which host you are served does **not** tell you which capabilities work — see [the survey](../docs/superpowers/spikes/2026-09-14-two-domain-protocol-survey.md). +**What:** Which Flow frontend gflow drives. Google has moved Flow from `labs.google/fx/tools/flow` onto `flow.google.com` ([#639](https://github.com/ffroliva/gflow-cli/issues/639)) — measured 2026-09-14, the old labs URL answers **HTTP 308 Permanent Redirect** on every account we tested. The two are the same product (the new frontend's own root element is `aisandbox-root`) on different widget toolkits and different wire protocols, so each has its own driver. Which host you are served does **not** tell you which capabilities work — see [the survey](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-14-two-domain-protocol-survey.md). **Values:** - `auto` (default) — **`flow.google.com` is the default host for every video request it can serve today** (`video t2v`, `video i2v` from local files or same-`--project` catalogued image UUIDs (#1542), and local-file `video r2v`; with no `--project` and no `GFLOW_CLI_PROJECT`, one is created first, #864). Image requests use the migrated composer for `image t2i` and local-file `image i2i` where `flow.google.com` is what Flow serves, and stay on labs where labs is. A request the new host cannot serve keeps the labs driver where labs is what Flow serves; where flow.google.com is, there is no labs fallback and unsupported forms exit 36/11 before submit. - `flow.google.com` — force the migrated composer for everything, including what it cannot serve yet (those requests then exit 36/11 instead of falling back). @@ -754,7 +754,7 @@ Variables already set in the actual environment always beat both `.env` files. A An invalid value stops every command except `gflow config` with exit 11 (`ConfigurationError`), on stderr, naming the key as written, its value (masked for a secret), the file or the environment that holds it, and the command that repairs it; `--json` prints one Problem Details object with `key` and `origin`. `gflow config` still runs so the value can be repaired. See [Troubleshooting](#troubleshooting). -Use [`.env.template`](../.env.template) as your starting point: +Use [`.env.template`](https://github.com/ffroliva/gflow-cli/blob/main/.env.template) as your starting point: ```bash cp .env.template .env diff --git a/website/docs/DATA_LAYER.md b/website/docs/DATA_LAYER.md index 92a6a2750..29a09ca82 100644 --- a/website/docs/DATA_LAYER.md +++ b/website/docs/DATA_LAYER.md @@ -38,7 +38,7 @@ The schema is adapter-shaped so a future Postgres backend can slot in without ch | `operation_assets` | Many-to-many between operations and assets, with role (`input`/`output`/`seed_start`/`seed_end`/`reference`) and ordered position | When the operation links its inputs/outputs | | `local_files` | One row per downloaded asset location — local path or cloud URI, sha256/byte count when local, media type, `superseded_at` once a later copy replaced it | After each download/upload completes | -Schema lives in [`src/gflow_cli/data/migrations/0001_initial.sql`](../src/gflow_cli/data/migrations/0001_initial.sql). +Schema lives in [`src/gflow_cli/data/migrations/0001_initial.sql`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/data/migrations/0001_initial.sql). ### Operation `metadata_json` provenance @@ -277,7 +277,7 @@ The hash is always stored so you can correlate without the plaintext. ### Metadata redaction -[`redact_metadata`](../src/gflow_cli/data/redaction.py) is applied to every dict that lands in `assets.metadata_json`. It strips: +[`redact_metadata`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/data/redaction.py) is applied to every dict that lands in `assets.metadata_json`. It strips: | Key (case-insensitive) | Replacement | |---|---| @@ -304,7 +304,7 @@ sharing the raw SQLite file if failed queue payloads must stay confidential. In the default `store` mode, failure rows persist a scrubbed, readable copy of the exception's Problem Details `detail` through -[`redact_error_detail`](../src/gflow_cli/data/redaction.py). Free-text +[`redact_error_detail`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/data/redaction.py). Free-text `Bearer …` / `SAPISIDHASH …` tokens and auth-cookie pairs become ``, flow.google.com's bare `at` XSRF value and `0cAF…` reCAPTCHA tokens become ``, URLs carrying signed-query markers and @@ -505,7 +505,7 @@ Cloud-only assets have `LocalFileRecord.path is None` and carry their object location in `LocalFileRecord.cloud_uri`; path-based seed-image resolution is local-only. -The public read API is `DataRepository` ([`src/gflow_cli/data/repository.py`](../src/gflow_cli/data/repository.py)), whose methods live in the table-group modules `data/_repo_*.py`; all read methods return typed `SeedImage` / `AssetLookup` dataclasses, not raw SQLite rows. +The public read API is `DataRepository` ([`src/gflow_cli/data/repository.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/data/repository.py)), whose methods live in the table-group modules `data/_repo_*.py`; all read methods return typed `SeedImage` / `AssetLookup` dataclasses, not raw SQLite rows. --- @@ -525,7 +525,7 @@ See [`CONFIGURATION.md`](CONFIGURATION.md) for the full env-var precedence chain ## Migrations -All schema changes are SQL files under [`src/gflow_cli/data/migrations/`](../src/gflow_cli/data/migrations/), named `NNNN_description.sql` with a 4+ digit zero-padded prefix. +All schema changes are SQL files under [`src/gflow_cli/data/migrations/`](https://github.com/ffroliva/gflow-cli/tree/main/src/gflow_cli/data/migrations), named `NNNN_description.sql` with a 4+ digit zero-padded prefix. **How they're applied:** @@ -572,7 +572,7 @@ All three errors map to **exit code 16**: All three are subclasses of `GFlowError` and re-exported through `gflow_cli.exceptions`. They follow the project's RFC 9457 Problem Details pattern. -See [`errors.py::EXIT_CODE_MAP`](../src/gflow_cli/errors.py) for the complete exit-code mapping. +See [`errors.py::EXIT_CODE_MAP`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/errors.py) for the complete exit-code mapping. Distinct from the above (which are errors OF the data layer), the `operations.error_type` column stores the taxonomy of RECORDED generation @@ -588,7 +588,7 @@ the transfer failed — recover it with `gflow data download`). Query them with ### Adding a new operation kind -1. Add the enum value to `OperationKind` in [`data/models.py`](../src/gflow_cli/data/models.py). +1. Add the enum value to `OperationKind` in [`data/models.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/data/models.py). 2. Add a `record_(...)` method to `OperationRecorder` following the existing patterns (upsert profile → project → asset → insert operation → link → asset location rows). 3. Wire it into the CLI call site, mirroring the `_run_t2i` / `record_completed_video` patterns: open recorder BEFORE Flow, close in `finally`, wrap the `record_*` call in `try/except DataStoreError` calling `_warn_persistence_failed_after_success(...)`. @@ -641,7 +641,7 @@ Live tests (`@pytest.mark.live`) and E2E tests (`@pytest.mark.e2e`) are opt-in a - **Postgres / Supabase adapter** — for users running gflow on shared workers or wanting cross-machine sync. The repository surface is already designed for this swap. - **`gflow data export`** (full catalog → JSON / Parquet) — the failed-operation slice shipped as `gflow data errors export` (JSONL, #345); a full-catalog / Parquet dump for downstream analytics is still open. -These are tracked in [`PLAN.md`](../PLAN.md) under the data-layer phase backlog. +These are tracked in [`PLAN.md`](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md) under the data-layer phase backlog. --- diff --git a/website/docs/DEBUGGING.md b/website/docs/DEBUGGING.md index 1553162ac..14cd84d22 100644 --- a/website/docs/DEBUGGING.md +++ b/website/docs/DEBUGGING.md @@ -2,7 +2,7 @@ > Where to look and which tool to reach for when something breaks. Per-release > evidence (e.g. live verification runs) lives in sibling docs like -> [`LIVE_VERIFICATION_v0.7.0.md`](LIVE_VERIFICATION_v0.7.0.md). This file is +> [`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md). This file is > evergreen. ## Quick reference @@ -45,7 +45,7 @@ Confirm by checking for `ui_automation.image_mode_entered` in the log; if it is missing, the mode switch did not run. If `image_mode_entered` is present but `batch_response_seen` is still missing, the remaining hypothesis is the historical UI-flake noted in -[`LIVE_VERIFICATION_v0.7.0.md`](LIVE_VERIFICATION_v0.7.0.md#open-follow-ups) +[`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md#open-follow-ups) (transient overlay swallowed the arrow-forward click). **Two extra artifact file names worth searching for in the out dir** when the @@ -275,7 +275,7 @@ For health probes from a worker process, use ## Reproducing image gen end-to-end -See [`LIVE_VERIFICATION_v0.7.0.md`](LIVE_VERIFICATION_v0.7.0.md) for the +See [`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md) for the canonical example. Short form: ```bash @@ -372,7 +372,7 @@ remediations. The most-hit categories: - [`AUTHENTICATION.md`](AUTHENTICATION.md) — sign-in flow details - [`DEVELOPMENT.md`](DEVELOPMENT.md) — branching, PRs, quality gates - [`USAGE.md`](USAGE.md) — CLI surface -- [`LIVE_VERIFICATION_v0.7.0.md`](LIVE_VERIFICATION_v0.7.0.md) — +- [`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md) — per-release end-to-end evidence - `/gflow:known-issues` — surface open known issues from the CLI - `/gflow:check` — local quality gate (lint, format, types, tests) diff --git a/website/docs/DEVELOPMENT.md b/website/docs/DEVELOPMENT.md index 6b8844de1..c11955420 100644 --- a/website/docs/DEVELOPMENT.md +++ b/website/docs/DEVELOPMENT.md @@ -1,9 +1,9 @@ # Development Workflow -> For _contributing_ (TDD, quality gates, commit style, how to add a route) see [CONTRIBUTING.md](../CONTRIBUTING.md). +> For _contributing_ (TDD, quality gates, commit style, how to add a route) see [CONTRIBUTING.md](https://github.com/ffroliva/gflow-cli/blob/main/CONTRIBUTING.md). > This document covers the **internal development process**: branching model, PR protocol, e2e gate, and release pipeline. > For scenario-based GitHub PR triage, external fork handling, and SonarCloud -> decisions, see [docs/GITHUB.md](GITHUB.md). +> decisions, see [docs/GITHUB.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/GITHUB.md). --- @@ -89,7 +89,7 @@ coverage ≥ 80 %, rating A, duplication ≤ 3 %). It blocks merge via `sonar.qualitygate.wait=true`, so a failed gate turns the `SonarCloud analysis` check red rather than reporting silently on the dashboard. Browser-automation and live-auth transports are coverage-excluded (e2e-tested, not unit-tested). -See [docs/GITHUB.md § SonarCloud Quality Gate](GITHUB.md#sonarcloud-quality-gate). +See [docs/GITHUB.md § SonarCloud Quality Gate](https://github.com/ffroliva/gflow-cli/blob/main/docs/GITHUB.md#sonarcloud-quality-gate). ### Mutation testing (mutmut) @@ -154,7 +154,7 @@ export GFLOW_CLI_E2E_PROFILE= uv run pytest -m e2e -v ``` -All `@pytest.mark.e2e` scenarios must pass. See [CONTRIBUTING § E2e tests](../CONTRIBUTING.md#test-categories) for the full marker reference. +All `@pytest.mark.e2e` scenarios must pass. See [CONTRIBUTING § E2e tests](https://github.com/ffroliva/gflow-cli/blob/main/CONTRIBUTING.md#test-categories) for the full marker reference. --- @@ -175,7 +175,7 @@ Version bumps belong in the **`develop → main` release PR**, not in feature PR ## AI-assisted development (Claude Code) -This repo is actively developed with Claude Code (see [CLAUDE.md](../CLAUDE.md)). A few conventions that keep the workflow clean: +This repo is actively developed with Claude Code (see [CLAUDE.md](https://github.com/ffroliva/gflow-cli/blob/main/CLAUDE.md)). A few conventions that keep the workflow clean: - Claude branches are renamed to the appropriate `feature/`, `fix/`, `docs/` prefix before the PR is opened. The `claude/` prefix is internal scaffolding. - Claude never bumps the version or cuts a release without explicit instruction — use `/release`. @@ -188,9 +188,9 @@ This repo is actively developed with Claude Code (see [CLAUDE.md](../CLAUDE.md)) ## See also -- [CONTRIBUTING.md](../CONTRIBUTING.md) — TDD, quality gates, how to add a route, commit style -- [docs/GOVERNANCE_BENCHMARK.md](GOVERNANCE_BENCHMARK.md) — calibrating the advisory materiality gate (false-positive / coverage backtest) -- [docs/GITHUB.md](GITHUB.md) — GitHub PR triage, external fork handling, SonarCloud scenarios -- [RELEASE.md](../RELEASE.md) — release checklist, PyPI/GitHub publishing, tag protocol -- [CHANGELOG.md](../CHANGELOG.md) — version history -- [CLAUDE.md](../CLAUDE.md) — project memory hub for AI agents +- [CONTRIBUTING.md](https://github.com/ffroliva/gflow-cli/blob/main/CONTRIBUTING.md) — TDD, quality gates, how to add a route, commit style +- [docs/GOVERNANCE_BENCHMARK.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/GOVERNANCE_BENCHMARK.md) — calibrating the advisory materiality gate (false-positive / coverage backtest) +- [docs/GITHUB.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/GITHUB.md) — GitHub PR triage, external fork handling, SonarCloud scenarios +- [RELEASE.md](https://github.com/ffroliva/gflow-cli/blob/main/RELEASE.md) — release checklist, PyPI/GitHub publishing, tag protocol +- [CHANGELOG.md](https://github.com/ffroliva/gflow-cli/blob/main/CHANGELOG.md) — version history +- [CLAUDE.md](https://github.com/ffroliva/gflow-cli/blob/main/CLAUDE.md) — project memory hub for AI agents diff --git a/website/docs/E2E_TESTING.md b/website/docs/E2E_TESTING.md index 7d4e21dea..26ca7b1a5 100644 --- a/website/docs/E2E_TESTING.md +++ b/website/docs/E2E_TESTING.md @@ -101,7 +101,7 @@ e2e ─┬─ e2e_auth (auth/session, health check — zero credits) A live test can be written as Gherkin. This is the required form for a bug whose scenario can only happen in a browser — see -[`skills/issue-resolve/SKILL.md`](../skills/issue-resolve/SKILL.md) § The Bug Lane, +[`skills/issue-resolve/SKILL.md`](https://github.com/ffroliva/gflow-cli/blob/main/skills/issue-resolve/SKILL.md) § The Bug Lane, step 5. It needs **no new machinery**: pytest-bdd (already a dependency) converts every Gherkin tag into a pytest marker, so a tagged scenario is filtered by the same `addopts` and selected by the same `-m ` as a hand-written e2e test. @@ -689,7 +689,7 @@ flow.google.com clip lands in that bucket (#1003). ## See also -- [CONTRIBUTING.md § Test categories](../CONTRIBUTING.md#test-categories) +- [CONTRIBUTING.md § Test categories](https://github.com/ffroliva/gflow-cli/blob/main/CONTRIBUTING.md#test-categories) - [DEVELOPMENT.md § E2e gate](DEVELOPMENT.md#e2e-gate-before-merging-develop-main) - [docs/DATA_LAYER.md](DATA_LAYER.md) - [docs/ARCHITECTURE.md § Testing topology](ARCHITECTURE.md#testing-topology) diff --git a/website/docs/ERRORS.md b/website/docs/ERRORS.md index 02933e3a0..a62d01088 100644 --- a/website/docs/ERRORS.md +++ b/website/docs/ERRORS.md @@ -171,7 +171,7 @@ place today: `PUBLIC_ERROR_UNUSUAL_ACTIVITY` is `WafRejectionError` (exit 10), never retryable, and its `charged` / `next_action` depend on the scale. The scales measured to spend no credits (1080p, 720p and the 270p GIF for video, 2K for image; - [spike](superpowers/spikes/2026-11-29-export-billing-720p-270p.md)) read `no` / `wait`; + [spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-29-export-billing-720p-270p.md)) read `no` / `wait`; 4K (a 4K video bills on click; 4K image billing is unmeasured and treated the same), and a refusal on the `jwpduf` status poll, which runs after Flow accepted the export, read `maybe` / `reconcile`. No `retry_after` is given: no diff --git a/website/docs/INSTRUCTIONS.md b/website/docs/INSTRUCTIONS.md index 391cfb535..a5e6d9c87 100644 --- a/website/docs/INSTRUCTIONS.md +++ b/website/docs/INSTRUCTIONS.md @@ -164,6 +164,6 @@ title is ambiguous. - [USAGE.md](USAGE.md) — full command reference. - [MOVIE.md](MOVIE.md) — multi-scene movies (`[[…instructions.card]]` blocks). - [MCP.md](MCP.md) — the six `gflow_instructions_*` MCP tools mirroring this command group. -- [LIVE_VERIFICATION_v0.29.0.md](LIVE_VERIFICATION_v0.29.0.md) — live e2e evidence for the +- [LIVE_VERIFICATION_v0.29.0.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.29.0.md) — live e2e evidence for the CRUD surface (mechanism, H4 image-reference confirmation). The original plan + spike findings were consolidated and removed when the feature shipped (v0.29.0 release prep). diff --git a/website/docs/KNOWN_ISSUES.md b/website/docs/KNOWN_ISSUES.md index 770fe7088..635dca6a8 100644 --- a/website/docs/KNOWN_ISSUES.md +++ b/website/docs/KNOWN_ISSUES.md @@ -2,7 +2,7 @@ Living list of behaviour that's broken, surprising, or limited by design — alongside workarounds and a pointer to the issue / version where each is tracked or resolved. -> Pair with [CHANGELOG.md](CHANGELOG.md) (what shipped per version) and [DISCLAIMER.md](DISCLAIMER.md) (legal/scope limits). +> Pair with [CHANGELOG.md](https://github.com/ffroliva/gflow-cli/blob/main/CHANGELOG.md) (what shipped per version) and [DISCLAIMER.md](https://github.com/ffroliva/gflow-cli/blob/main/DISCLAIMER.md) (legal/scope limits). ## Conventions @@ -794,8 +794,7 @@ endpoint, a different surface from the `labs.google` tRPC API. > because it sends cookies but not that token. The `gflow scene` groundwork now > fetches+caches the token and attaches the Bearer to the **`page.request` REST > path** (`_post_json` / `_patch_json`, host-scoped to `aisandbox-pa`) so -> `uploadImage` / `scenes` / `commit` authenticate — see -> [`docs/superpowers/plans/2026-05-31-l0-bearer-pivot.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/plans/2026-05-31-l0-bearer-pivot.md). +> `uploadImage` / `scenes` / `commit` authenticate. > **Live-verified 2026-05-31:** REST `uploadImage` returns 200 > (`tests/e2e/test_aisandbox_auth_live.py`, credit-free). > **Liberating follow-up:** the same Bearer likely unlocks the `evaluate_fetch` diff --git a/website/docs/MCP.md b/website/docs/MCP.md index 645f6d661..eaa4ab035 100644 --- a/website/docs/MCP.md +++ b/website/docs/MCP.md @@ -130,8 +130,8 @@ completed result (blocking and queued alike) carries `route` (`direct` / `ui`), is [BROWSER_MODES](BROWSER_MODES.md). * `gflow_generate_image(prompt, model, aspect, count, reference_images, reference_entities, reference_entity_names, tools, profile, project, project_name, instructions, ui_mode, thinking_level, out_file, wait, browser_visibility)`: Triggers text-to-image / image-to-image (Imagen / Nano Banana). `thinking_level` (`low`/`medium`/`high`, matched case-insensitively, mirroring CLI `--thinking-level`) binds Flow's image thinking-level toggle in the settings pane (omitting leaves Flow's existing setting untouched). `out_file` sets an explicit destination file path (mirrors CLI `--out-file`; legacy `output` removed in #1158). There is no `seed` parameter: Flow picks the seed and the image request cannot carry one (removed in [#1013](https://github.com/ffroliva/gflow-cli/issues/1013), as the CLI's `--seed` was in v0.8.0). A completed result reports the catalogued seed under `seed`: the seed Flow chose on the classic image paths, `0` on the agentic / agent-only arms (which observe none), `null` if none was recorded — the MCP twin of `gflow image t2i --json`'s `images[].seed`. `instructions` is an optional list of ephemeral agent-instruction strings (agentic cohort only). `reference_images` switches to i2i and accepts **either a local file path or a generated image's Flow media UUID**. A UUID reference is attached by **selecting the already-existing asset in Flow's reference picker — no duplicate copy is uploaded** (locating the tile by the media id in its thumbnail URL, and searching the recorded display name to surface it when needed); gflow falls back to uploading the asset's on-disk local file only when it can't be located in place (e.g. it lives in a different project's picker). `project` generates into an existing Flow project id (mirrors CLI `--project`; when omitted, [`GFLOW_CLI_PROJECT`](CONFIGURATION.md#gflow_cli_project) is used unless `project_name` asks for a new project, #1039) — pass the reference's project to keep it selectable in place. `ui_mode` selects the Flow UI arm (`auto`/`classic`/`agentic`, mirroring CLI `--ui-mode`, matched case-insensitively). Since [#595](https://github.com/ffroliva/gflow-cli/issues/595) `auto` means "no arm was asked for" and **resolves to `classic`** — the arm that can satisfy an image request — so an account in Flow's agentic cohort aborts pre-submit (exit-28 equivalent envelope, zero credits) instead of failing mid-run with selector drift or video bytes; the agentic arm is bound only when named. Passing `instructions` forces `agentic` automatically, so `ui_mode="classic"` + `instructions` is a hard conflict rather than a silent drop. An unknown value returns a 400 problem-details envelope. See [CONFIGURATION § GFLOW_CLI_UI_MODE](CONFIGURATION.md#gflow_cli_ui_mode). - `model` is `nano2` (Nano Banana 2.1 on flow.google.com; `nano2.1` also accepted), `nano2-lite` (Nano Banana 2 Lite), `nano-pro` (Nano Banana Pro) or `image4` (Imagen 4, no longer in Flow's menu); other aliases are accepted too. On migrated `flow.google.com` accounts, T2I and local-file I2I are supported with Nano Banana 2.1 (`nano2`, #958) / 2 Lite / Pro, all five aspects (16:9, 4:3, 1:1, 3:4, 9:16) and count 1–4; the measured shapes are sent as a direct `ogiZ0b` request with a token from a headless browser, and the rest are submitted by Flow's own page ([DIRECT_TRANSPORT](DIRECT_TRANSPORT.md)). `@Name` character mentions in the prompt are attached through the composer's `@` picker and verified as character chips before submit (#723). each explicit `reference_entities` id needs its `reference_entity_names` entry or a matching `@Name` in the prompt (otherwise exit 36); a `reference_images` UUID is referenced in place when the catalog records it in the same `project` (#995), and a local `reference_images` file is uploaded into the project once and mentioned in place on later calls with the same file, like the CLI's `--ref` ([#772](https://github.com/ffroliva/gflow-cli/issues/772)); an output path gflow cannot write ends in the exit-11-equivalent envelope, with the image still in the Flow project ([#1091](https://github.com/ffroliva/gflow-cli/issues/1091)); other UUID references, instructions and Imagen 4 remain pre-submit refusals there. An agent-only composer (see below) takes T2I only. When Flow returns fewer images than `count`, the reply is still `completed`, `files` lists the images produced, and the `warnings` list includes the object `{"type": "images_missing", "requested": 4, "returned": 3}` (a `failed` reply carries it too when the images came back short before the failure) ([#1489](https://github.com/ffroliva/gflow-cli/issues/1489)). Each saved image is checked against the request at no cost, and a mismatch adds a `warnings` entry carrying its `media_name`: `aspect_mismatch` (decoded `width`/`height` more than 10 % off the `requested` aspect), `echoed_reference` (byte-identical to a local reference image) or `tiny_file` (under 8 KB, with `bytes` and `min_bytes`); the reply stays `completed` and the file is kept, and `wait=true` and `tasks/get` report the same entries ([#1534](https://github.com/ffroliva/gflow-cli/issues/1534)). A path that reads the images off the page (Agent mode, an agent-only composer, or a lost reply) fails instead when some are missing. The queued (`wait=false`) and blocking (`wait=true`) calls use the same typed payload and worker path. -* `gflow_generate_video(prompt, mode, aspect, initial_frame, end_frame, reference_images, reference_entities, reference_entity_names, model, duration, resolution, count, tools, profile, project, project_name, ui_mode, out_file, max_credits, wait, browser_visibility)`: Triggers vertical or landscape video generation (Veo). `out_file` sets an explicit destination file path (mirrors CLI `--out-file`; legacy `output` removed in #1158). `mode` is `t2v`/`i2v`/`r2v`; `model` (`veo_lite`/`veo_fast`/`veo_quality`/`omni_flash`/`omni_1_2_flash`, aliases accepted), `duration` (seconds — 4/6/8 for Veo 3.1, 4/6/8/10 for omni_flash, every integer 3–15 for omni_1_2_flash, at most 10 with an `end_frame`; with no `model`, 4/6/8/10), `resolution` ('360p' or '720p', supported on the Omni models; on any other model, or on the labs editor, the job fails pre-submit with the exit-11-equivalent envelope and no credits spent). **Whether Flow renders a duration control at all is account/cohort-dependent**: on an account that renders none, the job is accepted here and fails in the worker pre-submit (exit 23 equivalent on the labs driver, exit 11 equivalent on the migrated `flow.google.com` host — now the default t2v route, #650 — no credits spent either way) rather than being rejected up front — see [KNOWN_ISSUES](https://github.com/ffroliva/gflow-cli/blob/main/KNOWN_ISSUES.md) (#451/#288/#630), and `count` mirror the CLI `gflow video` flags — an omitted `model` lets the transport apply its i2v veo-lite default (issue #125), and every model — `omni_flash` included — accepts i2v with a start frame and with an end frame (wire-verified 2026-09-02, issue #626); `i2v` requires `initial_frame`, `r2v` requires `reference_images` **or** `reference_entities`; `project` generates into an existing Flow project id (mirrors CLI `--project`; when omitted, [`GFLOW_CLI_PROJECT`](CONFIGURATION.md#gflow_cli_project) is used unless `project_name` asks for a new project, #1039); on an account Google has moved to `flow.google.com` (`GFLOW_CLI_FLOW_HOST`, read from the server/daemon environment, not per call — see [CONFIGURATION § GFLOW_CLI_FLOW_HOST](CONFIGURATION.md#gflow_cli_flow_host)) omitting `project` creates one there first (#864); there, on the classic migrated composer (an agent-only one takes text-to-video only — see below), the ported modes are text-to-video; image-to-video with a **local** `initial_frame` (at the measured key, 9:16 with the default Veo 3.1 Lite and no `duration` / `resolution` / `end_frame`, the frame is uploaded and the request sent over direct HTTP with a headless browser; see [DIRECT_TRANSPORT](DIRECT_TRANSPORT.md)), optionally with a **local** `end_frame` (start+end interpolation, #639 — on the UI path local files are uploaded under a **run-unique** name like `hero-a1b2c3d4.png`, [#792](https://github.com/ffroliva/gflow-cli/issues/792)), **or** captioned image UUIDs the local catalog records in the same `project` ([#1542](https://github.com/ffroliva/gflow-cli/issues/1542), bound in place on the UI path via `/asb/` — the UUID frame skips upload, including Start+End and mixed local+UUID pairs where only the local frame uploads); and reference-to-video with local `reference_images` (each file is uploaded the same way — run-unique name included — and attached as an `@` mention of *that* name in the prompt; `duration` there accepts every integer from `3` through `15` with explicit `model="omni_1_2_flash"` (set through its duration slider; Google AI plans are required above `10`) and `4/6/8/10` with explicit `omni_flash`; Veo or an unspecified model accepts only `8`, because measured shorter Veo requests dropped the references and billed text-to-video, so any other value returns the exit-11-equivalent envelope. An omitted r2v duration still pins `8` to avoid inheriting the editor's previous setting). A cross-project Flow media UUID (or an un-captioned UUID with a verified local fallback) as `initial_frame`/`end_frame`, a character on `t2v` or `i2v`, and a character id missing its display name return the exit-36-equivalent envelope (an uncatalogued/unusable UUID or a non-path string such as `@Name` returns 400 before dispatch); `r2v` takes named characters with or without local `reference_images`. An explicit id's display name can come from its `reference_entity_names` entry or a matching `@Name` in the prompt ([#723](https://github.com/ffroliva/gflow-cli/issues/723)). `initial_frame`, `end_frame`, and `reference_images` each accept **either a local file path or the Flow image UUID of a generated asset** — pass a generated image's id straight in to chain image→video, and gflow attaches it for you. Since v0.58.0 (#529) the CLI and MCP surfaces are unified for i2v frames: the UUID keeps its identity and is enriched with the catalog's recorded display name plus an integrity-verified local fallback, so both transports prefer **selecting the exact asset in the project's media picker** (no duplicate upload). On `labs.google`, a missing tile falls back to re-uploading the recorded local file only if its byte count/SHA-256 still match; on `flow.google.com` (#1542), there is no local-file upload fallback — a missing or unrendered same-project tile reloads the grid up to ~90 s (plus at most one reload cycle) and fails with the exit-32-equivalent envelope. A UUID that isn't in your local asset catalog is rejected up front with a clear "Reference Not Found" error; a catalogued asset with neither a display name nor a verified local file gives a "Reference Not Usable" error (re-generate it or pass a local path). A video clip, or the media UUID of a catalogued clip, in `reference_images` returns a 400 naming `gflow_edit_video`, which edits a local clip with reference images ([#1540](https://github.com/ffroliva/gflow-cli/issues/1540)). For `r2v`, MCP resolves a catalogued image UUID to a verified local file before queuing the job. The flow.google.com driver receives the file for upload. A UUID without a local copy cannot be used this way. `ui_mode` selects the Flow UI arm (#299 PR-A, mirroring CLI `--ui-mode`) and **applies to every mode of this tool, including `r2v`** — unlike the CLI, where `video r2v`/`chain` have no flag and follow the env-only path. On labs and the classic migrated composer, video generation has **only a classic driver**, so `auto` ≡ `classic`: both verify the classic editor pre-submit and abort before spending credits if it is unreachable. `ui_mode="agentic"` is rejected with a 400 problem-details envelope, because no agentic video driver exists yet. (An agent-only migrated composer is routed before this check: text-to-video runs through its chat agent under `ui_mode` `auto` or `classic` — `"agentic"` is still rejected with the 400 above, before any browser work — and other video forms return the exit-36-equivalent envelope before anything is clicked.) Values are matched case-insensitively. (MCP tools return envelopes, never process exit codes — the CLI equivalents of these aborts are exit 28 and exit 2 respectively.) See [CONFIGURATION § GFLOW_CLI_UI_MODE](CONFIGURATION.md#gflow_cli_ui_mode). On a model Flow is retiring, the reply (the `wait=true` result and the queued task's `tasks/get` result alike) also carries `"warnings": [{"type": "model_retiring", "model": "", "retires_on": ""}]` ([#1375](https://github.com/ffroliva/gflow-cli/issues/1375)); the job still runs, and once Flow's menu stops offering the model it fails before submit, charged nothing. + `model` is `nano2` (Nano Banana 2.1 on flow.google.com; `nano2.1` also accepted), `nano2-lite` (Nano Banana 2 Lite), `nano-pro` (Nano Banana Pro) or `image4` (Imagen 4, no longer in Flow's menu); other aliases are accepted too. On migrated `flow.google.com` accounts, T2I and local-file I2I are supported with Nano Banana 2.1 (`nano2`, #958) / 2 Lite / Pro, all five aspects (16:9, 4:3, 1:1, 3:4, 9:16) and count 1–4; the measured shapes are sent as a direct `ogiZ0b` request with a token from a headless browser, and the rest are submitted by Flow's own page ([DIRECT_TRANSPORT](https://github.com/ffroliva/gflow-cli/blob/main/docs/DIRECT_TRANSPORT.md)). `@Name` character mentions in the prompt are attached through the composer's `@` picker and verified as character chips before submit (#723). each explicit `reference_entities` id needs its `reference_entity_names` entry or a matching `@Name` in the prompt (otherwise exit 36); a `reference_images` UUID is referenced in place when the catalog records it in the same `project` (#995), and a local `reference_images` file is uploaded into the project once and mentioned in place on later calls with the same file, like the CLI's `--ref` ([#772](https://github.com/ffroliva/gflow-cli/issues/772)); an output path gflow cannot write ends in the exit-11-equivalent envelope, with the image still in the Flow project ([#1091](https://github.com/ffroliva/gflow-cli/issues/1091)); other UUID references, instructions and Imagen 4 remain pre-submit refusals there. An agent-only composer (see below) takes T2I only. When Flow returns fewer images than `count`, the reply is still `completed`, `files` lists the images produced, and the `warnings` list includes the object `{"type": "images_missing", "requested": 4, "returned": 3}` (a `failed` reply carries it too when the images came back short before the failure) ([#1489](https://github.com/ffroliva/gflow-cli/issues/1489)). Each saved image is checked against the request at no cost, and a mismatch adds a `warnings` entry carrying its `media_name`: `aspect_mismatch` (decoded `width`/`height` more than 10 % off the `requested` aspect), `echoed_reference` (byte-identical to a local reference image) or `tiny_file` (under 8 KB, with `bytes` and `min_bytes`); the reply stays `completed` and the file is kept, and `wait=true` and `tasks/get` report the same entries ([#1534](https://github.com/ffroliva/gflow-cli/issues/1534)). A path that reads the images off the page (Agent mode, an agent-only composer, or a lost reply) fails instead when some are missing. The queued (`wait=false`) and blocking (`wait=true`) calls use the same typed payload and worker path. +* `gflow_generate_video(prompt, mode, aspect, initial_frame, end_frame, reference_images, reference_entities, reference_entity_names, model, duration, resolution, count, tools, profile, project, project_name, ui_mode, out_file, max_credits, wait, browser_visibility)`: Triggers vertical or landscape video generation (Veo). `out_file` sets an explicit destination file path (mirrors CLI `--out-file`; legacy `output` removed in #1158). `mode` is `t2v`/`i2v`/`r2v`; `model` (`veo_lite`/`veo_fast`/`veo_quality`/`omni_flash`/`omni_1_2_flash`, aliases accepted), `duration` (seconds — 4/6/8 for Veo 3.1, 4/6/8/10 for omni_flash, every integer 3–15 for omni_1_2_flash, at most 10 with an `end_frame`; with no `model`, 4/6/8/10), `resolution` ('360p' or '720p', supported on the Omni models; on any other model, or on the labs editor, the job fails pre-submit with the exit-11-equivalent envelope and no credits spent). **Whether Flow renders a duration control at all is account/cohort-dependent**: on an account that renders none, the job is accepted here and fails in the worker pre-submit (exit 23 equivalent on the labs driver, exit 11 equivalent on the migrated `flow.google.com` host — now the default t2v route, #650 — no credits spent either way) rather than being rejected up front — see [KNOWN_ISSUES](https://github.com/ffroliva/gflow-cli/blob/main/KNOWN_ISSUES.md) (#451/#288/#630), and `count` mirror the CLI `gflow video` flags — an omitted `model` lets the transport apply its i2v veo-lite default (issue #125), and every model — `omni_flash` included — accepts i2v with a start frame and with an end frame (wire-verified 2026-09-02, issue #626); `i2v` requires `initial_frame`, `r2v` requires `reference_images` **or** `reference_entities`; `project` generates into an existing Flow project id (mirrors CLI `--project`; when omitted, [`GFLOW_CLI_PROJECT`](CONFIGURATION.md#gflow_cli_project) is used unless `project_name` asks for a new project, #1039); on an account Google has moved to `flow.google.com` (`GFLOW_CLI_FLOW_HOST`, read from the server/daemon environment, not per call — see [CONFIGURATION § GFLOW_CLI_FLOW_HOST](CONFIGURATION.md#gflow_cli_flow_host)) omitting `project` creates one there first (#864); there, on the classic migrated composer (an agent-only one takes text-to-video only — see below), the ported modes are text-to-video; image-to-video with a **local** `initial_frame` (at the measured key, 9:16 with the default Veo 3.1 Lite and no `duration` / `resolution` / `end_frame`, the frame is uploaded and the request sent over direct HTTP with a headless browser; see [DIRECT_TRANSPORT](https://github.com/ffroliva/gflow-cli/blob/main/docs/DIRECT_TRANSPORT.md)), optionally with a **local** `end_frame` (start+end interpolation, #639 — on the UI path local files are uploaded under a **run-unique** name like `hero-a1b2c3d4.png`, [#792](https://github.com/ffroliva/gflow-cli/issues/792)), **or** captioned image UUIDs the local catalog records in the same `project` ([#1542](https://github.com/ffroliva/gflow-cli/issues/1542), bound in place on the UI path via `/asb/` — the UUID frame skips upload, including Start+End and mixed local+UUID pairs where only the local frame uploads); and reference-to-video with local `reference_images` (each file is uploaded the same way — run-unique name included — and attached as an `@` mention of *that* name in the prompt; `duration` there accepts every integer from `3` through `15` with explicit `model="omni_1_2_flash"` (set through its duration slider; Google AI plans are required above `10`) and `4/6/8/10` with explicit `omni_flash`; Veo or an unspecified model accepts only `8`, because measured shorter Veo requests dropped the references and billed text-to-video, so any other value returns the exit-11-equivalent envelope. An omitted r2v duration still pins `8` to avoid inheriting the editor's previous setting). A cross-project Flow media UUID (or an un-captioned UUID with a verified local fallback) as `initial_frame`/`end_frame`, a character on `t2v` or `i2v`, and a character id missing its display name return the exit-36-equivalent envelope (an uncatalogued/unusable UUID or a non-path string such as `@Name` returns 400 before dispatch); `r2v` takes named characters with or without local `reference_images`. An explicit id's display name can come from its `reference_entity_names` entry or a matching `@Name` in the prompt ([#723](https://github.com/ffroliva/gflow-cli/issues/723)). `initial_frame`, `end_frame`, and `reference_images` each accept **either a local file path or the Flow image UUID of a generated asset** — pass a generated image's id straight in to chain image→video, and gflow attaches it for you. Since v0.58.0 (#529) the CLI and MCP surfaces are unified for i2v frames: the UUID keeps its identity and is enriched with the catalog's recorded display name plus an integrity-verified local fallback, so both transports prefer **selecting the exact asset in the project's media picker** (no duplicate upload). On `labs.google`, a missing tile falls back to re-uploading the recorded local file only if its byte count/SHA-256 still match; on `flow.google.com` (#1542), there is no local-file upload fallback — a missing or unrendered same-project tile reloads the grid up to ~90 s (plus at most one reload cycle) and fails with the exit-32-equivalent envelope. A UUID that isn't in your local asset catalog is rejected up front with a clear "Reference Not Found" error; a catalogued asset with neither a display name nor a verified local file gives a "Reference Not Usable" error (re-generate it or pass a local path). A video clip, or the media UUID of a catalogued clip, in `reference_images` returns a 400 naming `gflow_edit_video`, which edits a local clip with reference images ([#1540](https://github.com/ffroliva/gflow-cli/issues/1540)). For `r2v`, MCP resolves a catalogued image UUID to a verified local file before queuing the job. The flow.google.com driver receives the file for upload. A UUID without a local copy cannot be used this way. `ui_mode` selects the Flow UI arm (#299 PR-A, mirroring CLI `--ui-mode`) and **applies to every mode of this tool, including `r2v`** — unlike the CLI, where `video r2v`/`chain` have no flag and follow the env-only path. On labs and the classic migrated composer, video generation has **only a classic driver**, so `auto` ≡ `classic`: both verify the classic editor pre-submit and abort before spending credits if it is unreachable. `ui_mode="agentic"` is rejected with a 400 problem-details envelope, because no agentic video driver exists yet. (An agent-only migrated composer is routed before this check: text-to-video runs through its chat agent under `ui_mode` `auto` or `classic` — `"agentic"` is still rejected with the 400 above, before any browser work — and other video forms return the exit-36-equivalent envelope before anything is clicked.) Values are matched case-insensitively. (MCP tools return envelopes, never process exit codes — the CLI equivalents of these aborts are exit 28 and exit 2 respectively.) See [CONFIGURATION § GFLOW_CLI_UI_MODE](CONFIGURATION.md#gflow_cli_ui_mode). On a model Flow is retiring, the reply (the `wait=true` result and the queued task's `tasks/get` result alike) also carries `"warnings": [{"type": "model_retiring", "model": "", "retires_on": ""}]` ([#1375](https://github.com/ffroliva/gflow-cli/issues/1375)); the job still runs, and once Flow's menu stops offering the model it fails before submit, charged nothing. * `gflow_edit_video(source, prompt, reference_images, model, aspect, resolution, max_credits, tools, profile, project, project_name, out_file, wait)`: Edits a local video file (`.mp4`/`.m4v`/`.mov`/`.3gp`/`.avi`, up to 1 GB) or an existing Flow clip media UUID on `flow.google.com` (`jIps6`, Omni models only, default `omni-1.2`, single-clip output) with `0–5` optional `reference_images` (local paths or catalog image UUIDs resolved to local files) for a local source file. With a media UUID source, `reference_images` are refused before the queue (exit 11, `charged: no`): references are not ported to editing an existing clip yet; download the clip with `gflow data download MEDIA_ID --out DIR` and pass the file. `max_credits` enforces Flow's pre-submit credit quote (refusing missing or over-cap quotes at zero spend). Local files support optional `aspect` (`16:9`/`9:16`) and `resolution` (`360p`/`720p`); existing Flow media UUIDs need a project (`project`, else the catalog's record, else `GFLOW_CLI_PROJECT`, the CLI's resolution) and keep source aspect at `720p`. The worker refuses a missing or unsupported file (exit 11), `GFLOW_CLI_FLOW_HOST=labs.google` (exit 36) and a mistyped queued payload (`QueueSchemaError`, exit 30) before it creates a project, all `charged: no`. `out_file` must stay inside the configured output directory. Gated by `--no-spend` with the other credit-spending tools. @@ -143,7 +143,7 @@ is [BROWSER_MODES](BROWSER_MODES.md). > different axis entirely: it buys a *look*, not an identity. For `r2v`, supply `reference_images` or `reference_entities` alongside a prompt mention. Use > `gflow_character_list` to discover ids and display names on `flow.google.com`. On that host, > each id needs its display name in `reference_entity_names` or a matching `@Name` in the prompt. -> An id with neither is exit 36. See [REFERENCE_STRATEGIES](REFERENCE_STRATEGIES.md). +> An id with neither is exit 36. See [REFERENCE_STRATEGIES](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md). > **`wait` and long generations ([#481](https://github.com/ffroliva/gflow-cli/issues/481), [#1097](https://github.com/ffroliva/gflow-cli/issues/1097)).** > Both generation tools take `wait` (default `true`), and its schema description in @@ -688,7 +688,7 @@ retried by the SDK. These requests are counted in telemetry under the client nam > surface are built as internal foundation but are **not yet wired into** > `gflow serve` — it currently runs the MCP server (Streamable HTTP or SSE) and the > OpenAI-compatible image route above. See the -> [CHANGELOG](../CHANGELOG.md) for the roadmap. +> [CHANGELOG](https://github.com/ffroliva/gflow-cli/blob/main/CHANGELOG.md) for the roadmap. > **Settings reach the server through its environment, not your shell's `.env`.** An MCP > client starts `gflow mcp run` in a directory of its own choosing, so a `.env` beside your diff --git a/website/docs/MEDIA_LIBRARY.md b/website/docs/MEDIA_LIBRARY.md index 21f55b2d9..4c289ca1e 100644 --- a/website/docs/MEDIA_LIBRARY.md +++ b/website/docs/MEDIA_LIBRARY.md @@ -4,7 +4,7 @@ > gflow-cli has hit driving it. All claims here are reverse-engineered from > live recon (2026-08-15/16, evidence in [#529](https://github.com/ffroliva/gflow-cli/issues/529) > / [#543](https://github.com/ffroliva/gflow-cli/issues/543) and the -> [#529 picker spike](superpowers/spikes/2026-08-15-picker-tile-alt-text.md)); +> [#529 picker spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-08-15-picker-tile-alt-text.md)); > Google documents none of it publicly and may change any of it without notice. ## Why this doc exists @@ -106,7 +106,7 @@ Freshness is layered, cheapest-first: budget. This heals the run on every surface (CLI, MCP, `gflow run`); the catalog write still needs the CLI's resolver (`store` mode only). Reach is what the empty picker lists: 15 of 21 assets in the measured project - ([spike](superpowers/spikes/2026-11-12-migrated-listing-captions.md)). + ([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-12-migrated-listing-captions.md)). 3. **Bulk reconciliation** — `gflow data sync --names` ([#543](https://github.com/ffroliva/gflow-cli/issues/543), shipped) for cold catalogs and ghost detection; `gflow doctor` @@ -189,7 +189,7 @@ surfaces that support character entities (the tab set varies by mode), and a - **Reference resolution** (v0.58.0, #529): `catalog UUID → display name → picker search → exact-UUID tile → attach`, falling back to a verified local upload, else a typed error. See - [REFERENCE_STRATEGIES.md](REFERENCE_STRATEGIES.md). + [REFERENCE_STRATEGIES.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md). - **Shipped**: `gflow doctor` ([#542](https://github.com/ffroliva/gflow-cli/issues/542)) reports nameless/ghost rows; `gflow data sync --names` ([#543](https://github.com/ffroliva/gflow-cli/issues/543)) reconciles the diff --git a/website/docs/MOVIE.md b/website/docs/MOVIE.md index 71ed385de..05ccf6e53 100644 --- a/website/docs/MOVIE.md +++ b/website/docs/MOVIE.md @@ -304,12 +304,12 @@ Scenes then name the costume state, and continuity is a lookup rather than a hop **The full identity resolution ladder** — entity, then the entity's own plate, then a plate cut from a take, then prose canon, with the rule that descending a rung is recorded next to the shot — lives in -[`skills/video-production/SKILL.md`](../skills/video-production/SKILL.md) step 4a. Read it +[`skills/video-production/SKILL.md`](https://github.com/ffroliva/gflow-cli/blob/main/skills/video-production/SKILL.md) step 4a. Read it before planning a multi-shot piece; a manifest that silently lands on the bottom rung produces a different actor in every scene. See [CHARACTER.md](CHARACTER.md) for the underlying entity model and -[CHARACTER_RECON.md](CHARACTER_RECON.md) for the reverse-engineered wire +[CHARACTER_RECON.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/CHARACTER_RECON.md) for the reverse-engineered wire protocol. ## Scene instructions (project brief cards) diff --git a/website/docs/PROMPT_EXPANSION.md b/website/docs/PROMPT_EXPANSION.md index b6ad03d7a..bc4521d30 100644 --- a/website/docs/PROMPT_EXPANSION.md +++ b/website/docs/PROMPT_EXPANSION.md @@ -40,7 +40,7 @@ Without `GFLOW_CLI_LLM_API_KEY` (or `GFLOW_CLI_LLM_BASE_URL`) the tool leaves yo | **Expansion** | `ExpansionResult(original, expanded, was_expanded)` | The result; `expanded == original` when nothing changed. | | **Provenance** | `AppliedTool(name, version, model, config_hash, params)` | Recorded in history when a tool rewrote a prompt. | -The tool itself lives in [`src/gflow_cli/tools/`](../src/gflow_cli/tools/): `spec.py` (schema), +The tool itself lives in [`src/gflow_cli/tools/`](https://github.com/ffroliva/gflow-cli/tree/main/src/gflow_cli/tools): `spec.py` (schema), `runtime.py` (`apply_tool`), `expander.py` (the provider-agnostic `PromptExpander`), `banned.py` (keyword stripping), `invocation.py` (provenance + MCP adapter). @@ -74,7 +74,7 @@ The instruction also carries "Critical Rules": name real cameras/brands, include use prestigious context anchors ("Vanity Fair editorial", "National Geographic cover"), use ALL CAPS for hard constraints, "prominently displayed" for products, and **never** emit banned keywords. The full text is the `system_template` in -[`creative-director.toml`](../src/gflow_cli/tools/builtin/creative-director.toml). +[`creative-director.toml`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/builtin/creative-director.toml). --- @@ -112,7 +112,7 @@ with different vocabularies. | `abstract` | Particle/fluid sims, smoke/ink textures, gradient-shift color, VJ aesthetic. | An **unknown** style is ignored with a `tool_unknown_style` warning — never an error. Full -vocabularies live in [`creative-director.toml`](../src/gflow_cli/tools/builtin/creative-director.toml); +vocabularies live in [`creative-director.toml`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/builtin/creative-director.toml); `gflow tools show creative-director` lists the current set. --- @@ -142,7 +142,7 @@ prompt the tool left unchanged is never altered. ## 6. Never-fatal contract -The `PromptExpander` ([`expander.py`](../src/gflow_cli/tools/expander.py)) is +The `PromptExpander` ([`expander.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/expander.py)) is stdlib-only (`urllib`) and bounded. `expand()` returns the original prompt with `was_expanded=False` in every degraded case. Generation `--tool` calls warn and continue; `gflow tools run` returns a typed error on this result: @@ -193,7 +193,7 @@ reference and worked examples (Google, OpenRouter, a local Docker proxy, keyless ## 8. Provenance — what history records When a tool rewrites a prompt, the generation is recorded with full provenance -([`data/_recorder_core.py`](../src/gflow_cli/data/_recorder_core.py), `_tool_metadata`): +([`data/_recorder_core.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/data/_recorder_core.py), `_tool_metadata`): - **`prompt`** column = the user's **original** prompt. - **`expanded_prompt`** column = the **submitted** (rewritten) prompt. @@ -219,7 +219,7 @@ a recording failure warns and returns exit 0 — never a non-zero exit after a p ## 9. Relationship to the `expand_prompt` MCP prompt The MCP server also exposes an older, now-**deprecated** **prompt template** named `expand_prompt` -([`mcp/prompts.py`](../src/gflow_cli/mcp/prompts.py)). It predates the tools framework and overlaps +([`mcp/prompts.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/mcp/prompts.py)). It predates the tools framework and overlaps functionally with `creative-director`, but they are **different surfaces**: | | `expand_prompt` (MCP prompt) | `creative-director` (tool) | diff --git a/website/docs/SECURITY.md b/website/docs/SECURITY.md index 79a42b900..1155a7a4a 100644 --- a/website/docs/SECURITY.md +++ b/website/docs/SECURITY.md @@ -259,7 +259,7 @@ If a profile dir or `.env` containing real secrets ever lands in a Git repo: ## `.gitignore` rules in this repo -The repository's [`.gitignore`](../.gitignore) excludes: +The repository's [`.gitignore`](https://github.com/ffroliva/gflow-cli/blob/main/.gitignore) excludes: ``` auth/ # any project-local auth dir @@ -343,6 +343,6 @@ None to date. This section will list public CVEs, advisories, and patched versio ## See also -- [DISCLAIMER](../DISCLAIMER.md) — legal scope & takedown policy +- [DISCLAIMER](https://github.com/ffroliva/gflow-cli/blob/main/DISCLAIMER.md) — legal scope & takedown policy - [AUTHENTICATION](AUTHENTICATION.md) — full auth lifecycle - [CONFIGURATION](CONFIGURATION.md) — secret-bearing env vars diff --git a/website/docs/TOOLS.md b/website/docs/TOOLS.md index 287ce3dad..8d7c106d3 100644 --- a/website/docs/TOOLS.md +++ b/website/docs/TOOLS.md @@ -26,7 +26,7 @@ A tool is invoked uniformly in two ways: Tools are **pure prompt transforms** today: they read a prompt and return a (possibly rewritten) prompt. The richer `Tool.apply(ctx) → outcome` dispatch framework (workflow tools beyond prompt rewriting) is a deferred design — see -[the tool-abstraction evaluation](superpowers/research/2026-06-27-tool-abstraction-evaluation.md). +[the tool-abstraction evaluation](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/research/2026-06-27-tool-abstraction-evaluation.md). ### Lineage @@ -193,7 +193,7 @@ without collision — e.g. `creative-director` has both a `product` *image* styl ## 5. The TOML schema A tool is a single TOML file validated into a Pydantic `ToolSpec` -([`src/gflow_cli/tools/spec.py`](../src/gflow_cli/tools/spec.py)). All models are **frozen** +([`src/gflow_cli/tools/spec.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/spec.py)). All models are **frozen** (immutable after load). ### Top-level (`ToolSpec`) @@ -233,7 +233,7 @@ A tool is a single TOML file validated into a Pydantic `ToolSpec` ## 6. How a tool is applied (runtime contract) -[`src/gflow_cli/tools/runtime.py`](../src/gflow_cli/tools/runtime.py): +[`src/gflow_cli/tools/runtime.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/runtime.py): 1. **`build_instruction(config, style, category)`** — starts from `config.system_template`, appends the bare label `Target medium: image.` or `Target medium: video.` when a category is @@ -261,8 +261,8 @@ generation. `gflow tools run` reports a typed error because expansion is its onl 1. Write `src/gflow_cli/tools/builtin/.toml` following the schema in §5. 2. That's it — the loader auto-discovers every `*.toml` in the `builtin/` package via `importlib.resources` at startup - ([`loader.py`](../src/gflow_cli/tools/loader.py)), validates it into a `ToolSpec`, and the - registry ([`registry.py`](../src/gflow_cli/tools/registry.py)) exposes it under `spec.name`. + ([`loader.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/loader.py)), validates it into a `ToolSpec`, and the + registry ([`registry.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/registry.py)) exposes it under `spec.name`. Invalid TOML or a schema violation **fails loud** (`ConfigurationError`) the first time any `tools` / `--tool` path runs. 3. Bump the tool's `version` whenever you change behavior; the `config_hash` (a SHA-256 of the @@ -293,7 +293,7 @@ analogue of Flow's Tools menu.) ## 8. MCP exposure Per AGENTS.md §61 (CLI ↔ MCP parity), the tools surface is mirrored on the MCP server -([`src/gflow_cli/mcp/`](../src/gflow_cli/mcp/)): +([`src/gflow_cli/mcp/`](https://github.com/ffroliva/gflow-cli/tree/main/src/gflow_cli/mcp)): - **`gflow_list_tools`** — mirrors `gflow tools list`; returns `[{name, title, description, category}, …]`. @@ -304,7 +304,7 @@ Per AGENTS.md §61 (CLI ↔ MCP parity), the tools surface is mirrored on the MC (no per-tool flag sprawl). The MCP `list[dict]` form is validated and adapted to the CLI `--tool name[:k=v]` form by -`tool_specs_from_invocations` ([`invocation.py`](../src/gflow_cli/tools/invocation.py)) — e.g. +`tool_specs_from_invocations` ([`invocation.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/invocation.py)) — e.g. `{"name": "creative-director", "options": {"style": "cinema"}}` → `"creative-director:style=cinema"`. Malformed entries return a structured `{"status": "invalid_tools", ...}` error to the agent rather than raising. @@ -332,5 +332,5 @@ for the full comparison and migration guidance. - [CONFIGURATION.md](CONFIGURATION.md) — `GFLOW_CLI_LLM_BASE_URL` / `_API_KEY` / `_MODEL`. - [DATA_LAYER.md](DATA_LAYER.md) — how `expanded_prompt` and `metadata_json.tool` are recorded. - [MCP.md](MCP.md) — the MCP server. -- [tool-abstraction evaluation](superpowers/research/2026-06-27-tool-abstraction-evaluation.md) — +- [tool-abstraction evaluation](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/research/2026-06-27-tool-abstraction-evaluation.md) — the deferred S3 dispatch-framework design. diff --git a/website/docs/USAGE.md b/website/docs/USAGE.md index ce2e1d06a..f0b8d3e3e 100644 --- a/website/docs/USAGE.md +++ b/website/docs/USAGE.md @@ -143,7 +143,7 @@ back. `--search "r2v duration"` narrows that to a handful with the host-specific at the top. Curated answers rank first: the `**"How do I …?"** →` rows in -[INDEX](INDEX.md#topic-shortcuts) were each written to *be* an answer, so they come above +[INDEX](https://github.com/ffroliva/gflow-cli/blob/main/docs/INDEX.md#topic-shortcuts) were each written to *be* an answer, so they come above raw body-text matches for the same term. Piping works — the page is emitted as its own Markdown, not as rendered boxes: @@ -481,7 +481,7 @@ Notes: - **flow.google.com only.** There is no labs.google route; `GFLOW_CLI_FLOW_HOST=labs.google` refuses the command with exit 36. - **Cost:** the 1080p export was measured free (1 observation, 2026-10-07), as were the 720p - export and the 270p GIF ([2026-11-29](superpowers/spikes/2026-11-29-export-billing-720p-270p.md)); the 4K export on Flow Ultra spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). + export and the 270p GIF ([2026-11-29](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-29-export-billing-720p-270p.md)); the 4K export on Flow Ultra spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). - Saved as `/videos//_.` (`.mp4` or `.gif`). ## `gflow image generate` / `gflow video generate` @@ -872,7 +872,7 @@ entities (it carries start/end frames instead). `--ref` is different: it attaches an arbitrary **image** (`referenceImages`), not a saved identity, and can be combined with a `@Name` for "this identity, in this look". -See [REFERENCE_STRATEGIES.md](REFERENCE_STRATEGIES.md) for the full decision guide. +See [REFERENCE_STRATEGIES.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md) for the full decision guide. ## `gflow image batch` @@ -886,7 +886,7 @@ Tab-separated columns. Only `prompt` is required; remaining columns fall back to promptcountaspect_ratiomodel ``` -Lines starting with `#` and blank lines are skipped. Example: [`test_assets/sample_batch.tsv`](../test_assets/sample_batch.tsv). +Lines starting with `#` and blank lines are skipped. Example: [`test_assets/sample_batch.tsv`](https://github.com/ffroliva/gflow-cli/blob/main/test_assets/sample_batch.tsv). ```tsv a small calico kitten sitting on a windowsill @@ -908,7 +908,7 @@ an isometric pixel-art bakery 1 1:1 nano2 ] ``` -Example: [`test_assets/sample_batch.json`](../test_assets/sample_batch.json). +Example: [`test_assets/sample_batch.json`](https://github.com/ffroliva/gflow-cli/blob/main/test_assets/sample_batch.json). ### Session behaviour @@ -923,7 +923,7 @@ All prompts in a batch share one Flow project. The editor is opened once and sta - `MAX_BATCH_PROMPTS = 5` (defined in `src/gflow_cli/image_batch.py`). To raise, edit the constant. -### Exit codes +### Batch exit codes - `0` — all rows succeeded. - `1` — invalid manifest (file not found, parse error, unknown aspect/model). @@ -1049,7 +1049,7 @@ Options: > are not ported to the migrated composer yet; `r2v` takes a character with > `--reference-entity` paired with `--reference-entity-name` (#723). `image t2i` and local-file `image i2i` also run on a moved > account, and on images a character can be tagged with `@Name` or `--reference-entity` -> (see [REFERENCE_STRATEGIES § flow.google.com](REFERENCE_STRATEGIES.md#on-flowgooglecom-images-and-video-r2v-723)). An image `--ref ` is referenced in place, with no upload, when the +> (see [REFERENCE_STRATEGIES § flow.google.com](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md#on-flowgooglecom-images-and-video-r2v-723)). An image `--ref ` is referenced in place, with no upload, when the > local catalog records that image in the same `--project` and keeps its Flow caption > ([#995](https://github.com/ffroliva/gflow-cli/issues/995)); any other UUID, and instruction/Imagen-4 > image forms, still exit 36. `flow.google.com` forces the migrated composer, @@ -1085,7 +1085,7 @@ the editor's frame slot via the media dialog, then Flow fires > - **Default shape (direct HTTP, since v0.108.0):** a local `--initial-frame` at 9:16 with > the default Veo 3.1 Lite model and no `--duration`, `--resolution`, `--end-frame`, or > `--max-credits` uploads the frame and submits over direct HTTP with a headless browser -> ([DIRECT_TRANSPORT](DIRECT_TRANSPORT.md)). +> ([DIRECT_TRANSPORT](https://github.com/ffroliva/gflow-cli/blob/main/docs/DIRECT_TRANSPORT.md)). > - **Local files (UI route):** other local start-frame shapes and local `--end-frame` > interpolation upload the file through the editor's own Upload entry (it stays in the > project's library like any upload — a second run uploads it again), find it in the Frames @@ -1142,7 +1142,7 @@ gflow video i2v ./hero.png "Slow camera arc, soft golden light" Local frame files follow the [`gflow image upload`](#gflow-image-upload) rules (header check, 20 MB cap), and a UUID must be catalogued in the same `--project` (exit 36 otherwise, see -[exit codes](#exit-codes-1)). Start+end submits were measured with Veo 3.1 Fast and Lite, and with +[exit codes](#exit-codes)). Start+end submits were measured with Veo 3.1 Fast and Lite, and with Omni 1.2 (which accepts at most 10 s with an end frame); Veo 3.1 Quality uses the same key family as Fast but was not run live (#1594). Whether the two frames must share an aspect ratio has not been measured (#1603). @@ -3165,7 +3165,7 @@ The table below is the default (legacy) set. `GFLOW_CLI_EXIT_CODES=2` opts in to | `28` | `UiModeUnavailableError` | The Flow UI arm this command required (`--ui-mode`/`GFLOW_CLI_UI_MODE`; `-i` forces agentic for images; **labs video always requires classic** — no agentic labs video driver exists; an agent-only `flow.google.com` composer ([#799](https://github.com/ffroliva/gflow-cli/issues/799)) is routed before this policy and never exits 28) couldn't be reached after a switch attempt; aborted before submitting — no credits spent (issue #299) | Retry (the cohort flaps per load); try another `--profile`; for images you can also relax `GFLOW_CLI_UI_MODE` — for video there is nothing to relax | | `29` | `MentionIndexUnavailableError` | An `@mention` was present but the catalog source needed to resolve it (character entities or media assets) failed to load — distinct from an empty index, which is not an error. Also raised on a page served labs for an image character known only by name (#723), since that picker attaches by entity id | Check network connectivity (character source) or `GFLOW_CLI_DB_PATH` / filesystem permissions (media source), then retry. For the by-name character on labs, pass `--reference-entity ` | | `30` | `QueueSchemaError` | A `gflow serve`/MCP worker-queue task payload has an unrecognized `schema_version` or fails validation against the typed request DTOs | Usually means gflow-cli was downgraded after a newer version enqueued the task, or the payload was hand-edited; re-enqueue with a compatible version | -| `31` | `FlowAppError` | Flow did not serve the page gflow asked for. Two shapes: its error-boundary page rendered instead of the editor (a transient client-side crash), or it redirected to `flow.google.com/about` instead of the project ([#756](https://github.com/ffroliva/gflow-cli/issues/756)) | Crash: retry shortly; if it persists, Flow itself is degraded. `/about`: run `gflow auth login --profile ` and finish Google's "Confirm it's you" if it asks; then open the project in a browser on that host and confirm this account can reach it. A retry is **measured** not to help — 5/5 consecutive attempts during a live occurrence landed on `/about` again ([2026-09-11](superpowers/spikes/2026-09-11-about-redirect-is-stable-for-an-account.md); the [2026-09-10 run](superpowers/spikes/2026-09-10-about-redirect-stability.md) got 0/5 only because the redirect had stopped reproducing) — so gflow does not flag it retryable. One cause is measured since: Google wanted the account to "Confirm it's you" while its cookies were healthy ([2026-09-23](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-23-about-cta-leads-to-google-reauth.md)); `gflow auth login` waits on that check ([#902](https://github.com/ffroliva/gflow-cli/issues/902)) | +| `31` | `FlowAppError` | Flow did not serve the page gflow asked for. Two shapes: its error-boundary page rendered instead of the editor (a transient client-side crash), or it redirected to `flow.google.com/about` instead of the project ([#756](https://github.com/ffroliva/gflow-cli/issues/756)) | Crash: retry shortly; if it persists, Flow itself is degraded. `/about`: run `gflow auth login --profile ` and finish Google's "Confirm it's you" if it asks; then open the project in a browser on that host and confirm this account can reach it. A retry is **measured** not to help — 5/5 consecutive attempts during a live occurrence landed on `/about` again ([2026-09-11](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-11-about-redirect-is-stable-for-an-account.md); the [2026-09-10 run](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-10-about-redirect-stability.md) got 0/5 only because the redirect had stopped reproducing) — so gflow does not flag it retryable. One cause is measured since: Google wanted the account to "Confirm it's you" while its cookies were healthy ([2026-09-23](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-23-about-cta-leads-to-google-reauth.md)); `gflow auth login` waits on that check ([#902](https://github.com/ffroliva/gflow-cli/issues/902)) | | `32` | `ReferenceNotFoundError` | A referenced media NAME is not in this project's picker. Flow indexes a short auto-caption, not the generation prompt, so a prompt used as a reference name never matches. On flow.google.com this includes an unmatched `@Name` when the catalog is available. For an image character (#723) it is also raised when no picker option is titled exactly the name, several are, or the match is media; after up to ~90 s of reloads, for a catalogued same-`--project` UUID ref (`image i2i --ref`, #995, or `video i2v` Start/End frame, #1542) whose image is no longer in the project grid (deleted in Flow); and when an `@` reference attaches out of order, landing before a chip already in the prompt (#997); and when a local `--ref` upload does not become the `@` picker's active row within 8 s, or the new chip is not that upload (`video extend`, `video r2v`, and the `image i2i` fallback, [#1581](https://github.com/ffroliva/gflow-cli/issues/1581)), before anything is submitted | Reference the asset by its media UUID (if Flow deleted it, regenerate it or pass its local file), pass a local file with `--ref`, or check what exists with `gflow data list images`. For a character the picker never offers (#1333), check the name with `gflow character list --project `; when several options or a media asset share the name, rename the colliding asset in Flow, or give the character a unique one-word name. Out of order: re-run; if it repeats, report it with the reference count and window size | | `33` | — (`gflow doctor` verdict) | Doctor found warn/fail findings — a successful diagnosis, not an error class | Review the report; see [`gflow doctor`](#gflow-doctor) | | `34` | `SyncPartialError` | `gflow data sync` failed on some projects but succeeded on others — completed writes stay committed | Retryable: re-run the same command; it resumes with what is still nameless (see [`gflow data sync`](#gflow-data-sync)) | @@ -3318,5 +3318,5 @@ async with FlowApiClient(profile_dir=profile_dir) as client: - [AUTHENTICATION](AUTHENTICATION.md) — auth flow + multi-account - [ARCHITECTURE](ARCHITECTURE.md) — internal structure (for contributors) - [TELEMETRY](TELEMETRY.md) — local weekly usage metrics, telemetry.db, and kill switches -- [PLAN](../PLAN.md) — what ships in which phase +- [PLAN](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md) — what ships in which phase From 2925fffb02f17a3c5e66e8b9bb33b085e40277de Mon Sep 17 00:00:00 2001 From: deepslit <731369471@qq.com> Date: Fri, 4 Dec 2026 23:33:27 +0800 Subject: [PATCH 02/28] fix(docs): handle CommonMark escapes, titles, and reference defs Signed-off-by: deepslit <731369471@qq.com> --- docs/DEBUGGING.md | 2 +- scripts/ci/generate_website_docs.py | 112 +++++++++++++++++--- tests/scripts/test_generate_website_docs.py | 57 ++++++++++ website/docs/DEBUGGING.md | 2 +- 4 files changed, 155 insertions(+), 18 deletions(-) diff --git a/docs/DEBUGGING.md b/docs/DEBUGGING.md index 8fbd93ae2..9f9248f8a 100644 --- a/docs/DEBUGGING.md +++ b/docs/DEBUGGING.md @@ -45,7 +45,7 @@ Confirm by checking for `ui_automation.image_mode_entered` in the log; if it is missing, the mode switch did not run. If `image_mode_entered` is present but `batch_response_seen` is still missing, the remaining hypothesis is the historical UI-flake noted in -[`LIVE_VERIFICATION_v0.7.0.md`](LIVE_VERIFICATION_v0.7.0.md#open-follow-ups) +[`LIVE_VERIFICATION_v0.7.0.md`](LIVE_VERIFICATION_v0.7.0.md#open-follow-ups-not-blocking-v070) (transient overlay swallowed the arrow-forward click). **Two extra artifact file names worth searching for in the out dir** when the diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index 28fd01cae..9b74f1b6a 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -107,8 +107,63 @@ def _source_for(dest_name: str) -> Path | None: _FENCE = re.compile(r"^[ \t>]*(`{3,}|~{3,})(.*)") -_CODE_SPAN = re.compile(r"(?\n]+)>|((?:[^\s()]|\([^()\s]*\))+))(?=\s|\))") +_MD_ESCAPE = re.compile(r"\\([!\"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~])") +_TITLE = r'(?:"(?:\\.|[^"\\])*"|\'(?:\\.|[^\'\\])*\'|\((?:\\.|[^()\\])*\))' +_DEST_PART = r"(?:<((?:[^>\n\\]|\\.)+)>|((?:[^\s()\\]|\\.|\((?:[^\s()\\]|\\.)*\))+))" +_DESTINATION = re.compile(rf"\(\s*{_DEST_PART}(?:\s+{_TITLE})?\s*\)") +_REF_DEF = re.compile( + rf"(?m)^[ \t]{{0,3}}\[(?![ \t]*\])(?:[^\]\n\\]|\\[^\n])+\]:[ \t]*(?:\r?\n[ \t]*)?" + rf"(?:<((?:[^>\n\\]|\\.)+)>|((?:[^\s\\]|\\.)+))(?:[ \t]+{_TITLE})?[ \t]*(?=$|\r?\n)" +) + + +def _unescape_md(value: str) -> str: + return _MD_ESCAPE.sub(r"\1", value) + + +def _mask_inline_code(text: str) -> str: + """Replace inline code spans with spaces while respecting backslash-escaped backticks.""" + out = list(text) + i = 0 + n = len(text) + while i < n: + ch = text[i] + if ch == "\\": + i += 2 + continue + if ch != "`": + i += 1 + continue + run_end = i + while run_end < n and text[run_end] == "`": + run_end += 1 + tick_len = run_end - i + j = run_end + close_end = -1 + while j < n: + if text[j] == "\n": + # CommonMark code spans cannot cross blank lines. + rest = text[j + 1 :] + if rest.startswith("\n") or re.match(r"[ \t]+\n", rest): + break + if text[j] == "`": + c_end = j + while c_end < n and text[c_end] == "`": + c_end += 1 + if c_end - j == tick_len: + close_end = c_end + break + j = c_end + continue + j += 1 + if close_end > 0: + for k in range(i, close_end): + if out[k] != "\n": + out[k] = " " + i = close_end + else: + i = run_end + return "".join(out) def _mask_code(text: str) -> str: @@ -125,26 +180,50 @@ def _mask_code(text: str) -> str: elif not fence and (run.startswith("~") or "`" not in info): fence = run lines.append(re.sub(r"[^\n]", " ", line) if inside or fence else line) - return _CODE_SPAN.sub(lambda m: " " * len(m[0]), "".join(lines)) + return _mask_inline_code("".join(lines)) + + +def _is_relative_target(target: str) -> bool: + return not target.startswith("/") and not urlsplit(target).scheme def _relative_links(text: str) -> Iterator[tuple[int, int, str]]: - """Yield (start, end, target), including both destinations in a linked image.""" + """Yield (start, end, target) for inline links, linked images, and reference definitions.""" prose = _mask_code(text) + tokens: list[tuple[int, int, str, int | None, int | None]] = [] + for match in _REF_DEF.finditer(prose): + group = 1 if match[1] is not None else 2 + s, e = match.span(group) + tokens.append((match.start(), match.end(), "ref", s, e)) + for match in re.finditer(r"\\[^\n]|\[|\]|\n[ \t]*\n", prose): + tokens.append((match.start(), match.end(), match[0], None, None)) + tokens.sort(key=lambda item: item[0]) + depth = 0 - for bracket in re.finditer(r"\\[\\\[\]]|\[|\]|\n[ \t]*\n", prose): - if bracket[0] == "[": + cursor = 0 + for tok_start, tok_end, kind, ref_s, ref_e in tokens: + if tok_start < cursor: + continue + if kind == "ref": + assert ref_s is not None and ref_e is not None + target = text[ref_s:ref_e] + if _is_relative_target(target): + yield ref_s, ref_e, target + cursor = tok_end + depth = 0 + elif kind == "[": depth += 1 - elif bracket[0].startswith("\n"): + elif kind.startswith("\n"): depth = 0 - elif bracket[0] == "]" and depth: + elif kind == "]" and depth: depth -= 1 - match = _DESTINATION.match(prose, bracket.end()) + match = _DESTINATION.match(prose, tok_end) if match: - start, end = match.span(1 if match[1] is not None else 2) - target = text[start:end] - if not target.startswith("/") and not urlsplit(target).scheme: - yield start, end, target + dest_start, dest_end = match.span(1 if match[1] is not None else 2) + target = text[dest_start:dest_end] + if _is_relative_target(target): + yield dest_start, dest_end, target + cursor = match.end() def _site_files() -> set[str]: @@ -156,7 +235,8 @@ def _site_link(target: str, source_dir: Path, dest_dir: Path, published: dict[Pa url = urlsplit(target) site_path = url.path if site_path: - canonical = (source_dir / unquote(site_path)).resolve() + decoded_path = unquote(_unescape_md(site_path)) + canonical = (source_dir / decoded_path).resolve() destination = published.get(canonical) if destination is not None: site_path = quote(posixpath.relpath(destination.as_posix(), dest_dir.as_posix())) @@ -167,7 +247,7 @@ def _site_link(target: str, source_dir: Path, dest_dir: Path, published: dict[Pa path = quote(canonical.relative_to(_REPO).as_posix()) suffix = target.removeprefix(url.path) # Keep GitHub's query and fragment verbatim. return f"https://github.com/ffroliva/gflow-cli/{kind}/main/{path}{suffix}" - elif (dest_dir / unquote(site_path)).resolve() not in published: + elif (dest_dir / decoded_path).resolve() not in published: return target # Leave the unresolved destination intact for --check. return url._replace(path=site_path, fragment=re.sub("-{2,}", "-", url.fragment)).geturl() @@ -239,7 +319,7 @@ def _unresolved_relative_links() -> Iterator[str]: for page in sorted(_WEB.rglob("*.md")): text = page.read_text(encoding="utf-8") for start, _, target in _relative_links(text): - path = unquote(urlsplit(target).path) + path = unquote(_unescape_md(urlsplit(target).path)) parent = page.parent.relative_to(_WEB).as_posix() if path and posixpath.normpath(posixpath.join(parent, path)) not in site_files: line = text.count("\n", 0, start) + 1 diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index 7155a23c5..6643797b8 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -203,3 +203,60 @@ def test_check_reports_unresolved_links_on_bespoke_pages( "UNRESOLVED-LINK: website/docs/index.md:5: ../private.txt", "UNRESOLVED-LINK: website/docs/index.md:6: INDEX.md", ] + + +def test_escaped_backticks_and_link_titles_do_not_hide_or_invent_links( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + docs = tmp_path / "docs" + web = tmp_path / "website" / "docs" + docs.mkdir(parents=True) + web.mkdir(parents=True) + (tmp_path / "PLAN.md").touch() + (web / "USER_GUIDE.md").touch() + (docs / "USER_GUIDE.md").touch() + monkeypatch.setattr(_gen, "_REPO", tmp_path) + monkeypatch.setattr(_gen, "_DOCS", docs) + monkeypatch.setattr(_gen, "_WEB", web) + + text = ( + r"Escaped \` [Plan](../PLAN.md) \` and " + r'[Guide](USER_GUIDE.md "See [missing](missing.md)").' + ) + rendered = _gen.render("GUIDE.md", text) + assert "](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md)" in rendered + assert "[missing](missing.md)" in rendered + (web / "GUIDE.md").write_text(rendered, encoding="utf-8") + assert _gen.main(["--check"]) == 0 + + +def test_reference_definitions_and_markdown_escaped_destinations( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + docs = tmp_path / "docs" + web = tmp_path / "website" / "docs" + docs.mkdir(parents=True) + web.mkdir(parents=True) + (tmp_path / "PLAN.md").touch() + (docs / "part(1).md").touch() + (web / "part(1).md").touch() + monkeypatch.setattr(_gen, "_REPO", tmp_path) + monkeypatch.setattr(_gen, "_DOCS", docs) + monkeypatch.setattr(_gen, "_WEB", web) + + source = ( + "[Plan][p] [Escaped](part\\(1\\).md#a--b) [Pct](part%281%29.md#a--b)\n\n" + "[p]: ../PLAN.md#s--1\n" + "[e]: part\\(1\\).md#a--b\n" + ) + rendered = _gen.render("SYNTHETIC.md", source) + assert "[p]: https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md#s--1" in rendered + assert "[Escaped](part%281%29.md#a-b)" in rendered + assert "[Pct](part%281%29.md#a-b)" in rendered + assert "[e]: part%281%29.md#a-b" in rendered + (web / "SYNTHETIC.md").write_text( + "[Escaped](part\\(1\\).md#a-b)\n[bad]: missing.md\n", + encoding="utf-8", + ) + unresolved = list(_gen._unresolved_relative_links()) + assert unresolved == ["UNRESOLVED-LINK: website/docs/SYNTHETIC.md:2: missing.md"] diff --git a/website/docs/DEBUGGING.md b/website/docs/DEBUGGING.md index 14cd84d22..6f821e8f7 100644 --- a/website/docs/DEBUGGING.md +++ b/website/docs/DEBUGGING.md @@ -45,7 +45,7 @@ Confirm by checking for `ui_automation.image_mode_entered` in the log; if it is missing, the mode switch did not run. If `image_mode_entered` is present but `batch_response_seen` is still missing, the remaining hypothesis is the historical UI-flake noted in -[`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md#open-follow-ups) +[`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md#open-follow-ups-not-blocking-v070) (transient overlay swallowed the arrow-forward click). **Two extra artifact file names worth searching for in the out dir** when the From 3f3f0886a2f0e0f73f2c10c6d3b4ddcc0d4c695f Mon Sep 17 00:00:00 2001 From: deepslit <731369471@qq.com> Date: Sat, 5 Dec 2026 00:12:56 +0800 Subject: [PATCH 03/28] fix(docs): handle nested parens, indented code, block boundaries, and HTML entities Signed-off-by: deepslit <731369471@qq.com> --- scripts/ci/generate_website_docs.py | 100 ++++++++++++++++---- tests/scripts/test_generate_website_docs.py | 37 ++++++++ 2 files changed, 121 insertions(+), 16 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index 9b74f1b6a..f1ff3e63d 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -18,6 +18,7 @@ from __future__ import annotations +import html import posixpath import re import sys @@ -107,10 +108,14 @@ def _source_for(dest_name: str) -> Path | None: _FENCE = re.compile(r"^[ \t>]*(`{3,}|~{3,})(.*)") -_MD_ESCAPE = re.compile(r"\\([!\"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~])") +_INDENTED_CODE = re.compile(r"(?: {4}|\t)") +_BLOCK_BREAK = re.compile(r"[ \t]*(?:\r?\n|$|#|(?:-|[*+]|\d+[.)])[ \t]|>|`{3,}|~{3,})") +_MD_UNESCAPE = re.compile( + r"\\([!\"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~])" + r"|(&(?:#[0-9]{1,7}|#[xX][0-9a-fA-F]{1,6}|[A-Za-z][A-Za-z0-9]{1,31});)" +) _TITLE = r'(?:"(?:\\.|[^"\\])*"|\'(?:\\.|[^\'\\])*\'|\((?:\\.|[^()\\])*\))' -_DEST_PART = r"(?:<((?:[^>\n\\]|\\.)+)>|((?:[^\s()\\]|\\.|\((?:[^\s()\\]|\\.)*\))+))" -_DESTINATION = re.compile(rf"\(\s*{_DEST_PART}(?:\s+{_TITLE})?\s*\)") +_DEST_TAIL = re.compile(rf"(?:\s+{_TITLE})?\s*\)") _REF_DEF = re.compile( rf"(?m)^[ \t]{{0,3}}\[(?![ \t]*\])(?:[^\]\n\\]|\\[^\n])+\]:[ \t]*(?:\r?\n[ \t]*)?" rf"(?:<((?:[^>\n\\]|\\.)+)>|((?:[^\s\\]|\\.)+))(?:[ \t]+{_TITLE})?[ \t]*(?=$|\r?\n)" @@ -118,7 +123,10 @@ def _source_for(dest_name: str) -> Path | None: def _unescape_md(value: str) -> str: - return _MD_ESCAPE.sub(r"\1", value) + return _MD_UNESCAPE.sub( + lambda m: m[1] if m[1] is not None else html.unescape(m[2]), + value, + ) def _mask_inline_code(text: str) -> str: @@ -142,11 +150,9 @@ def _mask_inline_code(text: str) -> str: close_end = -1 while j < n: if text[j] == "\n": - # CommonMark code spans cannot cross blank lines. - rest = text[j + 1 :] - if rest.startswith("\n") or re.match(r"[ \t]+\n", rest): + if _BLOCK_BREAK.match(text, j + 1): break - if text[j] == "`": + elif text[j] == "`": c_end = j while c_end < n and text[c_end] == "`": c_end += 1 @@ -167,11 +173,14 @@ def _mask_inline_code(text: str) -> str: def _mask_code(text: str) -> str: - """Hide code without shifting the positions of link destinations in the source.""" - lines = [] + """Hide fenced and indented code blocks and inline code spans without shifting indices.""" + lines: list[str] = [] fence = "" + prev_blank = True + in_indented = False for line in text.splitlines(keepends=True): - marker = _FENCE.match(line) + is_blank = not line.strip() + marker = _FENCE.match(line) if not in_indented else None inside = bool(fence) if marker: run, info = marker.groups() @@ -179,10 +188,69 @@ def _mask_code(text: str) -> str: fence = "" elif not fence and (run.startswith("~") or "`" not in info): fence = run - lines.append(re.sub(r"[^\n]", " ", line) if inside or fence else line) + if inside or fence: + lines.append(re.sub(r"[^\n]", " ", line)) + prev_blank = False + continue + if is_blank: + lines.append(line) + prev_blank = True + continue + if (prev_blank or in_indented) and _INDENTED_CODE.match(line): + in_indented = True + lines.append(re.sub(r"[^\n]", " ", line)) + else: + in_indented = False + lines.append(line) + prev_blank = False return _mask_inline_code("".join(lines)) +def _parse_inline_destination(prose: str, pos: int) -> tuple[int, int, int] | None: + """Parse ``(dest [title])`` starting right after ``]``, handling nested parens.""" + n = len(prose) + if pos >= n or prose[pos] != "(": + return None + i = pos + 1 + while i < n and prose[i].isspace(): + i += 1 + if i >= n: + return None + if prose[i] == "<": + dest_start = i + 1 + i = dest_start + while i < n and prose[i] not in ">\r\n": + i += 2 if prose[i] == "\\" else 1 + if i >= n or prose[i] != ">": + return None + dest_end = i + i += 1 + else: + dest_start = i + depth = 0 + while i < n: + ch = prose[i] + if ch == "\\" and i + 1 < n: + i += 2 + elif ch.isspace() or ord(ch) < 32: + break + elif ch == "(": + depth += 1 + i += 1 + elif ch == ")": + if depth == 0: + break + depth -= 1 + i += 1 + else: + i += 1 + if depth != 0 or i == dest_start: + return None + dest_end = i + tail = _DEST_TAIL.match(prose, i) + return (dest_start, dest_end, tail.end()) if tail else None + + def _is_relative_target(target: str) -> bool: return not target.startswith("/") and not urlsplit(target).scheme @@ -217,13 +285,13 @@ def _relative_links(text: str) -> Iterator[tuple[int, int, str]]: depth = 0 elif kind == "]" and depth: depth -= 1 - match = _DESTINATION.match(prose, tok_end) - if match: - dest_start, dest_end = match.span(1 if match[1] is not None else 2) + parsed = _parse_inline_destination(prose, tok_end) + if parsed is not None: + dest_start, dest_end, tail_end = parsed target = text[dest_start:dest_end] if _is_relative_target(target): yield dest_start, dest_end, target - cursor = match.end() + cursor = tail_end def _site_files() -> set[str]: diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index 6643797b8..7a5383ac8 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -260,3 +260,40 @@ def test_reference_definitions_and_markdown_escaped_destinations( ) unresolved = list(_gen._unresolved_relative_links()) assert unresolved == ["UNRESOLVED-LINK: website/docs/SYNTHETIC.md:2: missing.md"] + + +def test_nested_parens_indented_code_block_boundaries_and_char_refs( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + docs = tmp_path / "docs" + web = tmp_path / "website" / "docs" + docs.mkdir(parents=True) + web.mkdir(parents=True) + (tmp_path / "PLAN.md").touch() + (docs / "plan(v1(draft)).md").touch() + (docs / "café.md").touch() + (web / "café.md").touch() + monkeypatch.setattr(_gen, "_REPO", tmp_path) + monkeypatch.setattr(_gen, "_DOCS", docs) + monkeypatch.setattr(_gen, "_WEB", web) + + source = ( + " [IndentedCode](missing.md)\n\n" + "- `open\n" + "- [Plan](../PLAN.md) close`\n\n" + "[Nested](plan(v1(draft)).md) and [Entity](café.md#a--b)\n" + ) + rendered = _gen.render("SYNTHETIC.md", source) + assert " [IndentedCode](missing.md)" in rendered + assert "](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md)" in rendered + assert ( + "[Nested](https://github.com/ffroliva/gflow-cli/blob/main/docs/plan%28v1%28draft%29%29.md)" + in rendered + ) + assert "[Entity](caf%C3%A9.md#a-b)" in rendered + + (web / "SYNTHETIC.md").write_text( + " [IndentedCode](missing.md)\n[Entity](café.md#a-b)\n", + encoding="utf-8", + ) + assert list(_gen._unresolved_relative_links()) == [] From f378aed64bee0ef51ff46f63fd38ba37dc56071a Mon Sep 17 00:00:00 2001 From: deepslit <731369471@qq.com> Date: Sat, 5 Dec 2026 09:15:54 +0800 Subject: [PATCH 04/28] fix(docs): handle list continuations and fences after indented code Signed-off-by: deepslit <731369471@qq.com> --- scripts/ci/generate_website_docs.py | 114 +++++++++++++++++--- tests/scripts/test_generate_website_docs.py | 68 ++++++++++++ 2 files changed, 165 insertions(+), 17 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index f1ff3e63d..1c8cad583 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -13,7 +13,7 @@ Usage: python scripts/ci/generate_website_docs.py # write the mirror - python scripts/ci/generate_website_docs.py --check # CI: fail on any drift + python scripts/ci/generate_website_docs.py --check # CI: check drift, orphans, links """ from __future__ import annotations @@ -29,6 +29,7 @@ _REPO = Path(__file__).resolve().parents[2] _DOCS = _REPO / "docs" _WEB = _REPO / "website" / "docs" +_GITHUB_REPO = "https://github.com/ffroliva/gflow-cli" # Pages authored directly for the site (nav landing/onboarding) — NOT mirrors of # canonical, so never regenerated or diffed. `index.md` has a canonical namesake @@ -108,7 +109,9 @@ def _source_for(dest_name: str) -> Path | None: _FENCE = re.compile(r"^[ \t>]*(`{3,}|~{3,})(.*)") -_INDENTED_CODE = re.compile(r"(?: {4}|\t)") +_MASK_LINE = re.compile(r"[^\n]") +_LIST_MARKER = re.compile(r"(?:[-*+]|\d{1,9}[.)])([ \t]+)(?=\S)") +_BLOCK_INTERRUPT = re.compile(r"(?:#{1,6}(?:[ \t]|$)|>|(?:[-*_][ \t]*){3,}(?:\r?\n|$))") _BLOCK_BREAK = re.compile(r"[ \t]*(?:\r?\n|$|#|(?:-|[*+]|\d+[.)])[ \t]|>|`{3,}|~{3,})") _MD_UNESCAPE = re.compile( r"\\([!\"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~])" @@ -172,35 +175,112 @@ def _mask_inline_code(text: str) -> str: return "".join(out) +def _indent_width(line: str) -> tuple[int, int]: + """Return CommonMark leading indent width in columns and first non-indent char index.""" + col = 0 + idx = 0 + n = len(line) + while idx < n: + ch = line[idx] + if ch == " ": + col += 1 + elif ch == "\t": + col += 4 - (col % 4) + else: + break + idx += 1 + return col, idx + + +def _list_content_indent(rest: str, col: int) -> int | None: + """Return a list item's content indent column if ``rest`` starts a list marker.""" + match = _LIST_MARKER.match(rest) + if not match: + return None + marker_end = col + match.start(1) + c = marker_end + for ch in match.group(1): + c += 1 if ch == " " else 4 - (c % 4) + return marker_end + 1 if c - marker_end >= 5 else c + + +def _pop_lists(list_indents: list[int], col: int) -> None: + while list_indents and list_indents[-1] > col: + list_indents.pop() + + +def _base_indent(list_indents: list[int]) -> int: + return list_indents[-1] if list_indents else 0 + + +def _active_base_indent(list_indents: list[int], col: int, *, pop: bool) -> int: + if pop: + _pop_lists(list_indents, col) + return _base_indent(list_indents) + + +def _opens_fence(line: str, col: int, base: int) -> str: + if col >= base + 4: + return "" + marker = _FENCE.match(line) + if not marker: + return "" + run, info = marker.groups() + return run if run.startswith("~") or "`" not in info else "" + + +def _advance_fence(line: str, col: int, base: int, fence: str) -> str: + if col < base + 4: + marker = _FENCE.match(line) + if marker and marker.group(1).startswith(fence) and not marker.group(2).strip(): + return "" + return fence + + +def _starts_indented_code(col: int, base: int, prev_blank: bool, in_indented: bool) -> bool: + return (prev_blank or in_indented) and col >= base + 4 + + +def _update_list_context(rest: str, col: int, list_indents: list[int]) -> None: + if _BLOCK_INTERRUPT.match(rest): + _pop_lists(list_indents, col) + return + if (content_col := _list_content_indent(rest, col)) is not None: + _pop_lists(list_indents, col) + list_indents.append(content_col) + + def _mask_code(text: str) -> str: """Hide fenced and indented code blocks and inline code spans without shifting indices.""" lines: list[str] = [] + list_indents: list[int] = [] fence = "" prev_blank = True in_indented = False for line in text.splitlines(keepends=True): - is_blank = not line.strip() - marker = _FENCE.match(line) if not in_indented else None - inside = bool(fence) - if marker: - run, info = marker.groups() - if fence and run.startswith(fence) and not info.strip(): - fence = "" - elif not fence and (run.startswith("~") or "`" not in info): - fence = run - if inside or fence: - lines.append(re.sub(r"[^\n]", " ", line)) + col, idx = _indent_width(line) + rest = line[idx:] + if fence: + fence = _advance_fence(line, col, _base_indent(list_indents), fence) + lines.append(_MASK_LINE.sub(" ", line)) prev_blank = False continue - if is_blank: + if not rest.strip(): lines.append(line) prev_blank = True continue - if (prev_blank or in_indented) and _INDENTED_CODE.match(line): + base = _active_base_indent(list_indents, col, pop=prev_blank) + if opened := _opens_fence(line, col, base): + _pop_lists(list_indents, col) + fence = opened + in_indented = False + lines.append(_MASK_LINE.sub(" ", line)) + elif _starts_indented_code(col, base, prev_blank, in_indented): in_indented = True - lines.append(re.sub(r"[^\n]", " ", line)) + lines.append(_MASK_LINE.sub(" ", line)) else: in_indented = False + _update_list_context(rest, col, list_indents) lines.append(line) prev_blank = False return _mask_inline_code("".join(lines)) @@ -314,7 +394,7 @@ def _site_link(target: str, source_dir: Path, dest_dir: Path, published: dict[Pa kind = "tree" if canonical.is_dir() else "blob" path = quote(canonical.relative_to(_REPO).as_posix()) suffix = target.removeprefix(url.path) # Keep GitHub's query and fragment verbatim. - return f"https://github.com/ffroliva/gflow-cli/{kind}/main/{path}{suffix}" + return f"{_GITHUB_REPO}/{kind}/main/{path}{suffix}" elif (dest_dir / decoded_path).resolve() not in published: return target # Leave the unresolved destination intact for --check. return url._replace(path=site_path, fragment=re.sub("-{2,}", "-", url.fragment)).geturl() diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index 7a5383ac8..876f26128 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -297,3 +297,71 @@ def test_nested_parens_indented_code_block_boundaries_and_char_refs( encoding="utf-8", ) assert list(_gen._unresolved_relative_links()) == [] + + +def test_list_item_continuation_paragraph_links_are_rewritten_and_checked( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + docs = tmp_path / "docs" + web = tmp_path / "website" / "docs" + docs.mkdir(parents=True) + web.mkdir(parents=True) + (tmp_path / "PLAN.md").touch() + monkeypatch.setattr(_gen, "_REPO", tmp_path) + monkeypatch.setattr(_gen, "_DOCS", docs) + monkeypatch.setattr(_gen, "_WEB", web) + + ordered = "1. Item\n\n [Plan](../PLAN.md)\n" + assert [t for _, _, t in _gen._relative_links(ordered)] == ["../PLAN.md"] + assert _gen.render("SYNTHETIC.md", ordered) == ( + "1. Item\n\n [Plan](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md)\n" + ) + + bullet = "- Item\n\n [Plan](../PLAN.md)\n" + assert [t for _, _, t in _gen._relative_links(bullet)] == ["../PLAN.md"] + + indented_in_list = "1. Item\n\n [Code](missing.md)\n" + assert list(_gen._relative_links(indented_in_list)) == [] + + after_list_ends = "1. Item\n\nParagraph\n\n [Code](missing.md)\n" + assert list(_gen._relative_links(after_list_ends)) == [] + + (web / "SYNTHETIC.md").write_text("1. Item\n\n [Bad](missing.md)\n", encoding="utf-8") + assert list(_gen._unresolved_relative_links()) == [ + "UNRESOLVED-LINK: website/docs/SYNTHETIC.md:3: missing.md" + ] + + +def test_fenced_code_block_after_indented_code_block_is_masked( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + docs = tmp_path / "docs" + web = tmp_path / "website" / "docs" + docs.mkdir(parents=True) + web.mkdir(parents=True) + (tmp_path / "PLAN.md").touch() + monkeypatch.setattr(_gen, "_REPO", tmp_path) + monkeypatch.setattr(_gen, "_DOCS", docs) + monkeypatch.setattr(_gen, "_WEB", web) + + only_fence = " example\n\n```\n[Example](missing.md)\n```\n" + assert list(_gen._relative_links(only_fence)) == [] + (web / "SYNTHETIC.md").write_text(only_fence, encoding="utf-8") + assert list(_gen._unresolved_relative_links()) == [] + + with_after = f"{only_fence}[After](../PLAN.md)\n" + assert [t for _, _, t in _gen._relative_links(with_after)] == ["../PLAN.md"] + assert _gen.render("SYNTHETIC.md", with_after) == ( + f"{only_fence}[After](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md)\n" + ) + + no_blank = " example\n```\n[Example](missing.md)\n```\n[After](../PLAN.md)\n" + assert [t for _, _, t in _gen._relative_links(no_blank)] == ["../PLAN.md"] + + indented_ticks = " ```\n [Example](missing.md)\n\n[After](../PLAN.md)\n" + assert [t for _, _, t in _gen._relative_links(indented_ticks)] == ["../PLAN.md"] + + inside_list = ( + "1. Item\n\n ```\n [Example](missing.md)\n ```\n\n [Plan](../PLAN.md)\n" + ) + assert [t for _, _, t in _gen._relative_links(inside_list)] == ["../PLAN.md"] From 98c5667b9e785f42462a166664e6ad2c767b7c1e Mon Sep 17 00:00:00 2001 From: deepslit <731369471@qq.com> Date: Sat, 5 Dec 2026 10:28:41 +0800 Subject: [PATCH 05/28] fix(docs): parse CommonMark containers cleanly in website doc link scanner Signed-off-by: deepslit <731369471@qq.com> --- scripts/ci/generate_website_docs.py | 704 ++++++++++++++------ tests/scripts/test_generate_website_docs.py | 64 +- 2 files changed, 557 insertions(+), 211 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index 1c8cad583..a1613c084 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -23,6 +23,7 @@ import re import sys from collections.abc import Iterator +from dataclasses import dataclass, field from pathlib import Path from urllib.parse import quote, unquote, urlsplit @@ -108,11 +109,24 @@ def _source_for(dest_name: str) -> Path | None: return None -_FENCE = re.compile(r"^[ \t>]*(`{3,}|~{3,})(.*)") -_MASK_LINE = re.compile(r"[^\n]") -_LIST_MARKER = re.compile(r"(?:[-*+]|\d{1,9}[.)])([ \t]+)(?=\S)") -_BLOCK_INTERRUPT = re.compile(r"(?:#{1,6}(?:[ \t]|$)|>|(?:[-*_][ \t]*){3,}(?:\r?\n|$))") -_BLOCK_BREAK = re.compile(r"[ \t]*(?:\r?\n|$|#|(?:-|[*+]|\d+[.)])[ \t]|>|`{3,}|~{3,})") +_THEMATIC = re.compile(r"(?:(-[ \t]*){3,}|(\*[ \t]*){3,}|(_[ \t]*){3,})$") +_SETEXT = re.compile(r"(?:=+|-+)[ \t]*$") +_ATX = re.compile(r"#{1,6}(?:[ \t]|$)") +_FENCE_OPEN = re.compile(r"(`{3,}|~{3,})(.*)") +_FENCE_CLOSE = re.compile(r"(`{3,}|~{3,})[ \t]*$") +_LIST_MARKER = re.compile(r"([-*+]|\d{1,9}[.)])(?:([ \t]+)|$)") +_HTML_BLOCK_1 = re.compile(r"<(?:pre|script|style|textarea)(?:[ \t>]|$)", re.IGNORECASE) +_HTML_BLOCK_1_END = re.compile(r"", re.IGNORECASE) +_HTML_COMMENT_OPEN = re.compile(r"") +_HTML_BLOCK_6 = re.compile( + r"]|$)", + re.IGNORECASE, +) _MD_UNESCAPE = re.compile( r"\\([!\"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~])" r"|(&(?:#[0-9]{1,7}|#[xX][0-9a-fA-F]{1,6}|[A-Za-z][A-Za-z0-9]{1,31});)" @@ -120,9 +134,16 @@ def _source_for(dest_name: str) -> Path | None: _TITLE = r'(?:"(?:\\.|[^"\\])*"|\'(?:\\.|[^\'\\])*\'|\((?:\\.|[^()\\])*\))' _DEST_TAIL = re.compile(rf"(?:\s+{_TITLE})?\s*\)") _REF_DEF = re.compile( - rf"(?m)^[ \t]{{0,3}}\[(?![ \t]*\])(?:[^\]\n\\]|\\[^\n])+\]:[ \t]*(?:\r?\n[ \t]*)?" - rf"(?:<((?:[^>\n\\]|\\.)+)>|((?:[^\s\\]|\\.)+))(?:[ \t]+{_TITLE})?[ \t]*(?=$|\r?\n)" + rf"[ \t]{{0,3}}\[(?![ \t]*\])(?:[^\[\]\\]|\\[^\n]){{1,999}}\]:[ \t]*(?:\n[ \t]*)?" + rf"(?:<((?:[^<>\n\\]|\\.)*)>|((?:[^\s\\]|\\.)+))" + rf"(?:(?:[ \t]+|[ \t]*\n[ \t]*){_TITLE})?[ \t]*(?=$|\n)" +) +_AUTOLINK_OR_HTML = re.compile( + r"<(?:[A-Za-z][A-Za-z0-9+.-]{1,31}:[^\s<>]*|!--[\s\S]*?--|" + r"/?[A-Za-z][A-Za-z0-9-]*" + r"(?:\s+[^\s\"'>/=]+(?:\s*=\s*(?:\"[^\"]*\"|'[^']*'|[^\s\"'=<>`]+))?)*\s*/?)>" ) +_LINK_TOK = re.compile(r"\\[^\n]|!\[|\[|\]") def _unescape_md(value: str) -> str: @@ -132,158 +153,408 @@ def _unescape_md(value: str) -> str: ) -def _mask_inline_code(text: str) -> str: - """Replace inline code spans with spaces while respecting backslash-escaped backticks.""" - out = list(text) - i = 0 - n = len(text) - while i < n: - ch = text[i] - if ch == "\\": - i += 2 - continue - if ch != "`": - i += 1 - continue - run_end = i - while run_end < n and text[run_end] == "`": - run_end += 1 - tick_len = run_end - i - j = run_end - close_end = -1 - while j < n: - if text[j] == "\n": - if _BLOCK_BREAK.match(text, j + 1): - break - elif text[j] == "`": - c_end = j - while c_end < n and text[c_end] == "`": - c_end += 1 - if c_end - j == tick_len: - close_end = c_end - break - j = c_end - continue - j += 1 - if close_end > 0: - for k in range(i, close_end): - if out[k] != "\n": - out[k] = " " - i = close_end - else: - i = run_end - return "".join(out) +@dataclass +class _Container: + kind: str # "bq" or "list" + width: int = 0 + empty: bool = False -def _indent_width(line: str) -> tuple[int, int]: - """Return CommonMark leading indent width in columns and first non-indent char index.""" - col = 0 - idx = 0 - n = len(line) - while idx < n: - ch = line[idx] +@dataclass +class _LineCursor: + line: str + idx: int = 0 + col: int = 0 + pad: int = 0 + + def peek_indent(self) -> tuple[int, int]: + """Return (leading whitespace columns, char index of first non-whitespace char).""" + cols = self.pad + i = self.idx + c = self.col + self.pad + n = len(self.line) + while i < n: + ch = self.line[i] + if ch == " ": + cols += 1 + c += 1 + elif ch == "\t": + step = 4 - (c % 4) + cols += step + c += step + else: + break + i += 1 + return cols, i + + def is_blank(self) -> bool: + _, i = self.peek_indent() + return i >= len(self.line) + + def consume_cols(self, count: int) -> None: + """Advance across ``count`` indentation columns, expanding tabs into virtual spaces.""" + rem = count + if self.pad: + take = min(self.pad, rem) + self.pad -= take + self.col += take + rem -= take + n = len(self.line) + while rem > 0 and self.idx < n: + rem -= self._step_col(rem) + + def _step_col(self, rem: int) -> int: + ch = self.line[self.idx] if ch == " ": - col += 1 - elif ch == "\t": - col += 4 - (col % 4) - else: + self.idx += 1 + self.col += 1 + return 1 + if ch == "\t": + step = 4 - (self.col % 4) + self.idx += 1 + take = min(step, rem) + self.col += take + self.pad = step - take + return take + return rem + + def consume_chars(self, count: int) -> None: + self.pad = 0 + self.idx += count + self.col += count + + +def _consume_bq(cur: _LineCursor) -> bool: + indent, nonws = cur.peek_indent() + if indent >= 4 or nonws >= len(cur.line) or cur.line[nonws] != ">": + return False + cur.consume_cols(indent) + cur.consume_chars(1) + if cur.peek_indent()[0] > 0: + cur.consume_cols(1) + return True + + +def _match_containers(cur: _LineCursor, containers: list[_Container]) -> int: + matched = 0 + for cont in containers: + if cont.kind == "bq": + if not _consume_bq(cur): + break + matched += 1 + continue + indent, nonws = cur.peek_indent() + if nonws >= len(cur.line): + matched += 1 + continue + if indent < cont.width: break - idx += 1 - return col, idx + cur.consume_cols(cont.width) + matched += 1 + return matched -def _list_content_indent(rest: str, col: int) -> int | None: - """Return a list item's content indent column if ``rest`` starts a list marker.""" - match = _LIST_MARKER.match(rest) - if not match: +def _list_marker_allowed(marker: str, is_empty: bool, interrupting_para: bool) -> bool: + if not interrupting_para: + return True + if is_empty: + return False + return not marker[0].isdigit() or marker[:-1] == "1" + + +def _try_open_list(cur: _LineCursor, interrupting_para: bool) -> _Container | None: + indent, nonws = cur.peek_indent() + if indent >= 4 or nonws >= len(cur.line): + return None + rest = cur.line[nonws:] + if _THEMATIC.match(rest): + return None + m = _LIST_MARKER.match(rest) + if not m: + return None + marker = m.group(1) + is_empty = nonws + m.end() >= len(cur.line) + if not _list_marker_allowed(marker, is_empty, interrupting_para): return None - marker_end = col + match.start(1) - c = marker_end - for ch in match.group(1): - c += 1 if ch == " " else 4 - (c % 4) - return marker_end + 1 if c - marker_end >= 5 else c + cur.consume_cols(indent) + cur.consume_chars(len(marker)) + if is_empty: + return _Container("list", width=indent + len(marker) + 1, empty=True) + ws_cols, _ = cur.peek_indent() + use_cols = 1 if ws_cols >= 5 else ws_cols + cur.consume_cols(use_cols) + return _Container("list", width=indent + len(marker) + use_cols, empty=False) + + +def _opens_fence(rest: str) -> str: + fm = _FENCE_OPEN.match(rest) + if not fm: + return "" + run, info = fm.groups() + return run if run[0] == "~" or "`" not in info else "" -def _pop_lists(list_indents: list[int], col: int) -> None: - while list_indents and list_indents[-1] > col: - list_indents.pop() +def _html_block_end(rest: str) -> re.Pattern[str] | None: + if _HTML_BLOCK_1.match(rest): + return _HTML_BLOCK_1_END + if _HTML_COMMENT_OPEN.match(rest): + return _HTML_COMMENT_END + return None -def _base_indent(list_indents: list[int]) -> int: - return list_indents[-1] if list_indents else 0 +def _is_block_interrupt(cur: _LineCursor, interrupting_para: bool) -> bool: + indent, nonws = cur.peek_indent() + if indent >= 4 or nonws >= len(cur.line): + return False + rest = cur.line[nonws:] + if rest[0] == ">" or _ATX.match(rest) or _THEMATIC.match(rest) or _opens_fence(rest): + return True + if _html_block_end(rest) is not None or _HTML_BLOCK_6.match(rest): + return True + m = _LIST_MARKER.match(rest) + if not m: + return False + return _list_marker_allowed(m.group(1), nonws + m.end() >= len(cur.line), interrupting_para) + + +def _is_only_ref_defs(text: str, spans: list[tuple[int, int]]) -> bool: + if not spans: + return False + block = "\n".join(text[s:e] for s, e in spans) + pos = 0 + n = len(block) + while pos < n: + m = _REF_DEF.match(block, pos) + if not m: + return False + pos = m.end() + if pos < n and block[pos] == "\n": + pos += 1 + return True + + +@dataclass +class _BlockParser: + text: str + blocks: list[tuple[str, list[tuple[int, int]]]] = field(default_factory=list) + containers: list[_Container] = field(default_factory=list) + fence: tuple[str, int] | None = None + html_end: tuple[re.Pattern[str] | None, int] | None = None + para: list[tuple[int, int]] = field(default_factory=list) + + def _flush_para(self) -> None: + if self.para: + self.blocks.append(("para", list(self.para))) + self.para.clear() + + def _handle_blank(self, matched: int) -> None: + del self.containers[matched:] + if self.fence and self.fence[1] > len(self.containers): + self.fence = None + if self.html_end and (self.html_end[0] is None or self.html_end[1] > len(self.containers)): + self.html_end = None + self._flush_para() + while self.containers and self.containers[-1].kind == "list" and self.containers[-1].empty: + self.containers.pop() + + def _handle_active_html(self, cur: _LineCursor, matched: int) -> bool: + if self.html_end is None: + return False + end_pat, depth = self.html_end + if matched < depth: + del self.containers[matched:] + self.html_end = None + return False + if end_pat is not None and end_pat.search(cur.line[cur.idx :]): + self.html_end = None + return True + + def _handle_active_fence(self, cur: _LineCursor, matched: int) -> bool: + if self.fence is None: + return False + marker, depth = self.fence + if matched < depth: + del self.containers[matched:] + self.fence = None + return False + indent, nonws = cur.peek_indent() + if indent < 4: + cm = _FENCE_CLOSE.match(cur.line[nonws:]) + if cm and cm.group(1).startswith(marker): + self.fence = None + return True + + def _open_containers(self, cur: _LineCursor, in_para: bool) -> bool: + opened = False + while True: + if _consume_bq(cur): + new_c: _Container | None = _Container("bq") + else: + new_c = _try_open_list(cur, interrupting_para=in_para) + if new_c is None: + return opened + self._flush_para() + in_para = False + for c in self.containers: + c.empty = False + self.containers.append(new_c) + opened = True + + def _handle_leaf(self, cur: _LineCursor, line_start: int, end_off: int, in_para: bool) -> None: + indent, nonws = cur.peek_indent() + rest = cur.line[nonws:] + if indent < 4 and self._handle_unindented_leaf(rest, line_start + nonws, end_off, in_para): + return + if not in_para and indent >= 4: + self._flush_para() + return + self.para.append((line_start + cur.idx, end_off)) + + def _handle_unindented_leaf( + self, rest: str, abs_nonws: int, end_off: int, in_para: bool + ) -> bool: + if in_para and _SETEXT.match(rest): + self._flush_para() + return True + if run := _opens_fence(rest): + self._flush_para() + self.fence = (run, len(self.containers)) + return True + if (end_pat := _html_block_end(rest)) is not None or _HTML_BLOCK_6.match(rest): + self._flush_para() + if end_pat is None or not end_pat.search(rest): + self.html_end = (end_pat, len(self.containers)) + return True + if _THEMATIC.match(rest): + self._flush_para() + return True + if _ATX.match(rest): + self._flush_para() + self.blocks.append(("heading", [(abs_nonws, end_off)])) + return True + return False + + def feed(self, raw: str, line_start: int) -> None: + stripped = raw.rstrip("\r\n") + end_off = line_start + len(stripped) + cur = _LineCursor(stripped) + matched = _match_containers(cur, self.containers) + if cur.is_blank(): + self._handle_blank(matched) + return + if self._handle_active_html(cur, matched) or self._handle_active_fence(cur, matched): + return + in_para = bool(self.para) and not _is_only_ref_defs(self.text, self.para) + if matched < len(self.containers): + replacing_list = self.containers[matched].kind == "list" + if in_para and not _is_block_interrupt(cur, interrupting_para=not replacing_list): + self.para.append((line_start + cur.idx, end_off)) + return + self._flush_para() + del self.containers[matched:] + in_para = False + if self._open_containers(cur, in_para): + in_para = False + if cur.is_blank(): + return + for c in self.containers: + c.empty = False + self._handle_leaf(cur, line_start, end_off, in_para) + + def extract(self) -> list[tuple[str, list[tuple[int, int]]]]: + offset = 0 + for raw in self.text.splitlines(keepends=True): + self.feed(raw, offset) + offset += len(raw) + self._flush_para() + return self.blocks + + +def _find_code_span_end(block: str, start: int, tick_len: int) -> int: + j = start + n = len(block) + while j < n: + if block[j] == "`": + c_end = j + while c_end < n and block[c_end] == "`": + c_end += 1 + if c_end - j == tick_len: + return c_end + j = c_end + continue + j += 1 + return -1 -def _active_base_indent(list_indents: list[int], col: int, *, pop: bool) -> int: - if pop: - _pop_lists(list_indents, col) - return _base_indent(list_indents) +def _blank_span(out: list[str], start: int, end: int) -> None: + for k in range(start, end): + if out[k] != "\n": + out[k] = " " -def _opens_fence(line: str, col: int, base: int) -> str: - if col >= base + 4: - return "" - marker = _FENCE.match(line) - if not marker: - return "" - run, info = marker.groups() - return run if run.startswith("~") or "`" not in info else "" - - -def _advance_fence(line: str, col: int, base: int, fence: str) -> str: - if col < base + 4: - marker = _FENCE.match(line) - if marker and marker.group(1).startswith(fence) and not marker.group(2).strip(): - return "" - return fence - - -def _starts_indented_code(col: int, base: int, prev_blank: bool, in_indented: bool) -> bool: - return (prev_blank or in_indented) and col >= base + 4 - - -def _update_list_context(rest: str, col: int, list_indents: list[int]) -> None: - if _BLOCK_INTERRUPT.match(rest): - _pop_lists(list_indents, col) - return - if (content_col := _list_content_indent(rest, col)) is not None: - _pop_lists(list_indents, col) - list_indents.append(content_col) - - -def _mask_code(text: str) -> str: - """Hide fenced and indented code blocks and inline code spans without shifting indices.""" - lines: list[str] = [] - list_indents: list[int] = [] - fence = "" - prev_blank = True - in_indented = False - for line in text.splitlines(keepends=True): - col, idx = _indent_width(line) - rest = line[idx:] - if fence: - fence = _advance_fence(line, col, _base_indent(list_indents), fence) - lines.append(_MASK_LINE.sub(" ", line)) - prev_blank = False - continue - if not rest.strip(): - lines.append(line) - prev_blank = True - continue - base = _active_base_indent(list_indents, col, pop=prev_blank) - if opened := _opens_fence(line, col, base): - _pop_lists(list_indents, col) - fence = opened - in_indented = False - lines.append(_MASK_LINE.sub(" ", line)) - elif _starts_indented_code(col, base, prev_blank, in_indented): - in_indented = True - lines.append(_MASK_LINE.sub(" ", line)) +def _mask_code_span(block: str, out: list[str], start: int) -> int: + n = len(block) + run_end = start + while run_end < n and block[run_end] == "`": + run_end += 1 + close_end = _find_code_span_end(block, run_end, run_end - start) + if close_end > 0: + _blank_span(out, start, close_end) + return close_end + return run_end + + +def _mask_inline_code_and_html(block: str) -> str: + """Replace inline code spans and autolinks/HTML tags with spaces without shifting indices.""" + out = list(block) + i = 0 + n = len(block) + while i < n: + ch = block[i] + if ch == "\\": + i += 2 + elif ch == "`": + i = _mask_code_span(block, out, i) + elif ch == "<" and (m := _AUTOLINK_OR_HTML.match(block, i)): + _blank_span(out, i, m.end()) + i = m.end() else: - in_indented = False - _update_list_context(rest, col, list_indents) - lines.append(line) - prev_blank = False - return _mask_inline_code("".join(lines)) + i += 1 + return "".join(out) + + +def _parse_angle_dest(prose: str, i: int) -> tuple[int, int, int] | None: + n = len(prose) + dest_start = i + 1 + j = dest_start + while j < n and prose[j] not in "<>\r\n": + j += 2 if prose[j] == "\\" else 1 + if j >= n or prose[j] != ">": + return None + return dest_start, j, j + 1 + + +def _parse_bare_dest(prose: str, i: int) -> tuple[int, int, int] | None: + n = len(prose) + dest_start = i + depth = 0 + while i < n: + ch = prose[i] + if ch == "\\" and i + 1 < n: + i += 2 + elif ch.isspace() or ord(ch) < 32: + break + elif ch == "(": + depth += 1 + i += 1 + elif ch == ")": + if depth == 0: + break + depth -= 1 + i += 1 + else: + i += 1 + return (dest_start, i, i) if depth == 0 and i > dest_start else None def _parse_inline_destination(prose: str, pos: int) -> tuple[int, int, int] | None: @@ -296,84 +567,99 @@ def _parse_inline_destination(prose: str, pos: int) -> tuple[int, int, int] | No i += 1 if i >= n: return None - if prose[i] == "<": - dest_start = i + 1 - i = dest_start - while i < n and prose[i] not in ">\r\n": - i += 2 if prose[i] == "\\" else 1 - if i >= n or prose[i] != ">": - return None - dest_end = i - i += 1 - else: - dest_start = i - depth = 0 - while i < n: - ch = prose[i] - if ch == "\\" and i + 1 < n: - i += 2 - elif ch.isspace() or ord(ch) < 32: - break - elif ch == "(": - depth += 1 - i += 1 - elif ch == ")": - if depth == 0: - break - depth -= 1 - i += 1 - else: - i += 1 - if depth != 0 or i == dest_start: - return None - dest_end = i - tail = _DEST_TAIL.match(prose, i) + parsed = _parse_angle_dest(prose, i) if prose[i] == "<" else _parse_bare_dest(prose, i) + if parsed is None: + return None + dest_start, dest_end, next_i = parsed + tail = _DEST_TAIL.match(prose, next_i) return (dest_start, dest_end, tail.end()) if tail else None def _is_relative_target(target: str) -> bool: - return not target.startswith("/") and not urlsplit(target).scheme + return bool(target) and not target.startswith("/") and not urlsplit(target).scheme + + +def _consume_ref_defs( + block: str, pos_map: list[int], text: str +) -> tuple[int, list[tuple[int, int, str]]]: + found: list[tuple[int, int, str]] = [] + pos = 0 + n = len(block) + while pos < n: + m = _REF_DEF.match(block, pos) + if not m: + break + ds, de = m.span(1 if m[1] is not None else 2) + if ds < de: + abs_s, abs_e = pos_map[ds], pos_map[de - 1] + 1 + target = text[abs_s:abs_e] + if _is_relative_target(target): + found.append((abs_s, abs_e, target)) + pos = m.end() + if pos < n and block[pos] == "\n": + pos += 1 + return pos, found -def _relative_links(text: str) -> Iterator[tuple[int, int, str]]: - """Yield (start, end, target) for inline links, linked images, and reference definitions.""" - prose = _mask_code(text) - tokens: list[tuple[int, int, str, int | None, int | None]] = [] - for match in _REF_DEF.finditer(prose): - group = 1 if match[1] is not None else 2 - s, e = match.span(group) - tokens.append((match.start(), match.end(), "ref", s, e)) - for match in re.finditer(r"\\[^\n]|\[|\]|\n[ \t]*\n", prose): - tokens.append((match.start(), match.end(), match[0], None, None)) - tokens.sort(key=lambda item: item[0]) +def _deactivate_outer_links(stack: list[list[bool]]) -> None: + for entry in stack: + if not entry[0]: + entry[1] = False - depth = 0 + +def _extract_inline_target( + ds: int, de: int, base: int, pos_map: list[int], text: str +) -> tuple[int, int, str] | None: + if ds >= de: + return None + abs_s, abs_e = pos_map[base + ds], pos_map[base + de - 1] + 1 + target = text[abs_s:abs_e] + return (abs_s, abs_e, target) if _is_relative_target(target) else None + + +def _scan_inline_links( + prose: str, base: int, pos_map: list[int], text: str +) -> Iterator[tuple[int, int, str]]: + stack: list[list[bool]] = [] # [is_image, active] cursor = 0 - for tok_start, tok_end, kind, ref_s, ref_e in tokens: - if tok_start < cursor: + for m in _LINK_TOK.finditer(prose): + ts, te, tok = m.start(), m.end(), m[0] + if ts < cursor: continue - if kind == "ref": - assert ref_s is not None and ref_e is not None - target = text[ref_s:ref_e] - if _is_relative_target(target): - yield ref_s, ref_e, target - cursor = tok_end - depth = 0 - elif kind == "[": - depth += 1 - elif kind.startswith("\n"): - depth = 0 - elif kind == "]" and depth: - depth -= 1 - parsed = _parse_inline_destination(prose, tok_end) - if parsed is not None: - dest_start, dest_end, tail_end = parsed - target = text[dest_start:dest_end] - if _is_relative_target(target): - yield dest_start, dest_end, target + if tok in ("![", "["): + stack.append([tok == "![", True]) + elif tok == "]" and stack: + is_img, active = stack.pop() + if active and (parsed := _parse_inline_destination(prose, te)) is not None: + ds, de, tail_end = parsed + if link := _extract_inline_target(ds, de, base, pos_map, text): + yield link + if not is_img: + _deactivate_outer_links(stack) cursor = tail_end +def _relative_links(text: str) -> Iterator[tuple[int, int, str]]: + """Yield (start, end, target) for inline links, linked images, and reference definitions.""" + for kind, spans in _BlockParser(text).extract(): + parts: list[str] = [] + pos_map: list[int] = [] + for idx_s, (s, e) in enumerate(spans): + if idx_s > 0: + parts.append("\n") + pos_map.append(-1) + parts.append(text[s:e]) + pos_map.extend(range(s, e)) + block = "".join(parts) + pos = 0 + if kind == "para": + pos, ref_links = _consume_ref_defs(block, pos_map, text) + yield from ref_links + if pos < len(block): + prose = _mask_inline_code_and_html(block[pos:]) + yield from _scan_inline_links(prose, pos, pos_map, text) + + def _site_files() -> set[str]: # URLs are case-sensitive even on Windows (docs/INDEX.md and the bespoke index.md). return {p.relative_to(_WEB).as_posix() for p in _WEB.rglob("*") if p.is_file()} diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index 876f26128..61bd8fea6 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -255,11 +255,11 @@ def test_reference_definitions_and_markdown_escaped_destinations( assert "[Pct](part%281%29.md#a-b)" in rendered assert "[e]: part%281%29.md#a-b" in rendered (web / "SYNTHETIC.md").write_text( - "[Escaped](part\\(1\\).md#a-b)\n[bad]: missing.md\n", + "[Escaped](part\\(1\\).md#a-b)\n\n[bad]: missing.md\n", encoding="utf-8", ) unresolved = list(_gen._unresolved_relative_links()) - assert unresolved == ["UNRESOLVED-LINK: website/docs/SYNTHETIC.md:2: missing.md"] + assert unresolved == ["UNRESOLVED-LINK: website/docs/SYNTHETIC.md:3: missing.md"] def test_nested_parens_indented_code_block_boundaries_and_char_refs( @@ -365,3 +365,63 @@ def test_fenced_code_block_after_indented_code_block_is_masked( "1. Item\n\n ```\n [Example](missing.md)\n ```\n\n [Plan](../PLAN.md)\n" ) assert [t for _, _, t in _gen._relative_links(inside_list)] == ["../PLAN.md"] + + +@pytest.mark.parametrize( + ("source", "expected"), + [ + ("Paragraph\n2. item\n\n [Example](missing.md)\n", []), + ("Paragraph\n1. item\n\n [Plan](../PLAN.md)\n", ["../PLAN.md"]), + ( + "1. Item\n\n ~~~\n example\n\n[Issues](../KNOWN_ISSUES.md)\n", + ["../KNOWN_ISSUES.md"], + ), + ( + "> ~~~\n> [Example](missing.md)\n\n[Issues](../KNOWN_ISSUES.md)\n", + ["../KNOWN_ISSUES.md"], + ), + ("```\n[Example](missing.md)\n\n[AlsoInside](missing.md)\n", []), + ( + "- ~~~\n [Example](missing.md)\n ~~~\n\n[Issues](../KNOWN_ISSUES.md)\n", + ["../KNOWN_ISSUES.md"], + ), + ( + "- - ~~~\n [Example](missing.md)\n ~~~\n\n[Issues](../KNOWN_ISSUES.md)\n", + ["../KNOWN_ISSUES.md"], + ), + ( + "1. Item\n2. ~~~\n [Example](missing.md)\n ~~~\n\n[Out](../PLAN.md)\n", + ["../PLAN.md"], + ), + ( + "> - ~~~\n> [Example](missing.md)\n> ~~~\n>\n> [Issues](../KNOWN_ISSUES.md)\n", + ["../KNOWN_ISSUES.md"], + ), + ( + "- [Code](missing.md)\n [Code2](missing.md)\n\n [Plan](../PLAN.md)\n", + ["../PLAN.md"], + ), + ("-\n\n [Code](missing.md)\n", []), + ("-\n [Plan](../PLAN.md)\n\n [Plan2](../PLAN.md)\n", ["../PLAN.md", "../PLAN.md"]), + ("-\tItem\n\n\t[Plan](../PLAN.md)\n", ["../PLAN.md"]), + ("-\tItem\n\n\t\t[Code](missing.md)\n", []), + ("# Heading\n [Code](missing.md)\n", []), + ("---\n [Code](missing.md)\n", []), + ("Heading\n===\n [Code](missing.md)\n", []), + ("> [Code](missing.md)\n", []), + ("> quote\n> [Plan](../PLAN.md)\n", ["../PLAN.md"]), + ("\n[Real](../PLAN.md)\n", ["../PLAN.md"]), + ("
\n[Raw](missing.md)\n
\n\n[Real](../PLAN.md)\n", ["../PLAN.md"]), + ("
\n\n[Real](../PLAN.md)\n\n
\n", ["../PLAN.md"]), + ('x [Real](../PLAN.md)\n', ["../PLAN.md"]), + ("[![alt](img.png)](../PLAN.md)\n", ["img.png", "../PLAN.md"]), + ("![alt [inner](../PLAN.md)](img.png)\n", ["../PLAN.md", "img.png"]), + ("[outer [inner](../PLAN.md)](missing.md)\n", ["../PLAN.md"]), + (r"\![alt](../PLAN.md)" + "\n", ["../PLAN.md"]), + ("- Item\n\n [p]: ../PLAN.md\n\n [Plan][p]\n", ["../PLAN.md"]), + ("> [p]: ../PLAN.md\n>\n> [Plan][p]\n", ["../PLAN.md"]), + ("Paragraph\n[p]: missing.md\n", []), + ], +) +def test_commonmark_container_fence_and_inline_edge_cases(source: str, expected: list[str]) -> None: + assert [t for _, _, t in _gen._relative_links(source)] == expected From 21d7babbbdb49b2fe217cff5e1bc3c20b2a3f5dd Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 11:56:16 +0000 Subject: [PATCH 06/28] fix(docs): link the default branch and close three link-scanner gaps (#1755) - GitHub links target develop, the default branch the site deploys from and the tree the generator checks a file exists on. - An angle-bracket destination such as [x]() is a link, not an HTML tag. - A malformed external URL no longer aborts the scan (scheme detected without urlsplit). - Character references decode before the URL is split at '#', in both the renderer and --check. --- CHANGELOG.md | 4 +- scripts/ci/generate_website_docs.py | 23 +++++--- tests/scripts/test_generate_website_docs.py | 61 ++++++++++++++++----- website/docs/ACCOUNT_SAFETY.md | 6 +- website/docs/ARCHITECTURE.md | 18 +++--- website/docs/BROWSER_MODES.md | 8 +-- website/docs/CHARACTER.md | 12 ++-- website/docs/CONFIGURATION.md | 4 +- website/docs/DATA_LAYER.md | 16 +++--- website/docs/DEBUGGING.md | 8 +-- website/docs/DEVELOPMENT.md | 22 ++++---- website/docs/E2E_TESTING.md | 8 +-- website/docs/ERRORS.md | 2 +- website/docs/INSTRUCTIONS.md | 2 +- website/docs/KNOWN_ISSUES.md | 58 ++++++++++---------- website/docs/MCP.md | 8 +-- website/docs/MEDIA_LIBRARY.md | 6 +- website/docs/MOVIE.md | 4 +- website/docs/PROMPT_EXPANSION.md | 12 ++-- website/docs/SECURITY.md | 4 +- website/docs/TOOLS.md | 14 ++--- website/docs/USAGE.md | 18 +++--- 22 files changed, 180 insertions(+), 138 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58e0e2688..88a3b22fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,8 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Published documentation now links to GitHub for repository files and directories outside - the site mirror. CI reports broken relative links with their page and line number (#1755). +- Published documentation now links to GitHub's default branch (`develop`) for repository + files and directories outside the site mirror. CI reports broken relative links with their page and line number (#1755). - The storyboard tool now sends the requested panel count to the model for inline `--tool`, standalone `tools run --panels`, and MCP generation requests. It accepts 1 to 20 panels and defaults to 4 (#1754). diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index a1613c084..cfb77f651 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -144,6 +144,8 @@ def _source_for(dest_name: str) -> Path | None: r"(?:\s+[^\s\"'>/=]+(?:\s*=\s*(?:\"[^\"]*\"|'[^']*'|[^\s\"'=<>`]+))?)*\s*/?)>" ) _LINK_TOK = re.compile(r"\\[^\n]|!\[|\[|\]") +_DEST_OPEN = re.compile(r"\]\(\s*$") +_SCHEME = re.compile(r"[A-Za-z][A-Za-z0-9+.-]*:") def _unescape_md(value: str) -> str: @@ -515,7 +517,11 @@ def _mask_inline_code_and_html(block: str) -> str: i += 2 elif ch == "`": i = _mask_code_span(block, out, i) - elif ch == "<" and (m := _AUTOLINK_OR_HTML.match(block, i)): + elif ( + ch == "<" + and not _DEST_OPEN.search(block, 0, i) # `]()` is a destination, not HTML. + and (m := _AUTOLINK_OR_HTML.match(block, i)) + ): _blank_span(out, i, m.end()) i = m.end() else: @@ -576,7 +582,8 @@ def _parse_inline_destination(prose: str, pos: int) -> tuple[int, int, int] | No def _is_relative_target(target: str) -> bool: - return bool(target) and not target.startswith("/") and not urlsplit(target).scheme + # Regex, not urlsplit: urlsplit raises on a malformed authority such as `https://[x`. + return bool(target) and not target.startswith("/") and not _SCHEME.match(target) def _consume_ref_defs( @@ -666,10 +673,11 @@ def _site_files() -> set[str]: def _site_link(target: str, source_dir: Path, dest_dir: Path, published: dict[Path, Path]) -> str: - url = urlsplit(target) + decoded = _unescape_md(target) # Before splitting: `/` holds a '#' that is not a fragment. + url = urlsplit(decoded) site_path = url.path if site_path: - decoded_path = unquote(_unescape_md(site_path)) + decoded_path = unquote(site_path) canonical = (source_dir / decoded_path).resolve() destination = published.get(canonical) if destination is not None: @@ -679,8 +687,9 @@ def _site_link(target: str, source_dir: Path, dest_dir: Path, published: dict[Pa return target kind = "tree" if canonical.is_dir() else "blob" path = quote(canonical.relative_to(_REPO).as_posix()) - suffix = target.removeprefix(url.path) # Keep GitHub's query and fragment verbatim. - return f"{_GITHUB_REPO}/{kind}/main/{path}{suffix}" + suffix = decoded.removeprefix(url.path) # Keep GitHub's query and fragment verbatim. + # develop: the default branch, which the site deploys from and this script checks. + return f"{_GITHUB_REPO}/{kind}/develop/{path}{suffix}" elif (dest_dir / decoded_path).resolve() not in published: return target # Leave the unresolved destination intact for --check. return url._replace(path=site_path, fragment=re.sub("-{2,}", "-", url.fragment)).geturl() @@ -753,7 +762,7 @@ def _unresolved_relative_links() -> Iterator[str]: for page in sorted(_WEB.rglob("*.md")): text = page.read_text(encoding="utf-8") for start, _, target in _relative_links(text): - path = unquote(_unescape_md(urlsplit(target).path)) + path = unquote(urlsplit(_unescape_md(target)).path) parent = page.parent.relative_to(_WEB).as_posix() if path and posixpath.normpath(posixpath.join(parent, path)) not in site_files: line = text.count("\n", 0, start) + 1 diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index 61bd8fea6..5681a1820 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -102,7 +102,7 @@ def test_a_docs_link_to_a_mirrored_root_file_becomes_a_sibling_link() -> None: so `../` would leave the docs tree (PR #1237 review). Fragment and query survive.""" out = _gen.render("USAGE.md", "see [KI](../KNOWN_ISSUES.md#a-b) and [C](../CHANGELOG.md)") assert "](KNOWN_ISSUES.md#a-b)" in out - assert "](https://github.com/ffroliva/gflow-cli/blob/main/CHANGELOG.md)" in out + assert "](https://github.com/ffroliva/gflow-cli/blob/develop/CHANGELOG.md)" in out def test_a_relative_anchor_takes_the_mkdocs_slug() -> None: @@ -118,20 +118,20 @@ def test_a_relative_anchor_takes_the_mkdocs_slug() -> None: @pytest.mark.parametrize( ("source", "target", "expected"), [ - ("SYNTHETIC.md", "../PLAN.md#phase--7", "blob/main/PLAN.md#phase--7"), - ("USAGE.md", "../src/gflow_cli/cli.py", "blob/main/src/gflow_cli/cli.py"), - ("USAGE.md", "../src/gflow_cli/mcp/", "tree/main/src/gflow_cli/mcp"), - ("USAGE.md", "FLOW_WIRE_RPCS.md", "blob/main/docs/FLOW_WIRE_RPCS.md"), + ("SYNTHETIC.md", "../PLAN.md#phase--7", "blob/develop/PLAN.md#phase--7"), + ("USAGE.md", "../src/gflow_cli/cli.py", "blob/develop/src/gflow_cli/cli.py"), + ("USAGE.md", "../src/gflow_cli/mcp/", "tree/develop/src/gflow_cli/mcp"), + ("USAGE.md", "FLOW_WIRE_RPCS.md", "blob/develop/docs/FLOW_WIRE_RPCS.md"), ( "USAGE.md", "superpowers/spikes/2026-11-10-rpc-descriptor-churn.md", - "blob/main/docs/superpowers/spikes/2026-11-10-rpc-descriptor-churn.md", + "blob/develop/docs/superpowers/spikes/2026-11-10-rpc-descriptor-churn.md", ), - ("KNOWN_ISSUES.md", "PLAN.md", "blob/main/PLAN.md"), + ("KNOWN_ISSUES.md", "PLAN.md", "blob/develop/PLAN.md"), ( "KNOWN_ISSUES.md", "docs/INDEX.md#topic--shortcuts", - "blob/main/docs/INDEX.md#topic--shortcuts", + "blob/develop/docs/INDEX.md#topic--shortcuts", ), ], ) @@ -224,7 +224,7 @@ def test_escaped_backticks_and_link_titles_do_not_hide_or_invent_links( r'[Guide](USER_GUIDE.md "See [missing](missing.md)").' ) rendered = _gen.render("GUIDE.md", text) - assert "](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md)" in rendered + assert "](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md)" in rendered assert "[missing](missing.md)" in rendered (web / "GUIDE.md").write_text(rendered, encoding="utf-8") assert _gen.main(["--check"]) == 0 @@ -250,7 +250,7 @@ def test_reference_definitions_and_markdown_escaped_destinations( "[e]: part\\(1\\).md#a--b\n" ) rendered = _gen.render("SYNTHETIC.md", source) - assert "[p]: https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md#s--1" in rendered + assert "[p]: https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md#s--1" in rendered assert "[Escaped](part%281%29.md#a-b)" in rendered assert "[Pct](part%281%29.md#a-b)" in rendered assert "[e]: part%281%29.md#a-b" in rendered @@ -285,9 +285,9 @@ def test_nested_parens_indented_code_block_boundaries_and_char_refs( ) rendered = _gen.render("SYNTHETIC.md", source) assert " [IndentedCode](missing.md)" in rendered - assert "](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md)" in rendered + assert "](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md)" in rendered assert ( - "[Nested](https://github.com/ffroliva/gflow-cli/blob/main/docs/plan%28v1%28draft%29%29.md)" + "[Nested](https://github.com/ffroliva/gflow-cli/blob/develop/docs/plan%28v1%28draft%29%29.md)" in rendered ) assert "[Entity](caf%C3%A9.md#a-b)" in rendered @@ -314,7 +314,7 @@ def test_list_item_continuation_paragraph_links_are_rewritten_and_checked( ordered = "1. Item\n\n [Plan](../PLAN.md)\n" assert [t for _, _, t in _gen._relative_links(ordered)] == ["../PLAN.md"] assert _gen.render("SYNTHETIC.md", ordered) == ( - "1. Item\n\n [Plan](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md)\n" + "1. Item\n\n [Plan](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md)\n" ) bullet = "- Item\n\n [Plan](../PLAN.md)\n" @@ -352,7 +352,7 @@ def test_fenced_code_block_after_indented_code_block_is_masked( with_after = f"{only_fence}[After](../PLAN.md)\n" assert [t for _, _, t in _gen._relative_links(with_after)] == ["../PLAN.md"] assert _gen.render("SYNTHETIC.md", with_after) == ( - f"{only_fence}[After](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md)\n" + f"{only_fence}[After](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md)\n" ) no_blank = " example\n```\n[Example](missing.md)\n```\n[After](../PLAN.md)\n" @@ -425,3 +425,36 @@ def test_fenced_code_block_after_indented_code_block_is_masked( ) def test_commonmark_container_fence_and_inline_edge_cases(source: str, expected: list[str]) -> None: assert [t for _, _, t in _gen._relative_links(source)] == expected + + +def test_link_destination_edge_cases_are_rewritten_and_checked( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + docs = tmp_path / "docs" + web = tmp_path / "website" / "docs" + docs.mkdir(parents=True) + web.mkdir(parents=True) + (tmp_path / "PLAN.md").touch() + (docs / "src").mkdir() + (docs / "USER_GUIDE.md").touch() + monkeypatch.setattr(_gen, "_REPO", tmp_path) + monkeypatch.setattr(_gen, "_DOCS", docs) + monkeypatch.setattr(_gen, "_WEB", web) + gh = "https://github.com/ffroliva/gflow-cli" + + # An angle-bracket destination is a link, not an HTML tag. + angle = "[Sources]()\n" + assert [t for _, _, t in _gen._relative_links(angle)] == ["src"] + assert _gen.render("SYNTHETIC.md", angle) == f"[Sources](<{gh}/tree/develop/docs/src>)\n" + + # A malformed external URL is skipped without aborting the scan. + bad_url = "[Draft](https://[example) then [Plan](../PLAN.md)\n" + assert [t for _, _, t in _gen._relative_links(bad_url)] == ["../PLAN.md"] + + # Character references decode before the URL is split at '#'. + entity = "[Guide](../docs/USER_GUIDE.md)\n" + assert _gen.render("SYNTHETIC.md", entity) == f"[Guide]({gh}/blob/develop/docs/USER_GUIDE.md)\n" + (web / "SYNTHETIC.md").write_text("[Guide](missing/page.md)\n", encoding="utf-8") + assert list(_gen._unresolved_relative_links()) == [ + "UNRESOLVED-LINK: website/docs/SYNTHETIC.md:1: missing/page.md" + ] diff --git a/website/docs/ACCOUNT_SAFETY.md b/website/docs/ACCOUNT_SAFETY.md index 1ec30f8e3..4fedabba3 100644 --- a/website/docs/ACCOUNT_SAFETY.md +++ b/website/docs/ACCOUNT_SAFETY.md @@ -10,7 +10,7 @@ > five files, so a reasonable person could not find it before deciding to install > ([#602](https://github.com/ffroliva/gflow-cli/issues/602)). -Read [DISCLAIMER.md](https://github.com/ffroliva/gflow-cli/blob/main/DISCLAIMER.md) first — it is the legal statement. This +Read [DISCLAIMER.md](https://github.com/ffroliva/gflow-cli/blob/develop/DISCLAIMER.md) first — it is the legal statement. This page is the operational one. ## Two different things people mean by "will I get banned?" @@ -30,7 +30,7 @@ evidence of absence, and Google's terms are Google's to enforce. The cost model matters too: **credits are only spent on Veo video.** Images and composition operations bill against a per-model daily quota rather than credits, so most failure modes cost you nothing but time — see the cost note in the -[README](https://github.com/ffroliva/gflow-cli/blob/main/README.md#why-gflow-cli). +[README](https://github.com/ffroliva/gflow-cli/blob/develop/README.md#why-gflow-cli). ## What gflow-cli does to stay unremarkable @@ -46,7 +46,7 @@ headed, except `video extend` on flow.google.com, the page fallback of `media tr `media restore`, the video download-menu upscales (4K unmeasured), image-to-image from one local `--ref` file in an existing project on an otherwise direct request, a credit-capped text-to-video of an explicit measured key, reference-to-video from one local image, and a `movie run` with no characters and no instruction cards, which run headless under `auto` (`GFLOW_CLI_TRANSPORT=ui_automation` keeps them headed); `GFLOW_CLI_BROWSER_VISIBILITY=headed` shows the window for every command. The per-command list is in [BROWSER_MODES](BROWSER_MODES.md). The headless mint was measured as accepted on two accounts on Windows -([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md)); macOS, +([spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md)); macOS, Linux and accounts Flow serves on labs.google are unmeasured. **Except credit reads.** On Windows and Linux, `gflow credits` and `gflow_get_credits` send diff --git a/website/docs/ARCHITECTURE.md b/website/docs/ARCHITECTURE.md index cd74f0f0d..eed204918 100644 --- a/website/docs/ARCHITECTURE.md +++ b/website/docs/ARCHITECTURE.md @@ -1,6 +1,6 @@ # Architecture -This document is the steady-state reference for how `gflow-cli` is organised. The intent and sequencing live in [PLAN.md](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md) — this file describes the **shape** that PLAN converges on. +This document is the steady-state reference for how `gflow-cli` is organised. The intent and sequencing live in [PLAN.md](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md) — this file describes the **shape** that PLAN converges on. ## Layers @@ -72,7 +72,7 @@ The hexagonal target above is the steady state. The **current** package — and **Phase 4 does NOT:** - Restructure existing modules beyond minimal dedup (shared CLI helpers were promoted to `gflow_cli._cli_helpers` at the package top level — kept flat to avoid a `cli.py` file / `cli/` package collision). -- Introduce dependency-injection containers, command/query buses, or any DDD/CQRS scaffolding (deferred per [PLAN ADR #2](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md#5-decision-log-adrs-in-miniature)). +- Introduce dependency-injection containers, command/query buses, or any DDD/CQRS scaffolding (deferred per [PLAN ADR #2](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md#5-decision-log-adrs-in-miniature)). **v0.6.0a2 module additions — auth strategy package:** @@ -120,8 +120,8 @@ When the project converges on the hexagonal target above, modules graduate to la ## Folder layout > **Note: this document describes the TARGET architecture, not the current -> package layout.** The current shape (per [PLAN.md § 2](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md#2-architecture-steady-state) -> and [ADR #2](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md#5-decision-log-adrs-in-miniature)) is the simpler +> package layout.** The current shape (per [PLAN.md § 2](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md#2-architecture-steady-state) +> and [ADR #2](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md#5-decision-log-adrs-in-miniature)) is the simpler > `src/gflow_cli/{_errors/, api/, auth/, data/, flow_selectors/, mcp/, services/, tools/, > ui/, worker/}` packages plus flat modules — the `cli*.py` adapters, `_cli_helpers.py`, > `_win_owner_only.py`, `browser_manager.py`, `chain*.py`, `composition.py`, `config.py`, @@ -421,8 +421,8 @@ The dependency direction is inviolate. Everything else is preference, not religi ## See also -- [PLAN.md](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md) — phasing, exit criteria, ADRs -- [CONTRIBUTING.md](https://github.com/ffroliva/gflow-cli/blob/main/CONTRIBUTING.md) — TDD discipline, test categories +- [PLAN.md](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md) — phasing, exit criteria, ADRs +- [CONTRIBUTING.md](https://github.com/ffroliva/gflow-cli/blob/develop/CONTRIBUTING.md) — TDD discipline, test categories - [AUTHENTICATION.md](AUTHENTICATION.md) — full auth flow lifecycle --- @@ -454,7 +454,7 @@ The dependency direction is inviolate. Everything else is preference, not religi aisandbox-pa.googleapis.com (Google's private Flow API) ``` -The `Provider` interface keeps backends interchangeable. v0.1 shipped `FlowProvider`. Google's separately billed Gemini / Vertex AI generation APIs are out of scope ([ROADMAP](https://github.com/ffroliva/gflow-cli/blob/main/ROADMAP.md#out-of-scope)). +The `Provider` interface keeps backends interchangeable. v0.1 shipped `FlowProvider`. Google's separately billed Gemini / Vertex AI generation APIs are out of scope ([ROADMAP](https://github.com/ffroliva/gflow-cli/blob/develop/ROADMAP.md#out-of-scope)). ## Auth strategy @@ -505,7 +505,7 @@ used only where it is strictly necessary. reCAPTCHA Enterprise token, and the request goes to Flow over direct HTTP. A refusal Flow reports as `PUBLIC_ERROR_UNUSUAL_ACTIVITY`, which is not billed, is retried once from a new headless browser process ([KNOWN_ISSUES](KNOWN_ISSUES.md)). The evidence is - [the direct video and headless mint spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md): + [the direct video and headless mint spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md): 15/15 headless cold mints accepted on two accounts (30/30 counting both visibilities), and headless and headed video submits accepted 6/6 each on fresh browsers. - **Video extend on flow.google.com drives Flow's page headless.** It is a UI surface, but a @@ -561,7 +561,7 @@ shell carries no `at`. Caveats and controls: Until v0.108.0 every generation drove Flow's page in a headed Chrome window: reCAPTCHA Enterprise rejected the earlier headless approaches, and the UI transport was the only path that produced a video. v0.108.0 measured a headless mint as accepted and moved the measured request -shapes to direct HTTP ([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md), +shapes to direct HTTP ([spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md), [#1371](https://github.com/ffroliva/gflow-cli/issues/1371)). This section records the earlier design and why it was chosen; it does not describe the current product. diff --git a/website/docs/BROWSER_MODES.md b/website/docs/BROWSER_MODES.md index b933c05c1..bd07346a1 100644 --- a/website/docs/BROWSER_MODES.md +++ b/website/docs/BROWSER_MODES.md @@ -6,7 +6,7 @@ reCAPTCHA token. The request itself goes to Flow over direct HTTP. Surfaces that Flow's own interface open a **headed** (visible) Chrome window. Local commands open no browser. This page is the single source of the per-command list. The wire details of the direct path are -in [DIRECT_TRANSPORT](https://github.com/ffroliva/gflow-cli/blob/main/docs/DIRECT_TRANSPORT.md); the settings are in +in [DIRECT_TRANSPORT](https://github.com/ffroliva/gflow-cli/blob/develop/docs/DIRECT_TRANSPORT.md); the settings are in [CONFIGURATION](CONFIGURATION.md#gflow_cli_browser_visibility). All rows below describe the default, `GFLOW_CLI_BROWSER_VISIBILITY=auto`. @@ -44,7 +44,7 @@ browser has been measured, so `auto` runs them headless. | `video upscale --scale 4k` | headless on `flow.google.com` (not measured) | Ultra only, so not measured: it follows the measured video download-menu path by an explicit decision ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). It spends credits on the click, and a failure after the click is never retried. `--browser-visibility headed` shows the window | | `video t2v --max-credits` | headless when only the cap needs the UI | A capped text-to-video whose uncapped request is an explicit measured key (for example `--model omni-1.2-flash --duration 4 --resolution 360p`; with no `--model` the key is the account's selection and it stays headed) reads Flow's quote in a headless browser: it reached the submit 2/2 headless matching a headed control with the submit aborted, and billed headless runs of that key on one account completed at the quoted 4 credits (3/3), and the other measured keys follow it by decision; an account that refused it headless refused the headed control too ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). A capped video of any other shape and a capped image-to-video stay headed; a capped reference-to-video follows the `video r2v --ref` row. `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | | `video r2v --ref` | headless with one local image | A reference-to-video from exactly one local image (no saved asset, character, voice or `@` mention, one output) drives Flow's composer in a headless browser: it reached the submit 2/2 headless matching a headed control with the submit aborted, and a billed headless run (Omni 1.2 Flash, 4 s, 360p) completed at the quoted 4 credits; other models and durations follow it by decision, and a configured proxy is unmeasured ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). An MCP reference given as a catalogued asset id resolves to its local file and counts as that file. An explicit `GFLOW_CLI_FLOW_HOST=labs.google` or `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | -| `movie run` | headless for a plain movie | A manifest with no characters and no instruction cards drives each scene, on any model, through Flow's composer in a headless browser, and the retry loop's UI fallback keeps that browser: a billed one-scene headless run (Omni 1.2 Flash, 4 s) completed at 4 credits, and the e2e completed headless ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554), [spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-30-headless-movie-and-agent-only.md)). Characters or instruction cards keep the whole run headed; an explicit `GFLOW_CLI_FLOW_HOST=labs.google` or `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | +| `movie run` | headless for a plain movie | A manifest with no characters and no instruction cards drives each scene, on any model, through Flow's composer in a headless browser, and the retry loop's UI fallback keeps that browser: a billed one-scene headless run (Omni 1.2 Flash, 4 s) completed at 4 credits, and the e2e completed headless ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554), [spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-30-headless-movie-and-agent-only.md)). Characters or instruction cards keep the whole run headed; an explicit `GFLOW_CLI_FLOW_HOST=labs.google` or `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | ## Headed (Flow's UI) @@ -54,7 +54,7 @@ browser has been measured, so `auto` runs them headless. | `image batch` | headed | The stay-mounted UI batch drives the composer; on an account served flow.google.com, gflow cannot drive it yet in either mode (exit 36, [#639](https://github.com/ffroliva/gflow-cli/issues/639)), so headless is unmeasured | | `image upscale --scale 2k` | headed | Headless was refused on one of two accounts while headed passed: after a day of runs, `SPrCad` answered `PUBLIC_ERROR_UNUSUAL_ACTIVITY` to three headless 2K upscales and accepted the headed one (unbilled); the other account passed both ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). `--scale 4k` (Ultra) follows the same path and stays headed | | `movie run` (with characters or instruction cards) | headed | Characters are created or attached and instruction cards are synced in Flow's UI, which is not measured headless; scene requests carry no resolution, so no scene goes direct | -| agent-only composer | the command's own launch (unmeasured) | gflow recognises the agent-only composer ([#799](https://github.com/ffroliva/gflow-cli/issues/799)) only after the page loads, so it runs in the browser the command launched: headed for most UI commands, headless for a measured headless surface such as a plain `movie run`. No account available was served it, so headless on it is unmeasured ([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-30-headless-movie-and-agent-only.md)). `--browser-visibility headed` shows the window | +| agent-only composer | the command's own launch (unmeasured) | gflow recognises the agent-only composer ([#799](https://github.com/ffroliva/gflow-cli/issues/799)) only after the page loads, so it runs in the browser the command launched: headed for most UI commands, headless for a measured headless surface such as a plain `movie run`. No account available was served it, so headless on it is unmeasured ([spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-30-headless-movie-and-agent-only.md)). `--browser-visibility headed` shows the window | | `video r2v` (other shapes) | headed | Two or more references, a saved asset, a character, an `@` mention, more than one output or `--ui-mode agentic` is not measured headless; reference-to-video is not measured over direct HTTP | | `video edit` | headed | On an account served flow.google.com, editing an existing clip by media id exits 23 in either mode ([#1605](https://github.com/ffroliva/gflow-cli/issues/1605)); a local clip reached the checked `jIps6` request in a $0 e2e with the submit aborted (2026-12-01); headless is unmeasured | | `video i2v --end-frame` | headed | An end frame, or a start frame that is already in the project, is not a measured shape. A billed headless run was refused as unusual activity (unbilled) while the headed control completed ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)) | @@ -167,5 +167,5 @@ below (the in-flight count, the start history, the armed page) carries from one `GFLOW_CLI_HEADLESS=true`) also runs the other Flow UI shapes headless at the user's choice; this is unsupported, see [#1554](https://github.com/ffroliva/gflow-cli/issues/1554). -Evidence: [the direct video and headless mint spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md) +Evidence: [the direct video and headless mint spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md) ([#1371](https://github.com/ffroliva/gflow-cli/issues/1371)). diff --git a/website/docs/CHARACTER.md b/website/docs/CHARACTER.md index 152a7ec78..48c6173ab 100644 --- a/website/docs/CHARACTER.md +++ b/website/docs/CHARACTER.md @@ -2,7 +2,7 @@ > **Status:** SHIPPED (live-verified 2026-06-02) · **Issue:** [#145](https://github.com/ffroliva/gflow-cli/issues/145) · **Branch:** `feature/character-creation` > **Living document.** Evolve this as the feature and Flow's API evolve. Raw capture provenance lives in -> [`CHARACTER_RECON.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/CHARACTER_RECON.md); the cross-feature decision lens is +> [`CHARACTER_RECON.md`](https://github.com/ffroliva/gflow-cli/blob/develop/docs/CHARACTER_RECON.md); the cross-feature decision lens is > [the REST-path capability matrix](#3-capability-cost). > **Credit:** pattern-references @kittinan's avatar PR #123 (attach-flow idiom + CLI scaffolding shape) — but > built **greenfield off `develop`, NOT stacked on #123** (that branch is CONFLICTING and likeness-specific; @@ -10,7 +10,7 @@ > **Shipped scope:** `gflow character create` + `list` + `show` + `voices` + `rm`. Name-based reuse via > `@Name` prompt mentions is **shipped** (v0.40.0, [#344](https://github.com/ffroliva/gflow-cli/issues/344)) -> for both `image` and `video` paths — see [REFERENCE_STRATEGIES](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md). An explicit +> for both `image` and `video` paths — see [REFERENCE_STRATEGIES](https://github.com/ffroliva/gflow-cli/blob/develop/docs/REFERENCE_STRATEGIES.md). An explicit > `--character ` **flag** on `gflow video` (a separate, repeatable-ref delivery mechanism) remains > **not yet implemented** — see [Backlog](#14-backlog-not-yet-implemented). @@ -310,7 +310,7 @@ is **shipped** (see the table below). | `gflow video … --character ` *(repeatable → multi-ref, explicit flag)* | **not yet implemented** (Phase 3) — `referenceEntities` on `video:batchAsyncGenerateVideoReferenceImages` | | `gflow character rm` (`--id`/`--name`) | On `flow.google.com`, moves the character to the project's Trash. Restore it from Trash in Flow. On `labs.google`, deletes the character through `flow:batchDeleteAssets`. Neither action spends credits. | | `gflow image … --character ` *(explicit flag)* | id-based reuse **shipped** as `gflow image t2i/i2i --reference-entity ` (wire captured 2026-06-08, `api/image.py`) | -| `@Name` in a t2i/i2i/video prompt | name-based mention resolution **shipped v0.40.0 (#344)** — resolves to the staged character entity, works on both image and video paths (on flow.google.com, video `@Name` works on `r2v` alongside a `--ref` or `--reference-entity`; other video modes on that host refuse character references before submit, exit 36); see [REFERENCE_STRATEGIES](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md) | +| `@Name` in a t2i/i2i/video prompt | name-based mention resolution **shipped v0.40.0 (#344)** — resolves to the staged character entity, works on both image and video paths (on flow.google.com, video `@Name` works on `r2v` alongside a `--ref` or `--reference-entity`; other video modes on that host refuse character references before submit, exit 36); see [REFERENCE_STRATEGIES](https://github.com/ffroliva/gflow-cli/blob/develop/docs/REFERENCE_STRATEGIES.md) | All commands take **`--project ` (required)** — every endpoint (`createEntity`, `projectInitialData`, reuse) is project-scoped; mirrors `gflow scene` / `gflow data` ergonomics. Use `--id`/`--name` flags, never a @@ -344,7 +344,7 @@ never hard-code wire names in user-facing help — see [[cli-model-aliases-verif - **Data layer.** Persist `entityId`, `workflowId`s, `primaryMediaId`s, voice, personality so a character is recoverable and reusable across sessions (mirrors the scene persistence + migration pattern). - **Docs are first-class.** This document is the living spec; update it in the same PR as any behavioural - change. Indexed in [`docs/INDEX.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/INDEX.md). + change. Indexed in [`docs/INDEX.md`](https://github.com/ffroliva/gflow-cli/blob/develop/docs/INDEX.md). ## 10. Open items @@ -426,7 +426,7 @@ convenience later. > Two of three generative routes accept a `TokenMinter` token. Treat the wall as a **per-route measurement**, > never an inherited assumption — and re-measure before citing it. The `batchGenerateImages` 403 has not been > re-tested since 2026-06-02 and may itself be stale. -> Evidence: [superpowers/spikes/2026-08-31-veo-extend-route-recon.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-08-31-veo-extend-route-recon.md). +> Evidence: [superpowers/spikes/2026-08-31-veo-extend-route-recon.md](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-08-31-veo-extend-route-recon.md). - **✅ Decision = Option B (UI-driven generation; structural ops stay REST).** Generation (character image create AND video reuse) **must** ride Flow's native UI so Flow's JS issues the WAF-valid request, which gflow passive-captures — identical mechanism to the existing `generate_image`/`generate_video`. Revised @@ -573,7 +573,7 @@ The following are explicitly **out of the shipped scope** and tracked for future (`services/mentions.py`), on both image and video paths for character references. The image-path wire shape (`gflow image t2i/i2i --reference-entity `) shipped earlier (live capture 2026-06-08, `api/image.py`; asserted by `_assert_image_entities_attached`). See - [REFERENCE_STRATEGIES](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md) for the decision guide across all three mechanisms. + [REFERENCE_STRATEGIES](https://github.com/ffroliva/gflow-cli/blob/develop/docs/REFERENCE_STRATEGIES.md) for the decision guide across all three mechanisms. (`gflow character rm` is now shipped, #150.) - **Set the Flow editor title field** so the editor isn't "Untitled Character" (see [§13.1 Known issues](#131-known-issues)). Investigate either the UI title box (with a Ctrl+A merge-bug workaround) or finding the dedicated title diff --git a/website/docs/CONFIGURATION.md b/website/docs/CONFIGURATION.md index 9e0a907a5..c427f60fd 100644 --- a/website/docs/CONFIGURATION.md +++ b/website/docs/CONFIGURATION.md @@ -624,7 +624,7 @@ per-command `--proxy` flags (the setting covers one-off runs: ### `GFLOW_CLI_FLOW_HOST` -**What:** Which Flow frontend gflow drives. Google has moved Flow from `labs.google/fx/tools/flow` onto `flow.google.com` ([#639](https://github.com/ffroliva/gflow-cli/issues/639)) — measured 2026-09-14, the old labs URL answers **HTTP 308 Permanent Redirect** on every account we tested. The two are the same product (the new frontend's own root element is `aisandbox-root`) on different widget toolkits and different wire protocols, so each has its own driver. Which host you are served does **not** tell you which capabilities work — see [the survey](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-14-two-domain-protocol-survey.md). +**What:** Which Flow frontend gflow drives. Google has moved Flow from `labs.google/fx/tools/flow` onto `flow.google.com` ([#639](https://github.com/ffroliva/gflow-cli/issues/639)) — measured 2026-09-14, the old labs URL answers **HTTP 308 Permanent Redirect** on every account we tested. The two are the same product (the new frontend's own root element is `aisandbox-root`) on different widget toolkits and different wire protocols, so each has its own driver. Which host you are served does **not** tell you which capabilities work — see [the survey](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-14-two-domain-protocol-survey.md). **Values:** - `auto` (default) — **`flow.google.com` is the default host for every video request it can serve today** (`video t2v`, `video i2v` from local files or same-`--project` catalogued image UUIDs (#1542), and local-file `video r2v`; with no `--project` and no `GFLOW_CLI_PROJECT`, one is created first, #864). Image requests use the migrated composer for `image t2i` and local-file `image i2i` where `flow.google.com` is what Flow serves, and stay on labs where labs is. A request the new host cannot serve keeps the labs driver where labs is what Flow serves; where flow.google.com is, there is no labs fallback and unsupported forms exit 36/11 before submit. - `flow.google.com` — force the migrated composer for everything, including what it cannot serve yet (those requests then exit 36/11 instead of falling back). @@ -754,7 +754,7 @@ Variables already set in the actual environment always beat both `.env` files. A An invalid value stops every command except `gflow config` with exit 11 (`ConfigurationError`), on stderr, naming the key as written, its value (masked for a secret), the file or the environment that holds it, and the command that repairs it; `--json` prints one Problem Details object with `key` and `origin`. `gflow config` still runs so the value can be repaired. See [Troubleshooting](#troubleshooting). -Use [`.env.template`](https://github.com/ffroliva/gflow-cli/blob/main/.env.template) as your starting point: +Use [`.env.template`](https://github.com/ffroliva/gflow-cli/blob/develop/.env.template) as your starting point: ```bash cp .env.template .env diff --git a/website/docs/DATA_LAYER.md b/website/docs/DATA_LAYER.md index 29a09ca82..c70eca451 100644 --- a/website/docs/DATA_LAYER.md +++ b/website/docs/DATA_LAYER.md @@ -38,7 +38,7 @@ The schema is adapter-shaped so a future Postgres backend can slot in without ch | `operation_assets` | Many-to-many between operations and assets, with role (`input`/`output`/`seed_start`/`seed_end`/`reference`) and ordered position | When the operation links its inputs/outputs | | `local_files` | One row per downloaded asset location — local path or cloud URI, sha256/byte count when local, media type, `superseded_at` once a later copy replaced it | After each download/upload completes | -Schema lives in [`src/gflow_cli/data/migrations/0001_initial.sql`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/data/migrations/0001_initial.sql). +Schema lives in [`src/gflow_cli/data/migrations/0001_initial.sql`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/data/migrations/0001_initial.sql). ### Operation `metadata_json` provenance @@ -277,7 +277,7 @@ The hash is always stored so you can correlate without the plaintext. ### Metadata redaction -[`redact_metadata`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/data/redaction.py) is applied to every dict that lands in `assets.metadata_json`. It strips: +[`redact_metadata`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/data/redaction.py) is applied to every dict that lands in `assets.metadata_json`. It strips: | Key (case-insensitive) | Replacement | |---|---| @@ -304,7 +304,7 @@ sharing the raw SQLite file if failed queue payloads must stay confidential. In the default `store` mode, failure rows persist a scrubbed, readable copy of the exception's Problem Details `detail` through -[`redact_error_detail`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/data/redaction.py). Free-text +[`redact_error_detail`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/data/redaction.py). Free-text `Bearer …` / `SAPISIDHASH …` tokens and auth-cookie pairs become ``, flow.google.com's bare `at` XSRF value and `0cAF…` reCAPTCHA tokens become ``, URLs carrying signed-query markers and @@ -505,7 +505,7 @@ Cloud-only assets have `LocalFileRecord.path is None` and carry their object location in `LocalFileRecord.cloud_uri`; path-based seed-image resolution is local-only. -The public read API is `DataRepository` ([`src/gflow_cli/data/repository.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/data/repository.py)), whose methods live in the table-group modules `data/_repo_*.py`; all read methods return typed `SeedImage` / `AssetLookup` dataclasses, not raw SQLite rows. +The public read API is `DataRepository` ([`src/gflow_cli/data/repository.py`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/data/repository.py)), whose methods live in the table-group modules `data/_repo_*.py`; all read methods return typed `SeedImage` / `AssetLookup` dataclasses, not raw SQLite rows. --- @@ -525,7 +525,7 @@ See [`CONFIGURATION.md`](CONFIGURATION.md) for the full env-var precedence chain ## Migrations -All schema changes are SQL files under [`src/gflow_cli/data/migrations/`](https://github.com/ffroliva/gflow-cli/tree/main/src/gflow_cli/data/migrations), named `NNNN_description.sql` with a 4+ digit zero-padded prefix. +All schema changes are SQL files under [`src/gflow_cli/data/migrations/`](https://github.com/ffroliva/gflow-cli/tree/develop/src/gflow_cli/data/migrations), named `NNNN_description.sql` with a 4+ digit zero-padded prefix. **How they're applied:** @@ -572,7 +572,7 @@ All three errors map to **exit code 16**: All three are subclasses of `GFlowError` and re-exported through `gflow_cli.exceptions`. They follow the project's RFC 9457 Problem Details pattern. -See [`errors.py::EXIT_CODE_MAP`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/errors.py) for the complete exit-code mapping. +See [`errors.py::EXIT_CODE_MAP`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/errors.py) for the complete exit-code mapping. Distinct from the above (which are errors OF the data layer), the `operations.error_type` column stores the taxonomy of RECORDED generation @@ -588,7 +588,7 @@ the transfer failed — recover it with `gflow data download`). Query them with ### Adding a new operation kind -1. Add the enum value to `OperationKind` in [`data/models.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/data/models.py). +1. Add the enum value to `OperationKind` in [`data/models.py`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/data/models.py). 2. Add a `record_(...)` method to `OperationRecorder` following the existing patterns (upsert profile → project → asset → insert operation → link → asset location rows). 3. Wire it into the CLI call site, mirroring the `_run_t2i` / `record_completed_video` patterns: open recorder BEFORE Flow, close in `finally`, wrap the `record_*` call in `try/except DataStoreError` calling `_warn_persistence_failed_after_success(...)`. @@ -641,7 +641,7 @@ Live tests (`@pytest.mark.live`) and E2E tests (`@pytest.mark.e2e`) are opt-in a - **Postgres / Supabase adapter** — for users running gflow on shared workers or wanting cross-machine sync. The repository surface is already designed for this swap. - **`gflow data export`** (full catalog → JSON / Parquet) — the failed-operation slice shipped as `gflow data errors export` (JSONL, #345); a full-catalog / Parquet dump for downstream analytics is still open. -These are tracked in [`PLAN.md`](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md) under the data-layer phase backlog. +These are tracked in [`PLAN.md`](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md) under the data-layer phase backlog. --- diff --git a/website/docs/DEBUGGING.md b/website/docs/DEBUGGING.md index 6f821e8f7..b6ba83319 100644 --- a/website/docs/DEBUGGING.md +++ b/website/docs/DEBUGGING.md @@ -2,7 +2,7 @@ > Where to look and which tool to reach for when something breaks. Per-release > evidence (e.g. live verification runs) lives in sibling docs like -> [`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md). This file is +> [`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.7.0.md). This file is > evergreen. ## Quick reference @@ -45,7 +45,7 @@ Confirm by checking for `ui_automation.image_mode_entered` in the log; if it is missing, the mode switch did not run. If `image_mode_entered` is present but `batch_response_seen` is still missing, the remaining hypothesis is the historical UI-flake noted in -[`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md#open-follow-ups-not-blocking-v070) +[`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.7.0.md#open-follow-ups-not-blocking-v070) (transient overlay swallowed the arrow-forward click). **Two extra artifact file names worth searching for in the out dir** when the @@ -275,7 +275,7 @@ For health probes from a worker process, use ## Reproducing image gen end-to-end -See [`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md) for the +See [`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.7.0.md) for the canonical example. Short form: ```bash @@ -372,7 +372,7 @@ remediations. The most-hit categories: - [`AUTHENTICATION.md`](AUTHENTICATION.md) — sign-in flow details - [`DEVELOPMENT.md`](DEVELOPMENT.md) — branching, PRs, quality gates - [`USAGE.md`](USAGE.md) — CLI surface -- [`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md) — +- [`LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.7.0.md) — per-release end-to-end evidence - `/gflow:known-issues` — surface open known issues from the CLI - `/gflow:check` — local quality gate (lint, format, types, tests) diff --git a/website/docs/DEVELOPMENT.md b/website/docs/DEVELOPMENT.md index 975122c03..a89cce81e 100644 --- a/website/docs/DEVELOPMENT.md +++ b/website/docs/DEVELOPMENT.md @@ -1,9 +1,9 @@ # Development Workflow -> For _contributing_ (TDD, quality gates, commit style, how to add a route) see [CONTRIBUTING.md](https://github.com/ffroliva/gflow-cli/blob/main/CONTRIBUTING.md). +> For _contributing_ (TDD, quality gates, commit style, how to add a route) see [CONTRIBUTING.md](https://github.com/ffroliva/gflow-cli/blob/develop/CONTRIBUTING.md). > This document covers the **internal development process**: branching model, PR protocol, e2e gate, and release pipeline. > For scenario-based GitHub PR triage, external fork handling, and SonarCloud -> decisions, see [docs/GITHUB.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/GITHUB.md). +> decisions, see [docs/GITHUB.md](https://github.com/ffroliva/gflow-cli/blob/develop/docs/GITHUB.md). --- @@ -91,7 +91,7 @@ new-code conditions only; overall coverage ≥ 90 % is enforced by CI's `sonar.qualitygate.wait=true`, so a failed gate turns the `SonarCloud analysis` check red rather than reporting silently on the dashboard. Browser-automation and live-auth transports are coverage-excluded (e2e-tested, not unit-tested). -See [docs/GITHUB.md § SonarCloud Quality Gate](https://github.com/ffroliva/gflow-cli/blob/main/docs/GITHUB.md#sonarcloud-quality-gate). +See [docs/GITHUB.md § SonarCloud Quality Gate](https://github.com/ffroliva/gflow-cli/blob/develop/docs/GITHUB.md#sonarcloud-quality-gate). ### Mutation testing (mutmut) @@ -156,7 +156,7 @@ export GFLOW_CLI_E2E_PROFILE= uv run pytest -m e2e -v ``` -All `@pytest.mark.e2e` scenarios must pass. See [CONTRIBUTING § E2e tests](https://github.com/ffroliva/gflow-cli/blob/main/CONTRIBUTING.md#test-categories) for the full marker reference. +All `@pytest.mark.e2e` scenarios must pass. See [CONTRIBUTING § E2e tests](https://github.com/ffroliva/gflow-cli/blob/develop/CONTRIBUTING.md#test-categories) for the full marker reference. --- @@ -177,7 +177,7 @@ Version bumps belong in the **`develop → main` release PR**, not in feature PR ## AI-assisted development (Claude Code) -This repo is actively developed with Claude Code (see [CLAUDE.md](https://github.com/ffroliva/gflow-cli/blob/main/CLAUDE.md)). A few conventions that keep the workflow clean: +This repo is actively developed with Claude Code (see [CLAUDE.md](https://github.com/ffroliva/gflow-cli/blob/develop/CLAUDE.md)). A few conventions that keep the workflow clean: - Claude branches are renamed to the appropriate `feature/`, `fix/`, `docs/` prefix before the PR is opened. The `claude/` prefix is internal scaffolding. - Claude never bumps the version or cuts a release without explicit instruction — use `/release`. @@ -190,9 +190,9 @@ This repo is actively developed with Claude Code (see [CLAUDE.md](https://github ## See also -- [CONTRIBUTING.md](https://github.com/ffroliva/gflow-cli/blob/main/CONTRIBUTING.md) — TDD, quality gates, how to add a route, commit style -- [docs/GOVERNANCE_BENCHMARK.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/GOVERNANCE_BENCHMARK.md) — calibrating the advisory materiality gate (false-positive / coverage backtest) -- [docs/GITHUB.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/GITHUB.md) — GitHub PR triage, external fork handling, SonarCloud scenarios -- [RELEASE.md](https://github.com/ffroliva/gflow-cli/blob/main/RELEASE.md) — release checklist, PyPI/GitHub publishing, tag protocol -- [CHANGELOG.md](https://github.com/ffroliva/gflow-cli/blob/main/CHANGELOG.md) — version history -- [CLAUDE.md](https://github.com/ffroliva/gflow-cli/blob/main/CLAUDE.md) — project memory hub for AI agents +- [CONTRIBUTING.md](https://github.com/ffroliva/gflow-cli/blob/develop/CONTRIBUTING.md) — TDD, quality gates, how to add a route, commit style +- [docs/GOVERNANCE_BENCHMARK.md](https://github.com/ffroliva/gflow-cli/blob/develop/docs/GOVERNANCE_BENCHMARK.md) — calibrating the advisory materiality gate (false-positive / coverage backtest) +- [docs/GITHUB.md](https://github.com/ffroliva/gflow-cli/blob/develop/docs/GITHUB.md) — GitHub PR triage, external fork handling, SonarCloud scenarios +- [RELEASE.md](https://github.com/ffroliva/gflow-cli/blob/develop/RELEASE.md) — release checklist, PyPI/GitHub publishing, tag protocol +- [CHANGELOG.md](https://github.com/ffroliva/gflow-cli/blob/develop/CHANGELOG.md) — version history +- [CLAUDE.md](https://github.com/ffroliva/gflow-cli/blob/develop/CLAUDE.md) — project memory hub for AI agents diff --git a/website/docs/E2E_TESTING.md b/website/docs/E2E_TESTING.md index 26ca7b1a5..dd27cc6cd 100644 --- a/website/docs/E2E_TESTING.md +++ b/website/docs/E2E_TESTING.md @@ -101,7 +101,7 @@ e2e ─┬─ e2e_auth (auth/session, health check — zero credits) A live test can be written as Gherkin. This is the required form for a bug whose scenario can only happen in a browser — see -[`skills/issue-resolve/SKILL.md`](https://github.com/ffroliva/gflow-cli/blob/main/skills/issue-resolve/SKILL.md) § The Bug Lane, +[`skills/issue-resolve/SKILL.md`](https://github.com/ffroliva/gflow-cli/blob/develop/skills/issue-resolve/SKILL.md) § The Bug Lane, step 5. It needs **no new machinery**: pytest-bdd (already a dependency) converts every Gherkin tag into a pytest marker, so a tagged scenario is filtered by the same `addopts` and selected by the same `-m ` as a hand-written e2e test. @@ -389,7 +389,7 @@ prompts, URLs, or anything else from the served JavaScript. ## RPC drift check (#1218) Every canary comment ends with an `RPC-DRIFT` section. It checks that each id in -[FLOW_WIRE_RPCS.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/FLOW_WIRE_RPCS.md) is still in the JavaScript flow.google.com serves. +[FLOW_WIRE_RPCS.md](https://github.com/ffroliva/gflow-cli/blob/develop/docs/FLOW_WIRE_RPCS.md) is still in the JavaScript flow.google.com serves. It fetches the public shell with **no cookies and no browser**, swaps the shell's `/_/js/` module list for the four feature modules, and looks for each id as a quoted literal. No RPC is sent, so billed submits are covered at $0. It needs no profile, so it @@ -401,7 +401,7 @@ title. | `OK` | every catalogued id is present. An id found only in the shell's base bundle is listed as "not in the feature modules", never as gone | none | | `ID-GONE` | the bundle parsed (it holds descriptors) and catalogued ids are missing from it, even if all of them are | the named ids are missing from the four modules. First load a project page (the spike's `--page` arm) to rule out an id that moved to another module; if it is still absent, it was renamed or removed: update its row | | `MODULES-CHANGED` | the feature-module bundle answered 404 | the feature module names moved; relearn them from a project page (the spike's `--page` arm). Says nothing about any single id | -| `PARSE-CHANGED` | the bundle answered 200 with no `{:"",…}` descriptor. The key is a minified name the check learns from where the catalogued ids sit (build `20261110.00_p0` renamed it `Xa` to `Wa`), so only a change of shape reads here: the 20260929 build held its ids in a constructor, `new _.Gx("",…)`, which this check does not parse | the bundle format changed; the descriptor pattern needs re-deriving ([#1223 spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-10-rpc-descriptor-churn.md)). Never reads as `OK` | +| `PARSE-CHANGED` | the bundle answered 200 with no `{:"",…}` descriptor. The key is a minified name the check learns from where the catalogued ids sit (build `20261110.00_p0` renamed it `Xa` to `Wa`), so only a change of shape reads here: the 20260929 build held its ids in a constructor, `new _.Gx("",…)`, which this check does not parse | the bundle format changed; the descriptor pattern needs re-deriving ([#1223 spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-10-rpc-descriptor-churn.md)). Never reads as `OK` | | `INCONCLUSIVE` | nothing was measured: offline, a shell or bundle HTTP error other than a bundle 404 (429, 5xx), a redirect to a page without the app, no build label, a catalog that lost rows or has no `live` row, or the 120 s budget ran out | none; says nothing about Flow | One renamed module cannot pass for a missing id. On 2026-11-10 the server answered the @@ -689,7 +689,7 @@ flow.google.com clip lands in that bucket (#1003). ## See also -- [CONTRIBUTING.md § Test categories](https://github.com/ffroliva/gflow-cli/blob/main/CONTRIBUTING.md#test-categories) +- [CONTRIBUTING.md § Test categories](https://github.com/ffroliva/gflow-cli/blob/develop/CONTRIBUTING.md#test-categories) - [DEVELOPMENT.md § E2e gate](DEVELOPMENT.md#e2e-gate-before-merging-develop-main) - [docs/DATA_LAYER.md](DATA_LAYER.md) - [docs/ARCHITECTURE.md § Testing topology](ARCHITECTURE.md#testing-topology) diff --git a/website/docs/ERRORS.md b/website/docs/ERRORS.md index a62d01088..24732a804 100644 --- a/website/docs/ERRORS.md +++ b/website/docs/ERRORS.md @@ -171,7 +171,7 @@ place today: `PUBLIC_ERROR_UNUSUAL_ACTIVITY` is `WafRejectionError` (exit 10), never retryable, and its `charged` / `next_action` depend on the scale. The scales measured to spend no credits (1080p, 720p and the 270p GIF for video, 2K for image; - [spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-29-export-billing-720p-270p.md)) read `no` / `wait`; + [spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-29-export-billing-720p-270p.md)) read `no` / `wait`; 4K (a 4K video bills on click; 4K image billing is unmeasured and treated the same), and a refusal on the `jwpduf` status poll, which runs after Flow accepted the export, read `maybe` / `reconcile`. No `retry_after` is given: no diff --git a/website/docs/INSTRUCTIONS.md b/website/docs/INSTRUCTIONS.md index a5e6d9c87..a686a5d4b 100644 --- a/website/docs/INSTRUCTIONS.md +++ b/website/docs/INSTRUCTIONS.md @@ -164,6 +164,6 @@ title is ambiguous. - [USAGE.md](USAGE.md) — full command reference. - [MOVIE.md](MOVIE.md) — multi-scene movies (`[[…instructions.card]]` blocks). - [MCP.md](MCP.md) — the six `gflow_instructions_*` MCP tools mirroring this command group. -- [LIVE_VERIFICATION_v0.29.0.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.29.0.md) — live e2e evidence for the +- [LIVE_VERIFICATION_v0.29.0.md](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.29.0.md) — live e2e evidence for the CRUD surface (mechanism, H4 image-reference confirmation). The original plan + spike findings were consolidated and removed when the feature shipped (v0.29.0 release prep). diff --git a/website/docs/KNOWN_ISSUES.md b/website/docs/KNOWN_ISSUES.md index 635dca6a8..b160aaea1 100644 --- a/website/docs/KNOWN_ISSUES.md +++ b/website/docs/KNOWN_ISSUES.md @@ -2,7 +2,7 @@ Living list of behaviour that's broken, surprising, or limited by design — alongside workarounds and a pointer to the issue / version where each is tracked or resolved. -> Pair with [CHANGELOG.md](https://github.com/ffroliva/gflow-cli/blob/main/CHANGELOG.md) (what shipped per version) and [DISCLAIMER.md](https://github.com/ffroliva/gflow-cli/blob/main/DISCLAIMER.md) (legal/scope limits). +> Pair with [CHANGELOG.md](https://github.com/ffroliva/gflow-cli/blob/develop/CHANGELOG.md) (what shipped per version) and [DISCLAIMER.md](https://github.com/ffroliva/gflow-cli/blob/develop/DISCLAIMER.md) (legal/scope limits). ## Conventions @@ -29,7 +29,7 @@ Living list of behaviour that's broken, surprising, or limited by design — alo - **Tracked:** [#1298](https://github.com/ffroliva/gflow-cli/issues/1298), fixed by [PR #1304](https://github.com/ffroliva/gflow-cli/pull/1304) - **Cause:** every running gflow process holds its own `gflow.exe` launcher open, and pip uninstalls the old files before it writes the new ones, so it fails halfway and never rolls back. From 0.100.0, `gflow update` renames the launchers aside first, but an older install still runs its old updater. - **Workaround:** upgrade once by hand. Close every gflow process (MCP servers, `gflow serve`), then run `\Scripts\python.exe -m pip install --upgrade gflow-cli` (with any extras you installed, e.g. `"gflow-cli[patchright]"`, or their pins stay behind), or for a `--user` install `py -3.X -m pip install --user --upgrade gflow-cli`, where `3.X` is the Python gflow was installed under (`py -0p` lists them). From then on `gflow update` works. Details: [USAGE § `gflow update`](USAGE.md#gflow-update). -- **Evidence:** `tests/e2e/test_update_installer_e2e.py` (`e2e_update`), 4/4 on the v0.100.0 release tree; [LIVE_VERIFICATION_v0.100.0](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.100.0.md). +- **Evidence:** `tests/e2e/test_update_installer_e2e.py` (`e2e_update`), 4/4 on the v0.100.0 release tree; [LIVE_VERIFICATION_v0.100.0](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.100.0.md). ### The direct credits read uses the profile's saved Google session outside Chrome @@ -87,7 +87,7 @@ that profile and keeps the other balances. - **Status:** Open · **Severity:** High for the affected account (nothing runs) · **Affected:** measured on one account (`my-profile`, 2026-09-23). Other `/about` occurrences are not yet shown to share the cause. - **Tracked:** [#902](https://github.com/ffroliva/gflow-cli/issues/902) (`auth login` could not clear it before v0.80.0; it now waits on the check) · [#888](https://github.com/ffroliva/gflow-cli/issues/888) · [#756](https://github.com/ffroliva/gflow-cli/issues/756) -- **Evidence:** [spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-23-about-cta-leads-to-google-reauth.md) +- **Evidence:** [spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-23-about-cta-leads-to-google-reauth.md) Flow sends every visit to its public landing page `/about`, while every Google and Flow cookie gflow checks is present and unexpired. On the measured account, the page's "Create with Google @@ -119,9 +119,9 @@ close Chrome yourself. On the measured account, `/about` was gone on the next ru - **Status:** Open (partially resolved) · **Severity:** High for unported forms · **Affected:** on accounts the rollout has reached, `gflow video t2v`, `video i2v` (local start/end frames and captioned image UUIDs the local catalog records in the same `--project`, #1542), local-file `video r2v`, `gflow image t2i`, `gflow image i2i` (local files or same-`--project` catalogued image UUIDs, #995), and a **single-segment** `gflow video extend` (#882: Flow's own Extend control, driven from the clip editor) now run on the migrated host. Image mode supports Nano Banana 2.1 (`nano2`, which replaced Nano Banana 2 there, #958) / 2 Lite / Pro, all five aspect ratios its radiogroup renders (16:9, 4:3, 1:1, 3:4, 9:16 — 3:4 appeared by 2026-09-17, #864), and count 1–4. Image prompts can tag a **character** with `@Name` / `--reference-entity` + `--reference-entity-name` since #723 (attached through the composer's `@` picker; an id without a name exits 36). Local-file `video r2v` takes a character the same way, by `--reference-entity` + `--reference-entity-name` (#723). That matrix is the **classic** migrated composer's. On an **agent-only** composer ([#799](https://github.com/ffroliva/gflow-cli/issues/799)) gflow drives `image t2i` (all five aspects; count 1–4) and `video t2v` (one 9:16 or 16:9 clip) only — i2i, i2v, r2v and character references are refused there before anything is clicked. Cross-project or un-captioned UUID image refs / video frame refs, video `@Name` outside `r2v`, r2v UUID refs, `--reference-entity` on t2v/i2v, Agent instructions, Imagen 4, scenes, chained extend (`-n > 1`, `--scene`/`--resume-from`, `--seed`, an `--aspect` other than the source clip's), instructions and tools are not ported yet and fail before submit. **`character create` worked on the migrated host until its labs `createEntity` route was retired:** measured 2026-10-14 on a profile served flow.google.com, it exits 7 with "Flow RPCs have been deprecated" (404). Building a character from local images, `character create --image FILE [--body-image FILE]` (MCP `gflow_character_create`), drives the character editor on flow.google.com instead and generates nothing ([#639](https://github.com/ffroliva/gflow-cli/issues/639)); the prompt-generated create (`--face-prompt`) is not ported to that host yet. `character list` and `character show` (and MCP `gflow_character_list` / `gflow_character_show`) now read `flow.google.com`'s `Zzl0ze` project reply ([#875](https://github.com/ffroliva/gflow-cli/issues/875), [#987](https://github.com/ffroliva/gflow-cli/pull/987)). `scenes`, multi-segment `extend` (`-n > 1`, `--scene`/`--resume-from`, `--seed`), `instructions` and `tools` remain *unported by gflow*, never proven impossible on the host. - **Tracked:** [#639](https://github.com/ffroliva/gflow-cli/issues/639) · Reported 2026-09-02 against 0.59.0, 0.62.1, 0.63.0 and 0.65.0 -- **Confirmed live 2026-09-03 on a second, independent account** (`ffroliva`) — see [LIVE_VERIFICATION_v0.66.0](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.66.0.md). A read-only probe of the migrated origin measured `i_total: 0`, reproducing the reporter's central measurement. +- **Confirmed live 2026-09-03 on a second, independent account** (`ffroliva`) — see [LIVE_VERIFICATION_v0.66.0](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.66.0.md). A read-only probe of the migrated origin measured `i_total: 0`, reproducing the reporter's central measurement. - **`--reference-entity` was refused on `r2v` but not on `t2v`** ([#716](https://github.com/ffroliva/gflow-cli/issues/716), fixed in v0.71.0): the "not ported, exit 36" refusal above sat inside the r2v branch of the routing gate, so a `t2v` request carrying a character entity returned from that gate without its entities ever being inspected — and nothing downstream attaches one on this host. The generation was **submitted and billed** with the entity silently dropped, returning a plausible clip of the wrong person. The check is now mode-independent and ahead of every early return. If you ran `gflow video t2v @Name …` or `--reference-entity` on a moved account before this fix, the identity in those clips was never bound. -- **The migrated composer image path is now driven** ([#692](https://github.com/ffroliva/gflow-cli/issues/692)): the first probe established a hit-testable Image mode; the 2026-09-08 follow-up captured real T2I and local-file I2I submissions on `ogiZ0b`, including page-owned reCAPTCHA, upload ids, response records and signed JPEG downloads. See [the submit-wire spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-08-migrated-image-submit-wire.md). +- **The migrated composer image path is now driven** ([#692](https://github.com/ffroliva/gflow-cli/issues/692)): the first probe established a hit-testable Image mode; the 2026-09-08 follow-up captured real T2I and local-file I2I submissions on `ogiZ0b`, including page-owned reCAPTCHA, upload ids, response records and signed JPEG downloads. See [the submit-wire spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-08-migrated-image-submit-wire.md). - **Image commands on a moved account** ([#673](https://github.com/ffroliva/gflow-cli/issues/673), fixed in v0.69.0): through v0.68.0 `image t2i` / `i2i` (and `upscale`, `extend`) died with exit 1 `RecaptchaError` within seconds, before any submit, instead of the exit 36 above, because the labs client minted the reCAPTCHA token on the `flow.google.com` project grid before any migration guard ran. The guard now runs at the mint; since v0.80.0 the browser transport no longer mints for images at all, and the flow.google.com composer itself refuses unported forms (#891). If you still see a `RecaptchaError` on a moved account right after `auth login`, that is the labs logged-out landing page from the [#644](https://github.com/ffroliva/gflow-cli/issues/644) cookie harvest, not this. - **A second image request on one client hit the same `RecaptchaError`** ([#891](https://github.com/ffroliva/gflow-cli/issues/891), fixed in v0.80.0): after a successful image on an account served flow.google.com, the page is parked on `about:blank`, and the client's pre-mint ran there, so an unported form (e.g. `--model imagen4`) failed with "the Flow editor page may have failed to load" instead of exit 36. The browser transport never used that token, so it no longer mints; the composer refuses the form by name. Reachable from `gflow run --config` with a per-prompt `"model": "imagen4"` after a successful prompt, where it also crashed the whole run (exit 1, results table lost); it now reports that prompt as exit 36 and the run completes. @@ -173,7 +173,7 @@ References by `@Name` and unpaired character entity ids stay on labs: the picker exposes no media id to anchor on (saved characters work on `r2v` when paired with `--reference-entity-name`, #723, and same-`--project` captioned `i2v` frame UUIDs now anchor on the grid tile's `/asb/`, #1542). Capture: -[2026-09-05-migrated-r2v-attach-surface](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-05-migrated-r2v-attach-surface.md). +[2026-09-05-migrated-r2v-attach-surface](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-05-migrated-r2v-attach-surface.md). **Images also run there (2026-09-08).** The driver selects Image mode, Nano Banana 2 (2.1 by 2026-10-08 — before v0.83.1 that made every `nano2` run exit 7, "does not carry @@ -260,7 +260,7 @@ serves the signed-out page, meaning the cookies were not accepted (#1221). A pag reader must treat that as an auth problem and fall back to the page. Cookie lifetime without a running browser is unmeasured. An account served `labs.google` could not be observed here. Full write-up: -[`docs/superpowers/spikes/2026-11-09-page-free-reads.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-09-page-free-reads.md). +[`docs/superpowers/spikes/2026-11-09-page-free-reads.md`](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-09-page-free-reads.md). **Workaround:** none needed; the browser path works. It is the cost, not the correctness, that a page-free reader would change. @@ -387,7 +387,7 @@ still refuses to go is reported as `div.glue-cookie-notification-bar`. **Workaround on 0.73.0 and earlier:** open that profile once in Chrome and dismiss the bar by hand. Consent persists in the profile. -Evidence: [`docs/superpowers/spikes/2026-09-11-migrated-cookie-bar-blocks-the-composer.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-11-migrated-cookie-bar-blocks-the-composer.md). +Evidence: [`docs/superpowers/spikes/2026-09-11-migrated-cookie-bar-blocks-the-composer.md`](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-11-migrated-cookie-bar-blocks-the-composer.md). ### One-time Flow banner/modal can cover the composer on first load @@ -596,7 +596,7 @@ accepted. Two corrections fixed it (verified end-to-end on macOS Apple Silicon): captured **pre-launch** via the working `--password-store=basic` reader. No-op on Windows and on runs where the context decrypts natively. -Evidence: [LIVE_VERIFICATION_v0.23.0](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.23.0.md). +Evidence: [LIVE_VERIFICATION_v0.23.0](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.23.0.md). ### Expanded chat sidebar left the composer unrecoverable (exit 23) @@ -637,7 +637,7 @@ Verified by an A/B on a real editor: with the scoped selector neutered the fallback recovers; with both neutered it does not. Two earlier hypotheses were tested and refuted first (a `crop_free` sub-mode trigger, and a composer hydration race) — see -[the spike evidence](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-08-14-video-model-capability-matrix.md). +[the spike evidence](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-08-14-video-model-capability-matrix.md). If you still hit exit 23 after upgrading, the run writes a PII-safe DOM signature to `diag_mode_switch_miss.json` (structural allowlist: ligature names @@ -657,7 +657,7 @@ state genuinely different from the sidebar one. of v0.65.0 it **does** run — it never had before ([#615](https://github.com/ffroliva/gflow-cli/issues/615)), and the fix is A/B-verified live (see -[LIVE_VERIFICATION_reference_entity_guard](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_reference_entity_guard.md)). +[LIVE_VERIFICATION_reference_entity_guard](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_reference_entity_guard.md)). But it guards by registering a Playwright route handler, so it can only ever observe **browser-initiated** traffic. Every direct-wire route goes through `client._post_json`, @@ -713,7 +713,7 @@ same day may simply work again. **Workaround:** none yet on affected accounts — the attach gesture for the new UI is being reverse-engineered (recon plan in -[docs/superpowers/plans/2026-06-12-issue-174-library-ui-attach/PLAN.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/plans/2026-06-12-issue-174-library-ui-attach/PLAN.md)). +[docs/superpowers/plans/2026-06-12-issue-174-library-ui-attach/PLAN.md](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/plans/2026-06-12-issue-174-library-ui-attach/PLAN.md)). If you have a second profile/account still on the old UI, entity attach works there. Follow [#174](https://github.com/ffroliva/gflow-cli/issues/174) for status; please report whether your account shows the dialog or the full-page @@ -734,7 +734,7 @@ account tier is enforced server-side. gflow cannot grant 4K locally. **Workaround:** use `--scale 2k` (available on all tiers), or upgrade the Flow account to Ultra. If you just upgraded, re-run `gflow auth login --profile ` to refresh the session before retrying 4K. Wire detail: -[docs/IMAGE_UPSCALE_RECON.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/IMAGE_UPSCALE_RECON.md) (#171). +[docs/IMAGE_UPSCALE_RECON.md](https://github.com/ffroliva/gflow-cli/blob/develop/docs/IMAGE_UPSCALE_RECON.md) (#171). ### Image generation returns HTTP 401 — `aisandbox-pa` generation endpoint @@ -746,7 +746,7 @@ to refresh the session before retrying 4K. Wire detail: > full auth context — bypassing the 401 on the `aisandbox-pa` HTTP path > entirely. Live-verified end-to-end on the `ffroliva` profile across four > aspect ratios (`9:16`, `16:9`, `1:1`, `4:3`); see -> [`docs/LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md). The +> [`docs/LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.7.0.md). The > 401 still hits the experimental HTTP transports > (`evaluate_fetch` / `bearer` / `sapisidhash`) under > `src/gflow_cli/api/transports/experimental/` — those are not the @@ -921,7 +921,7 @@ MediaUploadRejectedError (exit 27): migrated host: no maseQ reply within 60s of the file — the upload never reached Flow or was dropped ``` -…and advised re-encoding the image to strip metadata. Neither the file nor the network was ever involved. Measured 2026-09-08 on three profiles, eight runs: the two accounts that had uploaded before never saw the dialog and uploaded fine; the account that never had failed 3/3. See [the spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-08-migrated-upload-fails-two-ways.md). +…and advised re-encoding the image to strip metadata. Neither the file nor the network was ever involved. Measured 2026-09-08 on three profiles, eight runs: the two accounts that had uploaded before never saw the dialog and uploaded fine; the account that never had failed 3/3. See [the spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-08-migrated-upload-fails-two-ways.md). > **This entry previously said the opposite.** It read *"Affects: the legacy in-tree Compiled Growth worker, NOT `gflow-cli` itself"*, because *"gflow-cli's API-driven path bypasses this dialog entirely (the REST endpoint already implies acceptance)"*, with *"Workaround in gflow-cli: none needed."* That was true of the REST path and became false when the migrated driver started using the editor's **own** upload — so the entry a user hitting #719 would find was reassuring them about the exact thing that was breaking their run. @@ -933,7 +933,7 @@ the file — the upload never reached Flow or was dropped > **Accepting does not make every upload succeed — there is a second, unrelated failure on this path.** See the next entry. If you have already accepted the dialog and an upload still times out, you are not looking at this issue and repeating the workaround will not help. -**Video uploads are different: the acceptance is per browser profile, not per account** ([#1540](https://github.com/ffroliva/gflow-cli/issues/1540)). As reported on #1540 (a contributor's observation, not re-measured by the maintainers; [spike record](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-12-01-video-upload-consent-storage.md)), Flow records the video-rights acceptance only in the page's `localStorage` (`flow-video-upload-consent-dismissed`); no request reaches the account. A local video source (`video edit`, `video extend`) on a gflow profile that has never accepted it therefore meets `` even when the same Google account accepted it in your everyday Chrome. Since #1540 the driver fails with exit 27 as soon as that dialog appears before the upload request leaves the page. To clear it, with no gflow command using the profile (a running `gflow serve` or `gflow mcp run` counts), start Chrome with `--user-data-dir=` (`gflow auth list --json` prints `profile_dir`), upload one video to a Flow project by hand, and accept. On macOS and Linux also pass `--password-store=basic`: without it Chrome cannot read the cookies gflow sealed with it (#222), and signing in again there breaks the next gflow run. Chrome ignores the flag on Windows. +**Video uploads are different: the acceptance is per browser profile, not per account** ([#1540](https://github.com/ffroliva/gflow-cli/issues/1540)). As reported on #1540 (a contributor's observation, not re-measured by the maintainers; [spike record](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-12-01-video-upload-consent-storage.md)), Flow records the video-rights acceptance only in the page's `localStorage` (`flow-video-upload-consent-dismissed`); no request reaches the account. A local video source (`video edit`, `video extend`) on a gflow profile that has never accepted it therefore meets `` even when the same Google account accepted it in your everyday Chrome. Since #1540 the driver fails with exit 27 as soon as that dialog appears before the upload request leaves the page. To clear it, with no gflow command using the profile (a running `gflow serve` or `gflow mcp run` counts), start Chrome with `--user-data-dir=` (`gflow auth list --json` prints `profile_dir`), upload one video to a Flow project by hand, and accept. On macOS and Linux also pass `--password-store=basic`: without it Chrome cannot read the cookies gflow sealed with it (#222), and signing in again there breaks the next gflow run. Chrome ignores the flag on Windows. **gflow does not accept it for you, by design.** The dialog affirms that *you* hold the rights to the content you upload; that is not a claim a tool may make on an account owner's behalf. It is also a 30-second step, once, on a path that already requires an interactive browser login (`gflow auth login`) — so automating it would buy nothing and assert something on your behalf. There is deliberately no config flag: a setting that can never safely default to on, on a once-per-account event, is a flag nobody sets. @@ -964,7 +964,7 @@ The contrasting message, **`no upload request ever left the page`**, means somet - **Status:** Mitigated · **Severity:** Medium (intermittent; the write usually saved) · **Affects:** the migrated `flow.google.com` host, local uploads (`--initial-frame`, `--ref`, `i2i` files), project create and rename, image submits, video submits · **Tracked:** [#1009](https://github.com/ffroliva/gflow-cli/issues/1009), [#1075](https://github.com/ffroliva/gflow-cli/issues/1075), [#1112](https://github.com/ffroliva/gflow-cli/issues/1112), [#1141](https://github.com/ffroliva/gflow-cli/issues/1141) -Distinct from #719 above, where no reply arrives at all. Here the reply arrives, but Chrome cannot hand its body over: `Network.getResponseBody: No data found for resource with given identifier`. Our spike saw it on 2 of 45 real `maseQ` uploads, and a fresh reload found both uploads saved ([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-10-20-migrated-upload-reply-body-eviction.md)). Before the fix, gflow reported the upload as a refused file (exit 27). +Distinct from #719 above, where no reply arrives at all. Here the reply arrives, but Chrome cannot hand its body over: `Network.getResponseBody: No data found for resource with given identifier`. Our spike saw it on 2 of 45 real `maseQ` uploads, and a fresh reload found both uploads saved ([spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-10-20-migrated-upload-reply-body-eviction.md)). Before the fix, gflow reported the upload as a refused file (exit 27). A project create or rename whose reply is late, not lost, takes the same path: on a slow link a 40 s create used to end as a retryable exit 9 while Flow made the project, so a retry made a second one ([#1037](https://github.com/ffroliva/gflow-cli/issues/1037)). The reply wait is now 120 s, and past it gflow reads the new project's id from Flow's navigation to it. @@ -972,7 +972,7 @@ A project create or rename whose reply is late, not lost, takes the same path: o **Image submits (since v0.89.1, [#1075](https://github.com/ffroliva/gflow-cli/issues/1075)).** Flow had made the image every reported time. gflow now reads the run's new tile(s) off the project grid and downloads them, taking exactly the requested count once it holds still for a few seconds; an i2i reference is never counted. Any other count, or a grid it cannot read, still ends in exit **9** (`retryable: false`) naming the project page: check the project before re-running. -**Video submits ([#1112](https://github.com/ffroliva/gflow-cli/issues/1112)).** About 1 in 7 r2v submits lost this reply in a 21-clip run, and Flow made and billed every one. A video run that uploaded a file (`--ref`, `--initial-frame`, `--end-frame`) is now followed to its clip: Flow's own status replies name the clip by the id of that upload, and if none does within a minute, gflow reads the project listing in a second tab. The run then finishes and downloads as usual, with one `migrated.video_submit_reply_lost` warning and no second submit ([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-10-27-lost-video-submit-recovery.md)). A one-clip text-to-video run uploads nothing, so since v0.93.0 it is found by its exact prompt and model, and the project listing must name exactly one such clip once it finishes ([#1141](https://github.com/ffroliva/gflow-cli/issues/1141), [spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-04-t2v-lost-submit-reply.md)). Text-to-video with `--count` above 1, an r2v run with characters only, or a clip the listing cannot name that way still ends in exit **9** (`retryable: false`) naming the project. So does a run where two clips carry the upload, or none appears in time. Check the project before re-running. +**Video submits ([#1112](https://github.com/ffroliva/gflow-cli/issues/1112)).** About 1 in 7 r2v submits lost this reply in a 21-clip run, and Flow made and billed every one. A video run that uploaded a file (`--ref`, `--initial-frame`, `--end-frame`) is now followed to its clip: Flow's own status replies name the clip by the id of that upload, and if none does within a minute, gflow reads the project listing in a second tab. The run then finishes and downloads as usual, with one `migrated.video_submit_reply_lost` warning and no second submit ([spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-10-27-lost-video-submit-recovery.md)). A one-clip text-to-video run uploads nothing, so since v0.93.0 it is found by its exact prompt and model, and the project listing must name exactly one such clip once it finishes ([#1141](https://github.com/ffroliva/gflow-cli/issues/1141), [spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-04-t2v-lost-submit-reply.md)). Text-to-video with `--count` above 1, an r2v run with characters only, or a clip the listing cannot name that way still ends in exit **9** (`retryable: false`) naming the project. So does a run where two clips carry the upload, or none appears in time. Check the project before re-running. **If it cannot confirm the outcome**, the command exits **7** with `RpcResponseUnavailableError` (`retryable: false`). The write may have saved. Open the project on flow.google.com and look for the title or the file name in the error before you re-run, or you may get a duplicate project or upload. `gflow run` does not re-upload a reference file after this error in the same run. @@ -1012,7 +1012,7 @@ A block that survives dismissal now aborts pre-submit with exit 23 (probe `overl **Fixed.** In v0.87.1 `gflow credits` began opening flow.google.com in the profile's browser and reading the balance from the app's own `nzlxg` reply, the number Flow's account menu shows (measured 5/5, including after a spend: -[spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-10-22-credits-balance-on-nzlxg.md)). It no longer needs a +[spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-10-22-credits-balance-on-nzlxg.md)). It no longer needs a labs.google token. It cost one browser launch per profile; since [#1229](https://github.com/ffroliva/gflow-cli/issues/1229) the same reply is first asked for directly, with the profile's saved cookies and no browser, and the browser read is the fallback @@ -1115,7 +1115,7 @@ Other ratios may be silently rejected or coerced server-side. We validate in the > **Resolution (2026-05-20, v0.7.0):** `UiAutomationTransport` drives the Flow > editor so Flow's own JS issues every generation request with full auth > context — image generation now succeeds end-to-end (see -> [`docs/LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md)). Video +> [`docs/LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.7.0.md)). Video > T2V works at the library level via the same transport (Phase A, PR #23); > CLI wiring (`gflow video t2v/i2v/batch`) is queued for Phase B. The HTTP > transports under `experimental/` remain blocked by this 401 by design — @@ -1169,7 +1169,7 @@ find "$HOME/Downloads/gflow-cli" -type f -mtime +30 -delete `batchexecute` error envelope (`[7,null,[["type.googleapis.com/google.rpc.ErrorInfo",["PUBLIC_ERROR_UNUSUAL_ACTIVITY"]]]]`) and surfaces as `WafRejectionError: … Flow refused the submit: PUBLIC_ERROR_UNUSUAL_ACTIVITY`. Flow's grid shows *"We noticed some unusual activity… You have not been charged"* - ([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-27-migrated-refusal-is-on-the-wire.md)). + ([spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-27-migrated-refusal-is-on-the-wire.md)). - **structlog signature:** `ui_automation.batch_response_seen` with `status=403` followed by `ui_automation.batch_403_body` containing `'message': 'reCAPTCHA evaluation failed', 'status': 'PERMISSION_DENIED', 'reason': 'PUBLIC_ERROR_UNUSUAL_ACTIVITY'` Distinct from the historical `aisandbox-pa` 401 (resolved in v0.7.0). The 403 @@ -1182,7 +1182,7 @@ batch — so it is not a global incompatibility but a per-profile WAF state. **What gflow does about it (v0.108.0, #1371):** a refused submit is not billed, and gflow retries it **once**, from a new headless browser process. In the -[direct video and headless mint spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md), +[direct video and headless mint spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md), a page Flow had refused stayed refused for about 20 minutes, while fresh pages in new browser processes were accepted in both headless and headed mode: page freshness, not visibility, was the variable. Any refused page is discarded, so the next mint uses a new @@ -1614,7 +1614,7 @@ is ported to that build: it opens Agent settings through the gear, waits out the saves before it submits, and opens a closed agent panel first (submitted from the compact prompt box alone, a run saw no credit gate and timed out). That port was measured on a recoverable account held in agent mode, not on such an account -([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-21-agent-settings-on-the-new-build.md)). +([spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-21-agent-settings-on-the-new-build.md)). The **negative** controls were measured live at $0 on 2026-09-13, which is what makes the discriminator more than a guess: a healthy migrated composer carries its Agent toggle @@ -1740,7 +1740,7 @@ change surfaces there as a failing test. Start any investigation of a sudden **Since 2026-10-22 that endpoint answers HTTP 410 Gone** for every account, with or without cookies ([#1023](https://github.com/ffroliva/gflow-cli/issues/1023), -[spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-10-22-labs-session-oracle-gone.md)). A 410 is now +[spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-10-22-labs-session-oracle-gone.md)). A 410 is now read as "no labs session": a profile without Google cookies is `NO_SESSION`, and one with them is checked by the server-attested migrated-host probe (#791), which needs the Google SSO and flow.google.com session cookies, then reads `myaccount.google.com` (or, only if that @@ -1830,8 +1830,8 @@ re-navigating and then failing loudly instead of generating on the wrong surface. The `parentEntityId` guard that surfaced this was correct throughout — it refused to report a portrait-less character as success. -Wire contract: [CHARACTER_RECON § entity binding](https://github.com/ffroliva/gflow-cli/blob/main/docs/CHARACTER_RECON.md#entity-binding-entitycontext-captured-live-2026-07-28). -Evidence: [LIVE_VERIFICATION_v0.45.0 §2](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.45.0.md). +Wire contract: [CHARACTER_RECON § entity binding](https://github.com/ffroliva/gflow-cli/blob/develop/docs/CHARACTER_RECON.md#entity-binding-entitycontext-captured-live-2026-07-28). +Evidence: [LIVE_VERIFICATION_v0.45.0 §2](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.45.0.md). ### `gflow video`'s manifest-driven batch subcommand didn't skip already-completed entries — RESOLVED as obsolete @@ -1862,7 +1862,7 @@ Agent toggle's `aria-pressed` attribute (false = classic media, true = agent — locale-invariant), closes the expanded chat sidebar first, toggles off only when actually in agent mode, and re-verifies. Live-verified with a full classic→agent→classic round-trip and a real agentic→classic recovery in the v0.38.0 -release run ([evidence](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.38.0.md)). +release run ([evidence](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.38.0.md)). ### Agentic image generation could silently attribute a pre-existing project asset as the "generated" image @@ -2022,7 +2022,7 @@ why; re-run on the next release (≥ v0.9.0). The two long Open-section entries above (*Image generation returns HTTP 401* and *REST API 401 — all `aisandbox-pa.googleapis.com` generation endpoints blocked*) were closed by the same architectural change: `UiAutomationTransport` drives the Flow web UI so Flow's own JavaScript issues every generation request with the full browser auth context (cookies, reCAPTCHA, `Origin`/`Referer` headers). The 401 had affected every direct HTTP call from `evaluate_fetch` / `bearer` / `sapisidhash`; those transports now live under `src/gflow_cli/api/transports/experimental/` and are not on the production path. -End-to-end live-verified on the `ffroliva` profile across `9:16`, `16:9`, `1:1`, and `4:3` aspect ratios; see [`docs/LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/main/docs/LIVE_VERIFICATION_v0.7.0.md) for timing, file sizes, and exact filenames. Video T2V uses the same approach (Phase A — PR #23 — merged 2026-05-19). +End-to-end live-verified on the `ffroliva` profile across `9:16`, `16:9`, `1:1`, and `4:3` aspect ratios; see [`docs/LIVE_VERIFICATION_v0.7.0.md`](https://github.com/ffroliva/gflow-cli/blob/develop/docs/LIVE_VERIFICATION_v0.7.0.md) for timing, file sizes, and exact filenames. Video T2V uses the same approach (Phase A — PR #23 — merged 2026-05-19). --- @@ -2068,7 +2068,7 @@ gflow auth login **The block is current Google behaviour — "Resolved" means the mitigation holds, not that Google stopped.** Re-measured 2026-09-08 across three throwaway *unauthenticated* profiles, each signed into by hand -([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-08-g12-blocks-webdriver-not-playwright.md)): a +([spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-08-g12-blocks-webdriver-not-playwright.md)): a browser advertising `navigator.webdriver === true` — real Chrome, no stealth flags — was rejected at `/v3/signin/rejected` **17.5 s** into the flow, while the same real Chrome *with* the flags reported `false`, never saw the rejection, and reached a Flow session diff --git a/website/docs/MCP.md b/website/docs/MCP.md index 8f2599ba2..e9523656c 100644 --- a/website/docs/MCP.md +++ b/website/docs/MCP.md @@ -130,8 +130,8 @@ completed result (blocking and queued alike) carries `route` (`direct` / `ui`), is [BROWSER_MODES](BROWSER_MODES.md). * `gflow_generate_image(prompt, model, aspect, count, reference_images, reference_entities, reference_entity_names, tools, profile, project, project_name, instructions, ui_mode, thinking_level, out_file, wait, browser_visibility)`: Triggers text-to-image / image-to-image (Imagen / Nano Banana). `thinking_level` (`low`/`medium`/`high`, matched case-insensitively, mirroring CLI `--thinking-level`) binds Flow's image thinking-level toggle in the settings pane (omitting leaves Flow's existing setting untouched). `out_file` sets an explicit destination file path (mirrors CLI `--out-file`; legacy `output` removed in #1158). There is no `seed` parameter: Flow picks the seed and the image request cannot carry one (removed in [#1013](https://github.com/ffroliva/gflow-cli/issues/1013), as the CLI's `--seed` was in v0.8.0). A completed result reports the catalogued seed under `seed`: the seed Flow chose on the classic image paths, `0` on the agentic / agent-only arms (which observe none), `null` if none was recorded — the MCP twin of `gflow image t2i --json`'s `images[].seed`. `instructions` is an optional list of ephemeral agent-instruction strings (agentic cohort only). `reference_images` switches to i2i and accepts **either a local file path or a generated image's Flow media UUID**. A UUID reference is attached by **selecting the already-existing asset in Flow's reference picker — no duplicate copy is uploaded** (locating the tile by the media id in its thumbnail URL, and searching the recorded display name to surface it when needed); gflow falls back to uploading the asset's on-disk local file only when it can't be located in place (e.g. it lives in a different project's picker). `project` generates into an existing Flow project id (mirrors CLI `--project`; when omitted, [`GFLOW_CLI_PROJECT`](CONFIGURATION.md#gflow_cli_project) is used unless `project_name` asks for a new project, #1039) — pass the reference's project to keep it selectable in place. `ui_mode` selects the Flow UI arm (`auto`/`classic`/`agentic`, mirroring CLI `--ui-mode`, matched case-insensitively). Since [#595](https://github.com/ffroliva/gflow-cli/issues/595) `auto` means "no arm was asked for" and **resolves to `classic`** — the arm that can satisfy an image request — so an account in Flow's agentic cohort aborts pre-submit (exit-28 equivalent envelope, zero credits) instead of failing mid-run with selector drift or video bytes; the agentic arm is bound only when named. Passing `instructions` forces `agentic` automatically, so `ui_mode="classic"` + `instructions` is a hard conflict rather than a silent drop. An unknown value returns a 400 problem-details envelope. See [CONFIGURATION § GFLOW_CLI_UI_MODE](CONFIGURATION.md#gflow_cli_ui_mode). - `model` is `nano2` (Nano Banana 2.1 on flow.google.com; `nano2.1` also accepted), `nano2-lite` (Nano Banana 2 Lite), `nano-pro` (Nano Banana Pro) or `image4` (Imagen 4, no longer in Flow's menu); other aliases are accepted too. On migrated `flow.google.com` accounts, T2I and local-file I2I are supported with Nano Banana 2.1 (`nano2`, #958) / 2 Lite / Pro, all five aspects (16:9, 4:3, 1:1, 3:4, 9:16) and count 1–4; the measured shapes are sent as a direct `ogiZ0b` request with a token from a headless browser, and the rest are submitted by Flow's own page ([DIRECT_TRANSPORT](https://github.com/ffroliva/gflow-cli/blob/main/docs/DIRECT_TRANSPORT.md)). `@Name` character mentions in the prompt are attached through the composer's `@` picker and verified as character chips before submit (#723). each explicit `reference_entities` id needs its `reference_entity_names` entry or a matching `@Name` in the prompt (otherwise exit 36); a `reference_images` UUID is referenced in place when the catalog records it in the same `project` (#995), and a local `reference_images` file is uploaded into the project once and mentioned in place on later calls with the same file, like the CLI's `--ref` ([#772](https://github.com/ffroliva/gflow-cli/issues/772)); an output path gflow cannot write ends in the exit-11-equivalent envelope, with the image still in the Flow project ([#1091](https://github.com/ffroliva/gflow-cli/issues/1091)); other UUID references, instructions and Imagen 4 remain pre-submit refusals there. An agent-only composer (see below) takes T2I only. When Flow returns fewer images than `count`, the reply is still `completed`, `files` lists the images produced, and the `warnings` list includes the object `{"type": "images_missing", "requested": 4, "returned": 3}` (a `failed` reply carries it too when the images came back short before the failure) ([#1489](https://github.com/ffroliva/gflow-cli/issues/1489)). Each saved image is checked against the request at no cost, and a mismatch adds a `warnings` entry carrying its `media_name`: `aspect_mismatch` (decoded `width`/`height` more than 10 % off the `requested` aspect), `echoed_reference` (byte-identical to a local reference image) or `tiny_file` (under 8 KB, with `bytes` and `min_bytes`); the reply stays `completed` and the file is kept, and `wait=true` and `tasks/get` report the same entries ([#1534](https://github.com/ffroliva/gflow-cli/issues/1534)). A path that reads the images off the page (Agent mode, an agent-only composer, or a lost reply) fails instead when some are missing. The queued (`wait=false`) and blocking (`wait=true`) calls use the same typed payload and worker path. -* `gflow_generate_video(prompt, mode, aspect, initial_frame, end_frame, reference_images, reference_entities, reference_entity_names, model, duration, resolution, count, tools, profile, project, project_name, ui_mode, out_file, max_credits, wait, browser_visibility)`: Triggers vertical or landscape video generation (Veo). `out_file` sets an explicit destination file path (mirrors CLI `--out-file`; legacy `output` removed in #1158). `mode` is `t2v`/`i2v`/`r2v`; `model` (`veo_lite`/`veo_fast`/`veo_quality`/`omni_flash`/`omni_1_2_flash`, aliases accepted), `duration` (seconds — 4/6/8 for Veo 3.1, 4/6/8/10 for omni_flash, every integer 3–15 for omni_1_2_flash, at most 10 with an `end_frame`; with no `model`, 4/6/8/10), `resolution` ('360p' or '720p', supported on the Omni models; on any other model, or on the labs editor, the job fails pre-submit with the exit-11-equivalent envelope and no credits spent). **Whether Flow renders a duration control at all is account/cohort-dependent**: on an account that renders none, the job is accepted here and fails in the worker pre-submit (exit 23 equivalent on the labs driver, exit 11 equivalent on the migrated `flow.google.com` host — now the default t2v route, #650 — no credits spent either way) rather than being rejected up front — see [KNOWN_ISSUES](https://github.com/ffroliva/gflow-cli/blob/main/KNOWN_ISSUES.md) (#451/#288/#630), and `count` mirror the CLI `gflow video` flags — an omitted `model` lets the transport apply its i2v veo-lite default (issue #125), and every model — `omni_flash` included — accepts i2v with a start frame and with an end frame (wire-verified 2026-09-02, issue #626); `i2v` requires `initial_frame`, `r2v` requires `reference_images` **or** `reference_entities`; `project` generates into an existing Flow project id (mirrors CLI `--project`; when omitted, [`GFLOW_CLI_PROJECT`](CONFIGURATION.md#gflow_cli_project) is used unless `project_name` asks for a new project, #1039); on an account Google has moved to `flow.google.com` (`GFLOW_CLI_FLOW_HOST`, read from the server/daemon environment, not per call — see [CONFIGURATION § GFLOW_CLI_FLOW_HOST](CONFIGURATION.md#gflow_cli_flow_host)) omitting `project` creates one there first (#864); there, on the classic migrated composer (an agent-only one takes text-to-video only — see below), the ported modes are text-to-video; image-to-video with a **local** `initial_frame` (at the measured key, 9:16 with the default Veo 3.1 Lite and no `duration` / `resolution` / `end_frame`, the frame is uploaded and the request sent over direct HTTP with a headless browser; see [DIRECT_TRANSPORT](https://github.com/ffroliva/gflow-cli/blob/main/docs/DIRECT_TRANSPORT.md)), optionally with a **local** `end_frame` (start+end interpolation, #639 — on the UI path local files are uploaded under a **run-unique** name like `hero-a1b2c3d4.png`, [#792](https://github.com/ffroliva/gflow-cli/issues/792)), **or** captioned image UUIDs the local catalog records in the same `project` ([#1542](https://github.com/ffroliva/gflow-cli/issues/1542), bound in place on the UI path via `/asb/` — the UUID frame skips upload, including Start+End and mixed local+UUID pairs where only the local frame uploads); and reference-to-video with local `reference_images` (each file is uploaded the same way — run-unique name included — and attached as an `@` mention of *that* name in the prompt; `duration` there accepts every integer from `3` through `15` with explicit `model="omni_1_2_flash"` (set through its duration slider; Google AI plans are required above `10`) and `4/6/8/10` with explicit `omni_flash`; Veo or an unspecified model accepts only `8`, because measured shorter Veo requests dropped the references and billed text-to-video, so any other value returns the exit-11-equivalent envelope. An omitted r2v duration still pins `8` to avoid inheriting the editor's previous setting). A cross-project Flow media UUID (or an un-captioned UUID with a verified local fallback) as `initial_frame`/`end_frame`, a character on `t2v` or `i2v`, and a character id missing its display name return the exit-36-equivalent envelope (an uncatalogued/unusable UUID or a non-path string such as `@Name` returns 400 before dispatch); `r2v` takes named characters with or without local `reference_images`. An explicit id's display name can come from its `reference_entity_names` entry or a matching `@Name` in the prompt ([#723](https://github.com/ffroliva/gflow-cli/issues/723)). `initial_frame`, `end_frame`, and `reference_images` each accept **either a local file path or the Flow image UUID of a generated asset** — pass a generated image's id straight in to chain image→video, and gflow attaches it for you. Since v0.58.0 (#529) the CLI and MCP surfaces are unified for i2v frames: the UUID keeps its identity and is enriched with the catalog's recorded display name plus an integrity-verified local fallback, so both transports prefer **selecting the exact asset in the project's media picker** (no duplicate upload). On `labs.google`, a missing tile falls back to re-uploading the recorded local file only if its byte count/SHA-256 still match; on `flow.google.com` (#1542), there is no local-file upload fallback — a missing or unrendered same-project tile reloads the grid up to ~90 s (plus at most one reload cycle) and fails with the exit-32-equivalent envelope. A UUID that isn't in your local asset catalog is rejected up front with a clear "Reference Not Found" error; a catalogued asset with neither a display name nor a verified local file gives a "Reference Not Usable" error (re-generate it or pass a local path). A video clip, or the media UUID of a catalogued clip, in `reference_images` returns a 400 naming `gflow_edit_video`, which edits a local clip with reference images ([#1540](https://github.com/ffroliva/gflow-cli/issues/1540)). For `r2v`, MCP resolves a catalogued image UUID to a verified local file before queuing the job. The flow.google.com driver receives the file for upload. A UUID without a local copy cannot be used this way. `ui_mode` selects the Flow UI arm (#299 PR-A, mirroring CLI `--ui-mode`) and **applies to every mode of this tool, including `r2v`** — unlike the CLI, where `video r2v`/`chain` have no flag and follow the env-only path. On labs and the classic migrated composer, video generation has **only a classic driver**, so `auto` ≡ `classic`: both verify the classic editor pre-submit and abort before spending credits if it is unreachable. `ui_mode="agentic"` is rejected with a 400 problem-details envelope, because no agentic video driver exists yet. (An agent-only migrated composer is routed before this check: text-to-video runs through its chat agent under `ui_mode` `auto` or `classic` — `"agentic"` is still rejected with the 400 above, before any browser work — and other video forms return the exit-36-equivalent envelope before anything is clicked.) Values are matched case-insensitively. (MCP tools return envelopes, never process exit codes — the CLI equivalents of these aborts are exit 28 and exit 2 respectively.) See [CONFIGURATION § GFLOW_CLI_UI_MODE](CONFIGURATION.md#gflow_cli_ui_mode). On a model Flow is retiring, the reply (the `wait=true` result and the queued task's `tasks/get` result alike) also carries `"warnings": [{"type": "model_retiring", "model": "", "retires_on": ""}]` ([#1375](https://github.com/ffroliva/gflow-cli/issues/1375)); the job still runs, and once Flow's menu stops offering the model it fails before submit, charged nothing. + `model` is `nano2` (Nano Banana 2.1 on flow.google.com; `nano2.1` also accepted), `nano2-lite` (Nano Banana 2 Lite), `nano-pro` (Nano Banana Pro) or `image4` (Imagen 4, no longer in Flow's menu); other aliases are accepted too. On migrated `flow.google.com` accounts, T2I and local-file I2I are supported with Nano Banana 2.1 (`nano2`, #958) / 2 Lite / Pro, all five aspects (16:9, 4:3, 1:1, 3:4, 9:16) and count 1–4; the measured shapes are sent as a direct `ogiZ0b` request with a token from a headless browser, and the rest are submitted by Flow's own page ([DIRECT_TRANSPORT](https://github.com/ffroliva/gflow-cli/blob/develop/docs/DIRECT_TRANSPORT.md)). `@Name` character mentions in the prompt are attached through the composer's `@` picker and verified as character chips before submit (#723). each explicit `reference_entities` id needs its `reference_entity_names` entry or a matching `@Name` in the prompt (otherwise exit 36); a `reference_images` UUID is referenced in place when the catalog records it in the same `project` (#995), and a local `reference_images` file is uploaded into the project once and mentioned in place on later calls with the same file, like the CLI's `--ref` ([#772](https://github.com/ffroliva/gflow-cli/issues/772)); an output path gflow cannot write ends in the exit-11-equivalent envelope, with the image still in the Flow project ([#1091](https://github.com/ffroliva/gflow-cli/issues/1091)); other UUID references, instructions and Imagen 4 remain pre-submit refusals there. An agent-only composer (see below) takes T2I only. When Flow returns fewer images than `count`, the reply is still `completed`, `files` lists the images produced, and the `warnings` list includes the object `{"type": "images_missing", "requested": 4, "returned": 3}` (a `failed` reply carries it too when the images came back short before the failure) ([#1489](https://github.com/ffroliva/gflow-cli/issues/1489)). Each saved image is checked against the request at no cost, and a mismatch adds a `warnings` entry carrying its `media_name`: `aspect_mismatch` (decoded `width`/`height` more than 10 % off the `requested` aspect), `echoed_reference` (byte-identical to a local reference image) or `tiny_file` (under 8 KB, with `bytes` and `min_bytes`); the reply stays `completed` and the file is kept, and `wait=true` and `tasks/get` report the same entries ([#1534](https://github.com/ffroliva/gflow-cli/issues/1534)). A path that reads the images off the page (Agent mode, an agent-only composer, or a lost reply) fails instead when some are missing. The queued (`wait=false`) and blocking (`wait=true`) calls use the same typed payload and worker path. +* `gflow_generate_video(prompt, mode, aspect, initial_frame, end_frame, reference_images, reference_entities, reference_entity_names, model, duration, resolution, count, tools, profile, project, project_name, ui_mode, out_file, max_credits, wait, browser_visibility)`: Triggers vertical or landscape video generation (Veo). `out_file` sets an explicit destination file path (mirrors CLI `--out-file`; legacy `output` removed in #1158). `mode` is `t2v`/`i2v`/`r2v`; `model` (`veo_lite`/`veo_fast`/`veo_quality`/`omni_flash`/`omni_1_2_flash`, aliases accepted), `duration` (seconds — 4/6/8 for Veo 3.1, 4/6/8/10 for omni_flash, every integer 3–15 for omni_1_2_flash, at most 10 with an `end_frame`; with no `model`, 4/6/8/10), `resolution` ('360p' or '720p', supported on the Omni models; on any other model, or on the labs editor, the job fails pre-submit with the exit-11-equivalent envelope and no credits spent). **Whether Flow renders a duration control at all is account/cohort-dependent**: on an account that renders none, the job is accepted here and fails in the worker pre-submit (exit 23 equivalent on the labs driver, exit 11 equivalent on the migrated `flow.google.com` host — now the default t2v route, #650 — no credits spent either way) rather than being rejected up front — see [KNOWN_ISSUES](https://github.com/ffroliva/gflow-cli/blob/main/KNOWN_ISSUES.md) (#451/#288/#630), and `count` mirror the CLI `gflow video` flags — an omitted `model` lets the transport apply its i2v veo-lite default (issue #125), and every model — `omni_flash` included — accepts i2v with a start frame and with an end frame (wire-verified 2026-09-02, issue #626); `i2v` requires `initial_frame`, `r2v` requires `reference_images` **or** `reference_entities`; `project` generates into an existing Flow project id (mirrors CLI `--project`; when omitted, [`GFLOW_CLI_PROJECT`](CONFIGURATION.md#gflow_cli_project) is used unless `project_name` asks for a new project, #1039); on an account Google has moved to `flow.google.com` (`GFLOW_CLI_FLOW_HOST`, read from the server/daemon environment, not per call — see [CONFIGURATION § GFLOW_CLI_FLOW_HOST](CONFIGURATION.md#gflow_cli_flow_host)) omitting `project` creates one there first (#864); there, on the classic migrated composer (an agent-only one takes text-to-video only — see below), the ported modes are text-to-video; image-to-video with a **local** `initial_frame` (at the measured key, 9:16 with the default Veo 3.1 Lite and no `duration` / `resolution` / `end_frame`, the frame is uploaded and the request sent over direct HTTP with a headless browser; see [DIRECT_TRANSPORT](https://github.com/ffroliva/gflow-cli/blob/develop/docs/DIRECT_TRANSPORT.md)), optionally with a **local** `end_frame` (start+end interpolation, #639 — on the UI path local files are uploaded under a **run-unique** name like `hero-a1b2c3d4.png`, [#792](https://github.com/ffroliva/gflow-cli/issues/792)), **or** captioned image UUIDs the local catalog records in the same `project` ([#1542](https://github.com/ffroliva/gflow-cli/issues/1542), bound in place on the UI path via `/asb/` — the UUID frame skips upload, including Start+End and mixed local+UUID pairs where only the local frame uploads); and reference-to-video with local `reference_images` (each file is uploaded the same way — run-unique name included — and attached as an `@` mention of *that* name in the prompt; `duration` there accepts every integer from `3` through `15` with explicit `model="omni_1_2_flash"` (set through its duration slider; Google AI plans are required above `10`) and `4/6/8/10` with explicit `omni_flash`; Veo or an unspecified model accepts only `8`, because measured shorter Veo requests dropped the references and billed text-to-video, so any other value returns the exit-11-equivalent envelope. An omitted r2v duration still pins `8` to avoid inheriting the editor's previous setting). A cross-project Flow media UUID (or an un-captioned UUID with a verified local fallback) as `initial_frame`/`end_frame`, a character on `t2v` or `i2v`, and a character id missing its display name return the exit-36-equivalent envelope (an uncatalogued/unusable UUID or a non-path string such as `@Name` returns 400 before dispatch); `r2v` takes named characters with or without local `reference_images`. An explicit id's display name can come from its `reference_entity_names` entry or a matching `@Name` in the prompt ([#723](https://github.com/ffroliva/gflow-cli/issues/723)). `initial_frame`, `end_frame`, and `reference_images` each accept **either a local file path or the Flow image UUID of a generated asset** — pass a generated image's id straight in to chain image→video, and gflow attaches it for you. Since v0.58.0 (#529) the CLI and MCP surfaces are unified for i2v frames: the UUID keeps its identity and is enriched with the catalog's recorded display name plus an integrity-verified local fallback, so both transports prefer **selecting the exact asset in the project's media picker** (no duplicate upload). On `labs.google`, a missing tile falls back to re-uploading the recorded local file only if its byte count/SHA-256 still match; on `flow.google.com` (#1542), there is no local-file upload fallback — a missing or unrendered same-project tile reloads the grid up to ~90 s (plus at most one reload cycle) and fails with the exit-32-equivalent envelope. A UUID that isn't in your local asset catalog is rejected up front with a clear "Reference Not Found" error; a catalogued asset with neither a display name nor a verified local file gives a "Reference Not Usable" error (re-generate it or pass a local path). A video clip, or the media UUID of a catalogued clip, in `reference_images` returns a 400 naming `gflow_edit_video`, which edits a local clip with reference images ([#1540](https://github.com/ffroliva/gflow-cli/issues/1540)). For `r2v`, MCP resolves a catalogued image UUID to a verified local file before queuing the job. The flow.google.com driver receives the file for upload. A UUID without a local copy cannot be used this way. `ui_mode` selects the Flow UI arm (#299 PR-A, mirroring CLI `--ui-mode`) and **applies to every mode of this tool, including `r2v`** — unlike the CLI, where `video r2v`/`chain` have no flag and follow the env-only path. On labs and the classic migrated composer, video generation has **only a classic driver**, so `auto` ≡ `classic`: both verify the classic editor pre-submit and abort before spending credits if it is unreachable. `ui_mode="agentic"` is rejected with a 400 problem-details envelope, because no agentic video driver exists yet. (An agent-only migrated composer is routed before this check: text-to-video runs through its chat agent under `ui_mode` `auto` or `classic` — `"agentic"` is still rejected with the 400 above, before any browser work — and other video forms return the exit-36-equivalent envelope before anything is clicked.) Values are matched case-insensitively. (MCP tools return envelopes, never process exit codes — the CLI equivalents of these aborts are exit 28 and exit 2 respectively.) See [CONFIGURATION § GFLOW_CLI_UI_MODE](CONFIGURATION.md#gflow_cli_ui_mode). On a model Flow is retiring, the reply (the `wait=true` result and the queued task's `tasks/get` result alike) also carries `"warnings": [{"type": "model_retiring", "model": "", "retires_on": ""}]` ([#1375](https://github.com/ffroliva/gflow-cli/issues/1375)); the job still runs, and once Flow's menu stops offering the model it fails before submit, charged nothing. * `gflow_edit_video(source, prompt, reference_images, model, aspect, resolution, max_credits, tools, profile, project, project_name, out_file, wait)`: Edits a local video file (`.mp4`/`.m4v`/`.mov`/`.3gp`/`.avi`, up to 1 GB) or an existing Flow clip media UUID on `flow.google.com` (`jIps6`, Omni models only, default `omni-1.2`, single-clip output) with `0–5` optional `reference_images` (local paths or catalog image UUIDs resolved to local files) for a local source file. With a media UUID source, `reference_images` are refused before the queue (exit 11, `charged: no`): references are not ported to editing an existing clip yet; download the clip with `gflow data download MEDIA_ID --out DIR` and pass the file. `max_credits` enforces Flow's pre-submit credit quote (refusing missing or over-cap quotes at zero spend). Local files support optional `aspect` (`16:9`/`9:16`) and `resolution` (`360p`/`720p`); existing Flow media UUIDs need a project (`project`, else the catalog's record, else `GFLOW_CLI_PROJECT`, the CLI's resolution) and keep source aspect at `720p`. The worker refuses a missing or unsupported file (exit 11), `GFLOW_CLI_FLOW_HOST=labs.google` (exit 36) and a mistyped queued payload (`QueueSchemaError`, exit 30) before it creates a project, all `charged: no`. `out_file` must stay inside the configured output directory. Gated by `--no-spend` with the other credit-spending tools. @@ -143,7 +143,7 @@ is [BROWSER_MODES](BROWSER_MODES.md). > different axis entirely: it buys a *look*, not an identity. For `r2v`, supply `reference_images` or `reference_entities` alongside a prompt mention. Use > `gflow_character_list` to discover ids and display names on `flow.google.com`. On that host, > each id needs its display name in `reference_entity_names` or a matching `@Name` in the prompt. -> An id with neither is exit 36. See [REFERENCE_STRATEGIES](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md). +> An id with neither is exit 36. See [REFERENCE_STRATEGIES](https://github.com/ffroliva/gflow-cli/blob/develop/docs/REFERENCE_STRATEGIES.md). > **`wait` and long generations ([#481](https://github.com/ffroliva/gflow-cli/issues/481), [#1097](https://github.com/ffroliva/gflow-cli/issues/1097)).** > Both generation tools take `wait` (default `true`), and its schema description in @@ -688,7 +688,7 @@ retried by the SDK. These requests are counted in telemetry under the client nam > surface are built as internal foundation but are **not yet wired into** > `gflow serve` — it currently runs the MCP server (Streamable HTTP or SSE) and the > OpenAI-compatible image route above. See the -> [CHANGELOG](https://github.com/ffroliva/gflow-cli/blob/main/CHANGELOG.md) for the roadmap. +> [CHANGELOG](https://github.com/ffroliva/gflow-cli/blob/develop/CHANGELOG.md) for the roadmap. > **Settings reach the server through its environment, not your shell's `.env`.** An MCP > client starts `gflow mcp run` in a directory of its own choosing, so a `.env` beside your diff --git a/website/docs/MEDIA_LIBRARY.md b/website/docs/MEDIA_LIBRARY.md index 4c289ca1e..b1e355fe8 100644 --- a/website/docs/MEDIA_LIBRARY.md +++ b/website/docs/MEDIA_LIBRARY.md @@ -4,7 +4,7 @@ > gflow-cli has hit driving it. All claims here are reverse-engineered from > live recon (2026-08-15/16, evidence in [#529](https://github.com/ffroliva/gflow-cli/issues/529) > / [#543](https://github.com/ffroliva/gflow-cli/issues/543) and the -> [#529 picker spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-08-15-picker-tile-alt-text.md)); +> [#529 picker spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-08-15-picker-tile-alt-text.md)); > Google documents none of it publicly and may change any of it without notice. ## Why this doc exists @@ -106,7 +106,7 @@ Freshness is layered, cheapest-first: budget. This heals the run on every surface (CLI, MCP, `gflow run`); the catalog write still needs the CLI's resolver (`store` mode only). Reach is what the empty picker lists: 15 of 21 assets in the measured project - ([spike](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-12-migrated-listing-captions.md)). + ([spike](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-12-migrated-listing-captions.md)). 3. **Bulk reconciliation** — `gflow data sync --names` ([#543](https://github.com/ffroliva/gflow-cli/issues/543), shipped) for cold catalogs and ghost detection; `gflow doctor` @@ -189,7 +189,7 @@ surfaces that support character entities (the tab set varies by mode), and a - **Reference resolution** (v0.58.0, #529): `catalog UUID → display name → picker search → exact-UUID tile → attach`, falling back to a verified local upload, else a typed error. See - [REFERENCE_STRATEGIES.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md). + [REFERENCE_STRATEGIES.md](https://github.com/ffroliva/gflow-cli/blob/develop/docs/REFERENCE_STRATEGIES.md). - **Shipped**: `gflow doctor` ([#542](https://github.com/ffroliva/gflow-cli/issues/542)) reports nameless/ghost rows; `gflow data sync --names` ([#543](https://github.com/ffroliva/gflow-cli/issues/543)) reconciles the diff --git a/website/docs/MOVIE.md b/website/docs/MOVIE.md index 05ccf6e53..8fcd875f1 100644 --- a/website/docs/MOVIE.md +++ b/website/docs/MOVIE.md @@ -304,12 +304,12 @@ Scenes then name the costume state, and continuity is a lookup rather than a hop **The full identity resolution ladder** — entity, then the entity's own plate, then a plate cut from a take, then prose canon, with the rule that descending a rung is recorded next to the shot — lives in -[`skills/video-production/SKILL.md`](https://github.com/ffroliva/gflow-cli/blob/main/skills/video-production/SKILL.md) step 4a. Read it +[`skills/video-production/SKILL.md`](https://github.com/ffroliva/gflow-cli/blob/develop/skills/video-production/SKILL.md) step 4a. Read it before planning a multi-shot piece; a manifest that silently lands on the bottom rung produces a different actor in every scene. See [CHARACTER.md](CHARACTER.md) for the underlying entity model and -[CHARACTER_RECON.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/CHARACTER_RECON.md) for the reverse-engineered wire +[CHARACTER_RECON.md](https://github.com/ffroliva/gflow-cli/blob/develop/docs/CHARACTER_RECON.md) for the reverse-engineered wire protocol. ## Scene instructions (project brief cards) diff --git a/website/docs/PROMPT_EXPANSION.md b/website/docs/PROMPT_EXPANSION.md index bc4521d30..08fcf2509 100644 --- a/website/docs/PROMPT_EXPANSION.md +++ b/website/docs/PROMPT_EXPANSION.md @@ -40,7 +40,7 @@ Without `GFLOW_CLI_LLM_API_KEY` (or `GFLOW_CLI_LLM_BASE_URL`) the tool leaves yo | **Expansion** | `ExpansionResult(original, expanded, was_expanded)` | The result; `expanded == original` when nothing changed. | | **Provenance** | `AppliedTool(name, version, model, config_hash, params)` | Recorded in history when a tool rewrote a prompt. | -The tool itself lives in [`src/gflow_cli/tools/`](https://github.com/ffroliva/gflow-cli/tree/main/src/gflow_cli/tools): `spec.py` (schema), +The tool itself lives in [`src/gflow_cli/tools/`](https://github.com/ffroliva/gflow-cli/tree/develop/src/gflow_cli/tools): `spec.py` (schema), `runtime.py` (`apply_tool`), `expander.py` (the provider-agnostic `PromptExpander`), `banned.py` (keyword stripping), `invocation.py` (provenance + MCP adapter). @@ -74,7 +74,7 @@ The instruction also carries "Critical Rules": name real cameras/brands, include use prestigious context anchors ("Vanity Fair editorial", "National Geographic cover"), use ALL CAPS for hard constraints, "prominently displayed" for products, and **never** emit banned keywords. The full text is the `system_template` in -[`creative-director.toml`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/builtin/creative-director.toml). +[`creative-director.toml`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/tools/builtin/creative-director.toml). --- @@ -112,7 +112,7 @@ with different vocabularies. | `abstract` | Particle/fluid sims, smoke/ink textures, gradient-shift color, VJ aesthetic. | An **unknown** style is ignored with a `tool_unknown_style` warning — never an error. Full -vocabularies live in [`creative-director.toml`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/builtin/creative-director.toml); +vocabularies live in [`creative-director.toml`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/tools/builtin/creative-director.toml); `gflow tools show creative-director` lists the current set. --- @@ -142,7 +142,7 @@ prompt the tool left unchanged is never altered. ## 6. Never-fatal contract -The `PromptExpander` ([`expander.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/expander.py)) is +The `PromptExpander` ([`expander.py`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/tools/expander.py)) is stdlib-only (`urllib`) and bounded. `expand()` returns the original prompt with `was_expanded=False` in every degraded case. Generation `--tool` calls warn and continue; `gflow tools run` returns a typed error on this result: @@ -193,7 +193,7 @@ reference and worked examples (Google, OpenRouter, a local Docker proxy, keyless ## 8. Provenance — what history records When a tool rewrites a prompt, the generation is recorded with full provenance -([`data/_recorder_core.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/data/_recorder_core.py), `_tool_metadata`): +([`data/_recorder_core.py`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/data/_recorder_core.py), `_tool_metadata`): - **`prompt`** column = the user's **original** prompt. - **`expanded_prompt`** column = the **submitted** (rewritten) prompt. @@ -219,7 +219,7 @@ a recording failure warns and returns exit 0 — never a non-zero exit after a p ## 9. Relationship to the `expand_prompt` MCP prompt The MCP server also exposes an older, now-**deprecated** **prompt template** named `expand_prompt` -([`mcp/prompts.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/mcp/prompts.py)). It predates the tools framework and overlaps +([`mcp/prompts.py`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/mcp/prompts.py)). It predates the tools framework and overlaps functionally with `creative-director`, but they are **different surfaces**: | | `expand_prompt` (MCP prompt) | `creative-director` (tool) | diff --git a/website/docs/SECURITY.md b/website/docs/SECURITY.md index 1155a7a4a..aeb3edef4 100644 --- a/website/docs/SECURITY.md +++ b/website/docs/SECURITY.md @@ -259,7 +259,7 @@ If a profile dir or `.env` containing real secrets ever lands in a Git repo: ## `.gitignore` rules in this repo -The repository's [`.gitignore`](https://github.com/ffroliva/gflow-cli/blob/main/.gitignore) excludes: +The repository's [`.gitignore`](https://github.com/ffroliva/gflow-cli/blob/develop/.gitignore) excludes: ``` auth/ # any project-local auth dir @@ -343,6 +343,6 @@ None to date. This section will list public CVEs, advisories, and patched versio ## See also -- [DISCLAIMER](https://github.com/ffroliva/gflow-cli/blob/main/DISCLAIMER.md) — legal scope & takedown policy +- [DISCLAIMER](https://github.com/ffroliva/gflow-cli/blob/develop/DISCLAIMER.md) — legal scope & takedown policy - [AUTHENTICATION](AUTHENTICATION.md) — full auth lifecycle - [CONFIGURATION](CONFIGURATION.md) — secret-bearing env vars diff --git a/website/docs/TOOLS.md b/website/docs/TOOLS.md index 98031f53c..e0b2a5fa7 100644 --- a/website/docs/TOOLS.md +++ b/website/docs/TOOLS.md @@ -26,7 +26,7 @@ A tool is invoked uniformly in two ways: Tools are **pure prompt transforms** today: they read a prompt and return a (possibly rewritten) prompt. The richer `Tool.apply(ctx) → outcome` dispatch framework (workflow tools beyond prompt rewriting) is a deferred design — see -[the tool-abstraction evaluation](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/research/2026-06-27-tool-abstraction-evaluation.md). +[the tool-abstraction evaluation](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/research/2026-06-27-tool-abstraction-evaluation.md). ### Lineage @@ -195,7 +195,7 @@ without collision — e.g. `creative-director` has both a `product` *image* styl ## 5. The TOML schema A tool is a single TOML file validated into a Pydantic `ToolSpec` -([`src/gflow_cli/tools/spec.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/spec.py)). All models are **frozen** +([`src/gflow_cli/tools/spec.py`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/tools/spec.py)). All models are **frozen** (immutable after load). ### Top-level (`ToolSpec`) @@ -235,7 +235,7 @@ A tool is a single TOML file validated into a Pydantic `ToolSpec` ## 6. How a tool is applied (runtime contract) -[`src/gflow_cli/tools/runtime.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/runtime.py): +[`src/gflow_cli/tools/runtime.py`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/tools/runtime.py): 1. **`build_instruction(config, style, category, *, panels=None)`** — starts from `config.system_template`, appends the bare label `Target medium: image.` or `Target medium: video.` when a category is @@ -264,8 +264,8 @@ generation. `gflow tools run` reports a typed error because expansion is its onl 1. Write `src/gflow_cli/tools/builtin/.toml` following the schema in §5. 2. That's it — the loader auto-discovers every `*.toml` in the `builtin/` package via `importlib.resources` at startup - ([`loader.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/loader.py)), validates it into a `ToolSpec`, and the - registry ([`registry.py`](https://github.com/ffroliva/gflow-cli/blob/main/src/gflow_cli/tools/registry.py)) exposes it under `spec.name`. + ([`loader.py`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/tools/loader.py)), validates it into a `ToolSpec`, and the + registry ([`registry.py`](https://github.com/ffroliva/gflow-cli/blob/develop/src/gflow_cli/tools/registry.py)) exposes it under `spec.name`. Invalid TOML or a schema violation **fails loud** (`ConfigurationError`) the first time any `tools` / `--tool` path runs. 3. Bump the tool's `version` whenever you change behavior; the `config_hash` (a SHA-256 of the @@ -296,7 +296,7 @@ analogue of Flow's Tools menu.) ## 8. MCP exposure Per AGENTS.md §61 (CLI ↔ MCP parity), the tools surface is mirrored on the MCP server -([`src/gflow_cli/mcp/`](https://github.com/ffroliva/gflow-cli/tree/main/src/gflow_cli/mcp)): +([`src/gflow_cli/mcp/`](https://github.com/ffroliva/gflow-cli/tree/develop/src/gflow_cli/mcp)): - **`gflow_list_tools`** — mirrors `gflow tools list`; returns `[{name, title, description, category}, …]`. @@ -330,5 +330,5 @@ for the full comparison and migration guidance. - [CONFIGURATION.md](CONFIGURATION.md) — `GFLOW_CLI_LLM_BASE_URL` / `_API_KEY` / `_MODEL`. - [DATA_LAYER.md](DATA_LAYER.md) — how `expanded_prompt` and `metadata_json.tool` are recorded. - [MCP.md](MCP.md) — the MCP server. -- [tool-abstraction evaluation](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/research/2026-06-27-tool-abstraction-evaluation.md) — +- [tool-abstraction evaluation](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/research/2026-06-27-tool-abstraction-evaluation.md) — the deferred S3 dispatch-framework design. diff --git a/website/docs/USAGE.md b/website/docs/USAGE.md index ce9fb105b..173cb13a9 100644 --- a/website/docs/USAGE.md +++ b/website/docs/USAGE.md @@ -143,7 +143,7 @@ back. `--search "r2v duration"` narrows that to a handful with the host-specific at the top. Curated answers rank first: the `**"How do I …?"** →` rows in -[INDEX](https://github.com/ffroliva/gflow-cli/blob/main/docs/INDEX.md#topic-shortcuts) were each written to *be* an answer, so they come above +[INDEX](https://github.com/ffroliva/gflow-cli/blob/develop/docs/INDEX.md#topic-shortcuts) were each written to *be* an answer, so they come above raw body-text matches for the same term. Piping works — the page is emitted as its own Markdown, not as rendered boxes: @@ -481,7 +481,7 @@ Notes: - **flow.google.com only.** There is no labs.google route; `GFLOW_CLI_FLOW_HOST=labs.google` refuses the command with exit 36. - **Cost:** the 1080p export was measured free (1 observation, 2026-10-07), as were the 720p - export and the 270p GIF ([2026-11-29](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-11-29-export-billing-720p-270p.md)); the 4K export on Flow Ultra spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). + export and the 270p GIF ([2026-11-29](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-11-29-export-billing-720p-270p.md)); the 4K export on Flow Ultra spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). - Saved as `/videos//_.` (`.mp4` or `.gif`). ## `gflow image generate` / `gflow video generate` @@ -872,7 +872,7 @@ entities (it carries start/end frames instead). `--ref` is different: it attaches an arbitrary **image** (`referenceImages`), not a saved identity, and can be combined with a `@Name` for "this identity, in this look". -See [REFERENCE_STRATEGIES.md](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md) for the full decision guide. +See [REFERENCE_STRATEGIES.md](https://github.com/ffroliva/gflow-cli/blob/develop/docs/REFERENCE_STRATEGIES.md) for the full decision guide. ## `gflow image batch` @@ -886,7 +886,7 @@ Tab-separated columns. Only `prompt` is required; remaining columns fall back to promptcountaspect_ratiomodel ``` -Lines starting with `#` and blank lines are skipped. Example: [`test_assets/sample_batch.tsv`](https://github.com/ffroliva/gflow-cli/blob/main/test_assets/sample_batch.tsv). +Lines starting with `#` and blank lines are skipped. Example: [`test_assets/sample_batch.tsv`](https://github.com/ffroliva/gflow-cli/blob/develop/test_assets/sample_batch.tsv). ```tsv a small calico kitten sitting on a windowsill @@ -908,7 +908,7 @@ an isometric pixel-art bakery 1 1:1 nano2 ] ``` -Example: [`test_assets/sample_batch.json`](https://github.com/ffroliva/gflow-cli/blob/main/test_assets/sample_batch.json). +Example: [`test_assets/sample_batch.json`](https://github.com/ffroliva/gflow-cli/blob/develop/test_assets/sample_batch.json). ### Session behaviour @@ -1049,7 +1049,7 @@ Options: > are not ported to the migrated composer yet; `r2v` takes a character with > `--reference-entity` paired with `--reference-entity-name` (#723). `image t2i` and local-file `image i2i` also run on a moved > account, and on images a character can be tagged with `@Name` or `--reference-entity` -> (see [REFERENCE_STRATEGIES § flow.google.com](https://github.com/ffroliva/gflow-cli/blob/main/docs/REFERENCE_STRATEGIES.md#on-flowgooglecom-images-and-video-r2v-723)). An image `--ref ` is referenced in place, with no upload, when the +> (see [REFERENCE_STRATEGIES § flow.google.com](https://github.com/ffroliva/gflow-cli/blob/develop/docs/REFERENCE_STRATEGIES.md#on-flowgooglecom-images-and-video-r2v-723)). An image `--ref ` is referenced in place, with no upload, when the > local catalog records that image in the same `--project` and keeps its Flow caption > ([#995](https://github.com/ffroliva/gflow-cli/issues/995)); any other UUID, and instruction/Imagen-4 > image forms, still exit 36. `flow.google.com` forces the migrated composer, @@ -1085,7 +1085,7 @@ the editor's frame slot via the media dialog, then Flow fires > - **Default shape (direct HTTP, since v0.108.0):** a local `--initial-frame` at 9:16 with > the default Veo 3.1 Lite model and no `--duration`, `--resolution`, `--end-frame`, or > `--max-credits` uploads the frame and submits over direct HTTP with a headless browser -> ([DIRECT_TRANSPORT](https://github.com/ffroliva/gflow-cli/blob/main/docs/DIRECT_TRANSPORT.md)). +> ([DIRECT_TRANSPORT](https://github.com/ffroliva/gflow-cli/blob/develop/docs/DIRECT_TRANSPORT.md)). > - **Local files (UI route):** other local start-frame shapes and local `--end-frame` > interpolation upload the file through the editor's own Upload entry (it stays in the > project's library like any upload — a second run uploads it again), find it in the Frames @@ -3167,7 +3167,7 @@ The table below is the default (legacy) set. `GFLOW_CLI_EXIT_CODES=2` opts in to | `28` | `UiModeUnavailableError` | The Flow UI arm this command required (`--ui-mode`/`GFLOW_CLI_UI_MODE`; `-i` forces agentic for images; **labs video always requires classic** — no agentic labs video driver exists; an agent-only `flow.google.com` composer ([#799](https://github.com/ffroliva/gflow-cli/issues/799)) is routed before this policy and never exits 28) couldn't be reached after a switch attempt; aborted before submitting — no credits spent (issue #299) | Retry (the cohort flaps per load); try another `--profile`; for images you can also relax `GFLOW_CLI_UI_MODE` — for video there is nothing to relax | | `29` | `MentionIndexUnavailableError` | An `@mention` was present but the catalog source needed to resolve it (character entities or media assets) failed to load — distinct from an empty index, which is not an error. Also raised on a page served labs for an image character known only by name (#723), since that picker attaches by entity id | Check network connectivity (character source) or `GFLOW_CLI_DB_PATH` / filesystem permissions (media source), then retry. For the by-name character on labs, pass `--reference-entity ` | | `30` | `QueueSchemaError` | A `gflow serve`/MCP worker-queue task payload has an unrecognized `schema_version` or fails validation against the typed request DTOs | Usually means gflow-cli was downgraded after a newer version enqueued the task, or the payload was hand-edited; re-enqueue with a compatible version | -| `31` | `FlowAppError` | Flow did not serve the page gflow asked for. Two shapes: its error-boundary page rendered instead of the editor (a transient client-side crash), or it redirected to `flow.google.com/about` instead of the project ([#756](https://github.com/ffroliva/gflow-cli/issues/756)) | Crash: retry shortly; if it persists, Flow itself is degraded. `/about`: run `gflow auth login --profile ` and finish Google's "Confirm it's you" if it asks; then open the project in a browser on that host and confirm this account can reach it. A retry is **measured** not to help — 5/5 consecutive attempts during a live occurrence landed on `/about` again ([2026-09-11](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-11-about-redirect-is-stable-for-an-account.md); the [2026-09-10 run](https://github.com/ffroliva/gflow-cli/blob/main/docs/superpowers/spikes/2026-09-10-about-redirect-stability.md) got 0/5 only because the redirect had stopped reproducing) — so gflow does not flag it retryable. One cause is measured since: Google wanted the account to "Confirm it's you" while its cookies were healthy ([2026-09-23](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-23-about-cta-leads-to-google-reauth.md)); `gflow auth login` waits on that check ([#902](https://github.com/ffroliva/gflow-cli/issues/902)) | +| `31` | `FlowAppError` | Flow did not serve the page gflow asked for. Two shapes: its error-boundary page rendered instead of the editor (a transient client-side crash), or it redirected to `flow.google.com/about` instead of the project ([#756](https://github.com/ffroliva/gflow-cli/issues/756)) | Crash: retry shortly; if it persists, Flow itself is degraded. `/about`: run `gflow auth login --profile ` and finish Google's "Confirm it's you" if it asks; then open the project in a browser on that host and confirm this account can reach it. A retry is **measured** not to help — 5/5 consecutive attempts during a live occurrence landed on `/about` again ([2026-09-11](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-11-about-redirect-is-stable-for-an-account.md); the [2026-09-10 run](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-10-about-redirect-stability.md) got 0/5 only because the redirect had stopped reproducing) — so gflow does not flag it retryable. One cause is measured since: Google wanted the account to "Confirm it's you" while its cookies were healthy ([2026-09-23](https://github.com/ffroliva/gflow-cli/blob/develop/docs/superpowers/spikes/2026-09-23-about-cta-leads-to-google-reauth.md)); `gflow auth login` waits on that check ([#902](https://github.com/ffroliva/gflow-cli/issues/902)) | | `32` | `ReferenceNotFoundError` | A referenced media NAME is not in this project's picker. Flow indexes a short auto-caption, not the generation prompt, so a prompt used as a reference name never matches. On flow.google.com this includes an unmatched `@Name` when the catalog is available. For an image character (#723) it is also raised when no picker option is titled exactly the name, several are, or the match is media; after up to ~90 s of reloads, for a catalogued same-`--project` UUID ref (`image i2i --ref`, #995, or `video i2v` Start/End frame, #1542) whose image is no longer in the project grid (deleted in Flow); and when an `@` reference attaches out of order, landing before a chip already in the prompt (#997); and when a local `--ref` upload does not become the `@` picker's active row within 8 s, or the new chip is not that upload (`video extend`, `video r2v`, and the `image i2i` fallback, [#1581](https://github.com/ffroliva/gflow-cli/issues/1581)), before anything is submitted | Reference the asset by its media UUID (if Flow deleted it, regenerate it or pass its local file), pass a local file with `--ref`, or check what exists with `gflow data list images`. For a character the picker never offers (#1333), check the name with `gflow character list --project `; when several options or a media asset share the name, rename the colliding asset in Flow, or give the character a unique one-word name. Out of order: re-run; if it repeats, report it with the reference count and window size | | `33` | — (`gflow doctor` verdict) | Doctor found warn/fail findings — a successful diagnosis, not an error class | Review the report; see [`gflow doctor`](#gflow-doctor) | | `34` | `SyncPartialError` | `gflow data sync` failed on some projects but succeeded on others — completed writes stay committed | Retryable: re-run the same command; it resumes with what is still nameless (see [`gflow data sync`](#gflow-data-sync)) | @@ -3320,5 +3320,5 @@ async with FlowApiClient(profile_dir=profile_dir) as client: - [AUTHENTICATION](AUTHENTICATION.md) — auth flow + multi-account - [ARCHITECTURE](ARCHITECTURE.md) — internal structure (for contributors) - [TELEMETRY](TELEMETRY.md) — local weekly usage metrics, telemetry.db, and kill switches -- [PLAN](https://github.com/ffroliva/gflow-cli/blob/main/PLAN.md) — what ships in which phase +- [PLAN](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md) — what ships in which phase From 458354c98ec32b4278cb65203821a70be728fd8a Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 12:12:10 +0000 Subject: [PATCH 07/28] refactor(docs): replace the CommonMark link parser with masking and two regexes (#1755) The site renders with Python-Markdown, not CommonMark, so a spec-exact CommonMark parser modelled the wrong renderer: on its own edge-case tests it disagreed with the site in 12 of 30 cases. The scanner now blanks fenced code, HTML comments and code spans in place, then matches inline links and reference definitions with two regexes. On the docs corpus it finds the same links at the same offsets, the regenerated mirror is byte-identical, and --check still fails on every unresolved link. The script drops from about 810 to 329 lines and stays standard-library only. Tests that exercised CommonMark containers and indented code are removed; an escaped backtick and a list-item boundary now end a code span. The check and doc-review skills list the UNRESOLVED-LINK failure. --- scripts/ci/generate_website_docs.py | 588 ++------------------ skills/check/SKILL.md | 5 +- skills/doc-review/SKILL.md | 6 +- tests/scripts/test_generate_website_docs.py | 143 +---- 4 files changed, 67 insertions(+), 675 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index cfb77f651..1da965666 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -23,7 +23,6 @@ import re import sys from collections.abc import Iterator -from dataclasses import dataclass, field from pathlib import Path from urllib.parse import quote, unquote, urlsplit @@ -109,43 +108,10 @@ def _source_for(dest_name: str) -> Path | None: return None -_THEMATIC = re.compile(r"(?:(-[ \t]*){3,}|(\*[ \t]*){3,}|(_[ \t]*){3,})$") -_SETEXT = re.compile(r"(?:=+|-+)[ \t]*$") -_ATX = re.compile(r"#{1,6}(?:[ \t]|$)") -_FENCE_OPEN = re.compile(r"(`{3,}|~{3,})(.*)") -_FENCE_CLOSE = re.compile(r"(`{3,}|~{3,})[ \t]*$") -_LIST_MARKER = re.compile(r"([-*+]|\d{1,9}[.)])(?:([ \t]+)|$)") -_HTML_BLOCK_1 = re.compile(r"<(?:pre|script|style|textarea)(?:[ \t>]|$)", re.IGNORECASE) -_HTML_BLOCK_1_END = re.compile(r"", re.IGNORECASE) -_HTML_COMMENT_OPEN = re.compile(r"") -_HTML_BLOCK_6 = re.compile( - r"]|$)", - re.IGNORECASE, -) _MD_UNESCAPE = re.compile( r"\\([!\"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~])" r"|(&(?:#[0-9]{1,7}|#[xX][0-9a-fA-F]{1,6}|[A-Za-z][A-Za-z0-9]{1,31});)" ) -_TITLE = r'(?:"(?:\\.|[^"\\])*"|\'(?:\\.|[^\'\\])*\'|\((?:\\.|[^()\\])*\))' -_DEST_TAIL = re.compile(rf"(?:\s+{_TITLE})?\s*\)") -_REF_DEF = re.compile( - rf"[ \t]{{0,3}}\[(?![ \t]*\])(?:[^\[\]\\]|\\[^\n]){{1,999}}\]:[ \t]*(?:\n[ \t]*)?" - rf"(?:<((?:[^<>\n\\]|\\.)*)>|((?:[^\s\\]|\\.)+))" - rf"(?:(?:[ \t]+|[ \t]*\n[ \t]*){_TITLE})?[ \t]*(?=$|\n)" -) -_AUTOLINK_OR_HTML = re.compile( - r"<(?:[A-Za-z][A-Za-z0-9+.-]{1,31}:[^\s<>]*|!--[\s\S]*?--|" - r"/?[A-Za-z][A-Za-z0-9-]*" - r"(?:\s+[^\s\"'>/=]+(?:\s*=\s*(?:\"[^\"]*\"|'[^']*'|[^\s\"'=<>`]+))?)*\s*/?)>" -) -_LINK_TOK = re.compile(r"\\[^\n]|!\[|\[|\]") -_DEST_OPEN = re.compile(r"\]\(\s*$") -_SCHEME = re.compile(r"[A-Za-z][A-Za-z0-9+.-]*:") def _unescape_md(value: str) -> str: @@ -155,516 +121,65 @@ def _unescape_md(value: str) -> str: ) -@dataclass -class _Container: - kind: str # "bq" or "list" - width: int = 0 - empty: bool = False - - -@dataclass -class _LineCursor: - line: str - idx: int = 0 - col: int = 0 - pad: int = 0 - - def peek_indent(self) -> tuple[int, int]: - """Return (leading whitespace columns, char index of first non-whitespace char).""" - cols = self.pad - i = self.idx - c = self.col + self.pad - n = len(self.line) - while i < n: - ch = self.line[i] - if ch == " ": - cols += 1 - c += 1 - elif ch == "\t": - step = 4 - (c % 4) - cols += step - c += step - else: - break - i += 1 - return cols, i - - def is_blank(self) -> bool: - _, i = self.peek_indent() - return i >= len(self.line) - - def consume_cols(self, count: int) -> None: - """Advance across ``count`` indentation columns, expanding tabs into virtual spaces.""" - rem = count - if self.pad: - take = min(self.pad, rem) - self.pad -= take - self.col += take - rem -= take - n = len(self.line) - while rem > 0 and self.idx < n: - rem -= self._step_col(rem) - - def _step_col(self, rem: int) -> int: - ch = self.line[self.idx] - if ch == " ": - self.idx += 1 - self.col += 1 - return 1 - if ch == "\t": - step = 4 - (self.col % 4) - self.idx += 1 - take = min(step, rem) - self.col += take - self.pad = step - take - return take - return rem - - def consume_chars(self, count: int) -> None: - self.pad = 0 - self.idx += count - self.col += count - - -def _consume_bq(cur: _LineCursor) -> bool: - indent, nonws = cur.peek_indent() - if indent >= 4 or nonws >= len(cur.line) or cur.line[nonws] != ">": - return False - cur.consume_cols(indent) - cur.consume_chars(1) - if cur.peek_indent()[0] > 0: - cur.consume_cols(1) - return True - - -def _match_containers(cur: _LineCursor, containers: list[_Container]) -> int: - matched = 0 - for cont in containers: - if cont.kind == "bq": - if not _consume_bq(cur): - break - matched += 1 - continue - indent, nonws = cur.peek_indent() - if nonws >= len(cur.line): - matched += 1 - continue - if indent < cont.width: - break - cur.consume_cols(cont.width) - matched += 1 - return matched - - -def _list_marker_allowed(marker: str, is_empty: bool, interrupting_para: bool) -> bool: - if not interrupting_para: - return True - if is_empty: - return False - return not marker[0].isdigit() or marker[:-1] == "1" - +_FENCE = re.compile(r"^[ \t>]*(`{3,}|~{3,})") +# A code span: not opened by an escaped backtick, and ended by a blank line or a new list item. +_CODE_SPAN = re.compile( + r"(?]*(?:\n|[-*+][ \t]|\d{1,9}[.)][ \t]))|`(?!\1))*?" + r"(?", re.DOTALL) +_INLINE = re.compile( + r"\]\([ \t]*(?:<([^<>\n]*)>|((?:[^\s()\\]|\\.|\([^\s()]*\))+))" + r"(?:\s+(?:\"[^\"\n]*\"|'[^'\n]*'))?[ \t]*\)" +) +_REF_DEF = re.compile(r"^[ \t>]*\[[^\]\n]+\]:[ \t]*(?:<([^<>\n]*)>|(\S+))", re.MULTILINE) +_SCHEME = re.compile(r"[A-Za-z][A-Za-z0-9+.-]*:") -def _try_open_list(cur: _LineCursor, interrupting_para: bool) -> _Container | None: - indent, nonws = cur.peek_indent() - if indent >= 4 or nonws >= len(cur.line): - return None - rest = cur.line[nonws:] - if _THEMATIC.match(rest): - return None - m = _LIST_MARKER.match(rest) - if not m: - return None - marker = m.group(1) - is_empty = nonws + m.end() >= len(cur.line) - if not _list_marker_allowed(marker, is_empty, interrupting_para): - return None - cur.consume_cols(indent) - cur.consume_chars(len(marker)) - if is_empty: - return _Container("list", width=indent + len(marker) + 1, empty=True) - ws_cols, _ = cur.peek_indent() - use_cols = 1 if ws_cols >= 5 else ws_cols - cur.consume_cols(use_cols) - return _Container("list", width=indent + len(marker) + use_cols, empty=False) - - -def _opens_fence(rest: str) -> str: - fm = _FENCE_OPEN.match(rest) - if not fm: - return "" - run, info = fm.groups() - return run if run[0] == "~" or "`" not in info else "" - - -def _html_block_end(rest: str) -> re.Pattern[str] | None: - if _HTML_BLOCK_1.match(rest): - return _HTML_BLOCK_1_END - if _HTML_COMMENT_OPEN.match(rest): - return _HTML_COMMENT_END - return None +def _blank(m: re.Match[str]) -> str: + return re.sub(r"[^\n]", " ", m[0]) -def _is_block_interrupt(cur: _LineCursor, interrupting_para: bool) -> bool: - indent, nonws = cur.peek_indent() - if indent >= 4 or nonws >= len(cur.line): - return False - rest = cur.line[nonws:] - if rest[0] == ">" or _ATX.match(rest) or _THEMATIC.match(rest) or _opens_fence(rest): - return True - if _html_block_end(rest) is not None or _HTML_BLOCK_6.match(rest): - return True - m = _LIST_MARKER.match(rest) - if not m: - return False - return _list_marker_allowed(m.group(1), nonws + m.end() >= len(cur.line), interrupting_para) - - -def _is_only_ref_defs(text: str, spans: list[tuple[int, int]]) -> bool: - if not spans: - return False - block = "\n".join(text[s:e] for s, e in spans) - pos = 0 - n = len(block) - while pos < n: - m = _REF_DEF.match(block, pos) - if not m: - return False - pos = m.end() - if pos < n and block[pos] == "\n": - pos += 1 - return True - - -@dataclass -class _BlockParser: - text: str - blocks: list[tuple[str, list[tuple[int, int]]]] = field(default_factory=list) - containers: list[_Container] = field(default_factory=list) - fence: tuple[str, int] | None = None - html_end: tuple[re.Pattern[str] | None, int] | None = None - para: list[tuple[int, int]] = field(default_factory=list) - - def _flush_para(self) -> None: - if self.para: - self.blocks.append(("para", list(self.para))) - self.para.clear() - - def _handle_blank(self, matched: int) -> None: - del self.containers[matched:] - if self.fence and self.fence[1] > len(self.containers): - self.fence = None - if self.html_end and (self.html_end[0] is None or self.html_end[1] > len(self.containers)): - self.html_end = None - self._flush_para() - while self.containers and self.containers[-1].kind == "list" and self.containers[-1].empty: - self.containers.pop() - - def _handle_active_html(self, cur: _LineCursor, matched: int) -> bool: - if self.html_end is None: - return False - end_pat, depth = self.html_end - if matched < depth: - del self.containers[matched:] - self.html_end = None - return False - if end_pat is not None and end_pat.search(cur.line[cur.idx :]): - self.html_end = None - return True - - def _handle_active_fence(self, cur: _LineCursor, matched: int) -> bool: - if self.fence is None: - return False - marker, depth = self.fence - if matched < depth: - del self.containers[matched:] - self.fence = None - return False - indent, nonws = cur.peek_indent() - if indent < 4: - cm = _FENCE_CLOSE.match(cur.line[nonws:]) - if cm and cm.group(1).startswith(marker): - self.fence = None - return True - - def _open_containers(self, cur: _LineCursor, in_para: bool) -> bool: - opened = False - while True: - if _consume_bq(cur): - new_c: _Container | None = _Container("bq") - else: - new_c = _try_open_list(cur, interrupting_para=in_para) - if new_c is None: - return opened - self._flush_para() - in_para = False - for c in self.containers: - c.empty = False - self.containers.append(new_c) - opened = True - - def _handle_leaf(self, cur: _LineCursor, line_start: int, end_off: int, in_para: bool) -> None: - indent, nonws = cur.peek_indent() - rest = cur.line[nonws:] - if indent < 4 and self._handle_unindented_leaf(rest, line_start + nonws, end_off, in_para): - return - if not in_para and indent >= 4: - self._flush_para() - return - self.para.append((line_start + cur.idx, end_off)) - - def _handle_unindented_leaf( - self, rest: str, abs_nonws: int, end_off: int, in_para: bool - ) -> bool: - if in_para and _SETEXT.match(rest): - self._flush_para() - return True - if run := _opens_fence(rest): - self._flush_para() - self.fence = (run, len(self.containers)) - return True - if (end_pat := _html_block_end(rest)) is not None or _HTML_BLOCK_6.match(rest): - self._flush_para() - if end_pat is None or not end_pat.search(rest): - self.html_end = (end_pat, len(self.containers)) - return True - if _THEMATIC.match(rest): - self._flush_para() - return True - if _ATX.match(rest): - self._flush_para() - self.blocks.append(("heading", [(abs_nonws, end_off)])) - return True - return False - - def feed(self, raw: str, line_start: int) -> None: - stripped = raw.rstrip("\r\n") - end_off = line_start + len(stripped) - cur = _LineCursor(stripped) - matched = _match_containers(cur, self.containers) - if cur.is_blank(): - self._handle_blank(matched) - return - if self._handle_active_html(cur, matched) or self._handle_active_fence(cur, matched): - return - in_para = bool(self.para) and not _is_only_ref_defs(self.text, self.para) - if matched < len(self.containers): - replacing_list = self.containers[matched].kind == "list" - if in_para and not _is_block_interrupt(cur, interrupting_para=not replacing_list): - self.para.append((line_start + cur.idx, end_off)) - return - self._flush_para() - del self.containers[matched:] - in_para = False - if self._open_containers(cur, in_para): - in_para = False - if cur.is_blank(): - return - for c in self.containers: - c.empty = False - self._handle_leaf(cur, line_start, end_off, in_para) - - def extract(self) -> list[tuple[str, list[tuple[int, int]]]]: - offset = 0 - for raw in self.text.splitlines(keepends=True): - self.feed(raw, offset) - offset += len(raw) - self._flush_para() - return self.blocks - - -def _find_code_span_end(block: str, start: int, tick_len: int) -> int: - j = start - n = len(block) - while j < n: - if block[j] == "`": - c_end = j - while c_end < n and block[c_end] == "`": - c_end += 1 - if c_end - j == tick_len: - return c_end - j = c_end - continue - j += 1 - return -1 - - -def _blank_span(out: list[str], start: int, end: int) -> None: - for k in range(start, end): - if out[k] != "\n": - out[k] = " " - - -def _mask_code_span(block: str, out: list[str], start: int) -> int: - n = len(block) - run_end = start - while run_end < n and block[run_end] == "`": - run_end += 1 - close_end = _find_code_span_end(block, run_end, run_end - start) - if close_end > 0: - _blank_span(out, start, close_end) - return close_end - return run_end - - -def _mask_inline_code_and_html(block: str) -> str: - """Replace inline code spans and autolinks/HTML tags with spaces without shifting indices.""" - out = list(block) - i = 0 - n = len(block) - while i < n: - ch = block[i] - if ch == "\\": - i += 2 - elif ch == "`": - i = _mask_code_span(block, out, i) - elif ( - ch == "<" - and not _DEST_OPEN.search(block, 0, i) # `]()` is a destination, not HTML. - and (m := _AUTOLINK_OR_HTML.match(block, i)) - ): - _blank_span(out, i, m.end()) - i = m.end() - else: - i += 1 - return "".join(out) +def _mask(text: str) -> str: + """Blank fenced code, HTML comments and code spans in place, so offsets still index ``text``. -def _parse_angle_dest(prose: str, i: int) -> tuple[int, int, int] | None: - n = len(prose) - dest_start = i + 1 - j = dest_start - while j < n and prose[j] not in "<>\r\n": - j += 2 if prose[j] == "\\" else 1 - if j >= n or prose[j] != ">": - return None - return dest_start, j, j + 1 - - -def _parse_bare_dest(prose: str, i: int) -> tuple[int, int, int] | None: - n = len(prose) - dest_start = i - depth = 0 - while i < n: - ch = prose[i] - if ch == "\\" and i + 1 < n: - i += 2 - elif ch.isspace() or ord(ch) < 32: - break - elif ch == "(": - depth += 1 - i += 1 - elif ch == ")": - if depth == 0: - break - depth -= 1 - i += 1 + shortcut: matches what the docs use, not full Markdown. Indented code and admonition bodies are + scanned as prose, so a link-shaped example there is rewritten or fails ``--check`` loudly; + upgrade to a real parser only when a page needs that. + """ + out: list[str] = [] + fence = "" + for line in text.splitlines(keepends=True): + m = _FENCE.match(line) + if fence: + if ( + m + and m[1][0] == fence[0] + and len(m[1]) >= len(fence) + and not line[m.end() :].strip() + ): + fence = "" + elif m and not (m[1][0] == "`" and "`" in line[m.end() :]): + fence = m[1] else: - i += 1 - return (dest_start, i, i) if depth == 0 and i > dest_start else None - - -def _parse_inline_destination(prose: str, pos: int) -> tuple[int, int, int] | None: - """Parse ``(dest [title])`` starting right after ``]``, handling nested parens.""" - n = len(prose) - if pos >= n or prose[pos] != "(": - return None - i = pos + 1 - while i < n and prose[i].isspace(): - i += 1 - if i >= n: - return None - parsed = _parse_angle_dest(prose, i) if prose[i] == "<" else _parse_bare_dest(prose, i) - if parsed is None: - return None - dest_start, dest_end, next_i = parsed - tail = _DEST_TAIL.match(prose, next_i) - return (dest_start, dest_end, tail.end()) if tail else None - - -def _is_relative_target(target: str) -> bool: - # Regex, not urlsplit: urlsplit raises on a malformed authority such as `https://[x`. - return bool(target) and not target.startswith("/") and not _SCHEME.match(target) - - -def _consume_ref_defs( - block: str, pos_map: list[int], text: str -) -> tuple[int, list[tuple[int, int, str]]]: - found: list[tuple[int, int, str]] = [] - pos = 0 - n = len(block) - while pos < n: - m = _REF_DEF.match(block, pos) - if not m: - break - ds, de = m.span(1 if m[1] is not None else 2) - if ds < de: - abs_s, abs_e = pos_map[ds], pos_map[de - 1] + 1 - target = text[abs_s:abs_e] - if _is_relative_target(target): - found.append((abs_s, abs_e, target)) - pos = m.end() - if pos < n and block[pos] == "\n": - pos += 1 - return pos, found - - -def _deactivate_outer_links(stack: list[list[bool]]) -> None: - for entry in stack: - if not entry[0]: - entry[1] = False - - -def _extract_inline_target( - ds: int, de: int, base: int, pos_map: list[int], text: str -) -> tuple[int, int, str] | None: - if ds >= de: - return None - abs_s, abs_e = pos_map[base + ds], pos_map[base + de - 1] + 1 - target = text[abs_s:abs_e] - return (abs_s, abs_e, target) if _is_relative_target(target) else None - - -def _scan_inline_links( - prose: str, base: int, pos_map: list[int], text: str -) -> Iterator[tuple[int, int, str]]: - stack: list[list[bool]] = [] # [is_image, active] - cursor = 0 - for m in _LINK_TOK.finditer(prose): - ts, te, tok = m.start(), m.end(), m[0] - if ts < cursor: + out.append(line) continue - if tok in ("![", "["): - stack.append([tok == "![", True]) - elif tok == "]" and stack: - is_img, active = stack.pop() - if active and (parsed := _parse_inline_destination(prose, te)) is not None: - ds, de, tail_end = parsed - if link := _extract_inline_target(ds, de, base, pos_map, text): - yield link - if not is_img: - _deactivate_outer_links(stack) - cursor = tail_end + out.append(re.sub(r"[^\n]", " ", line)) + return _CODE_SPAN.sub(_blank, _COMMENT.sub(_blank, "".join(out))) def _relative_links(text: str) -> Iterator[tuple[int, int, str]]: - """Yield (start, end, target) for inline links, linked images, and reference definitions.""" - for kind, spans in _BlockParser(text).extract(): - parts: list[str] = [] - pos_map: list[int] = [] - for idx_s, (s, e) in enumerate(spans): - if idx_s > 0: - parts.append("\n") - pos_map.append(-1) - parts.append(text[s:e]) - pos_map.extend(range(s, e)) - block = "".join(parts) - pos = 0 - if kind == "para": - pos, ref_links = _consume_ref_defs(block, pos_map, text) - yield from ref_links - if pos < len(block): - prose = _mask_inline_code_and_html(block[pos:]) - yield from _scan_inline_links(prose, pos, pos_map, text) + masked = _mask(text) + hits = [] + for pat in (_INLINE, _REF_DEF): + for m in pat.finditer(masked): + g = 1 if m[1] is not None else 2 + s, e = m.span(g) + t = text[s:e] + if t and not t.startswith("/") and not _SCHEME.match(t): + hits.append((s, e, t)) + yield from sorted(hits) def _site_files() -> set[str]: @@ -801,7 +316,10 @@ def main(argv: list[str]) -> int: for problem in unresolved: print(problem) return 1 - print(f"website/docs mirror in sync ({len(_mirrored_targets())} files), nav complete.") + print( + f"website/docs mirror in sync ({len(_mirrored_targets())} files), nav complete, " + "relative links resolved." + ) return 0 print(f"Regenerated {written} website/docs file(s) from canonical.") return 0 diff --git a/skills/check/SKILL.md b/skills/check/SKILL.md index 02b2f5e0d..3f8d2efbf 100644 --- a/skills/check/SKILL.md +++ b/skills/check/SKILL.md @@ -26,7 +26,7 @@ PYTHONUTF8=1 uv run python scripts/ci/generate_plugin_skills.py --check PYTHONUTF8=1 uv run python scripts/ci/check_commit_trailers.py ``` -`generate_website_docs.py --check` fails on either half of the published-site contract: +`generate_website_docs.py --check` fails on any part of the published-site contract: - `DRIFT:` — canonical `docs/` changed but the `website/docs/` mirror was not regenerated. Fix with `uv run python scripts/ci/generate_website_docs.py` and @@ -34,6 +34,9 @@ PYTHONUTF8=1 uv run python scripts/ci/check_commit_trailers.py - `NAV-ORPHAN:` — a page is published but no `nav:` entry in `website/mkdocs.yml` points at it, so it is live but unreachable. Add the entry under the right nav section. +- `UNRESOLVED-LINK: :: ` — a published page holds a relative + link that resolves to no published file. Fix the link in the canonical doc and + regenerate; a link to an existing repository file is rewritten to GitHub. **1b. Surface blast radius — MCP↔CLI parity and the other mirrors** (read-only; MANDATORY whenever the change touches a CLI command, option, flag help text, exit code, or user-facing error string) diff --git a/skills/doc-review/SKILL.md b/skills/doc-review/SKILL.md index d58a0ccc9..5d3a966ef 100644 --- a/skills/doc-review/SKILL.md +++ b/skills/doc-review/SKILL.md @@ -126,7 +126,7 @@ $env:PYTHONUTF8=1 uv run python scripts/ci/generate_website_docs.py --check ``` -Expected: `website/docs mirror in sync (N files), nav complete.` +Expected: `website/docs mirror in sync (N files), nav complete, relative links resolved.` - Any `DRIFT:` line is a **FAIL** — a canonical doc changed and the mirror was not regenerated. Fix it: @@ -140,6 +140,10 @@ Expected: `website/docs mirror in sync (N files), nav complete.` whoever guesses the URL. Mirroring a doc and wiring it into the nav are two separate acts; add the entry under the right nav section and re-run. +- Any `UNRESOLVED-LINK: :: ` line is a **FAIL** — a published + page links to a relative path that resolves to no published file, so it 404s on + the site. Fix the link in the canonical doc, regenerate, and re-run. + **3. New canonical doc → decide explicitly whether it is published.** Not every doc belongs on the site (release evidence, recon specs, and plans generally do not). If it should be published: create the file under `website/docs/`, add its diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index 5681a1820..f7e05fd07 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -262,7 +262,7 @@ def test_reference_definitions_and_markdown_escaped_destinations( assert unresolved == ["UNRESOLVED-LINK: website/docs/SYNTHETIC.md:3: missing.md"] -def test_nested_parens_indented_code_block_boundaries_and_char_refs( +def test_nested_parens_code_span_boundaries_and_char_refs( tmp_path: Path, monkeypatch: pytest.MonkeyPatch ) -> None: docs = tmp_path / "docs" @@ -270,7 +270,7 @@ def test_nested_parens_indented_code_block_boundaries_and_char_refs( docs.mkdir(parents=True) web.mkdir(parents=True) (tmp_path / "PLAN.md").touch() - (docs / "plan(v1(draft)).md").touch() + (docs / "plan(v1).md").touch() (docs / "café.md").touch() (web / "café.md").touch() monkeypatch.setattr(_gen, "_REPO", tmp_path) @@ -278,155 +278,22 @@ def test_nested_parens_indented_code_block_boundaries_and_char_refs( monkeypatch.setattr(_gen, "_WEB", web) source = ( - " [IndentedCode](missing.md)\n\n" "- `open\n" "- [Plan](../PLAN.md) close`\n\n" - "[Nested](plan(v1(draft)).md) and [Entity](café.md#a--b)\n" + "[Nested](plan(v1).md) and [Entity](café.md#a--b)\n" ) rendered = _gen.render("SYNTHETIC.md", source) - assert " [IndentedCode](missing.md)" in rendered assert "](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md)" in rendered assert ( - "[Nested](https://github.com/ffroliva/gflow-cli/blob/develop/docs/plan%28v1%28draft%29%29.md)" + "[Nested](https://github.com/ffroliva/gflow-cli/blob/develop/docs/plan%28v1%29.md)" in rendered ) assert "[Entity](caf%C3%A9.md#a-b)" in rendered - (web / "SYNTHETIC.md").write_text( - " [IndentedCode](missing.md)\n[Entity](café.md#a-b)\n", - encoding="utf-8", - ) + (web / "SYNTHETIC.md").write_text("[Entity](café.md#a-b)\n", encoding="utf-8") assert list(_gen._unresolved_relative_links()) == [] -def test_list_item_continuation_paragraph_links_are_rewritten_and_checked( - tmp_path: Path, monkeypatch: pytest.MonkeyPatch -) -> None: - docs = tmp_path / "docs" - web = tmp_path / "website" / "docs" - docs.mkdir(parents=True) - web.mkdir(parents=True) - (tmp_path / "PLAN.md").touch() - monkeypatch.setattr(_gen, "_REPO", tmp_path) - monkeypatch.setattr(_gen, "_DOCS", docs) - monkeypatch.setattr(_gen, "_WEB", web) - - ordered = "1. Item\n\n [Plan](../PLAN.md)\n" - assert [t for _, _, t in _gen._relative_links(ordered)] == ["../PLAN.md"] - assert _gen.render("SYNTHETIC.md", ordered) == ( - "1. Item\n\n [Plan](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md)\n" - ) - - bullet = "- Item\n\n [Plan](../PLAN.md)\n" - assert [t for _, _, t in _gen._relative_links(bullet)] == ["../PLAN.md"] - - indented_in_list = "1. Item\n\n [Code](missing.md)\n" - assert list(_gen._relative_links(indented_in_list)) == [] - - after_list_ends = "1. Item\n\nParagraph\n\n [Code](missing.md)\n" - assert list(_gen._relative_links(after_list_ends)) == [] - - (web / "SYNTHETIC.md").write_text("1. Item\n\n [Bad](missing.md)\n", encoding="utf-8") - assert list(_gen._unresolved_relative_links()) == [ - "UNRESOLVED-LINK: website/docs/SYNTHETIC.md:3: missing.md" - ] - - -def test_fenced_code_block_after_indented_code_block_is_masked( - tmp_path: Path, monkeypatch: pytest.MonkeyPatch -) -> None: - docs = tmp_path / "docs" - web = tmp_path / "website" / "docs" - docs.mkdir(parents=True) - web.mkdir(parents=True) - (tmp_path / "PLAN.md").touch() - monkeypatch.setattr(_gen, "_REPO", tmp_path) - monkeypatch.setattr(_gen, "_DOCS", docs) - monkeypatch.setattr(_gen, "_WEB", web) - - only_fence = " example\n\n```\n[Example](missing.md)\n```\n" - assert list(_gen._relative_links(only_fence)) == [] - (web / "SYNTHETIC.md").write_text(only_fence, encoding="utf-8") - assert list(_gen._unresolved_relative_links()) == [] - - with_after = f"{only_fence}[After](../PLAN.md)\n" - assert [t for _, _, t in _gen._relative_links(with_after)] == ["../PLAN.md"] - assert _gen.render("SYNTHETIC.md", with_after) == ( - f"{only_fence}[After](https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md)\n" - ) - - no_blank = " example\n```\n[Example](missing.md)\n```\n[After](../PLAN.md)\n" - assert [t for _, _, t in _gen._relative_links(no_blank)] == ["../PLAN.md"] - - indented_ticks = " ```\n [Example](missing.md)\n\n[After](../PLAN.md)\n" - assert [t for _, _, t in _gen._relative_links(indented_ticks)] == ["../PLAN.md"] - - inside_list = ( - "1. Item\n\n ```\n [Example](missing.md)\n ```\n\n [Plan](../PLAN.md)\n" - ) - assert [t for _, _, t in _gen._relative_links(inside_list)] == ["../PLAN.md"] - - -@pytest.mark.parametrize( - ("source", "expected"), - [ - ("Paragraph\n2. item\n\n [Example](missing.md)\n", []), - ("Paragraph\n1. item\n\n [Plan](../PLAN.md)\n", ["../PLAN.md"]), - ( - "1. Item\n\n ~~~\n example\n\n[Issues](../KNOWN_ISSUES.md)\n", - ["../KNOWN_ISSUES.md"], - ), - ( - "> ~~~\n> [Example](missing.md)\n\n[Issues](../KNOWN_ISSUES.md)\n", - ["../KNOWN_ISSUES.md"], - ), - ("```\n[Example](missing.md)\n\n[AlsoInside](missing.md)\n", []), - ( - "- ~~~\n [Example](missing.md)\n ~~~\n\n[Issues](../KNOWN_ISSUES.md)\n", - ["../KNOWN_ISSUES.md"], - ), - ( - "- - ~~~\n [Example](missing.md)\n ~~~\n\n[Issues](../KNOWN_ISSUES.md)\n", - ["../KNOWN_ISSUES.md"], - ), - ( - "1. Item\n2. ~~~\n [Example](missing.md)\n ~~~\n\n[Out](../PLAN.md)\n", - ["../PLAN.md"], - ), - ( - "> - ~~~\n> [Example](missing.md)\n> ~~~\n>\n> [Issues](../KNOWN_ISSUES.md)\n", - ["../KNOWN_ISSUES.md"], - ), - ( - "- [Code](missing.md)\n [Code2](missing.md)\n\n [Plan](../PLAN.md)\n", - ["../PLAN.md"], - ), - ("-\n\n [Code](missing.md)\n", []), - ("-\n [Plan](../PLAN.md)\n\n [Plan2](../PLAN.md)\n", ["../PLAN.md", "../PLAN.md"]), - ("-\tItem\n\n\t[Plan](../PLAN.md)\n", ["../PLAN.md"]), - ("-\tItem\n\n\t\t[Code](missing.md)\n", []), - ("# Heading\n [Code](missing.md)\n", []), - ("---\n [Code](missing.md)\n", []), - ("Heading\n===\n [Code](missing.md)\n", []), - ("> [Code](missing.md)\n", []), - ("> quote\n> [Plan](../PLAN.md)\n", ["../PLAN.md"]), - ("\n[Real](../PLAN.md)\n", ["../PLAN.md"]), - ("
\n[Raw](missing.md)\n
\n\n[Real](../PLAN.md)\n", ["../PLAN.md"]), - ("
\n\n[Real](../PLAN.md)\n\n
\n", ["../PLAN.md"]), - ('x [Real](../PLAN.md)\n', ["../PLAN.md"]), - ("[![alt](img.png)](../PLAN.md)\n", ["img.png", "../PLAN.md"]), - ("![alt [inner](../PLAN.md)](img.png)\n", ["../PLAN.md", "img.png"]), - ("[outer [inner](../PLAN.md)](missing.md)\n", ["../PLAN.md"]), - (r"\![alt](../PLAN.md)" + "\n", ["../PLAN.md"]), - ("- Item\n\n [p]: ../PLAN.md\n\n [Plan][p]\n", ["../PLAN.md"]), - ("> [p]: ../PLAN.md\n>\n> [Plan][p]\n", ["../PLAN.md"]), - ("Paragraph\n[p]: missing.md\n", []), - ], -) -def test_commonmark_container_fence_and_inline_edge_cases(source: str, expected: list[str]) -> None: - assert [t for _, _, t in _gen._relative_links(source)] == expected - - def test_link_destination_edge_cases_are_rewritten_and_checked( tmp_path: Path, monkeypatch: pytest.MonkeyPatch ) -> None: From 1f0720aa5400a2e295fc0e53d1601f76410f8673 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 12:29:33 +0000 Subject: [PATCH 08/28] fix(docs): keep code spans on one line in the website link scanner (#1755) A stray backtick in a table row or around a heading opened a code span that ran to the next backtick and hid every link in between. Code spans now end at the line, and are masked before HTML comments so a backticked comment opener does not open one. The docstring names the two shapes still missed. Tests cover these shapes and the repository containment guard. --- scripts/ci/generate_website_docs.py | 19 ++++++------ tests/scripts/test_generate_website_docs.py | 33 +++++++++++++++++++++ 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index 1da965666..400c45309 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -122,12 +122,9 @@ def _unescape_md(value: str) -> str: _FENCE = re.compile(r"^[ \t>]*(`{3,}|~{3,})") -# A code span: not opened by an escaped backtick, and ended by a blank line or a new list item. -_CODE_SPAN = re.compile( - r"(?]*(?:\n|[-*+][ \t]|\d{1,9}[.)][ \t]))|`(?!\1))*?" - r"(?", re.DOTALL) _INLINE = re.compile( r"\]\([ \t]*(?:<([^<>\n]*)>|((?:[^\s()\\]|\\.|\([^\s()]*\))+))" @@ -144,9 +141,10 @@ def _blank(m: re.Match[str]) -> str: def _mask(text: str) -> str: """Blank fenced code, HTML comments and code spans in place, so offsets still index ``text``. - shortcut: matches what the docs use, not full Markdown. Indented code and admonition bodies are - scanned as prose, so a link-shaped example there is rewritten or fails ``--check`` loudly; - upgrade to a real parser only when a page needs that. + shortcut: matches what the docs use, not full Markdown. Indented code, admonition bodies and + multi-line code spans are scanned as prose, so a link-shaped example there is rewritten or fails + ``--check`` loudly. Missed without a warning: a link whose ``](`` and destination sit on two + lines, and a fence opened inside an HTML comment. Upgrade only when a page needs one of these. """ out: list[str] = [] fence = "" @@ -166,7 +164,8 @@ def _mask(text: str) -> str: out.append(line) continue out.append(re.sub(r"[^\n]", " ", line)) - return _CODE_SPAN.sub(_blank, _COMMENT.sub(_blank, "".join(out))) + # Code spans first, so a backticked ``\n", ["FOO.md"]), + ("\n[L](FOO.md)\n", ["FOO.md"]), + ("> [r]: FOO.md\n", ["FOO.md"]), + ("[Abs](/site/page.md) [L](FOO.md)\n", ["FOO.md"]), + ], +) +def test_masking_keeps_links_outside_code_and_comments(source: str, expected: list[str]) -> None: + assert [t for _, _, t in _gen._relative_links(source)] == expected + + +def test_a_link_outside_the_repository_is_left_as_written( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + repo = tmp_path / "repo" + docs = repo / "docs" + web = repo / "website" / "docs" + docs.mkdir(parents=True) + web.mkdir(parents=True) + (tmp_path / "outside.md").touch() + monkeypatch.setattr(_gen, "_REPO", repo) + monkeypatch.setattr(_gen, "_DOCS", docs) + monkeypatch.setattr(_gen, "_WEB", web) + + assert _gen.render("SYNTHETIC.md", "[O](../../outside.md)\n") == "[O](../../outside.md)\n" From 2eaeaf7b145a8a2dc76e736d25121972eeb4ea18 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 12:35:44 +0000 Subject: [PATCH 09/28] fix(docs): case-exact link lookups and raw image links in the website mirror (#1755) - A link whose spelling differs from the file only in case now names no file on every platform. Windows matched it case-insensitively, so a regeneration there produced output that Linux CI reported as drift. - A link to an unmirrored PNG, JPEG, GIF or WebP file points at GitHub's raw file, which an image can display; a blob URL is an HTML page. - The module docstring states how links are rewritten and checked. - Tests pin the fence open/close rules and the site-only page branch, which no test covered before. --- scripts/ci/generate_website_docs.py | 30 +++++++++-- tests/scripts/test_generate_website_docs.py | 56 +++++++++++++++++++++ 2 files changed, 82 insertions(+), 4 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index 400c45309..c61bdb9a7 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -11,6 +11,11 @@ ``check_website_docs_pii.py``: this produces clean output, that proves it clean. Keep the two in sync. +Relative links are resolved against the canonical file: a link to a published page becomes +a site-relative path, and a link to any other repository file or directory becomes an absolute +GitHub URL on ``develop``, the default branch. ``--check`` reports, as ``UNRESOLVED-LINK``, any +published page that still holds a relative link resolving to no published file. + Usage: python scripts/ci/generate_website_docs.py # write the mirror python scripts/ci/generate_website_docs.py --check # CI: check drift, orphans, links @@ -19,6 +24,7 @@ from __future__ import annotations import html +import os import posixpath import re import sys @@ -132,6 +138,8 @@ def _unescape_md(value: str) -> str: ) _REF_DEF = re.compile(r"^[ \t>]*\[[^\]\n]+\]:[ \t]*(?:<([^<>\n]*)>|(\S+))", re.MULTILINE) _SCHEME = re.compile(r"[A-Za-z][A-Za-z0-9+.-]*:") +# Served with an image type from raw/; SVG is left out because GitHub serves it as plain text. +_RAW_IMAGES = frozenset({".png", ".jpg", ".jpeg", ".gif", ".webp"}) def _blank(m: re.Match[str]) -> str: @@ -186,25 +194,39 @@ def _site_files() -> set[str]: return {p.relative_to(_WEB).as_posix() for p in _WEB.rglob("*") if p.is_file()} +def _existing(path: Path) -> Path | None: + """The resolved path if it exists as spelled. Windows matches names case-insensitively, but the + published site and Linux CI do not, so a spelling that differs only in case names no file.""" + resolved = path.resolve() + spelled = os.path.normpath(path) + if not resolved.exists() or ( + str(resolved) != spelled and str(resolved).lower() == spelled.lower() + ): + return None + return resolved + + def _site_link(target: str, source_dir: Path, dest_dir: Path, published: dict[Path, Path]) -> str: decoded = _unescape_md(target) # Before splitting: `/` holds a '#' that is not a fragment. url = urlsplit(decoded) site_path = url.path if site_path: decoded_path = unquote(site_path) - canonical = (source_dir / decoded_path).resolve() - destination = published.get(canonical) + canonical = _existing(source_dir / decoded_path) + destination = published.get(canonical) if canonical else None if destination is not None: site_path = quote(posixpath.relpath(destination.as_posix(), dest_dir.as_posix())) - elif canonical.exists(): + elif canonical is not None: if not canonical.is_relative_to(_REPO): return target kind = "tree" if canonical.is_dir() else "blob" + if canonical.suffix.lower() in _RAW_IMAGES: + kind = "raw" # A blob URL is a GitHub page, which an image link cannot display. path = quote(canonical.relative_to(_REPO).as_posix()) suffix = decoded.removeprefix(url.path) # Keep GitHub's query and fragment verbatim. # develop: the default branch, which the site deploys from and this script checks. return f"{_GITHUB_REPO}/{kind}/develop/{path}{suffix}" - elif (dest_dir / decoded_path).resolve() not in published: + elif _existing(dest_dir / decoded_path) not in published: return target # Leave the unresolved destination intact for --check. return url._replace(path=site_path, fragment=re.sub("-{2,}", "-", url.fragment)).geturl() diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index 91f535ced..bc3d75d7a 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -358,3 +358,59 @@ def test_a_link_outside_the_repository_is_left_as_written( monkeypatch.setattr(_gen, "_WEB", web) assert _gen.render("SYNTHETIC.md", "[O](../../outside.md)\n") == "[O](../../outside.md)\n" + + +@pytest.mark.parametrize( + ("source", "expected"), + [ + # A backtick fence whose info string holds a backtick is a code span line, not a fence. + ("``` `x` [L](FOO.md)\n[M](BAR.md)\n", ["FOO.md", "BAR.md"]), + # A fence line with an info string does not close an open fence. + ("```\n```py\n[X](missing.md)\n```\n[L](FOO.md)\n", ["FOO.md"]), + ], +) +def test_fence_opening_and_closing_rules(source: str, expected: list[str]) -> None: + assert [t for _, _, t in _gen._relative_links(source)] == expected + + +def _site(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> tuple[Path, Path]: + docs = tmp_path / "docs" + web = tmp_path / "website" / "docs" + docs.mkdir(parents=True) + web.mkdir(parents=True) + monkeypatch.setattr(_gen, "_REPO", tmp_path) + monkeypatch.setattr(_gen, "_DOCS", docs) + monkeypatch.setattr(_gen, "_WEB", web) + return docs, web + + +def test_a_link_to_a_site_only_page_keeps_its_path_and_takes_the_slug( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + _, web = _site(tmp_path, monkeypatch) + (web / "agents.md").touch() # bespoke page, no canonical source + assert _gen.render("USAGE.md", "[A](agents.md#x--y)\n") == "[A](agents.md#x-y)\n" + + +def test_file_lookups_are_case_exact_on_every_platform( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + docs, web = _site(tmp_path, monkeypatch) + (docs / "USAGE.md").touch() + (web / "USAGE.md").touch() + (tmp_path / "PLAN.md").touch() + # A case mismatch names no file on a case-sensitive host, so it is left for --check. + assert _gen.render("GUIDE.md", "[u](usage.md) [p](../plan.md)\n") == ( + "[u](usage.md) [p](../plan.md)\n" + ) + + +def test_an_unmirrored_image_links_to_the_raw_file( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + docs, _ = _site(tmp_path, monkeypatch) + (docs / "assets").mkdir() + (docs / "assets" / "shot.png").touch() + assert _gen.render("GUIDE.md", "![s](assets/shot.png)\n") == ( + "![s](https://github.com/ffroliva/gflow-cli/raw/develop/docs/assets/shot.png)\n" + ) From 73de32d616224a919ad1ae0a34b37fd3f1ba7b97 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 12:49:28 +0000 Subject: [PATCH 10/28] test(docs): pin link-scanner edge cases and drop a redundant lookup rule (#1755) - File lookups accept only the exact spelling of the resolved path, so a Windows 8.3 short name or a trailing dot names no file, as a case mismatch already did. - Masking blanks newlines inside comments too: text after a comment that opened mid-line no longer starts a reference definition. - Tests cover upper-case image suffixes, a tilde line inside a backtick fence, document-order rewriting with reference definitions, line numbers after a multi-line comment, and percent-encoded targets in --check. --- scripts/ci/generate_website_docs.py | 14 ++++---- tests/scripts/test_generate_website_docs.py | 40 ++++++++++++++++++--- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index c61bdb9a7..02de9eda6 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -143,7 +143,8 @@ def _unescape_md(value: str) -> str: def _blank(m: re.Match[str]) -> str: - return re.sub(r"[^\n]", " ", m[0]) + # Newlines go too: a comment opened mid-line does not start a new line where it closes. + return " " * len(m[0]) def _mask(text: str) -> str: @@ -195,13 +196,12 @@ def _site_files() -> set[str]: def _existing(path: Path) -> Path | None: - """The resolved path if it exists as spelled. Windows matches names case-insensitively, but the - published site and Linux CI do not, so a spelling that differs only in case names no file.""" + """The resolved path if it exists exactly as spelled. Windows also matches another case, an 8.3 + short name or a trailing dot, which the published site and Linux CI do not, so those name no + file. ``_REPO`` is resolved and the repository tracks no symlinks, so a real file compares + equal.""" resolved = path.resolve() - spelled = os.path.normpath(path) - if not resolved.exists() or ( - str(resolved) != spelled and str(resolved).lower() == spelled.lower() - ): + if not resolved.exists() or str(resolved) != os.path.normpath(path): return None return resolved diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index bc3d75d7a..6dced37f8 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -336,6 +336,8 @@ def test_link_destination_edge_cases_are_rewritten_and_checked( # A backticked comment opener does not open a comment. ("``\n", ["FOO.md"]), ("\n[L](FOO.md)\n", ["FOO.md"]), + # Text after a comment that closes mid-line is not a reference definition. + ("Text [r]: missing.md\n[s]: FOO.md\n", ["FOO.md"]), ("> [r]: FOO.md\n", ["FOO.md"]), ("[Abs](/site/page.md) [L](FOO.md)\n", ["FOO.md"]), ], @@ -367,6 +369,8 @@ def test_a_link_outside_the_repository_is_left_as_written( ("``` `x` [L](FOO.md)\n[M](BAR.md)\n", ["FOO.md", "BAR.md"]), # A fence line with an info string does not close an open fence. ("```\n```py\n[X](missing.md)\n```\n[L](FOO.md)\n", ["FOO.md"]), + # A tilde fence does not close a backtick fence. + ("```\n~~~\n[X](missing.md)\n```\n[L](FOO.md)\n", ["FOO.md"]), ], ) def test_fence_opening_and_closing_rules(source: str, expected: list[str]) -> None: @@ -399,9 +403,9 @@ def test_file_lookups_are_case_exact_on_every_platform( (docs / "USAGE.md").touch() (web / "USAGE.md").touch() (tmp_path / "PLAN.md").touch() - # A case mismatch names no file on a case-sensitive host, so it is left for --check. - assert _gen.render("GUIDE.md", "[u](usage.md) [p](../plan.md)\n") == ( - "[u](usage.md) [p](../plan.md)\n" + # A case mismatch or a trailing dot names no file on a case-sensitive host: left for --check. + assert _gen.render("GUIDE.md", "[u](usage.md) [p](../plan.md) [d](../PLAN.md.)\n") == ( + "[u](usage.md) [p](../plan.md) [d](../PLAN.md.)\n" ) @@ -411,6 +415,32 @@ def test_an_unmirrored_image_links_to_the_raw_file( docs, _ = _site(tmp_path, monkeypatch) (docs / "assets").mkdir() (docs / "assets" / "shot.png").touch() - assert _gen.render("GUIDE.md", "![s](assets/shot.png)\n") == ( - "![s](https://github.com/ffroliva/gflow-cli/raw/develop/docs/assets/shot.png)\n" + (docs / "assets" / "LOGO.PNG").touch() + raw = "https://github.com/ffroliva/gflow-cli/raw/develop/docs/assets" + assert _gen.render("GUIDE.md", "![s](assets/shot.png) ![l](assets/LOGO.PNG)\n") == ( + f"![s]({raw}/shot.png) ![l]({raw}/LOGO.PNG)\n" ) + + +def test_links_are_rewritten_in_document_order( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + _site(tmp_path, monkeypatch) + (tmp_path / "PLAN.md").touch() + plan = "https://github.com/ffroliva/gflow-cli/blob/develop/PLAN.md" + # A reference definition is found by a second pattern but must still land in place. + source = "[p]: ../PLAN.md\n\n[Plan](../PLAN.md#s)\n" + assert _gen.render("GUIDE.md", source) == f"[p]: {plan}\n\n[Plan]({plan}#s)\n" + + +def test_check_line_numbers_and_percent_encoded_targets( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + _, web = _site(tmp_path, monkeypatch) + (web / "MY PAGE.md").touch() + (web / "GUIDE.md").write_text( + "\n[ok](MY%20PAGE.md)\n[bad](missing.md)\n", encoding="utf-8" + ) + assert list(_gen._unresolved_relative_links()) == [ + "UNRESOLVED-LINK: website/docs/GUIDE.md:5: missing.md" + ] From 9d4789c79391d638309252cd6ae8122ae588ff7c Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 13:16:30 +0000 Subject: [PATCH 11/28] fix(docs): close four link-scanner gaps found in review (#1755) - An unclosed fence no longer masks the rest of the page, since the site renders it as text; a fence opener inside an HTML comment no longer hides the links after the comment. - Destinations keep two levels of balanced parentheses. - A link-shaped title on a reference-definition line is not scanned as a second link. - Scheme and leading-slash tests run on the decoded destination, so an entity-encoded malformed URL no longer aborts generation. - The check and doc-review skills say where to fix a site-only page. --- scripts/ci/generate_website_docs.py | 45 +++++++++++++-------- skills/check/SKILL.md | 4 +- skills/doc-review/SKILL.md | 4 +- tests/scripts/test_generate_website_docs.py | 17 +++++++- 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index 02de9eda6..6e0c79f8c 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -133,7 +133,7 @@ def _unescape_md(value: str) -> str: _CODE_SPAN = re.compile(r"(?", re.DOTALL) _INLINE = re.compile( - r"\]\([ \t]*(?:<([^<>\n]*)>|((?:[^\s()\\]|\\.|\([^\s()]*\))+))" + r"\]\([ \t]*(?:<([^<>\n]*)>|((?:[^\s()\\]|\\.|\((?:[^\s()]|\([^\s()]*\))*\))+))" r"(?:\s+(?:\"[^\"\n]*\"|'[^'\n]*'))?[ \t]*\)" ) _REF_DEF = re.compile(r"^[ \t>]*\[[^\]\n]+\]:[ \t]*(?:<([^<>\n]*)>|(\S+))", re.MULTILINE) @@ -150,14 +150,21 @@ def _blank(m: re.Match[str]) -> str: def _mask(text: str) -> str: """Blank fenced code, HTML comments and code spans in place, so offsets still index ``text``. - shortcut: matches what the docs use, not full Markdown. Indented code, admonition bodies and - multi-line code spans are scanned as prose, so a link-shaped example there is rewritten or fails - ``--check`` loudly. Missed without a warning: a link whose ``](`` and destination sit on two - lines, and a fence opened inside an HTML comment. Upgrade only when a page needs one of these. + shortcut: matches what the docs use, not full Markdown. Indented code, admonition bodies, + multi-line code spans and a ``](`` in prose with no link text are scanned as links, so a + link-shaped example there is rewritten or fails ``--check`` loudly. Missed without a warning: a + link whose ``](`` and destination sit on two lines, parentheses nested three deep, and a fence + opened inside an HTML comment and closed after it. Upgrade only when a page needs one of these. """ + # Code spans first, so a backticked ` [r]: missing.md\n[s]: FOO.md\n", ["FOO.md"]), ("> [r]: FOO.md\n", ["FOO.md"]), ("[Abs](/site/page.md) [L](FOO.md)\n", ["FOO.md"]), + ("[Enc](/site/page.md) [L](FOO.md)\n", ["FOO.md"]), + # Two levels of balanced parentheses stay in the destination. + ("[L](a(b(c)).md)\n", ["a(b(c)).md"]), + # A link-shaped title of a reference definition is not a second link. + ('[g]: FOO.md "See [d](missing.md)"\n', ["FOO.md"]), ], ) def test_masking_keeps_links_outside_code_and_comments(source: str, expected: list[str]) -> None: @@ -371,6 +380,10 @@ def test_a_link_outside_the_repository_is_left_as_written( ("```\n```py\n[X](missing.md)\n```\n[L](FOO.md)\n", ["FOO.md"]), # A tilde fence does not close a backtick fence. ("```\n~~~\n[X](missing.md)\n```\n[L](FOO.md)\n", ["FOO.md"]), + # The renderer shows an unclosed fence as text, so it masks nothing. + ("```\n[L](FOO.md)\n", ["FOO.md"]), + ("\n[L](FOO.md)\n", ["FOO.md"]), + ("```\n~~~\n[X](missing.md)\n~~~\n[L](FOO.md)\n", ["FOO.md"]), ], ) def test_fence_opening_and_closing_rules(source: str, expected: list[str]) -> None: From 5421ccf0b8ec22734aac6f5605423915ee65b3f1 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 13:28:04 +0000 Subject: [PATCH 12/28] fix(docs): match only whole reference definitions and bound fence scanning (#1755) - A reference definition ends at its optional title and the end of the line. Text after the destination makes the line prose, as in Python-Markdown, so an inline link on it is scanned and checked. - An unclosed fence is found in one backward pass over the closing lines, not by rescanning, so many unclosed fences cost linear time and cannot exhaust the stack. - A destination that urlsplit rejects is left as written, so an entity-encoded space or control character cannot abort generation. - Tests cover these cases, an entity-encoded mailto scheme, and the fence shapes that pin the unclosed-fence rule. --- scripts/ci/generate_website_docs.py | 39 ++++++++++++++++----- tests/scripts/test_generate_website_docs.py | 11 ++++++ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index 6e0c79f8c..617cf34b4 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -136,7 +136,12 @@ def _unescape_md(value: str) -> str: r"\]\([ \t]*(?:<([^<>\n]*)>|((?:[^\s()\\]|\\.|\((?:[^\s()]|\([^\s()]*\))*\))+))" r"(?:\s+(?:\"[^\"\n]*\"|'[^'\n]*'))?[ \t]*\)" ) -_REF_DEF = re.compile(r"^[ \t>]*\[[^\]\n]+\]:[ \t]*(?:<([^<>\n]*)>|(\S+))", re.MULTILINE) +# A definition ends at its optional title; text after the destination makes the line prose. +_REF_DEF = re.compile( + r"^[ \t>]*\[[^\]\n]+\]:[ \t]*(?:<([^<>\n]*)>|(\S+))" + r"(?:[ \t]+(?:\"[^\"\n]*\"|'[^'\n]*'|\([^()\n]*\)))?[ \t]*$", + re.MULTILINE, +) _SCHEME = re.compile(r"[A-Za-z][A-Za-z0-9+.-]*:") # Served with an image type from raw/; SVG is left out because GitHub serves it as plain text. _RAW_IMAGES = frozenset({".png", ".jpg", ".jpeg", ".gif", ".webp"}) @@ -161,9 +166,20 @@ def _mask(text: str) -> str: def _mask_fences(lines: list[str]) -> str: + # The renderer shows a fence that never closes as text, so an opener masks only when a closing + # line follows: closers[i] is the longest bare ``` and ~~~ line after line i. + closers = [(0, 0)] * (len(lines) + 1) + for i in range(len(lines) - 1, -1, -1): + m = _FENCE.match(lines[i]) + ticks, tildes = closers[i + 1] + if m and not lines[i][m.end() :].strip(): + if m[1][0] == "`": + ticks = max(ticks, len(m[1])) + else: + tildes = max(tildes, len(m[1])) + closers[i] = (ticks, tildes) out: list[str] = [] fence = "" - opened = 0 for i, line in enumerate(lines): m = _FENCE.match(line) if fence: @@ -174,14 +190,16 @@ def _mask_fences(lines: list[str]) -> str: and not line[m.end() :].strip() ): fence = "" - elif m and not (m[1][0] == "`" and "`" in line[m.end() :]): - fence, opened = m[1], i + elif ( + m + and not (m[1][0] == "`" and "`" in line[m.end() :]) + and closers[i + 1]["`~".index(m[1][0])] >= len(m[1]) + ): + fence = m[1] else: out.append(line) continue out.append(re.sub(r"[^\n]", " ", line)) - if fence: # The renderer shows an unclosed fence as text: scan on from its next line. - return "".join(out[:opened]) + lines[opened] + _mask_fences(lines[opened + 1 :]) return "".join(out) @@ -198,8 +216,13 @@ def _relative_links(text: str) -> Iterator[tuple[int, int, str]]: s, e = m.span(g) t = text[s:e] decoded = _unescape_md(t) # `:` and `/` hide a scheme or a leading '/'. - if t and not decoded.startswith("/") and not _SCHEME.match(decoded): - hits.append((s, e, t)) + if not t or decoded.startswith("/") or _SCHEME.match(decoded): + continue + try: + urlsplit(decoded) + except ValueError: # Not a usable URL: leave it as written. + continue + hits.append((s, e, t)) yield from sorted(hits) diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index 0bb2c1736..33f2c3d5b 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -318,6 +318,7 @@ def test_link_destination_edge_cases_are_rewritten_and_checked( for bad_url in ( "[Draft](https://[example) then [Plan](../PLAN.md)\n", "[Draft](https://[example) then [Plan](../PLAN.md)\n", + "[Draft]( //[example) then [Plan](../PLAN.md)\n", ): assert [t for _, _, t in _gen._relative_links(bad_url)] == ["../PLAN.md"] assert f"[Plan]({gh}/blob/develop/PLAN.md)" in _gen.render("SYNTHETIC.md", bad_url) @@ -345,10 +346,14 @@ def test_link_destination_edge_cases_are_rewritten_and_checked( ("> [r]: FOO.md\n", ["FOO.md"]), ("[Abs](/site/page.md) [L](FOO.md)\n", ["FOO.md"]), ("[Enc](/site/page.md) [L](FOO.md)\n", ["FOO.md"]), + ("[M](mailto:a@example.com) [L](FOO.md)\n", ["FOO.md"]), # Two levels of balanced parentheses stay in the destination. ("[L](a(b(c)).md)\n", ["a(b(c)).md"]), # A link-shaped title of a reference definition is not a second link. ('[g]: FOO.md "See [d](missing.md)"\n', ["FOO.md"]), + # Text after the destination makes the line prose, so its inline link is scanned. + ("Text\n[g]: FOO.md [d](bar.md)\n", ["bar.md"]), + ("[r]: FOO.md and [Broken](missing.md)\n", ["missing.md"]), ], ) def test_masking_keeps_links_outside_code_and_comments(source: str, expected: list[str]) -> None: @@ -384,12 +389,18 @@ def test_a_link_outside_the_repository_is_left_as_written( ("```\n[L](FOO.md)\n", ["FOO.md"]), ("\n[L](FOO.md)\n", ["FOO.md"]), ("```\n~~~\n[X](missing.md)\n~~~\n[L](FOO.md)\n", ["FOO.md"]), + ("```\n[X](missing.md)\n```\n```\n[L](FOO.md)\n", ["FOO.md"]), + ("```[L](FOO.md)\n", ["FOO.md"]), ], ) def test_fence_opening_and_closing_rules(source: str, expected: list[str]) -> None: assert [t for _, _, t in _gen._relative_links(source)] == expected +def test_many_unclosed_fences_do_not_exhaust_the_stack() -> None: + assert list(_gen._relative_links("```x\n" * 3000 + "[L](FOO.md)\n"))[0][2] == "FOO.md" + + def _site(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> tuple[Path, Path]: docs = tmp_path / "docs" web = tmp_path / "website" / "docs" From 3fb5bf833f2930122096ac7bc23a4d18d1b698ff Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 13:30:14 +0000 Subject: [PATCH 13/28] docs(docs): record that a fence closed after a comment is rendered as code (#1755) With the site's pymdownx.superfences, a fence opened inside an HTML comment and closed after it renders as a code block, so masking the lines between matches the site. The docstring no longer lists it as a limit, and a test pins it. --- scripts/ci/generate_website_docs.py | 5 +++-- tests/scripts/test_generate_website_docs.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index 617cf34b4..ec0a90918 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -158,8 +158,9 @@ def _mask(text: str) -> str: shortcut: matches what the docs use, not full Markdown. Indented code, admonition bodies, multi-line code spans and a ``](`` in prose with no link text are scanned as links, so a link-shaped example there is rewritten or fails ``--check`` loudly. Missed without a warning: a - link whose ``](`` and destination sit on two lines, parentheses nested three deep, and a fence - opened inside an HTML comment and closed after it. Upgrade only when a page needs one of these. + link whose ``](`` and destination sit on two lines, and parentheses nested three deep. Upgrade + only when a page needs one of these. A fence opened inside an HTML comment and closed after it + is masked on purpose: the site's superfences renders the lines between as a code block. """ # Code spans first, so a backticked `\n[L](FOO.md)\n", ["FOO.md"]), + # Closed after the comment, superfences renders it as code, so the link inside is code. + ("\n[X](missing.md)\n```\n\n[L](FOO.md)\n", ["FOO.md"]), ("```\n~~~\n[X](missing.md)\n~~~\n[L](FOO.md)\n", ["FOO.md"]), ("```\n[X](missing.md)\n```\n```\n[L](FOO.md)\n", ["FOO.md"]), ("```[L](FOO.md)\n", ["FOO.md"]), From d7ae11273e204ca7a1ae09297bf10ce8ac5d44c4 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 13:41:02 +0000 Subject: [PATCH 14/28] fix(docs-site): follow the renderer's fence and reference-title rules A fence closes only on a bare line of the same marker at the same length, and once a fence never closes no later line opens one, as the site's superfences renders it. Reference-definition titles are greedy, as Python-Markdown reads them, so "a "b" c" and (see (x)) are one title. --- scripts/ci/generate_website_docs.py | 54 ++++++++------------- tests/scripts/test_generate_website_docs.py | 18 ++++++- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index ec0a90918..c6e18f726 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -139,7 +139,8 @@ def _unescape_md(value: str) -> str: # A definition ends at its optional title; text after the destination makes the line prose. _REF_DEF = re.compile( r"^[ \t>]*\[[^\]\n]+\]:[ \t]*(?:<([^<>\n]*)>|(\S+))" - r"(?:[ \t]+(?:\"[^\"\n]*\"|'[^'\n]*'|\([^()\n]*\)))?[ \t]*$", + # Titles are greedy, as Python-Markdown reads them: "a "b" c" and (see (x)) are one title. + r"(?:[ \t]+(?:\"[^\n]*\"|'[^\n]*'|\([^\n]*\)))?[ \t]*$", re.MULTILINE, ) _SCHEME = re.compile(r"[A-Za-z][A-Za-z0-9+.-]*:") @@ -167,43 +168,30 @@ def _mask(text: str) -> str: def _mask_fences(lines: list[str]) -> str: - # The renderer shows a fence that never closes as text, so an opener masks only when a closing - # line follows: closers[i] is the longest bare ``` and ~~~ line after line i. - closers = [(0, 0)] * (len(lines) + 1) - for i in range(len(lines) - 1, -1, -1): - m = _FENCE.match(lines[i]) - ticks, tildes = closers[i + 1] - if m and not lines[i][m.end() :].strip(): - if m[1][0] == "`": - ticks = max(ticks, len(m[1])) - else: - tildes = max(tildes, len(m[1])) - closers[i] = (ticks, tildes) + # As the site's superfences measured: a fence closes only on a bare line of the same marker, + # same length; one that never closes renders as text, and no later line opens a fence. out: list[str] = [] - fence = "" - for i, line in enumerate(lines): - m = _FENCE.match(line) - if fence: - if ( - m - and m[1][0] == fence[0] - and len(m[1]) >= len(fence) - and not line[m.end() :].strip() - ): - fence = "" - elif ( - m - and not (m[1][0] == "`" and "`" in line[m.end() :]) - and closers[i + 1]["`~".index(m[1][0])] >= len(m[1]) - ): - fence = m[1] - else: - out.append(line) + i = 0 + while i < len(lines): + m = _FENCE.match(lines[i]) + if not m or (m[1][0] == "`" and "`" in lines[i][m.end() :]): + out.append(lines[i]) + i += 1 continue - out.append(re.sub(r"[^\n]", " ", line)) + end = next((j for j in range(i + 1, len(lines)) if _closes(lines[j], m[1])), None) + if end is None: + out.extend(lines[i:]) + break + out.extend(re.sub(r"[^\n]", " ", line) for line in lines[i : end + 1]) + i = end + 1 return "".join(out) +def _closes(line: str, fence: str) -> bool: + m = _FENCE.match(line) + return bool(m) and m[1] == fence and not line[m.end() :].strip() + + def _relative_links(text: str) -> Iterator[tuple[int, int, str]]: masked = _mask(text) defs = list(_REF_DEF.finditer(masked)) diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index 9f52f0afa..61ec72545 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -170,7 +170,7 @@ def test_link_examples_in_inline_code_and_fences_are_literal() -> None: literal = ( f"`{example}` and ``a ` {example}``\n" f"````md\n```\n{example}\n````\n" - f"> ~~~markdown\n> {example}\n> ~~~~\n" + f"> ~~~markdown\n> {example}\n> ~~~\n" ) assert _gen.render("USAGE.md", literal + "[`real`](#a--b)") == literal + "[`real`](#a-b)" @@ -354,6 +354,12 @@ def test_link_destination_edge_cases_are_rewritten_and_checked( # Text after the destination makes the line prose, so its inline link is scanned. ("Text\n[g]: FOO.md [d](bar.md)\n", ["bar.md"]), ("[r]: FOO.md and [Broken](missing.md)\n", ["missing.md"]), + # Titles are greedy, as the renderer reads them: each line below is one definition. + ("[a]: A.md 'it's'\n", ["A.md"]), + ('[a]: A.md "a "b" c"\n', ["A.md"]), + ("[a]: A.md (see (x))\n", ["A.md"]), + ("[a]: A.md (see [d](B.md))\n", ["A.md"]), + ('[a]: A.md "t" \n', ["A.md"]), ], ) def test_masking_keeps_links_outside_code_and_comments(source: str, expected: list[str]) -> None: @@ -390,9 +396,17 @@ def test_a_link_outside_the_repository_is_left_as_written( ("\n[L](FOO.md)\n", ["FOO.md"]), # Closed after the comment, superfences renders it as code, so the link inside is code. ("\n[X](missing.md)\n```\n\n[L](FOO.md)\n", ["FOO.md"]), - ("```\n~~~\n[X](missing.md)\n~~~\n[L](FOO.md)\n", ["FOO.md"]), ("```\n[X](missing.md)\n```\n```\n[L](FOO.md)\n", ["FOO.md"]), ("```[L](FOO.md)\n", ["FOO.md"]), + # Measured on the site's renderer: a fence closes only on the same marker at the same + # length, and after one that never closes, no later line opens a fence. + ("```\n~~~\n[X](B.md)\n~~~\n[L](A.md)\n", ["B.md", "A.md"]), + ("```\n[X](B.md)\n````\n\n[L](A.md)\n", ["B.md", "A.md"]), + ("~~~~\n[X](B.md)\n~~~~~\n\n[L](A.md)\n", ["B.md", "A.md"]), + ("````\n[X](B.md)\n```\n````\n\n[L](A.md)\n", ["A.md"]), + ("``` `x` [L](A.md)\n\n```\n[M](B.md)\n```\n\n[N](C.md)\n", ["A.md", "C.md"]), + ("```\n[X](B.md)\n```\n\n```\n[Y](C.md)\n\n[L](A.md)\n", ["C.md", "A.md"]), + ("> ```\n> [X](B.md)\n> ```\n\n[L](A.md)\n", ["A.md"]), ], ) def test_fence_opening_and_closing_rules(source: str, expected: list[str]) -> None: From e6d923147683c21f8bbf480bbd047d0c8bdbded2 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 14:04:11 +0000 Subject: [PATCH 15/28] fix(docs-site): treat a fence header superfences rejects as text A fence opens only on a header the site's superfences accepts: an optional language, then an attribute block or its own title, linenums and hl_lines options. A rejected header is text, so a later fence still opens and masks its code. --- scripts/ci/generate_website_docs.py | 8 +++++++- tests/scripts/test_generate_website_docs.py | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index c6e18f726..6e1fd785c 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -128,6 +128,12 @@ def _unescape_md(value: str) -> str: _FENCE = re.compile(r"^[ \t>]*(`{3,}|~{3,})") +# The opener headers superfences accepts, as measured: a language, then {attrs} or its own options. +# A header it rejects is text; one it accepts that this misses is scanned as prose, loudly. +_FENCE_INFO = re.compile( + r"[ \t]*(?:\.?[\w#.+-]+(?=[ \t]|$))?" + r"(?:[ \t]*\{[^\n]*\}|(?:[ \t]+(?:title|linenums|hl_lines)=([\"'])[^\n]*?\1)*)[ \t]*" +) # A code span on one line, not opened by an escaped backtick: a stray backtick in a table row or # a heading must not swallow the lines after it. A multi-line span is scanned as prose (loudly). _CODE_SPAN = re.compile(r"(? str: i = 0 while i < len(lines): m = _FENCE.match(lines[i]) - if not m or (m[1][0] == "`" and "`" in lines[i][m.end() :]): + if not m or not _FENCE_INFO.fullmatch(lines[i][m.end() :].rstrip("\r\n")): out.append(lines[i]) i += 1 continue diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index 61ec72545..a85014e70 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -407,6 +407,15 @@ def test_a_link_outside_the_repository_is_left_as_written( ("``` `x` [L](A.md)\n\n```\n[M](B.md)\n```\n\n[N](C.md)\n", ["A.md", "C.md"]), ("```\n[X](B.md)\n```\n\n```\n[Y](C.md)\n\n[L](A.md)\n", ["C.md", "A.md"]), ("> ```\n> [X](B.md)\n> ```\n\n[L](A.md)\n", ["A.md"]), + # A header superfences rejects is text, so a later fence still opens. + ("``` invalid stuff\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n", ["A.md"]), + ("```py x\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n", ["A.md"]), + ('```py x="1"\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n', ["A.md"]), + ("```py{.x}\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n", ["A.md"]), + # A header it accepts opens a fence that never closes, so the rest renders as text. + ('```py title="a b"\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n', ["B.md", "A.md"]), + ("```{.py}\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n", ["B.md", "A.md"]), + ("```c++ hl_lines='1'\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n", ["B.md", "A.md"]), ], ) def test_fence_opening_and_closing_rules(source: str, expected: list[str]) -> None: From 599ebf2606a4f8a961efa55ffb7e1dad4e2ed6bd Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 14:11:52 +0000 Subject: [PATCH 16/28] fix(docs-site): check fence option values and read inline titles as the renderer does A fence header opens a fence only when every option is one superfences knows with a valid value: hl_lines takes line numbers and ranges, linenums takes numbers, and title takes quoted text without its own quote. Options need no space before them. An inline link title ends at the first closing quote followed by ")", so it may hold quotes. --- scripts/ci/generate_website_docs.py | 15 ++++++++++----- tests/scripts/test_generate_website_docs.py | 11 +++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index 6e1fd785c..659641902 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -128,11 +128,15 @@ def _unescape_md(value: str) -> str: _FENCE = re.compile(r"^[ \t>]*(`{3,}|~{3,})") -# The opener headers superfences accepts, as measured: a language, then {attrs} or its own options. -# A header it rejects is text; one it accepts that this misses is scanned as prose, loudly. +# The opener headers superfences accepts, as measured: a language, then {attrs} or only its own +# options with valid values. A header it rejects is text. A header read differently from the +# renderer shifts how the fences after it pair, so the grammar follows the renderer exactly. _FENCE_INFO = re.compile( - r"[ \t]*(?:\.?[\w#.+-]+(?=[ \t]|$))?" - r"(?:[ \t]*\{[^\n]*\}|(?:[ \t]+(?:title|linenums|hl_lines)=([\"'])[^\n]*?\1)*)[ \t]*" + r"[ \t]*(?:\.?[\w#.+-]+(?=[ \t]|$))?(?:[ \t]*\{[^\n]*\}|(?:[ \t]*(?:" + r"title=(?:\"[^\"\n]*\"|'[^'\n]*')" + r"|hl_lines=([\"'])\d+(?:-\d+)?(?:[ \t]+\d+(?:-\d+)?)*\1" + r"|linenums=([\"'])\d+(?:[ \t]+\d+)*\2" + r"))*)[ \t]*" ) # A code span on one line, not opened by an escaped backtick: a stray backtick in a table row or # a heading must not swallow the lines after it. A multi-line span is scanned as prose (loudly). @@ -140,7 +144,8 @@ def _unescape_md(value: str) -> str: _COMMENT = re.compile(r"", re.DOTALL) _INLINE = re.compile( r"\]\([ \t]*(?:<([^<>\n]*)>|((?:[^\s()\\]|\\.|\((?:[^\s()]|\([^\s()]*\))*\))+))" - r"(?:\s+(?:\"[^\"\n]*\"|'[^'\n]*'))?[ \t]*\)" + # A title ends at the first closing quote followed by ")", so it may hold quotes and ")". + r"(?:\s+(?:\"[^\n]*?\"|'[^\n]*?'))?[ \t]*\)" ) # A definition ends at its optional title; text after the destination makes the line prose. _REF_DEF = re.compile( diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index a85014e70..061218f53 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -360,6 +360,10 @@ def test_link_destination_edge_cases_are_rewritten_and_checked( ("[a]: A.md (see (x))\n", ["A.md"]), ("[a]: A.md (see [d](B.md))\n", ["A.md"]), ('[a]: A.md "t" \n', ["A.md"]), + # An inline title ends at the first quote followed by ")", as the renderer reads it. + ('x [l](A.md "a "b" c") y\n', ["A.md"]), + ('[l](A.md "a) b") [m](B.md)\n', ["A.md", "B.md"]), + ('[l](A.md "t") and [m](B.md "u")\n', ["A.md", "B.md"]), ], ) def test_masking_keeps_links_outside_code_and_comments(source: str, expected: list[str]) -> None: @@ -416,6 +420,13 @@ def test_a_link_outside_the_repository_is_left_as_written( ('```py title="a b"\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n', ["B.md", "A.md"]), ("```{.py}\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n", ["B.md", "A.md"]), ("```c++ hl_lines='1'\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n", ["B.md", "A.md"]), + # Option values are checked too, and options need no space before them. + ('```py hl_lines="abc"\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n', ["A.md"]), + ('```py linenums="abc"\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n', ["A.md"]), + ('```py title="a" b"\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n', ["A.md"]), + ('```py hl_lines="1 2-3"\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n', ["B.md", "A.md"]), + ('```title="x"\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n', ["B.md", "A.md"]), + ('```py title="a"linenums="1"\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n', ["B.md", "A.md"]), ], ) def test_fence_opening_and_closing_rules(source: str, expected: list[str]) -> None: From 491285e316248ff23ba1e8da83bcc2f1bc341135 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 14:19:06 +0000 Subject: [PATCH 17/28] fix(docs-site): pair fences by blockquote depth, as the renderer does A closing fence sits no deeper in a blockquote than its opener, so a quoted ``` inside a plain fence is its content. A fence inside a blockquote closes before the quote ends at a blank line, or renders as text, and later fences still open. The _mask docstring lists inline links with a parenthesized or unterminated title among the silent misses; the site renders those links broken. --- scripts/ci/generate_website_docs.py | 29 +++++++++++++++++---- tests/scripts/test_generate_website_docs.py | 13 +++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index 659641902..296f63481 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -170,7 +170,8 @@ def _mask(text: str) -> str: shortcut: matches what the docs use, not full Markdown. Indented code, admonition bodies, multi-line code spans and a ``](`` in prose with no link text are scanned as links, so a link-shaped example there is rewritten or fails ``--check`` loudly. Missed without a warning: a - link whose ``](`` and destination sit on two lines, and parentheses nested three deep. Upgrade + link whose ``](`` and destination sit on two lines, parentheses nested three deep, and an inline + link with a parenthesized or unterminated title, which the site renders broken anyway. Upgrade only when a page needs one of these. A fence opened inside an HTML comment and closed after it is masked on purpose: the site's superfences renders the lines between as a code block. """ @@ -180,7 +181,8 @@ def _mask(text: str) -> str: def _mask_fences(lines: list[str]) -> str: # As the site's superfences measured: a fence closes only on a bare line of the same marker, - # same length; one that never closes renders as text, and no later line opens a fence. + # same length; one that never closes renders as text, and no later line opens a fence. A fence + # in a blockquote closes before the quote ends at a blank line, or renders as text there. out: list[str] = [] i = 0 while i < len(lines): @@ -189,7 +191,18 @@ def _mask_fences(lines: list[str]) -> str: out.append(lines[i]) i += 1 continue - end = next((j for j in range(i + 1, len(lines)) if _closes(lines[j], m[1])), None) + quoted = ">" in m[0] + end = None + for j in range(i + 1, len(lines)): + if quoted and not lines[j].strip(): + break + if _closes(lines[j], m): + end = j + break + if end is None and quoted: + out.append(lines[i]) + i += 1 + continue if end is None: out.extend(lines[i:]) break @@ -198,9 +211,15 @@ def _mask_fences(lines: list[str]) -> str: return "".join(out) -def _closes(line: str, fence: str) -> bool: +def _closes(line: str, opener: re.Match[str]) -> bool: + # Same marker, no deeper in a blockquote: a quoted ``` inside a plain fence is its content. m = _FENCE.match(line) - return bool(m) and m[1] == fence and not line[m.end() :].strip() + return ( + bool(m) + and m[1] == opener[1] + and m[0].count(">") <= opener[0].count(">") + and not line[m.end() :].strip() + ) def _relative_links(text: str) -> Iterator[tuple[int, int, str]]: diff --git a/tests/scripts/test_generate_website_docs.py b/tests/scripts/test_generate_website_docs.py index 061218f53..c7a35a410 100644 --- a/tests/scripts/test_generate_website_docs.py +++ b/tests/scripts/test_generate_website_docs.py @@ -411,6 +411,19 @@ def test_a_link_outside_the_repository_is_left_as_written( ("``` `x` [L](A.md)\n\n```\n[M](B.md)\n```\n\n[N](C.md)\n", ["A.md", "C.md"]), ("```\n[X](B.md)\n```\n\n```\n[Y](C.md)\n\n[L](A.md)\n", ["C.md", "A.md"]), ("> ```\n> [X](B.md)\n> ```\n\n[L](A.md)\n", ["A.md"]), + # A closer sits no deeper in a blockquote than its opener. + ( + "```markdown\n> ```python\n> x\n> ```\n```\n\n[a](mid.md)\n\n" + "```bash\nls\n```\n[b](A.md)\n", + ["mid.md", "A.md"], + ), + ("```\n[X](B.md)\n> ```\n\n[L](A.md)\n", ["B.md", "A.md"]), + ("> ```\n> [X](B.md)\n```\n\n[L](A.md)\n", ["A.md"]), + # A blockquoted fence that does not close before the quote ends renders as text. + ( + "> ```\n> [X](B.md)\n\n[M](C.md)\n\n```\n[L](A.md)\n```\n[N](D.md)\n", + ["B.md", "C.md", "D.md"], + ), # A header superfences rejects is text, so a later fence still opens. ("``` invalid stuff\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n", ["A.md"]), ("```py x\n\n~~~\n[c](B.md)\n~~~\n\n[r](A.md)\n", ["A.md"]), From 844c8e6b7bedd32f10501c326e949062cc7cb823 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 14:26:18 +0000 Subject: [PATCH 18/28] fix(docs-site): end a blockquote only where the renderer does A blank line ends a blockquote only when the next non-blank line does not continue it with ">", so a fence in the quote may close after a blank line. The _mask docstring lists every remaining difference from the renderer that was measured, with whether it is reported or missed. --- scripts/ci/generate_website_docs.py | 24 ++++++++++++++------- tests/scripts/test_generate_website_docs.py | 5 +++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/scripts/ci/generate_website_docs.py b/scripts/ci/generate_website_docs.py index 296f63481..6d71790af 100644 --- a/scripts/ci/generate_website_docs.py +++ b/scripts/ci/generate_website_docs.py @@ -168,12 +168,14 @@ def _mask(text: str) -> str: """Blank fenced code, HTML comments and code spans in place, so offsets still index ``text``. shortcut: matches what the docs use, not full Markdown. Indented code, admonition bodies, - multi-line code spans and a ``](`` in prose with no link text are scanned as links, so a - link-shaped example there is rewritten or fails ``--check`` loudly. Missed without a warning: a - link whose ``](`` and destination sit on two lines, parentheses nested three deep, and an inline - link with a parenthesized or unterminated title, which the site renders broken anyway. Upgrade - only when a page needs one of these. A fence opened inside an HTML comment and closed after it - is masked on purpose: the site's superfences renders the lines between as a code block. + multi-line code spans, raw HTML blocks, an escaped ``\\[`` and a ``](`` in prose with no link + text are scanned as links, so a link-shaped example there is rewritten or fails ``--check`` + loudly. Missed without a warning: a link whose ``](`` and destination sit on two lines, + parentheses nested three deep, a destination with an unbracketed space, an ``href`` in raw + HTML, and an inline link with a parenthesized or unterminated title, which the site renders + broken anyway. Upgrade only when a page needs one of these. A fence opened inside an HTML + comment and closed after it is masked on purpose: the site's superfences renders the lines + between as a code block. """ # Code spans first, so a backticked `", re.DOTALL) _INLINE = re.compile( r"\]\([ \t]*(?:<([^<>\n]*)>|((?:[^\s()\\]|\\.|\((?:[^\s()]|\([^\s()]*\))*\))+))" # A title ends at the first closing quote followed by ")", so it may hold quotes and ")". @@ -166,27 +166,39 @@ def _unescape_md(value: str) -> str: def _blank(m: re.Match[str]) -> str: - # Newlines go too: a comment opened mid-line does not start a new line where it closes. return " " * len(m[0]) +def _blank_comments(text: str) -> str: + # str.find, not a lazy regex: an unclosed "", start + 4)) != -1: + out += [text[i:start], " " * (end + 3 - start)] + i = end + 3 + return "".join(out) + text[i:] + + def _mask(text: str) -> str: """Blank fenced code, HTML comments and code spans in place, so offsets still index ``text``. shortcut: matches what the docs use, not full Markdown. Indented code, admonition bodies, - multi-line code spans, raw HTML blocks, an escaped ``\\[`` and a ``](`` in prose with no link - text are scanned as links, so a link-shaped example there is rewritten or fails ``--check`` - loudly. Missed without a warning: a link whose ``](`` and destination sit on two lines, - parentheses nested three deep, a destination with an unbracketed space, an ``href`` in raw - HTML, and an inline link with a parenthesized or unterminated title, which the site renders - broken anyway. Upgrade only when a page needs one of these. A fence opened inside an HTML - comment and closed after it is masked on purpose: the site's superfences renders the lines - between as a code block. + multi-line code spans, a code span opened after an escaped backslash or holding another + backtick run, unused or malformed reference definitions, raw HTML blocks, an escaped ``\\[`` + and a ``](`` in prose with no link text are scanned as links, so a link-shaped example there + is rewritten or fails ``--check`` loudly. Missed without a warning: a link whose ``](`` and + destination sit on two lines, parentheses nested three deep, a destination with an + unbracketed space, a link between an inline ```` (an empty comment to the renderer) and + a later ``-->``, an ``href`` in raw HTML, and an inline link with a parenthesized or + unterminated title, which the site renders broken anyway. Upgrade only when a page needs one + of these. A fence opened inside an HTML comment and closed after it is masked on purpose: the + site's superfences renders the lines between as a code block. """ # Code spans first, so a backticked `" regex rescans to the end once per opener: about 10 s for this input. + start = time.perf_counter() + assert list(_gen._relative_links("`` (an empty comment to the renderer) and - a later ``-->``, an ``href`` in raw HTML, and an inline link with a parenthesized or - unterminated title, which the site renders broken anyway. Upgrade only when a page needs one + a later ``-->``, a link after a ``" regex rescans to the end once per opener: about 10 s for this input. +@pytest.mark.parametrize( + "source", + [ + # A lazy "" regex rescans to the end once per opener: about 10 s. + "`` (an empty comment to the renderer) and a later ``-->``, a link after a ``" regex rescans to the end once per opener: about 10 s. "