@xberg-io/opencode-xberg 1.3.7 → 1.3.8

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 (40) hide show
  1. package/.opencode/ai-rulez-bundle.json +51 -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/batch-extraction/SKILL.md +168 -0
  7. package/.opencode/skills/chunking/SKILL.md +163 -0
  8. package/.opencode/skills/extracting-keywords/SKILL.md +171 -0
  9. package/.opencode/skills/extracting-tables/SKILL.md +156 -0
  10. package/.opencode/skills/extracting-with-ocr/SKILL.md +130 -0
  11. package/.opencode/skills/picking-a-format/SKILL.md +104 -0
  12. package/.opencode/skills/xberg/SKILL.md +427 -0
  13. package/.opencode/skills/xberg/references/advanced-features.md +628 -0
  14. package/.opencode/skills/xberg/references/cli-reference.md +462 -0
  15. package/.opencode/skills/xberg/references/configuration.md +587 -0
  16. package/.opencode/skills/xberg/references/nodejs-api.md +485 -0
  17. package/.opencode/skills/xberg/references/other-bindings.md +345 -0
  18. package/.opencode/skills/xberg/references/python-api.md +657 -0
  19. package/.opencode/skills/xberg/references/rust-api.md +412 -0
  20. package/.opencode/skills/xberg/references/supported-formats.md +252 -0
  21. package/.pi/prompts/xberg-extract.md +14 -0
  22. package/.pi/prompts/xberg-ocr.md +14 -0
  23. package/.pi/skills/batch-extraction/SKILL.md +168 -0
  24. package/.pi/skills/chunking/SKILL.md +163 -0
  25. package/.pi/skills/extracting-keywords/SKILL.md +171 -0
  26. package/.pi/skills/extracting-tables/SKILL.md +156 -0
  27. package/.pi/skills/extracting-with-ocr/SKILL.md +130 -0
  28. package/.pi/skills/picking-a-format/SKILL.md +104 -0
  29. package/.pi/skills/xberg/SKILL.md +427 -0
  30. package/.pi/skills/xberg/references/advanced-features.md +628 -0
  31. package/.pi/skills/xberg/references/cli-reference.md +462 -0
  32. package/.pi/skills/xberg/references/configuration.md +587 -0
  33. package/.pi/skills/xberg/references/nodejs-api.md +485 -0
  34. package/.pi/skills/xberg/references/other-bindings.md +345 -0
  35. package/.pi/skills/xberg/references/python-api.md +657 -0
  36. package/.pi/skills/xberg/references/rust-api.md +412 -0
  37. package/.pi/skills/xberg/references/supported-formats.md +252 -0
  38. package/README.md +40 -0
  39. package/package.json +69 -16
  40. package/scripts/mcp-launch.sh +188 -0
