@xberg-io/opencode-xberg 1.3.8 → 1.4.0

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