opencode-v2-guard 1.0.0 → 1.0.2
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 +8 -8
- package/docs/deps-spec.md +2 -0
- package/package.json +3 -3
- package/src/deps.ts +5 -2
- package/src/index.ts +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# opencode-guard
|
|
1
|
+
# opencode-v2-guard
|
|
2
2
|
|
|
3
3
|
Security plugin for [OpenCode](https://opencode.ai) V2: intercepts prompts, tool calls and shell commands, detects secrets and personal data, and masks them **before** they reach disk, model context, logs or the network. No LLM involved — only deterministic patterns.
|
|
4
4
|
|
|
@@ -49,13 +49,13 @@ Or a local checkout:
|
|
|
49
49
|
```json
|
|
50
50
|
"plugins": [
|
|
51
51
|
{
|
|
52
|
-
"package": "/path/to/opencode-guard",
|
|
52
|
+
"package": "/path/to/opencode-v2-guard",
|
|
53
53
|
"options": { "mode": "enforce" }
|
|
54
54
|
}
|
|
55
55
|
]
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
OpenCode installs the npm package automatically on startup. Then `opencode service restart`. Verify with `opencode api get "/api/plugin?directory=..."` — look for `"id":"guard"` with `"status":"active"`.
|
|
58
|
+
OpenCode installs the npm package automatically on startup. Then `opencode service restart`. Verify with `opencode api get "/api/plugin?directory=..."` — look for `"id":"opencode-v2-guard"` with `"status":"active"`.
|
|
59
59
|
|
|
60
60
|
## Options
|
|
61
61
|
|
|
@@ -86,7 +86,7 @@ OpenCode installs the npm package automatically on startup. Then `opencode servi
|
|
|
86
86
|
|
|
87
87
|
```bash
|
|
88
88
|
npm install
|
|
89
|
-
npm test # node --test (
|
|
89
|
+
npm test # node --test (111 tests)
|
|
90
90
|
npm run typecheck # tsc --noEmit
|
|
91
91
|
```
|
|
92
92
|
|
|
@@ -99,7 +99,7 @@ The OpenCode server watches `src/**` and reloads the plugin on save — no servi
|
|
|
99
99
|
**After changes, make sure nothing broke:**
|
|
100
100
|
|
|
101
101
|
```bash
|
|
102
|
-
npm test # expect: pass
|
|
102
|
+
npm test # expect: pass 111, fail 0
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
**If anything misbehaves (plugin failed to load, config changed outside the watched files):**
|
|
@@ -172,7 +172,7 @@ opencode service restart
|
|
|
172
172
|
```json
|
|
173
173
|
"plugins": [
|
|
174
174
|
{
|
|
175
|
-
"package": "/absolute/path/to/opencode-guard",
|
|
175
|
+
"package": "/absolute/path/to/opencode-v2-guard",
|
|
176
176
|
"options": { "mode": "enforce" }
|
|
177
177
|
}
|
|
178
178
|
]
|
|
@@ -210,7 +210,7 @@ OpenCode сам установит npm-пакет при старте. Зате
|
|
|
210
210
|
|
|
211
211
|
```bash
|
|
212
212
|
npm install
|
|
213
|
-
npm test # node --test (
|
|
213
|
+
npm test # node --test (111 тестов)
|
|
214
214
|
npm run typecheck # tsc --noEmit
|
|
215
215
|
```
|
|
216
216
|
|
|
@@ -220,7 +220,7 @@ npm run typecheck # tsc --noEmit
|
|
|
220
220
|
|
|
221
221
|
**Правки кода:** сохранил файл — сервер сам перезагрузил плагин (file watcher). Никаких команд не требуется.
|
|
222
222
|
|
|
223
|
-
**Проверка, что не сломано:** `npm test` — ожидается `pass
|
|
223
|
+
**Проверка, что не сломано:** `npm test` — ожидается `pass 111, fail 0`.
|
|
224
224
|
|
|
225
225
|
**Если что-то пошло не так (плагин не загрузился, правки вне зоны watcher'а):** `opencode service restart` — эта одна команда универсальный «сброс/апдейт».
|
|
226
226
|
|
package/docs/deps-spec.md
CHANGED
|
@@ -24,6 +24,8 @@ npm: install|i, yarn: add, pnpm: add|install, pip: install, cargo: add. Флаг
|
|
|
24
24
|
`pkg`, `pkg@1.2.3`, `@scope/pkg@1.0.0` (версия после последнего `@`), pip: `pkg==1.0` (операторы
|
|
25
25
|
стрипаются). Все сегменты проверяются на нарушения (parseSegments), не только первый.
|
|
26
26
|
Прочее (curl, git clone, npx) → null.
|
|
27
|
+
Windows-формы менеджеров нормализуются: `npm.cmd`, `pnpm.cmd`, `yarn.ps1`, `pip.exe` → базовое имя
|
|
28
|
+
(иначе `npm.cmd install lodahs` проходил мимо — найдено живой проверкой опубликованного 1.0.0, фикс в 1.0.1).
|
|
27
29
|
|
|
28
30
|
### 2.2 Blocklist (встроенный список)
|
|
29
31
|
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-v2-guard",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Security plugin for OpenCode V2 — deterministic secret/PII redaction, sensitive-path blocking, prompt-injection detection in skills, package-install interception (blocklist + typosquat)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/avkutuzov/opencode-guard.git"
|
|
9
|
+
"url": "git+https://github.com/avkutuzov/opencode-v2-guard.git"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://github.com/avkutuzov/opencode-guard#readme",
|
|
11
|
+
"homepage": "https://github.com/avkutuzov/opencode-v2-guard#readme",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"opencode",
|
|
14
14
|
"opencode-plugin",
|
package/src/deps.ts
CHANGED
|
@@ -95,8 +95,11 @@ function parseSegment(segment: string): InstallTarget | null {
|
|
|
95
95
|
}
|
|
96
96
|
break
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
// Windows runners: npm.cmd, pnpm.cmd, pip.exe, yarn.ps1, ... — strip the script/extension suffix
|
|
99
|
+
const raw = tokens[i]
|
|
100
|
+
if (!raw) return null
|
|
101
|
+
const manager = raw.replace(/\.(?:cmd|ps1|exe|bat)$/i, "")
|
|
102
|
+
if (!MANAGERS.has(manager)) return null
|
|
100
103
|
const sub = tokens[i + 1]
|
|
101
104
|
if (!SUBCOMMANDS[manager]?.includes(sub)) return null
|
|
102
105
|
if (manager === "yarn" && tokens[i + 2] === "global") return null
|
package/src/index.ts
CHANGED