@@ -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 | |