@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.
- package/.opencode/ai-rulez-bundle.json +52 -0
- package/.opencode/ai-rulez-content.js +167 -0
- package/.opencode/commands/xberg-extract.md +14 -0
- package/.opencode/commands/xberg-ocr.md +14 -0
- package/.opencode/plugins/xberg.js +75 -62
- package/.opencode/skills/xberg/SKILL.md +422 -0
- package/.opencode/skills/xberg/index.md +10 -0
- package/.opencode/skills/xberg/references/advanced-features.md +628 -0
- package/.opencode/skills/xberg/references/cli-reference.md +462 -0
- package/.opencode/skills/xberg/references/configuration.md +587 -0
- package/.opencode/skills/xberg/references/nodejs-api.md +485 -0
- package/.opencode/skills/xberg/references/other-bindings.md +345 -0
- package/.opencode/skills/xberg/references/python-api.md +657 -0
- package/.opencode/skills/xberg/references/rust-api.md +412 -0
- package/.opencode/skills/xberg/references/supported-formats.md +252 -0
- package/.opencode/skills/xberg-batch-extraction/SKILL.md +170 -0
- package/.opencode/skills/xberg-batch-extraction/index.md +10 -0
- package/.opencode/skills/xberg-batch-extraction/references/advanced-features.md +628 -0
- package/.opencode/skills/xberg-batch-extraction/references/cli-reference.md +462 -0
- package/.opencode/skills/xberg-batch-extraction/references/configuration.md +587 -0
- package/.opencode/skills/xberg-batch-extraction/references/nodejs-api.md +485 -0
- package/.opencode/skills/xberg-batch-extraction/references/other-bindings.md +345 -0
- package/.opencode/skills/xberg-batch-extraction/references/python-api.md +657 -0
- package/.opencode/skills/xberg-batch-extraction/references/rust-api.md +412 -0
- package/.opencode/skills/xberg-batch-extraction/references/supported-formats.md +252 -0
- package/.opencode/skills/xberg-chunking/SKILL.md +163 -0
- package/.opencode/skills/xberg-chunking/index.md +10 -0
- package/.opencode/skills/xberg-chunking/references/advanced-features.md +628 -0
- package/.opencode/skills/xberg-chunking/references/cli-reference.md +462 -0
- package/.opencode/skills/xberg-chunking/references/configuration.md +587 -0
- package/.opencode/skills/xberg-chunking/references/nodejs-api.md +485 -0
- package/.opencode/skills/xberg-chunking/references/other-bindings.md +345 -0
- package/.opencode/skills/xberg-chunking/references/python-api.md +657 -0
- package/.opencode/skills/xberg-chunking/references/rust-api.md +412 -0
- package/.opencode/skills/xberg-chunking/references/supported-formats.md +252 -0
- package/.opencode/skills/xberg-extracting-keywords/SKILL.md +170 -0
- package/.opencode/skills/xberg-extracting-keywords/index.md +10 -0
- package/.opencode/skills/xberg-extracting-keywords/references/advanced-features.md +628 -0
- package/.opencode/skills/xberg-extracting-keywords/references/cli-reference.md +462 -0
- package/.opencode/skills/xberg-extracting-keywords/references/configuration.md +587 -0
- package/.opencode/skills/xberg-extracting-keywords/references/nodejs-api.md +485 -0
- package/.opencode/skills/xberg-extracting-keywords/references/other-bindings.md +345 -0
- package/.opencode/skills/xberg-extracting-keywords/references/python-api.md +657 -0
- package/.opencode/skills/xberg-extracting-keywords/references/rust-api.md +412 -0
- package/.opencode/skills/xberg-extracting-keywords/references/supported-formats.md +252 -0
- package/.opencode/skills/xberg-extracting-tables/SKILL.md +155 -0
- package/.opencode/skills/xberg-extracting-tables/index.md +10 -0
- package/.opencode/skills/xberg-extracting-tables/references/advanced-features.md +628 -0
- package/.opencode/skills/xberg-extracting-tables/references/cli-reference.md +462 -0
- package/.opencode/skills/xberg-extracting-tables/references/configuration.md +587 -0
- package/.opencode/skills/xberg-extracting-tables/references/nodejs-api.md +485 -0
- package/.opencode/skills/xberg-extracting-tables/references/other-bindings.md +345 -0
- package/.opencode/skills/xberg-extracting-tables/references/python-api.md +657 -0
- package/.opencode/skills/xberg-extracting-tables/references/rust-api.md +412 -0
- package/.opencode/skills/xberg-extracting-tables/references/supported-formats.md +252 -0
- package/.opencode/skills/xberg-extracting-with-ocr/SKILL.md +129 -0
- package/.opencode/skills/xberg-extracting-with-ocr/index.md +10 -0
- package/.opencode/skills/xberg-extracting-with-ocr/references/advanced-features.md +628 -0
- package/.opencode/skills/xberg-extracting-with-ocr/references/cli-reference.md +462 -0
- package/.opencode/skills/xberg-extracting-with-ocr/references/configuration.md +587 -0
- package/.opencode/skills/xberg-extracting-with-ocr/references/nodejs-api.md +485 -0
- package/.opencode/skills/xberg-extracting-with-ocr/references/other-bindings.md +345 -0
- package/.opencode/skills/xberg-extracting-with-ocr/references/python-api.md +657 -0
- package/.opencode/skills/xberg-extracting-with-ocr/references/rust-api.md +412 -0
- package/.opencode/skills/xberg-extracting-with-ocr/references/supported-formats.md +252 -0
- package/.opencode/skills/xberg-picking-a-format/SKILL.md +104 -0
- package/.opencode/skills/xberg-picking-a-format/index.md +10 -0
- package/.opencode/skills/xberg-picking-a-format/references/advanced-features.md +628 -0
- package/.opencode/skills/xberg-picking-a-format/references/cli-reference.md +462 -0
- package/.opencode/skills/xberg-picking-a-format/references/configuration.md +587 -0
- package/.opencode/skills/xberg-picking-a-format/references/nodejs-api.md +485 -0
- package/.opencode/skills/xberg-picking-a-format/references/other-bindings.md +345 -0
- package/.opencode/skills/xberg-picking-a-format/references/python-api.md +657 -0
- package/.opencode/skills/xberg-picking-a-format/references/rust-api.md +412 -0
- package/.opencode/skills/xberg-picking-a-format/references/supported-formats.md +252 -0
- package/.pi/prompts/xberg-extract.md +14 -0
- package/.pi/prompts/xberg-ocr.md +14 -0
- package/.pi/skills/xberg/SKILL.md +422 -0
- package/.pi/skills/xberg/index.md +10 -0
- package/.pi/skills/xberg/references/advanced-features.md +628 -0
- package/.pi/skills/xberg/references/cli-reference.md +462 -0
- package/.pi/skills/xberg/references/configuration.md +587 -0
- package/.pi/skills/xberg/references/nodejs-api.md +485 -0
- package/.pi/skills/xberg/references/other-bindings.md +345 -0
- package/.pi/skills/xberg/references/python-api.md +657 -0
- package/.pi/skills/xberg/references/rust-api.md +412 -0
- package/.pi/skills/xberg/references/supported-formats.md +252 -0
- package/.pi/skills/xberg-batch-extraction/SKILL.md +170 -0
- package/.pi/skills/xberg-batch-extraction/index.md +10 -0
- package/.pi/skills/xberg-batch-extraction/references/advanced-features.md +628 -0
- package/.pi/skills/xberg-batch-extraction/references/cli-reference.md +462 -0
- package/.pi/skills/xberg-batch-extraction/references/configuration.md +587 -0
- package/.pi/skills/xberg-batch-extraction/references/nodejs-api.md +485 -0
- package/.pi/skills/xberg-batch-extraction/references/other-bindings.md +345 -0
- package/.pi/skills/xberg-batch-extraction/references/python-api.md +657 -0
- package/.pi/skills/xberg-batch-extraction/references/rust-api.md +412 -0
- package/.pi/skills/xberg-batch-extraction/references/supported-formats.md +252 -0
- package/.pi/skills/xberg-chunking/SKILL.md +163 -0
- package/.pi/skills/xberg-chunking/index.md +10 -0
- package/.pi/skills/xberg-chunking/references/advanced-features.md +628 -0
- package/.pi/skills/xberg-chunking/references/cli-reference.md +462 -0
- package/.pi/skills/xberg-chunking/references/configuration.md +587 -0
- package/.pi/skills/xberg-chunking/references/nodejs-api.md +485 -0
- package/.pi/skills/xberg-chunking/references/other-bindings.md +345 -0
- package/.pi/skills/xberg-chunking/references/python-api.md +657 -0
- package/.pi/skills/xberg-chunking/references/rust-api.md +412 -0
- package/.pi/skills/xberg-chunking/references/supported-formats.md +252 -0
- package/.pi/skills/xberg-extracting-keywords/SKILL.md +170 -0
- package/.pi/skills/xberg-extracting-keywords/index.md +10 -0
- package/.pi/skills/xberg-extracting-keywords/references/advanced-features.md +628 -0
- package/.pi/skills/xberg-extracting-keywords/references/cli-reference.md +462 -0
- package/.pi/skills/xberg-extracting-keywords/references/configuration.md +587 -0
- package/.pi/skills/xberg-extracting-keywords/references/nodejs-api.md +485 -0
- package/.pi/skills/xberg-extracting-keywords/references/other-bindings.md +345 -0
- package/.pi/skills/xberg-extracting-keywords/references/python-api.md +657 -0
- package/.pi/skills/xberg-extracting-keywords/references/rust-api.md +412 -0
- package/.pi/skills/xberg-extracting-keywords/references/supported-formats.md +252 -0
- package/.pi/skills/xberg-extracting-tables/SKILL.md +155 -0
- package/.pi/skills/xberg-extracting-tables/index.md +10 -0
- package/.pi/skills/xberg-extracting-tables/references/advanced-features.md +628 -0
- package/.pi/skills/xberg-extracting-tables/references/cli-reference.md +462 -0
- package/.pi/skills/xberg-extracting-tables/references/configuration.md +587 -0
- package/.pi/skills/xberg-extracting-tables/references/nodejs-api.md +485 -0
- package/.pi/skills/xberg-extracting-tables/references/other-bindings.md +345 -0
- package/.pi/skills/xberg-extracting-tables/references/python-api.md +657 -0
- package/.pi/skills/xberg-extracting-tables/references/rust-api.md +412 -0
- package/.pi/skills/xberg-extracting-tables/references/supported-formats.md +252 -0
- package/.pi/skills/xberg-extracting-with-ocr/SKILL.md +129 -0
- package/.pi/skills/xberg-extracting-with-ocr/index.md +10 -0
- package/.pi/skills/xberg-extracting-with-ocr/references/advanced-features.md +628 -0
- package/.pi/skills/xberg-extracting-with-ocr/references/cli-reference.md +462 -0
- package/.pi/skills/xberg-extracting-with-ocr/references/configuration.md +587 -0
- package/.pi/skills/xberg-extracting-with-ocr/references/nodejs-api.md +485 -0
- package/.pi/skills/xberg-extracting-with-ocr/references/other-bindings.md +345 -0
- package/.pi/skills/xberg-extracting-with-ocr/references/python-api.md +657 -0
- package/.pi/skills/xberg-extracting-with-ocr/references/rust-api.md +412 -0
- package/.pi/skills/xberg-extracting-with-ocr/references/supported-formats.md +252 -0
- package/.pi/skills/xberg-picking-a-format/SKILL.md +104 -0
- package/.pi/skills/xberg-picking-a-format/index.md +10 -0
- package/.pi/skills/xberg-picking-a-format/references/advanced-features.md +628 -0
- package/.pi/skills/xberg-picking-a-format/references/cli-reference.md +462 -0
- package/.pi/skills/xberg-picking-a-format/references/configuration.md +587 -0
- package/.pi/skills/xberg-picking-a-format/references/nodejs-api.md +485 -0
- package/.pi/skills/xberg-picking-a-format/references/other-bindings.md +345 -0
- package/.pi/skills/xberg-picking-a-format/references/python-api.md +657 -0
- package/.pi/skills/xberg-picking-a-format/references/rust-api.md +412 -0
- package/.pi/skills/xberg-picking-a-format/references/supported-formats.md +252 -0
- package/README.md +112 -6
- package/package.json +184 -16
- 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.
|