Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6f2b449
feat: comprehensive Android/Kotlin/XML support improvements
hossihub Apr 20, 2026
93d57c5
fix: address code review findings in Android extractor improvements
hossihub Apr 20, 2026
753399d
fix: rustfmt and clippy corrections for CI
hossihub Apr 20, 2026
6024a3e
test: fix flaky performance thresholds and race conditions in test suite
hossihub Apr 20, 2026
8f2d917
feat: add project_path to leankg.yaml for MCP routing
hossihub Apr 20, 2026
096b318
style: fix formatting issues for ci pipeline
hossihub Apr 20, 2026
de564a8
fix: address code review comments on PR #18
hossihub Apr 20, 2026
1d1124f
revert: restore .mcp.json tracking and remove from .gitignore
hossihub Apr 20, 2026
1f672aa
revert: restore original .mcp.json command path
hossihub Apr 20, 2026
7c5a82b
merge: main into dev, resolve Cargo.lock version to 0.16.4
hossihub Apr 20, 2026
4221e2b
Merge remote-tracking branch 'origin/main' into dev
hossihub Apr 20, 2026
c88f04f
merge: main into dev, resolve conflicts in Cargo.lock and mcp_tests.rs
hossihub Apr 20, 2026
8b64cfd
fix: address PR review comments - add tests and documentation
hossihub Apr 22, 2026
5913c75
feat: Enhance Kotlin analysis with extractor and graph builders
hossihub Apr 22, 2026
ef7082d
docs: add navigation extractor design spec (Phase 1 of modern Android…
hossihub Apr 22, 2026
bd1f8a7
docs: add navigation extractor implementation plan
hossihub Apr 22, 2026
6362fa7
feat: add android_nav_model shared types
hossihub Apr 22, 2026
1d191bb
feat: add navigation relationship types to RelationshipType enum
hossihub Apr 22, 2026
d00161e
feat: add JetpackNavExtractor XML parsing for nav graphs
hossihub Apr 22, 2026
90d15f7
fix: align nav_jetpack metadata fields with spec
hossihub Apr 22, 2026
9e257eb
feat: add FragmentNavExtractor and LeanbackNavExtractor
hossihub Apr 22, 2026
ceb8fb5
feat: wire navigation extractors into indexer pipeline
hossihub Apr 22, 2026
2f7eead
feat: add get_nav_graph, find_route, get_screen_args, get_nav_callers…
hossihub Apr 22, 2026
d03762e
feat: add navigation MCP tool handlers
hossihub Apr 22, 2026
ef428e8
feat: complete Android Navigation Extractor implementation
hossihub Apr 22, 2026
7744507
fix: nav tool schema mismatch and dead code
hossihub Apr 22, 2026
57c5346
feat: close Kotlin tool gaps
hossihub Apr 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .opencode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,14 @@ Cluster tools: `get_clusters`, `get_cluster_context`

Risk tools: `detect_changes`

## Known Limitations

- **Android/Kotlin/XML search** - Search for Android-related code elements (Kotlin, XML layouts, AndroidManifest.xml) may return incomplete results. The indexer finds these files but search indexing has gaps.

## Verification Status

See `docs/implementation-feature-verification-2026-03-25.md` for test results.

---

*Last updated: 2026-03-28*
*Last updated: 2026-04-20*
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ tempfile = "3"
rust-embed = "8"
ignore = "0.4.25"
similar = "3.1.0"
roxmltree = "0.20"
tree-sitter-bash = "0.25"
tree-sitter-ruby = "0.23.1"
tree-sitter-php = "0.24.2"
Expand Down
211 changes: 211 additions & 0 deletions docs/android-kotlin-xml-improvements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
# LeanKG Improvements for Android, Kotlin, XML

This document summarizes the improvements made to LeanKG for better Android, Kotlin, and XML support.

## Overview

These improvements enable LeanKG to:
- Index all XML files (not just Android-specific ones)
- Extract Room database relationships
- Map Hilt dependency injection graphs
- Track Android resource references in code
- Enhanced AndroidManifest.xml parsing

## Changes by Phase

### Phase 1: Foundation (XML Support)

**Files Modified:**
- `src/indexer/mod.rs` - Added "xml" to file extensions

**Files Created:**
- `src/indexer/xml_generic.rs` - Generic XML extractor

**Features:**
- All `.xml` files now indexed
- Generic XML files create XMLDocument elements
- Android-specific XML still handled by dedicated extractors

### Phase 2: Test Fixtures

**Created 34 test fixture files:**

Kotlin Patterns (7 files):
- `tests/fixtures/kotlin_patterns/room_entities.kt`
- `tests/fixtures/kotlin_patterns/room_dao.kt`
- `tests/fixtures/kotlin_patterns/hilt_module.kt`
- `tests/fixtures/kotlin_patterns/data_class.kt`
- `tests/fixtures/kotlin_patterns/coroutines.kt`
- `tests/fixtures/kotlin_patterns/extension_functions.kt`
- `tests/fixtures/kotlin_patterns/generics.kt`

Android XML (11 files):
- `tests/fixtures/android_xml/AndroidManifest.xml`
- `tests/fixtures/android_xml/browse_fragment.xml`
- `tests/fixtures/android_xml/player_activity.xml`
- `tests/fixtures/android_xml/preferences.xml`
- `tests/fixtures/android_xml/searchable.xml`
- `tests/fixtures/android_xml/selector_button.xml`
- `tests/fixtures/android_xml/ic_launcher_foreground.xml`
- `tests/fixtures/android_xml/strings.xml`
- `tests/fixtures/android_xml/colors.xml`
- `tests/fixtures/android_xml/styles.xml`
- `tests/fixtures/android_xml/main_menu.xml`

TV App Scenario (16 files in complex_scenarios/tv_app/):
- Complete TV app structure with Room, Hilt, UI layers

### Phase 3: Deep Extraction

**Files Created:**

1. `src/indexer/android_room.rs`
- Extracts @Entity, @Dao, @Database
- Creates foreign key relationships
- Links DAOs to queried entities
- 3 unit tests

2. `src/indexer/android_hilt.rs`
- Extracts @Module, @Provides, @Inject
- Creates DI graph relationships
- Tracks provider dependencies
- 3 unit tests

3. `src/indexer/android_resource_refs.rs`
- Detects R.string, R.drawable, R.layout, etc.
- Creates resource usage relationships
- 4 unit tests

**Files Enhanced:**

4. `src/indexer/android_manifest.rs`
- Added intent filter extraction
- Added metadata extraction
- Added application class detection
- 6 existing tests still pass

### Phase 4: Comprehensive Testing

**Test Files Created:**

1. `tests/kotlin_extraction_tests.rs` (8 tests)
- Room entity extraction
- DAO extraction
- Hilt module extraction
- Pattern detection

2. `tests/xml_extraction_tests.rs` (12 tests)
- Manifest parsing
- Intent filter detection
- Resource file validation

3. `tests/android_integration_tests.rs` (8 tests)
- Cross-file relationships
- Full TV app scenario
- Structure completeness

4. `tests/android_performance_tests.rs` (6 tests)
- Extraction speed benchmarks
- Batch processing
- Scalability

**Test Results:**
- Total new tests: 34
- All passing: 34 ✓
- Build time: < 0.5s

## Technical Details

### Regex Patterns Used

**Room Entity:**
```regex
(?s)@Entity\s*(?:\(.*?\))?\s*data\s+class\s+(\w+)
```

**Room DAO:**
```regex
@Dao\s*\n?\s*\n?(?:interface|class)\s+(\w+)
```

**Hilt Module:**
```regex
(?s)@Module\s*\n?\s*(?:@InstallIn\(.*?\)\s*\n?\s*)?(?:abstract\s+)?(?:class|object)\s+(\w+)
```

**Hilt Provider:**
```regex
@Provides\s*\n?(?:@Singleton\s*\n?)?\s*fun\s+(\w+)\s*\([^)]*\)\s*:\s*(\w+)
```

**Resource References:**
```regex
R\.(\w+)\.(\w+)
```

### Integration Points

All extractors integrated into `extract_elements_for_file()`:

```rust
// For Kotlin files
if language == "kotlin" {
// Room extraction
let room_extractor = AndroidRoomExtractor::new(source, file_path);
let (room_elements, room_rels) = room_extractor.extract();

// Hilt extraction
let hilt_extractor = AndroidHiltExtractor::new(source, file_path);
let (hilt_elements, hilt_rels) = hilt_extractor.extract();

// Resource reference extraction
let res_ref_extractor = AndroidResourceRefExtractor::new(source, file_path);
let (_, res_refs) = res_ref_extractor.extract();
}
```

## Performance

| Operation | Time | Notes |
|-----------|------|-------|
| Room extraction | ~28ms | 4 entities |
| Hilt extraction | ~25ms | 5 elements |
| Manifest parsing | ~16ms | 5 elements |
| Batch (4 files) | ~291ms | Mixed content |

## Migration Guide

### For Existing Projects

No changes needed. Re-index to get new Android elements:

```bash
leankg index --force
```

### For New Android Projects

1. Initialize in project root:
```bash
leankg init
```

2. Index includes src/ automatically:
```bash
leankg index
```

## Future Improvements

Potential enhancements:
- Compose UI extraction
- Navigation component graph parsing
- Gradle dependency analysis
- Test coverage integration
- Resource overlay detection

## References

- Test fixtures: `tests/fixtures/`
- Extractor source: `src/indexer/android_*.rs`
- Documentation: `docs/android-support.md`
Loading
Loading