- Unless necessary, only read and write files within the current workspace.Git-related operations are permitted as an exception.
- Forbidden commands:
rm,rmdir(do not use them even if requested).
App Name: FLIT (Repo: RikkaHub)
The "Fidget Toy" Philosophy: FLIT is not just a tool; it is designed to be a "fidget toy".
- Feel: Interactions must be playful, physics-based, and deeply satisfying.
- Tactile Feedback: High-quality haptics are non-negotiable. Every tap, toggle, and drag must have appropriate feedback.
- Motion: Prefer physics-based interpolators (springs) for all interactive motion to convey momentum and weight. Exception: navigation/page transitions may use
tween.
Workflow:
- Iterative Polish: We prefer iterative "glow-ups" of specific components over massive, risky refactors.
- Robustness: The app must be crash-resistant.
NullPointerExceptionis the enemy.
app/: Main application module. Contains UI (Compose), Core Logic, DI, Data Layers, and Room Database.ai/: Abstraction layer for AI providers (OpenAI, Google, Anthropic).common/: Shared utilities and extensions.highlight/: Syntax highlighting features.search/: Search functionality (Exa, Tavily, Zhipu).tts/: Text-to-Speech implementation.
- Language: Kotlin (uses experimental
kotlin.uuid.Uuid). - UI: Jetpack Compose (Material You 3 Expressive / Android 16).
- Dependency Injection: Koin.
- Database: Room.
- Network: OkHttp (with SSE support).
- Serialization: Kotlinx Serialization.
- I/O Operations: MUST be explicitly executed on
Dispatchers.IO.- Crucial:
AppScopedefaults toDispatchers.Default. Do not block the main thread or the default dispatcher with I/O.
- Crucial:
- Compose Optimization:
- Lists: Never pass mutable collections (
SnapshotStateList) directly toLazyColumnitems. UsederivedStateOfto pass simple, immutable states (e.g.,Boolean) to prevent unnecessary recompositions.
- Lists: Never pass mutable collections (
- AI Context: Prioritize token economy and vector memory efficiency. Use caching.
- JSON Handling:
- STRICTLY PROHIBITED: Non-null assertions (
!!) on JSON elements. - REQUIRED: Use safe type checks (
is JsonArray,jsonPrimitiveOrNull).
- STRICTLY PROHIBITED: Non-null assertions (
- State Management:
- When updating
StateFlowin services (e.g.,ChatService), snapshot the current value into a local variable before applying complex transformations to avoid race conditions.
- When updating
- Use
me.rerere.rikkahub.utils.JsonInstant(orJsonInstantPretty).- Note: It ignores unknown keys but does not apply snake_case strategies. Field mapping must be manual for external APIs.
- Standard: Material You 3 Expressive / Android 16.
- Shapes: Adhere strictly to
me.rerere.rikkahub.ui.theme.AppShapes:- Cards:
AppShapes.CardLarge(28.dp),AppShapes.CardMedium(24.dp). - Buttons:
AppShapes.ButtonPill(50%).
- Cards:
- Library: Use the custom
PremiumHapticswrapper.import me.rerere.rikkahub.ui.hooks.rememberPremiumHapticsimport me.rerere.rikkahub.ui.hooks.HapticPattern
- Usage:
- Do not use
LocalHapticFeedback. - Interactive Elements: Buttons (like
BackButton) must scale down to0.85fon press and triggerHapticPattern.Pop. - Patterns:
- Click/Toggle:
HapticPattern.Pop - Heavy Action/Drop:
HapticPattern.Thud - Success:
HapticPattern.Success
- Click/Toggle:
- Do not use
- Standard Spec:
spring(dampingRatio = 0.5f, stiffness = 400f) - Bouncy/Clicky Spec:
spring(dampingRatio = 0.6f, stiffness = 300f) - Prohibited (Interactive):
tweenor linear animations. Exception: navigation/page transitions may usetween.
- Persistence: Embeddings are stored in source entities (
MemoryEntity,ChatEpisodeEntity) ANDEmbeddingCacheDAO. - Sync: Operations (add/update/delete) must synchronize both stores.
- Retrieval: Always prefer existing entity embeddings over re-computation.
- Unit Tests: Place in
src/test. Cover parsing and logic. - Instrumented Tests: Place in
src/androidTest. Cover flows. - Build Environment: Use JDK 21. Prefer a project-local JDK and expose it through
JAVA_HOME. - Build Cache: Use a project-local Gradle cache through
GRADLE_USER_HOME(for example, a.gradle-userdirectory under the repo root). - Android User Home: Use a project-local Android user directory through
ANDROID_USER_HOMEand ensure it exists before running Gradle. - Build: After completing the changes, use
export PATH=$JAVA_HOME/bin:$PATH && mkdir -p "$ANDROID_USER_HOME" && source ~/.bashrc && ./gradlew :app:assembleExpRelease --no-daemon -x :app:uploadCrashlyticsMappingFileExpReleaseto build the package for testing. EnsureJAVA_HOME,GRADLE_USER_HOME, andANDROID_USER_HOMEare already set to valid project-local paths in the local environment. - Build Exception: If the change only updates UI copy or prompt text (no logic, behavior, or resource/schema changes), compile verification can be skipped.
- Commit Guidelines: Use Conventional Commits (
feat:,fix:,chore:). - Localization Requirement: Only three locales are maintained: English (
values/, the default), Simplified Chinese (values-zh-rCN/strings.xml), and Traditional Chinese (values-zh-rTW/strings.xml). When adding or modifying features that introduce/modify user-visible text, you MUST update both Simplified Chinese and Traditional Chinesestrings.xmlalongside the default resources. - Language Support: Do not submit new languages unless explicitly requested.