@leejungkiin/awkit 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/core/GEMINI.md.bak +168 -181
  2. package/package.json +2 -2
  3. package/schemas/brain-snapshot.json +167 -0
  4. package/skills/CATALOG.md +70 -0
  5. package/skills/beads-manager/SKILL.md +20 -1
  6. package/skills/memory-sync/SKILL.md +20 -2
  7. package/skills/nm-memory-audit/SKILL.md +157 -0
  8. package/skills/nm-memory-evolution/SKILL.md +202 -0
  9. package/skills/nm-memory-intake/SKILL.md +135 -0
  10. package/skills/nm-memory-sync/SKILL.md +184 -0
  11. package/skills/orchestrator/SKILL.md +41 -50
  12. package/skills/schemas/brain-snapshot.json +167 -0
  13. package/skills/skills/nm-memory-audit/SKILL.md +157 -0
  14. package/skills/skills/nm-memory-evolution/SKILL.md +202 -0
  15. package/skills/skills/nm-memory-intake/SKILL.md +135 -0
  16. package/skills/skills/nm-memory-sync/SKILL.md +184 -0
  17. package/skills/smali-to-kotlin/SKILL.md +331 -85
  18. package/skills/smali-to-kotlin/phase-0-discovery.md +93 -94
  19. package/skills/smali-to-kotlin/phase-1-architecture.md +67 -58
  20. package/skills/smali-to-kotlin/phase-2-blueprint.md +228 -0
  21. package/skills/smali-to-kotlin/phase-3-build.md +248 -0
  22. package/skills/smali-to-kotlin/templates/app-map.md +101 -0
  23. package/skills/smali-to-kotlin/templates/architecture.md +142 -0
  24. package/skills/smali-to-kotlin/templates/blueprint.md +145 -0
  25. package/skills/smali-to-swift/SKILL.md +532 -91
  26. package/skills/smali-to-swift/phase-0-discovery.md +101 -118
  27. package/skills/smali-to-swift/phase-1-architecture.md +62 -67
  28. package/skills/smali-to-swift/phase-2-blueprint.md +173 -0
  29. package/skills/smali-to-swift/phase-3-build.md +257 -0
  30. package/skills/smali-to-swift/templates/app-map.md +82 -0
  31. package/skills/smali-to-swift/templates/architecture.md +97 -0
  32. package/skills/smali-to-swift/templates/blueprint.md +82 -0
  33. package/skills/workflows/nm-import.md +73 -0
  34. package/skills/workflows/nm-recall.md +67 -0
  35. package/skills/workflows/nm-snapshot.md +69 -0
  36. package/workflows/_uncategorized/nm-import.md +73 -0
  37. package/workflows/_uncategorized/nm-recall.md +67 -0
  38. package/workflows/_uncategorized/nm-snapshot.md +69 -0
  39. package/workflows/_uncategorized/reverse-android-build.md +222 -0
  40. package/workflows/_uncategorized/reverse-android-design.md +139 -0
  41. package/workflows/_uncategorized/reverse-android-discover.md +150 -0
  42. package/workflows/_uncategorized/reverse-android-scan.md +158 -0
  43. package/workflows/_uncategorized/reverse-android.md +143 -0
  44. package/workflows/_uncategorized/reverse-ios-build.md +240 -0
  45. package/workflows/_uncategorized/reverse-ios-design.md +112 -0
  46. package/workflows/_uncategorized/reverse-ios-discover.md +120 -0
  47. package/workflows/_uncategorized/reverse-ios-scan.md +155 -0
  48. package/workflows/_uncategorized/reverse-ios.md +152 -0
  49. package/skills/adaptive-language/SKILL.md +0 -189
  50. package/skills/ambient-brain/SKILL.md +0 -314
  51. package/skills/ambient-brain/brain-router.md +0 -185
  52. package/skills/ambient-brain/brain-templates.md +0 -201
  53. package/skills/context-help/SKILL.md +0 -180
  54. package/skills/error-translator/SKILL.md +0 -153
  55. package/skills/session-restore/SKILL.md +0 -240
