Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(desktop): 补齐 #1243 验收遗漏——本地包免文件恢复、随包死路文案、隔离自愈点火

Yuewei-LL84307d4fdcee
diff --git a/apps/desktop/src/main/cindy-brain/GhostManager.ts b/apps/desktop/src/main/cindy-brain/GhostManager.ts
index f51efcc267..a01c9703cd 100644
--- a/apps/desktop/src/main/cindy-brain/GhostManager.ts
+++ b/apps/desktop/src/main/cindy-brain/GhostManager.ts
@@ -365,6 +365,151 @@ export class GhostManager {
return true;
}
+ /**
+ * 「从已装目录重新确认」第一步:只读出确认卡需要的事实,零副作用。
+ *
+ * 这是本地包批准丢失(一次性迁移之后 receipt 又损坏/被删)时的第三条恢复路径 ——
+ * 不用用户翻出原始 `.cindy` 文件,也不自动放行:字节从已装目录读,权限清单在确认卡
+ * 上**全量**展示(无批准基线,全部按新增项列),用户逐条看过点确认才开 receipt。
+ * 本地 `.cindy` 的运行字节本来就一直从这个可变目录现读(§7 登记),两条恢复路径的
+ * 差别只是字节来源,授权边界同样是那张确认卡。
+ *
+ * `manifestSha256` 是「确认卡展示的」与「confirm 时批准的」之间的字节绑定:renderer
+ * 原样回传,confirm 侧重读重算,对不上即拒 —— 与更新流程的 `expectedPackageSha256`
+ * 同形,防确认间隙里 ghost.json 被换(#636 的同类窗口)。
+ *
+ * 随包插件一律拒:它们的批准由 provisioning 与种子逐字节对账后自动补,重启即恢复,
+ * 不走人工确认(也不能走 —— 这条路的 trust 封顶在非官方档)。
+ */
+ inspectInstalledReapproval(
+ id: string,
+ ):
+ | { manifest: GhostManifest; trust: GhostTrustInfo; manifestSha256: string }
+ | { rejection: InstallRejection } {
+ if (!isValidGhostId(id) || this.options.isTrustedBundledId?.(id)) {
+ return { rejection: { code: 'file-invalid', reason: '该插件不支持从安装目录重新确认' } };
+ }
+ if (this.readApproval(id).state === 'approved') {
+ return { rejection: { code: 'state-changed', reason: '插件批准状态已恢复,无需重新确认' } };
+ }
+ const dir = path.join(this.options.getRootDir(), id);
+ let rawBytes: Buffer;
+ try {
+ rawBytes = fs.readFileSync(path.join(dir, GHOST_MANIFEST_FILE));
+ } catch (err) {
+ return {
+ rejection: {
+ code: 'not-installed',
+ reason: `安装目录里读不到清单:${err instanceof Error ? err.message : String(err)}`,
+ },
+ };
+ }
+ let parsed: unknown;
+ try {
+ parsed = JSON.parse(rawBytes.toString('utf8'));
+ } catch (err) {
+ return {
+ rejection: {
+ code: 'file-invalid',
+ reason: `清单不是合法 JSON:${err instanceof Error ? err.message : String(err)}`,
+ },
+ };
+ }
+ const validated = validateGhostManifest(parsed);
+ if (!validated.ok) return { rejection: { code: 'file-invalid', reason: validated.reason } };
+ if (validated.manifest.id !== id) {
+ return { rejection: { code: 'file-invalid', reason: '清单 id 与安装目录不一致' } };
+ }
+ const trust: GhostTrustInfo = readLegacyInstallTrust(dir) ?? {
+ level: 'unverified',
+ publisherSigned: false,
+ publisherVerified: false,
+ reviewed: false,
+ };
+ return {
+ manifest: validated.manifest,
+ trust,
+ manifestSha256: crypto.createHash('sha256').update(rawBytes).digest('hex'),
+ };
+ }
+
+ /**
+ * 「从已装目录重新确认」第二步:用户在确认卡上点了同意,据此开 receipt。
+ *
+ * 与迁移(`backfillLegacyApproval`)的本质区别:**这是一次真实的用户确认**(用户
+ * 刚看完全量权限清单),不受迁移 ledger 一次性门约束,来源记 `user-reapproval`。
+ * 与迁移的共同点:trust 走同一个封顶读取器、技能字节现算钉指纹、只写状态根。
+ */
+ async reapproveInstalled(
+ id: string,
+ opts: { enable: boolean; expectedManifestSha256: string; expectedInstalledApproval: string },
+ ): Promise<{ ghost: InstalledGhost } | { rejection: InstallRejection }> {
+ return this.runExclusiveMutation(() => this.reapproveInstalledUnlocked(id, opts));
+ }
+
+ private async reapproveInstalledUnlocked(
+ id: string,
+ opts: { enable: boolean; expectedManifestSha256: string; expectedInstalledApproval: string },
+ ): Promise<{ ghost: InstalledGhost } | { rejection: InstallRejection }> {
+ // 确认期间批准状态不得变过:与更新流程同款前置条件(token 由 Main 现读比对)。
+ const currentToken = ghostInstallApprovalToken(
+ this.list().find((g) => g.manifest.id === id)?.approval,
+ );
+ if (currentToken !== opts.expectedInstalledApproval || currentToken.startsWith('approved')) {
+ return {
+ rejection: { code: 'state-changed', reason: '插件批准状态在确认后发生了变化,请重新确认' },
+ };
+ }
+ // 重走只读检查(含随包拒收/清单校验),并绑定确认卡展示时的清单字节。
+ const inspected = this.inspectInstalledReapproval(id);
+ if ('rejection' in inspected) return inspected;
+ if (inspected.manifestSha256 !== opts.expectedManifestSha256) {
+ return {
+ rejection: { code: 'state-changed', reason: '插件清单在确认后发生了变化,请重新确认' },
+ };
+ }
+ const dir = path.join(this.options.getRootDir(), id);
+ try {
+ const localeResources = this.readApprovedLocaleResources(dir, inspected.manifest);
+ const iconDataUrl = this.readInstalledIconDataUrl(dir, inspected.manifest) ?? undefined;
+ const skillContentSha256 = await hashApprovedSkillContent(inspected.manifest, dir);
+ await this.receiptStore.write(
+ createGhostInstallReceipt({
+ manifest: inspected.manifest,
+ localeResources,
+ enabled: opts.enable,
+ trust: inspected.trust,
+ skillContentSha256,
+ ...(iconDataUrl !== undefined ? { iconDataUrl } : {}),
+ }),
+ { skillSourceDir: dir },
+ );
+ } catch (err) {
+ return {
+ rejection: { code: 'io', reason: err instanceof Error ? err.message : String(err) },
+ };
+ }
+ this.untrustedApprovals.delete(id);
+ // 与 setEnabled 同款:启停镜像同步维护,回滚到旧客户端不错位。
+ try {
+ const marker = path.join(dir, DISABLED_MARKER_FILE);
+ if (opts.enable) await fs.promises.rm(marker, { force: true });
+ else await fs.promises.writeFile(marker, '');
+ } catch {
+ // 镜像写不动不影响批准事实;receipt 是权威。
+ }
+ this.options.log?.info('ghost reapproved from installed dir', {
+ id,
+ enabled: opts.enable,
+ trustLevel: inspected.trust.level,
+ origin: 'user-reapproval',
+ });
+ const ghost = this.list().find((g) => g.manifest.id === id);
+ if (!ghost) return { rejection: { code: 'io', reason: '重新确认后读不到插件清单' } };
+ this.options.onChanged?.(this.list());
+ return { ghost };
+ }
+
/** 扫描已装意识(同步 —— renderer 首帧 sendSync 拉取,目录极小不卡启动)。 */
list(): InstalledGhost[] {
const root = this.options.getRootDir();
@@ -403,6 +548,7 @@ export class GhostManager {
}
: {}),
...(receipt.iconDataUrl !== undefined ? { iconDataUrl: receipt.iconDataUrl } : {}),
+ ...(this.options.isTrustedBundledId?.(entry.name) ? { builtin: true } : {}),
});
continue;
}
@@ -447,6 +593,7 @@ export class GhostManager {
enabled: false,
approval: { state: approvalResult.state },
...(iconDataUrl !== null ? { iconDataUrl } : {}),
+ ...(this.options.isTrustedBundledId?.(entry.name) ? { builtin: true } : {}),
});
}
result.sort((a, b) => a.manifest.id.localeCompare(b.manifest.id));
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/GhostManager.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/GhostManager.test.ts
index c36e8007b4..491cde2e6c 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/GhostManager.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/GhostManager.test.ts
@@ -315,6 +315,30 @@ describe('GhostManager · 存量插件一次性迁移(§5 升级无感)', () =>
expect(fs.existsSync(path.join(workDir, 'ghosts-install-state', 'hello.json'))).toBe(false);
});
+ it('首轮迁移治愈损坏/旧 schema 的 receipt(格式升级不落到用户重新确认)', async () => {
+ // issue #1243 验收第 4 条的实现形态:schema/编码 bump 后的旧 receipt 判 invalid,
+ // 但**首轮迁移**会把它当"已判损坏"从安装目录 backfill 重建 —— 一次内部格式变更
+ // 不变成用户重新确认。v1 receipt 从未随任何构建发布,所以不需要专门的 v1 读取器;
+ // 未来的 bump 走 §5 的「按旧编码核对 → 原地升级」,见规则文档。
+ await writeLegacyInstall('hello', goodManifest(), { disabled: true });
+ const stateDir = path.join(workDir, 'ghosts-install-state');
+ await fs.promises.mkdir(stateDir, { recursive: true });
+ // 一份 schemaVersion 过时的 receipt(读取器判 invalid)。
+ await fs.promises.writeFile(
+ path.join(stateDir, 'hello.json'),
+ JSON.stringify({ schemaVersion: 1, id: 'hello', legacy: true }),
+ );
+ expect(manager.list()[0].approval.state).toBe('invalid');
+
+ const outcome = await manager.migrateLegacyApprovalsOnce();
+ expect(outcome.migrated).toEqual(['hello']);
+ // 治愈后为有效批准;用户的停用决定(.disabled)照旧保留。
+ expect(manager.list()[0]).toMatchObject({
+ enabled: false,
+ approval: { state: 'approved' },
+ });
+ });
+
it('已有 receipt 的安装不被迁移覆盖(迁移只补,不改既有批准)', async () => {
await manager.install(await makeCindy('a.cindy', goodManifest()));
const before = await fs.promises.readFile(
@@ -344,6 +368,82 @@ describe('GhostManager · 存量插件一次性迁移(§5 升级无感)', () =>
});
});
+describe('GhostManager · 从已装目录重新确认(本地包第三条恢复路径)', () => {
+ it('批准丢失后不用原始 .cindy:inspect 出全量清单,确认后开 receipt、恢复可用', async () => {
+ // 场景:迁移已跑过(ledger 在),之后 receipt 又被删 —— 一次性门不再迁移,
+ // 本地包用户没有市场路线;第三条路必须能不找文件恢复。
+ await writeLegacyInstall('hello', goodManifest());
+ await manager.migrateLegacyApprovalsOnce();
+ await fs.promises.rm(path.join(workDir, 'ghosts-install-state', 'hello.json'));
+ expect(manager.list()[0].approval.state).toBe('legacy-unapproved');
+
+ const inspected = manager.inspectInstalledReapproval('hello');
+ if ('rejection' in inspected) throw new Error(JSON.stringify(inspected.rejection));
+ expect(inspected.manifest.id).toBe('hello');
+ expect(inspected.manifestSha256).toMatch(/^[a-f0-9]{64}$/);
+
+ const result = await manager.reapproveInstalled('hello', {
+ enable: true,
+ expectedManifestSha256: inspected.manifestSha256,
+ expectedInstalledApproval: 'legacy-unapproved',
+ });
+ if ('rejection' in result) throw new Error(JSON.stringify(result.rejection));
+ expect(manager.list()[0]).toMatchObject({ enabled: true, approval: { state: 'approved' } });
+ // 启停镜像同步维护(回滚到旧客户端不错位)。
+ expect(fs.existsSync(path.join(rootDir, 'hello', '.disabled'))).toBe(false);
+ });
+
+ it('确认间隙 ghost.json 被换 → 拒(确认卡展示的与批准的必须是同一份字节)', async () => {
+ await writeLegacyInstall('hello', goodManifest());
+ const inspected = manager.inspectInstalledReapproval('hello');
+ if ('rejection' in inspected) throw new Error(JSON.stringify(inspected.rejection));
+
+ // 攻击窗口:用户看的是权限集 A,confirm 落地前清单被换成声明更多权限的 B。
+ await fs.promises.writeFile(
+ path.join(rootDir, 'hello', 'ghost.json'),
+ JSON.stringify({ ...goodManifest(), slots: ['tool', 'skill'], skill: { items: [{ dir: 'skills/x', name: 'x', description: 'x' }] } }),
+ );
+ const result = await manager.reapproveInstalled('hello', {
+ enable: true,
+ expectedManifestSha256: inspected.manifestSha256,
+ expectedInstalledApproval: 'legacy-unapproved',
+ });
+ expect('rejection' in result && result.rejection.code).toBe('state-changed');
+ expect(manager.list()[0].approval.state).toBe('legacy-unapproved');
+ });
+
+ it('随包插件拒走人工重新确认(由启动对账自动补批准)', async () => {
+ const guarded = new GhostManager({
+ getRootDir: () => rootDir,
+ getLocale: () => hostLocale,
+ isTrustedBundledId: (id) => id === 'hello',
+ });
+ await writeLegacyInstall('hello', goodManifest());
+ const inspected = guarded.inspectInstalledReapproval('hello');
+ expect('rejection' in inspected && inspected.rejection.code).toBe('file-invalid');
+ });
+
+ it('已是 approved 的插件拒重复确认(不给覆盖既有批准开口子)', async () => {
+ await manager.install(await makeCindy('a.cindy', goodManifest()));
+ const inspected = manager.inspectInstalledReapproval('hello');
+ expect('rejection' in inspected && inspected.rejection.code).toBe('state-changed');
+ });
+
+ it('信任镜像自称 cindy-official 一律封顶拒收(非随包目录不可能合法持有官方档)', async () => {
+ await writeLegacyInstall('hello', goodManifest(), {
+ trust: {
+ level: 'cindy-official',
+ publisherSigned: true,
+ publisherVerified: true,
+ reviewed: true,
+ },
+ });
+ const inspected = manager.inspectInstalledReapproval('hello');
+ if ('rejection' in inspected) throw new Error(JSON.stringify(inspected.rejection));
+ expect(inspected.trust.level).toBe('unverified');
+ });
+});
+
describe('GhostManager · install', () => {
it('按宿主语言返回本地化清单,切换语言后 list 立即更新,不支持语言固定回退英文', async () => {
const manifest = {
diff --git a/apps/desktop/src/main/cindy-brain/ghostInstallReceipt.ts b/apps/desktop/src/main/cindy-brain/ghostInstallReceipt.ts
index b8443fa55e..7ab6665ea7 100644
--- a/apps/desktop/src/main/cindy-brain/ghostInstallReceipt.ts
+++ b/apps/desktop/src/main/cindy-brain/ghostInstallReceipt.ts
@@ -408,13 +408,20 @@ export class GhostInstallReceiptStore {
* 缺失/损坏/非普通文件一律返回 `null` —— trust 只是**展示与来源信号**(能力由 manifest
* slot 授予,不由 trust 等级授予),读不出时调用方用保守默认(`unverified`)而不是让整个
* 迁移失败:旧模型读的也是同一个文件,缺了同样显示不出 verified,不比旧模型少展示什么。
+ *
+ * `cindy-official` 一律**封顶拒收**(按镜像损坏处理):官方档只该由 provisioning 在与
+ * 随包种子逐字节对账后授予,而本函数的两个调用方(legacy 迁移 / 从已装目录重新确认)都
+ * 只服务非随包插件 —— 非随包目录里出现官方档镜像本身就不可信,照抄会让确认卡/列表把
+ * 一个可变目录里的插件展示成「Cindy 官方」。
*/
export function readLegacyInstallTrust(dir: string): GhostTrustInfo | null {
const file = path.join(dir, '.cindy-trust.json');
try {
const stat = fs.lstatSync(file);
if (!stat.isFile() || stat.size > MAX_RECEIPT_BYTES) return null;
- return validateTrust(JSON.parse(fs.readFileSync(file, 'utf8')));
+ const trust = validateTrust(JSON.parse(fs.readFileSync(file, 'utf8')));
+ if (!trust || trust.level === 'cindy-official') return null;
+ return trust;
} catch {
return null;
}
diff --git a/apps/desktop/src/main/cindy-brain/index.ts b/apps/desktop/src/main/cindy-brain/index.ts
index efc169f784..bb669c1c84 100644
--- a/apps/desktop/src/main/cindy-brain/index.ts
+++ b/apps/desktop/src/main/cindy-brain/index.ts
@@ -627,6 +627,18 @@ function currentProvisionIdentity(): ProvisionIdentity | null {
*/
let builtinReconcileChain: Promise<void> = Promise.resolve();
+/**
+ * 本会话内因「撤销陈旧批准」被熄灯的常驻随包插件 id。
+ *
+ * 撤销路径的四连熄灯会把正在跑的常驻实例停掉;后一轮对账把批准补回来时,原判
+ * (#1080)是不自动重启 —— 那时缺少"用户此刻想让它跑"的信号。但对**本会话内被
+ * 我们自己熄掉**的常驻声明插件,重启只是恢复熄灯前的既有状态,不是新决策;常驻
+ * 声明本身就是"启用即应运行"的意思(启动扫描无条件点火)。范围刻意收窄:只记
+ * 本会话、只记常驻声明、点火仍走 spawnIfResident(它自查启用态与会话可用性,
+ * 停用的插件不会被点亮)。
+ */
+const quenchedResidentBuiltinIds = new Set<string>();
+
function scheduleBuiltinReconcile(reason: string): Promise<boolean> {
const scheduled = builtinReconcileChain
.catch((err) => {
@@ -816,6 +828,7 @@ async function reconcileBuiltinGhostsLocked(
}
}
let approvalChanged = false;
+ const healedResidentIds: string[] = [];
for (const manifest of outcome.approved) {
try {
approvalChanged =
@@ -826,6 +839,11 @@ async function reconcileBuiltinGhostsLocked(
// 头注释;重新启用只有用户显式 setEnabled 一条路)。
!fs.existsSync(path.join(brainRootDir(), manifest.id, '.disabled')),
)) || approvalChanged;
+ // 本会话内被撤销熄灯的常驻实例,批准补回即恢复点火(隔离态下批准必然重写,
+ // approvalChanged 已为 true,不会被下面的 no-op 早退拦住)。
+ if (quenchedResidentBuiltinIds.delete(manifest.id)) {
+ healedResidentIds.push(manifest.id);
+ }
} catch (err) {
// 走到这里内容目录可能已经换成新种子字节,旧 receipt 却还是授权事实 ——
// 留着它就是拿旧批准跑新代码(新版删掉的 slot 仍被授予、版本与技能快照
@@ -846,6 +864,10 @@ async function reconcileBuiltinGhostsLocked(
getGhostNodeRuntimeBroker().stop(manifest.id);
getGhostAgentSlot().clearGhost(manifest.id);
getGhostErrandSlot().clearGhost(manifest.id);
+ // 常驻声明的实例被本次撤销熄掉:记下 id,批准自愈那一轮补点火(见 set 头注释)。
+ if (manifest.launch === 'resident' || manifest.node?.lifecycle === 'resident') {
+ quenchedResidentBuiltinIds.add(manifest.id);
+ }
approvalChanged = true;
log.warn('builtin ghost approval receipt failed; approval revoked', {
id: manifest.id,
@@ -887,6 +909,12 @@ async function reconcileBuiltinGhostsLocked(
const ghost = manager.list().find((g) => g.manifest.id === manifest.id);
if (ghost) spawnIfResident(ghost);
}
+ // 本会话内被撤销熄灯、本轮批准自愈的常驻插件:恢复熄灯前的运行状态。
+ // spawnIfResident 自查启用态与会话可用性,停用/不可用的不会被点亮。
+ for (const id of healedResidentIds) {
+ const ghost = manager.list().find((g) => g.manifest.id === id);
+ if (ghost) spawnIfResident(ghost);
+ }
}
export function getGhostManager(): GhostManager {
@@ -4074,6 +4102,61 @@ export function registerGhostIpc(): void {
return { filePath: takePendingCindyInstall() };
});
+ // 本地包第三条恢复路径第一步:从**已装目录**读出确认卡事实,零副作用。
+ // 批准丢失(迁移后 receipt 又损坏/被删)时不用用户翻出原始 .cindy —— 字节从安装
+ // 目录读,权限清单全量展示,确认后由 ghosts:reapprove-installed 开 receipt。
+ ipcMain.handle('ghosts:reapprove-inspect', (event, id: unknown) => {
+ assertTrustedAppRendererEvent(event);
+ if (typeof id !== 'string' || id.trim().length === 0) {
+ throwIpcError('INVALID_PARAMS', 'id must be a non-empty string');
+ }
+ const result = manager.inspectInstalledReapproval(id);
+ if ('rejection' in result) throwInstallError(result.rejection);
+ return result;
+ });
+
+ // 第三条恢复路径第二步:用户点过确认卡后开 receipt。expectedManifestSha256 绑定
+ // 「确认卡展示的」与「此刻批准的」清单字节(与更新流程 expectedPackageSha256 同形),
+ // expectedInstalledApproval 防确认期间批准状态被并发改写。
+ ipcMain.handle('ghosts:reapprove-installed', async (event, id: unknown, opts: unknown) => {
+ assertTrustedAppRendererEvent(event);
+ if (typeof id !== 'string' || id.trim().length === 0) {
+ throwIpcError('INVALID_PARAMS', 'id must be a non-empty string');
+ }
+ const options = opts as
+ | { enable?: unknown; expectedManifestSha256?: unknown; expectedInstalledApproval?: unknown }
+ | undefined;
+ if (typeof options?.enable !== 'boolean') {
+ throwIpcError('INVALID_PARAMS', 'enable must be a boolean');
+ }
+ if (
+ typeof options.expectedManifestSha256 !== 'string' ||
+ !/^[a-f0-9]{64}$/.test(options.expectedManifestSha256)
+ ) {
+ throwIpcError('INVALID_PARAMS', 'expectedManifestSha256 must come from ghosts:reapprove-inspect');
+ }
+ if (!isGhostInstallApprovalToken(options.expectedInstalledApproval)) {
+ throwIpcError('INVALID_PARAMS', 'expectedInstalledApproval must come from ghosts:list');
+ }
+ const result = await manager.reapproveInstalled(id, {
+ enable: options.enable,
+ expectedManifestSha256: options.expectedManifestSha256,
+ expectedInstalledApproval: options.expectedInstalledApproval,
+ });
+ if ('rejection' in result) throwInstallError(result.rejection);
+ // 与装入/更新同款收尾:面板停靠(已有位置则 no-op)+ 常驻点火。
+ const store = getLayoutStore();
+ const docked = layoutWithGhostPanel(store.getLayout(), result.ghost.manifest);
+ if (docked) {
+ const applied = store.setLayout(docked);
+ if ('rejection' in applied) {
+ log.warn('ghost panel dock rejected', { id: result.ghost.manifest.id, reason: applied.rejection });
+ }
+ }
+ spawnIfResident(result.ghost);
+ return { ghost: result.ghost };
+ });
+
// 只验不装:读出 .cindy 的清单给确认弹窗展示,零副作用。
ipcMain.handle('ghosts:inspect', async (event, lizFilePath: unknown) => {
assertTrustedAppRendererEvent(event);
diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.ts
index c6920eb1cf..b2695461fa 100644
--- a/apps/desktop/src/preload/preload.ts
+++ b/apps/desktop/src/preload/preload.ts
@@ -902,6 +902,18 @@ contextBridge.exposeInMainWorld('electronAPI', {
iconDataUrl?: string;
}> =>
ipcRenderer.invoke('ghosts:inspect', lizFilePath),
+ /** 本地包第三条恢复路径:从已装目录读确认卡事实(零副作用)。 */
+ reapproveInspect: (id: string): Promise<{
+ manifest: unknown;
+ trust: unknown;
+ manifestSha256: string;
+ }> => ipcRenderer.invoke('ghosts:reapprove-inspect', id),
+ /** 确认卡点过同意后开 receipt;sha 绑定确认卡展示时的清单字节。 */
+ reapproveInstalled: (
+ id: string,
+ opts: { enable: boolean; expectedManifestSha256: string; expectedInstalledApproval: string },
+ ): Promise<{ ghost: unknown }> =>
+ ipcRenderer.invoke('ghosts:reapprove-installed', id, opts),
uninstall: (id: string): Promise<{ ok: true }> => ipcRenderer.invoke('ghosts:uninstall', id),
/** 详情页「导出 .cindy」:main 打包安装目录 → 系统保存对话框落盘。 */
export: (id: string): Promise<{ status: 'saved'; savedPath: string } | { status: 'canceled' }> =>
diff --git a/apps/desktop/src/renderer/cindy-brain/__tests__/ghostPluginViewModel.test.ts b/apps/desktop/src/renderer/cindy-brain/__tests__/ghostPluginViewModel.test.ts
index 41a821e0d8..b7bfcb3065 100644
--- a/apps/desktop/src/renderer/cindy-brain/__tests__/ghostPluginViewModel.test.ts
+++ b/apps/desktop/src/renderer/cindy-brain/__tests__/ghostPluginViewModel.test.ts
@@ -103,6 +103,7 @@ describe('ghostPluginViewModel', () => {
enabled: true,
canUse: true,
approvalState: 'approved',
+ builtin: false,
},
{
id: 'lizi-mivo',
@@ -112,6 +113,7 @@ describe('ghostPluginViewModel', () => {
enabled: true,
canUse: true,
approvalState: 'approved',
+ builtin: false,
},
{
id: 'slack',
@@ -121,6 +123,7 @@ describe('ghostPluginViewModel', () => {
enabled: true,
canUse: true,
approvalState: 'approved',
+ builtin: false,
},
] satisfies GhostPluginListItem[];
diff --git a/apps/desktop/src/renderer/cindy-brain/installFlow.tsx b/apps/desktop/src/renderer/cindy-brain/installFlow.tsx
index fd1aea7c44..86d5f28407 100644
--- a/apps/desktop/src/renderer/cindy-brain/installFlow.tsx
+++ b/apps/desktop/src/renderer/cindy-brain/installFlow.tsx
@@ -226,6 +226,77 @@ export async function confirmAndInstallGhost(
}
}
+/**
+ * 「重新确认权限」的本地包路线:**从已装目录**读出全量权限清单 → 确认 → 开 receipt。
+ * 不用用户翻出原始 `.cindy` 文件(#1243 验收:本地包不存在不可恢复状态)。
+ *
+ * 授权边界仍是这张确认卡:无批准基线,权限**全量**按新增项展示(GhostInstallReview),
+ * 与"重新选包"路线看到的是同一张卡,差别只是字节从安装目录读。清单字节以
+ * manifestSha256 绑定到 confirm(确认间隙 ghost.json 被换 → main 拒 state-changed)。
+ *
+ * 安装目录读不出/清单不合法时回退到「重新选包」路线 —— 目录坏了才需要用户找文件,
+ * 目录完好时一次点击即恢复。
+ */
+export async function reapproveInstalledGhost(ghostId: string, deps: InstallFlowDeps): Promise<void> {
+ const { t, confirmWithCheckbox } = deps;
+ const installed = findInstalled(ghostId);
+ if (!installed) {
+ toast.error(t('settings.ghosts.errors.generic'));
+ return;
+ }
+ let manifest: GhostManifest;
+ let trust: GhostTrustInfo;
+ let manifestSha256: string;
+ try {
+ const inspected = await window.electronAPI.ghosts.reapproveInspect(ghostId);
+ manifest = inspected.manifest;
+ trust = inspected.trust;
+ manifestSha256 = inspected.manifestSha256;
+ } catch (err) {
+ // 安装目录读不出清单 = 只剩"重新选包"一条路;如实降级,不吞掉恢复机会。
+ installFlowLog.warn('reapprove-inspect failed; falling back to file picker', {
+ ghostId,
+ err,
+ });
+ await pickAndUpdateGhost(ghostId, deps);
+ return;
+ }
+ const factsLine = manifest.author
+ ? t('settings.ghosts.installConfirm.metaWithAuthor', {
+ author: manifest.author,
+ version: manifest.version,
+ })
+ : t('settings.ghosts.installConfirm.meta', { version: manifest.version });
+ const { ok, checked: enable } = await confirmWithCheckbox({
+ title: t('settings.ghosts.reapproveConfirm.title', { name: manifest.name }),
+ description: t('settings.ghosts.reapproveConfirm.body'),
+ content: (
+ <GhostInstallReview
+ description={manifest.description}
+ meta={factsLine}
+ trust={trust}
+ items={ghostPermissionItems(manifest)}
+ />
+ ),
+ maxWidth: GHOST_CONFIRM_MAX_WIDTH,
+ confirmText: t('settings.ghosts.reapproveConfirm.confirm'),
+ cancelText: t('settings.ghosts.installConfirm.cancel'),
+ checkboxLabel: t('settings.ghosts.installConfirm.enableNow'),
+ checkboxDefaultChecked: true,
+ });
+ if (!ok) return;
+ try {
+ const { ghost } = await window.electronAPI.ghosts.reapproveInstalled(ghostId, {
+ enable,
+ expectedManifestSha256: manifestSha256,
+ expectedInstalledApproval: ghostInstallApprovalToken(installed.approval),
+ });
+ toast.success(t('settings.ghosts.toast.reapproved', { name: ghost.manifest.name }));
+ } catch (err) {
+ toast.error(t(ghostInstallErrorKey(extractIpcError(err)?.code)));
+ }
+}
+
/**
* 单意识详情页的「更新版本…」:选文件 → 验身 → 必须与当前意识同 id
* (选错别的意识的包直接拒,不做"顺手装成新意识"的隐式行为)→ 确认 → 更新。
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx
index 4064760341..3a1aa2f000 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx
@@ -233,7 +233,7 @@ export function GhostPluginDetailView({
className="plugin-detail-actions flex shrink-0 flex-nowrap items-center gap-1.5"
style={WINDOW_NO_DRAG_STYLE}
>
- {needsReapproval ? (
+ {needsReapproval && !detail.builtin ? (
<button
type="button"
onClick={onReapprove}
@@ -368,9 +368,11 @@ export function GhostPluginDetailView({
</p>
<p className="mt-1 text-13 leading-5 text-[var(--text-secondary)]">
{t(
- detail.approvalState === 'invalid'
- ? 'settings.ghosts.reapproval.bodyInvalid'
- : 'settings.ghosts.reapproval.bodyLegacy',
+ detail.builtin
+ ? 'settings.ghosts.reapproval.bodyBuiltinRestart'
+ : detail.approvalState === 'invalid'
+ ? 'settings.ghosts.reapproval.bodyInvalid'
+ : 'settings.ghosts.reapproval.bodyLegacy',
)}
</p>
</div>
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
index 0f1060c1ba..e00fd75f4a 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
@@ -33,7 +33,11 @@ import {
} from '@/lib/composerDraftStore';
import { patchDraft } from '@/state/newMakerDraft';
import { ghostInstallErrorKey } from '@/cindy-brain/installErrorKey';
-import { confirmAndInstallGhost, pickAndUpdateGhost } from '@/cindy-brain/installFlow';
+import {
+ confirmAndInstallGhost,
+ pickAndUpdateGhost,
+ reapproveInstalledGhost,
+} from '@/cindy-brain/installFlow';
import { GhostPermissionList, GhostUpdateReview } from '@/cindy-brain/GhostPermissionList';
import { cn } from '@/lib/utils';
import { Switch } from '@/components/ui/switch';
@@ -544,13 +548,17 @@ export function GhostPluginPage() {
*/
const handleReapprove = useCallback(
async (ghostId: string) => {
+ // 随包插件不走人工重新确认(入口已隐藏,这里是防御):批准由启动对账自动补。
+ if (ghosts.find((g) => g.manifest.id === ghostId)?.builtin) return;
if (ghostReapprovalRoute(marketByGhostId.get(ghostId)) === 'market') {
await handleMarketUpdate(ghostId);
return;
}
- await pickAndUpdateGhost(ghostId, { t, confirm, confirmWithCheckbox });
+ // 本地包路线:从已装目录读全量权限清单确认后开 receipt,不用用户翻出原始
+ // .cindy 文件;目录读不出时该流程内部自动回退到"重新选包"。
+ await reapproveInstalledGhost(ghostId, { t, confirm, confirmWithCheckbox });
},
- [confirm, confirmWithCheckbox, handleMarketUpdate, marketByGhostId, t],
+ [confirm, confirmWithCheckbox, ghosts, handleMarketUpdate, marketByGhostId, t],
);
const handleInstall = useCallback(async () => {
@@ -1447,7 +1455,8 @@ export function GhostPluginCard({
/>
) : null}
{needsReapproval ? (
- onReapprove ? (
+ // 随包插件不给人工重新确认入口:批准由启动对账自动补,详情页说明「重启即恢复」。
+ onReapprove && !item.builtin ? (
<button
type="button"
onClick={onReapprove}
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
index 2710d4dee5..1fa1960b43 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
@@ -38,6 +38,7 @@ const installedPlugin: GhostPluginListItem = {
enabled: true,
canUse: true,
approvalState: 'approved',
+ builtin: false,
};
const marketPlugin: PluginMarketItem = {
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx
index 0d0ad3e4da..4fbcdfe55e 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx
@@ -100,6 +100,7 @@ const detail: GhostPluginDetail = {
enabled: true,
canUse: true,
approvalState: 'approved',
+ builtin: false,
author: 'XD',
contents: ['code'],
permissions: [],
diff --git a/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts b/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts
index ec51a4d1df..44659c2359 100644
--- a/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts
+++ b/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts
@@ -29,6 +29,8 @@ export interface GhostPluginListItem {
* 详情都必须如实说明并给出重新确认入口,而不是让它看起来只是"被关掉了"。
*/
approvalState: GhostInstallApproval['state'];
+ /** 随包内置插件(main 按种子清单投影)。批准态异常时文案与恢复入口都不同。 */
+ builtin: boolean;
trust?: GhostTrustInfo;
iconDataUrl?: string;
}
@@ -172,6 +174,7 @@ export function toGhostPluginListItem(
enabled: ghost.enabled,
canUse: Boolean(manifest.command),
approvalState: ghost.approval.state,
+ builtin: ghost.builtin === true,
trust: ghost.trust ?? {
level: 'unverified',
publisherSigned: false,
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index edd88baa99..de256655e6 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -2934,7 +2934,8 @@
"actionAria": "Review permissions for plugin {{name}}",
"noticeTitle": "Permission review needed",
"bodyLegacy": "Cindy has no record of a permission review for this plugin, so it stays disabled. Choose Review Permissions to go through what it asks for and confirm it again.",
- "bodyInvalid": "The permission review record for this plugin is damaged, so it stays disabled. Choose Review Permissions to go through what it asks for and confirm it again."
+ "bodyInvalid": "The permission review record for this plugin is damaged, so it stays disabled. Choose Review Permissions to go through what it asks for and confirm it again.",
+ "bodyBuiltinRestart": "Something went wrong with this built-in plugin's approval record. Restart Cindy to recover automatically — no other action needed."
},
"install": "Install Plugin…",
"empty": "No plugins installed yet",
@@ -2990,6 +2991,7 @@
"uninstalled": "Uninstalled \"{{name}}\"",
"installedAsleep": "Installed \"{{name}}\" (disabled — enable it here anytime)",
"updated": "\"{{name}}\" updated to v{{version}}",
+ "reapproved": "\"{{name}}\" restored",
"exported": "Exported the .cindy file for \"{{name}}\"",
"exportFailed": "Couldn't export \"{{name}}\" — try again",
"projectDisabled": "Turned off \"{{name}}\" for this project",
@@ -3215,6 +3217,11 @@
"confirm": "Update",
"cancel": "Cancel"
},
+ "reapproveConfirm": {
+ "title": "Re-approve permissions for \"{{name}}\"?",
+ "body": "Review the permissions below to re-approve this installed plugin — no install file needed.",
+ "confirm": "Approve & Restore"
+ },
"pick": {
"dialogTitle": "Choose a folder",
"dialogMessage": "Plugin “{{name}}” is asking you to choose a folder"
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index c7d0740335..8069cae696 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -2933,7 +2933,8 @@
"actionAria": "プラグイン「{{name}}」の権限を再確認",
"noticeTitle": "権限の再確認が必要",
"bodyLegacy": "このプラグインの権限確認の記録が Cindy にないため、無効のままにしています。「権限を再確認」から要求される権限を確認し、あらためて許可してください。",
- "bodyInvalid": "このプラグインの権限確認の記録が壊れているため、無効のままにしています。「権限を再確認」から要求される権限を確認し、あらためて許可してください。"
+ "bodyInvalid": "このプラグインの権限確認の記録が壊れているため、無効のままにしています。「権限を再確認」から要求される権限を確認し、あらためて許可してください。",
+ "bodyBuiltinRestart": "この内蔵プラグインの承認記録に問題が発生しました。Cindy を再起動すると自動的に復元されます。他の操作は不要です。"
},
"install": "プラグインをインストール…",
"empty": "まだプラグインがインストールされていません",
@@ -2989,6 +2990,7 @@
"uninstalled": "「{{name}}」をアンインストールしました",
"installedAsleep": "「{{name}}」をインストールしました(無効状態。ここでいつでも有効化できます)",
"updated": "「{{name}}」を v{{version}} に更新しました",
+ "reapproved": "「{{name}}」を復元しました",
"exported": "「{{name}}」の .cindy ファイルを書き出しました",
"exportFailed": "「{{name}}」を書き出せませんでした。もう一度お試しください",
"projectDisabled": "「{{name}}」をこのプロジェクトで無効にしました",
@@ -3214,6 +3216,11 @@
"confirm": "更新",
"cancel": "キャンセル"
},
+ "reapproveConfirm": {
+ "title": "「{{name}}」の権限を再確認しますか?",
+ "body": "以下の権限を確認して、このインストール済みプラグインをあらためて許可します。インストールファイルは不要です。",
+ "confirm": "確認して復元"
+ },
"pick": {
"dialogTitle": "フォルダを選択",
"dialogMessage": "プラグイン「{{name}}」がフォルダの選択を求めています"
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index dfa4bb036a..bf12047d46 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -2933,7 +2933,8 @@
"actionAria": "플러그인 {{name}}의 권한 다시 확인",
"noticeTitle": "권한 재확인 필요",
"bodyLegacy": "Cindy에 이 플러그인의 권한 확인 기록이 없어 사용 중지한 상태입니다. [권한 다시 확인]에서 요청하는 권한을 확인하고 다시 허용해 주세요.",
- "bodyInvalid": "이 플러그인의 권한 확인 기록이 손상되어 사용 중지한 상태입니다. [권한 다시 확인]에서 요청하는 권한을 확인하고 다시 허용해 주세요."
+ "bodyInvalid": "이 플러그인의 권한 확인 기록이 손상되어 사용 중지한 상태입니다. [권한 다시 확인]에서 요청하는 권한을 확인하고 다시 허용해 주세요.",
+ "bodyBuiltinRestart": "이 내장 플러그인의 승인 기록에 문제가 발생했습니다. Cindy를 다시 시작하면 자동으로 복구되며, 다른 조치는 필요하지 않습니다."
},
"install": "플러그인 설치…",
"empty": "아직 설치된 플러그인이 없습니다",
@@ -2989,6 +2990,7 @@
"uninstalled": "\"{{name}}\" 제거됨",
"installedAsleep": "\"{{name}}\" 설치 완료 (비활성 상태이며 여기에서 언제든 활성화할 수 있습니다)",
"updated": "\"{{name}}\"이(가) v{{version}}(으)로 업데이트되었습니다",
+ "reapproved": "\"{{name}}\"이(가) 복원되었습니다",
"exported": "\"{{name}}\"의 .cindy 파일을 내보냈습니다",
"exportFailed": "\"{{name}}\"을(를) 내보내지 못했습니다. 다시 시도하세요",
"projectDisabled": "이 프로젝트에서 \"{{name}}\"을(를) 껐습니다",
@@ -3214,6 +3216,11 @@
"confirm": "업데이트",
"cancel": "취소"
},
+ "reapproveConfirm": {
+ "title": "\"{{name}}\" 권한을 다시 확인할까요?",
+ "body": "아래 권한을 확인하면 설치된 플러그인이 다시 승인됩니다. 설치 파일은 필요하지 않습니다.",
+ "confirm": "확인 후 복원"
+ },
"pick": {
"dialogTitle": "폴더 선택",
"dialogMessage": "플러그인 \"{{name}}\"이(가) 폴더 선택을 요청합니다"
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index b5073a2215..68a19e8676 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -2933,7 +2933,8 @@
"actionAria": "重新确认插件「{{name}}」的权限",
"noticeTitle": "需要重新确认权限",
"bodyLegacy": "Cindy 没有这个插件的权限确认记录,所以先把它停用了。点「重新确认权限」重新过一遍它要的权限,确认后即可继续使用。",
- "bodyInvalid": "这个插件的权限确认记录已损坏,所以先把它停用了。点「重新确认权限」重新过一遍它要的权限,确认后即可继续使用。"
+ "bodyInvalid": "这个插件的权限确认记录已损坏,所以先把它停用了。点「重新确认权限」重新过一遍它要的权限,确认后即可继续使用。",
+ "bodyBuiltinRestart": "这个内置插件的权限记录出了点问题。重启 Cindy 即可自动恢复,无需其他操作。"
},
"install": "安装插件…",
"empty": "还没有安装任何插件",
@@ -2989,6 +2990,7 @@
"uninstalled": "已卸载「{{name}}」",
"installedAsleep": "已安装「{{name}}」(未生效,可在此开启)",
"updated": "「{{name}}」已更新到 v{{version}}",
+ "reapproved": "已恢复「{{name}}」",
"exported": "已导出「{{name}}」的 .cindy 文件",
"exportFailed": "导出「{{name}}」失败,请重试",
"projectDisabled": "已在此项目停用「{{name}}」",
@@ -3214,6 +3216,11 @@
"confirm": "更新",
"cancel": "取消"
},
+ "reapproveConfirm": {
+ "title": "重新确认「{{name}}」的权限?",
+ "body": "按下方清单重新授权这个已安装的插件,无需重新提供安装包文件。",
+ "confirm": "确认并恢复"
+ },
"pick": {
"dialogTitle": "选择文件夹",
"dialogMessage": "插件「{{name}}」请求你选择一个文件夹"
diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.ts
index 73f6e63471..e2e722d3c3 100644
--- a/apps/desktop/src/renderer/vite-env.d.ts
+++ b/apps/desktop/src/renderer/vite-env.d.ts
@@ -1157,6 +1157,20 @@ interface ElectronAPI {
packageSha256: string;
iconDataUrl?: string;
}>;
+ /** 本地包第三条恢复路径第一步:从已装目录读确认卡事实,零副作用。 */
+ reapproveInspect: (
+ id: string,
+ ) => Promise<{
+ manifest: import('../shared/ghost').GhostManifest;
+ trust: import('../shared/ghost').GhostTrustInfo;
+ /** 确认卡展示时的清单字节指纹;确认时回传,防确认间隙清单被换。 */
+ manifestSha256: string;
+ }>;
+ /** 第三条恢复路径第二步:用户点过确认卡后开 receipt。 */
+ reapproveInstalled: (
+ id: string,
+ opts: { enable: boolean; expectedManifestSha256: string; expectedInstalledApproval: string },
+ ) => Promise<{ ghost: import('../shared/ghost').InstalledGhost }>;
uninstall: (id: string) => Promise<{ ok: true }>;
/** 详情页「导出 .cindy」:打包安装目录 → 保存对话框落盘。 */
export: (
diff --git a/apps/desktop/src/shared/ghost.ts b/apps/desktop/src/shared/ghost.ts
index b15b3ad2dc..887f4d7a75 100644
--- a/apps/desktop/src/shared/ghost.ts
+++ b/apps/desktop/src/shared/ghost.ts
@@ -1334,6 +1334,12 @@ export interface InstalledGhost {
* 文件缺失或超限时缺省)。renderer 直接作 <img src> 用,无需 loading 态。
*/
iconDataUrl?: string;
+ /**
+ * 是否随包内置插件(id 在随包种子清单里,由 main 投影;renderer 不自判前缀 ——
+ * 企业种子不带 `cindy-` 前缀)。批准态异常时 UI 据此换文案:随包插件由启动对账
+ * 自动补批准,「重启应用即恢复」,不走人工重新确认。
+ */
+ builtin?: boolean;
}
/** 插件包的来源与审核等级;决定 UI 徽标,不改变运行时 slot 权限。 */
diff --git a/docs/dev-rules/plugin-security-and-authoring.md b/docs/dev-rules/plugin-security-and-authoring.md
index ab18b17c8e..1d9bbe7f06 100644
--- a/docs/dev-rules/plugin-security-and-authoring.md
+++ b/docs/dev-rules/plugin-security-and-authoring.md
@@ -212,6 +212,13 @@
便于事后分辨"用户确认过"与"宿主迁移来的"。
- 迁移**读不出**(文件缺失、格式坏)或**自相矛盾**(镜像与内容互斥)时才 fail
closed,落到下面的兜底义务。
+- **receipt schema/指纹编码 bump 必须走「按旧编码核对 → 原地升级」,不是 fail closed
+ 到重新确认。** 纯格式变更时旧 receipt 的授权事实没有消失:先用旧编码核对旧摘要与当前
+ 安装字节,对得上就原地重算成新编码并升级 receipt,只有真漂移才 fail closed。一次内部
+ 格式变更不得变成全体用户重新确认。历史注:v1→v2(NUL framing 修复)没有专门的 v1
+ 读取器,因为 v1 receipt 从未随任何构建发布、全网不存在;同时一次性 legacy 迁移会把
+ 「已判损坏」的 receipt 从安装目录 backfill 治愈,效果上覆盖了该场景(有回归用例钉住)。
+ **从 v2 起的任何 bump 都必须实现原地升级器**,不得再引用本注作为豁免。
- **确实不可避免时的兜底义务**(四条全部要满足,缺一条就不算做完):
1. **能自动就别打扰用户**:自动重建/自动重算/自动重新播种优先,且要能在下一轮启动
对账时自愈,不要求用户在特定时机点特定按钮。
@@ -273,7 +280,11 @@
授权事实读不出(manifest 不合法、技能目录含链接、声明的 locale 装入后损坏)才对该插件
fail closed、走恢复 UI;trust 镜像缺失降级为 `unverified`、`packageSha256` audit-only
故省略。改动装入/迁移链路时保持这些不变量,尤其不得把迁移改成"每次缺 receipt 就补"
- (那就是把授权事实重新交给可变安装目录,等于回到 #636)。
+ (那就是把授权事实重新交给可变安装目录,等于回到 #636)。迁移之后批准再丢失的恢复
+ 路径:市场包走市场重装确认;本地包走「从已装目录重新确认」(`ghosts:reapprove-inspect`
+ → 确认卡全量权限清单 → `ghosts:reapprove-installed`,清单字节以 manifestSha256 绑定
+ 确认间隙,trust 走与迁移同一个封顶读取器)—— 不要求用户重新提供原始 `.cindy`,不存在
+ 不可恢复状态;随包插件不走人工确认,由启动对账自动补(UI 提示「重启应用即恢复」)。
- `networkSlot.ts` 的 `as: 'media'` 不能只信任 Content-Type(GLB 常见
`application/octet-stream`),需要安全的 magic-byte/扩展名嗅探。
- SSH 远程场景必须让 `LiziMcpSessionContext` 携带 remote 标识;目录过户不得回退读取本机