mirror of
https://github.com/Egonex-AI/Understand-Anything.git
synced 2026-06-22 10:58:03 +08:00
Wires Kotlin into the existing tree-sitter pipeline so .kt and .kts files now produce functions, classes, data classes, sealed classes, interfaces, objects, imports, exports, and call-graph edges — matching the behavior of the other language extractors. ## Why @tree-sitter-grammars/tree-sitter-kotlin The standard `tree-sitter-kotlin` (v0.3.8) ships only native bindings. The new `@tree-sitter-grammars/tree-sitter-kotlin@1.1.0` ships a prebuilt `.wasm` (loads cleanly with `web-tree-sitter@^0.26.6`, nodeTypeCount=289, parses class_declaration / function_declaration as expected). Same shape that PR1 used for Swift, just a different publisher because the repomix WASM bundle does not include Kotlin. `@tree-sitter-grammars` is the official tree-sitter org's GitHub account, so this is the canonical upstream WASM source for Kotlin. ## Notes for reviewers - `kotlinConfig` already existed as a stub (no `treeSitter` field), so Android / JVM / Gradle codebases currently produce no structural edges between `.kt` files. This PR adds the `treeSitter` field; the existing plugin loader picks it up unchanged. - **Visibility rule differs from Swift**: Kotlin's default visibility is `public`, so the extractor treats *every* declaration with no modifier as exported. Only an explicit `private` opts out. `internal` and `protected` remain exported in the project-graph sense because they are still resolvable from other files (within the module / via inheritance). - `class_declaration` in tree-sitter-kotlin is overloaded for class, data class, sealed class, and interface (distinguished by the keyword child and `modifiers > class_modifier`). The extractor handles all four uniformly. - `object_declaration` is a separate node type (Kotlin singletons) — treated as a class-like entry with its own `name` and members. - Primary-constructor parameters marked `val` / `var` are surfaced as class properties; plain `parameter`s without `val/var` are constructor-only and are NOT counted as properties (matching Kotlin semantics). - Import handling distinguishes the three forms: plain dotted (`import a.b.C`), wildcard (`import a.b.*` → specifier `"*"`), and aliased (`import a.b.C as Foo` → specifier `"Foo"`). ## Verification - `pnpm lint` clean - `pnpm --filter @understand-anything/core build` clean - `pnpm --filter @understand-anything/skill build` clean - `pnpm --filter @understand-anything/core test`: **692/692** (+22 new Kotlin tests, matching the bar set by go-extractor.test.ts / swift-extractor.test.ts) - `pnpm test`: 196/196 (no regressions) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>