### Start Metro Server Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/CONTRIBUTING.md Run the Metro server to prepare for app development. Use `yarn start:reset` to ensure a clean start. ```bash yarn start:reset ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/README.md Install project dependencies using Yarn. Ensure Node.js (v18+) and Yarn are installed. ```bash yarn install ``` -------------------------------- ### Clone PocketPal AI Repository Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/README.md Clone the repository to start development. Ensure you have Git installed. ```bash git clone https://github.com/a-ghorbani/pocketpal-ai cd pocketpal-ai ``` -------------------------------- ### Install Dependencies Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/README.md Install project dependencies for end-to-end testing. ```bash cd e2e yarn install ``` -------------------------------- ### Setup Multi-Device Inventory Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/README.md Instructions for setting up the `devices.json` file required for the `--each-device` flag. This involves copying a template and editing it with actual device information. ```bash cp devices.template.json devices.json ``` -------------------------------- ### Start Metro Bundler Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/README.md Start the Metro bundler, which is necessary for running React Native applications. ```bash yarn start ``` -------------------------------- ### List Available Device Pools Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/DEVICE-POOLS.md Command to display all configured device pools. Useful for debugging and verifying pool setup. ```bash yarn crash-repro --list-pools ``` -------------------------------- ### Install iOS Pod Dependencies Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/README.md Install CocoaPods dependencies for iOS development. Run this command after installing Node.js dependencies. ```bash cd ios pod install cd .. ``` -------------------------------- ### Include React Native Application Setup Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/android/app/src/main/jni/CMakeLists.txt Includes the React Native CMake utility script to enable autolinking, TurboModule registration, and prefab linkage to libreactnative.so. This is crucial for the application to boot correctly. ```cmake include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake) ``` -------------------------------- ### Build and Install E2E Android Flavor Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/README.md Commands to build the E2E flavor of the Android app and install it on a device. This flavor is debuggable and required for the preseed workflow. ```bash yarn android:build:e2e adb install -r android/app/build/outputs/apk/e2e/releaseE2e/app-e2e-releaseE2e.apk ``` -------------------------------- ### Filter Benchmark Matrix Configuration Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/README.md Narrow down the benchmark tier by specifying models and quantizations. This command assumes the E2E-flavor APK is installed. ```bash BENCH_TIER=full BENCH_MODELS=qwen3.5-2b BENCH_QUANTS=q4_0,q6_k yarn build:bench-config ``` -------------------------------- ### E2E Benchmark Runner Screen Activation Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/src/__automation__/README.md This example shows how the `BenchmarkRunnerScreen` is activated via a deep link. It highlights the URL format `pocketpal://e2e/benchmark` used for navigation and mentions its registration in the Android manifest. ```typescript case 'e2e/benchmark': return navigation.navigate('BenchmarkRunnerScreen'); ``` -------------------------------- ### Find Device UDIDs for Multi-Device Setup Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/README.md Commands to find device UDIDs for both iOS and Android, which are necessary for configuring `devices.json` for multi-device testing. ```bash # iOS xcrun xctrace list devices ``` ```bash # Android adb devices -l ``` -------------------------------- ### Expected Validation for Memory Residency Hazard Sweep Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/baselines/benchmark/SWEEP-PLAN.md This example illustrates the expected memory behavior (PSS_post_load) for different combinations of mmap and repack settings on the Android CPU path. It highlights the hazard scenario where mmap=true and repack=ON can lead to approximately double the memory usage compared to weights_mib, and safe scenarios where memory usage is around 1x. ```text qwen3-1.7b q4_0 cpu mmap=true repack=ON → PSS_post_load ≈ 2× weights_mib (HAZARD) mmap=true repack=OFF → PSS_post_load ≈ 1× weights_mib (SAFE) mmap=false repack=ON → PSS_post_load ≈ 1× weights_mib (slow load, safe) mmap=false repack=OFF → PSS_post_load ≈ 1× weights_mib (slow load, safe) ``` -------------------------------- ### Build Android E2E APK Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/README.md Builds the E2E flavor of the Android application. This APK includes the automation bridge and installs side-by-side with the production app. ```bash # Android E2E APK (required — prod APK has no automation bridge) yarn android:build:e2e # Installs as com.pocketpalai.e2e and coexists side-by-side with the # prod install (com.pocketpalai). E2E_BUILD=true is set automatically # so the automation bridge (src/__automation__/) ships in this APK. ``` -------------------------------- ### Add Custom Source Files Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/android/app/src/main/jni/CMakeLists.txt Explicitly adds custom C++ source files to the target. This is done after including the React Native setup to avoid conflicts with the default template's file globbing. ```cmake target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/hardware_info.cpp) ``` -------------------------------- ### Run Benchmark Matrix Config Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/README.md Generate configuration for the benchmark matrix and push it to the device. Supports specifying a tier and a specific device UDID. ```bash # 1. Generate config + adb push to device BENCH_TIER=smoke yarn build:bench-config --push # default device BENCH_TIER=full yarn build:bench-config --push # specific device ``` -------------------------------- ### Run Benchmark with Preseeded Models Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/README.md Execute the benchmark matrix while skipping model downloads by setting the `MODELS_PRESEEDED` environment variable to `1`. This assumes models are already available on the device. ```bash # Preseeded mode (see "Preseed workflow" below) MODELS_PRESEEDED=1 yarn e2e --platform android --spec benchmark-matrix --skip-build ``` -------------------------------- ### List Available E2E Models Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/README.md List all available models that can be used for end-to-end testing and then exit. This is useful for understanding the testing scope. ```bash yarn e2e --list-models ``` -------------------------------- ### Run App on iOS Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/CONTRIBUTING.md Execute the command to run the application on an iOS simulator or device. ```bash yarn ios ``` -------------------------------- ### Run Full Benchmark Matrix on Android Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/README.md Execute the complete benchmark matrix on a connected Android device. This command may take 25-45 minutes. `--skip-build` is recommended if the project is already built. ```bash # Full matrix on the currently connected Android device (~25-45 min) yarn e2e --platform android --spec benchmark-matrix --skip-build ``` -------------------------------- ### Run App on Android Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/CONTRIBUTING.md Execute the command to run the application on an Android emulator or device. ```bash yarn android ``` -------------------------------- ### Initialize CMake and Project Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/android/app/src/main/jni/CMakeLists.txt Sets the minimum CMake version required and defines the project name, which is expected by React Native's SoLoader for library mapping. ```cmake cmake_minimum_required(VERSION 3.13) project(appmodules) ``` -------------------------------- ### Launch Benchmark Runner via Deep Link Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/e2e/README.md Cold-launch the benchmark runner application using a deep link. This command is for Android devices. ```bash # 2. Cold-launch the runner via deep link adb shell am start -a android.intent.action.VIEW \ -d 'pocketpal://e2e/benchmark' -p com.pocketpalai.e2e ``` -------------------------------- ### Memory Adapter Commands Source: https://github.com/a-ghorbani/pocketpal-ai/blob/main/src/__automation__/README.md This table lists the commands supported by the `MemoryAdapter` for memory profiling. These commands are used by the `memory-profile` spec to interact with the E2E automation bridge. ```markdown | Adapter | Purpose | |---|---| | `MemoryAdapter` | Memory profile snapshots for the `memory-profile` spec | `snap::