Open-source skills for designing and reviewing software with AI agents
Python agent-skillsai-agentsantigravityclaude-codeclaude-code-pluginclaude-skillscodexcodex-plugincoding-agentscontext-engineeringdeveloper-toolsgeminillmmulti-agentprompt-engineeringspec-driven-development
fix(packaging): publish archives safely on Windows
Olivered0655128c17
diff --git a/scripts/pack_plugin.py b/scripts/pack_plugin.pyindex 33207ee..e16cc08 100644--- a/scripts/pack_plugin.py+++ b/scripts/pack_plugin.py@@ -6,6 +6,7 @@import argparseimport jsonfrom pathlib import Path+import tempfileimport zipfileSHARED = (@@ -96,18 +97,23 @@ def build(root: Path, target: str, output: Path) -> tuple[Path, Path]:raise ValueError(f"Unbundled manifest reference: {reference}")output.mkdir(parents=True, exist_ok=True)folder.mkdir()- with zipfile.ZipFile(archive, "x", zipfile.ZIP_DEFLATED) as bundle:- for relative in sorted(files):- data = (root / relative).read_bytes()- destination = folder / relative- destination.parent.mkdir(parents=True, exist_ok=True)- destination.write_bytes(data)- destination.chmod(0o644)- info = zipfile.ZipInfo(relative.as_posix(), (1980, 1, 1, 0, 0, 0))- info.create_system = 3- info.external_attr = 0o100644 << 16- info.compress_type = zipfile.ZIP_DEFLATED- bundle.writestr(info, data)+ with tempfile.TemporaryDirectory(prefix=".egm-", dir=output) as temporary:+ staged = Path(temporary) / archive.name+ with zipfile.ZipFile(staged, "x", zipfile.ZIP_DEFLATED) as bundle:+ for relative in sorted(files):+ data = (root / relative).read_bytes()+ destination = folder / relative+ destination.parent.mkdir(parents=True, exist_ok=True)+ destination.write_bytes(data)+ destination.chmod(0o644)+ info = zipfile.ZipInfo(relative.as_posix(), (1980, 1, 1, 0, 0, 0))+ info.create_system = 3+ info.external_attr = 0o100644 << 16+ info.compress_type = zipfile.ZIP_DEFLATED+ bundle.writestr(info, data)+ # Windows exclusive file creation can follow a dangling symlink. Linking+ # the completed ZIP claims the final directory entry without following it.+ archive.hardlink_to(staged)return folder, archivediff --git a/tests/unit/test_packaging.py b/tests/unit/test_packaging.pyindex 0ae6a30..9481049 100644--- a/tests/unit/test_packaging.py+++ b/tests/unit/test_packaging.py@@ -54,14 +54,14 @@ def test_runtime_bundle_is_complete_and_reproducible(assert len([p for p in names if p.endswith("/SKILL.md")]) == 7for skill in source.glob("skills/*/SKILL.md"):prefix = skill.parent.relative_to(source)- metadata = yaml.safe_load(bundle.read(str(prefix / "agents/openai.yaml")))+ metadata = yaml.safe_load(bundle.read((prefix / "agents/openai.yaml").as_posix()))interface = metadata["interface"]assert interface["display_name"]assert 25 <= len(interface["short_description"]) <= 64for field in ("icon_small", "icon_large"):icon = Path(interface[field])assert not icon.is_absolute() and ".." not in icon.parts- data = bundle.read(str(prefix / icon))+ data = bundle.read((prefix / icon).as_posix())assert data == (skill.parent / icon).read_bytes()assert ElementTree.fromstring(data).tag == "{http://www.w3.org/2000/svg}svg"assert "skills/egm_bootstrap/references/worker-return.schema.json" in names@@ -246,18 +246,20 @@ def test_rejects_dangling_output_symlinks(@pytest.mark.parametrize("target", ["claude", "openai"])[email protected]("symlink", [False, True])[email protected]("claim", ["file", "dangling-symlink", "symlink"])def test_archive_claimed_after_preflight_is_not_overwritten(source: Path, tmp_path: Path, monkeypatch: pytest.MonkeyPatch,- target: str, symlink: bool,+ target: str, claim: str,) -> None:output = tmp_path / "output"archive = output / f"egm-{target}.zip"outside = tmp_path / "outside.zip"+ if claim == "symlink":+ outside.write_bytes(b"outside file must not change")original_zipfile = zipfile.ZipFiledef claim_archive(*args, **kwargs):- if symlink:+ if claim != "file":archive.symlink_to(outside)else:archive.write_bytes(b"another build owns this file")@@ -266,11 +268,15 @@ def test_archive_claimed_after_preflight_is_not_overwritten(monkeypatch.setattr(zipfile, "ZipFile", claim_archive)with pytest.raises(FileExistsError):build(source, target, output)- if symlink:+ if claim != "file":assert archive.is_symlink()- assert not outside.exists()+ if claim == "symlink":+ assert outside.read_bytes() == b"outside file must not change"+ else:+ assert not outside.exists()else:assert archive.read_bytes() == b"another build owns this file"+ assert not list(output.glob(".egm-*"))def test_published_claude_runtime_is_current(tmp_path: Path) -> None: