opencode-pollinations-plugin 5.1.22 → 5.1.23

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.
@@ -21,6 +21,7 @@ export interface PollinationsConfigV5 {
21
21
  };
22
22
  enablePaidTools: boolean;
23
23
  statusBar: boolean;
24
+ _loadedAt?: number;
24
25
  }
25
26
  export declare function subscribeToConfigChange(callback: () => void): void;
26
27
  export declare function loadConfig(): PollinationsConfigV5;
@@ -48,4 +49,5 @@ export declare function saveConfig(updates: Partial<PollinationsConfigV5>): {
48
49
  };
49
50
  enablePaidTools: boolean;
50
51
  statusBar: boolean;
52
+ _loadedAt?: number;
51
53
  };
@@ -98,11 +98,25 @@ export function loadConfig() {
98
98
  watchFileSafe(CONFIG_FILE);
99
99
  watchFileSafe(AUTH_FILE);
100
100
  watchFileSafe(OPENCODE_CONFIG_FILE);
101
+ // SMART CACHE: Check mtime to ensure freshness (Hot Reload Fix)
102
+ try {
103
+ if (fs.existsSync(AUTH_FILE)) {
104
+ const stats = fs.statSync(AUTH_FILE);
105
+ // If cache is null or file is newer than our last load
106
+ if (!cachedConfig || !cachedConfig._loadedAt || stats.mtimeMs > cachedConfig._loadedAt) {
107
+ logConfig(`[SmartCache] Auth file changed (mtime). Reloading...`);
108
+ cachedConfig = readConfigFromDisk();
109
+ }
110
+ }
111
+ }
112
+ catch (e) {
113
+ logConfig(`[SmartCache] Error checking mtime: ${e}`);
114
+ }
101
115
  return cachedConfig;
102
116
  }
103
117
  export function updateCache(newConfig) {
104
118
  const current = loadConfig();
105
- cachedConfig = { ...current, ...newConfig };
119
+ cachedConfig = { ...current, ...newConfig, _loadedAt: Date.now() }; // Update timestamp
106
120
  logConfig(`Cache Force-Updated via Hook. Mode: ${cachedConfig.mode}`);
107
121
  }
108
122
  // INTERNAL READER (The old loadConfig logic)
@@ -177,7 +191,7 @@ function readConfigFromDisk() {
177
191
  if (!keyFound && config.mode === 'pro') {
178
192
  config.mode = 'manual';
179
193
  }
180
- return { ...config, version: PKG_VERSION };
194
+ return { ...config, version: PKG_VERSION, _loadedAt: Date.now() };
181
195
  }
182
196
  export function saveConfig(updates) {
183
197
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-pollinations-plugin",
3
3
  "displayName": "Pollinations AI (V5.1)",
4
- "version": "5.1.22",
4
+ "version": "5.1.23",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {