feat: initialize operations memory branch

这个提交存在于:
YokiiroBW 2026-07-24 00:41:15 +08:00
父节点 2f24824b4f
当前提交 04854669fd
共有 14 个文件被更改,包括 95 次插入 和 54 次删除

查看文件

@ -2,6 +2,14 @@
本项目遵循面向用户体验的版本记录。日期使用北京时间。
## 1.6.2-ops.1 - 2026-07-23
- 建立 `ops-main` 专用运维记忆产品分支。
- 插件身份改为 `astrbot_plugin_memory_companion_ops`,独立注册名、数据目录、扩展页路由和版本。
- 增加 QQ Official 元数据声明,运维记忆页面和历史导入优先发现 `astrbot_plugin_private_companion_ops`。
- 保留普通人格插件名称作为一次性迁移和兼容入口。
- 修复 benchmark 遗留的旧包名引用;运维分支回归测试 `128 passed`。
## 1.6.2 - 2026-07-20
### 共同经历记忆

查看文件

@ -1,11 +1,13 @@
# 我会牢牢记住你
# 我会牢牢记住你・运维记忆
`astrbot_plugin_memory_companion` 是面向 AstrBot 陪伴体系的记忆陪伴中枢。它不把聊天记录粗暴塞回模型,而是把当前消息、连续对话、长期记忆、Bot 自我时间线、群聊/私聊权限和外部陪伴插件线索分层整理,再在每轮 LLM 请求前生成一份临时、可解释、可排查的记忆包。
> 当前分支:`ops-main`。这是面向个人 AstrBot VM 运维平台的专用记忆版本,与普通陪伴记忆版使用不同插件身份和数据目录。
- 插件名:`astrbot_plugin_memory_companion`
- 中文名:`我会牢牢记住你`
- 版本:`1.6.1`
- 适配平台:`aiocqhttp`
`astrbot_plugin_memory_companion_ops` 是面向专用 AstrBot VM 运维平台的记忆与项目连续性中枢。它不把聊天记录粗暴塞回模型,而是把当前消息、连续对话、长期记忆、Bot 自我时间线、群聊/私聊权限和外部陪伴插件线索分层整理,再在每轮 LLM 请求前生成一份临时、可解释、可排查的记忆包。
- 插件名:`astrbot_plugin_memory_companion_ops`
- 中文名:`我会牢牢记住你・运维记忆`
- 版本:`1.6.2-ops.1`
- 适配平台:`aiocqhttp`、`qq_official`
- AstrBot 版本:`>=4.22.0`
- 编码要求:UTF-8

查看文件

