Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# 更新说明

## 0.7.1 — 2026-11-14
## 0.7.2 — 2026-11-15

- **印象跟得上相处的变化**:新互动可以修正旧判断,同一件事只作为一份依据。撤销错误记录后,受影响的印象也会停止用于回复。
- **保留玩笑和自述的语境**:整理资料时保留来源与限定,提醒模型区分成员自述、临时角色扮演和已确认的关系。
- **当前资料,一键预览**:在成员详情查看当前选用的关系、印象和经历,以及取舍原因。预览不调用模型,也不改变关系状态。
- **回复依据,可以回看**:在系统诊断查看当轮实际提供的关系资料与筛选原因。正文需当时开启「完整上下文」且记录完整保留;未保存的内容不会补写。
- **全部群也能预览**:全局空间无需先选群,即可查看当前成员的关系资料。选择具体群后,预览会采用该群生效的模板。
- **先看资料,再看提示词**:预览直接展示关系释义、选中的印象和经历;筛选原因、完整注入文本按需展开,不再被大段提示词占满。历史诊断中的完整文本也改为折叠查看。

原有关系评分规则不变,自定义提示词和模板继续保留,无需清空旧数据。

诊断未设置档位时,默认改为「原文+评估」;已有明确设置不变,新安装仍默认关闭诊断。

**升级提醒**:本次包含数据结构升级。请先停止插件,备份代码、配置和完整数据目录;回退时需一并恢复升级前的备份。详见 [使用与升级说明](docs/RELATION_MATERIALS.md)。
预览仍不调用模型、不改变关系状态;全局空间不披露其他群的印象或经历。关系评分、自定义模板和诊断档位保持不变。
22 changes: 18 additions & 4 deletions api/page_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ async def run():
if request.method != "GET":
raise _PageRequestError
bot_id, mode = self._target(params)
group_id = self._required_account(params, "group_id")
group_id = self._relation_group(params, mode)
user_id = self._required_account(params, "user_id")
deps = self._runtime.peek(bot_id, mode)
if deps is None:
Expand All @@ -433,27 +433,41 @@ async def run():
description = deps.favor.describe_relation(
rec.familiarity, rec.favor, rec.trust
)
# 全局聚合关系不绑定真实群,沿用全局模板,不猜测群级覆盖。
preview_group = None if group_id == GLOBAL_GROUP else group_id
template = (
deps.prompts.resolve("behavior")
if preview_group is None
else deps.prompts.resolve("behavior", bot_id, preview_group)
)
preview = deps.inject.build_relation_materials(
deps.prompts.resolve("behavior", bot_id, group_id),
template,
relationship=description.text,
impression=rec.impression,
events=events,
configured_master=deps.favor.is_master(user_id),
identity=dict(
bot_id=bot_id,
scope_mode=mode,
group_id=group_id,
group_id=preview_group,
user_id=user_id,
),
captured_at=now,
selection=selection,
impression_valid=rec.impression_valid,
impression_origin=rec.impression_origin,
include_content=True,
)
preview.update(
available=True,
injection_enabled=deps.inject_enabled,
note="当前有效数据的只读预览;不是历史实际输入。"
note="当前有效资料的只读预览。"
+ ("全局空间仅提供关系释义。" if mode == "global" else "")
+ (
"全部群使用全局模板;选择具体群可预览该群模板。"
if preview_group is None
else ""
)
+ ("注入当前已关闭。" if not deps.inject_enabled else ""),
)
return self._response({"success": True, "preview": preview})
Expand Down
8 changes: 5 additions & 3 deletions docs/RELATION_MATERIALS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# 关系资料与印象(0.7.1)
# 关系资料与印象

Bond 提供当前关系释义、可修正的成员印象和少量有效经历。关系计算、事件分类、评分、衰减、独立保温、额度、舍入和被动熟悉度规则均沿用 0.7.0。

## 使用

