agentgui 1.0.732 → 1.0.733
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/lib/tool-version.js +46 -4
- package/package.json +1 -1
package/lib/tool-version.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import os from 'os';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import https from 'https';
|
|
4
5
|
import { execSync } from 'child_process';
|
|
5
6
|
|
|
6
7
|
const isWindows = os.platform() === 'win32';
|
|
@@ -15,10 +16,28 @@ const BIN_MAP = {
|
|
|
15
16
|
'agent-browser': 'agent-browser',
|
|
16
17
|
};
|
|
17
18
|
|
|
19
|
+
function getClaudeInstalledPluginPath(pluginId) {
|
|
20
|
+
try {
|
|
21
|
+
const installedPluginsPath = path.join(homeDir, '.claude', 'plugins', 'installed_plugins.json');
|
|
22
|
+
if (!fs.existsSync(installedPluginsPath)) return null;
|
|
23
|
+
const data = JSON.parse(fs.readFileSync(installedPluginsPath, 'utf-8'));
|
|
24
|
+
const plugins = data.plugins || {};
|
|
25
|
+
const key = Object.keys(plugins).find(k => k.endsWith('@' + pluginId));
|
|
26
|
+
if (!key) return null;
|
|
27
|
+
const entries = plugins[key];
|
|
28
|
+
if (!entries || !entries.length) return null;
|
|
29
|
+
return entries[0].installPath || null;
|
|
30
|
+
} catch (_) {}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
18
34
|
const FRAMEWORK_PATHS = {
|
|
19
35
|
claude: {
|
|
20
|
-
pluginDir: (pluginId) => path.join(homeDir, '.claude', 'plugins', pluginId),
|
|
21
|
-
versionFile: (pluginId) =>
|
|
36
|
+
pluginDir: (pluginId) => getClaudeInstalledPluginPath(pluginId) || path.join(homeDir, '.claude', 'plugins', pluginId),
|
|
37
|
+
versionFile: (pluginId) => {
|
|
38
|
+
const installPath = getClaudeInstalledPluginPath(pluginId);
|
|
39
|
+
return installPath ? path.join(installPath, 'plugin.json') : path.join(homeDir, '.claude', 'plugins', pluginId, 'plugin.json');
|
|
40
|
+
},
|
|
22
41
|
parseVersion: (filePath) => JSON.parse(fs.readFileSync(filePath, 'utf-8')).version,
|
|
23
42
|
},
|
|
24
43
|
opencode: {
|
|
@@ -164,9 +183,32 @@ const versionCache = new Map();
|
|
|
164
183
|
export function getPublishedVersion(pkg) {
|
|
165
184
|
const cacheKey = `published-${pkg}`;
|
|
166
185
|
const cached = versionCache.get(cacheKey);
|
|
167
|
-
if (cached && Date.now() - cached.timestamp <
|
|
186
|
+
if (cached && Date.now() - cached.timestamp < 3600000) {
|
|
187
|
+
return cached.version;
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export async function fetchPublishedVersion(pkg) {
|
|
193
|
+
const cacheKey = `published-${pkg}`;
|
|
194
|
+
const cached = versionCache.get(cacheKey);
|
|
195
|
+
if (cached && Date.now() - cached.timestamp < 3600000) {
|
|
168
196
|
return cached.version;
|
|
169
197
|
}
|
|
198
|
+
try {
|
|
199
|
+
const version = await new Promise((resolve, reject) => {
|
|
200
|
+
const url = `https://registry.npmjs.org/${pkg}/latest`;
|
|
201
|
+
https.get(url, { headers: { 'User-Agent': 'agentgui-version-check/1.0' } }, (res) => {
|
|
202
|
+
let data = '';
|
|
203
|
+
res.on('data', chunk => { data += chunk; });
|
|
204
|
+
res.on('end', () => {
|
|
205
|
+
try { resolve(JSON.parse(data).version || null); } catch (e) { reject(e); }
|
|
206
|
+
});
|
|
207
|
+
}).on('error', reject);
|
|
208
|
+
});
|
|
209
|
+
if (version) versionCache.set(cacheKey, { version, timestamp: Date.now() });
|
|
210
|
+
return version;
|
|
211
|
+
} catch (_) {}
|
|
170
212
|
return null;
|
|
171
213
|
}
|
|
172
214
|
|
|
@@ -181,7 +223,7 @@ export async function checkToolViaBunx(pkg, pluginId = null, category = 'plugin'
|
|
|
181
223
|
const installedVersion = isCli ? getCliVersion(pkg) : getInstalledVersion(pkg, pluginId, frameWork, tools);
|
|
182
224
|
let publishedVersion = null;
|
|
183
225
|
if (!skipPublishedVersion) {
|
|
184
|
-
publishedVersion =
|
|
226
|
+
publishedVersion = await fetchPublishedVersion(pkg);
|
|
185
227
|
}
|
|
186
228
|
const needsUpdate = installed && publishedVersion && compareVersions(installedVersion, publishedVersion);
|
|
187
229
|
const isUpToDate = installed && !needsUpdate;
|