|
| 1 | +# Coding Agent Instructions |
| 2 | + |
| 3 | +These instructions apply to coding agents working in this repository. |
| 4 | + |
| 5 | +## Project Shape |
| 6 | + |
| 7 | +- The Git repository root is `melodee-player/`, but the Android Gradle project |
| 8 | + root is `melodee-player/src/`. |
| 9 | +- Run Gradle from `src/`, not from the repository root. |
| 10 | +- The app module is `src/app`; the macrobenchmark module is `src/benchmark`. |
| 11 | +- The app targets Melodee API v1 and Android SDK 36, with minSdk 23. |
| 12 | +- The local Android SDK path used in this workspace is |
| 13 | + `/home/steven/Android/Sdk`. |
| 14 | + |
| 15 | +## Change Discipline |
| 16 | + |
| 17 | +- Keep edits scoped to the requested behavior and existing architecture. |
| 18 | +- Do not revert user changes or unrelated workspace changes. |
| 19 | +- Prefer the existing Kotlin, Compose, Retrofit, Media3, coroutine, and |
| 20 | + SharedPreferences patterns before introducing new frameworks. |
| 21 | +- Treat authentication, Android Auto, media playback, API models, and Gradle |
| 22 | + configuration as high-risk areas. Add or update tests when touching them. |
| 23 | +- Do not add local app-data SQLite/Room persistence unless explicitly requested. |
| 24 | + Media3 already uses its own SQLite-backed cache metadata internally. |
| 25 | + |
| 26 | +## Changelog |
| 27 | + |
| 28 | +- Update `CHANGELOG.md` for every notable change before finishing work. |
| 29 | +- Add new entries under `## [Unreleased]` by default. If the user says the |
| 30 | + current version has not been released yet, or the task is explicitly part of |
| 31 | + an in-progress release section such as `## [1.8.0]`, update that active |
| 32 | + version section instead. |
| 33 | +- Follow the existing Keep a Changelog categories: `Added`, `Changed`, |
| 34 | + `Deprecated`, `Removed`, `Fixed`, and `Security`. |
| 35 | +- Include user-visible behavior changes, API compatibility changes, |
| 36 | + authentication/session changes, Android Auto changes, dependency/toolchain |
| 37 | + changes, security hardening, and important test coverage additions. |
| 38 | +- Do not add changelog entries for purely mechanical formatting changes unless |
| 39 | + they materially affect users, maintainers, CI, or release behavior. |
| 40 | +- Keep entries concise and factual. Mention the affected subsystem when useful. |
| 41 | +- If a task intentionally skips a changelog update, state why in the final |
| 42 | + response. |
| 43 | + |
| 44 | +## README And Docs |
| 45 | + |
| 46 | +- Keep `README.md` accurate when setup, build commands, API behavior, |
| 47 | + authentication behavior, Android Auto behavior, or project layout changes. |
| 48 | +- Some files under `docs/` are historical review/planning artifacts. Do not |
| 49 | + treat them as more authoritative than current source, Gradle files, |
| 50 | + `README.md`, and `CHANGELOG.md`. |
| 51 | +- If docs contradict source code, verify against source before editing. |
| 52 | + |
| 53 | +## Authentication And API |
| 54 | + |
| 55 | +- Preserve refresh tokens when API responses omit rotated refresh-token values. |
| 56 | +- Android Auto must be able to restore existing stored authentication without |
| 57 | + requiring the user to open the handheld UI again. |
| 58 | +- Invalid/rejected refresh tokens may clear authentication; transient refresh |
| 59 | + failures should keep stored credentials available for retry. |
| 60 | +- API contract changes should be covered by tests under |
| 61 | + `src/app/src/test/java/com/melodee/autoplayer/api` or related model tests. |
| 62 | +- The current OpenAPI reference used during this work was |
| 63 | + `/home/steven/Downloads/v1.json`; verify with the user before assuming that |
| 64 | + path is still current in future sessions. |
| 65 | + |
| 66 | +## Android Auto And Playback |
| 67 | + |
| 68 | +- `MusicService` is exported for Android Auto discovery; caller validation must |
| 69 | + remain strict before returning browse content. |
| 70 | +- Do not trust Android Auto callers by substring package-name checks. Use exact |
| 71 | + trusted packages and package/UID ownership checks. |
| 72 | +- UI playback state should be driven by service/manager flows where possible, |
| 73 | + not by UI-owned polling loops. |
| 74 | +- When changing playback state, verify handheld UI and Android Auto behavior: |
| 75 | + current song, play/pause, queue, metadata, notification controls, and auth |
| 76 | + restoration. |
| 77 | + |
| 78 | +## Validation |
| 79 | + |
| 80 | +- Always run: |
| 81 | + |
| 82 | + ```bash |
| 83 | + git diff --check |
| 84 | + ``` |
| 85 | + |
| 86 | +- For Markdown-only changes, `git diff --check` is usually enough. |
| 87 | +- For test-only changes, run the targeted test class and preferably the full |
| 88 | + unit suite: |
| 89 | + |
| 90 | + ```bash |
| 91 | + cd src |
| 92 | + ANDROID_HOME=/home/steven/Android/Sdk ./gradlew testDebugUnitTest --stacktrace |
| 93 | + ``` |
| 94 | + |
| 95 | +- For production Android code, build logic, shared models, authentication, |
| 96 | + Android Auto, networking, or playback changes, run the full build: |
| 97 | + |
| 98 | + ```bash |
| 99 | + cd src |
| 100 | + ANDROID_HOME=/home/steven/Android/Sdk ./gradlew build --stacktrace |
| 101 | + ``` |
| 102 | + |
| 103 | +- Connected tests and benchmarks require a device or emulator: |
| 104 | + |
| 105 | + ```bash |
| 106 | + cd src |
| 107 | + ANDROID_HOME=/home/steven/Android/Sdk ./gradlew connectedDebugAndroidTest |
| 108 | + ANDROID_HOME=/home/steven/Android/Sdk ./gradlew :benchmark:connectedCheck |
| 109 | + ``` |
| 110 | + |
| 111 | +- If a validation command cannot be run, explain why and report what was run |
| 112 | + instead. |
| 113 | + |
| 114 | +## Final Response Expectations |
| 115 | + |
| 116 | +- Summarize what changed, what was verified, and any residual risk. |
| 117 | +- Mention skipped validations explicitly. |
| 118 | +- Keep file references precise for important source or documentation changes. |
0 commit comments