@eduardo191labs/opencode-free-pi 0.2.0 → 0.2.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/README.md +24 -2
- package/package.json +7 -6
- package/scripts/postinstall.mjs +39 -0
package/README.md
CHANGED
|
@@ -11,8 +11,18 @@ npm i -g @eduardo191labs/opencode-free-pi
|
|
|
11
11
|
opencode plugin add @eduardo191labs/opencode-free-pi
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
El primer comando instala el paquete
|
|
15
|
-
OpenCode
|
|
14
|
+
El primer comando instala el paquete y sus dependencias. El segundo registra
|
|
15
|
+
el plugin en OpenCode y es la forma recomendada, porque npm 12 bloquea los
|
|
16
|
+
scripts de instalación por defecto.
|
|
17
|
+
|
|
18
|
+
El `postinstall` del paquete copia el plugin a
|
|
19
|
+
`~/.config/opencode/plugins/opencode-free-pi.ts` (en Windows,
|
|
20
|
+
`%USERPROFILE%\.config\opencode\plugins\opencode-free-pi.ts`) para que
|
|
21
|
+
OpenCode lo descubra automáticamente. Si tu npm bloquea scripts, ejecuta
|
|
22
|
+
también `opencode plugin add @eduardo191labs/opencode-free-pi`.
|
|
23
|
+
|
|
24
|
+
Para una instalación local sin `-g`, fuerza el registro con
|
|
25
|
+
`FREEPI_CONFIGURE=1 npm install`.
|
|
16
26
|
|
|
17
27
|
## Instalación rápida con script
|
|
18
28
|
|
|
@@ -118,6 +128,18 @@ También puedes declararlo en OpenCode como plugin npm:
|
|
|
118
128
|
La instalación recomendada sigue siendo el script, porque coloca el archivo en
|
|
119
129
|
la carpeta de plugins y funciona sin publicación en npm.
|
|
120
130
|
|
|
131
|
+
## Publicación automática
|
|
132
|
+
|
|
133
|
+
Cada push a `main` ejecuta `.github/workflows/publish.yml`, comprueba la última
|
|
134
|
+
versión en npm, sube un patch si ya existe, publica el paquete y crea el commit
|
|
135
|
+
`chore(release): vX.Y.Z [skip ci]` con el tag `vX.Y.Z`.
|
|
136
|
+
|
|
137
|
+
El workflow usa el secret `NPM_TOKEN` del repositorio. Para una prueba sin
|
|
138
|
+
publicar, ejecuta el workflow manualmente con `publish = false`.
|
|
139
|
+
|
|
140
|
+
Después de un push, haz `git pull` para recibir el commit de versión que crea el
|
|
141
|
+
workflow.
|
|
142
|
+
|
|
121
143
|
## Desarrollo
|
|
122
144
|
|
|
123
145
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eduardo191labs/opencode-free-pi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Ad-supported free-pi provider plugin for OpenCode on Windows, Linux, macOS and Termux",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
|
+
"scripts",
|
|
17
18
|
"src",
|
|
18
19
|
"install.sh",
|
|
19
20
|
"install.ps1",
|
|
@@ -24,7 +25,8 @@
|
|
|
24
25
|
"build": "tsc -p tsconfig.json",
|
|
25
26
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
26
27
|
"test": "npm run build && node test/smoke.mjs",
|
|
27
|
-
"prepublishOnly": "npm run build"
|
|
28
|
+
"prepublishOnly": "npm run build",
|
|
29
|
+
"postinstall": "node scripts/postinstall.mjs"
|
|
28
30
|
},
|
|
29
31
|
"keywords": [
|
|
30
32
|
"opencode",
|
|
@@ -47,15 +49,14 @@
|
|
|
47
49
|
"engines": {
|
|
48
50
|
"node": ">=18"
|
|
49
51
|
},
|
|
50
|
-
"peerDependencies": {
|
|
51
|
-
"@opencode-ai/plugin": ">=1.0.0"
|
|
52
|
-
},
|
|
53
52
|
"devDependencies": {
|
|
54
|
-
"@opencode-ai/plugin": "^1.19.0",
|
|
55
53
|
"@types/node": "^24.0.0",
|
|
56
54
|
"typescript": "^5.9.0"
|
|
57
55
|
},
|
|
58
56
|
"publishConfig": {
|
|
59
57
|
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@opencode-ai/plugin": "^1.19.0"
|
|
60
61
|
}
|
|
61
62
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { copyFile, mkdir } from "node:fs/promises";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const source = join(packageRoot, "dist", "index.js");
|
|
9
|
+
const isGlobal = process.env.npm_config_global === "true";
|
|
10
|
+
|
|
11
|
+
if (!isGlobal && process.env.FREEPI_CONFIGURE !== "1") {
|
|
12
|
+
console.log("free-pi: instalación local; usa `npm i -g` o FREEPI_CONFIGURE=1 para registrar el plugin.");
|
|
13
|
+
process.exit(0);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (!existsSync(source)) {
|
|
17
|
+
console.error(`free-pi: no se encontró ${source}`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const configDir =
|
|
22
|
+
process.env.OPENCODE_CONFIG_DIR ||
|
|
23
|
+
(process.env.XDG_CONFIG_HOME
|
|
24
|
+
? join(process.env.XDG_CONFIG_HOME, "opencode")
|
|
25
|
+
: join(homedir(), ".config", "opencode"));
|
|
26
|
+
const pluginDir = join(configDir, "plugins");
|
|
27
|
+
const target = join(pluginDir, "opencode-free-pi.ts");
|
|
28
|
+
|
|
29
|
+
function display(file) {
|
|
30
|
+
const home = homedir();
|
|
31
|
+
if (process.platform === "win32") return file.replace(home, "%USERPROFILE%");
|
|
32
|
+
return file.replace(home, "~");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
await mkdir(pluginDir, { recursive: true });
|
|
36
|
+
await copyFile(source, target);
|
|
37
|
+
|
|
38
|
+
console.log(`free-pi: plugin instalado en ${display(target)}`);
|
|
39
|
+
console.log("free-pi: reinicia OpenCode y ejecuta `opencode auth login -p free-pi`.");
|