tenseleyflow/loader / d647e20

Browse files

Seed blank HTML child retries

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
d647e202e84787253b24d058b7ecba97bb8bfca3
Parents
721c739
Tree
6ea989a

2 changed files

StatusFile+-
M src/loader/runtime/repair.py 33 0
M tests/test_repair.py 7 0
src/loader/runtime/repair.pymodified
@@ -457,6 +457,14 @@ class ResponseRepairer:
457457
         )
458458
         if html_starter_line:
459459
             lines.append(html_starter_line)
460
+        html_template_line = self._known_html_starter_template_line(
461
+            concrete_target,
462
+            require_first_substantive_output=True,
463
+            retry_number=retry_number,
464
+            outline_label=outline_label,
465
+        )
466
+        if html_template_line:
467
+            lines.append(html_template_line)
460468
         if (
461469
             not compact_retry
462470
             and _should_encourage_initial_version(
@@ -1572,6 +1580,31 @@ class ResponseRepairer:
15721580
             "sections with short body text, and a back link to `../index.html`."
15731581
         )
15741582
 
1583
+    def _known_html_starter_template_line(
1584
+        self,
1585
+        target: Path,
1586
+        *,
1587
+        require_first_substantive_output: bool,
1588
+        retry_number: int,
1589
+        outline_label: str | None,
1590
+    ) -> str | None:
1591
+        if not require_first_substantive_output or retry_number < 4:
1592
+            return None
1593
+        if target.suffix.lower() not in {".html", ".htm"}:
1594
+            return None
1595
+        label = outline_label.strip() if outline_label and outline_label.strip() else "this chapter"
1596
+        snippet = (
1597
+            "<!DOCTYPE html> <html lang=\"en\"> <head> <meta charset=\"UTF-8\"> "
1598
+            f"<title>{label}</title> </head> <body> <div class=\"container\"> "
1599
+            f"<h1>{label}</h1> <p>...</p> <h2>Overview</h2> <p>...</p> "
1600
+            "<p><a href=\"../index.html\">← Back to Main Guide Index</a></p> "
1601
+            "</div> </body> </html>"
1602
+        )
1603
+        return (
1604
+            "If blanking continues, use this minimal HTML starter as the `content` value "
1605
+            f"and adapt it: `{snippet}`."
1606
+        )
1607
+
15751608
     def _best_known_root_html_scaffold(self, target: Path) -> Path | None:
15761609
         normalized_target = target.expanduser().resolve(strict=False)
15771610
         if normalized_target.suffix.lower() not in {".html", ".htm"}:
tests/test_repair.pymodified
@@ -1445,6 +1445,13 @@ def test_late_first_substantive_retry_trims_context_to_core_write_cues(
14451445
         "of `<h2>` sections with short body text, and a back link to `../index.html`."
14461446
         in decision.retry_message
14471447
     )
1448
+    assert (
1449
+        "If blanking continues, use this minimal HTML starter as the `content` value "
1450
+        "and adapt it:"
1451
+        in decision.retry_message
1452
+    )
1453
+    assert "<title>Chapter 1: Introduction to Nginx</title>" in decision.retry_message
1454
+    assert '<p><a href="../index.html">← Back to Main Guide Index</a></p>' in decision.retry_message
14481455
     assert (
14491456
         f"You already read `{display_runtime_path(reference_chapter)}`; reuse its overall structure "
14501457
         "as the starting pattern for this new file, then adapt the content to the current target."