@andyqiu/codeforge 0.8.7 → 0.8.8

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
@@ -19892,7 +19892,7 @@ import * as https from "node:https";
19892
19892
  // lib/version-injected.ts
19893
19893
  function getInjectedVersion() {
19894
19894
  try {
19895
- const v = "0.8.7";
19895
+ const v = "0.8.8";
19896
19896
  if (typeof v === "string" && /^\d+\.\d+\.\d+/.test(v)) {
19897
19897
  return v;
19898
19898
  }
package/install.mjs CHANGED
@@ -304,6 +304,56 @@ function fixGlobalPluginEntry() {
304
304
  vok(`全局 opencode.json plugin entry 已修正为 npm 包名格式`)
305
305
  }
306
306
 
307
+ // 全局安装时:确保所有 npm 包名格式的 plugin 已安装到 ~/.config/opencode/node_modules/
308
+ // 由 fixGlobalPluginEntry() 之后调用。非致命:npm install 失败只 addWarn 不 abort。
309
+ function ensureGlobalPluginDeps() {
310
+ const opencodeDir = path.join(xdgConfigHome(), "opencode")
311
+ const cfg = path.join(opencodeDir, "opencode.json")
312
+ if (!fs.existsSync(cfg)) return
313
+ let data
314
+ try { data = JSON.parse(fs.readFileSync(cfg, "utf8")) } catch { return }
315
+ if (!Array.isArray(data.plugin)) return
316
+
317
+ // 收集所有 npm 包名格式的 plugin(排除 file://、绝对路径、相对路径、home 路径)
318
+ // scoped package(如 @andyqiu/codeforge)含 / 属正常,不能用 !includes("/") 过滤
319
+ const npmPkgs = data.plugin
320
+ .map(e => String(e).trim())
321
+ .filter(e =>
322
+ e.length > 0 &&
323
+ !e.startsWith("file://") &&
324
+ !e.startsWith("/") &&
325
+ !e.startsWith("./") &&
326
+ !e.startsWith("../") &&
327
+ !e.startsWith("~")
328
+ )
329
+
330
+ if (npmPkgs.length === 0) {
331
+ vlog(`ensureGlobalPluginDeps: 无 npm 包名格式 plugin,跳过`)
332
+ return
333
+ }
334
+
335
+ if (DRY_RUN) {
336
+ vlog(`[dry-run] npm install ${npmPkgs.join(" ")} (cwd: ${opencodeDir})`)
337
+ return
338
+ }
339
+
340
+ vlog(`在 ${opencodeDir} 执行 npm install ${npmPkgs.join(" ")}`)
341
+ const r = spawnSync("npm", ["install", ...npmPkgs], {
342
+ cwd: opencodeDir,
343
+ stdio: VERBOSE ? "inherit" : "pipe",
344
+ shell: IS_WIN,
345
+ })
346
+ if (r.status !== 0) {
347
+ if (!VERBOSE) {
348
+ if (r.stdout) process.stderr.write(r.stdout)
349
+ if (r.stderr) process.stderr.write(r.stderr)
350
+ }
351
+ addWarn(`npm install ${npmPkgs.join(" ")} 失败 (exit=${r.status ?? 1}),plugin 可能无法加载`)
352
+ } else {
353
+ vok(`npm install ${npmPkgs.join(" ")} 完成`)
354
+ }
355
+ }
356
+
307
357
  function removePluginEntry({ targetRoot }) {
308
358
  const cfg = opencodeCfgPath(targetRoot)
309
359
  if (!fs.existsSync(cfg)) return
@@ -906,6 +956,7 @@ function main() {
906
956
  installSkills({ targetRoot })
907
957
  installAssets({ targetRoot })
908
958
  if (opts.mode === "global") fixGlobalPluginEntry()
959
+ if (opts.mode === "global") ensureGlobalPluginDeps()
909
960
  configureDefaultAgent({ mode: opts.mode })
910
961
  installKhConfig({ mode: opts.mode, codeforgeCfgDir })
911
962
  regenerateDevShim()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andyqiu/codeforge",
3
- "version": "0.8.7",
3
+ "version": "0.8.8",
4
4
  "description": "CodeForge — opencode 的零侵入扩展包",
5
5
  "type": "module",
6
6
  "private": false,
@@ -14,6 +14,7 @@
14
14
  # docs/spikes/p0.4-chat-message-unforgeable.md);spike 未 pass 前对话合入不上线。
15
15
  # ──────────────────────────────────────────────────────────────
16
16
 
17
+ name: merge-confirm-semantics
17
18
  version: 1.0.0
18
19
  description: |
19
20
  用户对话确认合入/放弃的语义判定规则。两层判定: