Skip to content

feat(#245): AST-aware code chunking — Rust, Go, Python, TS, Dart - #334

Merged
ajianaz merged 1 commit into
developfrom
feat/v020-245-ast-chunking
Jun 14, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/v020-245-ast-chunking

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Closes #245

Changes

CodeChunker (crates/uteke-core/src/chunker.rs)

  • detect_language() — from file extension (.rs, .go, .py, .ts, .dart, etc)
  • chunk_code() — splits source by semantic boundaries:
    • Rust: fn, struct, enum, trait, impl, macro
    • Go: func, type struct, interface
    • Python: def, class (indentation-based)
    • TypeScript/JS: function, class, interface, const arrow functions
    • Dart: class, Widget, Future, void functions
  • extract_imports() — pulls use/import statements
  • CodeChunk struct: content, language, symbol_type, symbol_name
  • Brace-matching for block extraction
  • Fallback: whole file for unknown languages

Zero dependencies

Uses regex-free pattern matching. No tree-sitter crate needed — keeps uteke's zero-dep philosophy.

Tests: 9 chunker tests

  • Rust functions, structs
  • Go functions
  • Python functions/classes
  • TypeScript functions/interfaces
  • Dart classes
  • Import extraction
  • Fallback text

Tests

  • cargo test --workspace ✅ (171 passed, 5 ignored)
  • cargo clippy --workspace -- -D warnings ✅
  • cargo fmt --all ✅

Comment thread crates/uteke-core/src/chunker.rs Fixed
Comment thread crates/uteke-core/src/chunker.rs Fixed
Comment thread crates/uteke-core/src/chunker.rs Fixed
@github-actions

github-actions Bot commented Jun 14, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (2)

  • crates/uteke-core/src/chunker.rs:104 — In chunk_python, every line starting with def or class starts a new chunk regardless of indentation. This causes nested definitions to terminate the current outer block early. For example, in class Calculator:\n def add(...), the class chunk will contain only the class header, and the method becomes a separate top-level chunk. The implementation never tracks indentation to determine block ownership, so Python chunks do not represent semantic blocks correctly.
  • crates/uteke-core/src/chunker.rs:229 — The generic extract_block function increments and decrements depth for every { and } character in the source line. This means braces appearing inside string literals, template strings, comments, or character literals will be counted as structural braces. In languages handled here (Rust, Go, TypeScript/JavaScript, Dart), that can cause premature block termination or missed closures when code contains text like println!("}") or JS template content.

Review powered by cora-cli · BYOK · MIT

- Regex-based chunker (zero tree-sitter dependency)
- detect_language() from file extension
- chunk_code() splits by function/struct/class/impl boundaries
- extract_imports() pulls use/import statements
- 9 chunker tests
- Languages: Rust, Go, Python, TypeScript/JS, Dart
- Fallback: whole file as single chunk for unknown languages

Closes #245
@ajianaz
ajianaz force-pushed the feat/v020-245-ast-chunking branch from 210bf4b to 9b43bfa Compare June 14, 2026 06:46
("type ", "struct"),
("interface{}", "interface"),
];

("Widget ", "widget"),
];

chunk_by_patterns(content, "dart", &patterns, '{', '}')
@ajianaz
ajianaz merged commit 817f49d into develop Jun 14, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the feat/v020-245-ast-chunking branch June 14, 2026 06:53
ajianaz added a commit that referenced this pull request Aug 13, 2026
- Regex-based chunker (zero tree-sitter dependency)
- detect_language() from file extension
- chunk_code() splits by function/struct/class/impl boundaries
- extract_imports() pulls use/import statements
- 9 chunker tests
- Languages: Rust, Go, Python, TypeScript/JS, Dart
- Fallback: whole file as single chunk for unknown languages

Closes #245
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🧠 Feature: Code-aware embedding with AST chunking

2 participants