@andyqiu/codeforge 0.8.18 → 0.8.20

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/install.mjs CHANGED
@@ -305,6 +305,42 @@ function fixGlobalPluginEntry() {
305
305
  }
306
306
 
307
307
 
308
+ /**
309
+ * 修正 opencode plugin cache 里的版本锁,让 opencode 下次启动重新拉最新 bundle。
310
+ * opencode 在 {cacheDir}/packages/@andyqiu/codeforge@latest/package.json 里记录已安装版本,
311
+ * 如果版本号是精确值(如 0.6.5),opencode 认为 cache 有效不重新下载——导致旧版 bundle 永远被加载。
312
+ * 把精确版本改成 "latest" 后,opencode 下次启动会重新 resolve 并安装最新版。
313
+ */
314
+ function fixOpencodePluginCache() {
315
+ const cacheRoot = process.env["XDG_CACHE_HOME"] ?? path.join(os.homedir(), ".cache")
316
+ const cachePkg = path.join(cacheRoot, "opencode", "packages", "@andyqiu", "codeforge@latest", "package.json")
317
+ if (!fs.existsSync(cachePkg)) {
318
+ vlog(`fixOpencodePluginCache: cache 不存在,跳过(${cachePkg})`)
319
+ return
320
+ }
321
+ if (DRY_RUN) {
322
+ vlog(`[dry-run] fixOpencodePluginCache: 将修正 ${cachePkg}`)
323
+ return
324
+ }
325
+ try {
326
+ const data = JSON.parse(fs.readFileSync(cachePkg, "utf8"))
327
+ if (!data.dependencies?.["@andyqiu/codeforge"]) {
328
+ vlog(`fixOpencodePluginCache: 无版本锁字段,跳过`)
329
+ return
330
+ }
331
+ const locked = data.dependencies["@andyqiu/codeforge"]
332
+ if (locked === "latest") {
333
+ vlog(`fixOpencodePluginCache: 已是 latest,无需修正`)
334
+ return
335
+ }
336
+ data.dependencies["@andyqiu/codeforge"] = "latest"
337
+ atomicWriteJson(cachePkg, data)
338
+ vok(`opencode cache 版本锁已修正:${locked} → latest(重启 opencode 后生效)`)
339
+ } catch (e) {
340
+ addWarn(`fixOpencodePluginCache 失败:${e?.message ?? e}(非致命)`)
341
+ }
342
+ }
343
+
308
344
  function removePluginEntry({ targetRoot }) {
309
345
  const cfg = opencodeCfgPath(targetRoot)
310
346
  if (!fs.existsSync(cfg)) return
@@ -907,6 +943,7 @@ function main() {
907
943
  installSkills({ targetRoot })
908
944
  installAssets({ targetRoot })
909
945
  if (opts.mode === "global") fixGlobalPluginEntry()
946
+ if (opts.mode === "global") fixOpencodePluginCache()
910
947
  configureDefaultAgent({ mode: opts.mode })
911
948
  installKhConfig({ mode: opts.mode, codeforgeCfgDir })
912
949
  regenerateDevShim()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andyqiu/codeforge",
3
- "version": "0.8.18",
3
+ "version": "0.8.20",
4
4
  "description": "CodeForge — opencode 的零侵入扩展包",
5
5
  "type": "module",
6
6
  "private": false,