MCPcopy
hub / github.com/github/spec-kit / ExtensionCatalog

Class ExtensionCatalog

src/specify_cli/extensions/__init__.py:2002–2654  ·  view source on GitHub ↗

Manages extension catalog fetching, caching, and searching.

Source from the content-addressed store, hash-verified

2000
2001
2002class ExtensionCatalog(CatalogStackBase):
2003 """Manages extension catalog fetching, caching, and searching."""
2004
2005 DEFAULT_CATALOG_URL = (
2006 "https://raw.githubusercontent.com/github/spec-kit/main/extensions/catalog.json"
2007 )
2008 COMMUNITY_CATALOG_URL = "https://raw.githubusercontent.com/github/spec-kit/main/extensions/catalog.community.json"
2009 CACHE_DURATION = 3600 # 1 hour in seconds
2010 CONFIG_FILENAME = "extension-catalogs.yml"
2011 ENTRY_CLASS = CatalogEntry
2012 ERROR_TYPE = ValidationError
2013 VALIDATION_ERROR_TYPE = ValidationError
2014
2015 def __init__(self, project_root: Path):
2016 """Initialize extension catalog manager.
2017
2018 Args:
2019 project_root: Root directory of the spec-kit project
2020 """
2021 self.project_root = project_root
2022 self.extensions_dir = project_root / ".specify" / "extensions"
2023 self.cache_dir = self.extensions_dir / ".cache"
2024 self.cache_file = self.cache_dir / "catalog.json"
2025 self.cache_metadata_file = self.cache_dir / "catalog-metadata.json"
2026
2027 def _make_request(self, url: str):
2028 """Build a urllib Request, adding auth headers when a provider matches.
2029
2030 Delegates to :func:`specify_cli.authentication.http.build_request`.
2031 """
2032 from specify_cli.authentication.http import build_request
2033
2034 return build_request(url)
2035
2036 def _open_url(
2037 self,
2038 url: str,
2039 timeout: int = 10,
2040 extra_headers: Optional[Dict[str, str]] = None,
2041 ):
2042 """Open a URL with provider-based auth, trying each configured provider.
2043
2044 Delegates to :func:`specify_cli.authentication.http.open_url`.
2045 """
2046 from specify_cli.authentication.http import open_url
2047
2048 return open_url(url, timeout, extra_headers=extra_headers)
2049
2050 def _resolve_github_release_asset_api_url(
2051 self,
2052 download_url: str,
2053 timeout: int = 60,
2054 ) -> Optional[str]:
2055 """Resolve a GitHub release asset URL to its API asset URL.
2056
2057 Delegates to the shared helper in :mod:`specify_cli._github_http`,
2058 passing the ``github`` provider hosts from ``auth.json`` so GitHub
2059 Enterprise Server release assets resolve via ``/api/v3``.

Calls

no outgoing calls