- 成员详情 →「当前关系资料预览」→「只读预览」。先选择 Bot、空间和真实群。只读当前状态,不生成回复、不调用模型、不刷新印象、不生成称谓、不结束临时关系、不提交衰减或推进评估进度。未加载空间显示缺少资料,不为预览初始化空间。全局关系仍不披露其他群的印象或经历。
- 成员详情 →「当前关系资料预览」→「只读预览」。先选择 Bot、空间和成员;按群空间须指定群,全局空间可保留「全部群」。全部群使用全局模板,选择具体群后使用该 Bot、该群生效的模板。全局空间仅提供共享关系释义,不披露其他群的印象或经历。
- 预览默认展示选中的关系释义、成员印象和经历;「筛选说明」查看取舍原因,「完整注入文本(含提示词)」查看本次完整文本。内容来自同一次构建的筛选结果,不从提示词中截取或另行推断;自定义模板未采用、已失效或超出预算的资料不会显示为已选用。
- 预览只读当前状态,不生成回复、不调用模型、不刷新印象、不生成称谓、不结束临时关系、不提交衰减或推进评估进度。未加载空间显示缺少资料,不为预览初始化空间。
- 设置 → 系统诊断 →「查看历史关系资料」。最多显示最近20条已保留的注入记录及程序筛选理由。历史正文来自当时保存的请求,不查当前关系回填。完整上下文记录遭脱敏、裁剪、容量淘汰或没有元信息时,明确显示无法还原或未记录。
- 历史记录表示 Bond 处理边界实际提供、观察到的内容,不保证是所有后续插件处理后的最终网络请求,也不是主回复模型的隐藏推理。
- 清除诊断会清除诊断文件、待写副本和页面已加载副本;不删除关系、评估流水或 AstrBot 历史。关闭/降低档位不会改写已保存历史。
Expand Down Expand Up @@ -46,7 +48,7 @@ schema 21 仅增加印象局部版本、可用标记、来源种类和日志依

## 升级与回退

停止插件写入后备份插件代码、AstrBot 配置和完整插件数据目录,安装0.7.1包后重载。无需清空关系数据或重新生成全部印象。回退时停止插件并成组恢复原代码、配置和升级前数据备份;旧版本不能直接打开 schema 21。备份与恢复也可使用已有管理功能。本地包交付不包含推送、发布或生产部署。
停止插件写入后备份插件代码、AstrBot 配置和完整插件数据目录,安装新包后重载。无需清空关系数据或重新生成全部印象。0.7.2 沿用 0.7.1 的 schema 21,从 0.7.1 升级不迁移数据;回退到 0.7.1 可恢复原插件代码。从 0.7.0 及更早版本升级涉及 schema 21,回退须成组恢复原代码、配置和升级前数据备份。备份与恢复也可使用已有管理功能。

