Skip to content

About

Android AI agent client built on the Pi SDK — clean offline chat, local coding, MCP & terminal | 手机上的 AI Agent:聊天好看,动手也行

Topics

Resources

Stars

25 stars

Watchers

1 watching

Forks

Repository files navigation

简体中文 · English

Pi for Android

An AI agent on your phone: clean chat, ready to build

A third-party Android client built on the official Pi SDK (@earendil-works/pi-coding-agent). Not affiliated with the official Pi team.

Latest Release Total Downloads CI Status GitHub Stars MIT License Android 8.0+ arm64

Download Latest APK · Install · FAQ

Pi for Android chat interface rendering Markdown tables, MathJax equations, Mermaid diagrams, and highlighted code

16-second demo of Pi for Android streaming a Markdown table, MathJax formula, code block, and queued follow-up
16-second demo: streaming layout, offline math, and message queueing (MP4 video).

Just Chat · Make It Build · Under the Hood

What It Is

  • For everyday chat: Use it as a clean, vendor-neutral chat app with your own model accounts or keys and local history on your phone.
  • When you need action: Inside the same conversation, open a project folder on your device so the agent can read files, edit code with diffs, and run tests or terminal commands.
  • For tinkerers and developers: Install Pi extensions, connect external tool servers, switch container runtimes, or build straight from source.

Clean, Offline Reading

You get offline rendering for Markdown, tables, math formulas, diagrams, and syntax-highlighted code, with steady streaming that avoids scroll jitter. Long replies open into a dedicated copy view for free text selection or block-by-block copying.

Offline MathJax equations, Mermaid diagrams, syntax-highlighted code, and full-screen Copy Studio

Your Models, Your History

Sign in directly with OAuth subscription accounts, add your own API keys, or point to a self-hosted compatible endpoint. Adjust thinking depth and context usage right from the composer, with conversations stored locally as files that support branching and export.

Model and provider picker, thinking depth and context ring controls, and /tree session branching

Hands-On When Needed

A ready-to-use local Linux environment with standard developer tools is bundled inside the app. Once you pick a workspace folder, the agent can inspect files, show word-level diffs, and run commands while you jump into the built-in multi-tab terminal anytime.

Tool cards with word-level inline diffs, workspace file explorer, and built-in multi-tab PTY terminal

Full Pi Ecosystem

Because the app runs the official Pi SDK directly, desktop extensions, skills, prompt templates, and ~/.pi directory layouts carry over to mobile. You can connect MCP (Model Context Protocol, a standard for exposing external tools and data sources) servers and use Code Mode to batch multiple tool calls in a single turn.

Extensions and skills management alongside MCP servers and Code Mode orchestration

Optional Device Copilot

All three phone capability groups (System Interaction, Screen Automation, and Device Shell) are disabled by default and consume zero context tokens while off. When enabled, irreversible actions such as sending replies trigger a native three-choice confirmation dialog before execution.

Device capabilities settings with all groups off by default and native three-choice confirmation prompt

Desktop TUI Extensions on Mobile

Many desktop Pi extensions draw text-based panels, progress bars, or status widgets inside a terminal. Pi for Android maps them onto your phone through a Virtual TUI (a rendering layer that turns terminal cell grids into touch-friendly native views) with touch scrolling, clickable links, and extracted quick actions.

Mobile Virtual TUI cell grid panel and floating extension widget above the composer

Comparison

Aspect Cloud Chat Wrappers Termux + CLI pi Pi for Android
Reading & formatting Native UI; math/diagram support varies by vendor Plain terminal text on a narrow screen Native UI with offline math, diagrams, and code
Local files & shell Typically file uploads only; no local runtime Full local environment; manual setup required Bundled Linux runtime and terminal out of the box
Models & history Accounts and chat logs usually cloud-hosted Local storage and bring-your-own models Local storage; OAuth, API keys, and custom endpoints
Desktop Pi TUI extensions Not compatible with Pi extensions Native terminal display; awkward with soft keyboards Virtual TUI projection with touch scroll and action chips
Optional device automation Limited to standard OS share intents Requires manual Termux API or ADB scripts Built-in opt-in bridge, all off by default, confirm prompts

