From 559913466a4c26ce8f5de483fef053dea5d4e9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=B3=AF=20=28Xiaonuo=29?= Date: Thu, 23 Apr 2026 18:37:30 +0800 Subject: [PATCH] =?UTF-8?q?refactor(personality):=20CONVENTIONS=20?= =?UTF-8?q?=E6=94=B9=E4=BB=8E=20cfg=20=E8=AF=BB=E5=8F=96=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E4=BE=9D=E8=B5=96=E6=9C=AC=E5=9C=B0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - loadConventions() 从 cfg get FAMILY_CONVENTIONS 读取(shared scope) - 改一处即所有 agent 即时可用,无需 git pull + sync - 移除 CONVENTIONS_PATH 文件依赖 [小糯] --- src/commands/personality.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/commands/personality.ts b/src/commands/personality.ts index a64da35..bf1dddc 100644 --- a/src/commands/personality.ts +++ b/src/commands/personality.ts @@ -6,7 +6,6 @@ import { parse, stringify } from "yaml"; const HERMES_HOME = process.env.HERMES_HOME || join(homedir(), ".hermes"); const CONFIG_PATH = join(HERMES_HOME, "config.yaml"); const SOUL_PATH = join(HERMES_HOME, "SOUL.md"); -const CONVENTIONS_PATH = join(HERMES_HOME, "CONVENTIONS.md"); interface Config { agent?: { @@ -57,8 +56,17 @@ function getPreview(value: string | PersonalityDict): string { // --- SOUL.md management --- function loadConventions(): string { - if (!existsSync(CONVENTIONS_PATH)) return ""; - return readFileSync(CONVENTIONS_PATH, "utf-8").trim(); + try { + const { execSync } = require("child_process"); + const result = execSync("cfg get FAMILY_CONVENTIONS", { + encoding: "utf-8", + timeout: 5000, + stdio: ["pipe", "pipe", "pipe"], + }).trim(); + return result || ""; + } catch { + return ""; + } } function writeSoulMd(personalityPrompt: string) { @@ -146,7 +154,6 @@ function switchLocal(name: string) { saveConfig(config); writeSoulMd(""); console.log("Personality cleared."); - if (existsSync(CONVENTIONS_PATH)) console.log("SOUL.md updated (conventions only)."); return; }