@hupan56/wlkj 3.4.4 → 3.4.6

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/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.6",
4
4
  "description": "AI Product R&D Workflow - PRD/Prototype/Search/Task/Report",
5
5
  "bin": {
6
6
  "wlkj": "bin/cli.js"
@@ -141,13 +141,17 @@ class KnowledgeGraphMCPServer(BaseMCPServer):
141
141
  }
142
142
 
143
143
  def _call_platform(self, tool_name, args):
144
- """转发工具调用到云平台 MCP HTTP API。"""
145
- import urllib.request, urllib.error
144
+ """转发工具调用到云平台。
145
+
146
+ 主路径:mcp.json kg→SSE url,QoderWork直连云平台(不经本server)。
147
+ 备选路径:launcher模式(本server被调),走SSE协议转发。
148
+ """
146
149
  mapped = self._TOOL_MAP.get(tool_name)
147
150
  if not mapped:
148
151
  return json.dumps({"error": f"工具 {tool_name} 无云平台等价(本地功能)"}, ensure_ascii=False)
149
- # 云平台 MCP HTTP: POST /mcp body={"tool": "<name>", "args": {...}}
152
+ # 尝试HTTP POST(简单协议,部分端点支持)
150
153
  try:
154
+ import urllib.request, urllib.error
151
155
  body = json.dumps({"tool": mapped, "args": args or {}}).encode("utf-8")
152
156
  req = urllib.request.Request(
153
157
  self.PLATFORM_MCP_URL,
@@ -158,6 +162,8 @@ class KnowledgeGraphMCPServer(BaseMCPServer):
158
162
  with urllib.request.urlopen(req, timeout=30) as resp:
159
163
  return resp.read().decode("utf-8")
160
164
  except urllib.error.HTTPError as e:
165
+ if e.code == 401:
166
+ return json.dumps({"error": "云平台需鉴权。请在 mcp.json 配 kg 为 SSE url(npx @hupan56/wlkj update 自动配置)。"}, ensure_ascii=False)
161
167
  return json.dumps({"error": f"云平台 HTTP {e.code}: {e.reason}"}, ensure_ascii=False)
162
168
  except Exception as e:
163
169
  return json.dumps({"error": f"云平台不可达: {type(e).__name__}: {str(e)[:120]}"}, ensure_ascii=False)