@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,422 @@
1
+ ---
2
+ description: Extract text, tables, metadata, and images from 107 document formats (PDF, Office, images, HTML, email, archives, academic) using Xberg. Use when writing code that calls Xberg APIs in Python, Node.js/TypeScript, Rust, or CLI. Covers installation, extraction (sync/async), configuration (OCR, chunking, output format), batch processing, error handling, and plugins.
3
+ license: Elastic-2.0
4
+ metadata:
5
+ author: xberg-io
6
+ version: "0.1.0"
7
+ repository: https://github.com/xberg-io/xberg
8
+ name: xberg
9
+ ---
10
+
11
+ <!--
12
+ AI-RULEZ :: GENERATED FILE — DO NOT EDIT
13
+ Content-Hash: blake3:5c39696cf46f9dabada4de547cf7b610394f57c4002ed5d2055fc83521fa3141
14
+ Source-Hash: blake3:662aa704cf97ad20f02258c9dcd1c73822213a426e27ec7ebc292d3f599fb7c2
15
+ Schema-Version: v1
16
+ -->
17
+
18
+ # Xberg Document Extraction
19
+
20
+ Xberg is a document intelligence library with a Rust core and bindings for Python, TypeScript/Node.js, Ruby, PHP, Go, Java, C#, Elixir, WebAssembly, Dart, Kotlin Android, Swift, Zig, and C. It extracts text, tables, metadata, and images from 107 formats across 140 unique file extensions and accepts 53 compatibility MIME aliases, including PDF, Office documents, images, HTML, email, archives, and academic formats.
21
+
22
+ Use this skill when writing code that:
23
+
24
+ - Extracts text or metadata from documents
25
+ - Performs OCR on scanned documents or images
26
+ - Batch-processes multiple files
27
+ - Configures extraction options (output format, chunking, OCR, language detection)
28
+ - Implements custom plugins (post-processors, validators, OCR backends)
29
+
30
+ > If the `xberg` MCP server is registered in this session, prefer its tools over shelling out to the CLI — they expose the same extraction surface with structured arguments and results.
31
+
32
+ ## Installation
33
+
34
+ ### Python
35
+
36
+ ```bash
37
+ pip install xberg
38
+ ```
39
+
40
+ ### Node.js
41
+
42
+ ```bash
43
+ npm install @xberg-io/xberg
44
+ ```
45
+
46
+ ### Rust
47
+
48
+ ```bash
49
+ cargo add xberg
50
+ ```
51
+
52
+ ```toml
53
+ # Cargo.toml
54
+ [dependencies]
55
+ xberg = { version = "1.1.0", features = ["full"] }
56
+ tokio = { version = "1", features = ["full"] }
57
+ # feature flags: pdf, ocr, chunking, embeddings, language-detection, keywords, api, mcp
58
+ # (or "formats" / "full" aggregates); tokio-runtime is on by default
59
+ ```
60
+
61
+ ### CLI
62
+
63
+ ```bash
64
+ brew install xberg-io/tap/xberg
65
+ # or run without a persistent install (the CLI proxy package self-installs the binary):
66
+ npx @xberg-io/xberg-cli@1.3.10 --help
67
+ uvx --from xberg-cli==1.3.8 xberg --help
68
+ # or download a prebuilt binary from the latest GitHub release:
69
+ # https://github.com/xberg-io/xberg/releases/latest
70
+ # or build from source:
71
+ cargo install xberg-cli
72
+ ```
73
+
74
+ ## Quick Start
75
+
76
+ The library entry points are `extract(input, config)` and `extract_batch(inputs, config)`. Both return an `ExtractionResult` **envelope** — the extracted document(s) live in `result.results`, and per-document data (`content`, `tables`, `metadata`, …) is on each `result.results[i]`. Python and Node are async-only.
77
+
78
+ ### Python
79
+
80
+ ```python
81
+ import asyncio
82
+ from xberg import ExtractInput, extract, ExtractionConfig
83
+
84
+ async def main() -> None:
85
+ result = await extract(ExtractInput(uri="document.pdf"), ExtractionConfig())
86
+ doc = result.results[0]
87
+ print(doc.content) # extracted text
88
+ print(doc.metadata) # document metadata
89
+ print(doc.tables) # extracted tables
90
+
91
+ asyncio.run(main())
92
+ ```
93
+
94
+ ### Node.js
95
+
96
+ ```typescript
97
+ import { extract } from "@xberg-io/xberg";
98
+
99
+ const output = await extract({ kind: "uri", uri: "document.pdf" });
100
+ const doc = output.results[0];
101
+ console.log(doc.content);
102
+ console.log(doc.metadata);
103
+ console.log(doc.tables);
104
+ ```
105
+
106
+ ### Rust
107
+
108
+ ```rust
109
+ use xberg::{extract, ExtractInput, ExtractionConfig};
110
+
111
+ #[tokio::main]
112
+ async fn main() -> xberg::Result<()> {
113
+ let output = extract(ExtractInput::from_uri("document.pdf"), &ExtractionConfig::default()).await?;
114
+ println!("{}", output.results[0].content);
115
+ Ok(())
116
+ }
117
+ ```
118
+
119
+ ### CLI
120
+
121
+ ```bash
122
+ xberg extract document.pdf
123
+ xberg extract document.pdf --format json
124
+ xberg extract document.pdf --content-format markdown
125
+ ```
126
+
127
+ ## Configuration
128
+
129
+ All languages use the same configuration structure with language-appropriate naming conventions.
130
+
131
+ ### Python (snake_case)
132
+
133
+ ```python
134
+ from xberg import (
135
+ ExtractInput, extract,
136
+ ExtractionConfig, OcrConfig, TesseractConfig, PdfConfig, ChunkingConfig, OutputFormat,
137
+ )
138
+
139
+ config = ExtractionConfig(
140
+ ocr=OcrConfig(
141
+ backend="tesseract",
142
+ language=["eng"],
143
+ tesseract_config=TesseractConfig(psm=6, enable_table_detection=True),
144
+ ),
145
+ pdf_options=PdfConfig(passwords=["secret123"]),
146
+ chunking=ChunkingConfig(max_characters=1000, overlap=200),
147
+ output_format=OutputFormat("markdown"),
148
+ )
149
+
150
+ result = await extract(ExtractInput(uri="document.pdf"), config)
151
+ ```
152
+
153
+ ### Node.js (camelCase)
154
+
155
+ ```typescript
156
+ import { extract, type ExtractionConfig } from "@xberg-io/xberg";
157
+
158
+ const config: ExtractionConfig = {
159
+ ocr: { backend: "tesseract", language: ["eng"] },
160
+ pdfOptions: { passwords: ["secret123"] },
161
+ chunking: { maxCharacters: 1000, overlap: 200 },
162
+ outputFormat: "markdown",
163
+ };
164
+
165
+ const output = await extract({ kind: "uri", uri: "document.pdf" }, config);
166
+ ```
167
+
168
+ ### Rust (snake_case)
169
+
170
+ ```rust
171
+ use xberg::{extract, ExtractInput, ExtractionConfig, OcrConfig, ChunkingConfig, OutputFormat};
172
+
173
+ let config = ExtractionConfig {
174
+ ocr: Some(OcrConfig {
175
+ backend: "tesseract".into(),
176
+ language: vec!["eng".to_string()],
177
+ ..Default::default()
178
+ }),
179
+ chunking: Some(ChunkingConfig {
180
+ max_characters: 1000,
181
+ overlap: 200,
182
+ ..Default::default()
183
+ }),
184
+ output_format: OutputFormat::Markdown,
185
+ ..Default::default()
186
+ };
187
+
188
+ let output = extract(ExtractInput::from_uri("document.pdf"), &config).await?;
189
+ ```
190
+
191
+ ### Config File (TOML)
192
+
193
+ ```toml
194
+ output_format = "markdown"
195
+
196
+ [ocr]
197
+ backend = "tesseract"
198
+ language = "eng"
199
+
200
+ [chunking]
201
+ max_characters = 1000
202
+ overlap = 200
203
+
204
+ [pdf_options]
205
+ passwords = ["secret123"]
206
+ ```
207
+
208
+ ```bash
209
+ # CLI: auto-discovers xberg.toml/yaml/yml/json in current/parent directories
210
+ xberg extract doc.pdf
211
+ # or explicit:
212
+ xberg extract doc.pdf --config xberg.toml
213
+ xberg extract doc.pdf --config-json '{"ocr":{"backend":"tesseract","language":"deu"}}'
214
+ ```
215
+
216
+ ## Batch Processing
217
+
218
+ `extract_batch` takes a list of `ExtractInput`s and returns one envelope whose `results` array holds documents in discovery order; one input may yield multiple documents. Per-input failures are reported in `result.errors` with an input index.
219
+
220
+ ### Python
221
+
222
+ ```python
223
+ from xberg import ExtractInput, extract_batch, ExtractionConfig
224
+
225
+ inputs = [
226
+ ExtractInput(uri="doc1.pdf"),
227
+ ExtractInput(uri="doc2.docx"),
228
+ ExtractInput(uri="doc3.xlsx"),
229
+ ]
230
+ output = await extract_batch(inputs, ExtractionConfig())
231
+
232
+ for doc in output.results:
233
+ print(f"{len(doc.content)} chars extracted")
234
+ ```
235
+
236
+ ### Node.js
237
+
238
+ ```typescript
239
+ import { extractBatch } from "@xberg-io/xberg";
240
+
241
+ const output = await extractBatch([
242
+ { kind: "uri", uri: "doc1.pdf" },
243
+ { kind: "uri", uri: "doc2.docx" },
244
+ ]);
245
+ for (const doc of output.results) {
246
+ console.log(`${doc.content.length} chars`);
247
+ }
248
+ ```
249
+
250
+ ### Rust
251
+
252
+ ```rust
253
+ use xberg::{extract_batch, ExtractInput, ExtractionConfig};
254
+
255
+ let config = ExtractionConfig::default();
256
+ let inputs = vec![ExtractInput::from_uri("doc1.pdf"), ExtractInput::from_uri("doc2.docx")];
257
+ let output = extract_batch(inputs, &config).await?;
258
+ ```
259
+
260
+ ### CLI
261
+
262
+ ```bash
263
+ xberg batch *.pdf --format json
264
+ xberg batch docs/*.docx --content-format markdown
265
+ ```
266
+
267
+ ## OCR
268
+
269
+ OCR runs automatically for images and scanned PDFs. Tesseract is the default backend (native binding, no external install required).
270
+
271
+ ### Backends
272
+
273
+ Select with `OcrConfig.backend`:
274
+
275
+ - **tesseract** (default): built-in native binding. All Tesseract languages supported.
276
+ - **paddleocr** (`"paddleocr"` / `"paddle-ocr"`): ONNX-based PaddleOCR.
277
+ - **vlm**: Vision-Language-Model OCR (configure via `OcrConfig.vlm_config`).
278
+
279
+ Custom backends can be registered in Python/Node via `register_ocr_backend` (see [Advanced Features](references/advanced-features.md)).
280
+
281
+ ### Language Codes
282
+
283
+ ```python
284
+ config = ExtractionConfig(ocr=OcrConfig(language=["eng"])) # English
285
+ config = ExtractionConfig(ocr=OcrConfig(language=["eng", "deu"])) # Multiple
286
+ # The single-string shorthand ("eng+deu") is only accepted in config files / --config-json,
287
+ # not in the OcrConfig constructor (Python takes a list, Node takes an array).
288
+ ```
289
+
290
+ ### Force OCR
291
+
292
+ ```python
293
+ config = ExtractionConfig(force_ocr=True) # OCR even if text is extractable
294
+ ```
295
+
296
+ ## Result Envelope and Document Fields
297
+
298
+ `extract` / `extract_batch` return an `ExtractionResult` envelope: `results` (list of documents), `errors` (per-input failures), and `summary` (counts). Per-document fields live on each document in `results` — bind `doc = result.results[0]` (Python/Node) or `&output.results[0]` (Rust) first.
299
+
300
+ | Field | Python (`doc.`) | Node.js (`doc.`) | Rust (`document.`) | Description |
301
+ | ------------ | ---------------------- | --------------------- | ----------------------- | --------------------------------------------- |
302
+ | Text content | `content` | `content` | `content` | Extracted text (str/String) |
303
+ | MIME type | `mime_type` | `mimeType` | `mime_type` | Input document MIME type |
304
+ | Metadata | `metadata` | `metadata` | `metadata` | Document metadata (flat mapping) |
305
+ | Tables | `tables` | `tables` | `tables` | Extracted tables with cells + markdown |
306
+ | Languages | `detected_languages` | `detectedLanguages` | `detected_languages` | Detected languages (if enabled) |
307
+ | Chunks | `chunks` | `chunks` | `chunks` | Text chunks (if chunking enabled) |
308
+ | Images | `images` | `images` | `images` | Extracted images (if enabled) |
309
+ | Elements | `elements` | `elements` | `elements` | Semantic elements (if element_based format) |
310
+ | Pages | `pages` | `pages` | `pages` | Per-page content (if page extraction enabled) |
311
+ | Keywords | `extracted_keywords` | `extractedKeywords` | `extracted_keywords` | Extracted keywords (if enabled) |
312
+
313
+ ## Error Handling
314
+
315
+ ### Python
316
+
317
+ `extract` / `extract_batch` raise a plain `RuntimeError` on failure — the typed `XbergError` subclasses are not raised by these entry points, so catch `RuntimeError`. Per-input failures during `extract_batch` are reported non-fatally in `result.errors`.
318
+
319
+ ```python
320
+ from xberg import ExtractInput, extract, ExtractionConfig
321
+
322
+ try:
323
+ result = await extract(ExtractInput(uri="file.pdf"), ExtractionConfig())
324
+ for err in result.errors:
325
+ print(f"Per-input error: {err}")
326
+ except RuntimeError as e:
327
+ print(f"Extraction failed: {e}")
328
+ ```
329
+
330
+ ### Node.js
331
+
332
+ The Node binding throws plain `Error` objects (it does not export typed error subclasses). Catch with `instanceof Error`, and inspect `output.errors` for non-fatal per-input failures.
333
+
334
+ ```typescript
335
+ import { extract } from "@xberg-io/xberg";
336
+
337
+ try {
338
+ const output = await extract({ kind: "uri", uri: "file.pdf" });
339
+ if (output.errors.length > 0) {
340
+ console.error("Per-input errors:", output.errors);
341
+ }
342
+ } catch (e) {
343
+ if (e instanceof Error) {
344
+ console.error(`Extraction failed: ${e.message}`);
345
+ }
346
+ }
347
+ ```
348
+
349
+ ### Rust
350
+
351
+ ```rust
352
+ use xberg::{extract, ExtractInput, ExtractionConfig, XbergError};
353
+
354
+ let config = ExtractionConfig::default();
355
+ match extract(ExtractInput::from_uri("file.pdf"), &config).await {
356
+ Ok(output) => println!("{}", output.results[0].content),
357
+ Err(XbergError::Parsing { message, .. }) => eprintln!("Parse error: {message}"),
358
+ Err(XbergError::Ocr { message, .. }) => eprintln!("OCR error: {message}"),
359
+ Err(XbergError::UnsupportedFormat(mime)) => eprintln!("Unsupported: {mime}"),
360
+ Err(e) => eprintln!("Error: {e}"),
361
+ }
362
+ ```
363
+
364
+ ## Common Pitfalls
365
+
366
+ 1. **Result is an envelope**: `extract` / `extract_batch` return `ExtractionResult` with `results`, `errors`, and `summary`. Per-document fields (`content`, `tables`, `chunks`, …) are on `result.results[i]`, NOT on the top-level return.
367
+ 2. **Async-only**: Python and Node have no sync variants — always `await extract(...)`. Rust `extract` is async; use `#[tokio::main]` or an async context.
368
+ 3. **Build the input**: pass an `ExtractInput`, not a bare path. Use `ExtractInput(uri=...)` / `ExtractInput::from_uri(...)` (Python/Rust) or `{ kind: "uri", uri: "..." }` (Node); for bytes use `kind="bytes"` with `bytes`/`mime_type`.
369
+ 4. **Python ChunkingConfig fields**: construct with `max_characters` and `overlap` (defaults 1000 / 200); these are also the readable attributes. When passing config as a dict/JSON, the `max_chars` / `max_overlap` aliases are also accepted. Node uses `maxCharacters` / `overlap`; Rust struct fields are `max_characters` / `overlap`.
370
+ 5. **Python errors**: `extract` / `extract_batch` raise a plain `RuntimeError` on failure, not typed `XbergError` subclasses — catch `RuntimeError`. Node throws plain `Error` (no typed error subclasses).
371
+ 6. **Rust extract signature**: `extract(input, &config)` — the config is a reference. Use `&ExtractionConfig::default()` for defaults.
372
+ 7. **CLI --format vs --content-format**: `--format` controls CLI output (`text`, `json`, or `toon`). `--content-format` controls content rendering (`plain`, `markdown`, `djot`, `html`, `json`, or `doctags`).
373
+ 8. **Config file field names**: Use snake_case in TOML/YAML/JSON config files — `[chunking]` fields are `max_characters` and `overlap`; other fields use names like `output_format`, `pdf_options`.
374
+
375
+ ## Supported Formats (Summary)
376
+
377
+ | Category | Extensions |
378
+ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
379
+ | **PDF** | `.pdf` |
380
+ | **Word** | `.docx`, `.docm`, `.doc`, `.dotx`, `.dotm`, `.dot`, `.odt`, `.pages`, `.wpd`, `.wp`, `.wp5`, `.wp6`, `.hwp`, `.hwpx` |
381
+ | **Spreadsheets** | `.xlsx`, `.xlsm`, `.xlsb`, `.xls`, `.xla`, `.xlam`, `.xltm`, `.xltx`, `.xlt`, `.ods`, `.numbers` |
382
+ | **Presentations** | `.pptx`, `.pptm`, `.ppt`, `.pps`, `.ppsx`, `.potx`, `.potm`, `.pot`, `.odp`, `.key` |
383
+ | **eBooks** | `.epub`, `.fb2` |
384
+ | **Images** | `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.bmp`, `.tiff`, `.tif`, `.jp2`, `.jpg2`, `.j2c`, `.j2k`, `.jpc`, `.jbig2`, `.jb2`, `.pnm`, `.pbm`, `.pgm`, `.ppm`, `.heic`, `.heics`, `.heif`, `.heifs`, `.hif`, `.avif`, `.avcs`, `.svg` |
385
+ | **Markup** | `.html`, `.htm`, `.xhtml`, `.xht`, `.xml`, `.kml` |
386
+ | **Data** | `.json`, `.geojson`, `.jsonl`, `.ndjson`, `.yaml`, `.yml`, `.toml`, `.csv`, `.tsv`, `.dbf`, `.sqlite`, `.sqlite3`, `.db`, `.gpkg`, `.gpkx` |
387
+ | **Text** | `.txt`, `.adoc`, `.asciidoc`, `.vtt`, `.md`, `.markdown`, `.commonmark`, `.qmd`, `.rmd`, `.mdx`, `.djot`, `.dj`, `.doctags`, `.rst`, `.org`, `.rtf` |
388
+ | **Email** | `.eml`, `.msg`, `.pst` |
389
+ | **Archives** | `.zip`, `.tar`, `.tgz`, `.gz`, `.7z` |
390
+ | **Audio/Video** | `.mp3`, `.mpga`, `.m4a`, `.wav`, `.webm`, `.mp4`, `.mpg4`, `.mp4v`, `.m4v`, `.mpeg`, `.mpg`, `.mpe`, `.m1v`, `.m2v` |
391
+ | **Academic** | `.bib`, `.ris`, `.nbib`, `.enw`, `.tex`, `.latex`, `.typ`, `.typst`, `.jats`, `.nxml`, `.ipynb`, `.docbook`, `.dbk`, `.docbook4`, `.docbook5`, `.opml` |
392
+
393
+ CSL JSON is supported through an explicit MIME type but does not have a registered file extension.
394
+
395
+ See [references/supported-formats.md](references/supported-formats.md) for the complete format reference with MIME types.
396
+
397
+ ## Additional Resources
398
+
399
+ Detailed reference files for specific topics:
400
+
401
+ - **[Python API Reference](references/python-api.md)** — All functions, config classes, plugin protocols, exact signatures
402
+ - **[Node.js API Reference](references/nodejs-api.md)** — All functions, TypeScript interfaces, worker pool APIs
403
+ - **[Rust API Reference](references/rust-api.md)** — All functions with feature gates, structs, Cargo.toml examples
404
+ - **[CLI Reference](references/cli-reference.md)** — All commands, flags, config precedence, exit codes
405
+ - **[Configuration Reference](references/configuration.md)** — TOML/YAML/JSON formats, auto-discovery, env vars, full schema
406
+ - **[Supported Formats](references/supported-formats.md)** — Format families, extensions, capabilities, and authoritative discovery commands
407
+ - **[Advanced Features](references/advanced-features.md)** — Plugins, embeddings, MCP server, API server, security limits
408
+ - **[Other Language Bindings](references/other-bindings.md)** — Go, Ruby, Java, C#, PHP, Elixir, WASM, Dart, Kotlin Android, Swift, Zig, C, and Docker
409
+
410
+ ## Related skills
411
+
412
+ Task-focused sibling skills go deeper than this overview:
413
+
414
+ - **xberg-extracting-with-ocr** — OCR backends, language packs, force-OCR, tuning.
415
+ - **xberg-extracting-tables** — layout-aware table detection and table models.
416
+ - **xberg-chunking** — chunk size/overlap, markdown/yaml/semantic chunkers, the `chunk` command.
417
+ - **xberg-extracting-keywords** — YAKE/RAKE keywords, language detection, the `embed` command.
418
+ - **xberg-batch-extraction** — the `batch` command, `--file-configs`, parallelism, error recovery.
419
+ - **xberg-picking-a-format** — choosing `--format` / `--content-format` per consumer.
420
+
421
+ Full documentation: <https://docs.xberg.io>
422
+ GitHub: <https://github.com/xberg-io/xberg>
@@ -0,0 +1,10 @@
1
+ <!--
2
+ AI-RULEZ :: GENERATED FILE — DO NOT EDIT
3
+ Content-Hash: blake3:995528a20ef3610c2da46cc63052bc232907509eca3477ba3e2decb42fba0146
4
+ Source-Hash: blake3:662aa704cf97ad20f02258c9dcd1c73822213a426e27ec7ebc292d3f599fb7c2
5
+ Schema-Version: v1
6
+ -->
7
+
8
+ # Concepts
9
+
10
+ * [Xberg](SKILL.md) - Extract text, tables, metadata, and images from 107 document formats (PDF, Office, images, HTML, email, archives, academic) using Xberg. Use when writing code that calls Xberg APIs in Python, Node.js/TypeScript, Rust, or CLI. Covers installation, extraction (sync/async), configuration (OCR, chunking, output format), batch processing, error handling, and plugins.