diff --git a/docs/Q8前端改造与验收记录.md b/docs/Q8前端改造与验收记录.md
new file mode 100644
index 0000000..0e9c509
--- /dev/null
+++ b/docs/Q8前端改造与验收记录.md
@@ -0,0 +1,40 @@
+# Q8 前端改造与验收记录
+
+- 日期:2026-07-25
+- 分支:ops-main
+- 范围:运维版陪伴插件前端,不修改普通陪伴分支。
+
+## 本轮目标
+
+Q8 把 Q7 已冻结的只读接口接入页面,重点解决三件事:
+
+1. 现实时间、当前时间段和下一项日程要能直接看懂。
+2. 计划、实际活动和对账数量分开显示,不能把计划当成事实。
+3. Bot 自有空间、用户记忆和记忆插件边界必须在页面上明确分开。
+
+## 已完成
+
+- 新增“运维”页签和“运维中枢”页面。
+- 接入只读接口:/bot-self/summary、/bot-self/timeline、/agenda/reconciliation、/bot-self/persona、/memory-boundary/status。
+- 新增现实时间、时区、当前活动、下一项日程、计划/实际/已对账指标。
+- 新增计划状态标签:计划中、进行中、已完成、部分完成、已延期、已取消、待确认。
+- 新增 Bot 自有空间只读摘要和自我时间线。
+- 新增记忆边界卡片,明确“用户记忆仅保存用户数据”和“Bot 数据不会外写”。
+- 总览页移除新闻、主动搜索卡片,改为关系/运行记录和数据边界卡片。
+- 页面不再加载每日穿搭预览脚本;每日穿搭配置在 OPS 前端能力列表中隐藏,但后端旧字段保留兼容。
+- 新增独立样式文件 pages/陪伴面板/css/q8-ops.css,包含响应式布局、状态色和只读信息层级。
+
+## 设计边界
+
+- 页面只读展示 Bot 自有数据,不提供任意修改底层 JSON/SQLite 的入口。
+- 记忆边界使用白话文,不把 bot_self_store 当作用户记忆。
+- 旧娱乐功能不恢复,不在 Q8 前端新增 QQ 空间、B 站、新闻、网页搜索、饭点娱乐入口。
+- 接口单项失败时页面显示“部分可用”,不会把失败误报为数据为空。
+
+## 验证
+
+- node --check pages/陪伴面板/app.js:通过。
+- git diff --check:通过。
+- 页面结构包含 data-tab=ops、panel-ops 和 Q8 样式入口。
+- 旧新闻/搜索 DOM 卡片和每日穿搭脚本入口已移除。
+- 尚未进行浏览器实机截图验收;下一步应在 AstrBot 拓展页打开页面,检查真实桥接接口返回和移动端折叠效果。
diff --git a/docs/运维陪伴错题本.md b/docs/运维陪伴错题本.md
index 0a0bbc4..a9233d9 100644
--- a/docs/运维陪伴错题本.md
+++ b/docs/运维陪伴错题本.md
@@ -203,4 +203,24 @@ docs\运维陪伴错题本.md
- 根因:回滚副本被放在活动插件目录的同级扫描范围内,且目录名不是合法的 Python 模块名。
- 修复或规避:删除本次误生成的同级副本;正式备份放在 `/var/backups/astrbot-plugin-private-companion/`。
- 预防规则:任何备份、临时解压目录都必须放在 AstrBot 插件扫描根目录之外。
-- 验证证据:清理后重启日志只保留正式运维陪伴插件加载记录,没有新的 `previous-*` 导入错误。
\ No newline at end of file
+- 验证证据:清理后重启日志只保留正式运维陪伴插件加载记录,没有新的 `previous-*` 导入错误。
+
+## 2026-07-25 — 前端只读契约必须与后端返回结构对齐
+
+- 阶段:Q8 前端改造
+- 类型:API契约 / 编码
+- 现象:前端首次接入日程对账接口时,不能假设接口同时返回摘要字段;详情接口主要返回计划、实际和历史列表。
+- 根因:Q7 将摘要和详情拆成不同职责,前端把两者误当成同一 payload。
+- 修复或规避:前端对状态数量、实际数量和对账数量增加列表回退计算,并对每个只读接口单独降级。
+- 预防规则:接入页面前先读取后端构造函数和真实字段,摘要缺失时必须有可解释的派生值或明确的“暂无”。
+- 验证证据:Q8 页面接入 build_agenda_detail 后通过 node --check 和 git diff --check。
+
+## 2026-07-25 — PowerShell 换行标记不能做全局替换
+
+- 阶段:Q8 前端改造
+- 类型:环境 / 编码
+- 现象:使用 PowerShell 文本替换插入事件处理时,模板字符串中的反引号加 n 被误当作换行标记,造成 JavaScript 语法损坏。
+- 根因:脚本编辑器和目标 JavaScript 都使用反引号,批量替换没有隔离作用域。
+- 修复或规避:回退未提交前端文件,改用 Node 直接读取、按真实换行处理并立即运行 node --check。
+- 预防规则:复杂 JavaScript 模板注入不要使用 PowerShell 全局替换;优先使用 Node/补丁工具,并在每次写入后做语法检查。
+- 验证证据:恢复后的 app.js 语法检查通过,Q8 补丁已重新写入。
diff --git a/pages/陪伴面板/app.js b/pages/陪伴面板/app.js
index 4cff67a..be17a97 100644
--- a/pages/陪伴面板/app.js
+++ b/pages/陪伴面板/app.js
@@ -130,6 +130,7 @@ const state = {
pageFontFamily: "original",
pageTheme: "classic",
overviewRefreshedAt: 0,
+ opsCenter: { loaded: false, loading: false, error: "", summary: null, timeline: null, agenda: null, persona: null, boundary: null },
uxReviewShowAll: false,
selectedFoodMenuIds: new Set(),
};
@@ -138,7 +139,7 @@ let setupGuideProactivePollTimer = null;
const SETUP_GUIDE_PROACTIVE_TEST_TIMEOUT_MS = 120000;
const opsRemovedFeatureKeys = new Set([
- "enable_livingmemory_integration", "enable_food_menu_recommendation", "enable_meal_care_proactive",
+ "enable_livingmemory_integration", "enable_food_menu_recommendation", "enable_daily_outfit_photo", "enable_meal_care_proactive",
"enable_poke_action", "enable_qq_presence_sync", "enable_qq_custom_presence_sync",
"enable_screen_glance_action", "enable_unanswered_screen_peek_followup",
"enable_bilibili_integration", "enable_bilibili_boredom_watch", "enable_news_integration",
@@ -4831,16 +4832,97 @@ function hydrateTokenStatsFromOverview(overview) {
state.lazyLoaded.tokenStats = false;
}
+function opsSafe(value, fallback = "暂无") {
+ const text = String(value ?? "").trim();
+ return text || fallback;
+}
+
+function opsTimeLabel(value) {
+ if (!value) return "暂无时间";
+ const date = new Date(value);
+ return Number.isNaN(date.getTime()) ? String(value) : date.toLocaleString("zh-CN", { hour12: false });
+}
+
+async function loadOpsCenter(force = false) {
+ if (state.opsCenter.loading) return state.opsCenter;
+ if (state.opsCenter.loaded && !force) return state.opsCenter;
+ state.opsCenter.loading = true;
+ state.opsCenter.error = "";
+ renderOpsCenter();
+ const requests = await Promise.all([
+ fetchJson("/bot-self/summary").catch((error) => ({ __error: error.message })),
+ fetchJson("/bot-self/timeline").catch((error) => ({ __error: error.message })),
+ fetchJson("/agenda/reconciliation").catch((error) => ({ __error: error.message })),
+ fetchJson("/bot-self/persona").catch((error) => ({ __error: error.message })),
+ fetchJson("/memory-boundary/status").catch((error) => ({ __error: error.message })),
+ ]);
+ const clean = (value) => value && !value.__error ? value : null;
+ [state.opsCenter.summary, state.opsCenter.timeline, state.opsCenter.agenda, state.opsCenter.persona, state.opsCenter.boundary] = requests.map(clean);
+ const errors = requests.filter((item) => item?.__error).map((item) => item.__error);
+ state.opsCenter.error = errors.length ? errors.join(";") : "";
+ state.opsCenter.loaded = true;
+ state.opsCenter.loading = false;
+ renderOpsCenter();
+ return state.opsCenter;
+}
+
+function renderOpsCenter() {
+ const center = state.opsCenter || {};
+ const agenda = center.agenda || {};
+ const summary = center.summary || {};
+ const boundary = center.boundary || {};
+ const persona = center.persona || {};
+ const timeline = center.timeline || {};
+ const overview = state.overview || {};
+ const put = (id, html) => { const node = document.getElementById(id); if (node) node.innerHTML = html; };
+ const text = (id, value) => { const node = document.getElementById(id); if (node) node.textContent = value; };
+ const now = agenda.current_time ? new Date(agenda.current_time) : new Date();
+ const plan = Array.isArray(agenda.plan) ? agenda.plan : [];
+ const next = plan.find((item) => !["completed", "cancelled"].includes(String(item.status || item.lifecycle_status || "").toLowerCase())) || plan[0] || {};
+ const current = overview.life_observation?.current_plan || {};
+ const statusLabels = { planned: "计划中", active: "进行中", completed: "已完成", partially_completed: "部分完成", deferred: "已延期", cancelled: "已取消", unknown: "待确认" };
+ const computedCounts = plan.reduce((counts, item) => { const key = statusLabels[item.status || item.lifecycle_status] ? (item.status || item.lifecycle_status) : "unknown"; counts[key] = Number(counts[key] || 0) + 1; return counts; }, {});
+ text("opsCurrentTime", center.loading ? "读取中" : now.toLocaleTimeString("zh-CN", { hour12: false }));
+ text("opsCurrentDate", now.toLocaleDateString("zh-CN", { year: "numeric", month: "long", day: "numeric", weekday: "long" }));
+ text("opsTimezone", opsSafe(agenda.timezone, Intl.DateTimeFormat().resolvedOptions().timeZone || "本地时区"));
+ text("opsTimeSource", agenda.current_time ? "来源:现实日程系统" : "来源:页面本地时钟");
+ text("opsCurrentWindow", opsSafe(current.activity || current.time, "当前无明确活动"));
+ text("opsNextAgenda", opsSafe(next.title || next.activity || next.summary || next.content, "暂无计划"));
+ text("opsNextAgendaMeta", opsSafe(next.window || next.start || next.time || agenda.plan_date, "时间待确认"));
+ const statusNode = document.getElementById("opsCenterStatus");
+ if (statusNode) { statusNode.textContent = center.loading ? "读取中" : (center.error ? "部分可用" : "运行正常"); statusNode.dataset.state = center.loading ? "loading" : (center.error ? "warn" : "ok"); }
+ const boundaryReady = boundary.status === "ready" && boundary.policy === "user_only" && boundary.bot_self_external_write === false;
+ const badge = document.getElementById("opsBoundaryBadge");
+ if (badge) { badge.textContent = boundaryReady ? "边界正常" : (center.loading ? "检查中" : "需要关注"); badge.dataset.state = boundaryReady ? "ok" : "warn"; }
+ put("opsBoundarySummary", `
用户记忆仅保存用户数据
Bot 数据外写${boundary.bot_self_external_write === false ? "已拦截" : "未确认"}
记忆插件${boundary.bridge_available ? opsSafe(boundary.bridge_name, "已连接") : "暂不可用"}
最近检查${opsTimeLabel(boundary.checked_at)}
${escapeHtml(opsSafe(boundary.boundary_note, "Bot 的日程、人格、创作和自我时间线不会写入用户记忆。"))}
`);
+ const recordCount = summary.namespaces && typeof summary.namespaces === "object" ? Object.values(summary.namespaces).reduce((total, item) => total + Number(item?.count || 0), 0) : Number(summary.total_records || 0);
+ put("opsSelfSummary", `所有者Bot 自己
存储空间陪伴插件自有空间
记录数量${recordCount} 条
最近更新${opsTimeLabel(summary.latest_at)}
这里只读展示 Bot 的人格、日程、创作和自我时间线摘要,不提供直接改库入口。
`);
+ const personaItems = Array.isArray(persona.items) ? persona.items : [];
+ put("opsPersonaSummary", personaItems.length ? `${personaItems.slice(-5).reverse().map((item) => `- ${escapeHtml(opsSafe(item.title || item.name || item.kind, "人格记录"))}${escapeHtml(opsSafe(item.summary || item.content || item.value, "已记录"))}
`).join("")}
` : `暂无独立人格记录;当前人格继续由 AstrBot 与插件配置共同提供。
`);
+ const timelineItems = Array.isArray(timeline.items) ? timeline.items : [];
+ put("opsSelfTimeline", timelineItems.length ? timelineItems.slice(-5).reverse().map((item) => `${escapeHtml(opsSafe(item.title || item.summary || item.content || item.kind, "Bot 活动"))}
`).join("") : `暂无自我时间线记录。
`);
+ const counts = Object.keys(agenda.status_counts || {}).length ? agenda.status_counts : computedCounts;
+ put("opsAgendaSummary", `${Number(agenda.plan_item_count || plan.length)}今日计划
${Number(agenda.observed_activity_count ?? (Array.isArray(agenda.observed) ? agenda.observed.length : 0))}实际活动
${Number(agenda.reconciliation_count ?? (Array.isArray(agenda.reconciliation_history) ? agenda.reconciliation_history.length : 0))}已对账
${Object.entries(statusLabels).filter(([key]) => Number(counts[key] || 0) > 0).map(([key, label]) => `${label} ${Number(counts[key] || 0)}`).join("") || "暂无状态记录"}
`);
+ put("opsAgendaTimeline", plan.slice(0, 12).map((item) => `${escapeHtml(opsSafe(item.title || item.activity || item.summary || item.content, "未命名计划"))}${escapeHtml(opsSafe(item.window || item.start || item.time, "时间待确认"))} · ${escapeHtml(statusLabels[item.status || item.lifecycle_status] || "待确认")}
`).join("") || `今天还没有确定的计划。
`);
+ const timelineWindow = document.getElementById("opsNextWindow");
+ if (timelineWindow) timelineWindow.textContent = `下一段:${opsSafe(overview.daily_timeline?.segments?.find((item) => item.lifecycle !== "active")?.window, "暂无")}`;
+ const dashboardBoundary = document.getElementById("dashboardBoundarySummary");
+ if (dashboardBoundary) dashboardBoundary.innerHTML = `${boundaryReady ? "边界正常" : "等待检查"}用户记忆仅保存用户数据;Bot 自有资料留在陪伴插件空间。`;
+ const notice = document.getElementById("opsCenterNotice");
+ if (notice) notice.textContent = center.error ? `部分数据读取失败:${center.error}` : "计划、实际活动和存储边界按来源分别展示;页面不会把 Bot 数据伪装成用户记忆。";
+}
function renderAll() {
- scheduleDailyOutfitHydration();
renderStats();
renderDashboard();
+ renderOpsCenter();
renderActiveTab(state.activeTab);
renderSetupGuideOverlay();
}
function renderActiveTab(tabName = state.activeTab || "dashboard") {
- if (tabName === "private") {
+ if (tabName === "ops") {
+ renderOpsCenter();
+ } else if (tabName === "private") {
renderUsers();
} else if (tabName === "learning") {
renderLearning();
@@ -4976,6 +5058,10 @@ async function ensureTabData(tabName, force = false) {
if (tabName === "dashboard") {
return;
}
+ if (tabName === "ops") {
+ await loadOpsCenter(force);
+ return;
+ }
if (["private", "group", "learning", "memory", "proactive", "experimental"].includes(tabName) && (!state.lazyLoaded.userGroupLists || force)) {
await loadUserGroupLists(loadAllRequestSeq, { showErrors: true, force });
}
@@ -8165,8 +8251,6 @@ function renderDashboard() {
renderStrategyOverview();
renderRelationshipChart();
renderGroupBubbleChart();
- renderNewsInsightPanel();
- renderWebExplorationPanel();
renderActivityHeatmap();
}
@@ -25469,6 +25553,11 @@ document.querySelectorAll(".annotations .tab[data-tab]").forEach((button) => {
document.addEventListener("click", async (event) => {
const target = event.target instanceof Element ? event.target : null;
if (!target) return;
+ if (target.closest("[data-ops-refresh]")) {
+ await loadOpsCenter(true);
+ showToast(state.opsCenter.error ? "运维状态已刷新,但有部分数据不可用" : "运维状态已刷新");
+ return;
+ }
if (target.closest("[data-setup-guide-open]")) {
state.setupGuideOpen = true;
state.setupGuideMode = "home";
diff --git a/pages/陪伴面板/css/q8-ops.css b/pages/陪伴面板/css/q8-ops.css
new file mode 100644
index 0000000..6b63aaf
--- /dev/null
+++ b/pages/陪伴面板/css/q8-ops.css
@@ -0,0 +1,52 @@
+.ops-center-panel { --ops-ink:#182235; --ops-muted:#667085; --ops-line:rgba(24,34,53,.12); --ops-surface:rgba(255,255,255,.84); --ops-accent:#246b8f; }
+.ops-center-head { align-items:flex-start; }
+.ops-center-head .eyebrow,.ops-card-kicker { color:var(--ops-accent); font-size:.68rem; letter-spacing:.12em; font-weight:800; }
+.ops-status-chip,.ops-readonly-label,.ops-badge { display:inline-flex; align-items:center; min-height:1.8rem; padding:0 .7rem; border:1px solid var(--ops-line); border-radius:999px; color:var(--ops-muted); background:rgba(255,255,255,.65); font-size:.75rem; }
+.ops-status-chip[data-state="ok"],.ops-badge[data-state="ok"] { color:#176b4c; border-color:rgba(23,107,76,.24); background:#e0f7ec; }
+.ops-status-chip[data-state="warn"],.ops-badge[data-state="warn"] { color:#99651c; border-color:rgba(153,101,28,.25); background:#fff4d7; }
+.ops-time-strip { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:.8rem; margin:1.1rem 0; }
+.ops-time-strip article { min-height:6.2rem; padding:1rem 1.05rem; border:1px solid var(--ops-line); border-radius:1rem; background:linear-gradient(145deg,rgba(255,255,255,.9),rgba(244,248,250,.72)); box-shadow:0 10px 26px rgba(35,53,72,.06); }
+.ops-time-strip span,.ops-time-strip small { display:block; color:var(--ops-muted); font-size:.75rem; }
+.ops-time-strip b { display:block; margin:.45rem 0 .25rem; color:var(--ops-ink); font-size:1.05rem; line-height:1.25; }
+.ops-center-grid { display:grid; grid-template-columns:minmax(0,1.35fr) minmax(18rem,.8fr); gap:1rem; }
+.ops-card { min-width:0; padding:1.1rem; border:1px solid var(--ops-line); border-radius:1.15rem; background:var(--ops-surface); box-shadow:0 14px 32px rgba(35,53,72,.06); }
+.ops-card header { display:flex; align-items:flex-start; justify-content:space-between; gap:.8rem; margin-bottom:.9rem; }
+.ops-card header h3 { margin:.3rem 0 0; color:var(--ops-ink); }
+.ops-card header button { border:0; color:var(--ops-accent); background:transparent; cursor:pointer; font-size:.78rem; }
+.ops-card-body { min-height:8rem; }
+.ops-fact-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.65rem; }
+.ops-fact-list div,.ops-list li,.ops-agenda-metrics div { padding:.7rem .75rem; border-radius:.75rem; background:rgba(238,244,247,.72); }
+.ops-fact-list span,.ops-fact-list b { display:block; }
+.ops-fact-list span,.ops-agenda-metrics span { color:var(--ops-muted); font-size:.72rem; }
+.ops-fact-list b { margin-top:.25rem; color:var(--ops-ink); font-size:.86rem; overflow-wrap:anywhere; }
+.ops-note,.ops-center-notice { margin:.9rem 0 0; color:var(--ops-muted); font-size:.8rem; line-height:1.65; }
+.ops-agenda-metrics { display:grid; grid-template-columns:repeat(3,1fr); gap:.6rem; }
+.ops-agenda-metrics div { text-align:center; }
+.ops-agenda-metrics b,.ops-agenda-metrics span { display:block; }
+.ops-agenda-metrics b { color:var(--ops-ink); font-size:1.25rem; }
+.ops-status-row { display:flex; flex-wrap:wrap; gap:.45rem; margin:.85rem 0; }
+.ops-status-row span { padding:.35rem .55rem; border-radius:999px; color:var(--ops-muted); background:#f3f5f7; font-size:.72rem; }
+.ops-status-row span[data-state="completed"] { color:#176b4c; background:#e4f5eb; }
+.ops-status-row span[data-state="deferred"],.ops-status-row span[data-state="cancelled"] { color:#99651c; background:#fff2d9; }
+.ops-agenda-timeline,.ops-mini-timeline,.ops-list { display:grid; gap:.55rem; margin:0; padding:0; list-style:none; }
+.ops-agenda-item { display:grid; grid-template-columns:.8rem 1fr; gap:.7rem; align-items:start; padding:.65rem 0; border-top:1px solid var(--ops-line); }
+.ops-agenda-dot { width:.65rem; height:.65rem; margin-top:.25rem; border-radius:50%; background:#9aa7b3; }
+.ops-agenda-dot[data-state="active"] { background:#246b8f; box-shadow:0 0 0 .28rem rgba(36,107,143,.12); }
+.ops-agenda-dot[data-state="completed"] { background:#38a169; }
+.ops-agenda-dot[data-state="deferred"],.ops-agenda-dot[data-state="cancelled"] { background:#d69e2e; }
+.ops-agenda-item b,.ops-agenda-item small { display:block; }
+.ops-agenda-item b,.ops-list b { color:var(--ops-ink); font-size:.84rem; }
+.ops-agenda-item small,.ops-list span,.ops-list time { margin-top:.2rem; color:var(--ops-muted); font-size:.73rem; line-height:1.45; }
+.ops-mini-timeline { margin-top:.85rem; }
+.ops-mini-timeline-item { display:flex; gap:.65rem; padding:.45rem 0; border-top:1px solid var(--ops-line); }
+.ops-mini-timeline-item time { min-width:8rem; color:var(--ops-muted); font-size:.7rem; }
+.ops-mini-timeline-item span { color:var(--ops-ink); font-size:.78rem; }
+.ops-empty { display:grid; min-height:6rem; place-items:center; color:var(--ops-muted); font-size:.82rem; text-align:center; }
+.ops-center-notice { padding:.8rem 1rem; border-left:3px solid var(--ops-accent); background:rgba(231,242,247,.65); }
+.ops-inline-summary { display:grid; gap:.35rem; }
+.ops-inline-summary b { color:#176b4c; font-size:.85rem; }
+.ops-inline-summary span { color:var(--ops-muted); font-size:.76rem; line-height:1.5; }
+.dashboard-ops-card { padding:1rem; border:1px solid var(--ops-line); border-radius:1rem; background:rgba(255,255,255,.72); }
+.dashboard-ops-card h2 { margin-top:0; }
+@media (max-width:900px) { .ops-time-strip { grid-template-columns:repeat(2,minmax(0,1fr)); } .ops-center-grid { grid-template-columns:1fr; } }
+@media (max-width:560px) { .ops-time-strip,.ops-fact-list { grid-template-columns:1fr; } .ops-mini-timeline-item { display:grid; gap:.2rem; } }
diff --git a/pages/陪伴面板/index.html b/pages/陪伴面板/index.html
index 92f1b41..bd845f9 100644
--- a/pages/陪伴面板/index.html
+++ b/pages/陪伴面板/index.html
@@ -7,6 +7,7 @@
+