## 验证与模型行为对照

Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _group_entry_id(event) -> str | None:
"astrbot_plugin_bond",
"yiwuerxin, Timeance",
"Bond 关系好感系统:三维关系与成员印象",
"0.7.1",
"0.7.2",
"https://github.com/timeance/Astrbot_plugin_bond",
)
class BondPlugin(Star):
Expand Down
2 changes: 1 addition & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: astrbot_plugin_bond
display_name: Bond 关系好感系统
short_desc: 按 Bot 隔离的三维关系与成员印象
desc: 保存熟悉度、亲近度、信任度与成员印象,支持分级评估、人格适配及管理面板。
version: 0.7.1
version: 0.7.2
author: yiwuerxin, Timeance
repo: https://github.com/timeance/Astrbot_plugin_bond
tags:
Expand Down
7 changes: 6 additions & 1 deletion pages/dashboard/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,11 @@ button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-
white-space: pre-wrap;
word-break: break-word;
}
/* 完整提示词在折叠区内独立滚动,沿用正文与主题样式。 */
.xx-material-block {
max-height: 18rem;
overflow: auto;
}
.xx-modal-actions {
display: flex;
justify-content: flex-end;
Expand Down Expand Up @@ -1539,7 +1544,7 @@ details.xx-form-card[open] > summary::after {
font-weight: 600;
cursor: pointer;
}
.xx-member-history[open] summary {
.xx-member-history[open] > summary {
color: var(--xx-accent-deep);
border-bottom: 1px solid var(--xx-line);
margin-bottom: 8px;
Expand Down
51 changes: 41 additions & 10 deletions pages/dashboard/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,13 +664,12 @@ createApp({
const snapshot = scopeSnapshot();
const revision = scopeRevision.value;
const target = memberRequestTarget.value;
const member = memberDetail.value;
if (!snapshot || !member || !target || materialPreviewLoading.value) return;
if (!canPreviewMaterials.value || materialPreviewLoading.value) return;
materialPreviewLoading.value = true;
materialPreview.value = null;
try {
const data = await scopedGet("member", {
action: "preview", group_id: member.group_id, user_id: member.user_id,
action: "preview", group_id: target.group_id, user_id: target.user_id,
}, snapshot);
if (!isCurrentMemberRequest(target, revision)) return;
if (!data.success) throw new Error(data.error || "预览失败");
Expand All @@ -682,6 +681,12 @@ createApp({
}
};
const memberDetail = ref(null);
const canPreviewMaterials = computed(() => {
const target = memberRequestTarget.value;
return !!memberDetail.value && isCurrentMemberRequest(target, scopeRevision.value)
&& isRealAccount(target.user_id)
&& (isRealAccount(target.group_id) || (target.scope_mode === "global" && !target.group_id));
});
const memberLoading = ref(false);
let expiryTimer;
const clearExpiryTimer = () => { clearTimeout(expiryTimer); expiryTimer = undefined; };
Expand Down Expand Up @@ -1400,7 +1405,7 @@ createApp({
undoPreview, openUndo, closeUndo, confirmUndo,
selectedLog, selectedLogGroup, showDetail, showLogMember, backToLogGroup, closeDetail,
isPassiveLog, isPassiveGroup, passiveLogMembers, passiveLogPreview, passiveLogDelta, logGroupLabel, isLogReversed,
materialPreview, materialPreviewLoading, previewMaterials, materialReason, materialKind, materialHistory,
materialPreview, materialPreviewLoading, canPreviewMaterials, previewMaterials, materialReason, materialKind, materialHistory,
memberDetail, memberLoading, memberNotice, memberNoticeError, memberSaveLoading,
relationEditMode, temporaryMinutes, endTemporary, relationForm, profileForm, openMember, closeMember, refreshNames, saveRelation, saveProfile, refreshImpression,
fetchBots, selectBot, applyMode, backupScope, prepareRestore,
Expand Down Expand Up @@ -1885,7 +1890,10 @@ createApp({
<p class="xx-help">{{ item.note }}</p>
<p v-if="!item.selection" class="xx-help">筛选说明未记录</p>
<p v-for="(entry,j) in (item.selection || [])" :key="j" class="xx-help">{{ materialKind(entry.kind) }}<span v-if="entry.log_id"> #{{ entry.log_id }}</span>:{{ materialReason(entry.reason) }}</p>
<pre v-if="item.block" class="xx-modal-text" style="white-space:pre-wrap;overflow-wrap:anywhere">{{ item.block }}</pre>
<details v-if="item.block" class="xx-member-history">
<summary>完整注入文本(含提示词)</summary>
<pre class="xx-modal-text xx-material-block">{{ item.block }}</pre>
</details>
</details>

<p class="xx-help">诊断记录占用:当前空间 {{ diagnosticSize(diagnosticStats?.size_available ? diagnosticStats.disk_bytes : null) }} · 全部 {{ diagnosticSize(diagnosticStats?.size_available ? diagnosticStats.total_disk_bytes : null) }} / {{ diagnosticSize(diagnosticStats?.max_bytes) }}</p>
Expand Down Expand Up @@ -2033,12 +2041,35 @@ createApp({
<details v-if="memberDetail.temporary_audit && memberDetail.temporary_audit.length" class="xx-member-history"><summary>临时关系操作记录({{ memberDetail.temporary_audit.length }})</summary><p v-for="(item,i) in memberDetail.temporary_audit" :key="i" class="xx-help">{{ fmtTime(item.ts) }} · {{ item.actor }} · {{ ({created:'创建',updated:'修改',cancelled:'结束',expired:'到期'})[item.action] || item.action }}<span v-if="item.details.values"> · 熟悉度 {{ item.details.values.familiarity }},亲近度 {{ item.details.values.affinity }},信任度 {{ item.details.values.trust }} · 截至 {{ fmtTime(item.details.expires_at) }} · {{ item.details.reason }}</span></p></details>
<details class="xx-member-history">
<summary>当前关系资料预览</summary>
<p class="xx-help">按当前有效资料模拟选择,不调用模型。请先选择真实群;历史输入在诊断中查看。</p>
<button class="xx-btn xx-btn-mini" @click="previewMaterials" :disabled="materialPreviewLoading || !memberDetail.group_id">{{ materialPreviewLoading ? "读取中…" : "只读预览" }}</button>
<p class="xx-help">查看当前会选用的资料,不调用模型、不改变关系。历史输入在系统诊断中查看。</p>
<button class="xx-btn xx-btn-mini" @click="previewMaterials" :disabled="materialPreviewLoading || !canPreviewMaterials">{{ materialPreviewLoading ? "读取中…" : "只读预览" }}</button>
<template v-if="materialPreview">
<p class="xx-help">{{ materialPreview.note }}</p>
<p v-for="(entry,i) in (materialPreview.selection || [])" :key="i" class="xx-help">{{ materialKind(entry.kind) }}<span v-if="entry.log_id"> #{{ entry.log_id }}</span>:{{ materialReason(entry.reason) }}</p>
<pre class="xx-modal-text" style="white-space:pre-wrap;overflow-wrap:anywhere">{{ materialPreview.block }}</pre>
<p class="xx-help" role="status">{{ materialPreview.note }}</p>
<section v-if="materialPreview.content?.relationship" class="xx-modal-section">
<h4>当前关系释义</h4>
<p class="xx-modal-text">{{ materialPreview.content.relationship }}</p>
</section>
<section v-if="materialPreview.content?.impression" class="xx-modal-section">
<h4>成员印象(主观判断)</h4>
<p class="xx-modal-text">{{ materialPreview.content.impression }}</p>
</section>
<section v-if="materialPreview.content?.events.length" class="xx-modal-section">
<h4>近期经历({{ materialPreview.content.events.length }})</h4>
<div v-for="(entry,i) in materialPreview.content.events" :key="i">
<p class="xx-help">{{ entry.assessment_kind }} · QQ {{ entry.subject || '未知' }} · {{ fmtTime(entry.occurred_at) }}</p>
<p class="xx-modal-text">{{ entry.assessment || '未记录摘要' }}</p>
<p class="xx-help">{{ entry.certainty }}</p>
</div>
</section>
<p v-if="materialPreview.content && !materialPreview.content.relationship && !materialPreview.content.impression && !materialPreview.content.events.length" class="xx-help">当前未选用关系资料,原因见筛选说明。</p>
<details v-if="materialPreview.selection?.length" class="xx-member-history">
<summary>筛选说明</summary>
<p v-for="(entry,i) in materialPreview.selection" :key="i" class="xx-help">{{ materialKind(entry.kind) }}<span v-if="entry.log_id"> #{{ entry.log_id }}</span>:{{ materialReason(entry.reason) }}</p>
</details>
<details v-if="materialPreview.block" class="xx-member-history">
<summary>完整注入文本(含提示词)</summary>
<pre class="xx-modal-text xx-material-block">{{ materialPreview.block }}</pre>
</details>
</template>
</details>
<details class="xx-member-history">
Expand Down
11 changes: 10 additions & 1 deletion services/inject_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def build_relation_materials(
impression_valid=True,
impression_origin="legacy",
budget=MATERIAL_BUDGET,
include_content: bool = False,
) -> dict:
"""整个块共用长度预算;只舍弃完整条目,不截断主语、否定和条件。"""
import hashlib
Expand Down Expand Up @@ -301,7 +302,7 @@ def render(imp, items):
for decision in decisions:
if decision["reason"] == "selected":
decision["reason"] = "length_budget"
return dict(
result = dict(
block=block,
selection=decisions,
captured_at=captured_at,
Expand All @@ -310,6 +311,14 @@ def render(imp, items):
budget=budget,
chars=len(block),
)
if include_content:
# 管理预览直接呈现本次选中的内容;消息快照和诊断不另存正文副本。
result["content"] = dict(
relationship=relationship if block and "relationship" in fields else "",
impression=imp if block else "",
events=items if block else [],
)
return result

def inject(self, req, block: str) -> None:
"""把档案块追加到 req.system_prompt(只追加不覆盖)。"""
Expand Down
Loading
Loading