@xberg-io/opencode-xberg 1.3.7 → 1.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/.opencode/ai-rulez-bundle.json +52 -0
  2. package/.opencode/ai-rulez-content.js +167 -0
  3. package/.opencode/commands/xberg-extract.md +14 -0
  4. package/.opencode/commands/xberg-ocr.md +14 -0
  5. package/.opencode/plugins/xberg.js +75 -62
  6. package/.opencode/skills/xberg/SKILL.md +422 -0
  7. package/.opencode/skills/xberg/index.md +10 -0
  8. package/.opencode/skills/xberg/references/advanced-features.md +628 -0
  9. package/.opencode/skills/xberg/references/cli-reference.md +462 -0
  10. package/.opencode/skills/xberg/references/configuration.md +587 -0
  11. package/.opencode/skills/xberg/references/nodejs-api.md +485 -0
  12. package/.opencode/skills/xberg/references/other-bindings.md +345 -0
  13. package/.opencode/skills/xberg/references/python-api.md +657 -0
  14. package/.opencode/skills/xberg/references/rust-api.md +412 -0
  15. package/.opencode/skills/xberg/references/supported-formats.md +252 -0
  16. package/.opencode/skills/xberg-batch-extraction/SKILL.md +170 -0
  17. package/.opencode/skills/xberg-batch-extraction/index.md +10 -0
  18. package/.opencode/skills/xberg-batch-extraction/references/advanced-features.md +628 -0
  19. package/.opencode/skills/xberg-batch-extraction/references/cli-reference.md +462 -0
  20. package/.opencode/skills/xberg-batch-extraction/references/configuration.md +587 -0
  21. package/.opencode/skills/xberg-batch-extraction/references/nodejs-api.md +485 -0
  22. package/.opencode/skills/xberg-batch-extraction/references/other-bindings.md +345 -0
  23. package/.opencode/skills/xberg-batch-extraction/references/python-api.md +657 -0
  24. package/.opencode/skills/xberg-batch-extraction/references/rust-api.md +412 -0
  25. package/.opencode/skills/xberg-batch-extraction/references/supported-formats.md +252 -0
  26. package/.opencode/skills/xberg-chunking/SKILL.md +163 -0
  27. package/.opencode/skills/xberg-chunking/index.md +10 -0
  28. package/.opencode/skills/xberg-chunking/references/advanced-features.md +628 -0
  29. package/.opencode/skills/xberg-chunking/references/cli-reference.md +462 -0
  30. package/.opencode/skills/xberg-chunking/references/configuration.md +587 -0
  31. package/.opencode/skills/xberg-chunking/references/nodejs-api.md +485 -0
  32. package/.opencode/skills/xberg-chunking/references/other-bindings.md +345 -0
  33. package/.opencode/skills/xberg-chunking/references/python-api.md +657 -0
  34. package/.opencode/skills/xberg-chunking/references/rust-api.md +412 -0
  35. package/.opencode/skills/xberg-chunking/references/supported-formats.md +252 -0
  36. package/.opencode/skills/xberg-extracting-keywords/SKILL.md +170 -0
  37. package/.opencode/skills/xberg-extracting-keywords/index.md +10 -0
  38. package/.opencode/skills/xberg-extracting-keywords/references/advanced-features.md +628 -0
  39. package/.opencode/skills/xberg-extracting-keywords/references/cli-reference.md +462 -0
  40. package/.opencode/skills/xberg-extracting-keywords/references/configuration.md +587 -0
  41. package/.opencode/skills/xberg-extracting-keywords/references/nodejs-api.md +485 -0
  42. package/.opencode/skills/xberg-extracting-keywords/references/other-bindings.md +345 -0
  43. package/.opencode/skills/xberg-extracting-keywords/references/python-api.md +657 -0
  44. package/.opencode/skills/xberg-extracting-keywords/references/rust-api.md +412 -0
  45. package/.opencode/skills/xberg-extracting-keywords/references/supported-formats.md +252 -0
  46. package/.opencode/skills/xberg-extracting-tables/SKILL.md +155 -0
  47. package/.opencode/skills/xberg-extracting-tables/index.md +10 -0
  48. package/.opencode/skills/xberg-extracting-tables/references/advanced-features.md +628 -0
  49. package/.opencode/skills/xberg-extracting-tables/references/cli-reference.md +462 -0
  50. package/.opencode/skills/xberg-extracting-tables/references/configuration.md +587 -0
  51. package/.opencode/skills/xberg-extracting-tables/references/nodejs-api.md +485 -0
  52. package/.opencode/skills/xberg-extracting-tables/references/other-bindings.md +345 -0
  53. package/.opencode/skills/xberg-extracting-tables/references/python-api.md +657 -0
  54. package/.opencode/skills/xberg-extracting-tables/references/rust-api.md +412 -0
  55. package/.opencode/skills/xberg-extracting-tables/references/supported-formats.md +252 -0
  56. package/.opencode/skills/xberg-extracting-with-ocr/SKILL.md +129 -0
  57. package/.opencode/skills/xberg-extracting-with-ocr/index.md +10 -0
  58. package/.opencode/skills/xberg-extracting-with-ocr/references/advanced-features.md +628 -0
  59. package/.opencode/skills/xberg-extracting-with-ocr/references/cli-reference.md +462 -0
  60. package/.opencode/skills/xberg-extracting-with-ocr/references/configuration.md +587 -0
  61. package/.opencode/skills/xberg-extracting-with-ocr/references/nodejs-api.md +485 -0
  62. package/.opencode/skills/xberg-extracting-with-ocr/references/other-bindings.md +345 -0
  63. package/.opencode/skills/xberg-extracting-with-ocr/references/python-api.md +657 -0
  64. package/.opencode/skills/xberg-extracting-with-ocr/references/rust-api.md +412 -0
  65. package/.opencode/skills/xberg-extracting-with-ocr/references/supported-formats.md +252 -0
  66. package/.opencode/skills/xberg-picking-a-format/SKILL.md +104 -0
  67. package/.opencode/skills/xberg-picking-a-format/index.md +10 -0
  68. package/.opencode/skills/xberg-picking-a-format/references/advanced-features.md +628 -0
  69. package/.opencode/skills/xberg-picking-a-format/references/cli-reference.md +462 -0
  70. package/.opencode/skills/xberg-picking-a-format/references/configuration.md +587 -0
  71. package/.opencode/skills/xberg-picking-a-format/references/nodejs-api.md +485 -0
  72. package/.opencode/skills/xberg-picking-a-format/references/other-bindings.md +345 -0
  73. package/.opencode/skills/xberg-picking-a-format/references/python-api.md +657 -0
  74. package/.opencode/skills/xberg-picking-a-format/references/rust-api.md +412 -0
  75. package/.opencode/skills/xberg-picking-a-format/references/supported-formats.md +252 -0
  76. package/.pi/prompts/xberg-extract.md +14 -0
  77. package/.pi/prompts/xberg-ocr.md +14 -0
  78. package/.pi/skills/xberg/SKILL.md +422 -0
  79. package/.pi/skills/xberg/index.md +10 -0
  80. package/.pi/skills/xberg/references/advanced-features.md +628 -0
  81. package/.pi/skills/xberg/references/cli-reference.md +462 -0
  82. package/.pi/skills/xberg/references/configuration.md +587 -0
  83. package/.pi/skills/xberg/references/nodejs-api.md +485 -0
  84. package/.pi/skills/xberg/references/other-bindings.md +345 -0
  85. package/.pi/skills/xberg/references/python-api.md +657 -0
  86. package/.pi/skills/xberg/references/rust-api.md +412 -0
  87. package/.pi/skills/xberg/references/supported-formats.md +252 -0
  88. package/.pi/skills/xberg-batch-extraction/SKILL.md +170 -0
  89. package/.pi/skills/xberg-batch-extraction/index.md +10 -0
  90. package/.pi/skills/xberg-batch-extraction/references/advanced-features.md +628 -0
  91. package/.pi/skills/xberg-batch-extraction/references/cli-reference.md +462 -0
  92. package/.pi/skills/xberg-batch-extraction/references/configuration.md +587 -0
  93. package/.pi/skills/xberg-batch-extraction/references/nodejs-api.md +485 -0
  94. package/.pi/skills/xberg-batch-extraction/references/other-bindings.md +345 -0
  95. package/.pi/skills/xberg-batch-extraction/references/python-api.md +657 -0
  96. package/.pi/skills/xberg-batch-extraction/references/rust-api.md +412 -0
  97. package/.pi/skills/xberg-batch-extraction/references/supported-formats.md +252 -0
  98. package/.pi/skills/xberg-chunking/SKILL.md +163 -0
  99. package/.pi/skills/xberg-chunking/index.md +10 -0
  100. package/.pi/skills/xberg-chunking/references/advanced-features.md +628 -0
  101. package/.pi/skills/xberg-chunking/references/cli-reference.md +462 -0
  102. package/.pi/skills/xberg-chunking/references/configuration.md +587 -0
  103. package/.pi/skills/xberg-chunking/references/nodejs-api.md +485 -0
  104. package/.pi/skills/xberg-chunking/references/other-bindings.md +345 -0
  105. package/.pi/skills/xberg-chunking/references/python-api.md +657 -0
  106. package/.pi/skills/xberg-chunking/references/rust-api.md +412 -0
  107. package/.pi/skills/xberg-chunking/references/supported-formats.md +252 -0
  108. package/.pi/skills/xberg-extracting-keywords/SKILL.md +170 -0
  109. package/.pi/skills/xberg-extracting-keywords/index.md +10 -0
  110. package/.pi/skills/xberg-extracting-keywords/references/advanced-features.md +628 -0
  111. package/.pi/skills/xberg-extracting-keywords/references/cli-reference.md +462 -0
  112. package/.pi/skills/xberg-extracting-keywords/references/configuration.md +587 -0
  113. package/.pi/skills/xberg-extracting-keywords/references/nodejs-api.md +485 -0
  114. package/.pi/skills/xberg-extracting-keywords/references/other-bindings.md +345 -0
  115. package/.pi/skills/xberg-extracting-keywords/references/python-api.md +657 -0
  116. package/.pi/skills/xberg-extracting-keywords/references/rust-api.md +412 -0
  117. package/.pi/skills/xberg-extracting-keywords/references/supported-formats.md +252 -0
  118. package/.pi/skills/xberg-extracting-tables/SKILL.md +155 -0
  119. package/.pi/skills/xberg-extracting-tables/index.md +10 -0
  120. package/.pi/skills/xberg-extracting-tables/references/advanced-features.md +628 -0
  121. package/.pi/skills/xberg-extracting-tables/references/cli-reference.md +462 -0
  122. package/.pi/skills/xberg-extracting-tables/references/configuration.md +587 -0
  123. package/.pi/skills/xberg-extracting-tables/references/nodejs-api.md +485 -0
  124. package/.pi/skills/xberg-extracting-tables/references/other-bindings.md +345 -0
  125. package/.pi/skills/xberg-extracting-tables/references/python-api.md +657 -0
  126. package/.pi/skills/xberg-extracting-tables/references/rust-api.md +412 -0
  127. package/.pi/skills/xberg-extracting-tables/references/supported-formats.md +252 -0
  128. package/.pi/skills/xberg-extracting-with-ocr/SKILL.md +129 -0
  129. package/.pi/skills/xberg-extracting-with-ocr/index.md +10 -0
  130. package/.pi/skills/xberg-extracting-with-ocr/references/advanced-features.md +628 -0
  131. package/.pi/skills/xberg-extracting-with-ocr/references/cli-reference.md +462 -0
  132. package/.pi/skills/xberg-extracting-with-ocr/references/configuration.md +587 -0
  133. package/.pi/skills/xberg-extracting-with-ocr/references/nodejs-api.md +485 -0
  134. package/.pi/skills/xberg-extracting-with-ocr/references/other-bindings.md +345 -0
  135. package/.pi/skills/xberg-extracting-with-ocr/references/python-api.md +657 -0
  136. package/.pi/skills/xberg-extracting-with-ocr/references/rust-api.md +412 -0
  137. package/.pi/skills/xberg-extracting-with-ocr/references/supported-formats.md +252 -0
  138. package/.pi/skills/xberg-picking-a-format/SKILL.md +104 -0
  139. package/.pi/skills/xberg-picking-a-format/index.md +10 -0
  140. package/.pi/skills/xberg-picking-a-format/references/advanced-features.md +628 -0
  141. package/.pi/skills/xberg-picking-a-format/references/cli-reference.md +462 -0
  142. package/.pi/skills/xberg-picking-a-format/references/configuration.md +587 -0
  143. package/.pi/skills/xberg-picking-a-format/references/nodejs-api.md +485 -0
  144. package/.pi/skills/xberg-picking-a-format/references/other-bindings.md +345 -0
  145. package/.pi/skills/xberg-picking-a-format/references/python-api.md +657 -0
  146. package/.pi/skills/xberg-picking-a-format/references/rust-api.md +412 -0
  147. package/.pi/skills/xberg-picking-a-format/references/supported-formats.md +252 -0
  148. package/README.md +112 -6
  149. package/package.json +184 -16
  150. package/scripts/mcp-launch.sh +189 -0
