diff options
| -rw-r--r-- | .codex-plugin/plugin.json | 3 | ||||
| -rwxr-xr-x | scripts/package-codex-plugin.sh | 8 | ||||
| -rwxr-xr-x | tests/codex/test-marketplace-manifest.sh | 12 | ||||
| -rwxr-xr-x | tests/codex/test-package-codex-plugin.sh | 48 |
4 files changed, 67 insertions, 4 deletions
diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index b0bc130..0dc7daa 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -24,7 +24,7 @@ "hooks": {}, "interface": { "displayName": "Superpowers", - "shortDescription": "Planning, TDD, debugging, and delivery workflows for coding agents", + "shortDescription": "Planning, TDD, and debugging", "longDescription": "Use Superpowers to guide agent work through brainstorming, implementation planning, test-driven development, systematic debugging, parallel execution, code review, and finish-the-branch workflows.", "developerName": "Jesse Vincent", "category": "Developer Tools", @@ -38,6 +38,7 @@ "Let's add a feature to this project." ], "websiteURL": "https://github.com/obra/superpowers", + "supportURL": "https://github.com/obra/superpowers/issues", "privacyPolicyURL": "https://docs.github.com/en/site-policy/privacy-policies/github-general-privacy-statement", "termsOfServiceURL": "https://docs.github.com/en/site-policy/github-terms/github-terms-of-service", "brandColor": "#F59E0B", diff --git a/scripts/package-codex-plugin.sh b/scripts/package-codex-plugin.sh index fe90862..d20a13e 100755 --- a/scripts/package-codex-plugin.sh +++ b/scripts/package-codex-plugin.sh @@ -42,6 +42,7 @@ Options: The archive is rootless: .codex-plugin/, assets/, skills/, README.md, LICENSE, and CODE_OF_CONDUCT.md sit at the archive root. Source-only repo files, hooks, tests, docs, and other harness manifests are intentionally not shipped. +Hook declarations are removed from the packaged manifest for portal submission. EOF } @@ -244,6 +245,13 @@ git -C "$REPO_ROOT" -c tar.umask=0022 archive --format=tar "$REF" -- \ VERSION="$(jq -r '.version // empty' "$STAGE/.codex-plugin/plugin.json")" [[ -n "$VERSION" ]] || die "could not read version from .codex-plugin/plugin.json" +# Omit hook declarations from portal packages while retaining the source +# manifest's suppression of hook discovery for repository installs. +# Write into the extracted file to preserve its canonical mode. +manifest_tmp="$WORK_DIR/plugin-manifest.json" +jq 'del(.hooks)' "$STAGE/.codex-plugin/plugin.json" >"$manifest_tmp" +cat "$manifest_tmp" >"$STAGE/.codex-plugin/plugin.json" + if [[ -z "$OUTPUT" ]]; then case "$FORMAT" in zip) diff --git a/tests/codex/test-marketplace-manifest.sh b/tests/codex/test-marketplace-manifest.sh index 4301a06..db647c4 100755 --- a/tests/codex/test-marketplace-manifest.sh +++ b/tests/codex/test-marketplace-manifest.sh @@ -9,6 +9,7 @@ python3 - "$MARKETPLACE" "$REPO_ROOT" <<'PY' import json import sys from pathlib import Path +from urllib.parse import urlsplit marketplace_path = Path(sys.argv[1]) repo_root = Path(sys.argv[2]) @@ -52,6 +53,17 @@ if not plugin_manifest.exists(): manifest = json.loads(plugin_manifest.read_text(encoding="utf-8")) assert_equal(manifest.get("name"), plugin.get("name"), "plugin manifest name") +interface = manifest.get("interface", {}) +subtitle = interface.get("shortDescription") +if not isinstance(subtitle, str) or not 1 <= len(subtitle) <= 30: + raise AssertionError("marketplace subtitle must contain 1 to 30 characters") +if "\n" in subtitle or "\r" in subtitle: + raise AssertionError("marketplace subtitle must fit on one line") + +support_url = urlsplit(interface.get("supportURL", "")) +if support_url.scheme != "https" or not support_url.hostname: + raise AssertionError("marketplace support URL must be an HTTPS URL") + # Codex auto-discovers a plugin's hooks/hooks.json whenever the Codex manifest # has no `hooks` field: load_plugin_hooks falls back to a hardcoded # DEFAULT_HOOKS_CONFIG_FILE = "hooks/hooks.json" and registers it. That file is diff --git a/tests/codex/test-package-codex-plugin.sh b/tests/codex/test-package-codex-plugin.sh index 05e150a..bb13758 100755 --- a/tests/codex/test-package-codex-plugin.sh +++ b/tests/codex/test-package-codex-plugin.sh @@ -118,6 +118,28 @@ read_archive_file() { esac } +assert_packaged_manifest() { + local archive_path="$1" + + if read_archive_file "$archive_path" .codex-plugin/plugin.json | python3 -c ' +import json +import subprocess +import sys + +source = json.loads(subprocess.check_output( + ["git", "show", "HEAD:.codex-plugin/plugin.json"], cwd=sys.argv[1] +)) +manifest = json.load(sys.stdin) +assert "hooks" not in manifest, "packaged manifest must omit hook declarations" +source.pop("hooks", None) +assert manifest == source, "packaging must preserve all other manifest fields" +' "$REPO_ROOT"; then + pass "archive omits hook declarations and preserves all other manifest fields" + else + fail "archive omits hook declarations and preserves all other manifest fields" + fi +} + write_metadata_fixture() { local destination="$1" local skill @@ -145,6 +167,7 @@ write_metadata_fixture "$metadata_source" source_hooks="$(python3 -c 'import json; print(json.load(open("'"$REPO_ROOT"'/.codex-plugin/plugin.json")).get("hooks"))')" assert_equals "$source_hooks" "{}" "source Codex manifest suppresses local hook auto-discovery" +source_manifest_checksum="$(shasum -a 256 "$REPO_ROOT/.codex-plugin/plugin.json" | awk '{print $1}')" if output="$("$SCRIPT_UNDER_TEST" --allow-dirty --metadata-source "$metadata_source" --output "$archive" 2>&1)"; then pass "package script exits successfully" @@ -193,9 +216,7 @@ assert_contains "$archive_paths" "skills/brainstorming/agents/openai.yaml" "arch assert_contains "$archive_paths" "assets/app-icon.png" "archive includes app icon" assert_contains "$archive_paths" "assets/superpowers-small.svg" "archive includes composer icon" -manifest_summary="$(read_archive_file "$archive" .codex-plugin/plugin.json | python3 -c 'import json,sys; data=json.load(sys.stdin); print("\t".join([data["name"], data["version"], data["skills"], str(data.get("hooks"))]))')" -expected_version="$(python3 -c 'import json; print(json.load(open("'"$REPO_ROOT"'/.codex-plugin/plugin.json"))["version"])')" -assert_equals "$manifest_summary" "superpowers $expected_version ./skills/ $source_hooks" "archive manifest preserves source hooks" +assert_packaged_manifest "$archive" skill_count="$(find "$extracted/skills" -mindepth 1 -maxdepth 1 -type d | wc -l | tr -d ' ')" metadata_count="$(find "$extracted/skills" -path '*/agents/openai.yaml' -type f | wc -l | tr -d ' ')" @@ -217,6 +238,23 @@ PY )" assert_equals "$zip_times" "(1980, 1, 1, 0, 0, 0)" "zip archive normalizes entry timestamps" +restrictive_archive="$TEST_ROOT/superpowers-restrictive.zip" +( + umask 077 + "$SCRIPT_UNDER_TEST" --allow-dirty --metadata-source "$metadata_source" --output "$restrictive_archive" >/dev/null +) +restrictive_manifest_mode="$(python3 - "$restrictive_archive" <<'PY' +import stat +import sys +import zipfile + +with zipfile.ZipFile(sys.argv[1]) as archive: + manifest = archive.getinfo(".codex-plugin/plugin.json") + print(oct(stat.S_IMODE(manifest.external_attr >> 16))) +PY +)" +assert_equals "$restrictive_manifest_mode" "0o644" "manifest preserves its mode under a restrictive umask" + if tar_output="$("$SCRIPT_UNDER_TEST" --allow-dirty --metadata-source "$metadata_source" --format tar.gz --output "$tar_archive" 2>&1)"; then pass "package script writes explicit tar.gz archive" else @@ -228,6 +266,7 @@ assert_contains "$tar_output" "Format: tar.gz" "reports explicit tar.gz format" extract_archive "$tar_archive" "$tar_extracted" tar_archive_paths="$(list_archive "$tar_archive" | normalize_archive_paths)" assert_equals "$tar_archive_paths" "$archive_paths" "zip and tar.gz archives contain the same paths" +assert_packaged_manifest "$tar_archive" tar_task_brief_mode="$(tar -tzvf "$tar_archive" skills/subagent-driven-development/scripts/task-brief | awk '{print $1}')" assert_equals "$tar_task_brief_mode" "-rwxr-xr-x" "tar.gz archive preserves executable script mode" @@ -311,6 +350,9 @@ else fi assert_contains "$dirty_output" "Working tree has uncommitted changes:" "dirty worktree reports changed files" +assert_equals "$(shasum -a 256 "$REPO_ROOT/.codex-plugin/plugin.json" | awk '{print $1}')" \ + "$source_manifest_checksum" "packaging leaves the repository manifest unchanged" + if [[ "$FAILURES" -eq 0 ]]; then echo "All Codex package archive tests passed" else |
