6 Commits
test ... v1.0.0

Author SHA1 Message Date
0ebd1d7ac6 docs: sync documentation with source code
- Fix branch badge: test -> main in README files
- Update tool_limits config: remove non-existent persona_query_max and task_query_max fields
- Complete memory tools list: add memory_archive, memory_cleanup, context_rewrite
- Remove 'experimental' labels from context_rewrite feature
2026-04-17 10:08:50 +08:00
de09eacabc fix: 修复 AppImage 构建脚本的多个问题
- 创建缺失的 usr/share/trulymem 目录
- 修复 desktop 文件分类,使用 X-AI 替代非标准的 AI
- 改进图标文件查找逻辑,支持多个可能的位置
- 添加完整的构建临时文件清理逻辑
- 成功时自动删除 AppDir,失败时保留以便调试

🤖 Generated with CodeArts Agent
2026-04-17 08:27:52 +08:00
14af13c050 update: 更新文件 README_EN.md
Signed-off-by: JianFeeeee <2198972886@qq.com>
2026-04-16 23:31:38 +08:00
47c5b99617 update: 更新文件 README.md
Signed-off-by: JianFeeeee <2198972886@qq.com>
2026-04-16 23:30:53 +08:00
e975fe409b !1 merge test into main
新增 context_rewrite 工具优化系统提示词

Created-by: JianFeeeee
Commit-by: JianFeeeee;root
Merged-by: JianFeeeee
Description: feat: 添加 context_rewrite 工具并清理工具限制器死配置
test: 修复测试套件结构问题
fix: 修复 context_rewrite 工具调用问题并优化系统提示词

See merge request: JianFeeeee/TrulyMEM-TrueHumanMEM!1
2026-04-16 23:28:54 +08:00
0270e17a76 fix: 修复 context_rewrite 工具调用问题并优化系统提示词
1. 修复 context_rewrite 导致的 API 错误

   - 删除错误的 tool 结果消息添加逻辑

   - 添加 context_compressed 标记让 AI 识别压缩结果

   - 将 context_rewrite 记录到 tool_calls 以便 TUI 显示

2. 优化系统提示词

   - 添加强制触发条件:每5次记忆工具调用必须调用 context_rewrite

   - 强化指代词处理规则:必须通过工作记忆链解析

   - 扩展时间指代词:添加刚刚

   - 更新执行检查清单

Generated with CodeArts Agent
2026-04-16 23:27:35 +08:00
12 changed files with 98 additions and 38 deletions

View File

