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(plugin): 补齐插件创建引导的设计选项与手册源码指引 (#3023)

DavidShenXD244ac2e37ab4
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts
index bd09c70c0c..fb811166fb 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts
@@ -1328,8 +1328,16 @@ describe('scaffoldGhostDir', () => {
});
describe('FORGE_GUIDE', () => {
- it('documents installed-directory isolation and the structured refusal', () => {
- expect(FORGE_GUIDE).toContain('已安装插件目录');
+ it('开场白必读口径与 createPrompt 一致:三章且卡槽总览带真实章号', () => {
+ // 聊天里直接说"帮我做个插件"的路径只看到手册,看不到 createPrompt;
+ // 两处必读口径分叉会让不同入口的 agent 走出不同的阅读深度。
+ // "卡槽总览"必须带章号(§2):章节匹配只认章号或标题子串,agent 照抄
+ // 文案字样调 section 会取章失败(PR #3023 review)。
+ expect(FORGE_GUIDE).toContain('至少读完 §2 卡槽总览、"沙箱红线"与"打包与测试"三章');
+ expect(FORGE_GUIDE).not.toContain('至少读完"沙箱红线"与"打包与测试"两章');
+ });
+
+ it('documents installed-directory isolation and the structured refusal', () => { expect(FORGE_GUIDE).toContain('已安装插件目录');
expect(FORGE_GUIDE).toContain('SOURCE_IS_INSTALLED_PLUGIN');
// 脚手架侧的同一禁区也要写进手册,否则 agent 会先把骨架建进安装目录再撞墙。
expect(FORGE_GUIDE).toContain('也不能落在已安装插件目录或 Host 状态目录内');
@@ -1686,6 +1694,17 @@ describe('FORGE_GUIDE', () => {
'发布到官方插件仓的额外门禁',
'makecindy/cindy-official-plugins',
'四语言 locale 缺一不可',
+ // 2026-08-19 范例与源码指引:§1 补官方插件仓 URL(真实完整范例)与
+ // 主仓地址(插件基座,apps/desktop/src/main/cindy-brain/),并写死边界
+ // ——API 契约一律以手册为准,main 分支可能与用户安装版本不一致。
+ 'github.com/makecindy/cindy-official-plugins',
+ // 范例判据是"含 ghost.json 的一级目录",不是"每个一级目录"——
+ // 仓库根还有 .tests/docs 等基础设施目录(PR #3023 review)。
+ '每个**含 ghost.json 的',
+ '不是插件',
+ 'apps/desktop/src/main/cindy-brain/',
+ 'API 契约一律以本手册为准',
+ 'github.com/makecindy/cindy',
// 2026-07-29 寄存通道(#784):§2 的 media 类目 + §4.0.1 章节,
// 以及 §6 沙箱红线里"改图只认名下媒体"的口径更新。
"kind: 'deposit_media'",
diff --git a/apps/desktop/src/main/cindy-brain/forge.ts b/apps/desktop/src/main/cindy-brain/forge.ts
index 82129d8d37..e41ecd00ab 100644
--- a/apps/desktop/src/main/cindy-brain/forge.ts
+++ b/apps/desktop/src/main/cindy-brain/forge.ts
@@ -1354,7 +1354,7 @@ export const FORGE_GUIDE = `# 意识(Ghost)编写手册
意识是 Cindy 的第三方能力包,文件形态是 \`.cindy\`(zip 包)。装入后可给
主机叠加:AI 可调用的工具、常驻界面面板、模型代办能力。本手册教你(agent)替用户
写一个意识。**流程:先取手册目录 → 按 §0 用提问卡片和用户对齐设计 → 按需用 section
-读透相关章(动手前至少读完"沙箱红线"与"打包与测试"两章) → 在工作目录写源码文件 →
+读透相关章(动手前至少读完 §2 卡槽总览、"沙箱红线"与"打包与测试"三章) → 在工作目录写源码文件 →
ghost_forge_pack 打包 → 用户在弹窗上确认装入。**
从零开始时优先调用 \`ghost_forge_scaffold\` 生成一份不会覆盖现有文件的骨架,再在
@@ -1416,6 +1416,17 @@ my-ghost/
└── settings.html ← 自定义设置区(声明了 settingsHtml 时必须,见 §4.8)
\`\`\`
+想看**真实完整范例**,浏览官方插件源码仓
+\`github.com/makecindy/cindy-official-plugins\`:仓库根下每个**含 ghost.json 的
+一级目录**(cindy-art、cindy-github、cindy-web-search……)都是一个已上架插件的
+全部源码,各槽(卡槽/
+面板/网络/设置页)都有现成写法可对照;\`.tests\`、\`docs\` 等无 ghost.json 的
+目录是仓库自身的基础设施,不是插件。需要理解宿主侧能力实现(某个槽的代发
+细节、校验器行为)时可参考主仓 \`github.com/makecindy/cindy\`(插件基座在
+\`apps/desktop/src/main/cindy-brain/\`),但**API 契约一律以本手册为准**——
+线上 main 分支可能领先或落后用户当前安装的主机版本,照 main 写码可能装进
+旧版就不工作。
+
## 2. ghost.json 身份卡
\`\`\`json
@@ -4113,7 +4124,8 @@ const opened = await cindy.iosSimulator.request({
### 8.1 发布到官方插件仓的额外门禁
-要提交到官方插件仓 \`makecindy/cindy-official-plugins\` 的插件,除本手册的打包/装入
+官方插件仓:\`github.com/makecindy/cindy-official-plugins\`(公开,合入即自动上架
+插件市场)。要提交到该仓的插件,除本手册的打包/装入
校验外还有仓级 CI 硬门禁,过不了整次发布被拦:
- **四语言 locale 缺一不可**:\`locales\` 必须**恰好**包含 \`zh-CN\` / \`en\` / \`ja\` /
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCreatePrompt.test.ts b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCreatePrompt.test.ts
index b89a2e528a..cfb6fbcc39 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCreatePrompt.test.ts
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCreatePrompt.test.ts
@@ -24,6 +24,9 @@ describe('Ghost Plugin creation prompt', () => {
expect(prompt).toContain('先从提问开始');
expect(prompt.indexOf('ghost_forge_guide')).toBeGreaterThanOrEqual(0);
expect(prompt.indexOf('ghost_forge_guide')).toBeLessThan(prompt.indexOf('ghost_forge_pack'));
+ // 用真实章号指向卡槽总览:agent 可能照抄文案字样调 ghost_forge_guide 的
+ // section 取章,而章节匹配只认章号或标题子串,"卡槽总览"不是任何标题的子串。
+ expect(prompt).toContain('第 2 章卡槽总览');
expect(prompt).toContain('打包并安装插件');
});
@@ -39,5 +42,18 @@ describe('Ghost Plugin creation prompt', () => {
// 面板收束(2026-08-02):tab 形态住在插件页内,不再是右侧栏页签。
expect(prompt).toContain('插件页内面板');
expect(prompt).not.toContain('右侧栏页签');
+ // 与 §0 七类"隐藏"设计选项保持同步:后台能力 / 运行形态(node 槽)/ 媒体
+ // 能力三类曾长期缺席,导致提问阶段就把这些能力漏掉(2026-08-19 补齐)。
+ expect(prompt).toContain('后台能力');
+ expect(prompt).toContain('应用内轻提示');
+ expect(prompt).not.toContain('系统提示(');
+ // notify 桌上弹的是应用内 toast,不是 OS 级通知——措辞不得回退成
+ // "系统提示/system notifications" 引导用户误解(PR #3023 review)。
+ expect(prompt).toContain('未读角标');
+ expect(prompt).toContain('随包 Node 进程');
+ expect(prompt).toContain('媒体能力');
+ // 必读章节含 §2 卡槽总览:18 个槽的全局视野是"按需读相关章节"的前提。
+ expect(prompt).toContain('卡槽总览');
+ expect(prompt).toContain('第 2 章');
});
});
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index fa5c235123..80a55cfeef 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -3776,7 +3776,7 @@
"updateTo": "Update to v{{version}}",
"updateAria": "Update {{name}} to v{{version}}",
"createWithCindy": "Create with Cindy",
- "createPrompt": "I want to create a Cindy plugin. First call ghost_forge_guide to get the handbook's table of contents, read chapter 0 (design alignment) first, then read the relevant chapters via the section parameter (at minimum the sandbox red-lines and packaging chapters) before writing any code; do not start implementing yet. Begin by asking questions: prefer option-based question cards, one key decision per card with your recommended choice marked, and proactively surface design options I may not know about — such as the UI form (docked panel, panel inside the Plugins page, chat card, or no UI), a $ command word, launch mode, network access, and whether a settings page is needed. Step by step, confirm the problem to solve, target users, interaction flow, required tools and connections, permission boundaries, and acceptance criteria. After I confirm the design, implement and validate it according to the specification, then call ghost_forge_pack to package and install the plugin.",
+ "createPrompt": "I want to create a Cindy plugin. First call ghost_forge_guide to get the handbook's table of contents, read chapter 0 (design alignment) first, then read the relevant chapters via the section parameter (at minimum chapter 2 for the slot overview, plus the sandbox red-lines and packaging chapters) before writing any code; do not start implementing yet. Begin by asking questions: prefer option-based question cards, one key decision per card with your recommended choice marked, and proactively surface design options I may not know about — such as the UI form (docked panel, panel inside the Plugins page, chat card, or no UI), a $ command word, launch mode, background abilities (event listening, in-app toast notifications, unread badges, confirmation dialogs), network access, whether a settings page is needed, whether a bundled Node process should do heavy lifting, and whether image/video media abilities are needed. Step by step, confirm the problem to solve, target users, interaction flow, required tools and connections, permission boundaries, and acceptance criteria. After I confirm the design, implement and validate it according to the specification, then call ghost_forge_pack to package and install the plugin.",
"filterAll": "All",
"filtersAria": "Filter plugins by source",
"origin": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index faf4d92756..2e9ccb5eaf 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -3802,7 +3802,7 @@
"updateTo": "v{{version}} に更新",
"updateAria": "{{name}} を v{{version}} に更新",
"createWithCindy": "Cindy で作成",
- "createPrompt": "Cindy プラグインを作成したいです。まず ghost_forge_guide を呼び出してハンドブックの目次を取得し、最初に第 0 章「設計のすり合わせ」を読み、その後 section パラメータで関連する章(少なくともサンドボックスの禁止事項とパッケージ化の章)を読み込んでから着手してください。すぐに実装を始めないでください。質問から始めてください:選択肢付きの質問カードを優先し、1 枚のカードでは 1 つの重要な判断に絞り、あなたのおすすめを明示した上で、私が気づきにくい設計オプション(UI 形態:ドッキングパネル / プラグインページ内のパネル / チャットカード / UI なし、$ 呼び出しコマンド、起動モード、ネットワーク接続の要否、設定ページの要否など)を積極的に提示して選ばせてください。解決する課題、対象ユーザー、操作フロー、必要なツールと接続、権限の境界、受け入れ条件を段階的に確認してください。設計を確認した後、仕様に沿って実装と検証を行い、最後に ghost_forge_pack を呼び出してプラグインをパッケージ化し、インストールしてください。",
+ "createPrompt": "Cindy プラグインを作成したいです。まず ghost_forge_guide を呼び出してハンドブックの目次を取得し、最初に第 0 章「設計のすり合わせ」を読み、その後 section パラメータで関連する章(少なくともスロット一覧を含む第 2 章、サンドボックスの禁止事項、パッケージ化の 3 章)を読み込んでから着手してください。すぐに実装を始めないでください。質問から始めてください:選択肢付きの質問カードを優先し、1 枚のカードでは 1 つの重要な判断に絞り、あなたのおすすめを明示した上で、私が気づきにくい設計オプション(UI 形態:ドッキングパネル / プラグインページ内のパネル / チャットカード / UI なし、$ 呼び出しコマンド、起動モード、バックグラウンド能力:イベント傍受・アプリ内トースト通知・未読バッジ・確認ダイアログ、ネットワーク接続の要否、設定ページの要否、Node プロセス同梱での重い処理の要否、画像・動画などのメディア能力の要否など)を積極的に提示して選ばせてください。解決する課題、対象ユーザー、操作フロー、必要なツールと接続、権限の境界、受け入れ条件を段階的に確認してください。設計を確認した後、仕様に沿って実装と検証を行い、最後に ghost_forge_pack を呼び出してプラグインをパッケージ化し、インストールしてください。",
"filterAll": "すべて",
"filtersAria": "提供元でプラグインを絞り込む",
"origin": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index ac8f329b49..56cfa93782 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -3802,7 +3802,7 @@
"updateTo": "v{{version}}(으)로 업데이트",
"updateAria": "{{name}}을(를) v{{version}}(으)로 업데이트",
"createWithCindy": "Cindy로 만들기",
- "createPrompt": "Cindy 플러그인을 만들고 싶습니다. 먼저 ghost_forge_guide를 호출해 핸드북 목차를 받고, 우선 0장 「설계 맞추기」를 읽은 뒤 section 매개변수로 관련 장(최소한 샌드박스 금지선과 패키징 장)을 읽고 나서 작업을 시작하세요. 바로 구현을 시작하지 마세요. 질문부터 시작하세요: 선택지가 있는 질문 카드를 우선 사용하고, 카드 한 장에는 핵심 결정 하나만 담아 추천안을 표시하며, 제가 모를 수 있는 설계 옵션(UI 형태: 도킹 패널 / 플러그인 페이지 내 패널 / 채팅 카드 / UI 없음, $ 호출 명령어, 시작 모드, 네트워크 사용 여부, 설정 페이지 필요 여부 등)을 먼저 보여 주고 고르게 해 주세요. 해결할 문제, 대상 사용자, 상호작용 흐름, 필요한 도구와 연결, 권한 경계, 완료 기준을 단계적으로 확인해 주세요. 설계를 확인한 뒤 규격에 따라 구현하고 검증한 다음, 마지막으로 ghost_forge_pack을 호출해 플러그인을 패키징하고 설치해 주세요.",
+ "createPrompt": "Cindy 플러그인을 만들고 싶습니다. 먼저 ghost_forge_guide를 호출해 핸드북 목차를 받고, 우선 0장 「설계 맞추기」를 읽은 뒤 section 매개변수로 관련 장(최소한 슬롯 총람이 담긴 2장, 샌드박스 금지선, 패키징 세 장)을 읽고 나서 작업을 시작하세요. 바로 구현을 시작하지 마세요. 질문부터 시작하세요: 선택지가 있는 질문 카드를 우선 사용하고, 카드 한 장에는 핵심 결정 하나만 담아 추천안을 표시하며, 제가 모를 수 있는 설계 옵션(UI 형태: 도킹 패널 / 플러그인 페이지 내 패널 / 채팅 카드 / UI 없음, $ 호출 명령어, 시작 모드, 백그라운드 능력: 이벤트 수신 · 앱 내 토스트 알림 · 읽지 않음 배지 · 확인 대화상자, 네트워크 사용 여부, 설정 페이지 필요 여부, Node 프로세스 동반 여부, 이미지·동영상 등 미디어 능력 필요 여부 등)을 먼저 보여 주고 고르게 해 주세요. 해결할 문제, 대상 사용자, 상호작용 흐름, 필요한 도구와 연결, 권한 경계, 완료 기준을 단계적으로 확인해 주세요. 설계를 확인한 뒤 규격에 따라 구현하고 검증한 다음, 마지막으로 ghost_forge_pack을 호출해 플러그인을 패키징하고 설치해 주세요.",
"filterAll": "전체",
"filtersAria": "출처별 플러그인 필터",
"origin": {
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 346ecbf7d4..bc0b92b48e 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -3775,7 +3775,7 @@
"updateTo": "更新到 v{{version}}",
"updateAria": "将 {{name}} 更新到 v{{version}}",
"createWithCindy": "使用 Cindy 创建",
- "createPrompt": "我要创建一个 Cindy 插件。请先调用 ghost_forge_guide 获取手册目录,先读第 0 章「设计对齐」,再用 section 参数读透相关章节(动手前至少读完沙箱红线与打包流程两章),不要直接开始实现。先从提问开始:优先用带选项的提问卡片,每张卡片聚焦一个关键决策并标注你的推荐项,把我可能不知道的设计选项主动摆出来让我选——比如界面形态(停靠面板、插件页内面板、对话卡片还是无界面)、$ 点名词、启动模式、是否联网、是否需要设置页;并逐步确认插件要解决的问题、目标用户、交互流程、所需工具与连接、权限边界和验收标准。设计确认后,再按规范实现并自检;最后调用 ghost_forge_pack 打包并安装插件。",
+ "createPrompt": "我要创建一个 Cindy 插件。请先调用 ghost_forge_guide 获取手册目录,先读第 0 章「设计对齐」,再用 section 参数读透相关章节(动手前至少读完第 2 章卡槽总览、沙箱红线与打包流程三章),不要直接开始实现。先从提问开始:优先用带选项的提问卡片,每张卡片聚焦一个关键决策并标注你的推荐项,把我可能不知道的设计选项主动摆出来让我选——比如界面形态(停靠面板、插件页内面板、对话卡片还是无界面)、$ 点名词、启动模式、后台能力(旁听事件、应用内轻提示、未读角标、确认弹窗)、是否联网、是否需要设置页、要不要随包 Node 进程跑重活、要不要图片视频等媒体能力;并逐步确认插件要解决的问题、目标用户、交互流程、所需工具与连接、权限边界和验收标准。设计确认后,再按规范实现并自检;最后调用 ghost_forge_pack 打包并安装插件。",
"filterAll": "全部",
"filtersAria": "按来源筛选插件",
"origin": {
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 456e80b64c..55f1e9d124 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -3802,7 +3802,7 @@
"updateTo": "更新到 v{{version}}",
"updateAria": "將 {{name}} 更新到 v{{version}}",
"createWithCindy": "使用 Cindy 建立",
- "createPrompt": "我要建立一個 Cindy 插件。請先呼叫 ghost_forge_guide 獲取手冊目錄,先讀第 0 章「設計對齊」,再用 section 引數讀透相關章節(動手前至少讀完沙箱紅線與打包流程兩章),不要直接開始實現。先從提問開始:優先用帶選項的提問卡片,每張卡片聚焦一個關鍵決策並標註你的推薦項,把我可能不知道的設計選項主動擺出來讓我選——比如介面形態(停靠面板、插件頁內面板、對話卡片還是無介面)、$ 點名詞、啟動模式、是否聯網、是否需要設定頁;並逐步確認插件要解決的問題、目標使用者、互動流程、所需工具與連線、權限邊界和驗收標準。設計確認後,再按規範實現並自檢;最後呼叫 ghost_forge_pack 打包並安裝插件。",
+ "createPrompt": "我要建立一個 Cindy 插件。請先呼叫 ghost_forge_guide 獲取手冊目錄,先讀第 0 章「設計對齊」,再用 section 引數讀透相關章節(動手前至少讀完第 2 章卡槽總覽、沙箱紅線與打包流程三章),不要直接開始實現。先從提問開始:優先用帶選項的提問卡片,每張卡片聚焦一個關鍵決策並標註你的推薦項,把我可能不知道的設計選項主動擺出來讓我選——比如介面形態(停靠面板、插件頁內面板、對話卡片還是無介面)、$ 點名詞、啟動模式、後台能力(旁聽事件、應用內輕提示、未讀角標、確認彈窗)、是否聯網、是否需要設定頁、要不要隨包 Node 行程跑重活、要不要圖片影片等媒體能力;並逐步確認插件要解決的問題、目標使用者、互動流程、所需工具與連線、權限邊界和驗收標準。設計確認後,再按規範實現並自檢;最後呼叫 ghost_forge_pack 打包並安裝插件。",
"filterAll": "全部",
"filtersAria": "按來源篩選插件",
"origin": {