Read existing concept pages and return compact one-line summaries. For each concept, reads the ``description:`` field (falling back to legacy ``brief:``) from YAML frontmatter if present; otherwise falls back to truncating the first 150 chars of the body (newlines collapsed to spaces).
(wiki_dir: Path)
| 703 | |
| 704 | |
| 705 | def _read_concept_briefs(wiki_dir: Path) -> str: |
| 706 | """Read existing concept pages and return compact one-line summaries. |
| 707 | |
| 708 | For each concept, reads the ``description:`` field (falling back to legacy |
| 709 | ``brief:``) from YAML frontmatter if present; otherwise falls back to |
| 710 | truncating the first 150 chars of the body (newlines collapsed to spaces). |
| 711 | Formats each as ``- {slug}: {description}``. |
| 712 | |
| 713 | Returns "(none yet)" if the concepts directory is missing or empty. |
| 714 | """ |
| 715 | concepts_dir = wiki_dir / "concepts" |
| 716 | if not concepts_dir.exists(): |
| 717 | return "(none yet)" |
| 718 | |
| 719 | md_files = sorted(concepts_dir.glob("*.md")) |
| 720 | if not md_files: |
| 721 | return "(none yet)" |
| 722 | |
| 723 | lines: list[str] = [] |
| 724 | for path in md_files: |
| 725 | text = path.read_text(encoding="utf-8") |
| 726 | fm_dict = frontmatter.parse(text) |
| 727 | brief = _resolve_description(fm_dict) |
| 728 | if not brief: |
| 729 | parts = frontmatter.split(text) |
| 730 | body = parts[1] if parts is not None else text |
| 731 | brief = body.strip().replace("\n", " ")[:150] |
| 732 | if brief: |
| 733 | lines.append(f"- {path.stem}: {brief}") |
| 734 | |
| 735 | return "\n".join(lines) or "(none yet)" |
| 736 | |
| 737 | |
| 738 | def _read_entity_briefs(wiki_dir: Path) -> str: |