android-agent-harness 0.27.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. android_agent_harness-0.27.6/LICENSE +21 -0
  2. android_agent_harness-0.27.6/PKG-INFO +163 -0
  3. android_agent_harness-0.27.6/README.md +118 -0
  4. android_agent_harness-0.27.6/agents/mcp/zoho_sprints/README.md +26 -0
  5. android_agent_harness-0.27.6/agents/mcp/zoho_sprints/_client.py +304 -0
  6. android_agent_harness-0.27.6/agents/mcp/zoho_sprints/_config.py +105 -0
  7. android_agent_harness-0.27.6/agents/mcp/zoho_sprints/_dns.py +92 -0
  8. android_agent_harness-0.27.6/agents/mcp/zoho_sprints/_formatter.py +132 -0
  9. android_agent_harness-0.27.6/agents/mcp/zoho_sprints/server.py +353 -0
  10. android_agent_harness-0.27.6/agents/scripts/_adb_core.py +1346 -0
  11. android_agent_harness-0.27.6/agents/scripts/_adb_core_selftest.py +251 -0
  12. android_agent_harness-0.27.6/agents/scripts/_apk_freshness.py +272 -0
  13. android_agent_harness-0.27.6/agents/scripts/_apk_freshness_selftest.py +190 -0
  14. android_agent_harness-0.27.6/agents/scripts/_baseline_selftest.py +169 -0
  15. android_agent_harness-0.27.6/agents/scripts/_env_codes.py +288 -0
  16. android_agent_harness-0.27.6/agents/scripts/_env_codes_selftest.py +229 -0
  17. android_agent_harness-0.27.6/agents/scripts/_final_verdict_selftest.py +302 -0
  18. android_agent_harness-0.27.6/agents/scripts/_gate_results.py +85 -0
  19. android_agent_harness-0.27.6/agents/scripts/_graph_core.py +1308 -0
  20. android_agent_harness-0.27.6/agents/scripts/_graph_selftest.py +400 -0
  21. android_agent_harness-0.27.6/agents/scripts/_hook_selftest.py +2981 -0
  22. android_agent_harness-0.27.6/agents/scripts/_hook_state.py +837 -0
  23. android_agent_harness-0.27.6/agents/scripts/_live_process.py +130 -0
  24. android_agent_harness-0.27.6/agents/scripts/_modules.py +37 -0
  25. android_agent_harness-0.27.6/agents/scripts/_product.py +41 -0
  26. android_agent_harness-0.27.6/agents/scripts/_repo_files.py +291 -0
  27. android_agent_harness-0.27.6/agents/scripts/_risk_and_impact_selftest.py +325 -0
  28. android_agent_harness-0.27.6/agents/scripts/_round_cap_selftest.py +141 -0
  29. android_agent_harness-0.27.6/agents/scripts/_security_selftest.py +484 -0
  30. android_agent_harness-0.27.6/agents/scripts/_variants.py +96 -0
  31. android_agent_harness-0.27.6/agents/scripts/approve_risk.py +100 -0
  32. android_agent_harness-0.27.6/agents/scripts/baseline_capture.py +203 -0
  33. android_agent_harness-0.27.6/agents/scripts/capture_screen.py +103 -0
  34. android_agent_harness-0.27.6/agents/scripts/cc_pre_tool_safety.py +84 -0
  35. android_agent_harness-0.27.6/agents/scripts/check_kit_update.py +225 -0
  36. android_agent_harness-0.27.6/agents/scripts/check_strings.py +491 -0
  37. android_agent_harness-0.27.6/agents/scripts/copilot_pre_tool_safety.py +99 -0
  38. android_agent_harness-0.27.6/agents/scripts/doctor/__init__.py +20 -0
  39. android_agent_harness-0.27.6/agents/scripts/doctor/engine.py +829 -0
  40. android_agent_harness-0.27.6/agents/scripts/doctor/models.py +125 -0
  41. android_agent_harness-0.27.6/agents/scripts/ensure_hook_selftest.py +185 -0
  42. android_agent_harness-0.27.6/agents/scripts/fast_kt_lint.py +449 -0
  43. android_agent_harness-0.27.6/agents/scripts/final_verdict.py +365 -0
  44. android_agent_harness-0.27.6/agents/scripts/gradle_error_parser.py +88 -0
  45. android_agent_harness-0.27.6/agents/scripts/harness_doctor.py +113 -0
  46. android_agent_harness-0.27.6/agents/scripts/impact_analyzer.py +343 -0
  47. android_agent_harness-0.27.6/agents/scripts/install_or_update.py +667 -0
  48. android_agent_harness-0.27.6/agents/scripts/install_tool_adapters.py +788 -0
  49. android_agent_harness-0.27.6/agents/scripts/install_zoho_mcp.py +170 -0
  50. android_agent_harness-0.27.6/agents/scripts/logcat_doctor.py +147 -0
  51. android_agent_harness-0.27.6/agents/scripts/new_feature_scaffold.py +378 -0
  52. android_agent_harness-0.27.6/agents/scripts/perf_guard.py +178 -0
  53. android_agent_harness-0.27.6/agents/scripts/pm_github.py +256 -0
  54. android_agent_harness-0.27.6/agents/scripts/pm_policy.py +297 -0
  55. android_agent_harness-0.27.6/agents/scripts/policy_vocab.py +226 -0
  56. android_agent_harness-0.27.6/agents/scripts/pre_commit_gate.py +116 -0
  57. android_agent_harness-0.27.6/agents/scripts/pre_invocation_reminder.py +151 -0
  58. android_agent_harness-0.27.6/agents/scripts/pre_tool_safety.py +1078 -0
  59. android_agent_harness-0.27.6/agents/scripts/preflight_check.py +86 -0
  60. android_agent_harness-0.27.6/agents/scripts/project_graph.py +235 -0
  61. android_agent_harness-0.27.6/agents/scripts/review_package.py +302 -0
  62. android_agent_harness-0.27.6/agents/scripts/risk_tier.py +356 -0
  63. android_agent_harness-0.27.6/agents/scripts/room_guard.py +259 -0
  64. android_agent_harness-0.27.6/agents/scripts/run_device.py +193 -0
  65. android_agent_harness-0.27.6/agents/scripts/run_gradle_task.py +263 -0
  66. android_agent_harness-0.27.6/agents/scripts/run_tests_gate.py +141 -0
  67. android_agent_harness-0.27.6/agents/scripts/setup_wizard.py +217 -0
  68. android_agent_harness-0.27.6/agents/scripts/wizard/__init__.py +2 -0
  69. android_agent_harness-0.27.6/agents/scripts/wizard/discovery.py +536 -0
  70. android_agent_harness-0.27.6/agents/scripts/wizard/i18n.py +281 -0
  71. android_agent_harness-0.27.6/agents/scripts/wizard/questions.py +875 -0
  72. android_agent_harness-0.27.6/agents/tool-adapters/README.md +32 -0
  73. android_agent_harness-0.27.6/android_agent_harness.egg-info/PKG-INFO +163 -0
  74. android_agent_harness-0.27.6/android_agent_harness.egg-info/SOURCES.txt +78 -0
  75. android_agent_harness-0.27.6/android_agent_harness.egg-info/dependency_links.txt +1 -0
  76. android_agent_harness-0.27.6/android_agent_harness.egg-info/entry_points.txt +2 -0
  77. android_agent_harness-0.27.6/android_agent_harness.egg-info/top_level.txt +2 -0
  78. android_agent_harness-0.27.6/harness_cli.py +760 -0
  79. android_agent_harness-0.27.6/pyproject.toml +58 -0
  80. android_agent_harness-0.27.6/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rabee Elkholy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.4
