Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / code / AGENTS.md
| 1 | # AGENTS.md — code/ (':code') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `code/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | _Install: ./install code (dev by default)._ |
| 6 | <!-- last-reviewed: 2026-10-16 --> |
| 7 | - Gradle: :code / dir: code/ |
| 8 | - Package roots present: ui |
| 9 | - Entry files: MainActivity.kt (no Route.kt — editor workspace with pages, not nav destinations) |
| 10 | - Deps: (none declared — tree-sitter via Rust JNI, SAF file access) |
| 11 | - Metadata: metadata_data/code.md (present) |
| 12 | - Rust: yes / screenshotTest: yes |
| 13 | |
| 14 | ## Overview |
| 15 | **Purpose:** Offline code editor — tree-sitter syntax highlighting, SAF project browsing, git (stage/commit/branch/diff), cross-file search, tabs, command palette, terminal. Handles VIEW/EDIT intents. |
| 16 | **Key features:** |
| 17 | - Canvas-rendered editor (`CodeEditor*`: canvas/content/draw/gestures/input/keys) with minimap, folding, completions, diagnostics, outline, merge-conflict UI |
| 18 | - Tree-sitter highlighting via Rust JNI (`TreeSitterNative`) with regex fallback (`SyntaxHighlighting`); formatting, fuzzy match, text encodings |
| 19 | - Git panel (`GitPage`, `EditorGitOps`, `GitRepo`, `GitIgnore`), file tree + folder browser, preview + markdown pages, snippets, settings, terminal sessions |
| 20 | **Architecture / data-flow:** `ui/` editor shell + pages → `util/EditorViewModel` (+ `CodeUiContract`, per-area `Editor*Ops`) → `util/EditorDocument` over SAF (`FileFiles`, `EditorFileTreeOps`); highlighting flows Rust → `SyntaxHighlighting` → `CodeEditorDraw`; git flows `GitRepo` → `EditorGitOps` → `GitPage`. |
| 21 | **Entry points + reading order:** `MainActivity.kt` → `ui/EditorScreen.kt` → `util/EditorViewModel.kt` → `util/EditorDocument.kt` → `ui/CodeEditor.kt` → `syntax/SyntaxHighlighting.kt`. |
| 22 | **Gotchas:** |
| 23 | - `syntax/` and `util/` are NOT closed package roots — pending migration; don't add more files there |
| 24 | - Editor state (tabs, undo, cursors) is session-scoped in the ViewModel — file writes go through `EditorSaveOps`, never direct |
| 25 | - Native highlighting can lag on huge files — regex fallback must stay working, test both paths |
| 26 | |
| 27 | ## Key files |
| 28 | ### Root + syntax/ — entry and highlighting |
| 29 | - com/vayunmathur/code/MainActivity.kt |
| 30 | - com/vayunmathur/code/syntax/SyntaxHighlighting.kt |
| 31 | ### ui/ — editor shell, canvas, pages |
| 32 | - com/vayunmathur/code/ui/EditorScreen.kt |
| 33 | - com/vayunmathur/code/ui/CodeEditor.kt |
| 34 | - com/vayunmathur/code/ui/CodeEditorView.kt |
| 35 | - com/vayunmathur/code/ui/CodeEditorCanvas.kt |
| 36 | - com/vayunmathur/code/ui/CodeEditorContent.kt |
| 37 | - com/vayunmathur/code/ui/CodeEditorDraw.kt |
| 38 | - com/vayunmathur/code/ui/CodeEditorChrome.kt |
| 39 | - com/vayunmathur/code/ui/CodeEditorGestures.kt |
| 40 | - com/vayunmathur/code/ui/CodeEditorInput.kt |
| 41 | - com/vayunmathur/code/ui/CodeEditorKeys.kt |
| 42 | - com/vayunmathur/code/ui/EditorBody.kt |
| 43 | - com/vayunmathur/code/ui/EditorChrome.kt |
| 44 | - com/vayunmathur/code/ui/EditorToolbar.kt |
| 45 | - com/vayunmathur/code/ui/CodeWideLayout.kt |
| 46 | - com/vayunmathur/code/ui/Minimap.kt |
| 47 | - com/vayunmathur/code/ui/CommandPalette.kt |
| 48 | - com/vayunmathur/code/ui/DiffView.kt |
| 49 | - com/vayunmathur/code/ui/FileTreePane.kt |
| 50 | - com/vayunmathur/code/ui/FolderBrowserPage.kt |
| 51 | - com/vayunmathur/code/ui/GitPage.kt |
| 52 | - com/vayunmathur/code/ui/GitPageSection.kt |
| 53 | - com/vayunmathur/code/ui/PreviewPage.kt |
| 54 | - com/vayunmathur/code/ui/SearchPage.kt |
| 55 | - com/vayunmathur/code/ui/SettingsPage.kt |
| 56 | - com/vayunmathur/code/ui/SnippetsPage.kt |
| 57 | - com/vayunmathur/code/ui/TerminalPage.kt |
| 58 | ### util/ — ViewModel, document, ops (pending migration to closed roots) |
| 59 | - com/vayunmathur/code/util/EditorViewModel.kt |
| 60 | - com/vayunmathur/code/util/CodeUiContract.kt |
| 61 | - com/vayunmathur/code/util/EditorDocument.kt |
| 62 | - com/vayunmathur/code/util/EditorTabs.kt |
| 63 | - com/vayunmathur/code/util/EditorInput.kt |
| 64 | - com/vayunmathur/code/util/EditorSaveOps.kt |
| 65 | - com/vayunmathur/code/util/EditorSearchOps.kt |
| 66 | - com/vayunmathur/code/util/EditorFileTreeOps.kt |
| 67 | - com/vayunmathur/code/util/EditorGitOps.kt |
| 68 | - com/vayunmathur/code/util/GitRepo.kt |
| 69 | - com/vayunmathur/code/util/GitIgnore.kt |
| 70 | - com/vayunmathur/code/util/MergeConflicts.kt |
| 71 | - com/vayunmathur/code/util/DiffModel.kt |
| 72 | - com/vayunmathur/code/util/EditorTerminalOps.kt |
| 73 | - com/vayunmathur/code/util/TerminalSession.kt |
| 74 | - com/vayunmathur/code/util/Completion.kt |
| 75 | - com/vayunmathur/code/util/Diagnostics.kt |
| 76 | - com/vayunmathur/code/util/Outline.kt |
| 77 | - com/vayunmathur/code/util/FoldRegions.kt |
| 78 | - com/vayunmathur/code/util/Formatting.kt |
| 79 | - com/vayunmathur/code/util/FuzzyMatch.kt |
| 80 | - com/vayunmathur/code/util/Markdown.kt |
| 81 | - com/vayunmathur/code/util/TextEncoding.kt |
| 82 | - com/vayunmathur/code/util/FileFiles.kt |
| 83 | - com/vayunmathur/code/util/EditorPrefs.kt |
| 84 | - com/vayunmathur/code/util/TreeSitterNative.kt — Rust JNI bridge |
| 85 | |
| 86 | ## Verify (this module only) |
| 87 | ``` |
| 88 | ./gradlew :code:compileDevKotlin |
| 89 | ./gradlew :code:lint |
| 90 | ./gradlew :code:checkMetadata |
| 91 | ``` |