@ -13,12 +13,11 @@
*The More Human Choice.*
> ⚠️ **当前分支**: `test` — 测试分支,用于测试实验性功能。此处代码可能不稳定,不应用于生产环境。稳定版本请参阅 `main` 分支。
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-lightgrey.svg)]()
[![Branch](https://img.shields.io/badge/branch-test-orange.svg)]()
[![Branch](https://img.shields.io/badge/branch-main-orange.svg)]()
---

View File

@ -13,12 +13,11 @@
*The More Human Choice.*
> ⚠️ **Current Branch**: `test` — Testing branch for experimental features. Code here may be unstable and should not be used in production. For stable releases, see the `main` branch.
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-lightgrey.svg)]()
[![Branch](https://img.shields.io/badge/branch-test-orange.svg)]()
[![Branch](https://img.shields.io/badge/branch-main-orange.svg)]()
---

View File

@ -11,6 +11,7 @@ fi
APPDIR="$PROJECT_ROOT/TrulyMEM.AppDir"
rm -rf "$APPDIR"
mkdir -p "$APPDIR/usr/bin"
mkdir -p "$APPDIR/usr/share/trulymem"
echo "===== Step 1: Build binary with PyInstaller ====="
VENV_DIR="$PROJECT_ROOT/.venv_appimage"
rm -rf "$VENV_DIR"
@ -80,9 +81,21 @@ Exec=TrulyMEM %U
Icon=trulymem
Terminal=true
Type=Application
Categories=Utility;AI;
Categories=Utility;X-AI;
EOF
[ -f "$PROJECT_ROOT/pic/TrulyMEM.png" ] && cp "$PROJECT_ROOT/pic/TrulyMEM.png" "$APPDIR/trulymem.png"
# Copy icon file (try multiple possible locations)
if [ -f "$PROJECT_ROOT/pic/TrulyMEM.png" ]; then
cp "$PROJECT_ROOT/pic/TrulyMEM.png" "$APPDIR/trulymem.png"
elif [ -f "$PROJECT_ROOT/pic/TrulyMEM.iconset/icon_256x256.png" ]; then
cp "$PROJECT_ROOT/pic/TrulyMEM.iconset/icon_256x256.png" "$APPDIR/trulymem.png"
elif [ -f "$PROJECT_ROOT/pic/TrulyMEM.iconset/icon_128x128.png" ]; then
cp "$PROJECT_ROOT/pic/TrulyMEM.iconset/icon_128x128.png" "$APPDIR/trulymem.png"
else
echo "Warning: No icon file found, creating placeholder"
# Create a simple placeholder icon
convert -size 256x256 xc:blue "$APPDIR/trulymem.png" 2>/dev/null || \
echo "Note: Install ImageMagick to generate placeholder icon"
fi
APPIMAGE="$PROJECT_ROOT/TrulyMEM.AppImage"
rm -f "$APPIMAGE"
echo "===== Step 3: Package as AppImage ====="
@ -108,7 +121,17 @@ fi
echo "===== Build Complete ====="
[ -f "$APPIMAGE" ] && echo "AppImage: $APPIMAGE" && ls -la "$APPIMAGE"
[ -d "$APPDIR" ] && echo "AppDir: $APPDIR (can be packaged manually with appimagetool)"
echo "===== Cleaning up build artifacts ====="
deactivate
rm -rf "$VENV_DIR"
rm -rf "$PROJECT_ROOT/build/pyinstaller_build"
rm -rf "$PROJECT_ROOT/build/pyinstaller_build"
rm -f /tmp/appimagetool
# Only remove AppDir if AppImage was successfully created
if [ -f "$APPIMAGE" ]; then
echo "Removing AppDir since AppImage was created successfully"
rm -rf "$APPDIR"
else
echo "Keeping AppDir for manual packaging"
fi
echo "Done!"

View File

@ -107,6 +107,34 @@
## context_rewrite 使用规则
### ⚠️ 强制触发条件
**每调用 5 次记忆相关工具,必须调用一次 context_rewrite!**
记忆相关工具包括:
- `memory_recall` - 检索记忆
- `memory_commit` - 写入记忆
- `memory_purge` - 删除记忆
- `memory_introspect` - 查看状态
- `persona_update` - 更新人设
- `persona_clear` - 清除人设
- `task_create` - 创建任务
- `task_set_state` - 设置状态
- `task_delete` - 删除任务
- `task_link_info` - 关联信息
**触发规则**:
- 累计调用 5 次记忆工具 → 必须调用 context_rewrite
- 累计调用 10 次记忆工具 → 必须调用 context_rewrite
- 以此类推...
**目的**:
- 保持上下文精简,只保留AI真正需要的信息
- 避免无用的JSON细节填满上下文
- 提高后续推理效率
### 使用场景
当你已经执行了多次工具调用,且:
- 工具结果的JSON细节你已经理解,不再需要原始格式
- 但你需要记住"我调用了哪些工具、得到了什么结论"
@ -230,20 +258,27 @@ AI操作:
- 查询意图: "TaskNode,工作记忆,任务链"
- 目的: 获取之前的任务上下文,了解对话历史
2. **用户提到"刚才"、"之前"、"上次"**
2. **用户提到"刚才"、"之前"、"上次"、"刚刚"**
- 例: "刚才我们聊了什么?"
- 例: "继续刚才的话题"
- 例: "关于刚才的成语接龙..."
- 例: "我不是刚刚给你讲了个故事嘛"
3. **用户询问对话历史**
3. **用户使用指代词(这个故事、那个故事、这件事等)**
- 例: "你给我整体讲一下这个故事吧" → 必须查询工作记忆链确定"这个故事"指什么
- 例: "继续那个任务" → 必须查询工作记忆链确定"那个任务"是什么
- 例: "复述一下" → 必须查询工作记忆链确定要复述什么
- **关键**: 指代词必须通过工作记忆链解析,不能凭空猜测!
4. **用户询问对话历史**
- 例: "我们之前说了什么?"
- 例: "我们聊过X吗?"
4. **连续性任务被打断后恢复**
5. **连续性任务被打断后恢复**
- 例: 用户突然回到之前的话题
- 例: 用户要求继续之前的任务
5. **涉及上下文的引用**
6. **涉及上下文的引用**
- 例: "那个东西"(需要查询上下文)
- 例: "继续"(需要查询当前任务)
@ -374,7 +409,9 @@ AI操作步骤:
- [ ] 步骤3: 是否根据人设和工作记忆链生成回复?
- [ ] 步骤4: 是否更新了工作记忆链?
- [ ] 涉及上下文引用时是否查询了工作记忆链?
- [ ] 用户提到"刚才/之前/上次"时是否查询了工作记忆链?
- [ ] 用户提到"刚才/之前/上次/刚刚"时是否查询了工作记忆链?
- [ ] 用户使用指代词(这个故事、那个任务等)时是否通过工作记忆链解析?
- [ ] 累计调用5次记忆工具后是否调用了 context_rewrite?
---

View File

@ -243,19 +243,23 @@ class BackendServer:
result = execute_tool(self._graph, tool_call.function.name, args)
result_data = json.loads(result)
# 记录到 tool_calls,让 TUI 显示这个工具调用
tool_calls.append({
"name": tool_call.function.name,
"arguments": args,
"result": result
})
if result_data.get("status") == "success":
user_msg = messages_history[0]
# 添加特殊标记,让 AI 知道这是上下文压缩的结果
compressed_content = f"<context_compressed>\n{result_data['summary']}\n</context_compressed>"
messages_history[:] = [
user_msg,
{"role": "assistant", "content": result_data["summary"]}
{"role": "assistant", "content": compressed_content}
]
tool_result_msg = {
"role": "tool",
"tool_call_id": tool_call.id,
"content": result
}
current_tool_results.append(tool_result_msg)
# context_rewrite 压缩上下文后,不需要添加 tool 结果消息
# 因为 messages_history 已经被重写为压缩后的状态
continue
result = execute_tool(self._graph, tool_call.function.name, args)

View File

@ -179,10 +179,8 @@ body = {} # No parameters
"model": str # Model name
},
"tool_limits": {
"persona_query_max": int, # Persona graph query limit
"persona_update_max": int, # Persona graph update limit
"task_query_max": int, # Working memory query limit
"task_update_max": int, # Working memory update limit
"task_update_max": int, # Working memory chain update limit
"memory_query_max": int, # General memory query limit
"memory_update_max": int # General memory update limit
}
@ -211,9 +209,7 @@ body = {
"model": str # Model name (default: deepseek-chat)
},
"tool_limits": {
"persona_query_max": int, # Persona query limit (≥1)
"persona_update_max": int, # Persona update limit (≥1)
"task_query_max": int, # Working memory query limit (≥1)
"task_update_max": int, # Working memory update limit (≥1)
"memory_query_max": int, # General memory query limit (≥1)
"memory_update_max": int # General memory update limit (≥1)
@ -237,8 +233,8 @@ result = client.update_settings(
"model": "deepseek-chat"
},
tool_limits={
"persona_query_max": 2,
"task_query_max": 5,
"persona_update_max": 2,
"task_update_max": 5,
"memory_query_max": 30
}
)

View File

@ -153,7 +153,7 @@ def main():
- `memory_introspect` - View status
- `memory_archive` - Archive memory
- `memory_cleanup` - Clean data
- `context_rewrite` - Compress single-turn tool call context (experimental)
- `context_rewrite` - Compress single-turn tool call context
### Persona Tools (2)
- `persona_update` - Update persona

View File

@ -66,6 +66,9 @@ Step 4: Update working memory chain
| `memory_commit` | Write memory |
| `memory_purge` | Delete memory |
| `memory_introspect` | View status |
| `memory_archive` | Archive memory |
| `memory_cleanup` | Clean data |
| `context_rewrite` | Compress single-turn tool call context |
#### Persona Tools

View File

@ -185,10 +185,8 @@ body = {} # 无参数
"model": str # 模型名称
},
"tool_limits": {
"persona_query_max": int, # 人设图查询上限
"persona_update_max": int, # 人设图修改上限
"task_query_max": int, # 工作记忆查询上限
"task_update_max": int, # 工作记忆修改上限
"task_update_max": int, # 工作记忆链修改上限
"memory_query_max": int, # 一般记忆查询上限
"memory_update_max": int # 一般记忆修改上限
}
@ -217,11 +215,9 @@ body = {
"model": str # 模型名称 (默认: deepseek-chat)
},
"tool_limits": {
"persona_query_max": int, # 人设图查询上限 (≥1)
"persona_update_max": int, # 人设图修改上限 (≥1)
"task_query_max": int, # 工作记忆查询上限 (≥1)
"task_update_max": int, # 工作记忆修改上限 (≥1)
"memory_query_max": int, # 一般记忆查询上限 (≥1)
"task_update_max": int, # 工作记忆链修改上限 (≥1)
"memory_query_max": int, # 一般记忆查询上限 (≥1)
"memory_update_max": int # 一般记忆修改上限 (≥1)
}
}
@ -243,8 +239,8 @@ result = client.update_settings(
"model": "deepseek-chat"
},
tool_limits={
"persona_query_max": 2,
"task_query_max": 5,
"persona_update_max": 2,
"task_update_max": 5,
"memory_query_max": 30
}
)

View File

@ -153,7 +153,7 @@ def main():
- `memory_introspect` - 查看状态
- `memory_archive` - 归档记忆
- `memory_cleanup` - 清理数据
- `context_rewrite` - 压缩单轮工具调用上下文(实验性)
- `context_rewrite` - 压缩单轮工具调用上下文
### 人设工具 (2个)
- `persona_update` - 更新人设

View File

@ -25,7 +25,7 @@ TrulyMEM 的解决思路:
所有记忆必须通过以下方式读取:
- `memory_recall` - 检索记忆
### 工作记忆管理(实验性)
### 工作记忆管理
`context_rewrite` 允许 AI 在单轮对话内主动压缩工具调用的临时上下文:
- 将冗长的 JSON 工具结果提炼为简洁的自然语言摘要

View File

@ -66,6 +66,9 @@ system_prompt = prompt_manager.get_system_prompt()
| `memory_commit` | 写入记忆 |
| `memory_purge` | 删除记忆 |
| `memory_introspect` | 查看状态 |
| `memory_archive` | 归档记忆 |
| `memory_cleanup` | 清理数据 |
| `context_rewrite` | 压缩单轮工具调用上下文 |
#### 人设工具