@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
package/README.md CHANGED
@@ -17,6 +17,30 @@ Self-host:
17
17
  /plugin install xberg@xberg
18
18
  ```
19
19
 
20
+ ### Pi
21
+
22
+ From a checkout of this repository, run:
23
+
24
+ ```bash
25
+ pi install ./plugin
26
+ ```
27
+
28
+ Once a plugin release includes Pi support, use the shared OpenCode/Pi npm package:
29
+
30
+ ```bash
31
+ pi install npm:@xberg-io/opencode-xberg
32
+ ```
33
+
34
+ Pi discovers skills from `.pi/skills` and prompt templates from `.pi/prompts`.
35
+ Use `/xberg-extract` and `/xberg-ocr` to start a task.
36
+ Install the CLI separately using the instructions below. The Pi package does not
37
+ register MCP servers, hooks, or executable extensions. The MCP integration
38
+ sections below apply to clients with MCP support.
39
+
40
+ Git installs use the repository root's `package.json` resource paths. GitHub
41
+ hosts the checkout resources; the existing npm plugin release publishes the same
42
+ Pi content alongside the OpenCode adapter. No separate Pi release job is needed.
43
+
20
44
  ### Binary requirement
21
45
 
22
46
  Install the `xberg` CLI:
@@ -118,6 +142,22 @@ xberg extract data.xlsx --format json
118
142
 
119
143
  The plugin version tracks the xberg core release (`Cargo.toml`). See [CHANGELOG.md](../CHANGELOG.md) for release notes.
120
144
 
145
+ ## Maintaining the plugin
146
+
147
+ Edit `plugin/.ai-rulez` sources, then run these commands from the repository root
148
+ with a Pi-capable ai-rulez v5 binary installed:
149
+
150
+ ```bash
151
+ task plugin:generate
152
+ task plugin:verify
153
+ task plugin:test
154
+ ```
155
+
156
+ CI builds the generator from a pinned source revision and verifies the generated
157
+ bundles, OpenCode tools, and actual npm archive before publication. The shared
158
+ npm package publishes both OpenCode and Pi resources; Hermes uses its existing
159
+ PyPI release job. GitHub hosts the remaining plugin bundles and marketplace indexes.
160
+
121
161
  ## License
122
162
 
123
163
  MIT. The skill content uses Elastic-2.0 references to the upstream [xberg](https://github.com/xberg-io/xberg) repository.
package/package.json CHANGED
@@ -1,31 +1,84 @@
1
1
  {
2
- "name": "@xberg-io/opencode-xberg",
3
- "version": "1.3.7",
2
+ "dependencies": {
3
+ "@opencode/plugin": "^2.0.20"
4
+ },
4
5
  "description": "Local document extraction: text, tables, metadata, images from 107 formats with optional OCR.",
6
+ "exports": {
7
+ ".": "./.opencode/plugins/xberg.js"
8
+ },
9
+ "files": [
10
+ ".opencode/ai-rulez-bundle.json",
11
+ ".opencode/ai-rulez-content.js",
12
+ ".opencode/commands/xberg-extract.md",
13
+ ".opencode/commands/xberg-ocr.md",
14
+ ".opencode/plugins/xberg.js",
15
+ ".opencode/skills/batch-extraction/SKILL.md",
16
+ ".opencode/skills/chunking/SKILL.md",
17
+ ".opencode/skills/extracting-keywords/SKILL.md",
18
+ ".opencode/skills/extracting-tables/SKILL.md",
19
+ ".opencode/skills/extracting-with-ocr/SKILL.md",
20
+ ".opencode/skills/picking-a-format/SKILL.md",
21
+ ".opencode/skills/xberg/SKILL.md",
22
+ ".opencode/skills/xberg/references/advanced-features.md",
23
+ ".opencode/skills/xberg/references/cli-reference.md",
24
+ ".opencode/skills/xberg/references/configuration.md",
25
+ ".opencode/skills/xberg/references/nodejs-api.md",
26
+ ".opencode/skills/xberg/references/other-bindings.md",
27
+ ".opencode/skills/xberg/references/python-api.md",
28
+ ".opencode/skills/xberg/references/rust-api.md",
29
+ ".opencode/skills/xberg/references/supported-formats.md",
30
+ ".pi/prompts/xberg-extract.md",
31
+ ".pi/prompts/xberg-ocr.md",
32
+ ".pi/skills/batch-extraction/SKILL.md",
33
+ ".pi/skills/chunking/SKILL.md",
34
+ ".pi/skills/extracting-keywords/SKILL.md",
35
+ ".pi/skills/extracting-tables/SKILL.md",
36
+ ".pi/skills/extracting-with-ocr/SKILL.md",
37
+ ".pi/skills/picking-a-format/SKILL.md",
38
+ ".pi/skills/xberg/SKILL.md",
39
+ ".pi/skills/xberg/references/advanced-features.md",
40
+ ".pi/skills/xberg/references/cli-reference.md",
41
+ ".pi/skills/xberg/references/configuration.md",
42
+ ".pi/skills/xberg/references/nodejs-api.md",
43
+ ".pi/skills/xberg/references/other-bindings.md",
44
+ ".pi/skills/xberg/references/python-api.md",
45
+ ".pi/skills/xberg/references/rust-api.md",
46
+ ".pi/skills/xberg/references/supported-formats.md",
47
+ "README.md",
48
+ "assets/",
49
+ "scripts/"
50
+ ],
51
+ "homepage": "https://xberg.io",
5
52
  "keywords": [
6
53
  "document-intelligence",
7
54
  "extraction",
8
55
  "ocr",
9
56
  "pdf",
57
+ "pi-package",
10
58
  "tables"
11
59
  ],
12
- "homepage": "https://xberg.io",
60
+ "license": "MIT",
61
+ "main": ".opencode/plugins/xberg.js",
62
+ "name": "@xberg-io/opencode-xberg",
63
+ "pi": {
64
+ "prompts": [
65
+ "./.pi/prompts/xberg-extract.md",
66
+ "./.pi/prompts/xberg-ocr.md"
67
+ ],
68
+ "skills": [
69
+ "./.pi/skills/batch-extraction",
70
+ "./.pi/skills/chunking",
71
+ "./.pi/skills/extracting-keywords",
72
+ "./.pi/skills/extracting-tables",
73
+ "./.pi/skills/extracting-with-ocr",
74
+ "./.pi/skills/picking-a-format",
75
+ "./.pi/skills/xberg"
76
+ ]
77
+ },
13
78
  "repository": {
14
79
  "type": "git",
15
80
  "url": "https://github.com/xberg-io/xberg"
16
81
  },
17
- "license": "MIT",
18
82
  "type": "module",
19
- "main": ".opencode/plugins/xberg.js",
20
- "exports": {
21
- ".": "./.opencode/plugins/xberg.js"
22
- },
23
- "files": [
24
- ".opencode/",
25
- "assets/",
26
- "README.md"
27
- ],
28
- "dependencies": {
29
- "@opencode-ai/plugin": "^1.17.8"
30
- }
83
+ "version": "1.3.8"
31
84
  }
@@ -0,0 +1,188 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ NPM_PKG="@xberg-io/xberg-cli"
5
+ PYPI_PKG="xberg-cli"
6
+
7
+ log() { printf 'xberg-launch: %s\n' "$*" >&2; }
8
+ die() {
9
+ log "error: $*"
10
+ exit 1
11
+ }
12
+
13
+ LAUNCHER="${XBERG_LAUNCHER:-auto}"
14
+ case "$LAUNCHER" in
15
+ auto | npx | uvx | brew | download) ;;
16
+ *) die "invalid XBERG_LAUNCHER='$LAUNCHER' (expected auto|npx|uvx|brew|download)" ;;
17
+ esac
18
+
19
+ want() { [ "$LAUNCHER" = "auto" ] || [ "$LAUNCHER" = "$1" ]; }
20
+
21
+ PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-}"
22
+ if [ -z "$PLUGIN_ROOT" ]; then
23
+ PLUGIN_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
24
+ fi
25
+
26
+ BINARY_NAME="xberg"
27
+ case "$(uname -s)" in
28
+ MINGW* | MSYS* | CYGWIN* | Windows_NT) BINARY_NAME="xberg.exe" ;;
29
+ esac
30
+ BIN_DIR="$PLUGIN_ROOT/bin"
31
+ BIN="$BIN_DIR/$BINARY_NAME"
32
+
33
+ have() { command -v "$1" >/dev/null 2>&1; }
34
+
35
+ runnable() { [ -x "$1" ] && "$1" --version >/dev/null 2>&1; }
36
+
37
+ if runnable "$BIN"; then
38
+ log "using cached xberg at $BIN"
39
+ exec "$BIN" "$@"
40
+ fi
41
+ if have "$BINARY_NAME"; then
42
+ PATH_BIN="$(command -v "$BINARY_NAME")"
43
+ if runnable "$PATH_BIN"; then
44
+ log "using xberg on PATH ($PATH_BIN)"
45
+ exec "$PATH_BIN" "$@"
46
+ fi
47
+ fi
48
+
49
+ if want npx && have npx; then
50
+ log "probing npx $NPM_PKG@latest ..."
51
+ scratch="$(mktemp -d)"
52
+ if (cd "$scratch" && npx -y "$NPM_PKG@latest" --version >/dev/null 2>&1); then
53
+ log "launching via npx $NPM_PKG@latest"
54
+ cd "$scratch"
55
+ exec npx -y "$NPM_PKG@latest" "$@"
56
+ fi
57
+ rm -rf "$scratch"
58
+ log "npx $NPM_PKG not available (no CLI bin yet); falling through"
59
+ fi
60
+
61
+ if want uvx && have uvx; then
62
+ log "probing uvx --from $PYPI_PKG $BINARY_NAME ..."
63
+ if uvx --from "$PYPI_PKG" "$BINARY_NAME" --version >/dev/null 2>&1; then
64
+ log "launching via uvx --from $PYPI_PKG $BINARY_NAME"
65
+ exec uvx --from "$PYPI_PKG" "$BINARY_NAME" "$@"
66
+ fi
67
+ log "uvx $PYPI_PKG not available (no CLI entry point yet); falling through"
68
+ fi
69
+
70
+ if want brew && have brew; then
71
+ log "installing via 'brew install xberg-io/tap/xberg' ..."
72
+ if brew install xberg-io/tap/xberg >&2; then
73
+ if have "$BINARY_NAME"; then
74
+ BREW_BIN="$(command -v "$BINARY_NAME")"
75
+ runnable "$BREW_BIN" && exec "$BREW_BIN" "$@"
76
+ fi
77
+ log "brew install reported success but xberg is not on PATH; falling through"
78
+ else
79
+ log "brew install failed; falling through"
80
+ fi
81
+ fi
82
+
83
+ try_download() {
84
+ local arch triple ext base_url asset asset_url tmp ex src_dir
85
+ arch="$(uname -m)"
86
+ case "$(uname -s)" in
87
+ Darwin)
88
+ case "$arch" in
89
+ arm64 | aarch64) triple="aarch64-apple-darwin" ;;
90
+ x86_64 | amd64) triple="x86_64-apple-darwin" ;;
91
+ *)
92
+ log "no prebuilt macOS archive for $arch; falling through"
93
+ return 1
94
+ ;;
95
+ esac
96
+ ;;
97
+ Linux)
98
+ case "$arch" in
99
+ aarch64 | arm64) triple="aarch64-unknown-linux-gnu" ;;
100
+ x86_64) triple="x86_64-unknown-linux-gnu" ;;
101
+ *)
102
+ log "no prebuilt Linux archive for $arch; falling through"
103
+ return 1
104
+ ;;
105
+ esac
106
+ ;;
107
+ MINGW* | MSYS* | CYGWIN* | Windows_NT) triple="x86_64-pc-windows-msvc" ;;
108
+ *)
109
+ log "no prebuilt archive for $(uname -s)/$arch; falling through"
110
+ return 1
111
+ ;;
112
+ esac
113
+ case "$triple" in
114
+ *windows*) ext="zip" ;;
115
+ *) ext="tar.gz" ;;
116
+ esac
117
+
118
+ base_url="https://github.com/xberg-io/xberg/releases/latest/download"
119
+ asset="xberg-cli-${triple}.${ext}"
120
+ asset_url="${base_url}/${asset}"
121
+
122
+ if have curl; then
123
+ fetch() { curl -fsSL --retry 3 -o "$2" "$1"; }
124
+ elif have wget; then
125
+ fetch() { wget -q -O "$2" "$1"; }
126
+ else
127
+ log "no curl or wget available for download; falling through"
128
+ return 1
129
+ fi
130
+
131
+ tmp="$(mktemp -d)"
132
+ # shellcheck disable=SC2064 # expand $tmp now so the trap removes this exact dir
133
+ trap "rm -rf '$tmp'" RETURN
134
+
135
+ log "downloading $asset from latest release ..."
136
+ if ! fetch "$asset_url" "$tmp/$asset"; then
137
+ log "download failed or asset not found: $asset_url; falling through"
138
+ return 1
139
+ fi
140
+
141
+ log "warning: no published checksum for $asset; integrity is verified by HTTPS/TLS only, not a content hash"
142
+
143
+ ex="$tmp/extracted"
144
+ mkdir -p "$ex"
145
+ case "$ext" in
146
+ tar.gz) tar -xzf "$tmp/$asset" -C "$ex" || {
147
+ log "extraction failed; falling through"
148
+ return 1
149
+ } ;;
150
+ zip)
151
+ if have unzip; then
152
+ unzip -qo "$tmp/$asset" -d "$ex" || {
153
+ log "extraction failed; falling through"
154
+ return 1
155
+ }
156
+ else
157
+ log "need unzip to extract $asset; falling through"
158
+ return 1
159
+ fi
160
+ ;;
161
+ esac
162
+
163
+ src_dir="$ex/xberg-cli-${triple}"
164
+ [ -d "$src_dir" ] || src_dir="$ex"
165
+ if [ ! -f "$src_dir/$BINARY_NAME" ]; then
166
+ log "binary $BINARY_NAME not found inside $asset; falling through"
167
+ return 1
168
+ fi
169
+
170
+ rm -rf "$BIN_DIR"
171
+ mkdir -p "$BIN_DIR"
172
+ mv "$src_dir"/* "$BIN_DIR"/
173
+ chmod +x "$BIN"
174
+ log "installed xberg to $BIN"
175
+ return 0
176
+ }
177
+
178
+ if want download; then
179
+ if try_download; then
180
+ exec "$BIN" "$@"
181
+ fi
182
+ fi
183
+
184
+ die "could not locate or install xberg. Install it manually with one of:
185
+ brew install xberg-io/tap/xberg
186
+ cargo install xberg-cli
187
+ or download a prebuilt archive from https://github.com/xberg-io/xberg/releases/latest
188
+ then ensure 'xberg' is on PATH and retry."