{"id":1883,"library":"tree-sitter-language-pack","title":"Tree-sitter Language Pack","description":"tree-sitter-language-pack is a Python library providing pre-compiled Tree-sitter parsers for over 300 programming languages. It offers a unified `process()` API for efficient parsing, advanced code analysis, and intelligent code chunking. The library is actively maintained with frequent releases, typically introducing new language grammars and API enhancements.","status":"active","version":"1.5.0","language":"en","source_language":"en","source_url":"https://github.com/kreuzberg-dev/tree-sitter-language-pack","tags":["parsing","code analysis","NLP","AST","tree-sitter","language processing","code intelligence","static analysis"],"install":[{"cmd":"pip install tree-sitter-language-pack","lang":"bash","label":"Pip"},{"cmd":"uv add tree-sitter-language-pack","lang":"bash","label":"Uv"}],"dependencies":[{"reason":"Required for Python bindings.","package":"python","version":">=3.10","optional":false}],"imports":[{"note":"The `process` function with `ProcessConfig` is the recommended unified API for comprehensive parsing and analysis.","symbol":"process","correct":"from tree_sitter_language_pack import process, ProcessConfig"},{"note":"These functions provide direct access to `tree-sitter.Language` and `tree-sitter.Parser` objects, primarily for lower-level interaction if `process()` is not sufficient.","symbol":"get_language","correct":"from tree_sitter_language_pack import get_language, get_parser"}],"quickstart":{"code":"from tree_sitter_language_pack import process, ProcessConfig\nimport os\n\nsource_code = \"\"\"\ndef hello():\n    # This is a comment\n    print(\"Hello, World!\")\n\nclass MyClass:\n    def __init__(self):\n        pass\n\"\"\"\n\n# Process source code for intelligence extraction (auto-downloads language if needed)\nresult = process(source_code, ProcessConfig(language=\"python\"))\n\nprint(f\"Functions found: {len(result.get('structure', []))}\")\nprint(f\"Diagnostics: {result.get('diagnostics', [])}\")\nprint(f\"Comments: {result.get('comments', [])}\")\n\n# Example with AST-aware chunking\nchunked_result = process(\n    source_code,\n    ProcessConfig(language=\"python\", chunk_max_size=50, comments=True)\n)\nprint(f\"Chunks found: {len(chunked_result.get('chunks', []))}\")","lang":"python","description":"This quickstart demonstrates the core `process()` API to extract structured intelligence from source code, including functions, diagnostics, and comments. It also shows how to use AST-aware chunking for breaking down larger code blocks. The library automatically downloads necessary language parsers on demand."},"warnings":[{"fix":"Ensure you are using the correct package name `tree-sitter-language-pack` for Python and refer to the latest documentation for CLI installation (`cargo install ts-pack-cli` or `brew install kreuzberg-dev/tap/ts-pack`).","message":"Prior to v1.4.2, installation documentation, especially for the CLI (`ts-pack-cli`), contained incorrect package names and references, leading to potential installation issues or confusion.","severity":"gotcha","affected_versions":"<1.4.2"},{"fix":"Upgrade to v1.3.3 or newer to resolve issues with dynamic loading and `c_symbol` overrides for affected languages.","message":"Versions prior to v1.3.3 experienced issues with dynamic parser loading and `c_symbol` overrides for specific languages (e.g., C#, VB, Embedded Template, Nushell), potentially causing runtime errors.","severity":"gotcha","affected_versions":"<1.3.3"},{"fix":"Prefer using the `process()` API with `ProcessConfig` for most code intelligence tasks to leverage the full capabilities and consistent interface of the library.","message":"While direct access to `tree-sitter.Language` and `tree-sitter.Parser` objects via `get_language()` and `get_parser()` is available, the `process()` function with `ProcessConfig` is the recommended and unified API across all bindings for comprehensive code intelligence, including parsing, analysis, and chunking.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Rely primarily on `tree-sitter-language-pack` for all your grammar needs to maintain consistency. If interoperability is required, carefully manage `tree-sitter` versions and compilation flags.","message":"tree-sitter-language-pack aims to simplify Tree-sitter usage by bundling grammars. However, if integrating with other raw `tree-sitter` libraries or manually compiled grammars, be aware that the underlying `tree-sitter` ecosystem can have complex versioning and compilation requirements that might lead to conflicts or unexpected behavior.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}