@pragma-sh/opencode-plugin 1.0.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pragma-sh/opencode-plugin",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "opencode plugin that reports agent status to Pragma automatically.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -1,6 +1,15 @@
1
1
  import { mkdir, readFile, writeFile } from "node:fs/promises";
2
2
  import { homedir } from "node:os";
3
3
  import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ // Pin the exact release being installed. OpenCode caches a bare package name
7
+ // once and never re-resolves it, so an unpinned entry keeps loading whichever
8
+ // version it first fetched after every Pragma upgrade.
9
+ const packageJson = JSON.parse(
10
+ await readFile(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf8"),
11
+ );
12
+ const specifier = `${packageJson.name}@${packageJson.version}`;
4
13
 
5
14
  const configPath =
6
15
  process.env.OPENCODE_CONFIG ?? join(homedir(), ".config", "opencode", "opencode.json");
@@ -15,8 +24,13 @@ try {
15
24
  );
16
25
  }
17
26
  }
18
- const plugins = Array.isArray(config.plugin) ? config.plugin : [];
19
- if (!plugins.includes("@pragma-sh/opencode-plugin")) plugins.push("@pragma-sh/opencode-plugin");
27
+ const isOurs = (entry) => entry === packageJson.name || entry.startsWith(`${packageJson.name}@`);
28
+ const plugins = [
29
+ ...(Array.isArray(config.plugin) ? config.plugin : []).filter(
30
+ (entry) => typeof entry !== "string" || !isOurs(entry),
31
+ ),
32
+ specifier,
33
+ ];
20
34
  await mkdir(dirname(configPath), { recursive: true });
21
35
  await writeFile(configPath, `${JSON.stringify({ ...config, plugin: plugins }, null, 2)}\n`, {
22
36
  mode: 0o600,