@@ -0,0 +1,150 @@
1
+ ---
2
+ description: 🗺️ RE Android Phase 0 — Discovery & App Map (NO CODE output)
3
+ parent: reverse-android
4
+ ---
5
+
6
+ # /re-android-discover — Discovery & App Map
7
+
8
+ > **Parent:** [`/reverse-android`](reverse-android.md) → Phase 0
9
+ > **Skill:** `smali-to-kotlin` → `phase-0-discovery.md`
10
+ > **Zoom Level:** 0 — Satellite View
11
+ > **Output:** App Map (diagrams, tables, NO CODE)
12
+
13
+ ---
14
+
15
+ ## ⛔ ZOOM 0 RULE
16
+
17
+ ```
18
+ This workflow produces NO CODE output.
19
+ Only: diagrams, tables, bullet lists, bash scan commands.
20
+ If you are about to write Kotlin code → STOP → you are at wrong zoom level.
21
+ ```
22
+
23
+ ---
24
+
25
+ ## 📦 Step 0: Library Scanner
26
+
27
+ > Nhận diện toàn bộ thư viện **trước khi làm bất kỳ thứ gì**.
28
+
29
+ ### 0.1: Quét structure
30
+
31
+ ```bash
32
+ # Top-level packages
33
+ find [apktool_dir]/smali -maxdepth 3 -type d | sed 's|.*/smali/||' | sort
34
+
35
+ # Multi-dex check
36
+ find [apktool_dir] -name "smali*" -maxdepth 1 -type d
37
+
38
+ # Resource counts
39
+ ls [apktool_dir]/res/layout/ 2>/dev/null | wc -l
40
+ ls [apktool_dir]/res/drawable*/ 2>/dev/null | wc -l
41
+
42
+ # Native + Assets
43
+ find [apktool_dir]/lib -name "*.so" 2>/dev/null
44
+ ls [apktool_dir]/assets/ 2>/dev/null
45
+ ```
46
+
47
+ ### 0.2: Phân loại thư viện
48
+
49
+ Dùng patterns từ `library-patterns.md`, phân thành 5 nhóm:
50
+
51
+ | Category | Example | Action |
52
+ |----------|---------|--------|
53
+ | ✅ Reuse | Retrofit, OkHttp | Add to build.gradle |
54
+ | 🔄 Replace | Volley, AsyncTask | Map to modern |
55
+ | 🔵 Google/Firebase | FCM, Analytics | Use latest |
56
+ | 📱 Native | .so files | Keep, JNI bridge |
57
+ | 🏷️ App Code | com.app.* | Rebuild |
58
+
59
+ ### 0.3: User approval
60
+
61
+ > **GATE:** Hiển thị Library Report → User approve trước khi tiếp.
62
+
63
+ ---
64
+
65
+ ## 📄 Step 1: Manifest Analysis
66
+
67
+ ```bash
68
+ cat [apktool_dir]/AndroidManifest.xml
69
+ ```
70
+
71
+ ### 1.1: Trích xuất
72
+
73
+ - Application ID + Package name
74
+ - Min/Target SDK
75
+ - Permissions (phân nhóm: network, storage, camera, location, other)
76
+ - Entry points: Application class, Launcher Activity, MainActivity
77
+ - Components: Activities (→ future screens), Services, Receivers, Providers
78
+ - Deep links / Intent filters
79
+
80
+ ### 1.2: Screen Map
81
+
82
+ Map Activities → future Compose screens:
83
+
84
+ ```
85
+ SplashActivity → presentation/screens/splash/
86
+ LoginActivity → presentation/screens/auth/
87
+ MainActivity → presentation/screens/main/
88
+ DetailActivity → presentation/screens/detail/
89
+ SettingsActivity → presentation/screens/settings/
90
+ ```
91
+
92
+ Draw navigation flow (ASCII or Mermaid).
93
+
94
+ ### 1.3: Complexity Estimate
95
+
96
+ | Area | Rating | Notes |
97
+ |------|--------|-------|
98
+ | Data Layer | ●●●○○ | [evidence] |
99
+ | Core Logic | ●●○○○ | [evidence] |
100
+ | UI Screens | ●●●●○ | [evidence] |
101
+ | SDK Integration | ●●○○○ | [evidence] |
102
+
103
+ ---
104
+
105
+ ## 📊 Output: App Map
106
+
107
+ Sử dụng template từ `skills/smali-to-kotlin/templates/app-map.md`:
108
+
109
+ ```markdown
110
+ ## 🗺️ App Map: [App Name]
111
+
112
+ ### Identity
113
+ [package, SDK, counts]
114
+
115
+ ### Screen Flow
116
+ [navigation graph]
117
+
118
+ ### Library Landscape
119
+ [categorized table]
120
+
121
+ ### Complexity Estimate
122
+ [rating dots]
123
+
124
+ ### Key Observations
125
+ [notable findings]
126
+ ```
127
+
128
+ ---
129
+
130
+ ## ✅ Gate: Chuyển sang Phase 1
131
+
132
+ ```
133
+ "🗺️ App Map xong! Anh review map này.
134
+ Có gì cần điều chỉnh không? OK → em sẽ thiết kế Architecture."
135
+
136
+ → User approves → /re-android-design (Phase 1)
137
+ → User has questions → investigate và update map
138
+ ```
139
+
140
+ ---
141
+
142
+ ## 🔗 Related
143
+
144
+ - **Next:** [`/re-android-design`](reverse-android-design.md) (Phase 1: Architecture)
145
+ - **Parent:** [`/reverse-android`](reverse-android.md)
146
+ - **Skill reference:** `skills/smali-to-kotlin/phase-0-discovery.md`
147
+
148
+ ---
149
+
150
+ *re-android-discover v3.0.0 — Phase 0: Discovery & App Map*
@@ -0,0 +1,158 @@
1
+ ---
2
+ description: 📦 RE Android Phase 1 — Library Scanner + Manifest Analysis + Project Bootstrap
3
+ parent: reverse-android
4
+ ---
5
+
6
+ # /re-android-scan — Library Scanner & Manifest Analysis
7
+
8
+ > **Parent:** [`/reverse-android`](reverse-android.md) → Step 0 + Step 1
9
+ > **Skill:** `smali-to-kotlin` | **Reference:** `skills/smali-to-kotlin/library-patterns.md`
10
+
11
+ ---
12
+
13
+ ## 📦 Step 0: Library Scanner (BẮT BUỘC)
14
+
15
+ > Nhận diện toàn bộ thư viện **trước khi code bất kỳ thứ gì**.
16
+
17
+ ### 0.3: Quét Smali directories
18
+
19
+ ```bash
20
+ # Top-level packages
21
+ find [apktool_dir]/smali -maxdepth 3 -type d | sed 's|[apktool_dir]/smali/||' | sort
22
+
23
+ # Multi-dex
24
+ find [apktool_dir] -name "smali*" -maxdepth 1 -type d
25
+ find [apktool_dir]/smali_classes2 -maxdepth 3 -type d 2>/dev/null | sort
26
+
27
+ # Native libraries & Assets
28
+ find [apktool_dir]/lib -name "*.so" 2>/dev/null
29
+ ls [apktool_dir]/assets/ 2>/dev/null
30
+ ```
31
+
32
+ ### 0.4: Tạo Library Detection Report
33
+
34
+ Dùng patterns từ `library-patterns.md`, phân loại:
35
+
36
+ ```markdown
37
+ ## 📦 Library Detection Report — [App Name]
38
+
39
+ ### ✅ Reuse (build.gradle)
40
+ | Library | Package Detected | Version | Notes |
41
+ |---------|-----------------|---------|-------|
42
+ | Retrofit | com/squareup/retrofit2 | 2.9.0 | Keep |
43
+ | OkHttp | com/squareup/okhttp3 | 4.12.0 | Keep |
44
+
45
+ ### 🔄 Replace (Legacy → Modern)
46
+ | Old Library | Detected | Replacement |
47
+ |-------------|----------|-------------|
48
+ | Volley | com/android/volley | Retrofit + OkHttp |
49
+ | AsyncTask | android.os.AsyncTask | Coroutines |
50
+
51
+ ### 🔵 Firebase/Google SDKs
52
+ | SDK | Detected | Action |
53
+ |-----|----------|--------|
54
+
55
+ ### 📱 Native (.so) — Giữ nguyên
56
+ | File | Architecture | Notes |
57
+ |------|-------------|-------|
58
+
59
+ ### 🏷️ App Code (Rebuild in Kotlin)
60
+ | Package | Module |
61
+ |---------|--------|
62
+
63
+ ### ❓ Unknown (Cần điều tra)
64
+ | Package | Path | Possible |
65
+ |---------|------|----------|
66
+ ```
67
+
68
+ ### 0.5: User approval
69
+
70
+ > **GATE:** Không tiếp tục Step 1 khi chưa có user approval report.
71
+
72
+ ---
73
+
74
+ ## 📄 Step 1: AndroidManifest Analysis & Project Bootstrap
75
+
76
+ > **Input:** `[apktool_dir]/AndroidManifest.xml`
77
+
78
+ ### 1.1: Phân tích Manifest
79
+
80
+ Trích xuất:
81
+
82
+ ```yaml
83
+ extract:
84
+ - application_id, package_name
85
+ - min_sdk, target_sdk
86
+ - permissions: [network, storage, camera, location, other]
87
+ - entry_points: [application_class, splash_activity, main_activity]
88
+ - components: [activities, services, receivers, providers]
89
+ - deep_links, features
90
+ ```
91
+
92
+ ### 1.2: Đề xuất project structure
93
+
94
+ Mapping activities → Compose screens (xem SKILL.md Step 1):
95
+
96
+ ```
97
+ SplashActivity → presentation/screens/splash/SplashScreen.kt
98
+ MainActivity → presentation/screens/main/MainScreen.kt
99
+ LoginActivity → presentation/screens/auth/LoginScreen.kt
100
+ ```
101
+
102
+ ### 1.3: Tạo `build.gradle.kts` skeleton
103
+
104
+ ```kotlin
105
+ plugins {
106
+ alias(libs.plugins.android.application)
107
+ alias(libs.plugins.kotlin.android)
108
+ alias(libs.plugins.kotlin.compose)
109
+ alias(libs.plugins.hilt.android)
110
+ alias(libs.plugins.ksp)
111
+ alias(libs.plugins.kotlin.serialization)
112
+ }
113
+
114
+ android {
115
+ namespace = "[package_name]"
116
+ compileSdk = [target_sdk]
117
+ defaultConfig {
118
+ applicationId = "[application_id]"
119
+ minSdk = [min_sdk]
120
+ targetSdk = [target_sdk]
121
+ }
122
+ buildFeatures { compose = true; buildConfig = true }
123
+ }
124
+
125
+ dependencies {
126
+ // Compose BOM + Material3 + Navigation
127
+ // Coroutines + Hilt DI
128
+ // Network: Retrofit + OkHttp (từ Library Report)
129
+ // Local: Room + DataStore
130
+ // Image: Coil + Logging: Timber
131
+ // [Thêm libs từ "Reuse" section]
132
+ }
133
+ ```
134
+
135
+ ### ✅ Checkpoint Step 1
136
+
137
+ ```markdown
138
+ ## ✅ Step 1 Complete
139
+
140
+ - Package: [package_name]
141
+ - Entry points: [list]
142
+ - Screens to rebuild: [list]
143
+
144
+ ⏭️ Next: `/re-android-build` — Step 2 (Data Layer)
145
+ Cung cấp Smali: smali/[package]/network/, model/, data/
146
+ ```
147
+
148
+ ---
149
+
150
+ ## 🔗 Related
151
+
152
+ - **Next:** [`/re-android-build`](reverse-android-build.md) (Step 2-6)
153
+ - **Parent:** [`/reverse-android`](reverse-android.md)
154
+ - **Library patterns:** `skills/smali-to-kotlin/library-patterns.md`
155
+
156
+ ---
157
+
158
+ *re-android-scan v2.0.0 — Phase 1: Discovery & Bootstrap*
@@ -0,0 +1,143 @@
1
+ ---
2
+ description: 🔧 Dịch ngược APK Android (Apktool output) → App Kotlin hiện đại với Jetpack Compose, Clean Architecture, và UI-First methodology.
3
+ skill: smali-to-kotlin
4
+ ---
5
+
6
+ # /reverse-android — Android APK Reverse Engineering Workflow
7
+
8
+ > **Skill:** `smali-to-kotlin` v2.0 | **Tech:** Kotlin + Compose + Hilt + Retrofit + Room
9
+ > **Philosophy:** "Map → Blueprint → UI First → Logic Behind"
10
+ > **Key:** UI is designed and approved BEFORE coding any business logic.
11
+
12
+ ---
13
+
14
+ ## ⚡ QUICK START
15
+
16
+ User cung cấp: Apktool output dir, `AndroidManifest.xml`, hoặc nói "reverse engineer APK này".
17
+ Workflow dẫn dắt qua **5 phases** — UI-First approach, **không bao giờ nhảy cóc**.
18
+
19
+ ---
20
+
21
+ ## 🔵 Session Setup
22
+
23
+ ### Bước 0.1: Khởi tạo session state
24
+
25
+ ```yaml
26
+ reverse_session:
27
+ project_name: "[TBD - từ manifest]"
28
+ apktool_dir: "[path]"
29
+ current_phase: 0
30
+ current_feature: null
31
+ phase_2_status:
32
+ contracts: pending
33
+ ui_shell: pending
34
+ resources: pending
35
+ completed_features: []
36
+ pending_features: []
37
+ decisions: []
38
+ ```
39
+
40
+ ### Bước 0.2: Xác nhận input
41
+
42
+ ```
43
+ 🔧 Android Reverse Engineering v2.0 — UI-First Pipeline
44
+
45
+ Em cần biết:
46
+ 1. Thư mục Apktool output ở đâu?
47
+ 2. Tên app gốc? Package name?
48
+
49
+ Chưa chạy Apktool? → apktool d your-app.apk -o ./decompiled/
50
+ ```
51
+
52
+ ---
53
+
54
+ ## 📋 Pipeline Overview (5 Phases — UI-First)
55
+
56
+ | Phase | Name | Sub-workflow | Code? | Gate |
57
+ |-------|------|-------------|-------|------|
58
+ | 0 | 🗺️ Discovery | [`/re-android-discover`](reverse-android-discover.md) | ❌ | User approves Map |
59
+ | 1 | 🏗️ Architecture | [`/re-android-design`](reverse-android-design.md) | ❌ | User approves Architecture |
60
+ | 2 | 📐🎨 Blueprint + UI | [`/re-android-build`](reverse-android-build.md) | UI code | User approves UI + Contracts |
61
+ | 3 | 🔨 Logic Build | [`/re-android-build`](reverse-android-build.md) | Full logic | Feature checkpoint |
62
+ | 4 | ✅ Final Parity | [`/re-android-build`](reverse-android-build.md) | — | Final check |
63
+
64
+ ### Execution Flow
65
+
66
+ ```
67
+ Session Setup
68
+
69
+ Phase 0: Discovery (/re-android-discover) → App Map
70
+ ↓ [User approves]
71
+ Phase 1: Architecture (/re-android-design) → Architecture Blueprint
72
+ ↓ [User approves + picks feature]
73
+ Feature Loop (/re-android-build):
74
+ Phase 2: Blueprint + UI (contracts + visual shell + resources)
75
+ ↓ 🚦 GATE: User approves UI + contracts
76
+ Phase 3: Logic Build (domain → data → DI → VM → wire UI)
77
+ ↓ 📊 CHECKPOINT: Feature done
78
+ → Repeat for next feature
79
+
80
+ Phase 4: Final Parity Check & Quality Gate
81
+ ```
82
+
83
+ ---
84
+
85
+ ## 🔭 ZOOM CONTROL
86
+
87
+ ```yaml
88
+ pre_output_check:
89
+ - "Đang ở phase nào?"
90
+ - "Output có đúng phase rule không?"
91
+ - "Phase 0/1: NO CODE BODIES"
92
+ - "Phase 2: UI code + signatures (no logic bodies)"
93
+ - "Phase 3: Full implementation code"
94
+
95
+ phase_rules:
96
+ phase_0: "NO CODE. Only diagrams, tables, maps."
97
+ phase_1: "NO CODE BODIES. Only architecture diagrams, file lists."
98
+ phase_2_contracts: "SIGNATURES ONLY. Interfaces, data classes, sealed classes."
99
+ phase_2_ui: "FULL UI CODE. Compose with hardcoded mock data + @Preview."
100
+ phase_3: "FULL LOGIC CODE. Domain → Data → DI → VM → Wire UI."
101
+ ```
102
+
103
+ ---
104
+
105
+ ## 🚫 WORKFLOW RULES
106
+
107
+ ```yaml
108
+ never_skip:
109
+ - Phase 0 (Discovery) — always first
110
+ - Phase 1 (Architecture) — design before coding
111
+ - Phase 2 UI Gate — user MUST approve UI before Phase 3
112
+ - Per-feature Blueprint before Logic Build
113
+
114
+ never_do:
115
+ - Write logic code before UI is approved
116
+ - Mass-copy resources from APK (on-demand only)
117
+ - Implement multiple features simultaneously
118
+ - Modify UI significantly in Phase 3 (only wire, don't redesign)
119
+ - Skip crypto parity check
120
+
121
+ always_do:
122
+ - Extract resources BEFORE coding UI (Phase 2.7 → 2.8)
123
+ - Create @Preview for ALL states
124
+ - Keep stateless composable (LoginScreenContent) after wiring
125
+ - Checkpoint after each feature
126
+ - Document all decisions
127
+ ```
128
+
129
+ ---
130
+
131
+ ## 🔗 Related
132
+
133
+ - **Sub-workflows:**
134
+ - [`/re-android-discover`](reverse-android-discover.md) — Phase 0: Discovery
135
+ - [`/re-android-design`](reverse-android-design.md) — Phase 1: Architecture
136
+ - [`/re-android-build`](reverse-android-build.md) — Phase 2+3+4: Blueprint + UI + Build
137
+ - **Skill:** `smali-to-kotlin` v2.0 (UI-First pipeline)
138
+ - **Sibling:** `/reverse-ios` (iOS counterpart)
139
+ - **After RE done:** `/test`, `/deploy`, `/code-janitor`
140
+
141
+ ---
142
+
143
+ *reverse-android workflow v4.0.0 — UI-First RE Pipeline*
@@ -0,0 +1,240 @@
1
+ ---
2
+ description: 🔨 RE iOS Phase 2+3+4 — Blueprint + UI Shell → Logic Build → Final Parity (UI-First)
3
+ parent: reverse-ios
4
+ ---
5
+
6
+ # /re-ios-build — Blueprint + UI + Build (Per Feature)
7
+
8
+ > **Parent:** [`/reverse-ios`](reverse-ios.md) → Phase 2+3+4
9
+ > **Prerequisite:** Completed Architecture from [`/re-ios-design`](reverse-ios-design.md)
10
+ > **Skill:** `smali-to-swift` → `phase-2-blueprint-ui.md` + `phase-3-logic-build.md`
11
+
12
+ ---
13
+
14
+ ## 🔄 Feature Loop (UI-First)
15
+
16
+ ```
17
+ For each feature (from Architecture Build Order):
18
+ Phase 2: Blueprint + UI (contracts + visual shell)
19
+ ↓ 🚦 GATE: User approves UI + contracts
20
+ Phase 3: Logic Build (domain → data → wire)
21
+ ↓ 📊 CHECKPOINT
22
+ → Next feature
23
+ ```
24
+
25
+ ---
26
+
27
+ ## 📐🎨 Phase 2: Blueprint + UI Design
28
+
29
+ > **Output:** Approved contracts + Working SwiftUI shell with mock data.
30
+
31
+ ### Part A: Contracts (signatures only)
32
+
33
+ #### 2.1: Deep Header Reading
34
+ Read class-dump headers + Hopper pseudo-code. See `objc-reading-guide.md`.
35
+
36
+ **ObjC → Swift Quick Ref:**
37
+ ```
38
+ @property (copy) NSString *name → let name: String
39
+ @property (assign) BOOL active → let active: Bool
40
+ - (void)fetchWith:(block)completion → func fetch() async throws -> T
41
+ + (instancetype)sharedInstance → static let shared
42
+ ```
43
+
44
+ #### 2.2–2.5: Define Contracts
45
+ ```swift
46
+ // 2.2 Domain Model
47
+ struct [Model]: Codable, Identifiable, Sendable {
48
+ let field: Type
49
+ }
50
+
51
+ // 2.3 Repository Protocol
52
+ protocol [Feature]Repository: Sendable {
53
+ func [method](...) async throws -> [Type]
54
+ }
55
+
56
+ // 2.4 API Endpoint
57
+ enum [Feature]Endpoint {
58
+ case [action](param: Type)
59
+ var path: String { /* ... */ }
60
+ }
61
+
62
+ // 2.5 UseCase
63
+ struct [Action]UseCase {
64
+ func execute(...) async throws -> [Type] // TODO
65
+ }
66
+ ```
67
+
68
+ #### 2.6: UI State Design
69
+ ```swift
70
+ struct [Screen]ViewState {
71
+ var field: Type = default
72
+ var isLoading: Bool = false
73
+ var error: String? = nil
74
+ }
75
+ enum [Screen]Action { /* user interactions */ }
76
+ enum [Screen]Event { /* navigation, alerts */ }
77
+
78
+ extension [Screen]ViewState {
79
+ static let normal = [Screen]ViewState(/* sample */)
80
+ static let loading = [Screen]ViewState(isLoading: true)
81
+ static let error = [Screen]ViewState(error: "Error message")
82
+ }
83
+ ```
84
+
85
+ ### Part B: UI Visual Shell
86
+
87
+ #### 2.7: Resource Extraction ⭐ (BEFORE UI code!)
88
+
89
+ Extract from IPA bundle / Assets.car:
90
+ - Images → Assets.xcassets
91
+ - Colors → Color extension or asset catalog
92
+ - Strings → Localizable.xcstrings
93
+ - Fonts → custom fonts
94
+
95
+ Copy ONLY needed resources. Verify they build.
96
+
97
+ #### 2.8: UI Implementation ⭐ (Visual shell with mock data)
98
+
99
+ - Use ViewState from 2.6 with hardcoded defaults
100
+ - Use REAL resources from 2.7
101
+ - Create `[Screen]Content` view (stateless)
102
+ - Match visual parity with original app
103
+ - NO ViewModel connection, NO real API calls
104
+
105
+ ```swift
106
+ struct [Screen]Content: View {
107
+ var state: [Screen]ViewState = .normal // Mock
108
+ var onAction: ([Screen]Action) -> Void = { _ in } // No-op
109
+
110
+ var body: some View {
111
+ // Full SwiftUI matching original app
112
+ }
113
+ }
114
+
115
+ #Preview("Normal") { [Screen]Content(state: .normal) }
116
+ #Preview("Loading") { [Screen]Content(state: .loading) }
117
+ #Preview("Error") { [Screen]Content(state: .error) }
118
+ ```
119
+
120
+ #### 2.9: Visual Parity Check ⭐
121
+
122
+ Compare with original app:
123
+ - [ ] Layout structure matches
124
+ - [ ] Colors, typography, spacing correct
125
+ - [ ] Icons/images positioned correctly
126
+ - [ ] All states: normal, loading, error, empty
127
+
128
+ ### 🚦 UI + Contracts Gate (MANDATORY)
129
+
130
+ ```
131
+ "📐🎨 Blueprint + UI cho [Feature] xong:
132
+ 📝 Contracts: [N] models, [N] protocols, [N] use cases, [N] endpoints
133
+ 🎨 UI: [Screen] with [N] state previews
134
+ 📸 Visual Parity: [OK / needs adjustment]
135
+
136
+ → ✅ Approve → Phase 3 (Logic Build)
137
+ → 🎨 Adjust UI → fix then re-check
138
+ → 📝 Adjust contracts → revise"
139
+ ```
140
+
141
+ > ⚠️ **DO NOT proceed to Phase 3 without user approval.**
142
+
143
+ ---
144
+
145
+ ## 🔨 Phase 3: Logic Build
146
+
147
+ > **Output:** Full Swift code. Wire logic to EXISTING UI.
148
+
149
+ ### 3.1: Domain Layer
150
+ Models + Repository protocols + UseCases (implement with repo calls)
151
+
152
+ ### 3.2: Data Layer
153
+ DTOs + APIClient endpoints + SwiftData (if applicable) + Repository implementation
154
+
155
+ ### 3.3: DI Container
156
+ AppContainer with lazy properties for repos, use cases, view models
157
+
158
+ ### 3.4: ViewModel
159
+ @Observable with state property + handle(_ action:) + event handler
160
+
161
+ ### 3.5: Wire UI ↔ Logic ⭐ (NOT "code new UI")
162
+
163
+ The UI already exists from Phase 2.8. Only CONNECT it:
164
+
165
+ ```swift
166
+ // Keep stateless Content view from Phase 2 (for Preview):
167
+ // [Screen]Content(state:, onAction:) — DO NOT MODIFY
168
+
169
+ // ADD wrapper that wires ViewModel:
170
+ struct [Screen]: View {
171
+ @State private var viewModel: [Screen]ViewModel
172
+
173
+ init(container: AppContainer) {
174
+ _viewModel = State(initialValue: container.make[Screen]ViewModel())
175
+ }
176
+
177
+ var body: some View {
178
+ [Screen]Content(
179
+ state: viewModel.state,
180
+ onAction: viewModel.handle
181
+ )
182
+ }
183
+ }
184
+ ```
185
+
186
+ ### 3.6: Integration Test ⭐
187
+ - [ ] API calls succeed, data displays
188
+ - [ ] Loading/error states work
189
+ - [ ] Navigation correct
190
+ - [ ] Crypto output matches (if applicable)
191
+
192
+ ### 🔒 Crypto (Special)
193
+ ```swift
194
+ import CryptoKit
195
+ import CommonCrypto
196
+ // XCTest mandatory for crypto utils
197
+ ```
198
+ > ⚠️ Crypto MUST match original output.
199
+
200
+ ### ✅ Feature Checkpoint
201
+
202
+ ```markdown
203
+ ## ✅ Feature Complete: [Name]
204
+ Files: [list] | Resources: [count] | Tests: [status]
205
+ ⏭️ Next Feature: [Name] → Return to Phase 2
206
+ ```
207
+
208
+ ---
209
+
210
+ ## ✅ Phase 4: Final Parity Check (After ALL features)
211
+
212
+ ### Checklist
213
+ - [ ] API Parity — all endpoints match
214
+ - [ ] Data/Crypto Parity — output identical
215
+ - [ ] UI Parity — screen-by-screen comparison
216
+ - [ ] Edge Cases — empty, error, offline, lifecycle
217
+ - [ ] Build: `xcodebuild build && xcodebuild test`
218
+
219
+ ### 🎉 Final Summary
220
+
221
+ ```markdown
222
+ ## ✅ Reverse Engineering Complete!
223
+ - Screens: [N] | Features: [N]
224
+ - Frameworks reused: [N] | Replaced: [N]
225
+ - Tests: [pass/fail]
226
+
227
+ ⏭️ Next: /test → /deploy → /code-janitor
228
+ ```
229
+
230
+ ---
231
+
232
+ ## 🔗 Related
233
+
234
+ - **Parent:** [`/reverse-ios`](reverse-ios.md)
235
+ - **Previous:** [`/re-ios-design`](reverse-ios-design.md) (Phase 1)
236
+ - **Skill:** `smali-to-swift` → `phase-2-blueprint-ui.md` + `phase-3-logic-build.md`
237
+
238
+ ---
239
+
240
+ *re-ios-build v4.0.0 — UI-First Blueprint + Build*