@eduardo191labs/opencode-free-pi 0.0.0-stage → 0.2.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.
package/install.ps1 ADDED
@@ -0,0 +1,74 @@
1
+ $ErrorActionPreference = "Stop"
2
+ $PluginName = "opencode-free-pi"
3
+ $Uninstall = ($args -contains "-Uninstall") -or ($args -contains "--uninstall")
4
+ $Repo = if ($env:FREEPI_OPENCODE_REPO) { $env:FREEPI_OPENCODE_REPO } else { "eduardo191-star/opencode-free-pi" }
5
+ $Ref = if ($env:FREEPI_OPENCODE_REF) { $env:FREEPI_OPENCODE_REF } else { "main" }
6
+
7
+ function Get-ConfigDir {
8
+ if ($env:OPENCODE_CONFIG_DIR) { return $env:OPENCODE_CONFIG_DIR }
9
+ if ($env:XDG_CONFIG_HOME) { return (Join-Path $env:XDG_CONFIG_HOME "opencode") }
10
+ return (Join-Path $HOME ".config\opencode")
11
+ }
12
+
13
+ function Write-Step([string]$Message) {
14
+ Write-Host $Message
15
+ }
16
+
17
+ if ($Uninstall) {
18
+ $pluginDir = Join-Path (Get-ConfigDir) "plugins"
19
+ Remove-Item -Force -ErrorAction SilentlyContinue (Join-Path $pluginDir "$PluginName.ts")
20
+ Remove-Item -Force -ErrorAction SilentlyContinue (Join-Path $pluginDir "$PluginName.js")
21
+ Write-Step "Removed $PluginName from $pluginDir"
22
+ Write-Step "Restart OpenCode to finish."
23
+ return
24
+ }
25
+
26
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
27
+
28
+ $configDir = Get-ConfigDir
29
+ $pluginDir = Join-Path $configDir "plugins"
30
+ $target = Join-Path $pluginDir "$PluginName.ts"
31
+ $rawBase = if ($env:FREEPI_OPENCODE_RAW_BASE) { $env:FREEPI_OPENCODE_RAW_BASE } else { "https://raw.githubusercontent.com/$Repo/$Ref" }
32
+ $temp = Join-Path ([System.IO.Path]::GetTempPath()) ("$PluginName-" + [guid]::NewGuid().ToString("N") + ".js")
33
+
34
+ try {
35
+ $localBuild = $null
36
+ if ($PSScriptRoot) {
37
+ $candidate = Join-Path $PSScriptRoot "dist\index.js"
38
+ if (Test-Path -LiteralPath $candidate) { $localBuild = $candidate }
39
+ }
40
+
41
+ if ($localBuild) {
42
+ Copy-Item -LiteralPath $localBuild -Destination $temp -Force
43
+ Write-Step "Using local build: $localBuild"
44
+ } else {
45
+ $url = "$rawBase/dist/index.js"
46
+ Write-Step "Downloading $url"
47
+ Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $temp
48
+ }
49
+
50
+ if (-not (Test-Path -LiteralPath $temp) -or (Get-Item -LiteralPath $temp).Length -eq 0) {
51
+ throw "downloaded plugin is empty"
52
+ }
53
+ if (-not (Select-String -LiteralPath $temp -Pattern "FreePiPlugin" -Quiet)) {
54
+ throw "downloaded file does not look like the free-pi plugin"
55
+ }
56
+
57
+ New-Item -ItemType Directory -Force -Path $pluginDir | Out-Null
58
+ if (Test-Path -LiteralPath $target) {
59
+ Copy-Item -LiteralPath $target -Destination "$target.bak" -Force
60
+ }
61
+ Copy-Item -LiteralPath $temp -Destination $target -Force
62
+ Remove-Item -Force -ErrorAction SilentlyContinue (Join-Path $pluginDir "$PluginName.js")
63
+
64
+ Write-Step "Installed $PluginName at $target"
65
+ Write-Step ""
66
+ Write-Step "Next steps:"
67
+ Write-Step " 1. Run: opencode auth login -p free-pi"
68
+ Write-Step " 2. Restart OpenCode."
69
+ Write-Step ""
70
+ $credentials = if ($env:FREEPI_CREDENTIALS_PATH) { $env:FREEPI_CREDENTIALS_PATH } else { "%USERPROFILE%\.free-pi\agent\credentials.json" }
71
+ Write-Step "Credentials: $credentials"
72
+ } finally {
73
+ Remove-Item -Force -ErrorAction SilentlyContinue $temp
74
+ }
package/install.sh ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ REPO="${FREEPI_OPENCODE_REPO:-eduardo191-star/opencode-free-pi}"
5
+ REF="${FREEPI_OPENCODE_REF:-main}"
6
+ RAW_BASE="${FREEPI_OPENCODE_RAW_BASE:-https://raw.githubusercontent.com/${REPO}/${REF}}"
7
+ PLUGIN_NAME="opencode-free-pi"
8
+
9
+ say() {
10
+ printf '%s\n' "$*"
11
+ }
12
+
13
+ fail() {
14
+ printf 'error: %s\n' "$*" >&2
15
+ exit 1
16
+ }
17
+
18
+ uninstall() {
19
+ local config_dir="${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}"
20
+ local plugin_dir="${config_dir}/plugins"
21
+ rm -f "${plugin_dir}/${PLUGIN_NAME}.ts" "${plugin_dir}/${PLUGIN_NAME}.js"
22
+ say "Removed ${PLUGIN_NAME} from ${plugin_dir}"
23
+ say "Restart OpenCode to finish."
24
+ }
25
+
26
+ if [ "${1:-}" = "--uninstall" ]; then
27
+ uninstall
28
+ exit 0
29
+ fi
30
+
31
+ command -v curl >/dev/null 2>&1 || fail "curl is required"
32
+ [ -n "${HOME:-}" ] || fail "HOME is not set"
33
+
34
+ config_dir="${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}"
35
+ plugin_dir="${config_dir}/plugins"
36
+ target="${plugin_dir}/${PLUGIN_NAME}.ts"
37
+ tmp="$(mktemp "${TMPDIR:-/tmp}/${PLUGIN_NAME}.XXXXXX")"
38
+ cleanup() {
39
+ rm -f "$tmp"
40
+ }
41
+ trap cleanup EXIT
42
+
43
+ script_dir=""
44
+ if [ -n "${BASH_SOURCE[0]:-}" ] && [ -f "${BASH_SOURCE[0]}" ]; then
45
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
46
+ fi
47
+
48
+ if [ -n "$script_dir" ] && [ -f "${script_dir}/dist/index.js" ]; then
49
+ cp "${script_dir}/dist/index.js" "$tmp"
50
+ say "Using local build: ${script_dir}/dist/index.js"
51
+ else
52
+ say "Downloading ${RAW_BASE}/dist/index.js"
53
+ curl -fsSL --retry 3 --retry-delay 1 "${RAW_BASE}/dist/index.js" -o "$tmp"
54
+ fi
55
+
56
+ [ -s "$tmp" ] || fail "downloaded plugin is empty"
57
+ grep -q "FreePiPlugin" "$tmp" || fail "downloaded file does not look like the free-pi plugin"
58
+
59
+ mkdir -p "$plugin_dir"
60
+ if [ -f "$target" ]; then
61
+ cp "$target" "${target}.bak"
62
+ fi
63
+ mv "$tmp" "$target"
64
+ rm -f "${plugin_dir}/${PLUGIN_NAME}.js"
65
+
66
+ say "Installed ${PLUGIN_NAME} at ${target}"
67
+ say ""
68
+ say "Next steps:"
69
+ say " 1. Run: opencode auth login -p free-pi"
70
+ say " 2. Restart OpenCode."
71
+ say ""
72
+ say "Credentials: ${FREEPI_CREDENTIALS_PATH:-~/.free-pi/agent/credentials.json}"
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@eduardo191labs/opencode-free-pi",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Ad-supported free-pi provider plugin for OpenCode on Windows, Linux, macOS and Termux",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src",
18
+ "install.sh",
19
+ "install.ps1",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsc -p tsconfig.json",
25
+ "typecheck": "tsc -p tsconfig.json --noEmit",
26
+ "test": "npm run build && node test/smoke.mjs",
27
+ "prepublishOnly": "npm run build"
28
+ },
29
+ "keywords": [
30
+ "opencode",
31
+ "opencode-plugin",
32
+ "free-pi",
33
+ "free-pi-cli",
34
+ "ai",
35
+ "provider"
36
+ ],
37
+ "author": "eduardo191labs",
38
+ "license": "MIT",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/eduardo191-star/opencode-free-pi.git"
42
+ },
43
+ "bugs": {
44
+ "url": "https://github.com/eduardo191-star/opencode-free-pi/issues"
45
+ },
46
+ "homepage": "https://github.com/eduardo191-star/opencode-free-pi#readme",
47
+ "engines": {
48
+ "node": ">=18"
49
+ },
50
+ "peerDependencies": {
51
+ "@opencode-ai/plugin": ">=1.0.0"
52
+ },
53
+ "devDependencies": {
54
+ "@opencode-ai/plugin": "^1.19.0",
55
+ "@types/node": "^24.0.0",
56
+ "typescript": "^5.9.0"
57
+ },
58
+ "publishConfig": {
59
+ "access": "public"
60
+ }
61
+ }