[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6BYZS6K8FTVA7N5MV9GC1YX":3,"skill-same:01M6BYZS6K8FTVA7N5MV9GC1YX":99},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":41,"linkOnly":42,"markdownContent":43,"markdownBody":44,"frontMatter":45,"refName":51,"commitSha":52,"skillDirectory":53,"forksCount":54,"repositoryHtmlUrl":55,"repositoryHomepageUrl":56,"ownerHtmlUrl":57,"ownerBlogUrl":58,"ownerDescription":59,"updatedAt":60,"install":61,"resources":74},"01M6BYZS6K8FTVA7N5MV9GC1YX","tree-sitter-language-pack-chunking-for-llms","LLM 上下文源码语法分块","Use when the user wants to split source code into chunks for an LLM context window without breaking syntax mid-construct. Covers `ts-pack process --chunk-size`, why syntax-aware splits beat fixed-byte splits, picking a size, and the chunk JSON shape.","当用户需要将源代码切分为适合 LLM 上下文窗口的分块、且不破坏语法结构完整性时使用。涵盖 `ts-pack process --chunk-size`、为何语法感知切分优于固定字节切分、如何选择分块大小，以及分块 JSON 的结构。","xberg-io\u002Ftree-sitter-language-pack","xberg-io","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F241328462?v=4","01M6BYYMACFMK5WNT338Y71K58","Xberg.io","01M6BYYMEGM63ZCEYZJRTVS9JT",485,"MIT",null,"https:\u002F\u002Fgithub.com\u002Fxberg-io\u002Ftree-sitter-language-pack\u002Fblob\u002Fmain\u002Fplugin\u002F.ai-rulez\u002Fskills\u002Ftree-sitter-language-pack-chunking-for-llms\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQ6TKQDF2K4KQS863Q79P4","开发参考","SCENARIO","使用场景",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",[31,32,33,34,35,36,37,38,39,40],"llms","language pack","tree sitter","tree sitter language pack chunking for llms","code","chunk","playbook","why","json","syntax","2026-11-10 10:12:30",false,"---\ntype: Playbook\ntitle: Tree Sitter Language Pack Chunking For Llms\ndescription: Use when the user wants to split source code into chunks for an LLM context window without breaking syntax mid-construct. Covers `ts-pack process --chunk-size`, why syntax-aware splits beat fixed-byte splits, picking a size, and the chunk JSON shape.\nx-ai-rulez:\n  kind: skill\n  id: tree-sitter-language-pack-chunking-for-llms\n  metadata:\n    name: tree-sitter-language-pack-chunking-for-llms\n---\n\n# Syntax-aware chunking for LLMs\n\nSplitting code on a fixed byte or line count cuts functions in half and\nstrips context. `ts-pack process \u003Cfile> --chunk-size \u003Cbytes>` splits on\nsyntactic boundaries (whole functions, classes, blocks) so each chunk is a\ncoherent unit, and emits them in the JSON `chunks` array.\n\n## Quick recipe\n\n```bash\n# ~2 KB chunks aligned to syntax boundaries\nts-pack process src\u002Fapp.ts --chunk-size 2000\n```\n\n`--chunk-size` is a maximum size in bytes. The splitter packs whole\nsyntactic units up to that bound; an oversized single construct becomes its\nown chunk rather than being cut. Chunks are added to the normal `process`\nJSON output under `chunks`.\n\n## Picking a size\n\n- Match the downstream model's token budget. A rough rule: bytes ÷ 4 ≈\n  tokens for code, so `--chunk-size 4000` is on the order of ~1k tokens.\n- Larger chunks preserve more local context but fit fewer per request.\n- Leave headroom for the prompt, the surrounding messages, and the\n  response — do not size chunks to the full context window.\n\n## Combining with extraction\n\nChunking composes with the other `process` features, so you can attach\nstructure metadata to each request:\n\n```bash\nts-pack process src\u002Fservice.py --structure --chunk-size 3000 \\\n  | jq '{chunks: (.chunks | length), functions: (.structure | length)}'\n```\n\n## Chunk output\n\n`chunks` is a list of code-chunk objects in the `process` JSON. Each chunk\ncarries its source text plus span information (line\u002Fbyte offsets), so you\ncan cite or re-locate a chunk back in the original file. Iterate the array\nto feed an LLM one coherent unit at a time:\n\n```bash\nts-pack process big_module.py --chunk-size 2500 \\\n  | jq -c '.chunks[]'\n```\n\n## SDK equivalent\n\nThe SDK exposes chunking through the process config: set the\n`chunk_max_size` field (in bytes) on `ProcessConfig` — the same value the\nCLI's `--chunk-size` flag sets. `ProcessConfig` is a frozen dataclass, so\npass it to the constructor:\n\n```python\nfrom tree_sitter_language_pack import process, ProcessConfig\n\nconfig = ProcessConfig(\"python\", chunk_max_size=2500)\nresult = process(source_code, config)\nfor chunk in result.chunks:          # ProcessResult is an object, not a dict\n    send_to_llm(chunk.content)\n```\n\n## When not to chunk\n\nFor a single small file that already fits the context window, skip\nchunking and pass the file whole. Reach for chunking when a file is large,\nwhen you are batching many files into a RAG index, or when you need stable,\nsyntactically coherent units to cite.\n","# Syntax-aware chunking for LLMs\n\nSplitting code on a fixed byte or line count cuts functions in half and\nstrips context. `ts-pack process \u003Cfile> --chunk-size \u003Cbytes>` splits on\nsyntactic boundaries (whole functions, classes, blocks) so each chunk is a\ncoherent unit, and emits them in the JSON `chunks` array.\n\n## Quick recipe\n\n```bash\n# ~2 KB chunks aligned to syntax boundaries\nts-pack process src\u002Fapp.ts --chunk-size 2000\n```\n\n`--chunk-size` is a maximum size in bytes. The splitter packs whole\nsyntactic units up to that bound; an oversized single construct becomes its\nown chunk rather than being cut. Chunks are added to the normal `process`\nJSON output under `chunks`.\n\n## Picking a size\n\n- Match the downstream model's token budget. A rough rule: bytes ÷ 4 ≈\n  tokens for code, so `--chunk-size 4000` is on the order of ~1k tokens.\n- Larger chunks preserve more local context but fit fewer per request.\n- Leave headroom for the prompt, the surrounding messages, and the\n  response — do not size chunks to the full context window.\n\n## Combining with extraction\n\nChunking composes with the other `process` features, so you can attach\nstructure metadata to each request:\n\n```bash\nts-pack process src\u002Fservice.py --structure --chunk-size 3000 \\\n  | jq '{chunks: (.chunks | length), functions: (.structure | length)}'\n```\n\n## Chunk output\n\n`chunks` is a list of code-chunk objects in the `process` JSON. Each chunk\ncarries its source text plus span information (line\u002Fbyte offsets), so you\ncan cite or re-locate a chunk back in the original file. Iterate the array\nto feed an LLM one coherent unit at a time:\n\n```bash\nts-pack process big_module.py --chunk-size 2500 \\\n  | jq -c '.chunks[]'\n```\n\n## SDK equivalent\n\nThe SDK exposes chunking through the process config: set the\n`chunk_max_size` field (in bytes) on `ProcessConfig` — the same value the\nCLI's `--chunk-size` flag sets. `ProcessConfig` is a frozen dataclass, so\npass it to the constructor:\n\n```python\nfrom tree_sitter_language_pack import process, ProcessConfig\n\nconfig = ProcessConfig(\"python\", chunk_max_size=2500)\nresult = process(source_code, config)\nfor chunk in result.chunks:          # ProcessResult is an object, not a dict\n    send_to_llm(chunk.content)\n```\n\n## When not to chunk\n\nFor a single small file that already fits the context window, skip\nchunking and pass the file whole. Reach for chunking when a file is large,\nwhen you are batching many files into a RAG index, or when you need stable,\nsyntactically coherent units to cite.\n",{"type":46,"title":47,"x-ai-rulez":48,"description":7},"Playbook","Tree Sitter Language Pack Chunking For Llms",{"id":5,"kind":49,"metadata":50},"skill",{"name":5},"main","c14405493731b34089b4aae085abe5527b5000c7","plugin\u002F.ai-rulez\u002Fskills\u002Ftree-sitter-language-pack-chunking-for-llms",71,"https:\u002F\u002Fgithub.com\u002Fxberg-io\u002Ftree-sitter-language-pack","https:\u002F\u002Fdocs.tree-sitter-language-pack.xberg.io","https:\u002F\u002Fgithub.com\u002Fxberg-io","https:\u002F\u002Fxberg.io","Open-source content intelligence with a Rust core: documents, web, LLMs and code, with native bindings for every major language.","2026-11-15 00:20:30",{"source":9,"skillName":5,"commands":62,"prompt":72,"zipAvailable":73},[63,66,69],{"tool":64,"command":65},"npx","npx skills add xberg-io\u002Ftree-sitter-language-pack --skill tree-sitter-language-pack-chunking-for-llms",{"tool":67,"command":68},"bunx","bunx skills add xberg-io\u002Ftree-sitter-language-pack --skill tree-sitter-language-pack-chunking-for-llms",{"tool":70,"command":71},"pnpm","pnpm dlx skills add xberg-io\u002Ftree-sitter-language-pack --skill tree-sitter-language-pack-chunking-for-llms","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fxberg-io\u002Ftree-sitter-language-pack\u002Fblob\u002Fmain\u002Fplugin\u002F.ai-rulez\u002Fskills\u002Ftree-sitter-language-pack-chunking-for-llms\u002FSKILL.md",true,[75,81,87,91,94],{"path":76,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":79,"sourceHtmlUrl":80},"assets\u002F.gitkeep","ASSET","资产文件",0,"https:\u002F\u002Fgithub.com\u002Fbitflight-devops\u002Fskilllint\u002Fblob\u002Fmain\u002Fpackages\u002Fskilllint\u002Ftests\u002Ffixtures\u002Fproviders\u002Fagentskills\u002Fpassing-examples\u002FFM005\u002Fcorrect-types\u002Fskills\u002Fmy-skill\u002Fassets\u002F.gitkeep",{"path":82,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":85,"sourceHtmlUrl":86},"eval_queries.json","REFERENCE","参考文档",18,"https:\u002F\u002Fgithub.com\u002Fbitflight-devops\u002Fskilllint\u002Fblob\u002Fmain\u002Fpackages\u002Fskilllint\u002Ftests\u002Ffixtures\u002Fproviders\u002Fagentskills\u002Fpassing-examples\u002FFM005\u002Fcorrect-types\u002Fskills\u002Fmy-skill\u002Feval_queries.json",{"path":88,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":89,"sourceHtmlUrl":90},"index.md",323,"https:\u002F\u002Fgithub.com\u002Fxberg-io\u002Ftree-sitter-language-pack\u002Fblob\u002Fmain\u002Fplugin\u002F.ai-rulez\u002Fskills\u002Ftree-sitter-language-pack-chunking-for-llms\u002Findex.md",{"path":92,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":79,"sourceHtmlUrl":93},"references\u002F.gitkeep","https:\u002F\u002Fgithub.com\u002Fbitflight-devops\u002Fskilllint\u002Fblob\u002Fmain\u002Fpackages\u002Fskilllint\u002Ftests\u002Ffixtures\u002Fproviders\u002Fagentskills\u002Fpassing-examples\u002FFM005\u002Fcorrect-types\u002Fskills\u002Fmy-skill\u002Freferences\u002F.gitkeep",{"path":95,"resourceType":96,"resourceTypeDesc":97,"sizeBytes":79,"sourceHtmlUrl":98},"scripts\u002F.gitkeep","SCRIPT","脚本","https:\u002F\u002Fgithub.com\u002Fbitflight-devops\u002Fskilllint\u002Fblob\u002Fmain\u002Fpackages\u002Fskilllint\u002Ftests\u002Ffixtures\u002Fproviders\u002Fagentskills\u002Fpassing-examples\u002FFM005\u002Fcorrect-types\u002Fskills\u002Fmy-skill\u002Fscripts\u002F.gitkeep",[100,129,150,169,193,211],{"skillNo":101,"name":102,"nameZh":103,"description":104,"descriptionZh":105,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":106,"categories":107,"keywords":112,"publishedAt":41},"01M6BZ48YBWAZH9X1XZ6QVA5TD","tree-sitter-language-pack","tree-sitter 代码智能解析","Parse and extract code intelligence from 371 programming languages using tree-sitter grammars. Use when writing code that parses source, extracts structure\u002Fimports\u002Fexports\u002Fsymbols\u002Fdocstrings\u002Fcomments, detects a language, runs syntax diagnostics, or produces syntax-aware chunks for LLMs — in Rust, Python, Node.js\u002FTypeScript, or the ts-pack CLI. Covers installation, the CLI surface, the SDK surface, and parser-cache management.","使用 tree-sitter 语法从 371 种编程语言中解析并提取代码智能信息。适用于编写解析源代码、提取结构\u002F导入\u002F导出\u002F符号\u002F文档字符串\u002F注释、检测语言、运行语法诊断或为大模型（LLM）生成语法感知分块的代码——支持 Rust、Python、Node.js\u002FTypeScript 或 ts-pack CLI。涵盖安装、CLI 接口、SDK 接口以及解析器缓存管理。","https:\u002F\u002Fgithub.com\u002Fxberg-io\u002Ftree-sitter-language-pack\u002Fblob\u002Fmain\u002Fskills\u002Ftree-sitter-language-pack\u002FSKILL.md",[108,109],{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},{"categoryNo":110,"categoryName":111,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8CBEPE1MJTS9ARYEK7J8BH4","代码解析与结构分析",[113,32,33,114,115,116,117,118,35,31,119,120,121,122,123,124,125,126,127,128],"tree sitter language pack","tree","language","pack","rust","writing","cli","node","parser","typescript","io","structure","chunks","imports","parse","when",{"skillNo":130,"name":131,"nameZh":132,"description":133,"descriptionZh":134,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":135,"categories":136,"keywords":139,"publishedAt":41},"01M6BZ461Q0A0TZJG56G6J5QF0","tree-sitter-language-pack-using-the-mcp-server","tree-sitter MCP 服务使用","Use when parsing source, extracting code structure, or detecting a language through the tree-sitter-language-pack MCP server's tools, rather than shelling out to the ts-pack CLI. Covers the tool surface, the auto-installing launcher, and when MCP beats the CLI or SDK.","当需要通过 tree-sitter-language-pack 的 MCP 服务器工具来解析源代码、提取代码结构或检测语言（而非调用 ts-pack CLI）时使用。涵盖工具接口、自动安装启动器，以及 MCP 相较于 CLI 或 SDK 的优势场景。","https:\u002F\u002Fgithub.com\u002Fxberg-io\u002Ftree-sitter-language-pack\u002Fblob\u002Fmain\u002Fskills\u002Ftree-sitter-language-pack-using-the-mcp-server\u002FSKILL.md",[137,138],{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},{"categoryNo":110,"categoryName":111,"taxonomyType":23,"taxonomyTypeDesc":24},[140,141,113,142,143,32,33,114,115,116,35,119,144,145,146,147,124,148,149,128],"tree sitter language pack using the mcp server","MCP","mcp server","server","detecting","extracting","launcher","auto","source","Tools",{"skillNo":151,"name":152,"nameZh":153,"description":154,"descriptionZh":155,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":156,"categories":157,"keywords":160,"publishedAt":41},"01M6BZ437CE3DZQ22GYHMNMMVK","tree-sitter-language-pack-parsing-source","源代码语法树解析","Use when the user wants a tree-sitter syntax tree for a source file — an s-expression dump or JSON tree. Covers `ts-pack parse`, language auto-detection vs `--language`, stdin input, and reading `has_errors`.","当用户需要为源文件生成 tree-sitter 语法树时使用——以 s-表达式转储或 JSON 树的形式呈现。涵盖 `ts-pack parse`、语言自动检测与 `--language` 的对比、标准输入（stdin）输入以及读取 `has_errors`。","https:\u002F\u002Fgithub.com\u002Fxberg-io\u002Ftree-sitter-language-pack\u002Fblob\u002Fmain\u002Fskills\u002Ftree-sitter-language-pack-parsing-source\u002FSKILL.md",[158,159],{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},{"categoryNo":110,"categoryName":111,"taxonomyType":23,"taxonomyTypeDesc":24},[161,162,113,32,33,114,148,115,116,163,39,40,164,165,166,147,167,168,127,128],"parsing","tree sitter language pack parsing source","file","for","errors","expression","use","reading",{"skillNo":170,"name":171,"nameZh":172,"description":173,"descriptionZh":174,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":175,"categories":176,"keywords":181,"publishedAt":41},"01M6BZ40QMB2C6QF2N09MM15GF","tree-sitter-language-pack-managing-parsers","解析器缓存管理","Use when the user needs to manage the tree-sitter parser cache — prefetch parsers for offline or CI runs, list what is downloaded, inspect a language, find the cache directory, or clean it. Covers `ts-pack download`, `list`, `info`, `cache-dir`, `clean`, and `init`.","当用户需要管理 tree-sitter 解析器缓存时使用——为离线或 CI 运行预取解析器、列出已下载内容、检查某种语言、查找缓存目录或清理缓存。涵盖 `ts-pack download`、`list`、`info`、`cache-dir`、`clean` 和 `init`。","https:\u002F\u002Fgithub.com\u002Fxberg-io\u002Ftree-sitter-language-pack\u002Fblob\u002Fmain\u002Fskills\u002Ftree-sitter-language-pack-managing-parsers\u002FSKILL.md",[177,178],{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},{"categoryNo":179,"categoryName":180,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BSTR9G4A4GZ0VB2DFN9490","开发环境与工具链管理",[182,183,113,32,33,114,115,116,184,185,186,187,188,164,189,190,191,167,192,128],"parsers","tree sitter language pack managing parsers","ci","init","prefetch","cache","find","inspect","manage","clean","info",{"skillNo":194,"name":195,"nameZh":196,"description":197,"descriptionZh":198,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":199,"categories":200,"keywords":203,"publishedAt":41},"01M6BZ3Y1E46H4CPXVJD6SB03D","tree-sitter-language-pack-extracting-code-structure","代码结构提取","Use when the user wants structured code metadata from a source file — functions, classes, imports, exports, symbols, docstrings, comments, or syntax diagnostics. Covers `ts-pack process` feature flags, the JSON result shape, and the default feature set.","当用户需要从源文件获取结构化代码元数据时使用——包括函数、类、导入、导出、符号、文档字符串、注释或语法诊断。涵盖 `ts-pack process` 的功能开关、JSON 结果结构以及默认功能集。","https:\u002F\u002Fgithub.com\u002Fxberg-io\u002Ftree-sitter-language-pack\u002Fblob\u002Fmain\u002Fskills\u002Ftree-sitter-language-pack-extracting-code-structure\u002FSKILL.md",[201,202],{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},{"categoryNo":110,"categoryName":111,"taxonomyType":23,"taxonomyTypeDesc":24},[204,113,35,32,33,145,124,114,115,116,205,206,207,40,208,209,148,126,210,128],"tree sitter language pack extracting code structure","extracting code structure","code structure","SET","default","flags","result",{"skillNo":212,"name":213,"nameZh":214,"description":215,"descriptionZh":216,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":217,"categories":218,"keywords":221,"publishedAt":41},"01M6BZ3VAJEY26GESPCWQ2JSXA","tree-sitter-language-pack-detecting-languages","编程语言检测","Use when the user wants to know which programming language a file or snippet is. Covers implicit detection in `ts-pack parse`\u002F`process`, confirming support with `ts-pack list`\u002F`info`, and the SDK detection functions for path, extension, and raw content.","当用户想知道某个文件或代码片段属于哪种编程语言时使用。涵盖 `ts-pack parse`\u002F`process` 中的隐式检测、通过 `ts-pack list`\u002F`info` 确认是否支持某种语言，以及用于路径、扩展名和原始内容的 SDK 检测函数。","https:\u002F\u002Fgithub.com\u002Fxberg-io\u002Ftree-sitter-language-pack\u002Fblob\u002Fmain\u002Fskills\u002Ftree-sitter-language-pack-detecting-languages\u002FSKILL.md",[219,220],{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},{"categoryNo":110,"categoryName":111,"taxonomyType":23,"taxonomyTypeDesc":24},[222,113,32,33,114,144,115,116,223,163,224,225,226,164,167,227,228,192,127,128],"tree sitter language pack detecting languages","programming language","programming","support","which","functions","with"]