| 129 | |
| 130 | |
| 131 | def chapter_prompt( |
| 132 | chapter: str, |
| 133 | module: str, |
| 134 | slug: str, |
| 135 | module_query: str, |
| 136 | chapter_hit: dict[str, Any], |
| 137 | module_hit: dict[str, Any], |
| 138 | ) -> str: |
| 139 | return f"""# Docs Writing Prompt: {chapter} -> {module} |
| 140 | |
| 141 | ## Scope |
| 142 | - Chapter: `{chapter}` |
| 143 | - Module: `{module}` (`/module/{slug}`) |
| 144 | - Source files: |
| 145 | - `docs-site/src/data/moduleDocs.ts` (module content) |
| 146 | - `docs-site/src/pages/modules.astro` (subject/chapter entry point) |
| 147 | - `docs-site/src/pages/module/[slug].astro` (module page rendering) |
| 148 | |
| 149 | ## Required AFML grounding |
| 150 | Use AFML MCP retrieval before writing: |
| 151 | 1. `afml_search(query=\"{chapter_hit.get('section','')}\", chapter=\"{chapter}\", top_k=3)` |
| 152 | 2. `afml_search(query=\"{module_query}\", chapter=\"{chapter}\", top_k=3)` |
| 153 | 3. `afml_get_context(query=\"{module_query}\", chapter=\"{chapter}\", top_k=2, window=1)` |
| 154 | |
| 155 | Use chunk ids and page ranges in your internal notes. |
| 156 | |
| 157 | ## Content contract (must be complete) |
| 158 | 1. High-level purpose and failure modes. |
| 159 | 2. AFML math framing tied to API behavior. |
| 160 | 3. Minimum 2 executable Rust examples (realistic, not toy-only). |
| 161 | 4. Implementation caveats and production constraints. |
| 162 | 5. Cross-links to adjacent modules in same chapter/subject. |
| 163 | |
| 164 | ## UI/UX contract (not AI slop) |
| 165 | 1. Keep typography intentional and consistent. |
| 166 | 2. Improve scanability with clear section rhythm and spacing. |
| 167 | 3. Avoid generic gradient-heavy cards everywhere. |
| 168 | 4. Keep code blocks readable on mobile and desktop. |
| 169 | 5. Verify rendered page in Astro before marking complete. |
| 170 | |
| 171 | ## Current AFML anchors |
| 172 | - Chapter anchor: `{chapter_hit.get('chunk_id','')}` pages {chapter_hit.get('page_start',-1)}-{chapter_hit.get('page_end',-1)} ({chapter_hit.get('section','')}) |
| 173 | - Module anchor: `{module_hit.get('chunk_id','')}` pages {module_hit.get('page_start',-1)}-{module_hit.get('page_end',-1)} ({module_hit.get('section','')}) |
| 174 | """ |
| 175 | |
| 176 | |
| 177 | def build_state() -> dict[str, Any]: |