feat(personality): switch 时自动更新 SOUL.md,append CONVENTIONS.md
切换人格时同时写 SOUL.md = personality prompt + ~/.hermes/CONVENTIONS.md。 清除人格时 SOUL.md 只保留 conventions 内容。 CONVENTIONS.md 由 skills repo sync.sh 维护,集中管理家族共识。 [小糯]
This commit is contained in:
parent
69d9c69358
commit
c5559b134d
@ -3,7 +3,10 @@ import { homedir } from "os";
|
|||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { parse, stringify } from "yaml";
|
import { parse, stringify } from "yaml";
|
||||||
|
|
||||||
const CONFIG_PATH = join(homedir(), ".hermes", "config.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 {
|
interface Config {
|
||||||
agent?: {
|
agent?: {
|
||||||
@ -51,6 +54,21 @@ function getPreview(value: string | PersonalityDict): string {
|
|||||||
return value.description || (value.system_prompt || "").slice(0, 60) + "...";
|
return value.description || (value.system_prompt || "").slice(0, 60) + "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- SOUL.md management ---
|
||||||
|
|
||||||
|
function loadConventions(): string {
|
||||||
|
if (!existsSync(CONVENTIONS_PATH)) return "";
|
||||||
|
return readFileSync(CONVENTIONS_PATH, "utf-8").trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeSoulMd(personalityPrompt: string) {
|
||||||
|
const conventions = loadConventions();
|
||||||
|
const parts = [personalityPrompt];
|
||||||
|
if (conventions) parts.push(conventions);
|
||||||
|
const content = parts.filter(Boolean).join("\n\n");
|
||||||
|
writeFileSync(SOUL_PATH, content + "\n", "utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
// --- Actions ---
|
// --- Actions ---
|
||||||
|
|
||||||
function list() {
|
function list() {
|
||||||
@ -126,7 +144,9 @@ function switchLocal(name: string) {
|
|||||||
if (!config.agent) config.agent = {};
|
if (!config.agent) config.agent = {};
|
||||||
config.agent.system_prompt = "";
|
config.agent.system_prompt = "";
|
||||||
saveConfig(config);
|
saveConfig(config);
|
||||||
|
writeSoulMd("");
|
||||||
console.log("Personality cleared.");
|
console.log("Personality cleared.");
|
||||||
|
if (existsSync(CONVENTIONS_PATH)) console.log("SOUL.md updated (conventions only).");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +160,9 @@ function switchLocal(name: string) {
|
|||||||
if (!config.agent) config.agent = {};
|
if (!config.agent) config.agent = {};
|
||||||
config.agent.system_prompt = prompt;
|
config.agent.system_prompt = prompt;
|
||||||
saveConfig(config);
|
saveConfig(config);
|
||||||
|
writeSoulMd(prompt);
|
||||||
console.log(`Switched to: ${name}`);
|
console.log(`Switched to: ${name}`);
|
||||||
|
console.log("SOUL.md updated.");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function switchTelegram(name: string) {
|
async function switchTelegram(name: string) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user