Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@tnm
Copy link
Contributor

@tnm tnm commented Sep 15, 2025

Fixes #134, as the tree-sitter library continues to change its interface. Add additional compatibility, and tighten our dep range.

@tnm
Copy link
Contributor Author

tnm commented Sep 15, 2025

🛠️ Kit AI Code Review

Priority Issues

Medium Priority

  • src/kit/tree_sitter_symbol_extractor.py:291: The new tree_sitter.Query constructor call lacks error handling for malformed query strings, which could cause crashes during initialization rather than graceful degradation.

Low Priority

  • src/kit/tree_sitter_symbol_extractor.py:297: The new tree_sitter.QueryError exception handling is good, but the logging could be more actionable by including the specific query content that failed (truncated for readability).

Summary

This PR updates the tree-sitter integration to use the new API introduced in version 0.25.1, specifically migrating from the deprecated language.query() method to the new tree_sitter.Query constructor and QueryCursor pattern. The changes include:

  • Dependency Update: Added explicit tree-sitter>=0.25.1 dependency to ensure compatibility
  • API Migration: Replaced deprecated language.query() with tree_sitter.Query() constructor
  • Query Execution: Implemented new QueryCursor(query).matches(root) pattern as primary method
  • Backward Compatibility: Maintained fallback logic for older API methods (matches() and captures())
  • Enhanced Error Handling: Added specific handling for tree_sitter.QueryError
  • Comprehensive Testing: Added new test suite specifically for the 0.25.1+ API compatibility

The architectural change is significant but well-executed, moving from a language-centric query creation model to a more explicit Query object pattern with cursor-based execution.

Recommendations

  1. Error Context Enhancement: Consider truncating and including the actual query content in error logs at src/kit/tree_sitter_symbol_extractor.py:300 to aid debugging:

    logger.error(f"Query content (first 200 chars): {combined_query_content[:200]}...")
  2. Fallback Logic Validation: The fallback mechanism at src/kit/tree_sitter_symbol_extractor.py:389 is well-designed with the api_worked flag preventing unnecessary fallback attempts when the new API succeeds but returns no matches.

  3. Test Coverage: The new test file tests/test_tree_sitter_api_compat.py provides excellent coverage of the new API, including version verification and multi-language testing.

  4. Version Consistency: All version bumps (Python package, TypeScript package, and internal version) are properly synchronized to 1.9.3, maintaining consistency across the ecosystem.

The PR demonstrates careful attention to backward compatibility while modernizing the tree-sitter integration. The comprehensive test coverage and defensive programming approach make this a solid migration.


Generated by cased kit v1.9.3 • Mode: kit • Model: claude-sonnet-4-20250514

@tnm tnm merged commit 87673ad into main Sep 15, 2025
1 check passed
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.

No compatible tree-sitter API found, Error - Affects Multiple File Types

2 participants