@hupan56/wlkj 3.4.4 → 3.4.5

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.
Files changed (2) hide show
  1. package/bin/cli.js +29 -1
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -26,6 +26,10 @@ const PROTECTED_FILES = new Set([
26
26
  "settings.json", // 本地权限/hook 配置
27
27
  ]);
28
28
 
29
+ // commands/ 目录下的文件强制覆盖(不走三路快照保护)
30
+ // 原因:commands 是引擎产物(类似 .py 脚本),用户不该改;三路快照误保护导致新版 commands 到不了用户
31
+ const FORCE_OVERWRITE_DIRS = new Set(["commands"]);
32
+
29
33
  // 本地状态文件(升级时也绝不碰,但不算"受保护配置",不提示合并)
30
34
  const LOCAL_STATE_FILES = new Set([
31
35
  ".developer", ".current-task", ".engine-version",
@@ -497,6 +501,16 @@ function copyDirRecursive(src, dst, mode = "init", snap = {}, newSnap = {}, relB
497
501
  const s = path.join(src, entry.name);
498
502
  const d = path.join(dst, entry.name);
499
503
  const rel = relBase ? `${relBase}/${entry.name}` : entry.name;
504
+
505
+ // commands/ 目录强制覆盖(不走三路快照,引擎产物不该被保护)
506
+ const inForceOverwriteDir = FORCE_OVERWRITE_DIRS.has(relBase);
507
+ if (entry.isDirectory() && inForceOverwriteDir) {
508
+ // 直接全量拷贝目录(不保护,不快照)
509
+ const r = copyDirRecursive(s, d, "init", {}, {}, rel);
510
+ copied += r.copied; protectedN += r.protectedN; skipped += r.skipped;
511
+ protectedFiles.push(...r.protectedFiles);
512
+ continue;
513
+ }
500
514
  if (entry.isDirectory()) {
501
515
  const r = copyDirRecursive(s, d, mode, snap, newSnap, rel);
502
516
  copied += r.copied; protectedN += r.protectedN; skipped += r.skipped;
@@ -508,8 +522,22 @@ function copyDirRecursive(src, dst, mode = "init", snap = {}, newSnap = {}, relB
508
522
  entry.name.endsWith(".html") || entry.name.endsWith(".txt");
509
523
 
510
524
  if (mode === "update") {
511
- // 受保护配置 (config.yaml/settings.json): 永不覆盖, 有差异存 .new
525
+ // 受保护配置 (config.yaml/settings.json): 永不覆盖, 但自动修复已知问题
512
526
  if (PROTECTED_FILES.has(entry.name) && fs.existsSync(d)) {
527
+ // ★ config.yaml url 行内注释修复:自动清理 url 行的 # 注释(防被当 git url)
528
+ if (entry.name === "config.yaml") {
529
+ try {
530
+ let cfgContent = fs.readFileSync(d, "utf-8");
531
+ // 匹配 url: "xxx" # 注释 → 去掉注释
532
+ const fixedContent = cfgContent.replace(
533
+ /^(\s*url:\s*["']?[^"'\n]*["']?)\s+#.*$/gm, "$1"
534
+ );
535
+ if (fixedContent !== cfgContent) {
536
+ fs.writeFileSync(d, fixedContent, "utf-8");
537
+ console.log(` [FIX] config.yaml url 行内注释已自动清理`);
538
+ }
539
+ } catch { /* 修复失败不阻塞 */ }
540
+ }
513
541
  if (!filesEqual(s, d)) {
514
542
  fs.copyFileSync(s, d + ".new");
515
543
  protectedN++; protectedFiles.push(rel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hupan56/wlkj",
3
- "version": "3.4.4",
3
+ "version": "3.4.5",
4
4
  "description": "AI Product R&D Workflow - PRD/Prototype/Search/Task/Report",
5
5
  "bin": {
6
6
  "wlkj": "bin/cli.js"