Return set of file hashes that have a valid cache entry (any kind).
(root: Path = Path("."))
| 1868 | |
| 1869 | |
| 1870 | def cached_files(root: Path = Path(".")) -> set[str]: |
| 1871 | """Return set of file hashes that have a valid cache entry (any kind).""" |
| 1872 | base = Path(root).resolve() / _GRAPHIFY_OUT / "cache" |
| 1873 | hashes: set[str] = set() |
| 1874 | # Legacy flat entries |
| 1875 | if base.is_dir(): |
| 1876 | hashes.update(p.stem for p in base.glob("*.json")) |
| 1877 | # Namespaced entries, all globbed recursively: ast/ has per-version subdirs, |
| 1878 | # semantic-deep/ holds --mode deep entries (#1894), and both semantic kinds |
| 1879 | # have per-prompt-fingerprint subdirs alongside pre-fingerprint flat entries |
| 1880 | # (#1939). |
| 1881 | for kind in ("ast", "semantic", "semantic-deep"): |
| 1882 | d = base / kind |
| 1883 | if d.is_dir(): |
| 1884 | hashes.update(p.stem for p in d.glob("**/*.json")) |
| 1885 | return hashes |
| 1886 | |
| 1887 | |
| 1888 | def clear_cache(root: Path = Path(".")) -> None: |