@ -14,8 +14,8 @@ ROOT = Path(__file__).resolve().parents[1]
if str(ROOT.parent) not in sys.path:
sys.path.insert(0, str(ROOT.parent))
from astrbot_plugin_remember_you.core.models import EntityRef, MemoryRecord, SessionContext
from astrbot_plugin_remember_you.core.service import MemoryCompanionService
from astrbot_plugin_memory_companion_ops.core.models import EntityRef, MemoryRecord, SessionContext
from astrbot_plugin_memory_companion_ops.core.service import MemoryCompanionService
TARGETS = [

查看文件

@ -7,7 +7,7 @@ from .models import MemoryRecord, clean_text
ARCHIVE_API_VERSION = "1.0"
SOURCE_NAME = "memory_companion"
SOURCE_VERSION = "1.6.2"
SOURCE_VERSION = "1.6.2-ops.1"
_SECRET_PATTERNS = (
(re.compile(r"(?i)\b(password|passwd|pwd)\s*[:=]\s*[^\s,;]+"), r"\1=[REDACTED_SECRET]"),

查看文件

@ -270,10 +270,10 @@ def _is_temp_or_plugin_context(item: Any) -> bool:
metadata = item.get("metadata")
if isinstance(metadata, dict):
source = str(metadata.get("source") or metadata.get("plugin") or metadata.get("source_plugin") or "")
if source in {"private_companion", "astrbot_plugin_private_companion"}:
if source in {"private_companion", "astrbot_plugin_private_companion_ops", "astrbot_plugin_private_companion"}:
return True
source = str(item.get("source") or item.get("plugin") or item.get("source_plugin") or "")
return source in {"private_companion", "astrbot_plugin_private_companion"}
return source in {"private_companion", "astrbot_plugin_private_companion_ops", "astrbot_plugin_private_companion"}
def _sanitize_context_content(value: Any) -> tuple[Any, bool, bool]:

查看文件

@ -989,6 +989,8 @@ class HistoricalChatImporter:
def _private_api(self) -> Any | None:
for module_name in (
"data.plugins.astrbot_plugin_private_companion_ops.main",
"astrbot_plugin_private_companion_ops.main",
"data.plugins.astrbot_plugin_private_companion.main",
"astrbot_plugin_private_companion.main",
):

查看文件

@ -80,6 +80,11 @@ PRESET_LABELS = {
CONFLICT_PLUGINS: dict[str, dict[str, str]] = {
"astrbot_plugin_private_companion_ops": {
"level": "coordinated",
"label": "PrivateCompanion Ops",
"reason": "运维人格版已提供专用桥接和重复上下文抑制。",
},
"astrbot_plugin_private_companion": {
"level": "coordinated",
"label": "PrivateCompanion",

查看文件

@ -1938,8 +1938,8 @@ class MemoryCompanionService:
payload.update(
{
"available": True,
"display_name": "我会牢牢记住你",
"plugin_name": "astrbot_plugin_memory_companion",
"display_name": "我会牢牢记住你・运维记忆",
"plugin_name": "astrbot_plugin_memory_companion_ops",
"counted_in_private_companion_budget": False,
"note": "仅展示记忆插件自身模型消耗,不计入陪伴插件每日 Token 限额。",
}

查看文件

@ -111,3 +111,14 @@
- 修复或规避:运维版采用 `astrbot_plugin_memory_companion_ops` 独立身份,并同步修改注册、数据目录、页面路由、Bridge 发现、备份合同和更新源;普通数据只做一次性复制迁移。
- 预防规则:任何长期产品分线都必须同时检查代码分支、插件身份、数据目录、发布包和更新源五层隔离,不能把 Git 分支误当成运行时隔离。
- 验证证据:已核对 `main.py` 与 `page_api.py` 中的 `PLUGIN_NAME`、数据目录和路由用法,并形成 `双分支运维版可行性评估.md`。
## 2026-07-23 — 运维记忆分支建立并完成身份隔离
- 阶段:运维分支初始化与第一批代码改造
- 类型:环境 / 测试 / API契约
- 现象:源码快照没有 Git 历史;Git 初始化后触发 dubious ownership;系统命令中没有 python;旧 benchmark 仍引用 astrbot_plugin_remember_you。
- 根因:目录所有者与沙箱执行用户不同;Windows 环境未把 Python 放入 PATH;benchmark 未跟随插件改名。
- 修复或规避:建立 companion-main 基线、upstream-sync 和 ops-main;Git 使用仓库级 safe.directory;测试使用 Codex bundled Python;benchmark 改用 astrbot_plugin_memory_companion_ops。此前关于“全部测试因旧包名无法收集”的记录在当前基线已被本条取代,当前测试直接引用 core 包。
- 预防规则:后续版本改名必须同步检查 main、metadata、页面路由、Bridge、历史导入、运维诊断、benchmark 和测试;测试结果必须来自当前分支实际执行。
- 验证证据:companion-main 基线提交为 2f24824,当前分支为 ops-main;compileall 通过;pytest 结果 128 passed in 13.51s。

14
main.py
查看文件

@ -14,9 +14,7 @@ from .core.bridge import MemoryCompanionBridge
from .core.commands import MemoryCompanionCommandHandler
from .core.models import json_dumps
from .core.service import MemoryCompanionService
PLUGIN_NAME = "astrbot_plugin_memory_companion"
PLUGIN_VERSION = "1.6.2"
from .plugin_identity import PLUGIN_DISPLAY_NAME, PLUGIN_NAME, PLUGIN_REPO, PLUGIN_VERSION
_ACTIVE_BRIDGE: MemoryCompanionBridge | None = None
@ -36,11 +34,11 @@ def _prepare_data_dir() -> Path:
@register(
"MemoryCompanion",
PLUGIN_NAME,
"menglimi",
"我会牢牢记住你:结构化长期记忆、共同自我时间线和关系隔离。",
f"{PLUGIN_DISPLAY_NAME}:面向专用 VM 运维平台的长期记忆、项目连续性和关系隔离中枢。",
PLUGIN_VERSION,
"https://github.com/menglimi/astrbot_plugin_memory_companion",
PLUGIN_REPO,
)
class MemoryCompanionPlugin(Star):
def __init__(self, context: Context, config: dict[str, Any]):
@ -61,7 +59,7 @@ class MemoryCompanionPlugin(Star):
_ACTIVE_BRIDGE = self.memory_companion if self.service.config.bool("private_companion_bridge.enabled", True) else None
self._register_page_api_if_available()
logger.info("[MemoryCompanion] 我会牢牢记住你 已启动,数据目录=%s", self.service.data_dir)
logger.info("[MemoryCompanionOps] 我会牢牢记住你・运维记忆 已启动,数据目录=%s", self.service.data_dir)
def _register_page_api_if_available(self) -> None:
if not hasattr(self.context, "register_web_api"):
@ -316,4 +314,4 @@ class MemoryCompanionPlugin(Star):
if _ACTIVE_BRIDGE is self.memory_companion:
_ACTIVE_BRIDGE = None
await self.service.aclose()
logger.info("[MemoryCompanion] 我会牢牢记住你 已停止")
logger.info("[MemoryCompanionOps] 我会牢牢记住你・运维记忆 已停止")

查看文件

@ -1,11 +1,11 @@
name: astrbot_plugin_memory_companion
display_name: 我会牢牢记住你
name: astrbot_plugin_memory_companion_ops
display_name: 我会牢牢记住你・运维记忆
author: menglimi
author_url: https://github.com/menglimi
version: 1.6.2
description: 我会牢牢记住你是面向 AstrBot 陪伴体系的记忆陪伴中枢。它统一管理长期记忆、历史对话整理、群聊连续对话记忆、主链注入、权限边界、知识图谱、陪伴插件桥接、自然衰减、可移植数据和运行诊断。
version: 1.6.2-ops.1
description: 我会牢牢记住你・运维记忆是面向专用 AstrBot VM 运维平台的记忆与项目连续性中枢。它统一管理长期记忆、历史对话整理、群聊连续对话记忆、主链注入、权限边界、知识图谱、陪伴插件桥接、自然衰减、可移植数据和运行诊断。
desc: 为 AstrBot 提供主链记忆注入、历史聊天整理导入、连续对话记忆、陪伴插件协同、主动记忆/回忆工具、知识图谱、权限边界、自我时间线、自然衰减、迁移导出和成本诊断。
repo: https://github.com/menglimi/astrbot_plugin_memory_companion
repo: https://forgejo.yokiirobw.top:55443/YokiiroBW/astrbot_plugin_memory_companion_ops
category: AI 增强
tags:
- 长期记忆
@ -18,4 +18,5 @@ tags:
icon: logo.png
support_platforms:
- aiocqhttp
- qq_official
astrbot_version: ">=4.22.0"

查看文件

@ -26,7 +26,10 @@ except ImportError:
from core.identity import normalize_session_context_fields
from core.models import SessionContext, clean_text
PLUGIN_NAME = "astrbot_plugin_memory_companion"
try:
from .plugin_identity import PLUGIN_NAME, PRIVATE_COMPANION_PLUGIN_NAMES
except ImportError:
from plugin_identity import PLUGIN_NAME, PRIVATE_COMPANION_PLUGIN_NAMES
PAGE_API_PREFIXES = (f"/{PLUGIN_NAME}/page",)
logger = logging.getLogger("MemoryCompanion.PageAPI")
@ -1185,34 +1188,35 @@ class PluginPageApi:
return {"error": "photo_not_found", "status": 404}
def _private_companion_status(self) -> dict[str, Any]:
for module_name in (
"data.plugins.astrbot_plugin_private_companion.main",
"astrbot_plugin_private_companion.main",
):
module = sys.modules.get(module_name)
if module is None:
continue
getter = getattr(module, "get_private_companion_api", None)
if not callable(getter):
continue
try:
api = getter()
except Exception:
api = None
if api is None:
continue
plugin = getattr(api, "_plugin", None)
return {
"available": True,
"plugin_name": "astrbot_plugin_private_companion",
"daily_plan_enabled": bool(getattr(plugin, "enable_daily_plan", False)) if plugin else False,
"detail_enabled": bool(getattr(plugin, "enable_detail_enhancement", False)) if plugin else False,
"plugin": plugin,
}
for plugin_name in PRIVATE_COMPANION_PLUGIN_NAMES:
for module_name in (
f"data.plugins.{plugin_name}.main",
f"{plugin_name}.main",
):
module = sys.modules.get(module_name)
if module is None:
continue
getter = getattr(module, "get_private_companion_api", None)
if not callable(getter):
continue
try:
api = getter()
except Exception:
api = None
if api is None:
continue
plugin = getattr(api, "_plugin", None)
return {
"available": True,
"plugin_name": plugin_name,
"daily_plan_enabled": bool(getattr(plugin, "enable_daily_plan", False)) if plugin else False,
"detail_enabled": bool(getattr(plugin, "enable_detail_enhancement", False)) if plugin else False,
"plugin": plugin,
}
return {
"available": False,
"plugin_name": "astrbot_plugin_private_companion",
"reason": "未检测到已加载的主动陪伴插件",
"plugin_name": PRIVATE_COMPANION_PLUGIN_NAMES[0],
"reason": "未检测到已加载的运维人格插件",
}
@staticmethod

10
plugin_identity.py 普通文件
查看文件

@ -0,0 +1,10 @@
from __future__ import annotations
PLUGIN_NAME = "astrbot_plugin_memory_companion_ops"
PLUGIN_DISPLAY_NAME = "我会牢牢记住你・运维记忆"
PLUGIN_VERSION = "1.6.2-ops.1"
PLUGIN_REPO = "https://forgejo.yokiirobw.top:55443/YokiiroBW/astrbot_plugin_memory_companion_ops"
PRIVATE_COMPANION_PLUGIN_NAMES = (
"astrbot_plugin_private_companion_ops",
"astrbot_plugin_private_companion",
)

查看文件

@ -6,7 +6,7 @@ from core.visibility import VisibilityPolicy
def test_archive_capabilities_use_stable_contract():
payload = archive_capabilities()
assert payload["source_name"] == "memory_companion"
assert payload["source_version"] == "1.6.2"
assert payload["source_version"] == "1.6.2-ops.1"
assert payload["archive_api_version"] == "1.0"
assert payload["memory_write_available"] is False
assert payload["available"] is True