@andyqiu/codeforge 0.6.2 → 0.6.4
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/codeforge.json +1 -1
- package/dist/index.js +60 -20
- package/install.mjs +2 -0
- package/package.json +1 -1
package/codeforge.json
CHANGED
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"update": {
|
|
155
155
|
"_doc": "自动更新检查(ADR-0047)。opencode 启动时由 plugins/update-checker.ts 后台拉 npm registry latest,auto_install=true 时自动替换 ~/.config/opencode/codeforge/index.js(下次启动生效),失败/离线静默回退到 GitHub Releases。手动回滚:codeforge rollback。",
|
|
156
156
|
"auto_check_enabled": true,
|
|
157
|
-
"interval_hours":
|
|
157
|
+
"interval_hours": 6,
|
|
158
158
|
"package": "@andyqiu/codeforge",
|
|
159
159
|
"registry": "https://registry.npmjs.org",
|
|
160
160
|
"channel": "latest",
|
package/dist/index.js
CHANGED
|
@@ -19732,9 +19732,10 @@ var toolPolicyServer = async (ctx) => {
|
|
|
19732
19732
|
var handler19 = toolPolicyServer;
|
|
19733
19733
|
|
|
19734
19734
|
// plugins/update-checker.ts
|
|
19735
|
-
import { existsSync as existsSync6 } from "node:fs";
|
|
19735
|
+
import { existsSync as existsSync6, rmSync } from "node:fs";
|
|
19736
19736
|
import { homedir as homedir8 } from "node:os";
|
|
19737
19737
|
import { join as join23 } from "node:path";
|
|
19738
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
19738
19739
|
|
|
19739
19740
|
// lib/update-checker-impl.ts
|
|
19740
19741
|
import { createHash as createHash4 } from "node:crypto";
|
|
@@ -19759,7 +19760,7 @@ import * as zlib from "node:zlib";
|
|
|
19759
19760
|
// lib/version-injected.ts
|
|
19760
19761
|
function getInjectedVersion() {
|
|
19761
19762
|
try {
|
|
19762
|
-
const v = "0.6.
|
|
19763
|
+
const v = "0.6.4";
|
|
19763
19764
|
if (typeof v === "string" && /^\d+\.\d+\.\d+/.test(v)) {
|
|
19764
19765
|
return v;
|
|
19765
19766
|
}
|
|
@@ -20371,7 +20372,7 @@ var updateCheckerServer = async (ctx) => {
|
|
|
20371
20372
|
更新命令:npx ${u.package} install --global`);
|
|
20372
20373
|
return;
|
|
20373
20374
|
}
|
|
20374
|
-
await safeAsync(PLUGIN_NAME20, "
|
|
20375
|
+
await safeAsync(PLUGIN_NAME20, "auto_install_full", async () => {
|
|
20375
20376
|
const target = getOpencodeBundlePath();
|
|
20376
20377
|
if (!target) {
|
|
20377
20378
|
safeWriteLog(PLUGIN_NAME20, {
|
|
@@ -20383,27 +20384,66 @@ var updateCheckerServer = async (ctx) => {
|
|
|
20383
20384
|
自动安装失败:找不到 bundle,请手动 npx ${u.package} install`);
|
|
20384
20385
|
return;
|
|
20385
20386
|
}
|
|
20386
|
-
const { bundlePath } = await downloadAndExtractBundle({
|
|
20387
|
+
const { bundlePath, extractDir } = await downloadAndExtractBundle({
|
|
20387
20388
|
tarballUrl: npmResult.tarballUrl,
|
|
20388
20389
|
expectedIntegrity: npmResult.integrity
|
|
20389
20390
|
});
|
|
20390
|
-
|
|
20391
|
-
|
|
20392
|
-
|
|
20393
|
-
|
|
20394
|
-
|
|
20395
|
-
|
|
20396
|
-
|
|
20397
|
-
|
|
20398
|
-
|
|
20399
|
-
|
|
20400
|
-
|
|
20401
|
-
|
|
20402
|
-
|
|
20403
|
-
|
|
20404
|
-
|
|
20405
|
-
|
|
20391
|
+
try {
|
|
20392
|
+
const installMjs = join23(extractDir, "package", "install.mjs");
|
|
20393
|
+
if (existsSync6(installMjs)) {
|
|
20394
|
+
const r = spawnSync2(process.execPath, [installMjs, "--global", "--skip-build"], {
|
|
20395
|
+
cwd: join23(extractDir, "package"),
|
|
20396
|
+
stdio: "pipe",
|
|
20397
|
+
encoding: "utf8"
|
|
20398
|
+
});
|
|
20399
|
+
if (r.status === 0) {
|
|
20400
|
+
safeWriteLog(PLUGIN_NAME20, {
|
|
20401
|
+
level: "info",
|
|
20402
|
+
msg: "auto_install_full_success",
|
|
20403
|
+
local,
|
|
20404
|
+
remote: npmResult.version,
|
|
20405
|
+
strategy: "install.mjs"
|
|
20406
|
+
});
|
|
20407
|
+
await postToast(ctx, `[CodeForge] ✅ 已全量更新 ${local} → ${npmResult.version}(bundle + agents/skills/commands/workflows,重启 opencode 生效)
|
|
20408
|
+
回滚:npx ${u.package} rollback`);
|
|
20409
|
+
return;
|
|
20410
|
+
}
|
|
20411
|
+
safeWriteLog(PLUGIN_NAME20, {
|
|
20412
|
+
level: "warn",
|
|
20413
|
+
msg: "install_mjs_failed",
|
|
20414
|
+
status: r.status,
|
|
20415
|
+
stderr: r.stderr?.slice(0, 500),
|
|
20416
|
+
stdout: r.stdout?.slice(0, 500)
|
|
20417
|
+
});
|
|
20418
|
+
} else {
|
|
20419
|
+
safeWriteLog(PLUGIN_NAME20, {
|
|
20420
|
+
level: "info",
|
|
20421
|
+
msg: "install_mjs_absent_fallback_bundle_only",
|
|
20422
|
+
installMjs
|
|
20423
|
+
});
|
|
20424
|
+
}
|
|
20425
|
+
const { backupPath, strategy } = atomicReplaceBundle({
|
|
20426
|
+
source: bundlePath,
|
|
20427
|
+
target,
|
|
20428
|
+
oldVersion: local,
|
|
20429
|
+
keepBackups: u.backup_keep
|
|
20430
|
+
});
|
|
20431
|
+
safeWriteLog(PLUGIN_NAME20, {
|
|
20432
|
+
level: "info",
|
|
20433
|
+
msg: "auto_install_bundle_only_success",
|
|
20434
|
+
local,
|
|
20435
|
+
remote: npmResult.version,
|
|
20436
|
+
target,
|
|
20437
|
+
backupPath,
|
|
20438
|
+
strategy
|
|
20439
|
+
});
|
|
20440
|
+
await postToast(ctx, `[CodeForge] ✅ 已更新 bundle ${local} → ${npmResult.version}(仅 bundle,agents/skills 未变;重启生效)
|
|
20406
20441
|
回滚:npx ${u.package} rollback`);
|
|
20442
|
+
} finally {
|
|
20443
|
+
try {
|
|
20444
|
+
rmSync(extractDir, { recursive: true, force: true });
|
|
20445
|
+
} catch {}
|
|
20446
|
+
}
|
|
20407
20447
|
});
|
|
20408
20448
|
});
|
|
20409
20449
|
});
|
package/install.mjs
CHANGED
|
@@ -493,6 +493,8 @@ function installCopyDirs({ targetRoot }) {
|
|
|
493
493
|
vlog(`源目录不存在,跳过: ${srcPath}`)
|
|
494
494
|
continue
|
|
495
495
|
}
|
|
496
|
+
// 先删再建,防止旧版遗留的文件/符号链接阻塞 cpSync
|
|
497
|
+
if (fs.existsSync(dstPath) || isSymlink(dstPath)) rmrf(dstPath)
|
|
496
498
|
ensureDir(dstPath)
|
|
497
499
|
run(`cp -R ${srcPath}/. ${dstPath}/`, () => fs.cpSync(srcPath, dstPath, { recursive: true }))
|
|
498
500
|
vok(`${srcName}/ → ${dstPath} (整目录拷贝)`)
|