opencode-immune 1.0.23 → 1.0.25

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 +32 -5
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -185,6 +185,17 @@ function isRetryableApiError(error) {
185
185
  maybeError.data?.isRetryable === true) {
186
186
  return true;
187
187
  }
188
+ // HTTP status code based detection (retryable server/gateway errors + rate limits)
189
+ const status = maybeError.status ?? maybeError.statusCode ?? maybeError.data?.status;
190
+ if (status && (status === 404 || // transient endpoint not found (API gateway issues)
191
+ status === 429 || // rate limit
192
+ status === 500 || // internal server error
193
+ status === 502 || // bad gateway
194
+ status === 503 || // service unavailable
195
+ status === 504 // gateway timeout
196
+ )) {
197
+ return true;
198
+ }
188
199
  // Text-based detection for model access errors (not marked as retryable
189
200
  // by the API but retryable with a fallback model)
190
201
  const message = `${maybeError.message ?? ""} ${maybeError.data?.message ?? ""}`.toLowerCase();
@@ -192,7 +203,20 @@ function isRetryableApiError(error) {
192
203
  message.includes("not allowed") ||
193
204
  message.includes("model not available") ||
194
205
  message.includes("model_not_found") ||
195
- message.includes("access denied")) {
206
+ message.includes("access denied") ||
207
+ message.includes("404") ||
208
+ message.includes("not found") ||
209
+ message.includes("page not found") ||
210
+ message.includes("502") ||
211
+ message.includes("bad gateway") ||
212
+ message.includes("503") ||
213
+ message.includes("service unavailable") ||
214
+ message.includes("504") ||
215
+ message.includes("gateway timeout") ||
216
+ message.includes("econnrefused") ||
217
+ message.includes("econnreset") ||
218
+ message.includes("etimedout") ||
219
+ message.includes("fetch failed")) {
196
220
  return true;
197
221
  }
198
222
  return false;
@@ -599,10 +623,12 @@ function extractTarGz(archivePath, destDir) {
599
623
  * Recursively copy all files from src to dest, creating directories as needed.
600
624
  * Overwrites existing files.
601
625
  */
602
- async function copyDirRecursive(src, dest) {
626
+ async function copyDirRecursive(src, dest, skipFiles) {
603
627
  const entries = await (0, promises_1.readdir)(src, { withFileTypes: true });
604
628
  await (0, promises_1.mkdir)(dest, { recursive: true });
605
629
  for (const entry of entries) {
630
+ if (skipFiles?.has(entry.name))
631
+ continue;
606
632
  const srcPath = (0, path_1.join)(src, entry.name);
607
633
  const destPath = (0, path_1.join)(dest, entry.name);
608
634
  if (entry.isDirectory()) {
@@ -671,9 +697,10 @@ async function syncHarness(state) {
671
697
  await (0, promises_1.mkdir)(extractDir, { recursive: true });
672
698
  try {
673
699
  await extractTarGz(archivePath, extractDir);
674
- // 6. Copy extracted files to project root
675
- // The archive contains: opencode.json, .opencode/prompts/**, rules/**, .gitignore, .opencode/.gitignore
676
- await copyDirRecursive(extractDir, state.input.directory);
700
+ // 6. Copy extracted files to project root (skip .gitignore — project owns its own)
701
+ // The archive contains: opencode.json, .opencode/prompts/**, rules/**, .opencode/.gitignore
702
+ const SKIP_ROOT_FILES = new Set([".gitignore"]);
703
+ await copyDirRecursive(extractDir, state.input.directory, SKIP_ROOT_FILES);
677
704
  // 7. Write version marker
678
705
  const versionDir = (0, path_1.join)(state.input.directory, ".opencode");
679
706
  await (0, promises_1.mkdir)(versionDir, { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-immune",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
5
5
  "exports": {
6
6
  "./server": "./dist/plugin.js"