MCPcopy Index your code
hub / github.com/github/copilot-sdk / get_cache_dir

Function get_cache_dir

python/copilot/_cli_download.py:53–82  ·  view source on GitHub ↗

Return the cache directory for CLI binaries. Args: version: CLI version string. If None, returns the root cache dir.

(version: str | None = None)

Source from the content-addressed store, hash-verified

51
52
53def get_cache_dir(version: str | None = None) -> Path:
54 """Return the cache directory for CLI binaries.
55
56 Args:
57 version: CLI version string. If None, returns the root cache dir.
58 """
59 # COPILOT_CLI_EXTRACT_DIR overrides the entire version-specific directory
60 # (binary lives directly at $dir/<binary>, no version subdir). Matches Rust SDK.
61 extract_override = os.environ.get("COPILOT_CLI_EXTRACT_DIR")
62 if extract_override:
63 return Path(extract_override)
64
65 if sys.platform == "darwin":
66 root = Path.home() / "Library" / "Caches" / _CACHE_DIR_NAME
67 elif sys.platform == "win32":
68 local_app_data = os.environ.get("LOCALAPPDATA")
69 if local_app_data:
70 root = Path(local_app_data) / _CACHE_DIR_NAME
71 else:
72 root = Path.home() / "AppData" / "Local" / _CACHE_DIR_NAME
73 else:
74 xdg = os.environ.get("XDG_CACHE_HOME")
75 if xdg:
76 root = Path(xdg) / _CACHE_DIR_NAME
77 else:
78 root = Path.home() / ".cache" / _CACHE_DIR_NAME
79
80 if version:
81 return root / "cli" / _sanitize_version(version)
82 return root / "cli"
83
84
85def get_cached_cli_path(version: str | None = None) -> str | None:

Callers 2

get_cached_cli_pathFunction · 0.85
download_cliFunction · 0.85

Calls 3

PathFunction · 0.85
_sanitize_versionFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…