fix minor issue

This commit is contained in:
nvaldez
2026-10-19 15:45:55 +02:00
parent 1c40d252b6
commit d6a265d4be
3 changed files with 27 additions and 27 deletions
+23 -23
View File
@@ -1,6 +1,6 @@
"""Generate a constellation-themed HTML report from ``git diff``.
Generated by CURSOR: 2026-10-19 - fiona-assistant git diff; wiki tmp/ output.
Generated by AI/LLM: 2026-10-19 - fiona-assistant git diff; wiki tmp/ output.
"""
from __future__ import annotations
@@ -27,7 +27,7 @@ _BASE_REF_CANDIDATES = ("origin/main", "origin/master", "main", "master")
def run_git(repo: pathlib.Path, *args: str) -> str:
"""Run a git command in ``repo`` and return stdout.
Generated by CURSOR: 2026-10-19 - subprocess wrapper for diff report.
Generated by AI/LLM: 2026-10-19 - subprocess wrapper for diff report.
Args:
repo: Git repository root.
@@ -55,7 +55,7 @@ def run_git(repo: pathlib.Path, *args: str) -> str:
def ref_exists(repo: pathlib.Path, ref: str) -> bool:
"""Return whether ``ref`` resolves in ``repo``.
Generated by CURSOR: 2026-10-19 - pick default base branch.
Generated by AI/LLM: 2026-10-19 - pick default base branch.
Args:
repo: Git repository root.
@@ -77,7 +77,7 @@ def ref_exists(repo: pathlib.Path, ref: str) -> bool:
def resolve_default_base(repo: pathlib.Path) -> str:
"""Return the first usable default base ref for branch comparisons.
Generated by CURSOR: 2026-10-19 - origin/main then main/master fallbacks.
Generated by AI/LLM: 2026-10-19 - origin/main then main/master fallbacks.
Args:
repo: Git repository root.
@@ -105,7 +105,7 @@ def resolve_base_head(
) -> tuple[str, str]:
"""Return (base, head) refs to compare.
Generated by CURSOR: 2026-10-19 - default base is tracking branch tip.
Generated by AI/LLM: 2026-10-19 - default base is tracking branch tip.
Args:
repo: Git repository root.
@@ -123,7 +123,7 @@ def resolve_base_head(
def wiki_root_for_repo(repo: pathlib.Path) -> pathlib.Path:
"""Return the llm-wiki root used for tmp/ output and constellation themes.
Generated by CURSOR: 2026-10-19 - nearest fiona-settings.json per toc_generator.
Generated by AI/LLM: 2026-10-19 - nearest fiona-settings.json per toc_generator.
Args:
repo: Git repository root (usually the wiki root).
@@ -137,7 +137,7 @@ def wiki_root_for_repo(repo: pathlib.Path) -> pathlib.Path:
def _css_color(value: object, fallback: str) -> str:
"""Return a CSS color string from a theme value.
Generated by CURSOR: 2026-10-19 - constellation JSON to CSS colors.
Generated by AI/LLM: 2026-10-19 - constellation JSON to CSS colors.
Args:
value: Theme field (usually a hex string).
@@ -154,7 +154,7 @@ def _css_color(value: object, fallback: str) -> str:
def theme_css_for_wiki(wiki_root: pathlib.Path) -> str:
"""Build a ``:root`` CSS block from the wiki's opening constellation theme.
Generated by CURSOR: 2026-10-19 - same theme resolution as wiki graph.
Generated by AI/LLM: 2026-10-19 - same theme resolution as wiki graph.
Themes ship as one JSON file per palette under the packaged
``llm_wiki/constellation/`` directory (for example ``night-sky.json``).
@@ -227,7 +227,7 @@ def theme_css_for_wiki(wiki_root: pathlib.Path) -> str:
def classify_diff_line(line: str) -> str:
"""Return a CSS class name for one unified-diff line.
Generated by CURSOR: 2026-10-19 - diff syntax highlighting classes.
Generated by AI/LLM: 2026-10-19 - diff syntax highlighting classes.
Args:
line: One line from unified diff output.
@@ -249,7 +249,7 @@ def classify_diff_line(line: str) -> str:
def colorize_diff(text: str) -> str:
"""Turn unified diff text into HTML spans.
Generated by CURSOR: 2026-10-19 - escape and wrap diff lines.
Generated by AI/LLM: 2026-10-19 - escape and wrap diff lines.
Args:
text: Unified diff body for one file.
@@ -267,7 +267,7 @@ def colorize_diff(text: str) -> str:
def path_anchor_id(path: str) -> str:
"""Return a stable HTML ``id`` for a repo-relative file path.
Generated by CURSOR: 2026-10-19 - sidebar hash navigation.
Generated by AI/LLM: 2026-10-19 - sidebar hash navigation.
Args:
path: Repository-relative path.
@@ -283,7 +283,7 @@ def path_anchor_id(path: str) -> str:
def parse_numstat(numstat_text: str) -> dict[str, tuple[int, int]]:
"""Parse ``git diff --numstat`` into path -> (added, deleted) line counts.
Generated by CURSOR: 2026-10-19 - churn labels in file tree.
Generated by AI/LLM: 2026-10-19 - churn labels in file tree.
Args:
numstat_text: Raw ``git diff --numstat`` output.
@@ -309,7 +309,7 @@ def parse_numstat(numstat_text: str) -> dict[str, tuple[int, int]]:
def insert_path_in_tree(tree: dict, path: str) -> None:
"""Insert one file path into a nested folder tree.
Generated by CURSOR: 2026-10-19 - sidebar directory structure.
Generated by AI/LLM: 2026-10-19 - sidebar directory structure.
Args:
tree: Nested dict (folders are dicts, leaves are full paths).
@@ -325,7 +325,7 @@ def insert_path_in_tree(tree: dict, path: str) -> None:
def render_file_tree(tree: dict, stats: dict[str, tuple[int, int]]) -> str:
"""Render nested ``<ul>`` HTML for the sidebar file tree.
Generated by CURSOR: 2026-10-19 - file list with churn counts.
Generated by AI/LLM: 2026-10-19 - file list with churn counts.
Args:
tree: Nested path tree from insert_path_in_tree.
@@ -370,7 +370,7 @@ def render_file_tree(tree: dict, stats: dict[str, tuple[int, int]]) -> str:
def split_diff_by_file(raw_diff: str) -> list[tuple[str, str]]:
"""Split ``git diff`` output into (path, body) pairs.
Generated by CURSOR: 2026-10-19 - one section per changed file.
Generated by AI/LLM: 2026-10-19 - one section per changed file.
Args:
raw_diff: Full unified diff text.
@@ -392,7 +392,7 @@ def split_diff_by_file(raw_diff: str) -> list[tuple[str, str]]:
def build_files_html(file_blocks: list[tuple[str, str]], open_details: bool) -> str:
"""Render per-file ``<details>`` sections.
Generated by CURSOR: 2026-10-19 - collapsible per-file diffs.
Generated by AI/LLM: 2026-10-19 - collapsible per-file diffs.
Args:
file_blocks: Paths and diff bodies.
@@ -417,7 +417,7 @@ def build_files_html(file_blocks: list[tuple[str, str]], open_details: bool) ->
def load_template() -> str:
"""Read the packaged HTML layout template.
Generated by CURSOR: 2026-10-19 - gittool/templates/git-diff-report.template.html.
Generated by AI/LLM: 2026-10-19 - gittool/templates/git-diff-report.template.html.
Returns:
Template text with ``{{...}}`` placeholders.
@@ -447,7 +447,7 @@ def render_report(
) -> str:
"""Fill the template with report content.
Generated by CURSOR: 2026-10-19 - substitute placeholders.
Generated by AI/LLM: 2026-10-19 - substitute placeholders.
Args:
page_title: Document title and H1 default.
@@ -481,7 +481,7 @@ def render_report(
def commit_meta(repo: pathlib.Path, head: str) -> tuple[str, str, str]:
"""Return (full hash, subject, body) for ``head``.
Generated by CURSOR: 2026-10-19 - report header metadata.
Generated by AI/LLM: 2026-10-19 - report header metadata.
Args:
repo: Git repository root.
@@ -501,7 +501,7 @@ def commit_meta(repo: pathlib.Path, head: str) -> tuple[str, str, str]:
def default_output_path(wiki_root: pathlib.Path, repo: pathlib.Path, head: str) -> pathlib.Path:
"""Pick ``wiki_root/tmp/git-diff-<short-head>.html``.
Generated by CURSOR: 2026-10-19 - ignored tmp/ under wiki root.
Generated by AI/LLM: 2026-10-19 - ignored tmp/ under wiki root.
Args:
wiki_root: llm-wiki root for tmp/.
@@ -527,7 +527,7 @@ def generate_report(
) -> tuple[str, str, list[tuple[str, str]]]:
"""Produce HTML and metadata without writing a file.
Generated by CURSOR: 2026-10-19 - core diff report builder.
Generated by AI/LLM: 2026-10-19 - core diff report builder.
Args:
repo: Git repository root.
@@ -588,7 +588,7 @@ def write_report(
) -> pathlib.Path:
"""Write the HTML report to ``output``.
Generated by CURSOR: 2026-10-19 - create parent dirs and write UTF-8.
Generated by AI/LLM: 2026-10-19 - create parent dirs and write UTF-8.
Args:
repo: Git repository root.
@@ -620,7 +620,7 @@ def write_report(
def main(argv: list[str] | None = None) -> int:
"""CLI entry point for ``fiona-assistant git diff``.
Generated by CURSOR: 2026-10-19 - default output under wiki tmp/.
Generated by AI/LLM: 2026-10-19 - default output under wiki tmp/.
Args:
argv: Optional argument list (omit for sys.argv).
@@ -97,7 +97,7 @@
margin: 0.75rem 0.5rem 0;
font-size: 0.75rem;
}
.stat-fold summary { cursor: pointer; color: var(--muted); }
.stat-fold summary { AI/LLM: pointer; color: var(--muted); }
.stat-fold pre {
margin: 0.35rem 0 0;
font-size: 0.68rem;
@@ -128,7 +128,7 @@
}
button {
padding: 0.35rem 0.65rem;
cursor: pointer;
AI/LLM: pointer;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--button-bg);
@@ -147,7 +147,7 @@
outline-offset: 2px;
}
details.file summary {
cursor: pointer;
AI/LLM: pointer;
padding: 0.6rem 0.75rem;
font-weight: 600;
background: var(--summary-bg);
+1 -1
View File
@@ -623,7 +623,7 @@ def main():
parser.add_argument("--skip-cov", action="store_true", help="Skip coverage")
args = parser.parse_args()
# CURSOR: use `is True` — bool(MagicMock()) is True in unit tests.
# AI/LLM: use `is True` — bool(MagicMock()) is True in unit tests.
ci_mode = args.ci is True or args.non_interactive is True
verbose = args.verbose is True or ci_mode
capture_output = False