opencode-immune 1.0.24 → 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.
Files changed (2) hide show
  1. package/dist/plugin.js +40 -4
  2. 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,
@@ -623,10 +654,12 @@ function extractTarGz(archivePath, destDir) {
623
654
  * Recursively copy all files from src to dest, creating directories as needed.
624
655
  * Overwrites existing files.
625
656
  */
626
- async function copyDirRecursive(src, dest) {
657
+ async function copyDirRecursive(src, dest, skipFiles) {
627
658
  const entries = await (0, promises_1.readdir)(src, { withFileTypes: true });
628
659
  await (0, promises_1.mkdir)(dest, { recursive: true });
629
660
  for (const entry of entries) {
661
+ if (skipFiles?.has(entry.name))
662
+ continue;
630
663
  const srcPath = (0, path_1.join)(src, entry.name);
631
664
  const destPath = (0, path_1.join)(dest, entry.name);
632
665
  if (entry.isDirectory()) {
@@ -695,9 +728,10 @@ async function syncHarness(state) {
695
728
  await (0, promises_1.mkdir)(extractDir, { recursive: true });
696
729
  try {
697
730
  await extractTarGz(archivePath, extractDir);
698
- // 6. Copy extracted files to project root
699
- // The archive contains: opencode.json, .opencode/prompts/**, rules/**, .gitignore, .opencode/.gitignore
700
- await copyDirRecursive(extractDir, state.input.directory);
731
+ // 6. Copy extracted files to project root (skip .gitignore — project owns its own)
732
+ // The archive contains: opencode.json, .opencode/prompts/**, rules/**, .opencode/.gitignore
733
+ const SKIP_ROOT_FILES = new Set([".gitignore"]);
734
+ await copyDirRecursive(extractDir, state.input.directory, SKIP_ROOT_FILES);
701
735
  // 7. Write version marker
702
736
  const versionDir = (0, path_1.join)(state.input.directory, ".opencode");
703
737
  await (0, promises_1.mkdir)(versionDir, { recursive: true });
@@ -1387,6 +1421,8 @@ function createMultiCycleHandler(state) {
1387
1421
  // ═══════════════════════════════════════════════════════════════════════════════
1388
1422
  async function server(input) {
1389
1423
  const state = createState(input);
1424
+ // ── Plugin version check (non-blocking, fire-and-forget) ──
1425
+ checkPluginUpdate().catch(() => { });
1390
1426
  // ── Harness auto-sync (non-blocking, fire-and-forget) ──
1391
1427
  // Runs in background so it doesn't delay plugin initialization.
1392
1428
  // If sync fails, plugin continues normally with existing config.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-immune",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
5
5
  "exports": {
6
6
  "./server": "./dist/plugin.js"