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。

fix(desktop): 保留前缀文案改从正本插值,并清掉写窄资格的陈旧表述

fmfsaisai3d6b544eab73
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyPrivilege.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyPrivilege.test.ts
index 2724ba5255..649de39f75 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyPrivilege.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/ghostFirstPartyPrivilege.test.ts
@@ -382,11 +382,10 @@ describe('resolveGhostFirstPartyPrivilege', () => {
// 来源(`plugin-market/service.ts::adoptLegacyInstallations`)。判据对它一律 deny:
// 它既不是 `source: 'market'`(所以进不了 public 那支),也不是 git/local market。
//
- // **今天这是空操作**,因为所有真正用到 Broker 或宿主原语的插件都是随包的
- // (`xd-feishu` / `xd-atlassian` / `x-manager`),走优先级 1 的 builtin 分支,
- // 根本到不了这里。但将来一旦有**非随包**的官方前缀插件要用这两类特权,
- // 这条分支就会把它 fail-closed 掉——那时必须显式决策,不能当漏网 bug 顺手放宽。
- it('denies legacy-adopted rows, which today only bundled plugins could hit', () => {
+ // `legacy-adopted` 不是静态官方资格或组织资格的替代来源:即使 id 命中静态官方前缀,
+ // 或命中当前组织前缀,也必须 fail-closed。若要改变这条来源边界必须显式决策,
+ // 不能把它当漏网 bug 顺手放宽。
+ it('denies legacy-adopted rows for static official and matching organization ids', () => {
for (const scope of ['public', 'organization'] as const) {
expect(
resolveGhostFirstPartyPrivilege(
@@ -420,8 +419,7 @@ describe('resolveGhostFirstPartyPrivilege', () => {
basis: 'denied-unknown-origin',
});
}
- // 同一个 id 只要 builtin 为真就走优先级 1,台账怎么写都不影响——这才是
- // 随包插件今天的实际路径。
+ // 同一个 id 只要 builtin 事实为真就走优先级 1,台账怎么写都不影响。
expect(
resolveGhostFirstPartyPrivilege(
facts({
diff --git a/apps/desktop/src/main/cindy-brain/index.ts b/apps/desktop/src/main/cindy-brain/index.ts
index f3c278759c..c7d802013d 100644
--- a/apps/desktop/src/main/cindy-brain/index.ts
+++ b/apps/desktop/src/main/cindy-brain/index.ts
@@ -5215,8 +5215,8 @@ export function getGhostLibraryBindingStore(): LibraryBindingStore {
/**
* 官方保留前缀守门(docs/dev-rules/plugin-security-and-authoring.md):packaged 版本上,用户装入
* 通道(install/update/inspect 三个 IPC,即拖入/选文件/forge 转交的共同出口)
- * 对 `cindy-` / `filo-` / `xd-` 前缀 id 一律拒装——卸载内置意识后抢注同 id 的
- * 第三方包,会冒充官方身份并蹭走凭证别名(用户历史填过的机器级 key 被注入攻击者白名单域名)。
+ * 对 `cindy-` / `filo-` / `xd-` 前缀 id 一律拒装——抢注同 id 的第三方包会冒充官方身份并
+ * 蹭走凭证别名(用户历史填过的机器级 key 被注入攻击者白名单域名)。
* dev 构建默认豁免:方便 `cindy-` / `filo-` / `xd-` 官方前缀插件在本地迭代;需要复现
* packaged 行为时可设置 `XDT_GHOST_RESERVED_PREFIX_GATE=1`,此开关只能收紧、不能放宽。
* 若恢复随包 seed,builtinGhostProvisioner 的内部安装路径不经这些 IPC;不要把本闸套到播种路径。
@@ -5475,7 +5475,7 @@ async function installOrUpdateMarketGhostPackageLocked(
if ('rejection' in inspected) throwInstallError(inspected.rejection);
assertGhostSupportsCurrentCindy(inspected.canonicalManifest);
// Publisher identity slugs stay reserved even on the market path.
- // Official cindy-/xd- prefixes remain exempt here; these two slugs do not.
+ // Official reserved prefixes from shared/ghost.ts remain exempt here; publisher slugs do not.
rejectReservedPublisherSlug(inspected.canonicalManifest.id);
if (
inspected.canonicalManifest.id !== expected.ghostId ||
diff --git a/apps/desktop/src/renderer/cindy-brain/__tests__/installErrorKey.test.ts b/apps/desktop/src/renderer/cindy-brain/__tests__/installErrorKey.test.ts
index 102639c9d6..3583449769 100644
--- a/apps/desktop/src/renderer/cindy-brain/__tests__/installErrorKey.test.ts
+++ b/apps/desktop/src/renderer/cindy-brain/__tests__/installErrorKey.test.ts
@@ -1,5 +1,7 @@
import { describe, expect, it } from 'vitest';
+import { GHOST_OFFICIAL_ID_PREFIXES } from '../../../shared/ghost';
+import i18n from '../../i18n';
import { ghostInstallErrorKey } from '../installErrorKey';
describe('ghostInstallErrorKey', () => {
@@ -9,4 +11,71 @@ describe('ghostInstallErrorKey', () => {
);
expect(ghostInstallErrorKey('GHOST_FILE_INVALID')).toBe('settings.ghosts.errors.fileInvalid');
});
+
+ it.each(['zh-CN', 'en', 'ja', 'ko', 'zh-TW'])(
+ 'renders the complete reserved-prefix authority in the %s install error',
+ (locale) => {
+ const key = ghostInstallErrorKey('GHOST_ID_RESERVED');
+ const rawMessage = i18n.getResource(locale, 'common', key);
+ const message = i18n.getFixedT(locale)(key).toString();
+
+ // 原始资源存在排除缺 key 后静默回退英文;占位符排除硬写完整前缀表。
+ expect(rawMessage).toEqual(expect.any(String));
+ expect(rawMessage).toContain('{{reservedGhostIdPrefixes}}');
+ // 渲染结果排除默认变量漏接或插值失效。
+ expect(message).toContain(GHOST_OFFICIAL_ID_PREFIXES.join(' / '));
+ expect(message).not.toContain('{{reservedGhostIdPrefixes}}');
+ },
+ );
+
+ it.each(['zh-CN', 'en', 'ja', 'ko', 'zh-TW'])(
+ 'renders the complete reserved-prefix authority in the %s marketplace guide',
+ (locale) => {
+ const key = 'settings.ghosts.market.sources.guide.rulesBody';
+ const rawMessage = i18n.getResource(locale, 'common', key);
+ const message = i18n.getFixedT(locale)(key).toString();
+
+ // 原始资源存在排除缺 key 后静默回退英文;占位符排除硬写完整前缀表。
+ expect(rawMessage).toEqual(expect.any(String));
+ expect(rawMessage).toContain('{{reservedGhostIdPrefixes}}');
+ // 渲染结果排除默认变量漏接或插值失效。
+ expect(message).toContain(GHOST_OFFICIAL_ID_PREFIXES.join(' / '));
+ expect(message).not.toContain('{{reservedGhostIdPrefixes}}');
+ },
+ );
+
+ it.each([
+ { locale: 'zh-CN', fragments: ['拖入', '选择文件', 'ghost_forge_pack', '自定义插件市场'] },
+ {
+ locale: 'en',
+ fragments: [
+ 'dragging in a package',
+ 'choosing a file',
+ 'ghost_forge_pack',
+ 'custom plugin marketplace',
+ ],
+ },
+ {
+ locale: 'ja',
+ fragments: ['ドラッグ', 'ファイル選択', 'ghost_forge_pack', 'カスタムプラグインマーケット'],
+ },
+ {
+ locale: 'ko',
+ fragments: ['끌어다 놓기', '파일 선택', 'ghost_forge_pack', '사용자 지정 플러그인 마켓'],
+ },
+ {
+ locale: 'zh-TW',
+ fragments: ['拖入', '選取檔案', 'ghost_forge_pack', '自訂插件市場'],
+ },
+ ])('keeps all four user install channels in the $locale marketplace guide', ({ locale, fragments }) => {
+ const rawMessage = i18n.getResource(
+ locale,
+ 'common',
+ 'settings.ghosts.market.sources.guide.rulesBody',
+ );
+
+ // 只钉四个必要语义点,排除说明被重新写窄成仅禁止某一个装入来源。
+ expect(rawMessage).toEqual(expect.any(String));
+ for (const fragment of fragments) expect(rawMessage).toContain(fragment);
+ });
});
diff --git a/apps/desktop/src/renderer/i18n/index.ts b/apps/desktop/src/renderer/i18n/index.ts
index b4614c639f..9bfc7bd881 100644
--- a/apps/desktop/src/renderer/i18n/index.ts
+++ b/apps/desktop/src/renderer/i18n/index.ts
@@ -23,6 +23,7 @@ import jaCommon from './locales/ja/common.json';
import jaAiRename from './locales/ja/aiRename.json';
import koCommon from './locales/ko/common.json';
import koAiRename from './locales/ko/aiRename.json';
+import { GHOST_OFFICIAL_ID_PREFIXES } from '../../shared/ghost';
import { DEFAULT_LOCALE } from '../../shared/locale';
export {
@@ -54,7 +55,12 @@ void i18n.use(initReactI18next).init({
escapeValue: false, // React 已转义
// 品牌名单一事实源:locale 文案里的 {{appName}} 全部由此注入,改名只改
// @cindy/maker-shared/branding 的 BRAND_NAME(见该文件对"不跟随改名"标识符的说明)。
- defaultVariables: { appName: BRAND_NAME },
+ // 保留前缀同样只读 shared/ghost.ts 的正本。错误文案不各自枚举,
+ // 新增前缀后所有装入入口会自动展示完整列表。
+ defaultVariables: {
+ appName: BRAND_NAME,
+ reservedGhostIdPrefixes: GHOST_OFFICIAL_ID_PREFIXES.join(' / '),
+ },
},
returnNull: false,
});
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 97ea993046..9384f40cd8 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -4207,7 +4207,7 @@
"authTitle": "Private Repositories",
"authBody": "Authentication relies entirely on your system Git configuration — Cindy never stores Git credentials. SSH: a working key must be configured on this machine; if the organization enforces SAML SSO, authorize the key for that organization via Configure SSO in your GitHub SSH key settings. HTTPS: use a Personal Access Token stored by the system credential helper.",
"rulesTitle": "Install Rules",
- "rulesBody": "Plugin ids are globally unique, first come first served — conflicts with installed plugins are called out explicitly. Plugins using officially reserved prefixes like cindy- cannot be installed from custom marketplaces. Before install, every permission the plugin declares is shown for review; confirming completes the install and enables the plugin.",
+ "rulesBody": "Plugin ids are globally unique, first come first served — conflicts with installed plugins are called out explicitly. Plugins using the officially reserved prefixes {{reservedGhostIdPrefixes}} cannot be installed by dragging in a package, choosing a file, transferring from ghost_forge_pack, or using a custom plugin marketplace. Before install, every permission the plugin declares is shown for review; confirming completes the install and enables the plugin.",
"copy": "Copy guide",
"copied": "Guide copied to clipboard.",
"copyFailed": "Copy failed. Please try again."
@@ -4437,7 +4437,7 @@
"alreadyInstalled": "This plugin is already installed",
"approvalRequired": "This plugin's permissions must be reviewed again before continuing.",
"commandConflict": "Its command conflicts with an installed plugin. Uninstall the other one or rename the command.",
- "idReserved": "This id uses the reserved official prefix cindy-; it is only available to plugins bundled with the app",
+ "idReserved": "{{reservedGhostIdPrefixes}} are reserved for official plugins and can’t be installed by dragging in a package, choosing a file, transferring from ghost_forge_pack, or using a custom plugin marketplace. Install the corresponding official plugin from the Cindy plugin market",
"sourceMissing": "The selected file could not be found",
"generic": "Operation failed. Please try again.",
"updateIdMismatch": "The selected file is plugin \"{{id}}\", which does not match this plugin \"{{expected}}\""
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 9a684fa8db..eb9f0257f7 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -4206,7 +4206,7 @@
"authTitle": "プライベートリポジトリ",
"authBody": "認証はすべてシステムの Git 設定に依存し、Cindy は Git の認証情報を一切保存しません。SSH の場合: 利用可能な key がマシンに設定されている必要があります。組織が SAML SSO を強制している場合は、GitHub の SSH key 設定で Configure SSO からその組織に key を承認してください。HTTPS の場合: Personal Access Token を使用し、システムの credential helper に保存します。",
"rulesTitle": "インストールルール",
- "rulesBody": "プラグイン id はグローバルに一意で先着順です。インストール済みプラグインとの競合は明示されます。cindy- などの公式予約プレフィックスを使うプラグインはカスタムマーケットからインストールできません。インストール前にプラグインが宣言する権限をすべて表示し、確認するとインストールが完了して自動的に有効になります。",
+ "rulesBody": "プラグイン id はグローバルに一意で先着順です。インストール済みプラグインとの競合は明示されます。公式予約プレフィックス {{reservedGhostIdPrefixes}} を使うプラグインは、ドラッグ、ファイル選択、ghost_forge_pack からの受け渡し、カスタムプラグインマーケットからはインストールできません。インストール前にプラグインが宣言する権限をすべて表示し、確認するとインストールが完了して自動的に有効になります。",
"copy": "ガイドをコピー",
"copied": "ガイドをクリップボードにコピーしました。",
"copyFailed": "コピーに失敗しました。もう一度お試しください。"
@@ -4436,7 +4436,7 @@
"alreadyInstalled": "このプラグインは既にインストールされています",
"approvalRequired": "続けるには、このプラグインの権限を再確認する必要があります",
"commandConflict": "コマンドがインストール済みのプラグインと重複しています。先に相手をアンインストールするか、コマンド名を変更してください。",
- "idReserved": "この id は公式予約プレフィックス cindy- を使用しています。アプリに同梱されたプラグインのみ使用できます",
+ "idReserved": "{{reservedGhostIdPrefixes}} は公式プラグイン用の予約済みプレフィックスです。ドラッグ、ファイル選択、ghost_forge_pack からの受け渡し、カスタムプラグインマーケットからはインストールできません。対応する公式プラグインは Cindy プラグインマーケットからインストールしてください",
"sourceMissing": "選択したファイルが見つかりません",
"generic": "操作に失敗しました。もう一度お試しください",
"updateIdMismatch": "選択したファイルはプラグイン「{{id}}」で、このプラグイン「{{expected}}」と一致しません"
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 5b86fdb72a..80c6332266 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -4206,7 +4206,7 @@
"authTitle": "비공개 리포지토리",
"authBody": "인증은 전적으로 시스템 Git 구성에 의존하며 Cindy는 Git 자격 증명을 저장하지 않습니다. SSH: 이 머신에 사용 가능한 key가 구성되어 있어야 합니다. 조직이 SAML SSO를 강제하는 경우 GitHub SSH key 설정에서 Configure SSO로 해당 조직에 key를 승인해야 합니다. HTTPS: Personal Access Token을 사용하고 시스템 credential helper에 저장합니다.",
"rulesTitle": "설치 규칙",
- "rulesBody": "플러그인 id는 전역적으로 고유하며 선착순입니다. 설치된 플러그인과의 충돌은 명확히 표시됩니다. cindy- 같은 공식 예약 접두사를 사용하는 플러그인은 사용자 지정 마켓에서 설치할 수 없습니다. 설치 전에 플러그인이 선언한 권한을 모두 보여주며, 확인하면 설치가 완료되고 자동으로 활성화됩니다.",
+ "rulesBody": "플러그인 id는 전역적으로 고유하며 선착순입니다. 설치된 플러그인과의 충돌은 명확히 표시됩니다. 공식 예약 접두사 {{reservedGhostIdPrefixes}}를 사용하는 플러그인은 끌어다 놓기, 파일 선택, ghost_forge_pack 전달 또는 사용자 지정 플러그인 마켓으로는 설치할 수 없습니다. 설치 전에 플러그인이 선언한 권한을 모두 보여주며, 확인하면 설치가 완료되고 자동으로 활성화됩니다.",
"copy": "가이드 복사",
"copied": "가이드를 클립보드에 복사했습니다.",
"copyFailed": "복사에 실패했습니다. 다시 시도하세요."
@@ -4436,7 +4436,7 @@
"alreadyInstalled": "이 플러그인은 이미 설치되어 있습니다",
"approvalRequired": "계속하려면 이 플러그인의 권한을 다시 확인해야 합니다",
"commandConflict": "명령어가 설치된 플러그인과 충돌합니다. 먼저 상대를 제거하거나 명령어 이름을 변경하세요.",
- "idReserved": "이 id는 공식 예약 접두사 cindy-를 사용합니다. 앱에 내장된 플러그인만 사용할 수 있습니다",
+ "idReserved": "{{reservedGhostIdPrefixes}}는 공식 플러그인용 예약 접두사입니다. 끌어다 놓기, 파일 선택, ghost_forge_pack 전달 또는 사용자 지정 플러그인 마켓으로는 설치할 수 없습니다. 해당 공식 플러그인은 Cindy 플러그인 마켓에서 설치하세요",
"sourceMissing": "선택한 파일을 찾을 수 없습니다",
"generic": "작업에 실패했습니다. 다시 시도해 주세요",
"updateIdMismatch": "선택한 파일은 플러그인 \"{{id}}\"로, 현재 플러그인 \"{{expected}}\"와 일치하지 않습니다"
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 428c4ef6a8..ddd207ac8a 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -4206,7 +4206,7 @@
"authTitle": "私有仓库",
"authBody": "认证完全依赖系统的 Git 配置,Cindy 不保存任何 Git 凭证。SSH 方式:本机已配置可用的 key;若组织开启了 SAML SSO,还需在 GitHub 的 SSH key 设置里为该组织点 Configure SSO 授权。HTTPS 方式:使用 Personal Access Token,并由系统 credential helper 保存。",
"rulesTitle": "安装规则",
- "rulesBody": "插件 id 全局唯一、先装先得——与已安装插件冲突时会明确提示。使用 cindy- 等官方保留前缀的插件不能从自定义市场安装。安装前会逐项展示插件声明的权限,确认后即完成安装并自动开启。",
+ "rulesBody": "插件 id 全局唯一、先装先得——与已安装插件冲突时会明确提示。使用 {{reservedGhostIdPrefixes}} 官方保留前缀的插件不能通过拖入、选择文件、ghost_forge_pack 转交或自定义插件市场装入。安装前会逐项展示插件声明的权限,确认后即完成安装并自动开启。",
"copy": "复制指南",
"copied": "指南已复制到剪贴板。",
"copyFailed": "复制失败,请重试。"
@@ -4436,7 +4436,7 @@
"alreadyInstalled": "这个插件已经安装",
"approvalRequired": "需要重新确认这个插件的权限后才能继续",
"commandConflict": "它的指令和已装插件撞名了,先卸载占用方或让作者改名",
- "idReserved": "该 id 使用了官方保留前缀 cindy-,仅随应用内置的插件可用",
+ "idReserved": "{{reservedGhostIdPrefixes}} 是官方插件保留前缀,不能通过拖入、选择文件、ghost_forge_pack 转交或自定义插件市场装入;请从 Cindy 插件市场安装对应的官方插件",
"sourceMissing": "找不到所选文件",
"generic": "操作失败,请稍后重试",
"updateIdMismatch": "所选文件是插件「{{id}}」,与当前插件「{{expected}}」不一致"
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index c6f3613424..8d99f9c257 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -4205,7 +4205,7 @@
"authTitle": "私有倉庫",
"authBody": "認證完全依賴系統的 Git 配置,Cindy 不儲存任何 Git 憑證。SSH 方式:本機已配置可用的 key;若組織開啟了 SAML SSO,還需在 GitHub 的 SSH key 設定裡為該組織點 Configure SSO 授權。HTTPS 方式:使用 Personal Access Token,並由系統 credential helper 儲存。",
"rulesTitle": "安裝規則",
- "rulesBody": "插件 id 全域性唯一、先裝先得——與已安裝插件衝突時會明確提示。使用 cindy- 等官方保留字首的插件不能從自定義市場安裝。安裝前會逐項展示插件宣告的權限,確認後即完成安裝並自動開啟。",
+ "rulesBody": "插件 id 全域性唯一、先裝先得——與已安裝插件衝突時會明確提示。使用 {{reservedGhostIdPrefixes}} 官方保留字首的插件無法透過拖入、選取檔案、ghost_forge_pack 轉交或自訂插件市場安裝。安裝前會逐項展示插件宣告的權限,確認後即完成安裝並自動開啟。",
"copy": "複製指南",
"copied": "指南已複製到剪貼簿。",
"copyFailed": "複製失敗,請重試。"
@@ -4436,7 +4436,7 @@
"alreadyInstalled": "這個插件已經安裝",
"approvalRequired": "繼續前需要重新確認這個插件的權限",
"commandConflict": "它的指令和已裝插件撞名了,先解除安裝佔用方或讓作者改名",
- "idReserved": "該 id 使用了官方保留字首 cindy-,僅隨應用內建的插件可用",
+ "idReserved": "{{reservedGhostIdPrefixes}} 是官方插件保留字首,無法透過拖入、選取檔案、ghost_forge_pack 轉交或自訂插件市場安裝;請從 Cindy 插件市場安裝對應的官方插件",
"sourceMissing": "找不到所選檔案",
"generic": "操作失敗,請稍後重試",
"updateIdMismatch": "所選檔案是插件「{{id}}」,與當前插件「{{expected}}」不一致"
diff --git a/apps/desktop/src/shared/__tests__/ghost.test.ts b/apps/desktop/src/shared/__tests__/ghost.test.ts
index ccad4f4984..4d41ee7a5c 100644
--- a/apps/desktop/src/shared/__tests__/ghost.test.ts
+++ b/apps/desktop/src/shared/__tests__/ghost.test.ts
@@ -2658,10 +2658,12 @@ describe('ghost · launch 启动模式(2026-07-12)', () => {
});
});
-describe('ghost · 官方保留 id 前缀(cindy-)', () => {
- it('isOfficialGhostId:cindy- 前缀命中,其它不命中', () => {
+describe('ghost · 官方保留 id 前缀', () => {
+ it('isOfficialGhostId:三类完整前缀命中,近似形态不命中', () => {
expect(isOfficialGhostId('cindy-web-search')).toBe(true);
expect(isOfficialGhostId('cindy-art')).toBe(true);
+ expect(isOfficialGhostId('filo-google')).toBe(true);
+ expect(isOfficialGhostId('xd-mivo')).toBe(true);
// 前缀必须完整命中:cindyart 无连字符、my-cindy- 前缀不在最左都不算官方。
expect(isOfficialGhostId('cindyart')).toBe(false);
expect(isOfficialGhostId('my-cindy-tool')).toBe(false);
@@ -2669,15 +2671,15 @@ describe('ghost · 官方保留 id 前缀(cindy-)', () => {
});
it('四个官方 id 谓词对本阶段同一组输入返回完全相同的结果', () => {
- const ids = [
- 'cindy-art',
- 'filo-google',
- 'xd-mivo',
- 'acme-feishu',
- 'my-plugin',
- 'cindyart',
- 'my-cindy-tool',
- '',
+ const cases: ReadonlyArray<readonly [id: string, expected: boolean]> = [
+ ['cindy-art', true],
+ ['filo-google', true],
+ ['xd-mivo', true],
+ ['acme-feishu', false],
+ ['my-plugin', false],
+ ['cindyart', false],
+ ['my-cindy-tool', false],
+ ['', false],
];
const predicates = [
isOfficialGhostId,
@@ -2685,8 +2687,8 @@ describe('ghost · 官方保留 id 前缀(cindy-)', () => {
isBrokerEligibleGhostId,
isFirstPartyHostPrivilegeGhostId,
];
- for (const id of ids) {
- const expected = isOfficialGhostId(id);
+ // 期望值写死,避免用任一被测谓词或同一前缀表反推 expected 后让错误实现自证正确。
+ for (const [id, expected] of cases) {
for (const predicate of predicates) {
expect(predicate(id), `${predicate.name}(${JSON.stringify(id)})`).toBe(expected);
}
diff --git a/apps/desktop/src/shared/ghost.ts b/apps/desktop/src/shared/ghost.ts
index 5206bb426c..2b4dd7ebbd 100644
--- a/apps/desktop/src/shared/ghost.ts
+++ b/apps/desktop/src/shared/ghost.ts
@@ -1615,12 +1615,12 @@ export function isValidGhostId(id: unknown): id is string {
}
/**
- * 官方意识 id 前缀(docs/dev-rules/plugin-security-and-authoring.md):`cindy-` 保留给随包预装的
- * 第一方意识。用户装入通道(拖入/选文件/forge 转交)对该前缀**在 packaged
- * 版本上拒装**——否则卸载内置意识后,同 id 的第三方包可抢注官方身份,连带
+ * 官方意识历史 id 前缀常量:`cindy-`。完整保留集合与用户装入通道判定以
+ * `GHOST_OFFICIAL_ID_PREFIXES` 为准;官方市场可安装命中保留前缀的插件,
+ * 用户装入通道(拖入/选文件/forge 转交/自定义市场)则在 packaged 版本上拒装
+ * (dev 默认豁免,可用开发开关复现)。否则同 id 的第三方包可抢注官方身份,连带
* 蹭走凭证别名(providerSecrets 的 GHOST_SECRET_STORAGE_ALIASES 按 id 生效,
- * 抢注者能拿到用户历史填过的机器级 key)。dev 构建豁免:官方意识的开发迭代
- * 本来就靠打包重装。
+ * 抢注者能拿到用户历史填过的机器级 key)。
*/
export const GHOST_OFFICIAL_ID_PREFIX = 'cindy-';
@@ -1642,7 +1642,7 @@ export function isOfficialGhostId(id: string): boolean {
}
/**
- * 用户装入通道(拖入 / 选文件 / forge 转交)是否拒装该 id。
+ * 用户装入通道(拖入 / 选文件 / forge 转交 / 自定义市场)是否拒装该 id。
* 当前与 `isOfficialGhostId` 等价;本批不放宽组织前缀。
*/
export function isUserInstallReservedGhostId(id: string): boolean {
diff --git a/apps/desktop/src/shared/ipc-errors.ts b/apps/desktop/src/shared/ipc-errors.ts
index 08038be5a3..616894b333 100644
--- a/apps/desktop/src/shared/ipc-errors.ts
+++ b/apps/desktop/src/shared/ipc-errors.ts
@@ -178,7 +178,7 @@ export type IpcErrorCode =
| 'GHOST_FILE_INVALID' // 不是合法 zip / 缺 ghost.json / 清单不合格 / 超限
| 'GHOST_HOST_UNSUPPORTED' // 插件包合法,但当前 Cindy 不认识其 schema / capability slot
| 'GHOST_COMMAND_CONFLICT' // 显式指令与已装意识撞名(装入拒绝)
- | 'GHOST_ID_RESERVED' // id 属官方保留前缀(cindy-),用户通道拒装(防抢注蹭凭证别名)
+ | 'GHOST_ID_RESERVED' // id 属 shared/ghost.ts 登记的官方保留前缀,用户通道拒装(防抢注蹭凭证别名)
// 自定义插件市场源(Git / 本地文件夹)
| 'MARKET_SOURCE_INVALID' // 来源格式非法 / 本地路径不是目录 / 参数组合不允许
| 'MARKET_GIT_UNAVAILABLE' // 未安装 Git 或版本 < 2.25(稀疏检出下限)
diff --git a/apps/desktop/src/shared/providerSecrets.ts b/apps/desktop/src/shared/providerSecrets.ts
index 37d596f646..f422652c6d 100644
--- a/apps/desktop/src/shared/providerSecrets.ts
+++ b/apps/desktop/src/shared/providerSecrets.ts
@@ -186,7 +186,7 @@ export function providerOAuthStorageKey(providerId: string): string {
export const GHOST_SECRET_PREFIX = 'ghost_secret_';
/**
- * 官方内置意识凭证 → 历史机器级 provider key 的别名表(老用户兼容)。
+ * 官方意识凭证 → 历史机器级 provider key 的别名表(老用户兼容)。
*
* cindy-web-search 的两条凭证与「工具密钥」时代的 Brave / Tavily key 是**同一
* 把钥匙**,直接映射到同一存储键(.enc 同一文件):
@@ -195,7 +195,7 @@ export const GHOST_SECRET_PREFIX = 'ghost_secret_';
* - 卸载意识不删这两个键(removeGhostSecrets 只扫 ghost_secret_ 前缀,别名键
* 天然不在扫描面内)——它们是用户填的机器级 key,归属机器不归属意识,
* 重装意识即恢复可用;换账号仍随 clearAll 清扫(在 PROVIDER_SECRET_IDS 里)。
- * 仅限官方内置意识登记(key 必须是官方保留前缀 id,见
+ * 仅限官方意识登记(key 必须是官方保留前缀 id,见
* GHOST_OFFICIAL_ID_PREFIXES):第三方意识一律走 ghost_secret_ 命名空间;
* packaged 版本的用户装入通道对官方前缀 id 拒装(cindy-brain/index.ts
* rejectReservedGhostId),抢注官方 id 蹭别名的路被封死。
diff --git a/docs/dev-rules/plugin-security-and-authoring.md b/docs/dev-rules/plugin-security-and-authoring.md
index 445f3cad5e..60b70e2478 100644
--- a/docs/dev-rules/plugin-security-and-authoring.md
+++ b/docs/dev-rules/plugin-security-and-authoring.md
@@ -44,7 +44,8 @@
- `.cindy` 是以 `ghost.json` 为身份卡的插件包,现行唯一形态为 `kind: 'chip'`。
- 代码目录与运行时使用 `cindy-brain` / `Ghost` 命名,**不得重新引入已退役的 cartridge
声明型兼容层**。
-- `cindy-` id 前缀保留给随包官方插件,第三方插件不得占用。
+- `cindy-` / `filo-` / `xd-` 是官方保留 id 前缀,第三方插件不得占用;前缀正本见
+ `apps/desktop/src/shared/ghost.ts` 的 `GHOST_OFFICIAL_ID_PREFIXES`。
## 2. 运行时沙箱与进程隔离