Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix: address review — 扩权确认绑定当前安装状态 + 面板语义同步编写手册
Chrisd376a217034d
diff --git a/apps/desktop/src/main/cindy-brain/forge.ts b/apps/desktop/src/main/cindy-brain/forge.tsindex 857f47d30d..85f4629683 100644--- a/apps/desktop/src/main/cindy-brain/forge.ts+++ b/apps/desktop/src/main/cindy-brain/forge.ts@@ -872,7 +872,7 @@ ghost_forge_pack 打包 → 用户在弹窗上确认装入。**值得主动摆出来让用户选的"隐藏"设计选项(详见对应章节):- **界面形态**:无界面(纯工具)/ 聊天卡片(card 槽,§4.5)/ 停靠面板(panel.position- left,§5)/ 右侧栏页签(position "tab",§5)。+ left,§5)/ 插件页内独占面板(position "tab",从插件页「使用」打开、离开即关,§5)。- **唤起方式**:只靠 AI 按 whenToUse 自动想起,还是同时声明 \`command\` 点名词让用户显式点名(推荐,§2)。- **启动模式**:on-demand 按需拉起(缺省,推荐)/ resident 常驻(仅订阅型、要秒响应@@ -945,8 +945,8 @@ my-ghost/"minWidth": 240, "defaultFraction": 0.24,"systemButtons": { "maximize": false } },// panel.position:面板显示形态。left(缺省)= 停靠主聊天窗左侧;- // "tab" = 右侧栏页签(与文件/审查/终端同一容器,每会话至多一个,用户从- // 空态列表或「+」菜单打开;此形态没有拖缝宽度,声明 minWidth /+ // "tab" = 插件页内的独占面板(用户在插件页点插件卡的「使用」打开,离开+ // 插件页即关闭;同一时刻至多一个;此形态没有拖缝宽度,声明 minWidth /// defaultFraction 会被拒装,请移除)。right 已退役(右侧是右侧边栏的地盘;// 旧包声明 right 自动并入 left,用户想放右边可自己拖拽换位)。// top/bottom 暂未支持(排期中)@@ -2851,13 +2851,16 @@ if (r.ok && r.confirmed) {- 显示形态由 \`panel.position\` 决定:\`left\`(缺省)= 停靠主聊天窗左侧的常驻面板(\`right\` 已退役:右侧是右侧边栏的地盘,旧包声明 right 自动并入 left,- 用户想放右边可自己拖拽换位);\`"tab"\` = 右侧栏页签——与文件/审查/终端同一- 容器,每会话至多一个页签,由用户从右侧栏空态列表或「+」菜单打开。当用户在会话视图内装入- tab 型插件并勾选「立即开启」时,装入完成后会自动展开右侧栏并打开/聚焦该- 页签;从插件页(无会话路由)装入或未勾选时,仍由用户手动从空态/「+」菜单- 打开。页签形态没有拖缝宽度语义,声明 \`minWidth\` / \`defaultFraction\` 会被- 拒装。两种形态的面板代码完全一样(同一 panel.html,供片/主题/媒体规则不变),- 只是宿主容器不同;页签形态请把界面做成自适应宽度;+ 用户想放右边可自己拖拽换位);\`"tab"\` = **插件页内的独占面板**——由插件页+ 自己承载(不进右侧栏页签容器):用户在插件页点你这张卡的「使用」按钮打开,+ 同一时刻至多一个,**用户离开插件页即关闭卸载**(面板收束,2026-08-02 定案:+ 插件面板不再常驻右侧栏干扰其它会话)。装入时勾选「立即开启并打开面板」会+ 在装完后进入插件页并打开你的面板;不勾选则由用户之后自己从插件页点「使用」。+ 停用/卸载插件同样立即关闭面板。页签形态没有拖缝宽度语义,声明 \`minWidth\` /+ \`defaultFraction\` 会被拒装。两种形态的面板代码完全一样(同一 panel.html,+ 供片/主题/媒体规则不变),只是宿主容器不同;此形态请把界面做成自适应宽度,+ 并且**不要假设自己会在后台长期存活**——每次打开都可能是全新加载,状态要+ 自己持久化(见 §4.6 的偏好存储);- 停靠形态的**标题条(标准头)由主机绘制**:标题(\`panel.title\`)+ 一批系统按钮(当前:「撑满内容区」、「在独立窗口中打开」——用户可把你的面板抽进自己的 OS 窗口,关窗/合并即回停靠原位——以及「最小化为浮动气泡」——用户@@ -2866,8 +2869,8 @@ if (r.ok && r.confirmed) {也长在这里)。你的 panel.html 只画标题条以下的部分,**不要自己再画一条标题栏**。不想要某颗系统按钮时在身份卡声明\`"systemButtons": { "maximize": false, "detach": false, "minimize": false }\`- 逐个关闭(缺省全开;标题条本体关不掉;未知键拒装;\`position:"tab"\` 没有- 标准头,声明本字段拒装);+ 逐个关闭(缺省全开;标题条本体关不掉;未知键拒装;\`position:"tab"\` 由插件页+ 自绘头,没有这套标准头,声明本字段拒装);- 与电子脑同源,用 \`BroadcastChannel('<自定名>')\` 通信(电子脑发,面板收);- 取自己的媒体:\`cindy-ghost://<id>/media/<指纹><后缀>\`(主机查账验归属,别人的图 404);- 重启回放:\`fetch('cindy-ghost://<id>/gallery')\` 返回本意识作品清单 \`[{src, caption}]\`;@@ -2981,7 +2984,7 @@ if (r.ok && r.confirmed) {或用 $command 点名;AI 工具调用不受影响(见 §2 说明)- 声明了 tool 槽但缺 tools(或反之)· panel.html 声明了但 slots 没有 "panel"- settingsHtml 路径不合法/文件不在包里 · settingsHeight 越界(160–800)或没配 settingsHtml 单独声明-- panel.systemButtons 格式错(不是对象、未知键、值非布尔,或 position:"tab" 时声明——页签形态没有标准头)+- panel.systemButtons 格式错(不是对象、未知键、值非布尔,或 position:"tab" 时声明——插件页内面板没有标准头)- keywords(已废弃字段,旧包兼容保留,新意识别写)有单字词 · kind 写了但不是 "chip"(可省略) · schemaVersion 不是 2- cindy 详单格式错(未知类目/动作、空数组、有详单但 slots 没有 "cindy")- agent 详单格式错(有详单但 slots 没有 "agent",或 background / errand 都不是 true;只需点击触发时应省略 agent 字段)diff --git a/apps/desktop/src/renderer/cindy-brain/ghostPanelBody.tsx b/apps/desktop/src/renderer/cindy-brain/ghostPanelBody.tsxindex 26e55f6c2d..34a27944f5 100644--- a/apps/desktop/src/renderer/cindy-brain/ghostPanelBody.tsx+++ b/apps/desktop/src/renderer/cindy-brain/ghostPanelBody.tsx@@ -15,7 +15,7 @@ import { GHOST_SCHEME, ghostPartition, type GhostManifest } from '../../shared/gimport { createGhostThemeInjector, observeHostTheme } from './ghostPanelTheme';/**- * 意识面板体(webview 供片)—— 顶层停靠 pane(ghostPanels)与右侧栏页签+ * 意识面板体(webview 供片)—— 顶层停靠 pane(ghostPanels)与插件页内面板* (features/plugin/GhostPagePanelHost)共用的渲染内核,从 ghostPanels.tsx 原样抽出:* 沙箱 webview 装载、主题注入、崩溃接管、媒体右键菜单,全部与宿主容器无关。* 安全边界不变:分区/地址由 main 侧 webview 附加闸验明正身(webview-security),diff --git a/apps/desktop/src/renderer/features/plugin/UpdateAllDialog.tsx b/apps/desktop/src/renderer/features/plugin/UpdateAllDialog.tsxindex 1149ce7982..638d1fd441 100644--- a/apps/desktop/src/renderer/features/plugin/UpdateAllDialog.tsx+++ b/apps/desktop/src/renderer/features/plugin/UpdateAllDialog.tsx@@ -133,14 +133,32 @@ export function UpdateAllDialog({<>{' · '}<span className="text-[var(--text-primary)]">- {t('settings.ghosts.updateAll.permissionChanged')}+ {t(+ row.staleReview+ ? 'settings.ghosts.updateAll.reviewOutdated'+ : 'settings.ghosts.updateAll.permissionChanged',+ )}</span></>) : null}</p></div><div className="flex shrink-0 items-center gap-2">- {row.status === 'needs-confirm' ? (+ {row.status === 'needs-confirm' && row.staleReview ? (+ // 旧差异已随外部更新失效:点这里让控制器重新取详情重算,+ // 权限没扩张就直接更新,仍有扩张则回到逐项审阅。+ <button+ type="button"+ onClick={() => onApprove(row.pluginId)}+ className={cn(+ 'inline-flex h-7 items-center rounded-full border border-[var(--border-default)] px-3 text-12 font-medium text-[var(--text-primary)]',+ 'transition-colors duration-150 hover:bg-[var(--surface-hover-soft)]',+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',+ )}+ >+ {t('settings.ghosts.updateAll.rereview')}+ </button>+ ) : row.status === 'needs-confirm' ? (<buttontype="button"aria-expanded={expanded}diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/updateAllController.test.ts b/apps/desktop/src/renderer/features/plugin/__tests__/updateAllController.test.tsindex b726920c43..c751d9948b 100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/updateAllController.test.ts+++ b/apps/desktop/src/renderer/features/plugin/__tests__/updateAllController.test.ts@@ -160,6 +160,69 @@ describe('updateAllController', () => {expect(installMock).not.toHaveBeenCalled();});+ it('recomputes the diff when an external update moved the installed version', async () => {+ stubDetail({+ manifest: manifest({ network: { hosts: ['api.example.com'] } }),+ sourceType: 'server',+ });+ startUpdateAllBatch([marketItem({})]);+ await waitForSettledBatch();+ expect(getUpdateAllBatchState().rows?.[0]?.status).toBe('needs-confirm');++ // 「从文件更新」把插件装成了第三个版本,且它已自带原先要审的 network 权限:+ // 审阅过的 diff 与 allowPermissionExpansion 都不再对应现实。+ installedGhosts = [+ { manifest: manifest({ version: '1.0.5', network: { hosts: ['api.example.com'] } }) },+ ];+ reconcileUpdateAllBatch();+ const held = getUpdateAllBatchState().rows?.[0];+ expect(held).toMatchObject({ status: 'needs-confirm', staleReview: true, fromVersion: '1.0.5' });+ expect(held?.permissionDiff).toBeUndefined();++ await approveUpdateExpansion('plugin-a');+ // 相对当前已装 manifest 已无扩权 → 按普通更新安装,不带 allowPermissionExpansion。+ expect(installMock).toHaveBeenCalledWith('plugin-a', { expectedReleaseId: 'release-2' });+ expect(getUpdateAllBatchState().rows?.[0]?.status).toBe('done');+ });++ it('keeps the row held for re-review when the recomputed diff still expands permissions', async () => {+ stubDetail({+ manifest: manifest({ network: { hosts: ['api.example.com'] } }),+ sourceType: 'server',+ });+ startUpdateAllBatch([marketItem({})]);+ await waitForSettledBatch();++ // 外部装成第三个版本,但仍不含目标版本要新增的 network 权限。+ installedGhosts = [{ manifest: manifest({ version: '1.0.5' }) }];+ reconcileUpdateAllBatch();+ await approveUpdateExpansion('plugin-a');++ const row = getUpdateAllBatchState().rows?.[0];+ expect(row).toMatchObject({ status: 'needs-confirm', staleReview: false, fromVersion: '1.0.5' });+ expect(row?.permissionDiff?.added.length).toBeGreaterThan(0);+ // 重算后仍是扩权:必须回到用户逐项审阅,绝不静默放行。+ expect(installMock).not.toHaveBeenCalled();+ });++ it('recomputes on version drift even before reconcile flagged the row', async () => {+ stubDetail({+ manifest: manifest({ network: { hosts: ['api.example.com'] } }),+ sourceType: 'server',+ });+ startUpdateAllBatch([marketItem({})]);+ await waitForSettledBatch();++ // 外部更新已落地但 reconcile 还没跑(竞态窗口):版本比较必须兜住,+ // 不得拿旧 diff 换来的 allowPermissionExpansion 安装。+ installedGhosts = [+ { manifest: manifest({ version: '1.0.5', network: { hosts: ['api.example.com'] } }) },+ ];+ await approveUpdateExpansion('plugin-a');++ expect(installMock).toHaveBeenCalledWith('plugin-a', { expectedReleaseId: 'release-2' });+ });+it('voids the batch when the data owner changes during the detail round-trip', async () => {let releaseDetail: (() => void) | undefined;detailMock.mockImplementation(diff --git a/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts b/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.tsindex ea581a38c8..e407b17668 100644--- a/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts+++ b/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts@@ -23,7 +23,7 @@ export interface GhostPluginListItem {version: string;enabled: boolean;canUse: boolean;- /** 声明了右侧栏页签面板(panel.position:'tab'),主动作为「使用」(打开面板)。 */+ /** 声明了插件页内独占面板(panel.position:'tab'),主动作为「使用」(打开面板)。 */tabPanel: boolean;trust?: GhostTrustInfo;iconDataUrl?: string;diff --git a/apps/desktop/src/renderer/features/plugin/lib/updateAllController.ts b/apps/desktop/src/renderer/features/plugin/lib/updateAllController.tsindex a6e9950cef..0ca45e63fc 100644--- a/apps/desktop/src/renderer/features/plugin/lib/updateAllController.ts+++ b/apps/desktop/src/renderer/features/plugin/lib/updateAllController.ts@@ -210,12 +210,41 @@ export async function approveUpdateExpansion(pluginId: string): Promise<void> {}patchRow(pluginId, { status: 'installing' });try {- await window.electronAPI.pluginMarket.install(pluginId, {- expectedReleaseId: row.releaseId,- ...(row.expectedManifest ? { expectedManifest: row.expectedManifest } : {}),- allowPermissionExpansion: true,- });- patchRow(pluginId, { status: 'done' });+ // 用户审阅的是「fromVersion → toVersion」这一段的权限差异。等待期间若被+ // 「从文件更新」等外部路径装成了别的版本,那份 diff 与它换来的+ // allowPermissionExpansion 就不再对应现实——重新取详情、以当前已装+ // manifest 重算,权限没扩张就按普通更新装,扩张面变了则退回待确认重审。+ // 判据是 staleReview(reconcile 打的标)并联版本比较:reconcile 会把+ // fromVersion 同步成当前版本供展示,那之后版本比较恒等,靠标志识别;+ // reconcile 还没来得及跑的竞态窗口里,版本比较兜底。+ if (row.staleReview === true || installed.version !== row.fromVersion) {+ const detail = await window.electronAPI.pluginMarket.detail(pluginId);+ const freshDiff = diffGhostPermissionItems(installed, detail.manifest);+ if (freshDiff.added.length > 0) {+ patchRow(pluginId, {+ status: 'needs-confirm',+ fromVersion: installed.version,+ toVersion: detail.version,+ releaseId: detail.releaseId,+ permissionDiff: freshDiff,+ staleReview: false,+ expectedManifest: detail.sourceType !== 'server' ? detail.manifest : undefined,+ });+ return;+ }+ await window.electronAPI.pluginMarket.install(pluginId, {+ expectedReleaseId: detail.releaseId,+ ...(detail.sourceType !== 'server' ? { expectedManifest: detail.manifest } : {}),+ });+ patchRow(pluginId, { status: 'done', fromVersion: installed.version });+ } else {+ await window.electronAPI.pluginMarket.install(pluginId, {+ expectedReleaseId: row.releaseId,+ ...(row.expectedManifest ? { expectedManifest: row.expectedManifest } : {}),+ allowPermissionExpansion: true,+ });+ patchRow(pluginId, { status: 'done' });+ }} catch (error) {patchRow(pluginId, { status: 'failed', errorText: i18n.t(pluginMarketErrorKey(error)) });}@@ -237,7 +266,9 @@ export function skipUpdateExpansion(pluginId: string): void {/*** 与外部事实对账:账号切换 → 整批作废;待确认行的插件被卸载 → 跳过、- * 已被单项/文件更新装到目标版本 → 记为完成(不再提供重复安装入口)。+ * 已被单项/文件更新装到目标版本 → 记为完成(不再提供重复安装入口)、+ * 被装成别的版本 → 旧 permissionDiff 已不对应现实,清掉并标记待重审+ * (真正的重算在 approve 时做,那里能取详情)。* 页面在已装清单或身份变化时调用。*/export function reconcileUpdateAllBatch(): void {@@ -257,6 +288,13 @@ export function reconcileUpdateAllBatch(): void {} else if (installed.version === row.toVersion) {rows = updateRow(rows, row.pluginId, { status: 'done' });changed = true;+ } else if (installed.version !== row.fromVersion) {+ rows = updateRow(rows, row.pluginId, {+ fromVersion: installed.version,+ permissionDiff: undefined,+ staleReview: true,+ });+ changed = true;}}if (changed) {diff --git a/apps/desktop/src/renderer/features/plugin/lib/updateAllModel.ts b/apps/desktop/src/renderer/features/plugin/lib/updateAllModel.tsindex 1708b6cb33..33d6ece445 100644--- a/apps/desktop/src/renderer/features/plugin/lib/updateAllModel.ts+++ b/apps/desktop/src/renderer/features/plugin/lib/updateAllModel.ts@@ -33,6 +33,11 @@ export interface UpdateAllRow {releaseId?: string;/** 扩权详情(status 为 needs-confirm 时由运行器填充)。 */permissionDiff?: GhostPermissionDiff;+ /**+ * 待确认期间插件被外部路径(从文件更新等)装成了别的版本:审阅过的+ * 权限差异已不对应现实,弹窗提示"需要重新审阅",按钮点下去先重算再决定。+ */+ staleReview?: boolean;/*** 非 server 源在审阅时取得的 manifest:主进程对这类来源强制要求安装时* 传回同一份 reviewed manifest,approve 必须原样带上,否则 INVALID_PARAMS。diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 0b2b277e53..fb3761aec6 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -3521,6 +3521,8 @@"description": "Updates without permission changes finish automatically; permission expansions need your per-item approval.","versionRange": "v{{from}} → v{{to}}","permissionChanged": "Permissions changed",+ "reviewOutdated": "Permission diff outdated",+ "rereview": "Review again","reviewDiff": "Review & confirm","collapseDiff": "Collapse","approve": "Approve & update",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex fac9ae86e9..74815b4420 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -3520,6 +3520,8 @@"description": "権限に変更がない更新は自動で完了します。権限が拡張される更新は項目ごとに確認が必要です。","versionRange": "v{{from}} → v{{to}}","permissionChanged": "権限に変更あり",+ "reviewOutdated": "権限の差分が古くなりました",+ "rereview": "再確認","reviewDiff": "確認する","collapseDiff": "閉じる","approve": "同意して更新",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 07bdfa3c7d..8983e1df11 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -3520,6 +3520,8 @@"description": "권한 변경이 없는 업데이트는 자동으로 완료됩니다. 권한이 확장되는 업데이트는 항목별 확인이 필요합니다.","versionRange": "v{{from}} → v{{to}}","permissionChanged": "권한 변경됨",+ "reviewOutdated": "권한 변경 내역이 오래되었습니다",+ "rereview": "다시 검토","reviewDiff": "확인","collapseDiff": "접기","approve": "동의 후 업데이트",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex dc412dc0a8..b1b7af2306 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -3520,6 +3520,8 @@"description": "权限无变化的更新会自动完成;涉及权限变更的需要你逐项确认。","versionRange": "v{{from}} → v{{to}}","permissionChanged": "权限有变更",+ "reviewOutdated": "权限差异已过期",+ "rereview": "重新审阅","reviewDiff": "查看并确认","collapseDiff": "收起","approve": "同意并更新",diff --git a/apps/desktop/src/shared/ghost.ts b/apps/desktop/src/shared/ghost.tsindex 7814b45acc..710d81648c 100644--- a/apps/desktop/src/shared/ghost.ts+++ b/apps/desktop/src/shared/ghost.ts@@ -346,7 +346,8 @@ export type GhostPanelPosition = (typeof GHOST_PANEL_POSITIONS)[number];export interface GhostPanelDecl {/** 面板标准头(PanelChrome)标题;缺省用意识 name。 */title?: string;- /** 显示形态:left 停靠主聊天窗左侧(缺省),或 'tab' 右侧栏页签;+ /** 显示形态:left 停靠主聊天窗左侧(缺省),或 'tab' 插件页内独占面板+ * (2026-08-02 面板收束:只从插件页打开,离开插件页即关闭);* right 已退役并入 left(2026-07-25 Lizi 定案,见 GHOST_PANEL_POSITIONS 注释)。 */position?: GhostPanelPosition;/** 面板界面入口(安装目录内相对路径,意识自绘)。 */