# Stitch
**An AI assistant that actually runs your Android phone.**
Type or say what you want; Stitch sets the alarm, sends the message, finds the song or taps through the app,
using a tiny model on the phone for everyday commands and the AI of your choice for everything else.
[](LICENSE)




[**Download the APK**](https://git.mohammedkhalid.in/thekhalidsha/stitch/releases/latest) ·
[User guide](docs/USER_GUIDE.md) ·
[Contributing](CONTRIBUTING.md) ·
[Development history](DEVELOPMENT_HISTORY.md)
 |
 |
 |
| Phone commands run on the phone; writing goes to your AI |
Every conversation saved and searchable |
Picks a model that fits your phone |
Screenshots from an Android 14 emulator with a demo AI.
---
## Why Stitch
Phone assistants either do very little on their own, or send everything to the cloud. Stitch splits the work:
- **Plain code first.** Alarms, timers, reminders, the flashlight and "play X on Spotify" are handled by
deterministic rules: instant, offline, and they can't misunderstand.
- **A tiny model on the phone.** [Needle 2](https://huggingface.co/Cactus-Compute/needle2), a 45-million-parameter
tool-calling model (about 14 MB), handles simple one-step commands offline in well under a second, behind
strict safety checks.
- **Your AI for the rest.** Summaries, writing, questions and multi-step tasks go to the AI *you* choose:
Claude, GPT, Gemini, OpenRouter, a model on your PC, or a model running on the phone itself.
## What it can do
| | |
|---|---|
| 📱 **Operate any app** | "Open YouTube and search for lo-fi music". It reads the screen, taps, types and scrolls like a person, with a floating **Stop** button |
| 💬 **Messages & calls** | Send WhatsApp messages and texts, reply from notifications (WhatsApp, Telegram, Slack…), call, answer, hang up, summarize your recent calls |
| ⏰ **Time** | Alarms, timers, reminders and calendar events, with every time worked out by code from your phone's clock |
| 🎵 **Music** | "Play Believer on Spotify", skip, pause, what's playing |
| ⚙️ **Phone settings** | Do Not Disturb, ringer, brightness, rotation, volume, flashlight, screenshots |
| 🌐 **Knowledge** | Web search that falls back to a second engine when one blocks, page reading, weather, location |
| 🧠 **Memory** | "Remember my manager is Sara": used later, e.g. when writing emails |
| 🗣️ **Wake phrase** | Your own phrase, trained on your voice and matched on the phone, opens a bubble over any app |
| 💾 **Saved chats** | Every conversation kept: new chat, search, rename, delete |
| 🤖 **On-phone models** | Run Gemma 4 and other models fully offline, with a guide (20 models) that recommends one for your phone and your use |
70 tools in all. See the [user guide](docs/USER_GUIDE.md) for everything, with examples.
## Safe by design
Stitch can call, text and tap on your phone, so safety is built into how every action runs, not added on top:
- **Calls, messages and deletions always ask first**, showing the exact contact, number and text.
- **Exact values are never trusted from an AI's memory.** Phone numbers must come from your contacts or your
own words; times are computed from the phone's clock.
- **Other people's text can't give orders.** Messages, notifications, web pages and screen text are wrapped
in a marker the text can't forge, and after Stitch reads them, follow-up actions need your confirmation too.
- **Runaway protection:** a step limit, loop detection and a Stop button over every app.
- **Your keys stay on the phone**, encrypted with the Android Keystore. No analytics, no telemetry.
- **On-phone mode sends nothing anywhere.**
## How it works
```mermaid
flowchart TD
A([You type or speak]) --> B{Built-in rules}
B -- "alarm, timer, reminder,
flashlight, play X on Y" --> T[Tools]
B -- anything else --> C{Needle 2
on the phone}
C -- "confident, grounded,
passes the safety gates" --> T
C -- otherwise --> D[Your AI
cloud · your PC · on the phone]
D -- "tool calls, step by step" --> T
T --> E{Risky?}
E -- "call, send, delete" --> F[/Ask you first/]
E -- no --> G[Android]
F -- yes --> G
```
## Get started
1. **Download** the latest APK from [Releases](https://git.mohammedkhalid.in/thekhalidsha/stitch/releases/latest)
and open it on your phone. (Stitch is installed directly rather than from the Play Store, because it
uses permissions the Play Store restricts: SMS, call log and screen control.)
2. **Connect an AI** in ⚙ Settings → AI & provider, or pick *On this phone* and let the model guide
recommend a download.
3. **Allow phone control** in Settings → Phone control. If Android says "restricted setting", open
*App info → ⋮ → Allow restricted settings* and try again.
The [user guide](docs/USER_GUIDE.md) walks through every setting.
### Supported AI providers
| Where it runs | Providers |
|---|---|
| Cloud | Anthropic (Claude), OpenAI, OpenRouter, Google Gemini, Groq, DeepSeek, Xiaomi MiMo, OpenCode Zen / Go |
| Your computer | Ollama, LM Studio, any OpenAI-compatible server, Hermes Agent |
| This phone | Built-in engine (Gemma 4 and other `.litertlm` models via LiteRT-LM), [Thinai](https://github.com/Aravindargutus/Thinai) (GGUF models), any local server |
Every provider keeps its own key, address and model, so you can switch freely.
## Build from source
Requirements: JDK 17, Android SDK (platform 35, build-tools 35.0.0), **NDK 30.0.16248370** (the prebuilt
Needle engine needs r30), CMake 3.22.1. The Gradle wrapper fetches Gradle itself.
```sh
git clone https://git.mohammedkhalid.in/thekhalidsha/stitch.git && cd stitch
./scripts/fetch-needle.sh # prebuilt Needle 2 engine (already in the repo; this refreshes it)
./gradlew testDebugUnitTest # unit tests
./gradlew assembleRelease # → app/build/outputs/apk/release/app-release.apk
```
- **Emulator:** `./gradlew assembleDebug -Pemulator` adds an x86_64 stand-in for Needle, which has no x86 build.
- **No paid key needed for testing:** `python3 tools-dev/fake-ai/fake_ai.py` runs a stand-in AI on port 8099.
- **Tuning Needle:** `tools-dev/needle/run_eval.py` runs 64 phrases through the real engine and the app's
safety rules; the number of *wrong actions that would run* must stay at 0.
Project layout
```
app/src/main/kotlin/app/stitch/
agent/ router, safety gates, AI loop, saved chats, untrusted-text wrapper
needle/ the on-device Needle engine (JNI)
ai/ providers (OpenAI, Anthropic, Responses, LiteRT-LM), model guide, downloads
tools/ the 70 tools, web search
automation/ phone control: accessibility service, screen reader, floating overlay
voice/ wake phrase: fingerprints, listening service, training
notifications/ notification listener (kept in memory only)
core/ settings, time parser, reminders, backup, Markdown
ui/ Jetpack Compose screens
app/src/main/cpp/ JNI bridge and the prebuilt Needle libraries
tools-dev/ Needle eval, fake AI server
docs/ user guide, plans, signing, checklists
```
## Project status
Stitch is **beta**: a personal project, built and tested mostly in an emulator, and used on one real phone.
Its [development history](DEVELOPMENT_HISTORY.md) records every release, bug, cause and fix, including
what is still untested. Next up ([plan](docs/UPGRADE_PLAN.md)): connecting Stitch with the Hermes agent
in both directions, an action log, and fine-tuning Needle on Stitch's own tools.
## Contributing
Contributions are welcome: bug reports, ideas and pull requests. Fork the repository, branch from
`develop`, and open a pull request into `develop`; the maintainer reviews and merges. Please read
[CONTRIBUTING.md](CONTRIBUTING.md) first, and follow the [Code of Conduct](CODE_OF_CONDUCT.md).
Found a security problem? See [SECURITY.md](SECURITY.md).
Branches and releases
| Branch | What it holds |
|---|---|
| `main` | Released versions only (default) |
| `develop` | The next version, as it comes together |
| `feature/*`, `fix/*` | One change each; pull requests into `develop` |
| `release/` | One per version |
| `hotfix/` | Urgent fixes to a release |
Releases are tagged `v-alpha.N` (tests pass) → `-beta.N` (tested on a real phone) → `v`.
Every version since 0.1.0 has a release with its APK. 0.1.0–0.4.2 predate version control, so their branches
hold release notes only; the full source starts at `release/0.4.3`.
## License
Stitch is free and open source under the [Apache License 2.0](LICENSE): use it, change it, fork it and
build on it, including commercially. Keep the [NOTICE](NOTICE) file with any copy you share.
If Stitch helps your project, a line like *"Based on Stitch by Mohammed Khalid"* is warmly appreciated.
## Acknowledgements
- [Needle 2](https://huggingface.co/Cactus-Compute/needle2) by Cactus Compute: the on-device tool-calling model (Apache 2.0)
- [LiteRT-LM](https://github.com/google-ai-edge/LiteRT-LM) by Google: the on-phone model engine (Apache 2.0)
- [Thinai](https://github.com/Aravindargutus/Thinai) by Abhinivesh: the untrusted-text wrapper, web-search and
model-guide ideas were adapted from it (MIT)
- The models in the guide come from Hugging Face's [litert-community](https://huggingface.co/litert-community)
Made by Mohammed Khalid.