Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.
feat(tools): add an about_gotcha tool for app and settings guidance
Durganshu9ef42faabb4f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a40ebb6..efea6de 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,6 +4,18 @@ All notable changes to Gotcha are documented here.## [Unreleased]### Added+- **The assistant can now answer questions about Gotcha itself.** There was a+ tool for the company behind the app (`about_samosa_ai`) but none for the app,+ so "what can you do?" and "which setting do I change to read replies aloud?"+ were answered from the model's memory or by driving the Settings screens to+ rediscover a path — both of which produce confident directions to places that+ don't exist. A new `about_gotcha` tool reads a bundled handbook covering the+ capability areas, Monitor vs Operator, the exact path to every settings page,+ which permission each group of tools waits on and where it's granted, and the+ safety model. It's read-only, so **Monitor** has it too. The handbook is+ checked against the `SettingsPage` and `Capability` enums by a test, so+ renaming a settings page fails the build rather than quietly leaving the agent+ with a stale path.- **Starter prompts on the home screen.** A new chat used to be a greeting and anempty composer, which says nothing about what Gotcha can be asked for. Threesuggestion chips now sit under the agent selector — drawn per session from adiff --git a/app/src/main/assets/app/about-gotcha.md b/app/src/main/assets/app/about-gotcha.mdnew file mode 100644index 0000000..081520c--- /dev/null+++ b/app/src/main/assets/app/about-gotcha.md@@ -0,0 +1,151 @@+# About Gotcha++Gotcha is the app you are running inside. It is an on-device Android copilot: it+holds a conversation, and it drives the real device through a catalog of 100++tools — calls, SMS, contacts, calendar, alarms, files, media, notifications, a+Linux shell, and full screen automation through the accessibility service.++Use this document to answer "what can you do?", "why can't you do X?", and+"which setting do I change to get Y?". Read the settings paths out of here+rather than guessing them or navigating the Settings UI to find out.++## Copilot modes++**Monitor** is read-only. It can look and plan but cannot change anything: read+the screen and notifications, find contacts, read recent SMS and the call log,+list calendar events, read files, grep and glob, search the web, check battery,+storage, location and app usage, list alarms and timers, read health data, and+open an app. It cannot send, delete, write, tap or automate.++**Operator** is the full catalog: everything Monitor has, plus placing calls,+sending SMS and email, writing and deleting files, creating and editing calendar+events and alarms, taking photos, recording audio, changing device settings,+running shell and Termux commands, driving the screen, and delegating to+sub-agents.++The mode switch is in the chat screen and can be changed at any time, including+mid-conversation.++## What Gotcha can do++- **Phone and messaging** — place a call, open the dialer without calling, read+ the call log, find and add contacts, send and read SMS.+- **Calendar** — list, create, edit and delete events, and check availability.+- **Clock** — set and edit alarms and timers, list them, snooze, dismiss.+- **Files** — list, read, write, edit surgically, grep, glob, and report storage.+- **Documents and media** — parse and edit PDFs, edit audio and video, convert+ audio formats (via Termux ffmpeg), take photos, record audio, transcribe audio+ files, and synthesize single-voice or two-host podcasts.+- **Screen automation** — read the screen, tap, long-press, swipe, type, press+ keys, perform global actions, and hand a whole in-app journey to the App+ Navigator sub-agent.+- **Notifications** — read them, dismiss them, control media playback, report+ what is now playing.+- **Device control** — Wi-Fi, torch, volume, ringer mode, Do Not Disturb,+ brightness, wallpaper, vibration, clipboard, app launch and uninstall, app and+ data usage, location.+- **System access** — shell commands, root commands and secure-settings writes+ on a rooted device, and full Linux user-space through Termux.+- **Web** — search and fetch pages.+- **Health** — on-device, read-only summaries and records via Health Connect.+- **Connectors** — Email (IMAP), Google (BYO OAuth), Microsoft (Outlook,+ Calendar, To Do), Notion, and Home Assistant.+- **Skills** — bundled and community operational guidance, searchable and+ injected automatically when the matching app is in front.++## Where the settings are++Everything below is reached from **Settings** in the navigation drawer.++| Setting | What it controls |+| --- | --- |+| Personal Info | Name, occupation, background, reply style, location, preferred currency and language |+| Language | App display language, AI reply language, voice language, STT language |+| AI | Hub for the two pages below |+| AI > AI Configuration | LLM provider, API key, Base URL, main and navigator models, API timeout, max context tokens, max tool rounds, max repeated tool calls, max navigation tool calls, max consecutive delegations, cache and debug-screenshot clearing |+| AI > Speech (TTS / STT) | TTS and STT provider, base URL, key and model, voice selection, podcast host voices, auto-read replies aloud, transcription language override |+| Permissions | Every runtime and special-access permission, grouped: Communications, Contacts, Calendar, Media & Storage, Location, Device Control, Notifications, System Access, Health |+| Termux (Linux shell) | Guided setup for the Linux shell used by `run_termux_command` and audio conversion |+| Skills / Plugins | Built-in skills, importing community skills by URL, allowed community skill hosts |+| Proactive Assistance | Master switch for proactive offers, OTP/code detection, auto-copy OTP, and what may be scanned (screen content, notifications, clipboard) |+| Assistive Ball and Wake Word | The floating ball over other apps, hands-free voice calls, the "Hey Gotcha" wake word, when it listens, and detection sensitivity |+| Appearance | Theme |+| Notifications | Reply chime, vibration, and server messages |+| About | Samosa AI, other products, legal, contact |+| About > About Samosa AI | Mission, products, pricing, developers |+| About > Legal | Terms, disclaimer, data retention |++Two more rows sit on the Settings list itself: **Feature Tour**, which replays+the guided setup one step at a time, and **Send Feedback**.++**Connectors are not in Settings.** They live in the navigation drawer next to+Settings, on their own Connectors screen.++## Permissions and prerequisites++Some tools need a grant that cannot be requested from inside a chat turn. When+one is missing the tools are withheld, but the possibility is not: say what is+missing, where to turn it on, and offer to try again afterwards.++| Needs | Unlocks | Granted at |+| --- | --- | --- |+| The accessibility service | Screen reading, tap, long-press, swipe, typing, key presses, global actions, App Navigator | Settings > Permissions (opens Android's accessibility screen) |+| Notification access | Reading and dismissing notifications, media control, now playing | Settings > Permissions |+| Device admin | Lock screen, disable camera, password policy | Settings > Permissions |+| Root | Root commands and secure-settings writes | A rooted device; `check_root` reports the truth |+| Termux | Termux commands, audio conversion, pulling files out of Termux | Install Termux from F-Droid, then Settings > Termux (Linux shell) |+| Health Connect | Health summaries and records | Settings > Permissions > Health |+| Display over other apps | The overlay tools and the Assistive Ball | Settings > Permissions |++Runtime permissions (phone, SMS, contacts, calendar, camera, microphone,+location, storage) show the normal Android dialog when toggled on in Settings >+Permissions. Special-access permissions open a system settings screen for a+one-time setup instead.++## Safety model++Tools are organised in capability tiers, permissions are asked for up front, and+sensitive actions pass a confirmation gate. Shell commands run against a+deny-list, actions are recorded in an append-only audit log, and settings+screens that could be changed silently are marked confirm-first — the agent asks+before opening them, because screen text, notifications and email all reach the+model's context and could carry an injected instruction.++## Common questions++**"Set up a model."** Settings > AI > AI Configuration: API key, Base URL+(including `/v1/`), and model name. Any OpenAI-compatible `/chat/completions`+endpoint with tool calling works, or sign in to Samosa AI for starter credits.++**"Enable the floating ball / wake word."** Settings > Assistive Ball and Wake+Word. The ball needs the display-over-other-apps permission; the wake word+listens from inside the ball's service, and "When to listen" controls whether+that happens with the screen on, off, or always.++**"Get Termux working."** Install Termux from F-Droid, then Settings > Termux+(Linux shell) for the guided setup. Each command runs in a separate shell, so+`cd` and `export` do not carry over between calls.++**"Read replies aloud."** Settings > AI > Speech (TTS / STT) > Auto-read replies+aloud.++**"Stop Gotcha scanning my screen."** Settings > Proactive Assistance, which has+a master switch plus individual toggles for screen content, notifications and+clipboard.++**"Why can't you do that?"** Check the permission table above — the missing+piece is almost always a capability that has not been granted yet, or Monitor+mode being on when the request needs Operator.++## More++Full documentation is online: getting started, copilot modes, the tool catalog,+architecture, safety and permissions, and the FAQ.++- https://samosa-ai.com/gotcha/docs+- https://samosa-ai.com/gotcha/docs/tool-catalog+- https://samosa-ai.com/gotcha/docs/safety-permissions++For the company behind Gotcha, its other products, pricing, contact details and+the terms and privacy summary, call `about_samosa_ai` instead. The authoritative+legal text is bundled in the app under Settings > About > Legal.diff --git a/app/src/main/java/com/gotcha/tools/AppInfoTool.kt b/app/src/main/java/com/gotcha/tools/AppInfoTool.ktnew file mode 100644index 0000000..7f44e01--- /dev/null+++ b/app/src/main/java/com/gotcha/tools/AppInfoTool.kt@@ -0,0 +1,30 @@+package com.gotcha.tools++import android.content.Context++/**+ * Answers questions about Gotcha itself — what it can do, where each setting+ * lives, and which permission a tool is waiting on.+ *+ * The company analogue is [CompanyInfoTool], and the reasoning is the same: the+ * content is a bundled asset, so the answer works offline and never drifts with+ * the network. The difference is what a wrong answer costs here. Without this+ * the agent either invents a settings path or spends several rounds driving the+ * Settings UI to rediscover one, and the question ("which setting do I change+ * to…") is one of the most common things a user asks the assistant it is+ * running inside.+ */+class AppInfoTool(private val context: Context) {++ fun aboutGotcha(): ToolResult = try {+ val text = context.assets.open(ABOUT_ASSET)+ .use { it.readBytes().toString(Charsets.UTF_8) }+ ToolResult.ok(text)+ } catch (e: Exception) {+ ToolResult.error("Could not read Gotcha info: ${e.message}")+ }++ companion object {+ const val ABOUT_ASSET = "app/about-gotcha.md"+ }+}diff --git a/app/src/main/java/com/gotcha/tools/ToolDefinitions.kt b/app/src/main/java/com/gotcha/tools/ToolDefinitions.ktindex 4048daa..0b68d12 100644--- a/app/src/main/java/com/gotcha/tools/ToolDefinitions.kt+++ b/app/src/main/java/com/gotcha/tools/ToolDefinitions.kt@@ -55,6 +55,21 @@ object ToolDefinitions {schema { putJsonObject("properties") {} })+ val aboutGotcha = tool(+ "about_gotcha",+ "Get information about Gotcha — this app — from its bundled handbook: what it can do, " ++ "Monitor vs Operator mode, the exact path to every setting (AI models and API keys, " ++ "speech, language, permissions, Termux, skills, proactive assistance, the assistive " ++ "ball and wake word, appearance, notifications), which permission or capability each " ++ "group of tools needs and where the user turns it on, and the safety model. Call this " ++ "for ANY question about the app's own features, limits or settings — 'what can you " ++ "do', 'which setting do I change to…', 'why can't you do that', 'how do I set up a " ++ "model / the wake word / Termux'. Answer from this rather than guessing from memory, " ++ "and rather than reading or driving the Settings screens to rediscover a path. " ++ "For the company, its other products, pricing or contact details, use about_samosa_ai.",+ schema { putJsonObject("properties") {} }+ )+val updateUserProfile = tool("update_user_profile","Update the user's stored personal profile in Settings (occupation, background, " +@@ -2945,6 +2960,7 @@ object ToolDefinitions {val all: List<ToolDefinition> = listOf(aboutSamosaAi,+ aboutGotcha,updateUserProfile,dialNumber, getStorageInfo, getBatteryInfo, listFiles, readFile, writeFile,openApp, setBrightness, toggleWifi, openSetting,diff --git a/app/src/main/java/com/gotcha/tools/ToolExecutor.kt b/app/src/main/java/com/gotcha/tools/ToolExecutor.ktindex 5ac97ac..516a71c 100644--- a/app/src/main/java/com/gotcha/tools/ToolExecutor.kt+++ b/app/src/main/java/com/gotcha/tools/ToolExecutor.kt@@ -62,6 +62,7 @@ class ToolExecutor(private val clipboardTool = ClipboardTool(appContext)private val mediaCaptureTool = MediaCaptureTool(appContext)private val companyInfoTool = CompanyInfoTool(appContext)+ private val appInfoTool = AppInfoTool(appContext)// Tier 3 toolsprivate val webSearchTool = WebSearchTool()@@ -215,6 +216,7 @@ class ToolExecutor("get_storage_info" -> storageTool.getStorageInfo()"get_battery_info" -> systemTool.getBatteryInfo()"about_samosa_ai" -> companyInfoTool.aboutSamosaAi()+ "about_gotcha" -> appInfoTool.aboutGotcha()"edit" -> editTool.edit(path = args.requireString("path") ?: return missing("path"),oldString = args.requireString("oldString") ?: return missing("oldString"),diff --git a/app/src/main/java/com/gotcha/tools/ToolRegistry.kt b/app/src/main/java/com/gotcha/tools/ToolRegistry.ktindex 85cc17a..b5e7553 100644--- a/app/src/main/java/com/gotcha/tools/ToolRegistry.kt+++ b/app/src/main/java/com/gotcha/tools/ToolRegistry.kt@@ -92,7 +92,7 @@ object ToolRegistry {"check_root", "search_skills","get_health_summary", "get_health_records","get_now_playing",- "about_samosa_ai"+ "about_samosa_ai", "about_gotcha")/**diff --git a/app/src/test/java/com/gotcha/tools/AppInfoToolTest.kt b/app/src/test/java/com/gotcha/tools/AppInfoToolTest.ktnew file mode 100644index 0000000..7592033--- /dev/null+++ b/app/src/test/java/com/gotcha/tools/AppInfoToolTest.kt@@ -0,0 +1,99 @@+package com.gotcha.tools++import android.content.Context+import androidx.test.core.app.ApplicationProvider+import com.gotcha.ui.SettingsPage+import org.junit.Assert.assertFalse+import org.junit.Assert.assertTrue+import org.junit.Test+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner+import org.robolectric.annotation.Config++/**+ * `about_gotcha`.+ *+ * The asset shipping at all is the first thing to check, as with+ * [CompanyInfoToolTest]. The second is drift, which is the risk specific to this+ * document: it names settings pages and capabilities that the code can rename+ * underneath it, and a stale settings path is worse than none — the agent states+ * it with confidence and sends the user somewhere that no longer exists. So the+ * assertions below are made against the enums themselves rather than against+ * copies of their strings.+ */+@RunWith(RobolectricTestRunner::class)+@Config(sdk = [30, 34])+class AppInfoToolTest {++ private val context: Context = ApplicationProvider.getApplicationContext()+ private val tool = AppInfoTool(context)++ @Test+ fun `about_gotcha reads the bundled asset`() {+ val result = tool.aboutGotcha()++ assertTrue(result.message, result.success)+ assertTrue("expected substantial content, got ${result.message.length} chars", result.message.length > 500)+ }++ @Test+ fun `every settings page the app can open is documented`() {+ val text = tool.aboutGotcha().message++ SettingsPage.entries.forEach { page ->+ assertTrue(+ "the handbook does not mention the '${page.title}' settings page, so the agent " ++ "cannot tell the user how to reach it",+ text.contains(page.title)+ )+ }+ }++ @Test+ fun `every gated capability is documented with the tools it unlocks`() {+ val text = tool.aboutGotcha().message++ // The label reads as a sentence fragment ("it needs <label>"), so match on its+ // distinguishing noun rather than the whole phrase.+ val subjects = mapOf(+ Capability.ACCESSIBILITY to "accessibility service",+ Capability.NOTIFICATION_LISTENER to "Notification access",+ Capability.DEVICE_ADMIN to "Device admin",+ Capability.ROOT to "Root",+ Capability.TERMUX to "Termux",+ Capability.HEALTH_CONNECT to "Health Connect",+ Capability.OVERLAY to "Display over other apps"+ )+ assertTrue(+ "a Capability was added or removed without updating this test or the handbook",+ subjects.keys == Capability.entries.toSet()+ )+ subjects.forEach { (capability, subject) ->+ assertTrue(+ "the handbook does not document '$subject', which gates ${capability.tools.size} tool(s)",+ text.contains(subject)+ )+ }+ }++ @Test+ fun `both copilot modes are explained`() {+ val text = tool.aboutGotcha().message++ assertTrue(text.contains("Monitor"))+ assertTrue(text.contains("Operator"))+ }++ /**+ * The two info tools must stay in their own lanes: this one exists so the+ * agent stops guessing at app behaviour, not so it can paraphrase the legal+ * documents that [CompanyInfoTool] already refuses to stand in for.+ */+ @Test+ fun `company and legal questions are handed to the other tool`() {+ val text = tool.aboutGotcha().message++ assertTrue(text.contains("about_samosa_ai"))+ assertFalse("the handbook must not restate the agreements", text.contains("BY INSTALLING"))+ }+}diff --git a/app/src/test/resources/feature-test-coverage.json b/app/src/test/resources/feature-test-coverage.jsonindex 4cb3f27..c5fe76b 100644--- a/app/src/test/resources/feature-test-coverage.json+++ b/app/src/test/resources/feature-test-coverage.json@@ -22,6 +22,14 @@],"notes": "the bundled asset ships and still contains the company, product and contact facts the tool promises"},+ {+ "tool": "about_gotcha",+ "tier": "ROBOLECTRIC",+ "tests": [+ "com.gotcha.tools.AppInfoToolTest"+ ],+ "notes": "the bundled handbook ships and still documents every SettingsPage and every gated Capability, checked against the enums so a rename fails the build"+ },{"tool": "get_storage_info","tier": "ROBOLECTRIC",diff --git a/docs/FEATURE_TEST_COVERAGE.md b/docs/FEATURE_TEST_COVERAGE.mdindex 07eaacb..bf8882a 100644--- a/docs/FEATURE_TEST_COVERAGE.md+++ b/docs/FEATURE_TEST_COVERAGE.md@@ -14,12 +14,12 @@ Every tool the assistant can call is listed below, together with how it is verif| Tier | Tools | What it means ||---|---:|---|| `UNIT` | 24 | Plain JVM unit test — no Android framework needed. |-| `ROBOLECTRIC` | 27 | JVM test against Robolectric's Android framework, often across several API levels. |+| `ROBOLECTRIC` | 28 | JVM test against Robolectric's Android framework, often across several API levels. || `INSTRUMENTED` | 0 | Runs on a real device or emulator (`app/src/androidTest`). || `MANUAL_ONLY` | 64 | No automated test — verified by hand, see the checklist below. |-| **Total** | **115** | |+| **Total** | **116** | |-**51 of 115** tools are covered by an automated test; the remaining 64 are manual-QA-only with a recorded reason.+**52 of 116** tools are covered by an automated test; the remaining 64 are manual-QA-only with a recorded reason.## Foreground tools (act on the screen)@@ -107,6 +107,7 @@ Every tool the assistant can call is listed below, together with how it is verif| Tool | Tier | Tests / reason ||---|---|---|+| `about_gotcha` | `ROBOLECTRIC` | `AppInfoToolTest` — the bundled handbook ships and still documents every SettingsPage and every gated Capability, checked against the enums so a rename fails the build || `about_samosa_ai` | `ROBOLECTRIC` | `CompanyInfoToolTest` — the bundled asset ships and still contains the company, product and contact facts the tool promises || `ask_final_answer` | `MANUAL_ONLY` | Only reachable from inside a sub-agent loop with a live LLM connection. || `check_availability` | `UNIT` | `CalendarWindowTest` — free/busy window arithmetic |