Skip to content

Open-source skills for designing and reviewing software with AI agents

Reject incomplete runtime packages and occupied archive paths

n3wthbce631f50a41
diff --git a/scripts/pack_plugin.py b/scripts/pack_plugin.py
index cbf2822..33207ee 100644
--- a/scripts/pack_plugin.py
+++ b/scripts/pack_plugin.py
@@ -23,6 +23,33 @@ HOST = {
".claude-plugin/agents/*.md"),
"openai": (".codex-plugin/plugin.json",),
}
+SKILLS = (
+ "egm_bootstrap", "egm_brainstorm", "egm_draft", "egm_drift_report",
+ "egm_resolve", "egm_review", "egm_review_loop",
+)
+REQUIRED_SHARED = (
+ "plugin.json", "LICENSE", "README.md", "assets/icon.svg",
+ "docs/index.md", "docs/getting_started.md", "docs/harnesses.md",
+ "docs/claude.md", "docs/codex.md", "docs/faq.md", "docs/privacy.md",
+ "resources/README.md", "resources/execution_instructions.md",
+ "skills/egm_bootstrap/references/worker-return.schema.json",
+ "skills/egm_draft/references/design_doc.md",
+) + tuple(
+ f"skills/{skill}/{name}"
+ for skill in SKILLS
+ for name in ("SKILL.md", "agents/openai.yaml", "assets/icon.svg")
+) + tuple(
+ f"agents/{name}.md" for name in (
+ "bootstrap_orchestrator", "codebase_details", "comprehension",
+ "design_critic", "implementation_readiness", "structural", "style",
+ "synthesizer", "zoom_out",
+ )
+) + tuple(
+ f"resources/document_standards/{name}-standard.md" for name in (
+ "feature-spec", "heilmeier", "implementation-readiness",
+ "re-implementation", "zoom-out",
+ )
+)
def build(root: Path, target: str, output: Path) -> tuple[Path, Path]:
@@ -30,7 +57,7 @@ def build(root: Path, target: str, output: Path) -> tuple[Path, Path]:
root = root.resolve()
folder = output.resolve() / f"egm-{target}"
archive = folder.with_suffix(".zip")
- if folder.exists() or archive.exists():
+ if any(path.exists() or path.is_symlink() for path in (folder, archive)):
raise ValueError("Output folder or ZIP already exists")
if folder == root or root.is_relative_to(folder):
raise ValueError("Output must not contain the source tree")
@@ -45,8 +72,7 @@ def build(root: Path, target: str, output: Path) -> tuple[Path, Path]:
raise ValueError(f"Path outside source: {relative}")
if path.is_file():
files.add(relative)
- for name in ("plugin.json", "LICENSE", "README.md",
- HOST[target][0]):
+ for name in REQUIRED_SHARED + (HOST[target][0],):
if Path(name) not in files:
raise ValueError(f"Missing required file: {name}")
manifest = json.loads((root / HOST[target][0]).read_text())
@@ -70,7 +96,7 @@ 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, "w", zipfile.ZIP_DEFLATED) as bundle:
+ with zipfile.ZipFile(archive, "x", zipfile.ZIP_DEFLATED) as bundle:
for relative in sorted(files):
data = (root / relative).read_bytes()
destination = folder / relative
diff --git a/tests/unit/test_packaging.py b/tests/unit/test_packaging.py
index bd2f296..83781ed 100644
--- a/tests/unit/test_packaging.py
+++ b/tests/unit/test_packaging.py
@@ -167,6 +167,84 @@ def test_refuses_unbundled_services(source: Path, tmp_path: Path, field: str) ->
build(source, "openai", tmp_path / "output")
[email protected]("target", ["claude", "openai"])
[email protected]("missing", [
+ "skills",
+ "skills/egm_bootstrap/SKILL.md",
+ "skills/egm_brainstorm/SKILL.md",
+ "skills/egm_draft/SKILL.md",
+ "skills/egm_drift_report/SKILL.md",
+ "skills/egm_resolve/SKILL.md",
+ "skills/egm_review/SKILL.md",
+ "skills/egm_review_loop/SKILL.md",
+ "skills/egm_review/agents/openai.yaml",
+ "skills/egm_review/assets/icon.svg",
+ "skills/egm_bootstrap/references/worker-return.schema.json",
+ "skills/egm_draft/references/design_doc.md",
+ "agents/design_critic.md",
+ "resources/execution_instructions.md",
+ "resources/document_standards/zoom-out-standard.md",
+ "docs/harnesses.md",
+])
+def test_incomplete_source_fails_before_output(
+ source: Path, tmp_path: Path, target: str, missing: str,
+) -> None:
+ path = source / missing
+ if path.is_dir():
+ shutil.rmtree(path)
+ else:
+ path.unlink()
+ output = tmp_path / "output"
+ with pytest.raises(ValueError, match="Missing required file"):
+ build(source, target, output)
+ assert not output.exists()
+
+
[email protected]("target", ["claude", "openai"])
[email protected]("suffix", ["", ".zip"])
+def test_rejects_dangling_output_symlinks(
+ source: Path, tmp_path: Path, target: str, suffix: str,
+) -> None:
+ output = tmp_path / "output"
+ output.mkdir()
+ outside = tmp_path / "outside"
+ link = output / f"egm-{target}{suffix}"
+ link.symlink_to(outside, target_is_directory=not suffix)
+ with pytest.raises(ValueError, match="already exists"):
+ build(source, target, output)
+ assert link.is_symlink()
+ assert not outside.exists()
+ assert list(output.iterdir()) == [link]
+
+
[email protected]("target", ["claude", "openai"])
[email protected]("symlink", [False, True])
+def test_archive_claimed_after_preflight_is_not_overwritten(
+ source: Path, tmp_path: Path, monkeypatch: pytest.MonkeyPatch,
+ target: str, symlink: bool,
+) -> None:
+ output = tmp_path / "output"
+ archive = output / f"egm-{target}.zip"
+ outside = tmp_path / "outside.zip"
+ original_zipfile = zipfile.ZipFile
+
+ def claim_archive(*args, **kwargs):
+ if symlink:
+ archive.symlink_to(outside)
+ else:
+ archive.write_bytes(b"another build owns this file")
+ return original_zipfile(*args, **kwargs)
+
+ monkeypatch.setattr(zipfile, "ZipFile", claim_archive)
+ with pytest.raises(FileExistsError):
+ build(source, target, output)
+ if symlink:
+ assert archive.is_symlink()
+ assert not outside.exists()
+ else:
+ assert archive.read_bytes() == b"another build owns this file"
+
+
def test_published_claude_runtime_is_current(tmp_path: Path) -> None:
"""The directory subfolder must contain exactly the reviewed runtime."""
generated, _ = build(ROOT, "claude", tmp_path)