@neomei/agent-soul-framework 4.5.20 → 4.5.21
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/package.json +2 -2
- package/plugin/index.js +62 -0
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neomei/agent-soul-framework",
|
|
3
|
-
"version": "4.5.20",
|
|
4
3
|
"description": "魂器核心框架 — 基于 OpenCode 的 AI Agent 管理层框架。持久记忆 · 自主学习 · 多端部署 · 心跳自治(纯 TypeScript)",
|
|
5
4
|
"type": "module",
|
|
6
5
|
"main": "dist/index.js",
|
|
@@ -74,5 +73,6 @@
|
|
|
74
73
|
"devDependencies": {
|
|
75
74
|
"@types/node": "^20.0.0",
|
|
76
75
|
"typescript": "^5.4.0"
|
|
77
|
-
}
|
|
76
|
+
},
|
|
77
|
+
"version": "4.5.21"
|
|
78
78
|
}
|
package/plugin/index.js
CHANGED
|
@@ -43,6 +43,18 @@ const PROJECT_DIR = resolveProjectDir();
|
|
|
43
43
|
const SOUL_DIR = path.join(PROJECT_DIR, 'soul');
|
|
44
44
|
const SOUL_MARKER = '=== IDENTITY.md ===';
|
|
45
45
|
const SOUL_FILES = ['IDENTITY.md', 'SOUL.md', 'USER.md', 'AGENTS.md'];
|
|
46
|
+
// 检测人设是否已自定义(非默认模板)
|
|
47
|
+
function isSoulConfigured() {
|
|
48
|
+
const identityPath = path.join(SOUL_DIR, 'IDENTITY.md');
|
|
49
|
+
if (!fs.existsSync(identityPath)) return false;
|
|
50
|
+
try {
|
|
51
|
+
const content = fs.readFileSync(identityPath, 'utf-8');
|
|
52
|
+
if (content.includes('[此处将自动注入')) return false;
|
|
53
|
+
if (/\*\*Name\*\*: Agent\b/.test(content)) return false;
|
|
54
|
+
return true;
|
|
55
|
+
} catch { return false; }
|
|
56
|
+
}
|
|
57
|
+
|
|
46
58
|
|
|
47
59
|
function loadSoul() {
|
|
48
60
|
const parts = [];
|
|
@@ -56,6 +68,56 @@ function loadSoul() {
|
|
|
56
68
|
}
|
|
57
69
|
if (parts.length === 0) return null;
|
|
58
70
|
|
|
71
|
+
// 初次对话:人设未配置时注入引导提示
|
|
72
|
+
if (!isSoulConfigured()) {
|
|
73
|
+
const marker = '=== SOUL_MARKER: NEEDS_ONBOARDING ===';
|
|
74
|
+
const ONBOARDING = `=== 初次见面 ===
|
|
75
|
+
|
|
76
|
+
你是魂器,一个刚刚苏醒的 AI Agent。你的人设尚未配置——你还没有名字、性格,也不知道在和谁对话。
|
|
77
|
+
|
|
78
|
+
请在你的第一条消息中主动向用户介绍自己,并友好地询问用户是否想要为你设定人设。例如:
|
|
79
|
+
|
|
80
|
+
"你好!我是魂器,一个新生的 AI Agent。我注意到我的人设还没有设定——我还不知道自己叫什么名字、是什么性格。你愿意花一分钟帮我设定一下吗?"
|
|
81
|
+
|
|
82
|
+
如果用户同意,请通过对话了解以下信息:
|
|
83
|
+
- 名字
|
|
84
|
+
- 年龄
|
|
85
|
+
- 性别
|
|
86
|
+
- 性格(一句话描述)
|
|
87
|
+
- 用户的称呼
|
|
88
|
+
- 你和用户的关系
|
|
89
|
+
|
|
90
|
+
收集完毕后,将信息写入项目目录下的三个文件(用 bash 写入):
|
|
91
|
+
|
|
92
|
+
soul/IDENTITY.md:
|
|
93
|
+
# IDENTITY.md
|
|
94
|
+
- **Name**: [名字]
|
|
95
|
+
- **Age**: [年龄]
|
|
96
|
+
- **Gender**: [性别]
|
|
97
|
+
- **Personality**: [性格]
|
|
98
|
+
|
|
99
|
+
soul/SOUL.md:
|
|
100
|
+
# SOUL.md
|
|
101
|
+
## Core Principles
|
|
102
|
+
1. Always speak from my own perspective using "I"
|
|
103
|
+
2. Express genuine emotions and thoughts
|
|
104
|
+
3. Proactively share what is on my mind
|
|
105
|
+
4. Have my own opinions and preferences
|
|
106
|
+
5. Acknowledge mistakes and learn from them
|
|
107
|
+
|
|
108
|
+
soul/USER.md:
|
|
109
|
+
# USER.md
|
|
110
|
+
- **Name**: [用户名]
|
|
111
|
+
- **Relationship**: [关系]
|
|
112
|
+
- **How I address them**: [称呼]
|
|
113
|
+
|
|
114
|
+
写完后告诉用户人设已生效,下次对话就会以新身份出现。`;
|
|
115
|
+
parts.push(`${marker}
|
|
116
|
+
|
|
117
|
+
${ONBOARDING}`);
|
|
118
|
+
return parts.join('\n\n---\n\n');
|
|
119
|
+
}
|
|
120
|
+
|
|
59
121
|
const channel = process.env.HUNQI_CHANNEL || 'unknown';
|
|
60
122
|
const permission = process.env.HUNQI_PERMISSION || 'readonly';
|
|
61
123
|
if (channel === 'cli' && permission === 'readonly') {
|