Delete all cache entries (ast/, semantic/, semantic-deep/, and legacy flat entries).
(root: Path = Path("."))
| 1886 | |
| 1887 | |
| 1888 | def clear_cache(root: Path = Path(".")) -> None: |
| 1889 | """Delete all cache entries (ast/, semantic/, semantic-deep/, and legacy |
| 1890 | flat entries).""" |
| 1891 | base = Path(root).resolve() / _GRAPHIFY_OUT / "cache" |
| 1892 | # Legacy flat entries |
| 1893 | if base.is_dir(): |
| 1894 | for f in base.glob("*.json"): |
| 1895 | f.unlink() |
| 1896 | # Namespaced entries, all globbed recursively: ast/ has per-version subdirs, |
| 1897 | # semantic-deep/ holds --mode deep entries (#1894), and both semantic kinds |
| 1898 | # have per-prompt-fingerprint subdirs (#1939). |
| 1899 | for kind in ("ast", "semantic", "semantic-deep"): |
| 1900 | d = base / kind |
| 1901 | if d.is_dir(): |
| 1902 | for f in d.glob("**/*.json"): |
| 1903 | f.unlink() |
| 1904 | |
| 1905 | |
| 1906 | def prune_semantic_cache(root: Path, live_hashes: set[str]) -> int: |