From 3c9bb564ceef8321332eebeff189a4d2e1a0541a Mon Sep 17 00:00:00 2001 From: "fatih.bulut" Date: Thu, 25 Jun 2026 02:11:55 +0300 Subject: [PATCH] feat(clone-app): Unity tool wrappers (Il2CppInspectorRedux, AssetRipper) --- .../skills/clone-app/scripts/il2cpp-dump.sh | 26 +++++++++++++++++++ .../skills/clone-app/scripts/unity-assets.sh | 23 ++++++++++++++++ .../clone-app/tests/test-unity-wrappers.sh | 25 ++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100755 plugins/clone-app/skills/clone-app/scripts/il2cpp-dump.sh create mode 100755 plugins/clone-app/skills/clone-app/scripts/unity-assets.sh create mode 100755 plugins/clone-app/tests/test-unity-wrappers.sh diff --git a/plugins/clone-app/skills/clone-app/scripts/il2cpp-dump.sh b/plugins/clone-app/skills/clone-app/scripts/il2cpp-dump.sh new file mode 100755 index 0000000..35ae2b1 --- /dev/null +++ b/plugins/clone-app/skills/clone-app/scripts/il2cpp-dump.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Recover the C# type model from a Unity IL2CPP build via Il2CppInspectorRedux. +# Flags follow the Il2CppInspector CLI; adjust to your installed CLI version if +# they differ. Only the tool-missing path is exercised by tests. +set -uo pipefail + +SO="${1:-}"; META="${2:-}"; OUT="${3:-}" +if [[ -z "$SO" || -z "$META" || -z "$OUT" ]]; then + echo "ERROR: usage: il2cpp-dump.sh " >&2 + exit 2 +fi + +BIN="${IL2CPP_INSPECTOR_CLI:-Il2CppInspector}" +if ! command -v "$BIN" >/dev/null 2>&1; then + cat >&2 <<'EOF' +ERROR: Il2CppInspectorRedux CLI not found. +Install it (needs the .NET SDK): https://github.com/LukeFZ/Il2CppInspectorRedux +Build the CLI, put it on PATH, or set IL2CPP_INSPECTOR_CLI=/path/to/cli. +EOF + exit 3 +fi + +mkdir -p "$OUT" +# Produce C# stub headers + a metadata JSON describing types/methods/fields. +"$BIN" --bin "$SO" --metadata "$META" \ + --select-outputs --cs-out "$OUT/types.cs" --json-out "$OUT/metadata.json" diff --git a/plugins/clone-app/skills/clone-app/scripts/unity-assets.sh b/plugins/clone-app/skills/clone-app/scripts/unity-assets.sh new file mode 100755 index 0000000..78cfa58 --- /dev/null +++ b/plugins/clone-app/skills/clone-app/scripts/unity-assets.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Extract Unity game assets (textures, sprites, audio, scenes, prefabs) from an +# APK via AssetRipper's CLI. Only the tool-missing path is exercised by tests. +set -uo pipefail + +APK="${1:-}"; OUT="${2:-}" +if [[ -z "$APK" || -z "$OUT" ]]; then + echo "ERROR: usage: unity-assets.sh " >&2 + exit 2 +fi + +BIN="${ASSETRIPPER_CLI:-AssetRipper}" +if ! command -v "$BIN" >/dev/null 2>&1; then + cat >&2 <<'EOF' +ERROR: AssetRipper CLI not found. +Install it (needs the .NET runtime): https://github.com/AssetRipper/AssetRipper +Put the CLI on PATH, or set ASSETRIPPER_CLI=/path/to/AssetRipper. +EOF + exit 3 +fi + +mkdir -p "$OUT" +"$BIN" "$APK" -o "$OUT" diff --git a/plugins/clone-app/tests/test-unity-wrappers.sh b/plugins/clone-app/tests/test-unity-wrappers.sh new file mode 100755 index 0000000..d2636b3 --- /dev/null +++ b/plugins/clone-app/tests/test-unity-wrappers.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -uo pipefail +HERE="$(cd "$(dirname "$0")" && pwd)" +S="$HERE/../skills/clone-app/scripts" +fail=0 +check() { + local desc="$1" expected="$2" actual="$3" + if [[ "$expected" == "$actual" ]]; then echo "PASS: $desc" + else echo "FAIL: $desc — expected '$expected' got '$actual'"; fail=1; fi +} + +# usage errors → exit 2 +bash "$S/il2cpp-dump.sh" >/dev/null 2>&1; check "il2cpp usage" "2" "$?" +bash "$S/unity-assets.sh" >/dev/null 2>&1; check "assets usage" "2" "$?" + +# tool missing → exit 3 + guidance text on stderr +err="$(IL2CPP_INSPECTOR_CLI=/no/such/bin bash "$S/il2cpp-dump.sh" a b c 2>&1 >/dev/null)"; rc=$? +check "il2cpp missing exit 3" "3" "$rc" +grep -q "Il2CppInspectorRedux" <<<"$err" && echo "PASS: il2cpp guidance" || { echo "FAIL: il2cpp guidance"; fail=1; } + +err="$(ASSETRIPPER_CLI=/no/such/bin bash "$S/unity-assets.sh" a b 2>&1 >/dev/null)"; rc=$? +check "assets missing exit 3" "3" "$rc" +grep -q "AssetRipper" <<<"$err" && echo "PASS: assets guidance" || { echo "FAIL: assets guidance"; fail=1; } + +exit $fail