suby
запушил(а) oivo в suby/qmd
89267c17d4 feat(ast): Phase 3 — tree-sitter grammars for Java + Kotlin (i-76v1j1ld)
Extends qmd's AST-aware chunking to JVM-family code: .java, .kt, .kts
files now produce function/class/method/import break points instead of
falling back to regex-only chunking.
Changes:
* package.json — add two grammar deps to optionalDependencies:
tree-sitter-java@0.23.5 (ships prebuilt tree-sitter-java.wasm)
@tree-sitter-grammars/tree-sitter-kotlin@1.1.0
(ships prebuilt tree-sitter-kotlin.wasm).
Also added to pnpm.onlyBuiltDependencies for parity with the
existing go/rust/typescript grammar entries.
* src/ast.ts — extend SupportedLanguage, EXTENSION_MAP (.java/.kt/
.kts), GRAMMAR_MAP (java + kotlin package paths), and
LANGUAGE_QUERIES (class/iface/enum/record/method/import for Java;
class/object/function/type_alias/import for Kotlin).
* bun.lock — regenerated to include the two new packages + their
transitive deps (node-addon-api, node-gyp-build).
* dist/ast.js, dist/ast.d.ts — rebuilt from source for consumers
that import the compiled output (per oivo branch policy of
shipping prebuilt dist/).
Kotlin grammar naming note: the upstream `tree-sitter-kotlin` package
(fwcd, v0.3.8) does NOT ship a prebuilt .wasm — only src/parser.c.
Switched to `@tree-sitter-grammars/tree-sitter-kotlin@1.1.0`, which
DOES ship the wasm. Node names differ between the two: v1.1.0 uses
`import` (not `import_header`) and lacks `property_declaration` at
the query level — queries updated accordingly and confirmed working.
Swift deferred to follow-up i-f0dd5nge: no version of tree-sitter-swift
(0.1.4 → 0.7.1) ships a prebuilt .wasm; the full list needs docker /
emscripten to run `tree-sitter build --wasm`, and the code machine
has neither. Follow-up tracks vendoring a built wasm into
assets/grammars/ and extending resolveGrammarPath with a local-first
fallback.
Verified:
* `getASTStatus()` reports `java: available=true` and
`kotlin: available=true` (both wasm load + query compile).
* Java fixture (class + interface + enum + 3 methods + 2 imports)
produces 8 break points with correct scores and positions.
* Kotlin fixture (class + object + typealias + 3 funs + 2 imports)
produces 8 break points.
* `.kts` routes to kotlin grammar and produces 8 break points.
* `workspace_typecheck({ component: "cli", onlyModified: true })`
→ 0 errors (consumer at cli/src/daemon/run.ts resolves
`@oivo/qmd/bin/qmd` via createRequire; no public-API change).
Companion change on `code` machine (NOT in this commit — lives in
consumer config): ~/.config/qmd/index.yml adds oivo-research-jvm
collection at /srv/research, pattern **/*.{java,kt,kts} (204 files).
Rollback: `git revert` — removes the two deps + ast.ts additions +
regenerated dist. No new runtime requirements introduced (existing
optionalDependencies pattern).
Unblocks: polyglot AST chunking for /srv/research JVM content.
Parent: i-76v1j1ld (Phase 3 JVM grammars).
Sibling: i-bud0h8vu (Phase 2 — function-level chunking, independent).
Follow-up: i-f0dd5nge (Phase 3b — Swift wasm build/vendor).
Session-Id: d0f56a95
1 месяц назад