Back up + overwrite ``wiki/AGENTS.md`` with the current ``AGENTS_MD``. If the on-disk schema differs from the bundled default, copy it to ``wiki/AGENTS.md.bak`` then overwrite with ``AGENTS_MD``. No-op when the file is missing or already identical. Returns True if it overwrote.
(wiki_dir: Path)
| 1510 | |
| 1511 | |
| 1512 | def _refresh_schema(wiki_dir: Path) -> bool: |
| 1513 | """Back up + overwrite ``wiki/AGENTS.md`` with the current ``AGENTS_MD``. |
| 1514 | |
| 1515 | If the on-disk schema differs from the bundled default, copy it to |
| 1516 | ``wiki/AGENTS.md.bak`` then overwrite with ``AGENTS_MD``. No-op when the |
| 1517 | file is missing or already identical. Returns True if it overwrote. |
| 1518 | """ |
| 1519 | agents_file = wiki_dir / "AGENTS.md" |
| 1520 | if not agents_file.exists(): |
| 1521 | # No-op when missing: get_agents_md() already falls back to the |
| 1522 | # bundled AGENTS_MD default at runtime, so there is nothing to refresh. |
| 1523 | return False |
| 1524 | current = agents_file.read_text(encoding="utf-8") |
| 1525 | if current == AGENTS_MD: |
| 1526 | return False |
| 1527 | backup = wiki_dir / "AGENTS.md.bak" |
| 1528 | backup.write_text(current, encoding="utf-8") |
| 1529 | click.echo(f" Backed up existing schema to {backup.relative_to(wiki_dir.parent)}") |
| 1530 | agents_file.write_text(AGENTS_MD, encoding="utf-8") |
| 1531 | click.echo(" Refreshed wiki/AGENTS.md to the current schema.") |
| 1532 | return True |
| 1533 | |
| 1534 | |
| 1535 | @cli.command() |