Installation

Requirements: Android 8.0 (API 26) or newer on an arm64-v8a device. No Root and no Termux required.

  1. Download pi-android-*-sideload28-arm64.apk from GitHub Releases and install it.
  2. Open the app and wait briefly while the first launch unpacks the bundled runtime.
  3. Open Settings → Models & Providers, sign in via OAuth or enter an API key, and start chatting (pick a project folder from the top bar menu whenever you want it to edit code).

Choosing a build: pick sideload28 for everyday use (it pins targetSdk 28 so Android 10+ allows executing the unpacked runtime reliably); modern36 is provided for testing targetSdk 36 behavior. Future updates install in place via Settings → App Updates without wiping your conversations or tools.

Frequently Asked Questions

1. Do I need Root or Linux knowledge?

No. If you only want to chat, you never touch a terminal or Linux commands. Picking a project folder is only needed when you ask the agent to read or modify files.

2. Can I use it as a regular chat app and send images?

Yes. It opens straight into a clean chat view. You can attach images from your gallery or file picker (automatically resized to respect your model's image limits), while non-image files are copied into the active workspace for the agent to inspect.

3. Does it support web search?

The app does not bundle a proprietary search proxy. For live web lookup, you can use search capabilities provided by your model vendor, run CLI tools in the local environment, or connect a web-search MCP server or community extension.

4. Where are chats stored, and are they uploaded anywhere?

Sessions (JSONL files), settings, and credentials stay inside the app's local storage (~/.pi/agent/). There is no developer-hosted backend server; prompts go directly from your phone to the model providers or MCP servers you configure.

5. How much storage space does it need?

The APK is around 149 MB (bundling Ubuntu 24.04 ARM64 base, Node.js, Git, ripgrep, fd, and offline math/diagram engines). After first-launch extraction, plan for roughly 1 GB of free space to leave room for unpacked tools and package caches.

6. How do I upgrade without losing data?

Use Settings → App Updates inside the app or install a newer APK of the same build variant (such as sideload28) over the existing installation. Releases share a fixed sideload signing key and only replace changed runtime bundles by checksum, preserving your sessions, settings, workspaces, and installed container packages.

7. Is it compatible with desktop Pi configurations?

Yes. Because it runs the official @earendil-works/pi-coding-agent SDK directly, ~/.pi/agent/, project .pi/ folders, theme JSON files, JSONL sessions, skills, and extensions follow desktop conventions.

8. How should I choose between PRoot, Proroot, and TAWCROOT?

Stick with the default PRoot for broad device compatibility. Proroot (closed-source binary) and TAWCROOT (open-source single-process seccomp backend built from source in CI) are experimental options aimed at lower syscall overhead; switching runs an automated compatibility probe and falls back to PRoot if a check fails. See docs/runtime-engines.md.

9. Are the device capabilities safe?

All three capability groups are turned off by default. Disabled groups are never injected into model prompts and do not request sensitive system permissions. Once turned on, irreversible actions require explicit confirmation via a three-choice native dialog, and you can switch any group off at any time.

10. What is the relationship to the official Pi project?

Pi for Android is an independent, community-maintained third-party Android client built on top of the published @earendil-works/pi-coding-agent SDK. It is not produced or endorsed by the official Pi team.

11. Why is it not on Google Play?

The recommended sideload28 build pins targetSdk 28 so Android 10+ allows executing unpacked Linux binaries from app storage, which does not meet Google Play's target API requirement, and uses a public fixed sideload key in the repository for seamless in-place updates. The modern36 variant tracks targetSdk 36 compatibility work.

Data, Permissions, and Risks

  • Data flow: The app ships no analytics or ad SDKs. Network traffic goes strictly to the model endpoints and MCP servers you configure, plus manual update checks against GitHub Releases.
  • Core permissions: INTERNET connects to your configured providers; foreground service and wake lock keep long turns running while the screen is off; MANAGE_EXTERNAL_STORAGE (all files access) is requested only when you pick an external device folder as a workspace because containers bind-mount real filesystem paths; usesCleartextTraffic allows cleartext HTTP process-wide so Markdown http:// images can load.
  • Optional device capability risks: System Interaction (notifications, clipboard, location, torch, app launch), Screen Automation (Android Accessibility Service), and Device Shell (optional ADB-level elevation via Shizuku) are all disabled by default. Turning on Accessibility or Shizuku allows the agent to read screen contents or execute shell commands on your phone; prompt injection or model mistakes could cause unintended actions, so enable only what you need and review every confirmation dialog carefully.

For Developers

Architecture, protocol docs, CI guards, building from source, and asset regeneration

Architecture Overview

flowchart TB
    A["Android Native UI (Kotlin · Jetpack Compose)"]
    B["Offline Render Pipeline (GFM · MathJax 4 · Mermaid 12) · Virtual TUI · PTY Terminal"]
    C["Typed JSONL Frame Protocol (seq · epoch · backpressure)"]
    D["Node.js SDK Host (host.bundle.mjs + builtin:pi-android-bridge)"]
    E["Official @earendil-works/pi-coding-agent 1.6.1 SDK"]
    F["Container Runtimes (PRoot · Proroot · TAWCROOT) + Ubuntu 24.04 ARM64 / Node 24"]

    A --> B --> C <--> D --> E
    D --> F
Loading
  • Technical documentation: Architecture · Wire Protocol · SDK Upgrading · Runtime Engines · AGENTS.md
  • Automated CI and cold-start guards: Every push runs 6 GitHub Actions jobs (tawcroot NDK build, SDK Host contract and runtime suite including cold-start import-audit, Static safety guards including 12 startup guards and i18n checks, JVM unit tests, APK modern36, and APK sideload28).

Building from Source

git clone https://github.com/heikeyangle-code/pi-mobile-agent.git
cd pi-mobile-agent

# 1. Run SDK host checks, startup guards, and unit tests
node tools/sdk-host/contract.mjs
node tools/sdk-host/test.mjs
node tools/check-startup-perf.mjs
./gradlew :protocol:test :app:testDebugUnitTest

# 2. Fetch runtime bundles and assemble the Release APK
node tools/fetch-runtime.mjs
./gradlew :app:assembleRelease

Regenerating README Assets

All static galleries (WebP), animated demos (GIF), and videos (MP4) in this README are generated reproducibly from code using the repository's own bundled fonts and offline MathJax 4 / Mermaid 12 engines:

# Requires Python 3, Playwright, Chromium, ffmpeg, and cwebp
python3 tools/readme-assets/render.py

Generator sources live in tools/readme-assets/ and write to docs/assets/.

Community and Feedback

Contributing

Issues and pull requests are welcome. Before submitting changes, please read AGENTS.md for cold-start performance guards, rendering rules, and bilingual requirements. If you edit anything under app/src/main/assets/guest/sdk-host/, run node tools/sdk-host/build-bundle.mjs and verify that static guards and tests pass.

License and Acknowledgements

Released under the MIT License. Third-party components bundled inside the APK are distributed under their respective upstream licenses; see Settings → Open-Source Licenses inside the app or app/src/main/assets/licenses/ for the full manifest and license texts.

Acknowledgements:

  • @earendil-works/pi-coding-agent: Core agent session, tools, extensions, and MCP runtime.
  • Termux: terminal-emulator, terminal-view, proot, and libandroid-shmem.
  • proroot: Optional experimental container runtime (proprietary component redistributed unmodified; see proroot-license.txt).
  • wmww/tawc: Experimental single-process seccomp container backend tawcroot (MIT).
  • Offline rendering engines: Mermaid and MathJax for vector diagrams and math equations.
  • Android rendering and system libraries: JetBrains Markdown, AndroidSVG, jsoup, SnakeYAML, and Shizuku API.
  • Bundled fonts: IBM Plex Sans SC, JetBrains Mono, Geist Mono, Source Han Serif CN, and LXGW WenKai.

About

Android AI agent client built on the Pi SDK — clean offline chat, local coding, MCP & terminal | 手机上的 AI Agent:聊天好看,动手也行

Topics

Resources

Stars

25 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages