opencode-immune 1.0.25 → 1.0.26
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/dist/plugin.js +33 -0
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -8,6 +8,37 @@ const path_1 = require("path");
|
|
|
8
8
|
const crypto_1 = require("crypto");
|
|
9
9
|
const os_1 = require("os");
|
|
10
10
|
const child_process_1 = require("child_process");
|
|
11
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
12
|
+
// PLUGIN VERSION CHECK
|
|
13
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
14
|
+
const PLUGIN_VERSION = "1.0.26";
|
|
15
|
+
const PLUGIN_PACKAGE_NAME = "opencode-immune";
|
|
16
|
+
/**
|
|
17
|
+
* Check npm registry for latest version. Warn if current is outdated.
|
|
18
|
+
* Non-blocking, fire-and-forget — never delays plugin startup.
|
|
19
|
+
*/
|
|
20
|
+
async function checkPluginUpdate() {
|
|
21
|
+
try {
|
|
22
|
+
const controller = new AbortController();
|
|
23
|
+
const timeout = setTimeout(() => controller.abort(), 5_000);
|
|
24
|
+
const res = await fetch(`https://registry.npmjs.org/${PLUGIN_PACKAGE_NAME}/latest`, { signal: controller.signal });
|
|
25
|
+
clearTimeout(timeout);
|
|
26
|
+
if (!res.ok)
|
|
27
|
+
return;
|
|
28
|
+
const data = (await res.json());
|
|
29
|
+
const latest = data.version;
|
|
30
|
+
if (latest && latest !== PLUGIN_VERSION) {
|
|
31
|
+
console.warn(`[opencode-immune] Plugin update available: ${PLUGIN_VERSION} → ${latest}. ` +
|
|
32
|
+
`Restart opencode to pick up the new version.`);
|
|
33
|
+
}
|
|
34
|
+
else if (latest) {
|
|
35
|
+
console.log(`[opencode-immune] Plugin version ${PLUGIN_VERSION} is up to date.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Network error, timeout, etc. — silently ignore
|
|
40
|
+
}
|
|
41
|
+
}
|
|
11
42
|
function createState(input) {
|
|
12
43
|
return {
|
|
13
44
|
input,
|
|
@@ -1390,6 +1421,8 @@ function createMultiCycleHandler(state) {
|
|
|
1390
1421
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
1391
1422
|
async function server(input) {
|
|
1392
1423
|
const state = createState(input);
|
|
1424
|
+
// ── Plugin version check (non-blocking, fire-and-forget) ──
|
|
1425
|
+
checkPluginUpdate().catch(() => { });
|
|
1393
1426
|
// ── Harness auto-sync (non-blocking, fire-and-forget) ──
|
|
1394
1427
|
// Runs in background so it doesn't delay plugin initialization.
|
|
1395
1428
|
// If sync fails, plugin continues normally with existing config.
|