@@ -0,0 +1,462 @@
1
+ <!--
2
+ AI-RULEZ :: GENERATED FILE — DO NOT EDIT
3
+ Content-Hash: blake3:cd55a9d089a4fe188a64803a05bf46b418949673c0b952c381eefdd2416457f5
4
+ Source-Hash: blake3:3fca38eb564d0ed9c9194d070fd8dec96de727edc92e82954cb4b9af52cddbaf
5
+ Schema-Version: v1
6
+ -->
7
+
8
+ # Xberg CLI Reference
9
+
10
+ Comprehensive command-line interface for the Xberg document intelligence library.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ brew install xberg-io/tap/xberg
16
+ # or run without a persistent install (self-installs the binary):
17
+ npx @xberg-io/xberg-cli --help
18
+ uvx --from xberg-cli xberg --help
19
+ ```
20
+
21
+ Or download a pre-built binary from the [latest GitHub Release](https://github.com/xberg-io/xberg/releases/latest), or build from source:
22
+
23
+ ```bash
24
+ cargo install xberg-cli
25
+ ```
26
+
27
+ ## Commands
28
+
29
+ ### extract
30
+
31
+ Extract text and structure from a single document.
32
+
33
+ ```bash
34
+ xberg extract <path> [FLAGS]
35
+ ```
36
+
37
+ ## Positional Arguments
38
+
39
+ - `<path>` — Path to the document file
40
+
41
+ ## Flags
42
+
43
+ - `-c, --config <path>` — Path to config file (TOML, YAML, or JSON). Auto-discovers `xberg.{toml,yaml,json}` in current and parent directories if omitted.
44
+ - `--config-json <json>` — Inline JSON configuration (merged after config file, before CLI flags).
45
+ - `--config-json-base64 <base64>` — Base64-encoded JSON configuration.
46
+ - `-m, --mime-type <type>` — MIME type hint (auto-detected if not provided).
47
+ - `-f, --format <text|json|toon>` — CLI output format (default: `text`). Controls how results display, not extraction content format.
48
+ - `--content-format <plain|markdown|djot|html|json>` — Extraction content format (default: `plain`). Controls format of extracted content. (Note: `--output-format` is a hidden deprecated alias.)
49
+ - `--ocr <bool>` — Enable OCR processing.
50
+ - `--ocr-backend <BACKEND>` — OCR backend: `tesseract`, `paddle-ocr`, `vlm`, `candle-trocr`, `candle-paddleocr-vl`, `candle-glm-ocr`, `candle-deepseek-ocr`.
51
+ - `--ocr-language <LANG>` — OCR language code.
52
+ - `--ocr-auto-rotate <bool>` — Auto-rotate images before OCR.
53
+ - `--force-ocr <bool>` — Force OCR even if text extraction succeeds.
54
+ - `--disable-ocr <bool>` — Disable OCR entirely (even for images).
55
+ - `--no-cache <bool>` — Disable caching.
56
+ - `--chunk <bool>` — Enable text chunking.
57
+ - `--chunk-size <n>` — Chunk size in characters.
58
+ - `--chunk-overlap <n>` — Chunk overlap in characters.
59
+ - `--chunking-tokenizer <model>` — Tokenizer model for token-based sizing.
60
+ - `--include-structure <bool>` — Include hierarchical document structure.
61
+ - `--quality <bool>` — Enable quality processing.
62
+ - `--detect-language <bool>` — Enable language detection.
63
+ - `--layout` — Enable layout detection (RT-DETR v2). Use `--layout false` to disable.
64
+ - `--layout-confidence <float>` — Layout confidence threshold (0.0-1.0).
65
+ - `--layout-table-model <model>` — Table structure model: `tatr`, `slanet_wired`, `slanet_wireless`, `slanet_plus`, `slanet_auto`, `disabled`.
66
+ - `--acceleration <provider>` — ONNX execution provider: `auto`, `cpu`, `coreml`, `cuda`, `tensorrt`.
67
+ - `--extract-pages <bool>` — Extract pages as separate array.
68
+ - `--page-markers <bool>` — Insert page marker comments.
69
+ - `--extract-images <bool>` — Enable image extraction.
70
+ - `--target-dpi <n>` — Target DPI for images (36-2400).
71
+ - `--pdf-password <pass>` — Password for encrypted PDFs (repeatable).
72
+ - `--pdf-extract-images <bool>` — Extract images from PDF pages.
73
+ - `--pdf-extract-metadata <bool>` — Extract PDF metadata.
74
+ - `--token-reduction <level>` — Token reduction: `off`, `light`, `moderate`, `aggressive`, `maximum`.
75
+ - `--msg-codepage <n>` — Windows codepage fallback for MSG files.
76
+ - `--max-concurrent <n>` — Max parallel extractions in batch mode.
77
+ - `--max-threads <n>` — Cap all internal thread pools.
78
+ - `--max-concurrent-ocr <n>` — Set concurrent Tesseract recognition sessions, not capped by `--max-threads`.
79
+ - `--cache-namespace <name>` — Cache namespace for tenant isolation.
80
+ - `--cache-ttl-secs <n>` — Per-request cache TTL in seconds.
81
+
82
+ ## Examples
83
+
84
+ ```bash
85
+ # Extract with default settings
86
+ xberg extract document.pdf
87
+
88
+ # Extract with OCR enabled
89
+ xberg extract scanned.pdf --ocr=true
90
+
91
+ # Extract with specific content format
92
+ xberg extract doc.docx --content-format markdown
93
+
94
+ # Extract with inline JSON config
95
+ xberg extract file.pdf --config-json '{"ocr":{"backend":"tesseract"}}'
96
+
97
+ # Extract with base64-encoded config
98
+ xberg extract file.pdf --config-json-base64 eyJvY3IiOnsiYmFja2VuZCI6InRlc3NlcmFjdCJ9fQ==
99
+
100
+ # Extract and output as JSON
101
+ xberg extract doc.pdf --format json
102
+
103
+ # Extract with chunking
104
+ xberg extract large-doc.pdf --chunk true --chunk-size 2000 --chunk-overlap 200
105
+
106
+ # Layout-aware markdown extraction
107
+ xberg extract document.pdf --layout --content-format markdown
108
+
109
+ # With custom confidence threshold
110
+ xberg extract document.pdf --layout-confidence 0.7 --content-format markdown
111
+ ```
112
+
113
+ ### batch
114
+
115
+ Batch extract from multiple documents in parallel.
116
+
117
+ ```bash
118
+ xberg batch <paths...> [FLAGS]
119
+ ```
120
+
121
+ ## Positional Arguments
122
+
123
+ - `<paths...>` — One or more document file paths
124
+
125
+ ## Flags
126
+
127
+ - `-c, --config <path>` — Path to config file (TOML, YAML, or JSON). Auto-discovers `xberg.{toml,yaml,json}` in current and parent directories if omitted.
128
+ - `--config-json <json>` — Inline JSON configuration (merged after config file, before CLI flags).
129
+ - `--config-json-base64 <base64>` — Base64-encoded JSON configuration.
130
+ - `-f, --format <text|json|toon>` — CLI output format (default: `json`). Controls how results display, not extraction content format.
131
+ - All extraction override flags from `extract` are also supported (e.g., `--content-format`, `--ocr`, `--layout`, `--force-ocr`, `--no-cache`, `--quality`, `--acceleration`, etc.). See the `extract` command flags for the full list.
132
+
133
+ ## Notes
134
+
135
+ - Batch command defaults to JSON output format (unlike `extract` which defaults to text).
136
+ - Does not support the `--mime-type` flag (it is specific to the `extract` command).
137
+
138
+ ## Examples
139
+
140
+ ```bash
141
+ # Batch extract multiple PDFs
142
+ xberg batch document1.pdf document2.pdf document3.pdf
143
+
144
+ # Batch extract with glob patterns (shell expansion)
145
+ xberg batch *.pdf
146
+
147
+ # Batch extract with custom output format
148
+ xberg batch doc1.pdf doc2.pdf --content-format markdown
149
+
150
+ # Batch extract with OCR
151
+ xberg batch scanned*.pdf --ocr=true
152
+
153
+ # Batch extract with text output format
154
+ xberg batch files*.docx --format text
155
+ ```
156
+
157
+ ### detect
158
+
159
+ Identify MIME type of a file.
160
+
161
+ ```bash
162
+ xberg detect <path> [FLAGS]
163
+ ```
164
+
165
+ ## Positional Arguments
166
+
167
+ - `<path>` — Path to the file
168
+
169
+ ## Flags
170
+
171
+ - `-f, --format <text|json|toon>` — Output format (default: `text`)
172
+
173
+ ## Examples
174
+
175
+ ```bash
176
+ # Detect MIME type (text output)
177
+ xberg detect unknown-file.bin
178
+
179
+ # Detect MIME type (JSON output)
180
+ xberg detect file.xyz --format json
181
+ ```
182
+
183
+ ### version
184
+
185
+ Display version information.
186
+
187
+ ```bash
188
+ xberg version [FLAGS]
189
+ ```
190
+
191
+ ## Flags
192
+
193
+ - `-f, --format <text|json|toon>` — Output format (default: `text`)
194
+
195
+ ## Examples
196
+
197
+ ```bash
198
+ # Show version as text
199
+ xberg version
200
+
201
+ # Show version as JSON
202
+ xberg version --format json
203
+ ```
204
+
205
+ ### cache
206
+
207
+ Manage extraction cache.
208
+
209
+ #### cache stats
210
+
211
+ Display cache statistics.
212
+
213
+ ```bash
214
+ xberg cache stats [FLAGS]
215
+ ```
216
+
217
+ ## Flags
218
+
219
+ - `--cache-dir <path>` — Cache directory (default: `.xberg` in current directory)
220
+ - `-f, --format <text|json|toon>` — Output format (default: `text`)
221
+
222
+ ## Examples
223
+
224
+ ```bash
225
+ # Show cache stats
226
+ xberg cache stats
227
+
228
+ # Show cache stats as JSON
229
+ xberg cache stats --format json
230
+
231
+ # Show stats for specific cache directory
232
+ xberg cache stats --cache-dir /tmp/my-cache
233
+ ```
234
+
235
+ ### cache clear
236
+
237
+ Clear all cached extractions.
238
+
239
+ ```bash
240
+ xberg cache clear [FLAGS]
241
+ ```
242
+
243
+ ## Flags
244
+
245
+ - `--cache-dir <path>` — Cache directory (default: `.xberg` in current directory)
246
+ - `-f, --format <text|json|toon>` — Output format (default: `text`)
247
+
248
+ ## Examples
249
+
250
+ ```bash
251
+ # Clear cache
252
+ xberg cache clear
253
+
254
+ # Clear specific cache directory
255
+ xberg cache clear --cache-dir /tmp/my-cache
256
+ ```
257
+
258
+ ### serve
259
+
260
+ Start the API server (requires `api` feature).
261
+
262
+ ```bash
263
+ xberg serve [FLAGS]
264
+ ```
265
+
266
+ ## Flags
267
+
268
+ - `-H, --host <host>` — Host to bind to (e.g., `127.0.0.1` or `0.0.0.0`). CLI arg overrides config file and environment variables.
269
+ - `-p, --port <port>` — Port to bind to. CLI arg overrides config file and environment variables.
270
+ - `-c, --config <path>` — Path to config file (TOML, YAML, or JSON). Auto-discovers `xberg.{toml,yaml,json}` in current and parent directories if omitted.
271
+
272
+ ## Configuration Precedence
273
+
274
+ 1. CLI arguments (`--host`, `--port`)
275
+ 2. Environment variables (`XBERG_HOST`, `XBERG_PORT`)
276
+ 3. Config file (`[server]` section)
277
+ 4. Built-in defaults (`127.0.0.1:8000`)
278
+
279
+ ## Examples
280
+
281
+ ```bash
282
+ # Start server with defaults
283
+ xberg serve
284
+
285
+ # Start server on specific host and port
286
+ xberg serve --host 0.0.0.0 --port 3000
287
+
288
+ # Start server with config file
289
+ xberg serve --config xberg.toml
290
+
291
+ # Start server (environment variables override defaults)
292
+ XBERG_HOST=192.168.1.100 XBERG_PORT=8080 xberg serve
293
+ ```
294
+
295
+ ### mcp
296
+
297
+ Start the Model Context Protocol (MCP) server (requires `mcp` feature).
298
+
299
+ ```bash
300
+ xberg mcp [FLAGS]
301
+ ```
302
+
303
+ ## Flags
304
+
305
+ - `-c, --config <path>` — Path to config file (TOML, YAML, or JSON). Auto-discovers `xberg.{toml,yaml,json}` in current and parent directories if omitted.
306
+ - `--transport <stdio|http>` — Transport mode (default: `stdio`)
307
+ - `--host <host>` — HTTP host for http transport (default: `127.0.0.1`)
308
+ - `--port <port>` — HTTP port for http transport (default: `8001`)
309
+
310
+ ## Examples
311
+
312
+ ```bash
313
+ # Start MCP server with stdio transport
314
+ xberg mcp
315
+
316
+ # Start MCP server with HTTP transport
317
+ xberg mcp --transport http
318
+
319
+ # Start MCP server on custom HTTP host/port
320
+ xberg mcp --transport http --host 0.0.0.0 --port 9000
321
+
322
+ # Start MCP server with config file
323
+ xberg mcp --config xberg.toml
324
+ ```
325
+
326
+ ## Configuration
327
+
328
+ ### File Format
329
+
330
+ Configuration files support three formats with automatic detection:
331
+
332
+ - **TOML** — `.toml` extension (recommended)
333
+ - **YAML** — `.yaml` or `.yml` extension
334
+ - **JSON** — `.json` extension
335
+
336
+ ### Configuration Precedence
337
+
338
+ Settings are applied in order from highest to lowest priority:
339
+
340
+ 1. **Individual CLI flags** (e.g., `--ocr=true`, `--content-format markdown`)
341
+ 2. **Inline JSON config** (`--config-json` or `--config-json-base64`)
342
+ 3. **Config file** (explicit `--config path.toml` or auto-discovered)
343
+ 4. **Default values** (built-in library defaults)
344
+
345
+ ### Auto-Discovery
346
+
347
+ When no config file is specified, Xberg searches for configuration in this order:
348
+
349
+ 1. `xberg.toml` in current directory
350
+ 2. `xberg.yaml` in current directory
351
+ 3. `xberg.json` in current directory
352
+ 4. Parent directories (same search pattern, up to filesystem root)
353
+
354
+ ### Example Configuration
355
+
356
+ ```toml
357
+ # Top-level extraction options
358
+ use_cache = true
359
+ enable_quality_processing = true
360
+ force_ocr = false
361
+ output_format = "markdown"
362
+
363
+ # OCR settings
364
+ [ocr]
365
+ backend = "tesseract"
366
+ language = "eng"
367
+
368
+ # Chunking settings
369
+ [chunking]
370
+ max_characters = 2000
371
+ overlap = 200
372
+
373
+ # Language detection
374
+ [language_detection]
375
+ enabled = true
376
+
377
+ # Server configuration (for serve command)
378
+ [server]
379
+ host = "127.0.0.1"
380
+ port = 8000
381
+ ```
382
+
383
+ ## Exit Codes
384
+
385
+ - `0` — Success
386
+ - Non-zero — Error (see stderr for details)
387
+
388
+ ## Error Handling
389
+
390
+ The CLI validates input and provides clear error messages:
391
+
392
+ - **File not found** — Verify path exists and is readable
393
+ - **Invalid MIME type** — Ensure file is accessible and format is supported
394
+ - **Invalid JSON** — Check `--config-json` syntax
395
+ - **Invalid config file** — Verify TOML/YAML/JSON format
396
+ - **Invalid chunk parameters** — Ensure chunk-size > 0 and overlap < chunk-size
397
+
398
+ ## Environment Variables
399
+
400
+ - `RUST_LOG` — Set logging level (e.g., `RUST_LOG=debug`)
401
+ - `XBERG_HOST` — Server bind host (used by `serve` command)
402
+ - `XBERG_PORT` — Server bind port (used by `serve` command)
403
+
404
+ ## Common Patterns
405
+
406
+ ### Extract with Custom Configuration
407
+
408
+ ```bash
409
+ xberg extract document.pdf \
410
+ --content-format markdown \
411
+ --ocr=true \
412
+ --quality true
413
+ ```
414
+
415
+ ### Batch Process with Config File
416
+
417
+ ```bash
418
+ xberg batch *.pdf --config extraction-config.toml
419
+ ```
420
+
421
+ ### CI/CD Integration
422
+
423
+ ```bash
424
+ # Extract to JSON for downstream processing
425
+ xberg extract file.pdf --format json | jq '.content'
426
+
427
+ # Batch process with error handling
428
+ xberg batch docs/*.pdf --format json || exit 1
429
+ ```
430
+
431
+ ### Performance Tuning
432
+
433
+ ```bash
434
+ # Disable cache for temporary processing
435
+ xberg extract file.pdf --no-cache=true
436
+
437
+ # Enable chunking for large documents
438
+ xberg extract large-file.pdf \
439
+ --chunk true \
440
+ --chunk-size 5000 \
441
+ --chunk-overlap 500
442
+ ```
443
+
444
+ ## Debugging
445
+
446
+ Enable detailed logging:
447
+
448
+ ```bash
449
+ RUST_LOG=debug xberg extract document.pdf
450
+ ```
451
+
452
+ Check cache statistics:
453
+
454
+ ```bash
455
+ xberg cache stats --format json
456
+ ```
457
+
458
+ Detect file MIME type:
459
+
460
+ ```bash
461
+ xberg detect unknown-file --format json
462
+ ```