Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / youpipe / AGENTS.md
| 1 | # AGENTS.md — youpipe/ (':youpipe') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `youpipe/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | _Install: ./install youpipe (dev by default)._ |
| 6 | - Gradle: :youpipe / dir: youpipe/ |
| 7 | - Package roots present: ui, data, domain, platform, network, nativeext, intents |
| 8 | - Entry files: MainActivity.kt, Route.kt, Navigation.kt, YouPipeApplication.kt |
| 9 | - Deps: :library:image, :youpipe:extractor, :sdk:cast, :library:room, :library:work, :library:network |
| 10 | - Metadata: metadata_data/youpipe.md (present) |
| 11 | - Rust: yes / screenshotTest: yes |
| 12 | |
| 13 | ## Overview |
| 14 | **Purpose:** An ad-free Material 3 YouTube client (NewPipe extractor lineage) with subscriptions, history, downloads, and recommendations. Requires internet. |
| 15 | **Key features:** |
| 16 | - Subscription feed with categories, auto-refresh (`SubscriptionFetchTask`), watch history + resume, playlists, and Watch Later |
| 17 | - Video playback via Media3/ExoPlayer with SABR streaming, SponsorBlock, chapters, background audio, and Picture-in-Picture |
| 18 | - Offline downloads (`DownloadManager`/`DownloadWorker`) with import/export, plus Cast-to-TV via `:sdk:cast` |
| 19 | - Local recommendations engine with tunable interests/keywords and impression tracking |
| 20 | **Architecture / data-flow:** Tabbed-pager `ui/` (`Main` tabs + `VideoPage`/`ChannelPage`/dialog routes) over `platform/YouPipeViewModel` → `data/` Room (`SubscriptionDatabase`, repository + per-entity stores) fed by `SubscriptionFetchTask` and the Rust InnerTube extractor (`rustNativeLib youpipe_extractor`) bridged via `nativeext/YouPipeNative` + `network/Extractor.kt`; playback runs through `platform/PlaybackService` + the `network/sabr/` session stack. `onCreateBeforeContent` touches the VM so its hourly task arms, then resolves the launch backstack (share-target → watch link → persisted default page). |
| 21 | **Entry points + reading order:** `Route` (`Main(tab)` / `VideoPage` / `ChannelPage` / `SubscriptionVideosPage` / `PlaylistDetail` / `Downloads` + dialogs) → `MainActivity.kt` (`resolveInitialBackStack`) → `ui/VideoPage.kt` → `platform/YouPipeViewModel.kt` → `network/Extractor.kt` → `data/SubscriptionRepository.kt`. |
| 22 | **Gotchas:** |
| 23 | - `resolveInitialBackStack` runs synchronously in `onCreate` (before `setContent`) — keep it side-effect free |
| 24 | - PiP close and activity destroy deliberately do NOT stop `PlaybackService`; audio keeps playing and switches to audio-only |
| 25 | - SABR attestation goes through the `network/sabr/` WebView/token stack — changes there break playback long before the player UI does |
| 26 | |
| 27 | ## Key files |
| 28 | ### Root — entry + navigation |
| 29 | - com/vayunmathur/youpipe/MainActivity.kt — share/deep-link backstack, default page |
| 30 | - com/vayunmathur/youpipe/Route.kt |
| 31 | - com/vayunmathur/youpipe/Navigation.kt |
| 32 | - com/vayunmathur/youpipe/YouPipeApplication.kt |
| 33 | ### data/ — subscriptions, playlists, recommendations (Room) |
| 34 | - com/vayunmathur/youpipe/data/SubscriptionDatabase.kt — also `DB_NAME`, the preserved/excluded backup table lists and `youpipeDbConfigs` (mints the SQLCipher passphrase on a fresh restore target) |
| 35 | - com/vayunmathur/youpipe/data/SubscriptionRepository.kt |
| 36 | - com/vayunmathur/youpipe/data/Subscription.kt |
| 37 | - com/vayunmathur/youpipe/data/SubscriptionVideo.kt |
| 38 | - com/vayunmathur/youpipe/data/SubscriptionCategory.kt |
| 39 | - com/vayunmathur/youpipe/data/SubscriptionCategoryStore.kt |
| 40 | - com/vayunmathur/youpipe/data/Playlist.kt |
| 41 | - com/vayunmathur/youpipe/data/PlaylistStore.kt |
| 42 | - com/vayunmathur/youpipe/data/HistoryVideo.kt |
| 43 | - com/vayunmathur/youpipe/data/DownloadedVideo.kt |
| 44 | - com/vayunmathur/youpipe/data/CachedRelatedVideo.kt |
| 45 | - com/vayunmathur/youpipe/data/ChannelPreference.kt |
| 46 | - com/vayunmathur/youpipe/data/KeywordPreference.kt |
| 47 | - com/vayunmathur/youpipe/data/RecommendationPreferences.kt |
| 48 | - com/vayunmathur/youpipe/data/RecommendationImpression.kt |
| 49 | - com/vayunmathur/youpipe/data/RecommendationStore.kt |
| 50 | ### intents/ — assistant IPC (read-only, local cache) |
| 51 | - com/vayunmathur/youpipe/intents/GetSubscriptionsLatestIntent.kt — `youpipe_get_subscriptions_latest`: newest cached subscription videos (query/category filter, limit ≤10, titles ≤120 ch, metadata only — no transcripts/descriptions/playback); Room reads only, never triggers a refresh |
| 52 | - com/vayunmathur/youpipe/intents/YouPipeAssistantShaping.kt — pure provider-side caps/clamps for both intents (DTOs in `library/intents/youpipe/`); guarded by the signature `ACCESS_YOUPIPE` permission |
| 53 | ### nativeext/ — Rust extractor bridge |
| 54 | - com/vayunmathur/youpipe/nativeext/YouPipeNative.kt |
| 55 | ### network/ — extraction + SABR |
| 56 | - com/vayunmathur/youpipe/network/Extractor.kt |
| 57 | - com/vayunmathur/youpipe/network/NativeExtractor.kt |
| 58 | - com/vayunmathur/youpipe/network/MyDownloader.kt |
| 59 | ### domain/ — recommendations |
| 60 | - com/vayunmathur/youpipe/domain/Recommender.kt |
| 61 | ### ui/ — tabs, feed, search, library |
| 62 | - com/vayunmathur/youpipe/ui/VideoPage.kt |
| 63 | - com/vayunmathur/youpipe/ui/VideoPlayer.kt |
| 64 | - com/vayunmathur/youpipe/ui/VideoPlayerViewState.kt |
| 65 | - com/vayunmathur/youpipe/ui/VideoPlayerPlaybackState.kt |
| 66 | - com/vayunmathur/youpipe/ui/VideoPlayerPlaybackEffects.kt |
| 67 | - com/vayunmathur/youpipe/ui/VideoPlayerSeekRow.kt |
| 68 | - com/vayunmathur/youpipe/ui/VideoPlayerTopControls.kt |
| 69 | - com/vayunmathur/youpipe/ui/VideoPlayerChapterSheet.kt |
| 70 | - com/vayunmathur/youpipe/ui/VideoPlayerCasting.kt |
| 71 | - com/vayunmathur/youpipe/ui/VideoPlayerNotificationProgressBar.kt |
| 72 | - com/vayunmathur/youpipe/ui/VideoDetails.kt |
| 73 | - com/vayunmathur/youpipe/ui/VideoDetailScreen.kt |
| 74 | - com/vayunmathur/youpipe/ui/VideoFormatting.kt |
| 75 | - com/vayunmathur/youpipe/ui/VideoSections.kt |
| 76 | - com/vayunmathur/youpipe/ui/VideoRow.kt |
| 77 | - com/vayunmathur/youpipe/ui/FeedGrid.kt |
| 78 | - com/vayunmathur/youpipe/ui/SearchPage.kt |
| 79 | - com/vayunmathur/youpipe/ui/ChannelPage.kt |
| 80 | - com/vayunmathur/youpipe/ui/SubscriptionsPage.kt |
| 81 | - com/vayunmathur/youpipe/ui/SubscriptionVideosPage.kt |
| 82 | - com/vayunmathur/youpipe/ui/HistoryPage.kt |
| 83 | - com/vayunmathur/youpipe/ui/SavedPage.kt |
| 84 | - com/vayunmathur/youpipe/ui/PlaylistDetailPage.kt |
| 85 | - com/vayunmathur/youpipe/ui/DownloadedVideosPage.kt |
| 86 | - com/vayunmathur/youpipe/ui/LinkifiedText.kt |
| 87 | - com/vayunmathur/youpipe/ui/dialogs/AddToPlaylist.kt |
| 88 | - com/vayunmathur/youpipe/ui/dialogs/ClearHistoryDialog.kt — `Route.ClearHistoryDialog` host + stateless content |
| 89 | - com/vayunmathur/youpipe/ui/dialogs/DownloadOptionsDialog.kt — `Route.DownloadOptionsDialog(videoID)` host + stateless content; confirming enqueues via `DownloadManager` |
| 90 | - com/vayunmathur/youpipe/ui/tv/TvClearHistoryDialog.kt — shared TV clear-history confirmation, hosted as `TvRoute.ClearHistoryDialog` |
| 91 | - com/vayunmathur/youpipe/ui/dialogs/AddToWatchLater.kt |
| 92 | - com/vayunmathur/youpipe/ui/dialogs/CreatePlaylist.kt |
| 93 | - com/vayunmathur/youpipe/ui/dialogs/CreateSubscriptionCategory.kt |
| 94 | ### ui/ — settings |
| 95 | - com/vayunmathur/youpipe/ui/SettingsPage.kt |
| 96 | - com/vayunmathur/youpipe/ui/GeneralSettingsPage.kt |
| 97 | - com/vayunmathur/youpipe/ui/SponsorBlockSettingsPage.kt |
| 98 | - com/vayunmathur/youpipe/ui/RecommendationsSettingsPage.kt |
| 99 | - com/vayunmathur/youpipe/ui/ManageInterestsPage.kt |
| 100 | - com/vayunmathur/youpipe/ui/DataSettingsPage.kt |
| 101 | ### platform/ — ViewModel, playback, downloads, sync |
| 102 | - com/vayunmathur/youpipe/platform/AppBackupAgent.kt — key/value backup agent (manifest `backupAgent`, no `fullBackupOnly`): settings DataStore + codec-exported database zip |
| 103 | - com/vayunmathur/youpipe/platform/YouPipeDbBackupCodec.kt — `SqlCipherDbCodec` round-trip (plaintext export, re-encrypt under the new device's key) with the cache tables in `YOUPIPE_EXCLUDED_TABLES` stripped in both directions; never back up the raw `passwords-db` file or `secure_prefs` (see `res/xml/data_extraction_rules.xml`) |
| 104 | - com/vayunmathur/youpipe/platform/YouPipeViewModel.kt |
| 105 | - com/vayunmathur/youpipe/platform/YouPipeUiContract.kt |
| 106 | - com/vayunmathur/youpipe/platform/YouPipeVideoLoading.kt |
| 107 | - com/vayunmathur/youpipe/platform/PlaybackService.kt |
| 108 | - com/vayunmathur/youpipe/platform/DownloadManager.kt |
| 109 | - com/vayunmathur/youpipe/platform/DownloadWorker.kt |
| 110 | - com/vayunmathur/youpipe/platform/SubscriptionFetchTask.kt |
| 111 | - com/vayunmathur/youpipe/platform/YouPipeRecommendations.kt |
| 112 | - com/vayunmathur/youpipe/platform/YouPipeRecommendationSettings.kt |
| 113 | - com/vayunmathur/youpipe/platform/YouPipePlaylistOps.kt |
| 114 | - com/vayunmathur/youpipe/platform/YouPipeImportExport.kt |
| 115 | - com/vayunmathur/youpipe/platform/CastPlayback.kt |
| 116 | ### network/sabr/ — SABR session + attestation stack |
| 117 | - com/vayunmathur/youpipe/network/sabr/SabrNgSession.kt |
| 118 | - com/vayunmathur/youpipe/network/sabr/SabrNgSessionStore.kt |
| 119 | - com/vayunmathur/youpipe/network/sabr/SabrNgSourceSpec.kt |
| 120 | - com/vayunmathur/youpipe/network/sabr/SabrNgDashMediaSource.kt |
| 121 | - com/vayunmathur/youpipe/network/sabr/SabrNgDownloadHelper.kt |
| 122 | - com/vayunmathur/youpipe/network/sabr/SabrNgSegmentDataSource.kt |
| 123 | - com/vayunmathur/youpipe/network/sabr/SabrRequestCoordinator.kt |
| 124 | - com/vayunmathur/youpipe/network/sabr/SabrFfmpegMuxer.kt |
| 125 | - com/vayunmathur/youpipe/network/sabr/SabrAttestationRetryHandler.kt |
| 126 | - com/vayunmathur/youpipe/network/sabr/SabrDownloadException.kt |
| 127 | - com/vayunmathur/youpipe/network/sabr/LocalDomPoTokenProvider.kt |
| 128 | - com/vayunmathur/youpipe/network/sabr/LocalDomPoTokenGenerator.kt |
| 129 | - com/vayunmathur/youpipe/network/sabr/SabrLocalDomPoTokenUtil.kt |
| 130 | - com/vayunmathur/youpipe/network/sabr/SharedWebViewRuntime.kt |
| 131 | - com/vayunmathur/youpipe/network/sabr/YoutubePageAttestationBootstrap.kt |
| 132 | |
| 133 | ## Verify (this module only) |
| 134 | ``` |
| 135 | ./gradlew :youpipe:compileDevKotlin |
| 136 | ./gradlew :youpipe:lint |
| 137 | ./gradlew :youpipe:checkMetadata |
| 138 | ``` |