Imported from dkchw/ai_dict_android (
AGENTS.md). Install upstream withnpx skills add dkchw/ai_dict_android. Copyright stays with the author.
AI Agents & Architecture Ledger 🤖
AI Dict is built on the philosophy of intelligent, highly-specialized Multi-Agent architecture. Rather than relying on a single monolithic prompt to handle all language tasks, the app orchestrates different LLM Agent Personas dynamically based on the mode you are using.
Furthermore, this application itself was extensively developed, refactored, and maintained through Human-AI Pair Programming.
1. Internal LLM Personas (App Functionality)
When you use AI Dict, you aren't just talking to a generic chatbot. The app dynamically swaps out System Prompts, Models, and strict instructional guardrails to spawn specialized "Agents" for the task at hand.
📚 The Lexicographer (Dictionary Agent)
- Goal: Act as a comprehensive dictionary assistant.
- Mechanism: Strictly outputs definitions, phonetics, synonyms, and etymology in the Target language while structurally analyzing the word from the Source language.
⚖️ The Nuance Analyst (Compare Agent)
- Goal: Exhaustive and practical comparison of synonyms.
- Mechanism: Delineates core definitions, identifies register (formal vs. slang), highlights regional differences, and maps grammatical differences of comma-separated inputs.
🗣️ The Localizer (Translate Agent)
- Goal: Provide natural, culturally accurate translations—acting as a reverse dictionary.
- Mechanism: Takes abstract concepts or literal phrases in the Source language and identifies the most natural expressions, contextual usage, and idioms in the Target language.
🧠 The Grammarian (Explain Agent)
- Goal: Deep semantic and grammatical analysis of large text blocks.
- Mechanism: Breaks down long sentences or paragraphs to highlight vocabulary, syntax structure, cultural references, and overall semantic nuance.
2. The AI Engineering Ledger (Development)
This Android application is a testament to the power of AI-assisted software engineering.
The architecture, Jetpack Compose layouts, Room Database integrations, LLM streaming implementation, StateFlow segregation, and Custom Markdown UI components (featuring the Tokyo Night palette) were largely written, debugged, and iterated upon by Antigravity (Google DeepMind) in tight collaboration with the repository owner (dkchw).
Notable AI-Assisted Milestones:
- UI/UX Overhaul: Implementing fluid
HorizontalPagerswipe navigation and nested scrolling for pull-to-refresh (PullToRefreshContainer) integration without breaking native LazyColumn behaviors. Condensing Top/Bottom navigation bars to maximize screen real estate. - State Isolation: Decoupling monolithic UI state streams into strictly isolated asynchronous
StateFlowchannels, preventing prompt and output bleed between the 4 core modes. - Resilience: Implementing 300ms debounced auto-saving mechanisms that serialize drafts directly into SQLite, surviving sudden app closures and lifecycle deaths.
- Custom Markdown Engine: Mapping
RichTextStyleparameters to natively parse and render Markdown tables, codeblocks, and bold H1-H6 headers dynamically in Compose. - Dynamic Profiles & Data Architecture: Building complex Room Database foreign key cascades to allow for custom user Profiles. Implementing stable layout nodes (
key = { it.id }) to eliminate list scrolling lag. - Complex UI Recomposition Optimization: Identifying and isolating state reads (
collectAsState()) from high-level screens into heavily localized composables (likeSettingsGroupaccordions andChatInputBaroverrides) to rescue the UI from dropping frames. - Android File Scoped Permissions: Resolving strict API 33+ (Android 13/14) limitations on
READ_EXTERNAL_STORAGEandFileProviderby migrating the background Updater to purely nativeDownloadManagerURI broadcast receivers, eliminating silent failures during auto-installation. - Granular Reasoning Engine Control: Implemented independent reasoning effort controls (
default,none,minimal,low,medium,high,xhigh,max) per model and profile scope, seamlessly interfacing with OpenRouter's Reasoning API while preserving fallback safety and custom inheritance. - Resilient 24/7 Background Service & Two-Way State Sync: Engineered a foreground service with watchdog self-healing and bidirectional state synchronization. Notification action callbacks ("Stop 24/7 Mode") write directly to Room SQLite and trigger reactive Compose
LaunchedEffectupdates to guarantee UI switches never desynchronize from the actual service lifecycle. - Smart Mode Routing & Cross-Mode Regeneration Engine: Integrated dynamic sentence-length heuristic routing for text-selection popups (queries > 3 words automatically target
explainmode with instant streaming). Implemented universal cross-mode migration across Dictionary, Compare, Translate, and Explain with automatic prompt adaptation and live stream regeneration directly accessible from action bars and history cards. - Resilient Reactive History & Live Streaming Dashboard: Completely redesigned History architecture by decoupling mode queries from Pager indices, preventing history zeroing/disappearance during background generation. Engineered a reactive Mode Filter Bar (
Dict,Compare,Translate,Explain), live "Generating..." card indicators, and in-place real-time Markdown streaming within the History inspection panel. - Instant Intent Search & Strict Mode-Independent History Segregation: Eliminated text selection popup stale input locks by enforcing fresh intent overrides and multi-intent triggers across
onCreateandonNewIntent. Re-engineered the History architecture into strictly isolated, independent streams per mode (Dict,Compare,Translate,Explain), eliminating mode mixing while synchronizing active mode context directly from navigation entry points. - Resilient 24/7 Background Engine & Robust WakeLock Architecture: Re-architected the 24/7 background foreground service with non-leaking, synchronized
PARTIAL_WAKE_LOCKmanagement for uninterrupted LLM network streaming during sleep. Restored notification dismissal resurrection (ACTION_NOTIFICATION_DISMISSED) and a lightweight 15-second watchdog to keep the 24/7 foreground service alive across aggressive OEM task killers, while fully aligningFOREGROUND_SERVICE_SPECIAL_USE,WAKE_LOCK, andREQUEST_INSTALL_PACKAGESpermissions.