Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / AGENTS.md
| 1 | # AGENTS.md — Modern-Apps |
| 2 | |
| 3 | Monorepo: ~100 Gradle modules + Rust workspace. Do scoped work only. |
| 4 | |
| 5 | ## 1. Scope first (law) |
| 6 | 1. Each module has its own `AGENTS.md` (e.g. `notes/AGENTS.md`, `games/voxels/AGENTS.md`, `library/ui/AGENTS.md`) — auto-loaded on read. Read it instead of listing the dir. |
| 7 | 2. State `Scope: <dir/> + <shared>` before any scan. Stay inside those prefixes. |
| 8 | 3. Expand only with one-line justification. Never root-recurse. |
| 9 | 4. Don't read `CONTRIBUTING.md` whole (26KB). Pull a section only on demand. |
| 10 | 5. Prefer 1 targeted read over 10 searches. |
| 11 | |
| 12 | ### How to pick scope |
| 13 | | Task | Scope | |
| 14 | | :--- | :--- | |
| 15 | | UI bug in one app | that app + `library/ui` | |
| 16 | | DB / Room | that app + `library/room` | |
| 17 | | Network / TLS / certs | that app + `library/network` | |
| 18 | | Icons, scaffold, theme, messenger | that app + `library/ui` | |
| 19 | | Cross-app share / assistant tool | both apps + `library` (DTO in `library.intents.<app>`) | |
| 20 | | New app module | `settings.gradle.kts` + `build-logic/` + reference app (`backup/`, else `notes/`) | |
| 21 | | Store listing / screenshots | that app + `metadata_data/` | |
| 22 | | Rust / JNI / native | that app's `src/main/rust/` + root `Cargo.toml` | |
| 23 | | Build convention change | `build-logic/` only | |
| 24 | | Lint rule change | `lint-rules/` only | |
| 25 | | Games hub achievement | game + `sdk/games` | |
| 26 | |
| 27 | ### Shared modules (only pull when row above says so) |
| 28 | | Module | Path | What it owns | |
| 29 | | :--- | :--- | :--- | |
| 30 | | base | `library/` | nav keys, `AssistantIntent`, IPC DTOs (`library.intents.<app>`), `RoomRepository` base | |
| 31 | | ui | `library/ui/` | `Icons.kt` (ONLY `Icon()`/`painterResource()` allowed), `AppScaffold` family, `DynamicTheme`, messenger/`AppMessages`, motion helpers | |
| 32 | | network | `library/network/` | `NetworkClient`, pinned CAs in `assets/ca/`, `TrustBundle` (FIRST_PARTY/STANDARD/EXTENDED/SYSTEM/ESIM), `OfflineAware` banner | |
| 33 | | room | `library/room/` | Room 3 + SQLCipher (`implementRoom(libs)`) | |
| 34 | | map / ml / ocr | `library/map/`, `library/ml/`, `library/ocr/` | vector maps (INTERNET itself) / inference / OCR | |
| 35 | | image/media | `library/image/`, `library/media/` | image loading (offline-local; network apps opt into HTTP via `Builder.remote()` with a `NetworkClient` fetch fn) / AV playback | |
| 36 | | e2ee-p2p | `library/e2ee-p2p/` | E2EE, p2p, `Hkdf` | |
| 37 | | widgets/work | `library/widgets/`, `library/work/` | Glance widgets / WorkManager | |
| 38 | | biometric/ink | `library/biometric/`, `library/ink/` | biometric / stylus ink | |
| 39 | | downloadservice | `library/downloadservice/` | foreground downloads (INTERNET itself) | |
| 40 | | locationprovider | `library/locationprovider/` | location abstraction | |
| 41 | | aosp-stubs | `library/aosp-stubs/` | compile-only hidden-API stubs | |
| 42 | | sdk:games/cast/openassistant | `sdk/games/`, `sdk/cast/`, `sdk/openassistant/` | achievements / casting / assistant tools | |
| 43 | | build-logic | `build-logic/` | `common-conventions-app`, `launcherIcon`, `rustNativeLib` | |
| 44 | | lint-rules | `lint-rules/` | ToastUsage + DirectComposeAnimation + FileLength + DirectAndroidLog (fatal) + 9 advisory | |
| 45 | |
| 46 | ### Apps (Gradle key → dir) |
| 47 | Reference: `backup/` satisfies every rule; `notes/` second + `intents/` demo. `camera` + `games/voxels` hand-commit screenshots. |
| 48 | Full canonical index (Gradle key → dir + group + notes): `.llms/repo-map.md`. |
| 49 | `appstore→appstore/` `astronomy→astronomy/` `auto→auto/,auto/protocol/` `backup→backup/` `calculator→calculator/` `calendar→calendar/` `camera→camera/` `cast→cast/,cast/protocol/,cast/tv/` `clock→clock/` `code→code/` `communicate→communicate/` `contacts→contacts/` `education→education/` `email→email/` `emergency→emergency/` `euicc→euicc/` `everysync→everysync/` `files→files/` `findfamily→findfamily/` `findfamily-ios→apple/FindFamily/` (SwiftPM/xtool, not Gradle) `flashcards→flashcards/` `fooddelivery→fooddelivery/` `health→health/` `keyboard→keyboard/` `launcher→launcher/` `logviewer→logviewer/` `maps→maps/` `measure→measure/` `music→music/` `networklocation→networklocation/` `notes→notes/` `office→office/` `openassistant→openassistant/` `passwords→passwords/` `pdf→pdf/` `photos→photos/` `parentalcontrols→parentalcontrols/` `screentime→screentime/` `setupwizard→setupwizard/` `share→share/` `speech→speech/` `taxi→taxi/` `things→things/` `todo→todo/` `translate→translate/` `travel→travel/` `tuner→tuner/` `updater→updater/` `vpn→vpn/` `weather→weather/` `web→web/` `youpipe→youpipe/,youpipe/extractor/` `games-hub→games/hub/` `games-arrows→games/arrows/` `games-chess→games/chess/` `games-logicgate→games/logicgate/` `games-minesweeper→games/minesweeper/` `games-nonogram→games/nonogram/` `games-pipes→games/pipes/` `games-solitaire→games/solitaire/` `games-sudoku→games/sudoku/` `games-unblockjam→games/unblockjam/` `games-voxels→games/voxels/` `games-wordmaker→games/wordmaker/` |
| 50 | Slash == colon for Gradle (`games/voxels` == `games:voxels`). |
| 51 | |
| 52 | ### Never scan |
| 53 | `target/`, `scripts/`, `build/`, `.gradle/`, `.kotlin/`, `*/build/`, `*/schemas/` (single file ok), `metadata_data/photos/`, `third_party/`, `firmware/`, `*.onnx`, `*.log`, `personal/`. |
| 54 | |
| 55 | ### Backend server (outside this repo) |
| 56 | The backend (relay server for findfamily/everysync/office/voxels) lives outside this repo: |
| 57 | |
| 58 | - Server checkout: `../location_share_server` (sibling of this repo root). On this dev machine: `C:\Users\Vayun\Documents\code\location_share_server`. |
| 59 | - Live server SSH: `ssh [email protected]` |
| 60 | - Server env template: `../location_share_server/.env.example` (copy to `../location_share_server/.env`, never commit secrets). |
| 61 | - The server's canonical API host is `api.maproj.org` (same Cloudflare FIRST_PARTY pins). Legacy `findfamily.cc` / `api.findfamily.cc` still serve every API path identically so older app versions keep working. |
| 62 | - Cloudflare R2: see `../location_share_server/src/handlers/os_admin.rs` for `R2::from_env()`; required vars `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`, plus `R2_ENDPOINT` or `R2_ACCOUNT_ID`. |
| 63 | |
| 64 | ## 2. Conventions (check every time) |
| 65 | - `Toast` banned (fatal lint). Use `rememberMessenger().show()` in composable, `AppMessages.show()` elsewhere. |
| 66 | - Never `Icon()`/`painterResource()`/`androidx.compose.material.icons.*` in app. Add `IconXxx()` to `library/ui/.../Icons.kt`. |
| 67 | - Never raw `Scaffold`. Use `AppScaffold` family. Never raw `androidx.compose.animation` at call site — use `library.ui` helpers. Never `imePadding()/navigationBarsPadding()/systemBarsPadding()` in `library.ui`. |
| 68 | - Room 3 only. Literal `androidx.room.` flagged even in comments. Never `buildDatabase()` at call site — subclass `library.room.RoomRepository`. |
| 69 | - Network only via `library.network.NetworkClient` + `TrustBundle` narrowest (`FIRST_PARTY/STANDARD/EXTENDED/SYSTEM/ESIM`). |
| 70 | - Package roots closed set: `ui data domain platform network intents service provider widget notifications auth sync telephony`. No `util/`. One public `@Composable` per file, named as file. `domain/` pure (no Android/Compose). |
| 71 | - Escape hatches verbatim: `// PACKAGE STRUCTURE EXCEPTION (JNI)`, `// RAW SCAFFOLD EXCEPTION: <reason>`, `// TOAST EXCEPTION: <reason>`, `// RAW ANIMATION EXCEPTION: <reason>`. |
| 72 | - detekt rules live in `detekt.yml` (ui/domain/odf/service scoping rationale inline). Fix code, not config, to green a module. |
| 73 | |
| 74 | ## 3. Verify (slice touched, never whole repo) |
| 75 | ``` |
| 76 | ./gradlew :<module>:compileDevKotlin |
| 77 | ./gradlew :<module>:lint |
| 78 | ./gradlew :<module>:checkMetadata |
| 79 | ``` |
| 80 | Gradle defaults to small heap (`-Xmx8g`, 2 workers). Don't raise it. New build logic must be configuration-cache compatible. New/changed UI previews: `./gradlew :<module>:metadata`. |
| 81 | Rust builds use the fast cargo profile for dev tasks and the release profile for release/ambiguous tasks, overridable with `-Pmodernapps.rustProfile=release|fast`. |
| 82 | |
| 83 | ## 4. Tools — use these, not raw gradle/adb |
| 84 | Work in repo dir. Experiments/logs go in `analysis/` (gitignored). |
| 85 | |
| 86 | `./install` — build + session-install (handles `.idsig`/fs-verity + `versionCodeOverride` automatically): |
| 87 | ``` |
| 88 | ./install <module> [...] # dev by default |
| 89 | ./install [dev|release] <module> [...] |
| 90 | ./install voxels # shorthand → games:voxels; dooraccess → personal:dooraccess |
| 91 | ./install dev games/voxels # slash == colon |
| 92 | ./install contacts calendar # multi-module, one gradlew invocation |
| 93 | ./install 9 maps # 8 = Pixel 8, 9 = Pixel 9 (default: first non-emulator) |
| 94 | ./install all / ./install dev all # full repo (auto big-heap); release all caps R8 workers |
| 95 | ./install --dry-run dev contacts |
| 96 | ``` |
| 97 | Rules: `dev` default, `release` only when asked, `debug` blocked. Never uninstall / clear data (emulator-only exception, never touch physical device). Never give placeholder commands — output copy-pasteable. |
| 98 | |
| 99 | `./dhu` — Desktop Head Unit loopback for `auto/` (Pixel 8 default): |
| 100 | ``` |
| 101 | ./dhu # adb forward tcp:5277 + live logcat → analysis/dhu-<ts>.log + DHU window |
| 102 | ./dhu -NoLog # DHU only |
| 103 | ./dhu -DeviceId <serial> # non-default device |
| 104 | ``` |
| 105 | |
| 106 | `./search` — scoped string search (bash only, `rg` when present, grep fallback). Pattern + optional `-m` (module) / `-p` (root package) filters, composable: |
| 107 | ``` |
| 108 | ./search DB_NAME -m notes -p data # both: data/ package of notes/ only |
| 109 | ./search RoomRepository -m notes # module only |
| 110 | ./search TrustBundle -m web -p network # module + package combined |
| 111 | ./search "foo" -m voxels # shorthand → games:voxels; slash == colon; -m all = everything |
| 112 | ./search "bar" -m notes --files-only --max 20 |
| 113 | ``` |
| 114 | Never grep repo-wide when a filter will do. Always excluded: `target/ build/ .gradle/ .kotlin/ .git/ .llms/ analysis/ *.log *.onnx metadata_data/photos/`. |
| 115 | |
| 116 | `./check` — static verification without building: `:<module>:detekt` (rules in `detekt.yml`) + `:<module>:lint` + `cargo check/clippy/fmt/doc --locked` for Rust modules (workspace members via `-p`, standalone crates in-dir; fmt is advisory-only until the tree is fmt-clean): |
| 117 | ``` |
| 118 | ./check <module> [...] # e.g. ./check notes backup; ./check voxels |
| 119 | ./check all # every app + library module (pure-JVM modules excluded) |
| 120 | ``` |
| 121 | Findings fail the task. Only `notes/`, `backup/`, `library/ui/`, `games/voxels/` are detekt-clean today; other modules carry incremental backlog — fixing a module means `./check <module>` goes green, not config relaxation. |
| 122 | |
| 123 | ### On-device file map (per-module `AGENTS.md` carries concrete names) |
| 124 | - Room (`RoomRepository`, `DB_NAME` in `data/`): `/data/data/<pkg>/databases/<DB_NAME>` (+ `-wal`/`-shm` sidecars). SQLCipher-encrypted. `getDatabasePath`/`deleteDatabase`/`LEGACY_*` names are the same dir. |
| 125 | - DataStore: `preferencesDataStore(name=X)` → `/data/data/<pkg>/files/datastore/X.preferences_pb`; shared `DataStoreUtils` → `/data/data/<pkg>/files/datastore_default.preferences_pb`. |
| 126 | - Downloads (`InitialDownloadChecker`/`InitialModelDownloadChecker`, file lists in `platform/` or `data/`): each `fileName` → `/storage/emulated/0/Android/data/<pkg>/files/<fileName>` (`+.part` while downloading). |
| 127 | - Assets (`src/main/assets/`): APK-bundled, read via `AssetManager` — no on-device path. Library assets (e.g. `library/network` CAs) ship inside each dependent APK. |
| 128 | - Library modules have no `applicationId`: paths resolve under the hosting app's `<pkg>`. |
| 129 | |
| 130 | ## 5. Git / safety |
| 131 | - Other agents share the tree. Prohibited except reading state: `stash/revert/reset/checkout . /clean` etc. Only `add` + `commit` allowed, and only paths you changed — check `git status` first, never `add -A/.`, never stage without committing instantly. |
| 132 | - Commit message: line 1 is ≤80 chars, always in the format `appname: short description (#iss)`. Then a blank line and a full body: what changed and why, the context (bug/symptom, root cause, constraints, alternatives rejected), notable implementation details, user-visible effect, and how it was verified. Write in plain prose/bullets, wrapped at ~72 chars. The body feeds AI-written release notes, so make it complete; never stop at one line. |
| 133 | - LF only; never commit line-ending churn. `FAIL_ON_PROJECT_REPOS` — never add repos in modules. Read `SUPPLY_CHAIN_RISKS.md` before new third-party dep. |