Open source under Apache 2.0, with a new README
- LICENSE (Apache 2.0), NOTICE with credits (Needle 2, LiteRT-LM, Thinai), LICENSES/Thinai-MIT.txt, SPDX headers on every source file - CONTRIBUTING (fork, branch from develop, PR into develop, maintainer merges), CODE_OF_CONDUCT (Contributor Covenant 2.1), SECURITY, Gitea issue and pull-request templates - README rewritten with screenshots; the detailed guide moved to docs/USER_GUIDE.md - Personal details removed: made-up contact names in examples and tests, a placeholder for the Tailscale address, made-up web-search fixtures in place of saved third-party pages - B-43: the emulator reports Needle as unavailable instead of "init failed" - B-44: chat previews show plain text, not Markdown symbols
This commit is contained in:
1 parent
0bd9888335
commit
917d4632c2
109 files changed
+1080
-179
No files matched your search
@@ -1,206 +1,203 @@
|
||||
# Stitch: on-device Android agent
|
||||
<div align="center">
|
||||
|
||||
Stitch turns what you type or say into actions on your phone.
|
||||
# Stitch
|
||||
|
||||
- **On-device first:** [Cactus Needle 2](https://huggingface.co/Cactus-Compute/needle2), a 45M-parameter tool-calling model built into the app, handles simple phone commands offline in well under a second: flashlight, alarms, timers, calls, texts, call log, media, and settings.
|
||||
- **Your AI for everything else:** summaries ("summarize my last 5 calls"), writing ("draft a leave request email"), questions, and multi-step tasks. Supported: Anthropic, OpenAI, OpenRouter, Gemini, Groq, Ollama / LM Studio on your PC, a generic OpenAI-compatible server, and the current generic Hermes Agent provider preset. Your provider key stays on the phone, encrypted with the Android Keystore.
|
||||
- **Safe by default:** calls and SMS always show a confirmation with the exact recipient and text. After the AI reads other people's messages, every follow-up action needs confirmation too (prompt-injection guard).
|
||||
**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.
|
||||
|
||||
**Current release:** Stitch 0.4.4. The live Android registry contains 70 tools, 32 are exposed to Needle, and the current test suite has 124 unit tests. The original [docs/PLAN.md](docs/PLAN.md) is retained as a historical design document; it is not the current implementation contract.
|
||||
[](LICENSE)
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
**Before anything else:** 0.4.2, 0.4.3 and 0.4.4 have never been tested on a phone. Between them they
|
||||
changed the six things that were broken in 0.4.1, the provider keys, and (0.4.4) saved chats, the model
|
||||
guide, Thinai and web search. [docs/STAGE_A2_CHECKLIST.md](docs/STAGE_A2_CHECKLIST.md) is a 35-minute
|
||||
list to confirm they work.
|
||||
[**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)
|
||||
|
||||
**New in 0.4.4** (several ideas ported from the open-source Thinai app):
|
||||
- **Chats panel:** tap ☰ on the Chat tab. Every conversation is kept; start a new one, go back to an old
|
||||
one, search, rename or delete. Conversations now survive restarts, AI replies included.
|
||||
- **Model guide:** Settings → AI & provider → On this phone shows your phone's RAM and processor, asks
|
||||
what you want a model for (phone commands, Tamil, writing…) and recommends ones that fit, with a speed
|
||||
estimate. 20 models to choose from.
|
||||
- **Thinai** as a provider: runs GGUF models on the phone and Stitch uses them offline.
|
||||
- **Web search that keeps working:** DuckDuckGo blocks repeated questions, so Bing is now the backup, and
|
||||
results that aren't about the question are thrown away.
|
||||
- **Safer reading of other people's text:** a web page or message can no longer fake the end of the
|
||||
"this is someone else's text" wrapper.
|
||||
</div>
|
||||
|
||||
See [docs/UPGRADE_PLAN.md](docs/UPGRADE_PLAN.md) for what happens next: connecting Stitch and Hermes in both directions, so Hermes can use your phone and Stitch can use your server. **None of it is in 0.4.3 yet.** It will all be built **inside Stitch** — there will never be a second app to install. [docs/PLAN.md](docs/PLAN.md) and [docs/HOTWORD_PLAN.md](docs/HOTWORD_PLAN.md) are historical design documents, kept for the reasoning; neither describes current behaviour.
|
||||
<table align="center">
|
||||
<tr>
|
||||
<td align="center"><img src="docs/images/chat.png" width="250" alt="A chat: an alarm set on the phone in 0 ms, then an email drafted by the AI"/></td>
|
||||
<td align="center"><img src="docs/images/chats-panel.png" width="250" alt="The chats panel with search, new chat and saved conversations"/></td>
|
||||
<td align="center"><img src="docs/images/model-guide.png" width="250" alt="The model guide recommending an on-phone model for this phone"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><sub>Phone commands run on the phone; writing goes to your AI</sub></td>
|
||||
<td align="center"><sub>Every conversation saved and searchable</sub></td>
|
||||
<td align="center"><sub>Picks a model that fits your phone</sub></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Install on your phone
|
||||
<p align="center"><sub>Screenshots from an Android 14 emulator with a demo AI.</sub></p>
|
||||
|
||||
1. Copy the newest APK from `dist/` (currently `Stitch-0.4.4.apk`) to your phone and tap it to install. It installs over earlier versions and keeps your settings.
|
||||
2. Open **Stitch → ⚙ Settings**. Settings is a list of categories; tap one to open it and use the back arrow to return. Set up the following:
|
||||
- **AI & provider:** pick a provider, paste your key, and tap **Test connection**.
|
||||
- **Phone control:** tap **Turn on phone control**, open *Stitch phone control* and switch it on. If Android says "restricted setting", go to **App info → ⋮ → Allow restricted settings** and try again.
|
||||
- **Permissions & access:** grant permissions (contacts, calls, call log, SMS, calendar, location, notifications, microphone) and special access: Do Not Disturb, "modify system settings" (for brightness and rotation), and read notifications (for WhatsApp replies and music control).
|
||||
- **Who answers you:** Hybrid (recommended), on-device only, or always your AI. Under *On-device model*.
|
||||
- The other categories are **Voice & hotword**, **Default apps** and **Backup & restore**.
|
||||
3. **After every Stitch update,** open Settings → Phone control. If it shows "on but not running", switch it off and on again. Android stops accessibility services when an app is updated. If you use the wake phrase, a "Wake phrase is off" notification appears too: tap it once to turn listening back on (Android doesn't let an app restart the microphone by itself).
|
||||
---
|
||||
|
||||
## The main screen (0.4.4)
|
||||
## Why Stitch
|
||||
|
||||
Four tabs along the bottom:
|
||||
- **Chat:** talk to Stitch. **☰** (top left, or swipe from the left edge) opens your chats: New chat, search, and a ⋮ menu on each chat to rename or delete it, plus Delete all at the bottom. The **new chat** button and the settings gear are at the top right.
|
||||
- **Schedule:** your upcoming alarms, reminders and calendar events, soonest first. Timers and alarms set outside Stitch aren't listed.
|
||||
- **Saved:** your notes and the facts Stitch remembers.
|
||||
- **Workflows:** coming soon.
|
||||
Phone assistants either do very little on their own, or send everything to the cloud. Stitch splits the work:
|
||||
|
||||
Schedule and Saved are view-only. To change something, ask Stitch in Chat (e.g. "delete my 7am alarm").
|
||||
- **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
|
||||
|
||||
Stitch currently exposes 70 Android tools through the live registry. They cover native device actions, calls and messages, calendar and reminders, media, knowledge, memory, notes, and Accessibility-based screen control. The exact catalog is generated from the app code rather than this README.
|
||||
|
||||
| Area | Examples |
|
||||
| | |
|
||||
|---|---|
|
||||
| Operate any app (Phone control) | "Open YouTube and search for lo-fi music", "In Settings, turn on dark mode", "Find Ali in Contacts". The AI reads the screen, taps, types, scrolls and swipes like a person. It can also take a screenshot and look at it, for games, maps and images. A floating bar shows each step with a **Stop** button. |
|
||||
| Messages | "WhatsApp Ahmed I'm on my way" (really sends), "reply to Sara on WhatsApp: ok" (replies from the notification; works for Telegram, Instagram, Slack…), "text Mom…", "WhatsApp video call Ali", "any important messages?" |
|
||||
| Calls | "call Ali Khan", "summarize my last 5 calls", "any missed calls?", "hang up", "answer" |
|
||||
| Music | "play Believer on Spotify", "play lofi on YouTube Music", "what's playing?", "next song", "skip forward 30 seconds" |
|
||||
| Time | "alarm in 30 minutes", "alarm at 6:30 tomorrow", "timer 5 minutes", "remind me to call the bank tomorrow at 10", "add a meeting with Sara on Monday 3pm" |
|
||||
| Phone settings | Do Not Disturb, silent/vibrate, brightness, auto-rotate, screen timeout, volume, flashlight, lock screen, screenshot, phone status report |
|
||||
| Knowledge | Weather (no key needed), web search, "read this page and summarize", your location, the time |
|
||||
| Memory | "remember my manager is Sara Khan". It's used in later requests, for example when writing emails. |
|
||||
| 📱 **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 |
|
||||
|
||||
## AI providers
|
||||
70 tools in all. See the [user guide](docs/USER_GUIDE.md) for everything, with examples.
|
||||
|
||||
⚙ Settings → AI & provider:
|
||||
- **Cloud:** Anthropic, OpenAI, OpenRouter, OpenCode Zen, OpenCode Go, DeepSeek, Xiaomi MiMo (pay-as-you-go or Token Plan), Google Gemini, Groq.
|
||||
- **Your own servers:** Ollama / LM Studio on your PC, a local server on the phone, or any OpenAI-compatible server.
|
||||
- **Thinai (on this phone, offline):** [Thinai](https://github.com/Aravindargutus/Thinai) is a separate free app that runs GGUF models (Qwen, Llama, Gemma, Phi…) and serves them on the phone at `127.0.0.1:11434`. Install it, download a model, start its server, then pick **Thinai** in Stitch and tap ⟳ to choose the model. Any server on the phone itself gets the same treatment as the built-in engine: short instructions and the 33 phone tools rather than all 70, because these are small models. Keep Thinai's LAN mode off, and set an access token in Thinai if you want to stop other apps on the phone from using it.
|
||||
- **Hermes (current behaviour):** the "Hermes Agent" entry is an ordinary OpenAI-compatible provider connection, nothing more. Two things stop it working as shipped: its address (`192.168.1.10`) is not the build machine, and Hermes' own API server only listens on the PC itself and won't start without a key being set. Both are fixed in Stage C of [docs/UPGRADE_PLAN.md](docs/UPGRADE_PLAN.md).
|
||||
- **On this phone (offline):** Gemma 4 and other `.litertlm` models, running in the same engine Google AI Edge Gallery uses (LiteRT-LM). **"Which model should I get?"** reads your phone's RAM, processor and free storage, asks what you want the model for, and recommends models that do that well *and* fit, each with "Runs well / Tight fit / Too big" and a speed estimate. "Show all 20 models" lists the whole catalogue. Ratings are editorial (what each model's makers claim, plus its size), not tests; only Gemma 4 (the default) and Granite 350M have been run in Stitch — others are marked "Not tried in Stitch yet". Or import a file. Edge Gallery keeps its own models private to that app, so they can't be shared. Edge Gallery's planned local API server isn't released yet; if it ships, pick "Local server on this phone". On-device models need a 64-bit phone and get a smaller tool set (no screen control).
|
||||
- **Every provider keeps its own settings.** Its key, address and model are saved separately, so you can set up several and switch between them without retyping anything. A ✓ in the list marks the ones you've set up, and the eye icon next to the key field shows what you typed. (Before 0.4.3 they shared one slot, so a second provider overwrote the first.)
|
||||
- **Models:** type any model name, or tap ⟳ to download the provider's model list and pick from it. Typing filters the list. The chosen model is remembered per provider too.
|
||||
- **OpenCode:** each model is automatically sent to the right API format (Claude/Qwen → Messages, GPT/Grok → Responses, others → Chat Completions; MiniMax on Go → Messages). Gemini models on OpenCode aren't supported yet.
|
||||
## Safe by design
|
||||
|
||||
**Banking apps:** most banks refuse to run while Phone control is on — that's their own anti-fraud rule about screen reading, not something Stitch can or should work around. Add the **Phone control** tile to your Quick Settings to switch it off in one tap; tapping it again takes you to the page to switch it back on (Android won't let an app re-enable itself).
|
||||
Stitch can call, text and tap on your phone, so safety is built into how every action runs, not added on top:
|
||||
|
||||
**Safety:** Calls, sent messages, and taps on Send/Pay/Delete/Post-type buttons ask you first. The screen-tap check can be turned off in Settings. After Stitch reads other people's messages or web pages, it also confirms any follow-up action.
|
||||
- **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 requests are routed:** deterministic Kotlin rules handle common commands first, then Needle handles simple on-device tool calls, and the configured AI handles reasoning, writing, summaries, and multi-step tasks. Settings → On-device model lets you change this: **Hybrid** (the default, as described), **on-device only** (nothing leaves the phone, and it says so when it can't help), or **always my AI** (skips Needle). The built-in rules always run first whichever you pick — they're plain code, not a model. Times are always computed by code from your phone's clock, never by a model. If the model picks a tool for a different app than the one you named, is missing grounded arguments, or isn't confident, the request falls back safely to the configured AI.
|
||||
## How it works
|
||||
|
||||
## Build it yourself
|
||||
```mermaid
|
||||
flowchart TD
|
||||
A([You type or speak]) --> B{Built-in rules}
|
||||
B -- "alarm, timer, reminder,<br/>flashlight, play X on Y" --> T[Tools]
|
||||
B -- anything else --> C{Needle 2<br/>on the phone}
|
||||
C -- "confident, grounded,<br/>passes the safety gates" --> T
|
||||
C -- otherwise --> D[Your AI<br/>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
|
||||
```
|
||||
|
||||
The project is a git repository as of 25 Sep 2026. An online copy lives in a private repository on the
|
||||
owner's Gitea server (`https://git.mohammedkhalid.in/thekhalidsha/stitch`), with a **release for every
|
||||
version since 0.1.0**, each with its APK to download.
|
||||
## Get started
|
||||
|
||||
### How branches and releases work
|
||||
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.
|
||||
|
||||
<details>
|
||||
<summary><b>Project layout</b></summary>
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## 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).
|
||||
|
||||
<details>
|
||||
<summary><b>Branches and releases</b></summary>
|
||||
|
||||
| Branch | What it holds |
|
||||
|---|---|
|
||||
| `main` | Released versions only. The default branch |
|
||||
| `develop` | Where new work comes together |
|
||||
| `feature/<name>` | One piece of work; merged into `develop` when done |
|
||||
| `release/<version>` | One per version: final checks, then merged into `main` and tagged |
|
||||
| `hotfix/<version>` | An urgent fix to a released version, merged into `main` and `develop` |
|
||||
| `main` | Released versions only (default) |
|
||||
| `develop` | The next version, as it comes together |
|
||||
| `feature/*`, `fix/*` | One change each; pull requests into `develop` |
|
||||
| `release/<version>` | One per version |
|
||||
| `hotfix/<version>` | Urgent fixes to a release |
|
||||
|
||||
Alpha, beta and final are **tags**, not branches, and show on Gitea's Releases page:
|
||||
Releases are tagged `v<version>-alpha.N` (tests pass) → `-beta.N` (tested on a real phone) → `v<version>`.
|
||||
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`.
|
||||
|
||||
| Tag | Meaning | On Gitea |
|
||||
|---|---|---|
|
||||
| `v0.5.0-alpha.1` | Built, all tests pass on the computer | Pre-release |
|
||||
| `v0.5.0-beta.1` | Passed the owner's phone checklist | Pre-release |
|
||||
| `v0.5.0` | Used on the phone for a while with no problems | Release |
|
||||
</details>
|
||||
|
||||
**0.4.4 is the current release** (the owner's decision on 28 Sep 2026, made before the phone checklist
|
||||
was run on it). Every earlier version is marked pre-release.
|
||||
Versions 0.1.0 to 0.4.2 were made before git existed here: their `release/<version>` branches hold only
|
||||
their release notes and the APK's fingerprint, and the APK itself is attached to their Gitea release.
|
||||
The full source starts at `release/0.4.3`. Build outputs and the APKs in `dist/` are deliberately not tracked, the prebuilt
|
||||
`libneedle.a` files are.
|
||||
## License
|
||||
|
||||
Requirements: JDK 17, Android SDK (platform 35, build-tools 35.0.0), NDK `30.0.16248370`, CMake 3.22.1. The prebuilt Needle engine needs NDK r30's C++ runtime; older NDKs fail to link. Gradle is 8.14.5 (the wrapper downloads it on first build).
|
||||
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.
|
||||
|
||||
```sh
|
||||
./scripts/fetch-needle.sh # prebuilt Needle 2 engine (only needed on a fresh checkout)
|
||||
./gradlew assembleRelease # → app/build/outputs/apk/release/app-release.apk
|
||||
./gradlew testDebugUnitTest # unit tests; also writes app/build/needle-tools.json
|
||||
STITCH_LIVE=1 ./gradlew testDebugUnitTest --tests app.stitch.WebSearchTest # also asks the real search engines
|
||||
```
|
||||
If Stitch helps your project, a line like *"Based on Stitch by Mohammed Khalid"* is warmly appreciated.
|
||||
|
||||
For emulator tests without a paid key, `python3 tools-dev/fake-ai/fake_ai.py` runs a stand-in AI on port 8099 (use `http://10.0.2.2:8099/v1` as a Custom provider in the emulator).
|
||||
## Acknowledgements
|
||||
|
||||
To test on-device models in an x86_64 emulator, build with `./gradlew -Pemulator assembleDebug`. It adds x86_64 native libraries, with a stand-in for Needle, which has no Android x86 build. Without that flag, the emulator runs the ARM engine through translation and crashes.
|
||||
- [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)
|
||||
|
||||
The release APK is signed with the local debug key so it installs directly. Keep building on the same machine so updates install over the old version. A proper release key now exists at `~/.stitch-release-key/` and is used only when you pass `-PreleaseKey` — switching to it is a one-time move that requires uninstalling first, so read [docs/SIGNING.md](docs/SIGNING.md) before you use that flag.
|
||||
|
||||
### Tuning Needle
|
||||
|
||||
`tools-dev/needle/run_eval.py` runs `eval_set.tsv` through the Needle CLI (Linux/Mac build from the Hugging Face repo) against the app's real tool catalog and reports what would run on-device:
|
||||
|
||||
```sh
|
||||
python3 tools-dev/needle/run_eval.py path/to/needle app/build/needle-tools.json 0.4
|
||||
```
|
||||
|
||||
Tool descriptions matter a lot to Needle's accuracy. Change them in `app/src/main/kotlin/app/stitch/tools/`, re-run the unit tests to regenerate the catalog, then re-run the eval.
|
||||
|
||||
## Layout
|
||||
|
||||
```
|
||||
app/src/main/cpp/ JNI bridge + prebuilt libneedle.a (arm64-v8a, armeabi-v7a)
|
||||
app/src/main/kotlin/app/stitch/
|
||||
needle/NeedleEngine.kt on-device model (single thread, confidence + grounding gate)
|
||||
agent/Agent.kt router: Needle first → your AI with tool calling; permissions + confirmations
|
||||
ai/ Anthropic + OpenAI-compatible clients (thin, raw HTTP)
|
||||
tools/ 70 tools: device, calls, SMS, WhatsApp, music, reminders, calendar, weather, web, memory, notes, and screen control
|
||||
automation/ phone control: accessibility service, screen reader, floating overlay
|
||||
notifications/ notification listener (kept in memory only)
|
||||
ui/ Compose chat + settings
|
||||
tools-dev/needle/ eval set + runner
|
||||
tools-dev/fake-ai/ stand-in AI server for emulator tests
|
||||
```
|
||||
|
||||
## Tested so far vs. not yet
|
||||
|
||||
Tested in an Android 14 emulator with a scripted fake AI:
|
||||
- Phone control: opening Contacts, reading the screen, tapping search, typing, and reading system permission dialogs
|
||||
- The floating status bar with Stop, and the result card
|
||||
- Screenshots reaching the AI
|
||||
- Reminders firing on time
|
||||
- Weather, web search, and the phone status report
|
||||
- SMS sending with confirmation, and the ambiguous-contact case
|
||||
|
||||
Tested in the emulator for 0.4.4 (fake AI server):
|
||||
- The chats panel: new chat, switching back with the right history sent to the AI, rename, search, delete, and chats surviving an app update
|
||||
- Thinai's path (a server on 127.0.0.1:11434, simulated): connect, sync models, and the 33-tool set being sent
|
||||
- The model guide on a 2.4 GB emulator: it recommends only models that fit and says when better ones are too big
|
||||
- An update with the wake phrase on no longer crashes the app
|
||||
- Web search asked the real engines from the build machine: 4 of 4 questions answered while DuckDuckGo was blocking
|
||||
|
||||
Not yet tested on real apps:
|
||||
- WhatsApp auto-send (WhatsApp isn't installed in the emulator)
|
||||
- Music playback in Spotify, YouTube Music and YMusic
|
||||
- Cloud providers with a real key (model-list sync was tested live against OpenRouter and OpenCode Zen/Go)
|
||||
- The real Thinai app (only simulated), and any model in the guide other than Granite 350M
|
||||
- On-device Gemma 4 on a real phone (the engine, tool calls and downloads were tested in the emulator with the small Granite model)
|
||||
- Notification replies
|
||||
- Any run with a real AI model
|
||||
|
||||
## Known limits
|
||||
|
||||
- Needle's confidence scores are conservative, so many commands go to your AI. Fine-tuning Needle on this tool catalog is the eventual fix (post-1.0 roadmap in docs/UPGRADE_PLAN.md).
|
||||
- Wi-Fi, Bluetooth, and mobile data can't be switched by apps on Android 10+. The AI can do it through phone control by opening Quick Settings and tapping the toggle.
|
||||
- Banking apps and other protected screens block screenshots. Screen reading usually still works there.
|
||||
- **Backups exist but are untested on a phone.** Settings → Backup & restore saves everything to one encrypted file (new in 0.4.2), including every provider's key. Until you've confirmed a backup actually restores, treat uninstalling as permanent — installing a new APK over the old one is safe, uninstalling is not. Note that Android never restores the *special* permissions (Phone control, notification access, Do Not Disturb, modify system settings); those are always re-granted by hand after a reinstall.
|
||||
- Chat history (0.4.4): every conversation is saved separately in app-private storage (up to 1,000 lines each), and included in backups. Only what you and Stitch said is saved; tool results, screenshots, notification bodies and the "Show data" panel stay in memory for the session only, since they hold other people's messages. When you return to a chat, the AI is shown its last ~40 lines. Remembered facts, notes, and reminders are saved separately.
|
||||
|
||||
|
||||
## Wake phrase and the bubble (0.4.2)
|
||||
|
||||
1. **Settings → Wake phrase:** turn on *Listen for my wake phrase*, type your phrase (e.g. "Hey Stitch"),
|
||||
then tap **Record** five times, saying it each time. Only sound fingerprints are stored; the audio is deleted.
|
||||
2. Say the phrase anywhere: a **bubble** opens over the app you are in. Speak, or type in it.
|
||||
It can read the app behind it ("read what's on screen", "what does this say?").
|
||||
3. **Sensitivity** slider: left = fewer false wakes, right = wakes more easily. Retrain if it misses you.
|
||||
Each recording is now scored against the others, and any one you said differently is flagged — tap
|
||||
**Redo** on just that one rather than clearing them all. How strictly Stitch matches is worked out
|
||||
from how alike your recordings are, so one odd recording spoils the lot.
|
||||
3b. **Only show the bubble once I start speaking** (on by default). Matching sound will always mis-fire
|
||||
occasionally; with this on a mis-fire stays invisible and closes itself instead of interrupting you.
|
||||
The trade is that the bubble appears as you speak rather than the instant it hears the phrase.
|
||||
4. **Listen when:** always / screen on or charging (default) / only charging. The notification has a Pause button.
|
||||
5. **Replace Google Assistant:** Settings → *Use Stitch instead of Google Assistant* → Digital assistant app → Stitch.
|
||||
Holding the power button then opens Stitch. A Quick Settings tile is also available.
|
||||
<div align="center"><sub>Made by Mohammed Khalid.</sub></div>
|
||||
Reference in new issue
Block a user