2
+ Name: android-agent-harness
3
+ Version: 0.27.6
4
+ Summary: Deterministic Android Engineering for the AI Era: Turn Any AI Assistant into an Uncompromising Senior Android Engineering Team.
5
+ Author: Rabee Elkholy
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Rabee Elkholy
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/rabee-elkholy/android-agent-harness
29
+ Project-URL: Issues, https://github.com/rabee-elkholy/android-agent-harness/issues
30
+ Keywords: android,kmp,ai-agents,code-review,governance,mcp
31
+ Classifier: Development Status :: 5 - Production/Stable
32
+ Classifier: Environment :: Console
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: Operating System :: OS Independent
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3.10
37
+ Classifier: Programming Language :: Python :: 3.11
38
+ Classifier: Programming Language :: Python :: 3.12
39
+ Classifier: Programming Language :: Python :: 3.13
40
+ Classifier: Topic :: Software Development :: Quality Assurance
41
+ Requires-Python: >=3.10
42
+ Description-Content-Type: text/markdown
43
+ License-File: LICENSE
44
+ Dynamic: license-file
45
+
46
+ <div align="center">
47
+
48
+ # android-agent-harness
49
+
50
+ ### Deterministic Android Engineering for the AI Era
51
+ **Turn Any AI Assistant into an Uncompromising Senior Android Engineering Team.**
52
+
53
+ [![CI Build](https://img.shields.io/github/actions/workflow/status/rabee-elkholy/android-agent-harness/ci.yml?branch=main&style=flat-square&label=CI%20Build)](https://github.com/rabee-elkholy/android-agent-harness/actions/workflows/ci.yml)
54
+ [![Latest Release](https://img.shields.io/github/v/release/rabee-elkholy/android-agent-harness?color=2ea44f&style=flat-square&label=Release)](https://github.com/rabee-elkholy/android-agent-harness/releases)
55
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](LICENSE)
56
+ [![Platform](https://img.shields.io/badge/Platform-Android%20%7C%20KMP-3DDC84?style=flat-square)](https://android.com)
57
+ [![Python: 3.10+](https://img.shields.io/badge/Python-3.10%2B-3776AB?style=flat-square)](https://python.org)
58
+ [![Quality Gate](https://img.shields.io/badge/Quality%20Gate-6--Leaf%20Pass-success?style=flat-square)](docs/architecture.md)
59
+ [![AI Tools](https://img.shields.io/badge/AI%20Tools-14%20IDs%20%7C%2011%20Templates-8A2BE2?style=flat-square)](docs/tool-support.md)
60
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](CONTRIBUTING.md)
61
+
62
+ <br/><br/>
63
+ <img src="docs/assets/banner.svg" alt="android-agent-harness: Deterministic Android Engineering for the AI Era" width="100%" />
64
+
65
+ </div>
66
+
67
+ ---
68
+
69
+ ## Why the Harness? Prompts are Polite Requests. The Harness is an OS-Level Cage.
70
+
71
+ Prompts, `.cursorrules`, and `SKILL.md` files decay as conversation context expands. AI coding assistants eventually hallucinate success, break Room migrations, ignore RTL layouts, and push unreviewed code.
72
+
73
+ The **Android Agent Harness** enforces deterministic, cryptographic, and OS-level execution barriers outside the model brain:
74
+
75
+ | Android Failure Mode | Bare AI Assistant | Android Agent Harness |
76
+ | :--- | :--- | :--- |
77
+ | **Room Migrations** | Modifies `@Entity` without migration -> app crashes on user upgrade. | **Room Guard (`room_guard.py`)**: Hard-blocks un-migrated Kotlin & Java entities. |
78
+ | **Localization & RTL** | Hardcodes strings, drops Arabic (`values-ar`), scrambles placeholders. | **Adaptive String Guard (`check_strings.py`)**: Sub-second diff-scoped parity check. |
79
+ | **ANR & Main-Thread I/O** | Runs disk/network I/O on `Dispatchers.Main`; leaks sensor listeners. | **Perf & ANR Guardian**: Enforces 60/120 FPS fluidity and lifecycle unregistration. |
80
+ | **Review Verification** | Model declares "LGTM!" and assumes its own fix works. | **Cryptographic Barrier**: Assembly (`:assembleDebug`) locked until 6 guardians emit SHA-256 tokens. |
81
+ | **Rogue Git Commits** | Runs `git commit` or `git push --force` to hide compilation mistakes. | **OS Interceptor (`pre_tool_safety.py`)**: Hard-denies unauthorized Git and ADB mutations. |
82
+ | **Legacy Codebases** | Linters output 4,000 legacy errors, stalling delivery. | **Zero Legacy Penalty**: Diff-scoped AST lint (`fast_kt_lint.py`) inspects modified lines in <1s. |
83
+
84
+ ---
85
+
86
+ ### The Cage in Action: Real-Time Interceptions
87
+
88
+ ```text
89
+ [MODEL ATTEMPTS] > git push --force origin main
90
+ [HARNESS CAGE] [DENIED] Autonomous git push is strictly blocked. Human developer authority is absolute.
91
+
92
+ [MODEL ATTEMPTS] > python agents/scripts/run_gradle_task.py :app:assembleDebug
93
+ [HARNESS CAGE] [LOCKED] Cryptographic Review Barrier active. Missing pass tokens: [BUG_PASS, PERF_PASS].
94
+
95
+ [PREFLIGHT GATE] python agents/scripts/room_guard.py
96
+ [HARNESS CAGE] [FAIL] Room database AppDatabase.kt version was NOT incremented. Destructive fallback banned.
97
+ ```
98
+
99
+ ---
100
+
101
+ ## The 6 Parallel Quality Guardians
102
+
103
+ Before `:app:assembleDebug` or device deployment, 6 specialized subagents review the immutable snapshot in parallel:
104
+
105
+ 1. **`bug-reviewer-agent`** (`BUG_PASS`): Logic bugs, Kotlin null-safety across Java boundaries, and coroutine cancellation leaks.
106
+ 2. **`convention-reviewer-agent`** (`CONVENTION_PASS`): Clean Architecture, MVI StateFlow immutability, zero inline FQCNs.
107
+ 3. **`security-reviewer-agent`** (`SECURITY_PASS`): OWASP Mobile Top 10, unexported components, and credential isolation.
108
+ 4. **`perf-anr-guardian-agent`** (`PERF_PASS`): ANR elimination, Main-thread I/O prevention, and Compose recomposition fluidity.
109
+ 5. **`regression-impact-reviewer-agent`** (`REGRESSION_PASS`): Blast radius analysis, caller graph impacts, and API signature changes.
110
+ 6. **`test-quality-reviewer-agent`** (`TEST_PASS`): **Smart Test Promotion** — automatically promoted on test/mock diffs to verify assertion depth and `runTest` dispatchers.
111
+
112
+ *On-demand specialists:* `qa-diagnostics-agent` (Logcat crash forensics) & `android-ui-expert-agent` (Compose & RTL layouts).
113
+
114
+ ---
115
+
116
+ ## Physical Device Verification & Interactive Sign-off
117
+
118
+ Software that compiles is not necessarily software that works on mobile. The harness:
119
+ 1. Resolves connected physical devices via ADB (prioritizing physical devices over emulators).
120
+ 2. Builds and installs via `run_device.py install-start`, launching the target Activity directly.
121
+ 3. Generates **2 to 3 diff-grounded manual test steps** and triggers an interactive confirmation modal (`ask_question`):
122
+ `PASS -- Device testing passed successfully` vs `FAIL -- Issue or crash encountered`.
123
+
124
+ ---
125
+
126
+ ## Quickstart in 60 Seconds
127
+
128
+ ### Option A: Via AI Chat Prompt (Recommended)
129
+ Open a new chat session in your AI assistant (Antigravity, Claude Code, Cursor, Copilot, Windsurf) at your project root and paste:
130
+
131
+ ```text
132
+ Read https://raw.githubusercontent.com/rabee-elkholy/android-agent-harness/v0.27.6/docs/install-or-update-prompt.md and follow all its instructions.
133
+ ```
134
+
135
+ ### Option B: Via Terminal CLI
136
+ ```bash
137
+ pipx install git+https://github.com/rabee-elkholy/android-agent-harness.git
138
+ android-harness init
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Supported AI Environments (14 Tools, 3 Tiers)
144
+
145
+ * **Hook-Enforced**: Google Antigravity, Claude Code, GitHub Copilot (deterministic Python OS-level interceptors).
146
+ * **Rule-Driven**: Cursor, Windsurf, Cline, Roo Code, Amazon Q, Continue, Junie, Kilo, Goose, Qwen, Codex.
147
+ * **Prompt-Only**: Aider, Zed, Devin, Amp, Factory, Jules, Warp, OpenCode (`AGENTS.md` standard).
148
+
149
+ ---
150
+
151
+ ## Documentation & Deep-Dives
152
+
153
+ * **[Architecture Guide](docs/architecture.md)**: 7-stage delivery lifecycle, safety interceptor mechanics, and preflight pipeline.
154
+ * **[Developer Workflows](docs/workflows.md)**: 10 structured engineering playbooks (TDD, forensic triage, ANR audit, preflight).
155
+ * **[Quickstart & CLI](docs/quickstart.md)**: Complete CLI command matrix and environment setup.
156
+ * **[Threat Model & Security](docs/threat-model.md)**: Analysis of 7 threat vectors and mitigation layers.
157
+ * **[Architecture Decision Records (ADRs)](docs/adr/)**: Formal ADRs (001-006) covering review gates, human git authority, and conflict adjudication.
158
+
159
+ ---
160
+
161
+ ## License
162
+
163
+ Distributed under the **MIT License**. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,118 @@
1
+ <div align="center">
2
+
3
+ # android-agent-harness
4
+
5
+ ### Deterministic Android Engineering for the AI Era
6
+ **Turn Any AI Assistant into an Uncompromising Senior Android Engineering Team.**
7
+
8
+ [![CI Build](https://img.shields.io/github/actions/workflow/status/rabee-elkholy/android-agent-harness/ci.yml?branch=main&style=flat-square&label=CI%20Build)](https://github.com/rabee-elkholy/android-agent-harness/actions/workflows/ci.yml)
9
+ [![Latest Release](https://img.shields.io/github/v/release/rabee-elkholy/android-agent-harness?color=2ea44f&style=flat-square&label=Release)](https://github.com/rabee-elkholy/android-agent-harness/releases)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](LICENSE)
11
+ [![Platform](https://img.shields.io/badge/Platform-Android%20%7C%20KMP-3DDC84?style=flat-square)](https://android.com)
12
+ [![Python: 3.10+](https://img.shields.io/badge/Python-3.10%2B-3776AB?style=flat-square)](https://python.org)
13
+ [![Quality Gate](https://img.shields.io/badge/Quality%20Gate-6--Leaf%20Pass-success?style=flat-square)](docs/architecture.md)
14
+ [![AI Tools](https://img.shields.io/badge/AI%20Tools-14%20IDs%20%7C%2011%20Templates-8A2BE2?style=flat-square)](docs/tool-support.md)
15
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](CONTRIBUTING.md)
16
+
17
+ <br/><br/>
18
+ <img src="docs/assets/banner.svg" alt="android-agent-harness: Deterministic Android Engineering for the AI Era" width="100%" />
19
+
20
+ </div>
21
+
22
+ ---
23
+
24
+ ## Why the Harness? Prompts are Polite Requests. The Harness is an OS-Level Cage.
25
+
26
+ Prompts, `.cursorrules`, and `SKILL.md` files decay as conversation context expands. AI coding assistants eventually hallucinate success, break Room migrations, ignore RTL layouts, and push unreviewed code.
27
+
28
+ The **Android Agent Harness** enforces deterministic, cryptographic, and OS-level execution barriers outside the model brain:
29
+
30
+ | Android Failure Mode | Bare AI Assistant | Android Agent Harness |
31
+ | :--- | :--- | :--- |
32
+ | **Room Migrations** | Modifies `@Entity` without migration -> app crashes on user upgrade. | **Room Guard (`room_guard.py`)**: Hard-blocks un-migrated Kotlin & Java entities. |
33
+ | **Localization & RTL** | Hardcodes strings, drops Arabic (`values-ar`), scrambles placeholders. | **Adaptive String Guard (`check_strings.py`)**: Sub-second diff-scoped parity check. |
34
+ | **ANR & Main-Thread I/O** | Runs disk/network I/O on `Dispatchers.Main`; leaks sensor listeners. | **Perf & ANR Guardian**: Enforces 60/120 FPS fluidity and lifecycle unregistration. |
35
+ | **Review Verification** | Model declares "LGTM!" and assumes its own fix works. | **Cryptographic Barrier**: Assembly (`:assembleDebug`) locked until 6 guardians emit SHA-256 tokens. |
36
+ | **Rogue Git Commits** | Runs `git commit` or `git push --force` to hide compilation mistakes. | **OS Interceptor (`pre_tool_safety.py`)**: Hard-denies unauthorized Git and ADB mutations. |
37
+ | **Legacy Codebases** | Linters output 4,000 legacy errors, stalling delivery. | **Zero Legacy Penalty**: Diff-scoped AST lint (`fast_kt_lint.py`) inspects modified lines in <1s. |
38
+
39
+ ---
40
+
41
+ ### The Cage in Action: Real-Time Interceptions
42
+
43
+ ```text
44
+ [MODEL ATTEMPTS] > git push --force origin main
45
+ [HARNESS CAGE] [DENIED] Autonomous git push is strictly blocked. Human developer authority is absolute.
46
+
47
+ [MODEL ATTEMPTS] > python agents/scripts/run_gradle_task.py :app:assembleDebug
48
+ [HARNESS CAGE] [LOCKED] Cryptographic Review Barrier active. Missing pass tokens: [BUG_PASS, PERF_PASS].
49
+
50
+ [PREFLIGHT GATE] python agents/scripts/room_guard.py
51
+ [HARNESS CAGE] [FAIL] Room database AppDatabase.kt version was NOT incremented. Destructive fallback banned.
52
+ ```
53
+
54
+ ---
55
+
56
+ ## The 6 Parallel Quality Guardians
57
+
58
+ Before `:app:assembleDebug` or device deployment, 6 specialized subagents review the immutable snapshot in parallel:
59
+
60
+ 1. **`bug-reviewer-agent`** (`BUG_PASS`): Logic bugs, Kotlin null-safety across Java boundaries, and coroutine cancellation leaks.
61
+ 2. **`convention-reviewer-agent`** (`CONVENTION_PASS`): Clean Architecture, MVI StateFlow immutability, zero inline FQCNs.
62
+ 3. **`security-reviewer-agent`** (`SECURITY_PASS`): OWASP Mobile Top 10, unexported components, and credential isolation.
63
+ 4. **`perf-anr-guardian-agent`** (`PERF_PASS`): ANR elimination, Main-thread I/O prevention, and Compose recomposition fluidity.
64
+ 5. **`regression-impact-reviewer-agent`** (`REGRESSION_PASS`): Blast radius analysis, caller graph impacts, and API signature changes.
65
+ 6. **`test-quality-reviewer-agent`** (`TEST_PASS`): **Smart Test Promotion** — automatically promoted on test/mock diffs to verify assertion depth and `runTest` dispatchers.
66
+
67
+ *On-demand specialists:* `qa-diagnostics-agent` (Logcat crash forensics) & `android-ui-expert-agent` (Compose & RTL layouts).
68
+
69
+ ---
70
+
71
+ ## Physical Device Verification & Interactive Sign-off
72
+
73
+ Software that compiles is not necessarily software that works on mobile. The harness:
74
+ 1. Resolves connected physical devices via ADB (prioritizing physical devices over emulators).
75
+ 2. Builds and installs via `run_device.py install-start`, launching the target Activity directly.
76
+ 3. Generates **2 to 3 diff-grounded manual test steps** and triggers an interactive confirmation modal (`ask_question`):
77
+ `PASS -- Device testing passed successfully` vs `FAIL -- Issue or crash encountered`.
78
+
79
+ ---
80
+
81
+ ## Quickstart in 60 Seconds
82
+
83
+ ### Option A: Via AI Chat Prompt (Recommended)
84
+ Open a new chat session in your AI assistant (Antigravity, Claude Code, Cursor, Copilot, Windsurf) at your project root and paste:
85
+
86
+ ```text
87
+ Read https://raw.githubusercontent.com/rabee-elkholy/android-agent-harness/v0.27.6/docs/install-or-update-prompt.md and follow all its instructions.
88
+ ```
89
+
90
+ ### Option B: Via Terminal CLI
91
+ ```bash
92
+ pipx install git+https://github.com/rabee-elkholy/android-agent-harness.git
93
+ android-harness init
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Supported AI Environments (14 Tools, 3 Tiers)
99
+
100
+ * **Hook-Enforced**: Google Antigravity, Claude Code, GitHub Copilot (deterministic Python OS-level interceptors).
101
+ * **Rule-Driven**: Cursor, Windsurf, Cline, Roo Code, Amazon Q, Continue, Junie, Kilo, Goose, Qwen, Codex.
102
+ * **Prompt-Only**: Aider, Zed, Devin, Amp, Factory, Jules, Warp, OpenCode (`AGENTS.md` standard).
103
+
104
+ ---
105
+
106
+ ## Documentation & Deep-Dives
107
+
108
+ * **[Architecture Guide](docs/architecture.md)**: 7-stage delivery lifecycle, safety interceptor mechanics, and preflight pipeline.
109
+ * **[Developer Workflows](docs/workflows.md)**: 10 structured engineering playbooks (TDD, forensic triage, ANR audit, preflight).
110
+ * **[Quickstart & CLI](docs/quickstart.md)**: Complete CLI command matrix and environment setup.
111
+ * **[Threat Model & Security](docs/threat-model.md)**: Analysis of 7 threat vectors and mitigation layers.
112
+ * **[Architecture Decision Records (ADRs)](docs/adr/)**: Formal ADRs (001-006) covering review gates, human git authority, and conflict adjudication.
113
+
114
+ ---
115
+
116
+ ## License
117
+
118
+ Distributed under the **MIT License**. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,26 @@
1
+ # Zoho Sprints MCP
2
+
3
+ Stdio MCP server. Same tools and mutate rules as the original engine (`update zoho`, Arabic templates, `In progress` / `Ready To ReTest`). Playbook: `../../workflows/zoho-sprints.md`.
4
+
5
+ The kit ships **code + empty workflow defaults**, not tokens.
6
+
7
+ Credentials stay on the developer's machine:
8
+
9
+ 1. Copy `config.example.json` to `~/.android-harness/zoho_sprints.json`
10
+ 2. Fill `client_id`, `client_secret`, `refresh_token`, `team_id`, `project_id`
11
+ 3. Never put that file in the app repo or in this kit
12
+
13
+ To get Zoho API credentials:
14
+
15
+ 1. Go to https://api-console.zoho.com/ and create a **Self Client**
16
+ 2. Generate a grant token with scope: `ZohoSprints.sprints.ALL,ZohoSprints.items.ALL,ZohoSprints.team.READ`
17
+ 3. Exchange the grant token for a refresh token using the Zoho OAuth endpoint
18
+ 4. Find your `team_id` and `project_id` from your Zoho Sprints URL: `https://sprints.zoho.com/team/<team_id>/project/<project_id>/...`
19
+
20
+ `workflow_defaults.json` has assignee / item-prefix / title-strip settings. Empty values are resolved at runtime by the server. Fill them during install (I.16) or configure later.
21
+
22
+ Setup (`I.16`) wires `.agents/mcp_config.json` (and Cursor `.cursor/mcp.json` when Cursor was selected) to this `server.py` and sets `ZOHO_SPRINTS_CONFIG` to an **existing** user file if one is already on the PC. It does not copy tokens.
23
+
24
+ If a config already exists at `~/.gemini/antigravity/scratch/zoho_sprints/zoho_config.json`, setup points at that path and leaves the file untouched.
25
+
26
+ Zoho Desk is not included.
@@ -0,0 +1,304 @@
1
+ """Zoho Sprints API client, OAuth authentication, caching and endpoints."""
2
+ from __future__ import annotations
3
+
4
+ import json
5
+ import os
6
+ import re
7
+ import time
8
+ import urllib.error
9
+ import urllib.parse
10
+ import urllib.request
11
+ from pathlib import Path
12
+ from typing import Any
13
+
14
+ from _formatter import format_zoho_html
15
+
16
+ HERE = Path(__file__).resolve().parent
17
+
18
+ WORKFLOW_KEYS = (
19
+ "team_id",
20
+ "project_id",
21
+ "default_user_id",
22
+ "item_prefix",
23
+ "title_strip_suffixes",
24
+ "fallback_item_type_id",
25
+ "fallback_priority_id",
26
+ "fallback_sprint_id",
27
+ )
28
+
29
+
30
+ def _workflow_defaults() -> dict:
31
+ path = HERE / "workflow_defaults.json"
32
+ if not path.is_file():
33
+ return {}
34
+ data = json.loads(path.read_text(encoding="utf-8"))
35
+ return data if isinstance(data, dict) else {}
36
+
37
+
38
+ class ZohoSprintsAPI:
39
+ METADATA_CACHE_TTL = 300
40
+
41
+ def __init__(self, config_path: str):
42
+ self.config_path = config_path
43
+ self._meta_cache: dict[str, tuple[float, dict]] = {}
44
+ self.base_url = "https://sprintsapi.zoho.com/zsapi"
45
+ self.load_config()
46
+
47
+ def load_config(self) -> None:
48
+ with open(self.config_path, encoding="utf-8") as f:
49
+ user = json.load(f)
50
+ if not isinstance(user, dict):
51
+ raise RuntimeError("Zoho Sprints config must be a JSON object.")
52
+ defaults = _workflow_defaults()
53
+ self.config = dict(user)
54
+ for key in WORKFLOW_KEYS:
55
+ if key not in user or user.get(key) in (None, "", []):
56
+ if key in defaults:
57
+ self.config[key] = defaults[key]
58
+ self.access_token = user.get("access_token")
59
+ self.refresh_token = user.get("refresh_token")
60
+ self.client_id = user.get("client_id")
61
+ self.client_secret = user.get("client_secret")
62
+ self.auth_domain = user.get("auth_domain") or "https://accounts.zoho.com"
63
+ self.team_id = str(self.config.get("team_id") or "").strip()
64
+ self.project_id = str(self.config.get("project_id") or "").strip()
65
+ self.default_user_id = str(self.config.get("default_user_id") or "").strip()
66
+ self.item_prefix = str(self.config.get("item_prefix") or "").strip()
67
+ self.fallback_item_type_id = str(self.config.get("fallback_item_type_id") or "").strip()
68
+ self.fallback_priority_id = str(self.config.get("fallback_priority_id") or "").strip()
69
+ self.fallback_sprint_id = str(self.config.get("fallback_sprint_id") or "").strip()
70
+ suffixes = self.config.get("title_strip_suffixes") or []
71
+ self.title_strip_suffixes = [str(s) for s in suffixes if str(s).strip()]
72
+ if not self.team_id or not self.project_id:
73
+ raise RuntimeError("Zoho Sprints config needs team_id and project_id.")
74
+
75
+ def save_config(self) -> None:
76
+ path = Path(self.config_path)
77
+ path.parent.mkdir(parents=True, exist_ok=True)
78
+ try:
79
+ if hasattr(os, "O_CREAT") and os.name != "nt":
80
+ fd = os.open(str(path), os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
81
+ with open(fd, "w", encoding="utf-8") as f:
82
+ json.dump(self.config, f, indent=2)
83
+ else:
84
+ with open(self.config_path, "w", encoding="utf-8") as f:
85
+ json.dump(self.config, f, indent=2)
86
+ except Exception:
87
+ with open(self.config_path, "w", encoding="utf-8") as f:
88
+ json.dump(self.config, f, indent=2)
89
+
90
+ def sanitize_task_name(self, name: str) -> str:
91
+ cleaned = name.strip()
92
+ for suffix in self.title_strip_suffixes:
93
+ cleaned = re.sub(
94
+ r"\s*[-–—]\s*" + re.escape(suffix) + r"\s*$",
95
+ "",
96
+ cleaned,
97
+ flags=re.IGNORECASE,
98
+ ).strip()
99
+ return cleaned
100
+
101
+ def refresh_token_if_needed(self) -> None:
102
+ url = f"{self.auth_domain}/oauth/v2/token"
103
+ params = {
104
+ "refresh_token": self.refresh_token,
105
+ "client_id": self.client_id,
106
+ "client_secret": self.client_secret,
107
+ "grant_type": "refresh_token",
108
+ }
109
+ encoded = urllib.parse.urlencode(params).encode("utf-8")
110
+ req = urllib.request.Request(url, data=encoded, method="POST")
111
+ try:
112
+ with urllib.request.urlopen(req, timeout=30.0) as resp:
113
+ res = json.loads(resp.read().decode("utf-8"))
114
+ except Exception as e:
115
+ raise RuntimeError(f"Zoho OAuth token refresh network error: {e}") from e
116
+ if "access_token" in res:
117
+ self.access_token = res["access_token"]
118
+ self.config["access_token"] = self.access_token
119
+ self.save_config()
120
+ else:
121
+ err = res.get("error", "unknown_oauth_error")
122
+ raise RuntimeError(f"Zoho OAuth token refresh failed: {err}. Re-authenticate in config.")
123
+
124
+ def _request(self, path: str, method: str = "GET", params: dict | None = None, data: dict | None = None) -> Any:
125
+ url = f"{self.base_url}{path}"
126
+ if params:
127
+ url += "?" + urllib.parse.urlencode(params)
128
+ headers = {"Authorization": f"Zoho-oauthtoken {self.access_token}"}
129
+ encoded_data = None
130
+ if data is not None:
131
+ encoded_data = urllib.parse.urlencode(data).encode("utf-8")
132
+ headers["Content-Type"] = "application/x-www-form-urlencoded"
133
+
134
+ max_retries = 3
135
+ for attempt in range(max_retries):
136
+ req = urllib.request.Request(url, data=encoded_data, headers=headers, method=method)
137
+ try:
138
+ with urllib.request.urlopen(req, timeout=30.0) as resp:
139
+ return json.loads(resp.read().decode("utf-8"))
140
+ except urllib.error.HTTPError as exc:
141
+ err_msg = exc.read().decode("utf-8", errors="replace")
142
+ if exc.code in (429, 502, 503, 504) and attempt < max_retries - 1:
143
+ time.sleep(1.0 * (attempt + 1))
144
+ continue
145
+ if exc.code == 401 or "Invalid oauthToken" in err_msg or "invalid_token" in err_msg:
146
+ self.refresh_token_if_needed()
147
+ headers["Authorization"] = f"Zoho-oauthtoken {self.access_token}"
148
+ req2 = urllib.request.Request(url, data=encoded_data, headers=headers, method=method)
149
+ try:
150
+ with urllib.request.urlopen(req2, timeout=30.0) as resp2:
151
+ return json.loads(resp2.read().decode("utf-8"))
152
+ except Exception as retry_exc:
153
+ raise RuntimeError(f"Zoho request failed after token refresh: {retry_exc}") from retry_exc
154
+ raise RuntimeError(f"HTTP Error {exc.code}: {err_msg}") from exc
155
+ except Exception as exc:
156
+ if attempt < max_retries - 1 and isinstance(exc, (urllib.error.URLError, TimeoutError)):
157
+ time.sleep(1.0 * (attempt + 1))
158
+ continue
159
+ raise RuntimeError(f"Zoho request failed ({method} {path}): {exc}") from exc
160
+
161
+ def get_sprints(self) -> dict:
162
+ return self._request(
163
+ f"/team/{self.team_id}/projects/{self.project_id}/sprints/",
164
+ params={"action": "data", "type": "[1,2,3,4]"},
165
+ )
166
+
167
+ def get_active_sprint_id(self) -> str:
168
+ ids = self.get_sprints().get("sprintIds") or []
169
+ if ids:
170
+ return ids[0]
171
+ if self.fallback_sprint_id:
172
+ return self.fallback_sprint_id
173
+ raise RuntimeError("No sprints found for this Zoho project.")
174
+
175
+ def _cached_request(self, cache_key: str, path: str, params: dict | None = None) -> dict:
176
+ cached = self._meta_cache.get(cache_key)
177
+ if cached:
178
+ ts, data = cached
179
+ if time.time() - ts < self.METADATA_CACHE_TTL:
180
+ return data
181
+ result = self._request(path, params=params)
182
+ self._meta_cache[cache_key] = (time.time(), result)
183
+ return result
184
+
185
+ def get_item_types(self) -> dict:
186
+ return self._cached_request(
187
+ "item_types",
188
+ f"/team/{self.team_id}/projects/{self.project_id}/itemtype/",
189
+ params={"action": "data"},
190
+ )
191
+
192
+ def get_statuses(self) -> dict:
193
+ return self._cached_request(
194
+ "statuses",
195
+ f"/team/{self.team_id}/projects/{self.project_id}/itemstatus/",
196
+ params={"action": "data"},
197
+ )
198
+
199
+ def get_priorities(self) -> dict:
200
+ return self._cached_request(
201
+ "priorities",
202
+ f"/team/{self.team_id}/projects/{self.project_id}/priority/",
203
+ params={"action": "data"},
204
+ )
205
+
206
+ def list_items(self, sprint_id: str) -> dict:
207
+ return self._request(
208
+ f"/team/{self.team_id}/projects/{self.project_id}/sprints/{sprint_id}/item/",
209
+ params={"action": "sprintitems", "subitem": "true"},
210
+ )
211
+
212
+ def resolve_item(self, item_input: str, sprint_id: str | None = None) -> tuple[str, str]:
213
+ raw_input = str(item_input).strip()
214
+ match = re.search(r"(\d+)", raw_input)
215
+ target_num = match.group(1) if match else raw_input
216
+ sprint_ids = self.get_sprints().get("sprintIds") or []
217
+ if len(raw_input) >= 15 and raw_input.isdigit():
218
+ if sprint_id:
219
+ return sprint_id, raw_input
220
+ for sid in sprint_ids:
221
+ try:
222
+ res = self.get_item_details(sid, raw_input)
223
+ if res.get("status") == "success":
224
+ return sid, raw_input
225
+ except Exception:
226
+ continue
227
+ search_sprints = [sprint_id] if sprint_id else sprint_ids
228
+ prefix = self.item_prefix
229
+ for sid in search_sprints:
230
+ items_data = self.list_items(sid)
231
+ item_prop = items_data.get("item_prop") or {}
232
+ item_no_idx = item_prop.get("itemNo")
233
+ item_jobj = items_data.get("itemJObj") or {}
234
+ for iid, row in item_jobj.items():
235
+ if iid == raw_input:
236
+ return sid, iid
237
+ if item_no_idx is not None and len(row) > item_no_idx:
238
+ item_no = str(row[item_no_idx])
239
+ labels = {item_no, f"I{item_no}", target_num}
240
+ if prefix:
241
+ labels.add(f"{prefix}{item_no}")
242
+ if raw_input in labels or item_no == target_num:
243
+ return sid, iid
244
+ raise RuntimeError(
245
+ f"Item '{raw_input}' not found in {len(search_sprints)} sprint(s). "
246
+ "Verify the task id or pass sprint_id."
247
+ )
248
+
249
+ def get_item_details(self, sprint_id: str | None = None, item_id: str | None = None) -> dict:
250
+ if not sprint_id or (item_id and (not str(item_id).isdigit() or len(str(item_id)) < 15)):
251
+ sprint_id, item_id = self.resolve_item(item_id or sprint_id or "", sprint_id)
252
+ return self._request(
253
+ f"/team/{self.team_id}/projects/{self.project_id}/sprints/{sprint_id}/item/{item_id}/",
254
+ params={"action": "details"},
255
+ )
256
+
257
+ def create_item(
258
+ self,
259
+ sprint_id: str,
260
+ name: str,
261
+ item_type_id: str,
262
+ priority_id: str,
263
+ description: str = "",
264
+ points: str = "0",
265
+ parent_item_id: str | None = None,
266
+ users: list | None = None,
267
+ ) -> dict:
268
+ data: dict[str, str] = {
269
+ "name": self.sanitize_task_name(name),
270
+ "projitemtypeid": item_type_id,
271
+ "projpriorityid": priority_id,
272
+ "description": format_zoho_html(description),
273
+ }
274
+ assigned = users if users is not None else ([self.default_user_id] if self.default_user_id else None)
275
+ if assigned:
276
+ data["users"] = json.dumps(assigned)
277
+ if points and points != "0":
278
+ data["points"] = points
279
+ if parent_item_id:
280
+ path = f"/team/{self.team_id}/projects/{self.project_id}/sprints/{sprint_id}/item/{parent_item_id}/subitem/"
281
+ else:
282
+ path = f"/team/{self.team_id}/projects/{self.project_id}/sprints/{sprint_id}/item/"
283
+ return self._request(path, method="POST", data=data)
284
+
285
+ def update_item_status(self, sprint_id: str, item_id: str, status_id: str) -> dict:
286
+ return self._request(
287
+ f"/team/{self.team_id}/projects/{self.project_id}/sprints/{sprint_id}/item/{item_id}/",
288
+ method="POST",
289
+ data={"statusid": status_id},
290
+ )
291
+
292
+ def update_item_description(self, sprint_id: str, item_id: str, description: str) -> dict:
293
+ return self._request(
294
+ f"/team/{self.team_id}/projects/{self.project_id}/sprints/{sprint_id}/item/{item_id}/",
295
+ method="POST",
296
+ data={"description": format_zoho_html(description)},
297
+ )
298
+
299
+ def add_comment(self, sprint_id: str, item_id: str, content: str) -> dict:
300
+ return self._request(
301
+ f"/team/{self.team_id}/projects/{self.project_id}/sprints/{sprint_id}/item/{item_id}/notes/",
302
+ method="POST",
303
+ data={"name": format_zoho_html(content)},
304
+ )