|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +JsonCMP is a Kotlin Multiplatform (KMP) library providing JSON viewer and editor composables for Android, iOS, and JVM Desktop. Published to Maven Central as `dev.skymansandy:json-cmp` (currently 1.0.0-RC2). All public APIs are marked `@ExperimentalJsonCmpApi`. |
| 8 | + |
| 9 | +## Build Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +# Build |
| 13 | +./gradlew build # Full build |
| 14 | +./gradlew :json-cmp:jvmTest # Run JVM tests |
| 15 | +./gradlew :json-cmp:iosSimulatorArm64Test # Run iOS simulator tests |
| 16 | +./gradlew :json-cmp:jvmTest --tests "fully.qualified.TestClass" # Single test class |
| 17 | + |
| 18 | +# Code Quality |
| 19 | +./gradlew detektAll # Detekt static analysis (strict: 0 issues allowed) |
| 20 | +./gradlew apiCheck # Binary compatibility validation |
| 21 | + |
| 22 | +# Coverage |
| 23 | +./gradlew :json-cmp:jvmTest koverXmlReport # JVM tests + coverage report |
| 24 | + |
| 25 | +# Sample App |
| 26 | +./gradlew :androidApp:assembleRelease # Build sample Android APK |
| 27 | + |
| 28 | +# Publishing (requires credentials via env vars) |
| 29 | +./gradlew publishAndReleaseToMavenCentral --no-configuration-cache |
| 30 | + |
| 31 | +# Documentation |
| 32 | +mkdocs build # Build docs site (requires: pip install mkdocs-material) |
| 33 | +``` |
| 34 | + |
| 35 | +## Architecture |
| 36 | + |
| 37 | +**Modules:** |
| 38 | +- `json-cmp` — Core KMP library (the published artifact) |
| 39 | +- `composeApp` — Multiplatform Compose sample app (Android/iOS/Desktop) |
| 40 | +- `androidApp` — Native Android sample app |
| 41 | + |
| 42 | +**Library structure (`json-cmp/src/commonMain`):** |
| 43 | +- `domain/` — Core logic: JSON parser, serializer, syntax highlighter, Redux-like state store (`JsonHolderImpl` dispatching `JsonAction`), line-based virtualization, `JsonNode` tree model |
| 44 | +- `ui/viewer/` — `JsonViewerCMP` composable + `JsonViewerState` (read-only, virtualized) |
| 45 | +- `ui/editor/` — `JsonEditorCMP` composable + `JsonEditorState` (editable, with validation) |
| 46 | +- `ui/common/` — Shared UI components (highlighter, gutter, line view) |
| 47 | +- `theme/` — Built-in themes (Dark, Light, Monokai, Dracula, Solarized Dark) + `JsonTheme.Custom` |
| 48 | + |
| 49 | +**Key patterns:** |
| 50 | +- Observable state holders (`@Stable`, `mutableStateOf`, Flow) — no callback-based API |
| 51 | +- Virtualized rendering via line calculation for large JSON |
| 52 | +- `rememberJsonViewerState` / `rememberJsonEditorState` use Compose retain API for lifecycle |
| 53 | + |
| 54 | +**Platform targets:** Android (minSdk 24, compileSdk 36), iOS (Arm64 + Simulator), JVM |
| 55 | + |
| 56 | +## Code Quality |
| 57 | + |
| 58 | +- **Detekt** with auto-correct, strict mode (maxIssues: 0), baseline in `detekt-baseline.xml` |
| 59 | +- `@Composable` functions are exempt from LongMethod and LongParameterList rules |
| 60 | +- **Binary compatibility validator** tracks API surface at `json-cmp/api/jvm/json-cmp.api` |
| 61 | +- Kotlin code style: `official` |
| 62 | + |
| 63 | +## CI Pipeline (PR to main) |
| 64 | + |
| 65 | +1. API compatibility check (`apiCheck`) |
| 66 | +2. Detekt code quality |
| 67 | +3. JVM tests |
| 68 | +4. iOS simulator tests |
| 69 | + |
| 70 | +## Key Versions |
| 71 | + |
| 72 | +Managed in `gradle/libs.versions.toml`: Kotlin 2.3.10, Compose Multiplatform 1.10.2, AGP 9.1.0, Gradle 9.3.1 |
0 commit comments