@xberg-io/opencode-xberg 1.0.14 → 1.1.1
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/plugins/xberg.js +68 -75
- package/README.md +3 -3
- package/package.json +2 -2
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
// AI-RULEZ :: GENERATED FILE — DO NOT EDIT
|
|
2
|
-
// Content-Hash: blake3:
|
|
3
|
-
// Source-Hash: blake3:
|
|
2
|
+
// Content-Hash: blake3:0c4b20b2428ca03b76e22085bdcc856fbac85091cd3f6d157655d6c25c02714f
|
|
3
|
+
// Source-Hash: blake3:745562ff11c7f58507a71dedd56c8d6eab478fe2122112e395cad42ab1f17172
|
|
4
4
|
// Schema-Version: v1
|
|
5
5
|
|
|
6
|
-
import {tool} from "@opencode-ai/plugin";
|
|
7
|
-
import {spawn} from "node:child_process";
|
|
6
|
+
import { tool } from "@opencode-ai/plugin";
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
8
|
|
|
9
9
|
const schema = tool.schema;
|
|
10
10
|
|
|
11
|
-
const wireFormat = schema.enum([
|
|
12
|
-
.default("json")
|
|
13
|
-
.describe("CLI output format.");
|
|
11
|
+
const wireFormat = schema.enum(["text", "json", "toon"]).default("json").describe("CLI output format.");
|
|
14
12
|
|
|
15
|
-
const contentFormat =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const contentFormat = schema
|
|
14
|
+
.enum(["plain", "markdown", "djot", "html", "json"])
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("Document content rendering format.");
|
|
19
17
|
|
|
20
18
|
function hasValue(value) {
|
|
21
19
|
return value !== undefined && value !== null && value !== "";
|
|
@@ -35,7 +33,7 @@ function validateJson(value, name) {
|
|
|
35
33
|
try {
|
|
36
34
|
JSON.parse(value);
|
|
37
35
|
} catch (error) {
|
|
38
|
-
throw new Error(`${name} must be valid JSON: ${error.message}
|
|
36
|
+
throw new Error(`${name} must be valid JSON: ${error.message}`, { cause: error });
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
|
|
@@ -44,10 +42,10 @@ function runCli(args, context) {
|
|
|
44
42
|
|
|
45
43
|
return new Promise((resolve, reject) => {
|
|
46
44
|
const child = spawn("xberg", args, {
|
|
47
|
-
cwd
|
|
48
|
-
env
|
|
49
|
-
signal
|
|
50
|
-
stdio
|
|
45
|
+
cwd: directory,
|
|
46
|
+
env: process.env,
|
|
47
|
+
signal: context?.abort,
|
|
48
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
51
49
|
});
|
|
52
50
|
|
|
53
51
|
const stdout = [];
|
|
@@ -58,10 +56,10 @@ function runCli(args, context) {
|
|
|
58
56
|
child.on("error", (error) => {
|
|
59
57
|
if (error.code === "ENOENT") {
|
|
60
58
|
resolve({
|
|
61
|
-
title
|
|
62
|
-
output
|
|
63
|
-
|
|
64
|
-
metadata
|
|
59
|
+
title: "xberg CLI not found",
|
|
60
|
+
output:
|
|
61
|
+
"Install the xberg CLI with `brew install xberg-io/tap/xberg`, or run it via `npx -y @xberg-io/xberg-cli` / `uvx --from xberg-cli xberg`.",
|
|
62
|
+
metadata: { exitCode: 127, command: "xberg", subcommand: args[0] },
|
|
65
63
|
});
|
|
66
64
|
return;
|
|
67
65
|
}
|
|
@@ -70,70 +68,65 @@ function runCli(args, context) {
|
|
|
70
68
|
child.on("close", (exitCode, signal) => {
|
|
71
69
|
const stdoutText = Buffer.concat(stdout).toString("utf8").trim();
|
|
72
70
|
const stderrText = Buffer.concat(stderr).toString("utf8").trim();
|
|
73
|
-
const output = [
|
|
74
|
-
stdoutText, stderrText && `stderr:\n${stderrText}`
|
|
75
|
-
].filter(Boolean).join("\n\n");
|
|
71
|
+
const output = [stdoutText, stderrText && `stderr:\n${stderrText}`].filter(Boolean).join("\n\n");
|
|
76
72
|
|
|
77
73
|
resolve({
|
|
78
|
-
title
|
|
79
|
-
output
|
|
80
|
-
metadata
|
|
74
|
+
title: exitCode === 0 ? `xberg ${args[0]}` : `xberg ${args[0]} failed`,
|
|
75
|
+
output: output || "(no output)",
|
|
76
|
+
metadata: {
|
|
81
77
|
exitCode,
|
|
82
78
|
signal,
|
|
83
|
-
command
|
|
84
|
-
subcommand
|
|
79
|
+
command: "xberg",
|
|
80
|
+
subcommand: args[0],
|
|
85
81
|
},
|
|
86
82
|
});
|
|
87
83
|
});
|
|
88
84
|
});
|
|
89
85
|
}
|
|
90
86
|
|
|
91
|
-
export const XbergPlugin =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}),
|
|
136
|
-
},
|
|
137
|
-
});
|
|
87
|
+
export const XbergPlugin = () =>
|
|
88
|
+
Promise.resolve({
|
|
89
|
+
tool: {
|
|
90
|
+
xberg_extract: tool({
|
|
91
|
+
description: "Extract text, tables, metadata, and images from a local document with the xberg CLI.",
|
|
92
|
+
args: {
|
|
93
|
+
path: schema.string().min(1).describe("Path to the local document."),
|
|
94
|
+
format: wireFormat,
|
|
95
|
+
content_format: contentFormat,
|
|
96
|
+
mime_type: schema.string().min(1).optional().describe("Optional MIME type hint."),
|
|
97
|
+
config_json: schema.string().min(2).optional().describe("Optional ExtractionConfig JSON."),
|
|
98
|
+
},
|
|
99
|
+
async execute(args, context) {
|
|
100
|
+
validateJson(args.config_json, "config_json");
|
|
101
|
+
|
|
102
|
+
const cliArgs = ["extract", args.path, "--format", args.format];
|
|
103
|
+
pushOption(cliArgs, "--content-format", args.content_format);
|
|
104
|
+
pushOption(cliArgs, "--mime-type", args.mime_type);
|
|
105
|
+
pushOption(cliArgs, "--config-json", args.config_json);
|
|
106
|
+
|
|
107
|
+
return await runCli(cliArgs, context);
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
xberg_detect: tool({
|
|
111
|
+
description: "Detect the MIME type for a local file with the xberg CLI.",
|
|
112
|
+
args: {
|
|
113
|
+
path: schema.string().min(1).describe("Path to the local file."),
|
|
114
|
+
format: wireFormat,
|
|
115
|
+
},
|
|
116
|
+
async execute(args, context) {
|
|
117
|
+
return await runCli(["detect", args.path, "--format", args.format], context);
|
|
118
|
+
},
|
|
119
|
+
}),
|
|
120
|
+
xberg_formats: tool({
|
|
121
|
+
description: "List document formats supported by the xberg CLI.",
|
|
122
|
+
args: {
|
|
123
|
+
format: wireFormat,
|
|
124
|
+
},
|
|
125
|
+
async execute(args, context) {
|
|
126
|
+
return await runCli(["formats", "--format", args.format], context);
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
},
|
|
130
|
+
});
|
|
138
131
|
|
|
139
132
|
export default XbergPlugin;
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# xberg
|
|
2
2
|
|
|
3
|
-
Extract text, tables, metadata, and images from
|
|
3
|
+
Extract text, tables, metadata, and images from 107 document formats — PDF, Office, images with OCR, HTML, email, archives, academic — using the local `xberg` CLI in your agent.
|
|
4
4
|
|
|
5
5
|
<!-- ~keep TODO: add screenshot -->
|
|
6
6
|
|
|
@@ -51,7 +51,7 @@ sudo apt install tesseract-ocr-* # Debian/Ubuntu
|
|
|
51
51
|
|
|
52
52
|
| Skill | Trigger |
|
|
53
53
|
|-------|---------|
|
|
54
|
-
| **xberg** | Extract text, tables, metadata, and images from
|
|
54
|
+
| **xberg** | 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. |
|
|
55
55
|
| **extracting-with-ocr** | Use when extracting text from scanned PDFs, photographed pages, or images that have no embedded text layer. Covers OCR backends, language packs, force-OCR, and performance tuning. |
|
|
56
56
|
| **extracting-tables** | Use when extracting tabular data from PDFs, spreadsheets, or images. Covers layout-aware table detection, table model selection, output formats (markdown / JSON cells), and known limits. |
|
|
57
57
|
| **chunking** | 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. |
|
|
@@ -65,7 +65,7 @@ sudo apt install tesseract-ocr-* # Debian/Ubuntu
|
|
|
65
65
|
|-----------|---------|
|
|
66
66
|
| **CLI Reference** | All commands, flags, config precedence, exit codes |
|
|
67
67
|
| **Configuration Reference** | TOML/YAML/JSON formats, auto-discovery, env vars, full schema |
|
|
68
|
-
| **Supported Formats** |
|
|
68
|
+
| **Supported Formats** | Format families, extensions, capabilities, and authoritative discovery commands |
|
|
69
69
|
| **Python API Reference** | All functions, config classes, plugin protocols, exact signatures |
|
|
70
70
|
| **Node.js API Reference** | All functions, TypeScript interfaces, worker pool APIs |
|
|
71
71
|
| **Rust API Reference** | All functions with feature gates, structs, Cargo.toml examples |
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xberg-io/opencode-xberg",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Local document extraction: text, tables, metadata, images from
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Local document extraction: text, tables, metadata, images from 107 formats with optional OCR.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-intelligence",
|
|
7
7
|
"extraction",
|