tenseleyflow/loader / 515ed7c

Browse files

Steer substantive HTML guide writes

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
515ed7cc2a0a9aad15caf76409c3f155512f4b5a
Parents
5e2425f
Tree
c3b3810

2 changed files

StatusFile+-
M src/loader/runtime/prompting.py 67 0
M tests/test_prompt_builder.py 18 0
src/loader/runtime/prompting.pymodified
@@ -237,6 +237,10 @@ def build_system_prompt_result(
237
         ),
237
         ),
238
     ]
238
     ]
239
 
239
 
240
+    html_guide_section = _html_guide_quality_section(current_task)
241
+    if html_guide_section is not None:
242
+        dynamic_sections.append(html_guide_section)
243
+
240
     dynamic_sections.extend(_project_sections(project_context))
244
     dynamic_sections.extend(_project_sections(project_context))
241
     rendered = _render_sections(sections, dynamic_sections)
245
     rendered = _render_sections(sections, dynamic_sections)
242
     return SystemPromptBuildResult(
246
     return SystemPromptBuildResult(
@@ -255,6 +259,69 @@ def build_system_prompt(**kwargs: Any) -> str:
255
     return build_system_prompt_result(**kwargs).content
259
     return build_system_prompt_result(**kwargs).content
256
 
260
 
257
 
261
 
262
+def _html_guide_quality_section(current_task: str | None) -> PromptSection | None:
263
+    """Return extra guidance for substantive multi-page HTML guide generation."""
264
+
265
+    task = str(current_task or "").lower()
266
+    if not task:
267
+        return None
268
+    guide_like = any(
269
+        marker in task
270
+        for marker in (
271
+            "guide",
272
+            "tutorial",
273
+            "documentation",
274
+            "docs",
275
+            "manual",
276
+            "course",
277
+        )
278
+    )
279
+    html_like = any(
280
+        marker in task
281
+        for marker in (
282
+            ".html",
283
+            "html",
284
+            "index.html",
285
+            "chapters/",
286
+            "pages/",
287
+        )
288
+    )
289
+    substantive_like = any(
290
+        marker in task
291
+        for marker in (
292
+            "thorough",
293
+            "cadence",
294
+            "same structure",
295
+            "reference",
296
+            "multi-page",
297
+            "multi page",
298
+            "chapters",
299
+            "chapter",
300
+        )
301
+    )
302
+    if not (guide_like and html_like and substantive_like):
303
+        return None
304
+
305
+    return PromptSection(
306
+        name="Generated HTML Guide Quality",
307
+        body=(
308
+            "- For substantive multi-page HTML guide/tutorial/documentation tasks, "
309
+            "write each generated page or chapter as a real first pass, not a "
310
+            "placeholder outline.\n"
311
+            "- A chapter page should usually include 4-6 concrete body sections plus "
312
+            "lists, commands, configuration examples, or checks where relevant; avoid "
313
+            "filler like \"This section...\" standing in for content.\n"
314
+            "- Keep each HTML file structurally complete with exactly one closing "
315
+            "`</body>` tag and one closing `</html>` tag. Insert expansions before "
316
+            "the closing body/html tags, never after `</html>`.\n"
317
+            "- When the user asks to mirror a reference guide's cadence or make an "
318
+            "equally thorough guide, match that depth during the initial write rather "
319
+            "than relying on later repair passes."
320
+        ),
321
+        dynamic=True,
322
+    )
323
+
324
+
258
 def format_tool_descriptions(tools: list[dict[str, Any]]) -> str:
325
 def format_tool_descriptions(tools: list[dict[str, Any]]) -> str:
259
     """Format tool schemas as readable markdown."""
326
     """Format tool schemas as readable markdown."""
260
 
327
 
tests/test_prompt_builder.pymodified
@@ -97,3 +97,21 @@ def test_execute_mode_guidance_prefers_file_tools_for_text_edits(temp_dir: Path)
97
     )
97
     )
98
 
98
 
99
     assert "Prefer `edit`/`patch`/`write` over shell one-liners" in result.content
99
     assert "Prefer `edit`/`patch`/`write` over shell one-liners" in result.content
100
+
101
+
102
+def test_prompt_builder_adds_html_guide_quality_guidance(temp_dir: Path) -> None:
103
+    result = build_system_prompt_result(
104
+        tools=[_tool_schema("write")],
105
+        use_react=False,
106
+        workflow_mode="execute",
107
+        permission_mode="workspace-write",
108
+        cwd=temp_dir,
109
+        current_task=(
110
+            "Create an equally thorough HTML guide with index.html and chapters/ "
111
+            "matching the cadence of the reference guide."
112
+        ),
113
+    )
114
+
115
+    assert "Generated HTML Guide Quality" in result.dynamic_section_names
116
+    assert "write each generated page or chapter as a real first pass" in result.content
117
+    assert "never after `</html>`" in result.content