@@ -0,0 +1,163 @@
1
+ ---
2
+ description: Use when splitting extracted text into chunks for LLM context windows or RAG ingestion. Covers chunk size, overlap, markdown/yaml/semantic chunkers, tokenizer-based sizing, and the standalone `chunk` command.
3
+ name: xberg-chunking
4
+ ---
5
+
6
+ <!--
7
+ AI-RULEZ :: GENERATED FILE — DO NOT EDIT
8
+ Content-Hash: blake3:aaaffebaf030b1c214ffc0a869f0a63366360a5a568638f6996b98e75901d121
9
+ Source-Hash: blake3:662aa704cf97ad20f02258c9dcd1c73822213a426e27ec7ebc292d3f599fb7c2
10
+ Schema-Version: v1
11
+ -->
12
+
13
+ # Chunking
14
+
15
+ Use this when feeding documents into an LLM context window or a vector
16
+ store. Xberg chunks two ways: inline during extraction (chunks land on
17
+ each document's `chunks` field), or standalone via the `chunk` command for text you
18
+ already have. Sizing is character-based by default, or token-based when a
19
+ tokenizer model is supplied.
20
+
21
+ ## Inline during extraction
22
+
23
+ Turn on chunking with `--chunk` and the chunks appear on the structured
24
+ result under `chunks`:
25
+
26
+ ```bash
27
+ # 1000-char chunks, 200-char overlap (defaults when --chunk is on)
28
+ xberg extract report.pdf --chunk --format json | jq '.result.chunks | length'
29
+
30
+ # Explicit size + overlap
31
+ xberg extract report.pdf --chunk --chunk-size 1500 --chunk-overlap 300 --format json
32
+ ```
33
+
34
+ Overlap must be smaller than chunk size — the CLI rejects
35
+ `--chunk-overlap >= --chunk-size`. When you set only `--chunk-overlap`
36
+ against an existing config, an overlap that exceeds the size is clamped to
37
+ `chunk_size / 4`.
38
+
39
+ ## Standalone `chunk` command
40
+
41
+ Chunk text you already have, from `--text` or stdin. Output defaults to
42
+ JSON:
43
+
44
+ ```bash
45
+ # From a flag
46
+ xberg chunk --text "long document text ..." --chunk-size 800 --chunk-overlap 100
47
+
48
+ # From stdin (pipe extracted content straight in)
49
+ xberg extract notes.md | xberg chunk --chunk-size 500 --format json
50
+ ```
51
+
52
+ JSON output carries `chunks` (array of strings), `chunk_count`, the
53
+ resolved `config` (`max_characters`, `overlap`, `chunker_type`), and
54
+ `input_size_bytes`. Use `--format text` for a human-readable dump with
55
+ `--- chunk N ---` separators.
56
+
57
+ > Note: in the JSON output, `chunker_type` is rendered capitalized (`"Text"`,
58
+ > `"Markdown"`, `"Yaml"`, `"Semantic"`) because it is emitted via Rust's Debug
59
+ > formatting, whereas the `--chunker-type` input flag is lowercase
60
+ > (`text`, `markdown`, `yaml`, `semantic`). Lowercase the value before
61
+ > comparing if you parse it back.
62
+
63
+ ## Chunker types
64
+
65
+ `--chunker-type` selects the splitting strategy (standalone `chunk`
66
+ command):
67
+
68
+ | Type | Behavior |
69
+ | ---------- | ------------------------------------------------------------------- |
70
+ | `text` | **Default.** Plain character-window splitting with overlap. |
71
+ | `markdown` | Markdown-aware — splits on structure (headings, blocks) where possible. |
72
+ | `yaml` | YAML-aware splitting for structured config/data documents. |
73
+ | `semantic` | Topic-boundary splitting driven by `--topic-threshold` (0.0–1.0, default 0.75). |
74
+
75
+ ```bash
76
+ # Markdown-aware chunking keeps headings and blocks intact
77
+ xberg chunk --text "$(cat README.md)" --chunker-type markdown
78
+
79
+ # Semantic chunking — lower threshold = more, smaller topic chunks
80
+ xberg chunk --text "$(cat transcript.txt)" --chunker-type semantic --topic-threshold 0.6
81
+ ```
82
+
83
+ ## Token-based sizing
84
+
85
+ By default `--chunk-size` counts characters. To size chunks by tokens for
86
+ a specific model, pass `--chunking-tokenizer` with a HuggingFace tokenizer
87
+ id. On the `extract` command this implicitly enables chunking. Requires the
88
+ `chunking-tokenizers` feature (present in the default CLI build).
89
+
90
+ ```bash
91
+ # Size chunks by GPT-4o tokens during extraction
92
+ xberg extract report.pdf --chunking-tokenizer Xenova/gpt-4o --format json
93
+
94
+ # Or on the standalone command
95
+ xberg chunk --text "$(cat doc.txt)" --chunking-tokenizer Xenova/gpt-4o --chunk-size 512
96
+ ```
97
+
98
+ With a tokenizer set, `--chunk-size` is interpreted in tokens, not
99
+ characters.
100
+
101
+ ## Config file alternative
102
+
103
+ Field names in config files are snake_case under `[chunking]`:
104
+
105
+ ```toml
106
+ [chunking]
107
+ max_characters = 1000
108
+ overlap = 200
109
+ chunker_type = "markdown"
110
+ ```
111
+
112
+ ```bash
113
+ xberg extract report.pdf --config xberg.toml --format json
114
+ ```
115
+
116
+ > CLI flags map to config fields as `--chunk-size` → `max_characters` and
117
+ > `--chunk-overlap` → `overlap`. In config files use the snake_case names.
118
+
119
+ ## Programmatic access
120
+
121
+ From Python, enable chunking on the config and read the chunks off the
122
+ document in the result envelope (`result.results[0].chunks`):
123
+
124
+ ```python
125
+ from xberg import ExtractInput, extract, ExtractionConfig, ChunkingConfig
126
+
127
+ config = ExtractionConfig(
128
+ chunking=ChunkingConfig(max_characters=1000, overlap=200),
129
+ )
130
+ result = await extract(ExtractInput(uri="report.pdf"), config)
131
+ for chunk in result.results[0].chunks or []:
132
+ print(len(chunk.content))
133
+ ```
134
+
135
+ > The public Python `ChunkingConfig` (a dataclass) uses constructor kwargs
136
+ > `max_characters` / `overlap`; the Rust core struct fields are also
137
+ > `max_characters` / `overlap`. TOML/JSON config keys are `max_chars` /
138
+ > `max_overlap` (with `max_characters` / `overlap` accepted as serde aliases),
139
+ > and dict-form config passed to `ExtractionConfig` likewise accepts the
140
+ > `max_chars` / `max_overlap` aliases; Node's `ChunkingConfig` interface uses
141
+ > `maxCharacters` / `overlap`. See `references/python-api.md` and
142
+ > `references/rust-api.md`.
143
+
144
+ ## Picking parameters
145
+
146
+ - **RAG / vector store** — 500–1000 chars (or 256–512 tokens) with
147
+ 10–20% overlap. Use `markdown` chunking for docs to keep sections whole.
148
+ - **LLM summarization** — larger chunks (1500–4000 chars) with small
149
+ overlap; size by tokens to stay under the model window.
150
+ - **Topic segmentation** — `semantic` chunker; tune `--topic-threshold`
151
+ down for finer splits, up for coarser ones.
152
+
153
+ ## Common pitfalls
154
+
155
+ - **Overlap ≥ size** — rejected on `extract`; clamped to `size / 4` when
156
+ only overlap is changed against an existing config.
157
+ - **Tokenizer without the feature** — `--chunking-tokenizer` errors if the
158
+ CLI was built without `chunking-tokenizers`. The default build includes it.
159
+ - **Empty input** — the standalone `chunk` command bails on empty text;
160
+ provide `--text` or pipe non-empty stdin.
161
+
162
+ See `references/configuration.md` for the full `[chunking]` schema and
163
+ `references/cli-reference.md` for every chunk flag.
@@ -0,0 +1,10 @@
1
+ <!--
2
+ AI-RULEZ :: GENERATED FILE — DO NOT EDIT
3
+ Content-Hash: blake3:300ad773df783b84ad7b4ea64f24ab3a0b853670f28ac74c7d6f9f00a18ac505
4
+ Source-Hash: blake3:662aa704cf97ad20f02258c9dcd1c73822213a426e27ec7ebc292d3f599fb7c2
5
+ Schema-Version: v1
6
+ -->
7
+
8
+ # Concepts
9
+
10
+ * [Chunking](SKILL.md) - Use when splitting extracted text into chunks for LLM context windows or RAG ingestion. Covers chunk size, overlap, markdown/yaml/semantic chunkers, tokenizer-based sizing, and the standalone `chunk` command.