From 0b395734532c8476db926de63e6175abc17606a6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 04:35:07 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20address=20code=20review=20=E2=80=94=20im?= =?UTF-8?q?prove=20path=20generation=20fallback,=20add=20tianyan=20refresh?= =?UTF-8?q?=20logging,=20clarify=20HLDP=20version=20note?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/5faa7e11-7858-4edc-9c67-a311a93057ed Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- hldp/HLDP-EARTH-SPEC-v3.0.json | 2 +- server/age-os/mcp-server/tools/light-tree-ops.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hldp/HLDP-EARTH-SPEC-v3.0.json b/hldp/HLDP-EARTH-SPEC-v3.0.json index 0bbb298c..db46d948 100644 --- a/hldp/HLDP-EARTH-SPEC-v3.0.json +++ b/hldp/HLDP-EARTH-SPEC-v3.0.json @@ -47,7 +47,7 @@ "msg_type": { "type": "enum", "values": ["heartbeat", "report", "command", "query", "ack", "alert", "sync", "evolution", "battle", "tree"], - "description": "消息类型·10种基础类型·可通过evolution扩展" + "description": "消息类型·10种基础类型(v3.0.1新增tree)·可通过evolution扩展" }, "sender": { "type": "object", diff --git a/server/age-os/mcp-server/tools/light-tree-ops.js b/server/age-os/mcp-server/tools/light-tree-ops.js index 869173d5..5cd55903 100644 --- a/server/age-os/mcp-server/tools/light-tree-ops.js +++ b/server/age-os/mcp-server/tools/light-tree-ops.js @@ -87,7 +87,11 @@ async function growLeaf(input) { const parentNode = await db.query('SELECT depth, path FROM light_tree_nodes WHERE id = $1', [actualParentId]); if (parentNode.rows.length === 0) throw new Error(`父节点未找到: ${actualParentId}`); const newDepth = parentNode.rows[0].depth + 1; - const leafPath = path || `${parentNode.rows[0].path}/${title.replace(/[^a-zA-Z0-9\u4e00-\u9fa5_-]/g, '').substring(0, 50)}`; + const leafPath = path || (() => { + const sanitized = title.replace(/[^a-zA-Z0-9\u4e00-\u9fa5_-]/g, '').substring(0, 50); + const suffix = sanitized || `leaf-${Date.now()}`; + return `${parentNode.rows[0].path}/${suffix}`; + })(); const result = await db.query( `INSERT INTO light_tree_nodes (persona_id, parent_id, node_type, depth, path, title, content, human_said, persona_said, feeling, growth_note, importance, created_by, tags) @@ -316,6 +320,9 @@ async function getTianyanView(input) { await db.query('REFRESH MATERIALIZED VIEW tianyan_global_view'); } catch (err) { // 首次运行或并发刷新时可能失败,不影响查询 + if (err.message && !err.message.includes('has not been populated')) { + console.warn(`[光之树] 天眼视图刷新警告: ${err.message}`); + } } const viewResult = await db.query('SELECT * FROM tianyan_global_view');