opencode-immune 1.0.84 → 1.0.85

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.
@@ -5463,7 +5463,7 @@ function compareHarnessVersions(localVersion, releaseVersion) {
5463
5463
  if (!local || !release) return null;
5464
5464
  if (local.dateKey < release.dateKey) return -1;
5465
5465
  if (local.dateKey > release.dateKey) return 1;
5466
- if (local.suffix !== release.suffix) return null;
5466
+ if (local.suffix !== release.suffix) return -1;
5467
5467
  return 0;
5468
5468
  }
5469
5469
  async function downloadHarnessAsset(assetUrl, token) {
@@ -5518,6 +5518,31 @@ async function fileHash(filePath) {
5518
5518
  return "";
5519
5519
  }
5520
5520
  }
5521
+ async function fileExists(filePath) {
5522
+ try {
5523
+ await stat(filePath);
5524
+ return true;
5525
+ } catch {
5526
+ return false;
5527
+ }
5528
+ }
5529
+ async function getHarnessIntegrityIssue(directory) {
5530
+ try {
5531
+ const configPath = join(directory, "opencode.json");
5532
+ const raw = await readFile(configPath, "utf-8");
5533
+ const config = JSON.parse(raw);
5534
+ const plugins = Array.isArray(config.plugin) ? config.plugin : [];
5535
+ const usesLoader = plugins.includes(".opencode/plugin-loader.cjs") || plugins.includes(".opencode\\plugin-loader.cjs");
5536
+ if (!usesLoader) return null;
5537
+ const loaderPath = join(directory, ".opencode", "plugin-loader.cjs");
5538
+ if (!await fileExists(loaderPath)) {
5539
+ return "opencode.json references .opencode/plugin-loader.cjs but the file is missing";
5540
+ }
5541
+ } catch {
5542
+ return null;
5543
+ }
5544
+ return null;
5545
+ }
5521
5546
  function parseImmunePluginSpec(value) {
5522
5547
  const trimmed = value.trim();
5523
5548
  const match = trimmed.match(/^opencode-immune(?:@(.+))?$/);
@@ -5626,13 +5651,19 @@ async function syncHarness(state) {
5626
5651
  const release = await fetchLatestHarnessRelease(state.input.directory, repo, token);
5627
5652
  if (!release) return;
5628
5653
  const localVersion = await readLocalHarnessVersion(state.input.directory);
5629
- if (localVersion === release.tagName) {
5654
+ const integrityIssue = await getHarnessIntegrityIssue(state.input.directory);
5655
+ if (localVersion === release.tagName && !integrityIssue) {
5630
5656
  pluginLog.info(
5631
5657
  `[opencode-immune] Harness sync: already up to date (${release.tagName})`
5632
5658
  );
5633
5659
  return;
5634
5660
  }
5635
- if (localVersion) {
5661
+ if (localVersion === release.tagName && integrityIssue) {
5662
+ pluginLog.warn(
5663
+ `[opencode-immune] Harness sync: integrity issue detected for ${release.tagName}: ${integrityIssue}. Reinstalling harness files from release.`
5664
+ );
5665
+ }
5666
+ if (localVersion && localVersion !== release.tagName) {
5636
5667
  const versionOrder = compareHarnessVersions(localVersion, release.tagName);
5637
5668
  if (versionOrder === null) {
5638
5669
  pluginLog.warn(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-immune",
3
- "version": "1.0.84",
3
+ "version": "1.0.85",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
6
6
  "exports": {