{
  "source_file": "src/utils/cache.py",
  "generated_at": "2026-01-10T22:55:11.150694",
  "summary": {
    "purpose": "This file defines a persistent cache for file summaries using SQLite, keyed by file content hash, prompt version, model identifier, and chunking settings. It aims to avoid re-summarizing unchanged files across runs.",
    "exports": [
      "CacheKey",
      "CachedSummary",
      "normalize_repo_id",
      "repo_cache_dir_name",
      "safe_model_dirname",
      "SummaryCache",
      "get",
      "put",
      "invalidate",
      "clear",
      "stats",
      "close",
      "get_cache",
      "reset_cache"
    ],
    "imports": [
      "hashlib",
      "re",
      "json",
      "os",
      "sqlite3",
      "dataclasses",
      "datetime",
      "pathlib",
      "typing",
      "defaultdict",
      "collections"
    ],
    "key_components": [
      {
        "name": "CacheKey",
        "type": "class",
        "description": "A composite key for cache lookups, consisting of file hash, prompt version, model identifier, and chunk settings."
      },
      {
        "name": "CachedSummary",
        "type": "class",
        "description": "A cached file summary entry, containing file path, summary, creation timestamp, and hit count."
      },
      {
        "name": "normalize_repo_id",
        "type": "function",
        "description": "Normalizes a repository ID by stripping, converting to lowercase, removing trailing slashes, and removing the '.git' suffix."
      },
      {
        "name": "repo_cache_dir_name",
        "type": "function",
        "description": "Generates a directory name for the repository cache based on the normalized repository ID."
      },
      {
        "name": "safe_model_dirname",
        "type": "function",
        "description": "Generates a safe directory name for the model based on the model ID."
      },
      {
        "name": "SummaryCache",
        "type": "class",
        "description": "Manages the cache, including initialization, schema creation, file hash computation, and summary retrieval and storage."
      }
    ],
    "data_structures": "CacheKey, CachedSummary",
    "algorithms": "None explicitly defined, but includes file hash computation and summary retrieval logic.",
    "configuration": "Handles configuration through CacheConfig and config files, including default values.",
    "notes": "The cache uses SQLite for storage, and the cache directory is generated based on the repository ID and model ID. The cache avoids re-summarizing unchanged files by checking file hashes."
  }
}