Add .tar.gz / .tgz archive support for extension, preset, and workflow installation#2395
Open
Add .tar.gz / .tgz archive support for extension, preset, and workflow installation#2395
Conversation
…installation Agent-Logs-Url: https://github.com/github/spec-kit/sessions/9fb9a8ea-0967-4baf-b95c-7101e423ff58 Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/spec-kit/sessions/9fb9a8ea-0967-4baf-b95c-7101e423ff58 Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/spec-kit/sessions/9fb9a8ea-0967-4baf-b95c-7101e423ff58 Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/spec-kit/sessions/9fb9a8ea-0967-4baf-b95c-7101e423ff58 Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/spec-kit/sessions/9fb9a8ea-0967-4baf-b95c-7101e423ff58 Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for .tar.gz and .tgz archives
Add .tar.gz / .tgz archive support for extension, preset, and workflow installation
Apr 28, 2026
| f = tf.extractfile(tf.getmember("workflow.yml")) | ||
| if f is not None: | ||
| return f.read() | ||
| except KeyError: |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for installing extensions, presets, and workflows from gzipped tarballs (.tar.gz / .tgz) in addition to ZIPs, unblocking sources like npm registries and artifact stores that serve tarballs by default.
Changes:
- Introduces archive format detection (
zipvstar.gz) and safe tarball extraction (path traversal + link/special-file rejection). - Updates extension/preset download + install pipelines to persist the correct archive extension and extract accordingly.
- Extends
workflow addto accept archives from URL/catalog/local paths by extractingworkflow.ymlfrom ZIP/tar.gz.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/extensions.py |
Adds archive-format detection + safe tarball extraction; updates extension install/download to support tarballs. |
src/specify_cli/presets.py |
Updates preset install/download to support tarballs via shared helpers from extensions.py. |
src/specify_cli/__init__.py |
Extends CLI flows (preset add --from, extension add --from, extension update, workflow add) to handle tarball archives. |
tests/test_extensions.py |
Adds tests for archive format detection + tarball install and safety checks for extensions. |
tests/test_presets.py |
Adds tarball install and safety tests for presets. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
src/specify_cli/init.py:3661
- In
extension add --from, if_detect_archive_format()still returns empty after theContent-Typefallback, the code defaults to saving as.zipand proceeds. This can break tarball installs when servers omit/overrideContent-Type(e.g.,application/octet-stream) and yield a confusing zip parsing error. Consider failing fast with a clear message when the format is unknown (or sniff the first bytes to distinguish ZIP vs gzip).
# Download archive to temp location; detect format from URL or Content-Type.
download_dir = project_root / ".specify" / "extensions" / ".cache" / "downloads"
download_dir.mkdir(parents=True, exist_ok=True)
archive_fmt = _detect_archive_format(from_url)
archive_path = None
try:
with urllib.request.urlopen(from_url, timeout=60) as response:
if not archive_fmt:
content_type = response.headers.get("Content-Type", "")
archive_fmt = _detect_archive_format(from_url, content_type)
archive_data = response.read()
suffix = ".tar.gz" if archive_fmt == "tar.gz" else ".zip"
archive_path = download_dir / f"{extension}-url-download{suffix}"
archive_path.write_bytes(archive_data)
# Install from downloaded archive
manifest = manager.install_from_zip(archive_path, speckit_version, priority=priority)
except urllib.error.URLError as e:
- Files reviewed: 5/5 changed files
- Comments generated: 4
Comment on lines
+5101
to
+5106
| elif source_path.is_file() and ( | ||
| source.endswith(".tar.gz") or source.endswith(".tgz") or source.endswith(".zip") | ||
| ): | ||
| # Local archive file containing workflow.yml | ||
| from .extensions import _detect_archive_format | ||
| local_fmt = _detect_archive_format(source) |
| raise typer.Exit(1) | ||
|
|
||
| manifest = manager.install_from_zip(zip_path, speckit_version, priority) | ||
| suffix = ".tar.gz" if archive_fmt == "tar.gz" else ".zip" |
Comment on lines
+2153
to
+2158
| # Choose file extension based on detected format. | ||
| if archive_fmt == "tar.gz": | ||
| archive_filename = f"{extension_id}-{version}.tar.gz" | ||
| else: | ||
| archive_filename = f"{extension_id}-{version}.zip" | ||
|
|
Comment on lines
+2333
to
+2338
| # Choose file extension based on detected format. | ||
| if archive_fmt == "tar.gz": | ||
| archive_filename = f"{pack_id}-{version}.tar.gz" | ||
| else: | ||
| archive_filename = f"{pack_id}-{version}.zip" | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The extension, preset, and workflow download pipelines only accepted ZIP archives, blocking use of npm registries and CI artifact stores that serve tarballs natively.
Core utilities (
extensions.py)_detect_archive_format(url, content_type="")— infers format from URL path extension (.zip,.tar.gz,.tgz) withContent-Typeheader fallback (application/gzip,application/x-gzip,application/x-tar+gzip)_safe_extract_tarball(archive_path, dest_dir, error_class)— safe extraction with:..traversal, symlinks, hard links, and special filessafe_memberslist toextractall()tarfile.data_filterfor additional OS-level protectionExtensions & presets
install_from_zip()on both managers now detects archive format from the file extension and dispatches to ZIP or tarball extraction accordingly — existing callers are unaffecteddownload_extension()/download_pack()detect format from the download URL (orContent-Typefallback) and persist the archive with the correct extension (.zipor.tar.gz)__init__.pycall sitesextension add --frompreset add --fromextension updateworkflow add(URL)workflow.ymlfrom archive when URL points to oneworkflow add(local).tar.gz/.tgz/.ziparchive filesworkflow add(catalog)A shared
_extract_workflow_yml(archive_path, fmt)helper handles root-level and single-nested-directory layouts for both formats.Tests
21 new tests across
test_extensions.pyandtest_presets.pycovering: format detection (URL + Content-Type), flat and nested tarball install, missing manifest errors, path traversal rejection, and symlink rejection.