@xberg-io/opencode-xberg 0.2.3 → 1.0.3
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 +52 -44
- package/README.md +5 -5
- package/package.json +3 -3
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
// AI-RULEZ :: GENERATED FILE — DO NOT EDIT
|
|
2
|
-
// Content-Hash: blake3:
|
|
3
|
-
// Source-Hash: blake3:
|
|
2
|
+
// Content-Hash: blake3:a176d5615df7d9fc0f850b5d83d3355f87d3045645f185d67c0d1e5edfb4a6c6
|
|
3
|
+
// Source-Hash: blake3:4f30c10e77f8c5ff8ed30b9e154ad9bcf00fb22405417016845401f0db77e0e4
|
|
4
4
|
// Schema-Version: v1
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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(["text", "json", "toon"])
|
|
11
|
+
const wireFormat = schema.enum([ "text", "json", "toon" ])
|
|
12
|
+
.default("json")
|
|
13
|
+
.describe("CLI output format.");
|
|
12
14
|
|
|
13
|
-
const contentFormat =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const contentFormat =
|
|
16
|
+
schema.enum([ "plain", "markdown", "djot", "html", "json" ])
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("Document content rendering format.");
|
|
17
19
|
|
|
18
20
|
function hasValue(value) {
|
|
19
21
|
return value !== undefined && value !== null && value !== "";
|
|
@@ -42,10 +44,10 @@ function runCli(args, context) {
|
|
|
42
44
|
|
|
43
45
|
return new Promise((resolve, reject) => {
|
|
44
46
|
const child = spawn("xberg", args, {
|
|
45
|
-
cwd: directory,
|
|
46
|
-
env: process.env,
|
|
47
|
-
signal: context?.abort,
|
|
48
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
47
|
+
cwd : directory,
|
|
48
|
+
env : process.env,
|
|
49
|
+
signal : context?.abort,
|
|
50
|
+
stdio : [ "ignore", "pipe", "pipe" ],
|
|
49
51
|
});
|
|
50
52
|
|
|
51
53
|
const stdout = [];
|
|
@@ -56,10 +58,10 @@ function runCli(args, context) {
|
|
|
56
58
|
child.on("error", (error) => {
|
|
57
59
|
if (error.code === "ENOENT") {
|
|
58
60
|
resolve({
|
|
59
|
-
title: "xberg CLI not found",
|
|
60
|
-
output:
|
|
61
|
-
|
|
62
|
-
metadata: {
|
|
61
|
+
title : "xberg CLI not found",
|
|
62
|
+
output :
|
|
63
|
+
"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`.",
|
|
64
|
+
metadata : {exitCode : 127, command : "xberg", subcommand : args[0]},
|
|
63
65
|
});
|
|
64
66
|
return;
|
|
65
67
|
}
|
|
@@ -68,16 +70,18 @@ function runCli(args, context) {
|
|
|
68
70
|
child.on("close", (exitCode, signal) => {
|
|
69
71
|
const stdoutText = Buffer.concat(stdout).toString("utf8").trim();
|
|
70
72
|
const stderrText = Buffer.concat(stderr).toString("utf8").trim();
|
|
71
|
-
const output = [
|
|
73
|
+
const output = [
|
|
74
|
+
stdoutText, stderrText && `stderr:\n${stderrText}`
|
|
75
|
+
].filter(Boolean).join("\n\n");
|
|
72
76
|
|
|
73
77
|
resolve({
|
|
74
|
-
title: exitCode === 0 ? `xberg ${args[0]}` : `xberg ${args[0]} failed`,
|
|
75
|
-
output: output || "(no output)",
|
|
76
|
-
metadata: {
|
|
78
|
+
title : exitCode === 0 ? `xberg ${args[0]}` : `xberg ${args[0]} failed`,
|
|
79
|
+
output : output || "(no output)",
|
|
80
|
+
metadata : {
|
|
77
81
|
exitCode,
|
|
78
82
|
signal,
|
|
79
|
-
command: "xberg",
|
|
80
|
-
subcommand: args[0],
|
|
83
|
+
command : "xberg",
|
|
84
|
+
subcommand : args[0],
|
|
81
85
|
},
|
|
82
86
|
});
|
|
83
87
|
});
|
|
@@ -85,20 +89,23 @@ function runCli(args, context) {
|
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
export const XbergPlugin = async () => ({
|
|
88
|
-
tool: {
|
|
89
|
-
xberg_extract: tool({
|
|
90
|
-
description:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
tool : {
|
|
93
|
+
xberg_extract : tool({
|
|
94
|
+
description :
|
|
95
|
+
"Extract text, tables, metadata, and images from a local document with the xberg CLI.",
|
|
96
|
+
args : {
|
|
97
|
+
path : schema.string().min(1).describe("Path to the local document."),
|
|
98
|
+
format : wireFormat,
|
|
99
|
+
content_format : contentFormat,
|
|
100
|
+
mime_type : schema.string().min(1).optional().describe(
|
|
101
|
+
"Optional MIME type hint."),
|
|
102
|
+
config_json : schema.string().min(2).optional().describe(
|
|
103
|
+
"Optional ExtractionConfig JSON."),
|
|
97
104
|
},
|
|
98
105
|
async execute(args, context) {
|
|
99
106
|
validateJson(args.config_json, "config_json");
|
|
100
107
|
|
|
101
|
-
const cliArgs = ["extract", args.path, "--format", args.format];
|
|
108
|
+
const cliArgs = [ "extract", args.path, "--format", args.format ];
|
|
102
109
|
pushOption(cliArgs, "--content-format", args.content_format);
|
|
103
110
|
pushOption(cliArgs, "--mime-type", args.mime_type);
|
|
104
111
|
pushOption(cliArgs, "--config-json", args.config_json);
|
|
@@ -106,23 +113,24 @@ export const XbergPlugin = async () => ({
|
|
|
106
113
|
return runCli(cliArgs, context);
|
|
107
114
|
},
|
|
108
115
|
}),
|
|
109
|
-
xberg_detect: tool({
|
|
110
|
-
description: "Detect the MIME type for a local file with the xberg CLI.",
|
|
111
|
-
args: {
|
|
112
|
-
path: schema.string().min(1).describe("Path to the local file."),
|
|
113
|
-
format: wireFormat,
|
|
116
|
+
xberg_detect : tool({
|
|
117
|
+
description : "Detect the MIME type for a local file with the xberg CLI.",
|
|
118
|
+
args : {
|
|
119
|
+
path : schema.string().min(1).describe("Path to the local file."),
|
|
120
|
+
format : wireFormat,
|
|
114
121
|
},
|
|
115
122
|
async execute(args, context) {
|
|
116
|
-
return runCli(["detect", args.path, "--format", args.format],
|
|
123
|
+
return runCli([ "detect", args.path, "--format", args.format ],
|
|
124
|
+
context);
|
|
117
125
|
},
|
|
118
126
|
}),
|
|
119
|
-
xberg_formats: tool({
|
|
120
|
-
description: "List document formats supported by the xberg CLI.",
|
|
121
|
-
args: {
|
|
122
|
-
format: wireFormat,
|
|
127
|
+
xberg_formats : tool({
|
|
128
|
+
description : "List document formats supported by the xberg CLI.",
|
|
129
|
+
args : {
|
|
130
|
+
format : wireFormat,
|
|
123
131
|
},
|
|
124
132
|
async execute(args, context) {
|
|
125
|
-
return runCli(["formats", "--format", args.format], context);
|
|
133
|
+
return runCli([ "formats", "--format", args.format ], context);
|
|
126
134
|
},
|
|
127
135
|
}),
|
|
128
136
|
},
|
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 98+ 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
|
|
|
@@ -13,7 +13,7 @@ Pending review for official Claude marketplace.
|
|
|
13
13
|
Self-host:
|
|
14
14
|
|
|
15
15
|
```text
|
|
16
|
-
/plugin marketplace add xberg-io/
|
|
16
|
+
/plugin marketplace add xberg-io/xberg
|
|
17
17
|
/plugin install xberg@xberg
|
|
18
18
|
```
|
|
19
19
|
|
|
@@ -116,7 +116,7 @@ xberg extract data.xlsx --format json
|
|
|
116
116
|
|
|
117
117
|
## Versioning
|
|
118
118
|
|
|
119
|
-
The plugin version tracks the
|
|
119
|
+
The plugin version tracks the xberg core release (`Cargo.toml`). See [CHANGELOG.md](../CHANGELOG.md) for release notes.
|
|
120
120
|
|
|
121
121
|
## License
|
|
122
122
|
|
|
@@ -124,6 +124,6 @@ MIT. The skill content uses Elastic-2.0 references to the upstream [xberg](https
|
|
|
124
124
|
|
|
125
125
|
## See also
|
|
126
126
|
|
|
127
|
-
- **Marketplace**:
|
|
127
|
+
- **Marketplace**: this repo — `/plugin marketplace add xberg-io/xberg`
|
|
128
128
|
- **Upstream**: [xberg-io/xberg](https://github.com/xberg-io/xberg)
|
|
129
|
-
- **
|
|
129
|
+
- **Related plugins**: [crawlberg](https://github.com/xberg-io/crawlberg)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xberg-io/opencode-xberg",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Local document extraction: text, tables, metadata, images from
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Local document extraction: text, tables, metadata, images from 98+ formats with optional OCR.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-intelligence",
|
|
7
7
|
"extraction",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"homepage": "https://xberg.io",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/xberg-io/
|
|
15
|
+
"url": "https://github.com/xberg-io/xberg"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"type": "module",
|