@andyqiu/codeforge 0.7.7 → 0.7.9

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/dist/index.js CHANGED
@@ -18903,7 +18903,7 @@ import * as https from "node:https";
18903
18903
  // lib/version-injected.ts
18904
18904
  function getInjectedVersion() {
18905
18905
  try {
18906
- const v = "0.7.7";
18906
+ const v = "0.7.9";
18907
18907
  if (typeof v === "string" && /^\d+\.\d+\.\d+/.test(v)) {
18908
18908
  return v;
18909
18909
  }
@@ -19133,7 +19133,7 @@ var updateCheckerServer = async (ctx) => {
19133
19133
  _updateCheckStarted = true;
19134
19134
  setImmediate(() => {
19135
19135
  safeAsync(PLUGIN_NAME19, "checkAndMaybeUpdate", async () => {
19136
- const local = readLocalVersion();
19136
+ const local = readLastInstalledVersion() ?? readLocalVersion();
19137
19137
  let npmResult = null;
19138
19138
  try {
19139
19139
  npmResult = await fetchLatestFromNpm({
@@ -19187,7 +19187,7 @@ var updateCheckerServer = async (ctx) => {
19187
19187
  await postToast(ctx, `[codeforge] ⚠ npm 包已升级 ${local} → ${remote},但资产部署未完成。下次启动将重试,或手动运行:codeforge upgrade`);
19188
19188
  return;
19189
19189
  }
19190
- const r2 = spawnSync2(nodeBin, [installMjs, "--global", "--skip-build"], {
19190
+ const r2 = spawnSync2(nodeBin, [installMjs, "--global", "--skip-build", "--skip-plugin-entry"], {
19191
19191
  stdio: "pipe",
19192
19192
  encoding: "utf8",
19193
19193
  timeout: 60000,
package/install.mjs CHANGED
@@ -103,6 +103,7 @@ function parseArgs(argv) {
103
103
  action: "install",
104
104
  dryRun: false,
105
105
  skipBuild: false,
106
+ skipPluginEntry: false,
106
107
  verbose: false,
107
108
  help: false,
108
109
  global: false,
@@ -115,6 +116,7 @@ function parseArgs(argv) {
115
116
  case "--uninstall": out.action = "uninstall"; break
116
117
  case "--dry-run": out.dryRun = true; break
117
118
  case "--skip-build": out.skipBuild = true; break
119
+ case "--skip-plugin-entry": out.skipPluginEntry = true; break
118
120
  case "--verbose": out.verbose = true; break
119
121
  case "-h":
120
122
  case "--help": out.help = true; break
@@ -272,7 +274,6 @@ function writePluginEntry({ targetRoot }) {
272
274
  for (const e of data.plugin) {
273
275
  const s = String(e)
274
276
  if (/\/codeforge\/index\.js$/.test(s)) continue
275
- if (s === "@andyqiu/codeforge") continue // 删除 npm 包名格式 entry
276
277
  if (/\/plugins\/[^/]+\.ts$/.test(s) && /opencode/.test(s)) continue
277
278
  if (/\/\.opencode\/plugins\//.test(s)) continue
278
279
  cleaned.push(e)
@@ -283,6 +284,26 @@ function writePluginEntry({ targetRoot }) {
283
284
  vok(`opencode.json 已写入 plugin entry: ${uri}`)
284
285
  }
285
286
 
287
+ // 全局安装时:把 file:// entry 修正回 npm 包名格式
288
+ // 用于修复 update-checker 历史上写错的 file:// entry
289
+ function fixGlobalPluginEntry() {
290
+ const cfg = path.join(xdgConfigHome(), "opencode", "opencode.json")
291
+ if (!fs.existsSync(cfg)) return
292
+ if (DRY_RUN) { vlog(`[dry-run] fix global plugin entry in ${cfg}`); return }
293
+ let data
294
+ try { data = JSON.parse(fs.readFileSync(cfg, "utf8")) } catch { return }
295
+ if (!Array.isArray(data.plugin)) return
296
+ const PKG = "@andyqiu/codeforge"
297
+ // 把所有 file://...codeforge/index.js 替换为 npm 包名,去重
298
+ const hasNpm = data.plugin.some(e => String(e) === PKG)
299
+ const filtered = data.plugin.filter(e => !/\/codeforge\/index\.js$/.test(String(e)))
300
+ if (!hasNpm) filtered.push(PKG)
301
+ if (JSON.stringify(filtered) === JSON.stringify(data.plugin)) return // 无变化不写
302
+ data.plugin = filtered
303
+ atomicWriteJson(cfg, data)
304
+ vok(`全局 opencode.json plugin entry 已修正为 npm 包名格式`)
305
+ }
306
+
286
307
  function removePluginEntry({ targetRoot }) {
287
308
  const cfg = opencodeCfgPath(targetRoot)
288
309
  if (!fs.existsSync(cfg)) return
@@ -429,12 +450,16 @@ function isSymlink(p) {
429
450
  }
430
451
  }
431
452
 
432
- function installBundle({ targetRoot, bundleSrc }) {
453
+ function installBundle({ targetRoot, bundleSrc, skipPluginEntry = false }) {
433
454
  const bundleDst = path.join(targetRoot, BUNDLE_DST_REL)
434
455
  ensureDir(path.dirname(bundleDst))
435
456
  run(`cp ${bundleSrc} ${bundleDst}`, () => fs.copyFileSync(bundleSrc, bundleDst))
436
457
  vok(`bundle → ${bundleDst}`)
437
- writePluginEntry({ targetRoot })
458
+ if (!skipPluginEntry) {
459
+ writePluginEntry({ targetRoot })
460
+ } else {
461
+ vlog(`skip writePluginEntry(--skip-plugin-entry)`)
462
+ }
438
463
  // 写 VERSION marker
439
464
  let version = "unknown"
440
465
  try {
@@ -875,11 +900,12 @@ function main() {
875
900
  detectOpencode()
876
901
  const bundleSrc = buildBundle({ skipBuild: opts.skipBuild })
877
902
  cleanLegacy({ targetRoot })
878
- installBundle({ targetRoot, bundleSrc })
903
+ installBundle({ targetRoot, bundleSrc, skipPluginEntry: opts.skipPluginEntry })
879
904
  installMdDirs({ targetRoot })
880
905
  installCopyDirs({ targetRoot })
881
906
  installSkills({ targetRoot })
882
907
  installAssets({ targetRoot })
908
+ if (opts.mode === "global") fixGlobalPluginEntry()
883
909
  configureDefaultAgent({ mode: opts.mode })
884
910
  installKhConfig({ mode: opts.mode, codeforgeCfgDir })
885
911
  regenerateDevShim()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andyqiu/codeforge",
3
- "version": "0.7.7",
3
+ "version": "0.7.9",
4
4
  "description": "CodeForge — opencode 的零侵入扩展包",
5
5
  "type": "module",
6
6
  "private": false,