From 6ff64875644842d0abe15f6f62f887f865194f91 Mon Sep 17 00:00:00 2001 From: zyu51 Date: Thu, 9 Jul 2026 20:55:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20auto-research=20plugin=20?= =?UTF-8?q?=E2=80=94=20=3F=20to=20ask=20ChatGPT,=20=3F=3F=20to=20search=20?= =?UTF-8?q?web?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude-plugin/marketplace.json | 12 ++ .../auto-research/.claude-plugin/plugin.json | 28 +++++ plugins/auto-research/README.md | 114 ++++++++++++++++++ .../skills/auto-research/SKILL.md | 82 +++++++++++++ 4 files changed, 236 insertions(+) create mode 100644 plugins/auto-research/.claude-plugin/plugin.json create mode 100644 plugins/auto-research/README.md create mode 100644 plugins/auto-research/skills/auto-research/SKILL.md diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 9c6b6ca..7e5c412 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -8,6 +8,18 @@ "version": "1.0.0" }, "plugins": [ + { + "name": "auto-research", + "description": "Auto-research skill: trigger ? to ask ChatGPT via Playwright browser, ?? to search web. Automatically research uncertain problems, present options, wait for user approval. 支持中文/English.", + "version": "1.0.0", + "author": { + "name": "张宇 (zyu51)" + }, + "source": "./plugins/auto-research", + "category": "ai-tools", + "tags": ["research", "chatgpt", "playwright", "browser-automation", "decision-support"], + "keywords": ["research", "chatgpt", "playwright", "automation", "browser", "decision", "中文"] + }, { "name": "switch-provider", "description": "Switch Claude Code between AI providers (Anthropic, Z.AI, Kimi, MiniMax) with a single command", diff --git a/plugins/auto-research/.claude-plugin/plugin.json b/plugins/auto-research/.claude-plugin/plugin.json new file mode 100644 index 0000000..cfa4886 --- /dev/null +++ b/plugins/auto-research/.claude-plugin/plugin.json @@ -0,0 +1,28 @@ +{ + "name": "auto-research", + "description": "自动研究技能:触发词 ? 自动询问 ChatGPT,?? 搜索引擎调研,遇到不确定的问题自动研究后呈现方案等用户裁决", + "version": "1.0.0", + "author": { + "name": "张宇", + "email": "zyu51@example.com" + }, + "license": "MIT", + "category": "ai-tools", + "keywords": [ + "research", + "chatgpt", + "playwright", + "automation", + "decision-support", + "中文" + ], + "mcpServers": { + "playwright": { + "description": "用于通过浏览器扩展连接 Edge/Chrome 自动操作 ChatGPT", + "command": "npx", + "args": ["-y", "@playwright/mcp@latest", "--extension", "--browser", "msedge"], + "env": {}, + "required": true + } + } +} diff --git a/plugins/auto-research/README.md b/plugins/auto-research/README.md new file mode 100644 index 0000000..21a0fd7 --- /dev/null +++ b/plugins/auto-research/README.md @@ -0,0 +1,114 @@ +# Auto-Research Plugin · 自动研究插件 + +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) +[![Claude Code Plugin](https://img.shields.io/badge/Claude%20Code-Plugin-blue)](https://claude.ai/code) + +> **让 Claude Code 遇到不确定问题时,自动问 ChatGPT / 搜索网页,整理方案后等你拍板再动手。** +> +> Automatically research via ChatGPT (Playwright) or web search when uncertain — present options, wait for your approval, then code. + +--- + +## 🎬 效果演示 + +``` +用户: ? PyTorch 中自定义 ADMM 优化器怎么设计 +Claude: [自动打开 ChatGPT → 输入问题 → 抓取回答 → 整理方案] +Claude: GPT 建议方案 A,原因是 X Y Z。要继续实现吗? +用户: 行 +Claude: [开始写代码] +``` + +--- + +## 🔧 触发词 / Triggers + +| 输入 | 行为 | +|------|------| +| `?` | **确认去问 ChatGPT** — 把当前问题用 Playwright 打开 GPT 去问 | +| `??` | **搜索引擎调研** — WebSearch/WebFetch 查资料 | + +--- + +## 📦 安装 / Installation + +### Prerequisites + +**1. 安装 Playwright 浏览器扩展(一次性)** + +在 Edge 中打开,点击 "添加到 Edge" / "Add to Edge": + +> https://chromewebstore.google.com/detail/playwright-extension/mmlmfjhmonkocbjadbfplnigmagldckm + +Chrome 用户同理,点击 "添加至 Chrome"。 + +**2. 安装本插件** + +```bash +# GitHub 克隆安装 +git clone https://github.com/zyu51847-maker/Diooo.git auto-research-plugin +claude plugins install ./auto-research-plugin +``` + +**3. 批准 MCP Server** + +首次使用 Claude Code 会提示批准 Playwright MCP — 点 Allow 即可,一次批准全局生效。 + +--- + +## 🛠️ 工作原理 / How It Works + +| 组件 | 说明 | +|------|------| +| **Playwright MCP** | 通过浏览器扩展直连 Edge/Chrome,自动携带登录态和 Cookie | +| **ChatGPT** | ProseMirror 编辑器交互,`keyboard.type()` 输入,`data-testid="send-button"` 提交 | +| **WebSearch** | 搜索引擎查博客、论文、开源项目 | +| **WebFetch** | 抓取具体网页提炼关键信息 | + +全程在浏览器窗口可见,用户监控每一步操作。 + +--- + +## 📁 插件结构 / Structure + +``` +auto-research-plugin/ +├── .claude-plugin/ +│ └── plugin.json # 插件元数据 + MCP 声明 +├── skills/ +│ └── auto-research/ +│ └── SKILL.md # 核心行为规则 +├── .mcp.json # Playwright MCP 参考配置 +├── package.json # npm 打包信息 +└── README.md # 本文件 +``` + +--- + +## 🚀 进阶安装 / Advanced + +从 GitHub 直接安装到全局: + +```bash +claude plugins install https://github.com/zyu51847-maker/Diooo.git +``` + +或手动配置 MCP(不装插件,只配 MCP server): + +```bash +claude mcp add playwright -s user -- npx -y @playwright/mcp@latest --extension --browser msedge +``` + +--- + +## 🌐 让别人发现 / Discovery + +- [Claude Code Plugin Marketplace](https://claude.ai/code) +- [MCP Server Directory](https://glama.ai/mcp) +- [MCP Server Directory 2](https://mcpserver.so) + +--- + +## 📄 License + +MIT diff --git a/plugins/auto-research/skills/auto-research/SKILL.md b/plugins/auto-research/skills/auto-research/SKILL.md new file mode 100644 index 0000000..7ad893f --- /dev/null +++ b/plugins/auto-research/skills/auto-research/SKILL.md @@ -0,0 +1,82 @@ +--- +name: auto-research +description: Use when implementing tasks where design choices, algorithm details, API usage, or best practices are uncertain — automatically research via ChatGPT (Playwright) or web search, present options, and wait for user approval before coding +--- + +# 自动研究 + 用户决策流程 + +## 核心规则 + +遇到不确定的问题时,先自己研究,再让用户拍板: + +1. **自动搜索** — 使用 Playwright(ChatGPT)或 WebSearch/WebFetch 调研 +2. **整理呈现** — 提炼为简洁方案建议(含来源),展示给用户 +3. **等待裁决** — 用户说"行"后,才开始写代码 + +## 触发词 + +| 输入 | 行为 | +|------|------| +| `?` | **一键反馈给 GPT** — 把当前对话上下文(含 Claude 上一条输出)自动拿去问 ChatGPT,获取反馈/验证/改进建议 | +| `??` | 搜索引擎调研 — WebSearch/WebFetch 查资料 | + +### `?` 的上下文拼接规则 + +用户输入 `?` 时,将以下内容拼接成 ChatGPT prompt: + +1. 用户最近一条有意义的问题/指令 +2. Claude 最近一条输出(摘要 + 关键结论) +3. 追问:"请评估上述方案/输出的正确性、完整性和可改进之处" + +然后打开 ChatGPT → 输入 → 抓回答 → 呈现。 + +## Playwright 浏览器自动化流程 + +配置:`@playwright/mcp@latest --extension --browser msedge`,通过浏览器扩展连接用户 Edge。 + +1. Edge 保持运行,Playwright 通过扩展直连,自动携带登录态和 Cookie +2. 导航、输入、抓取内容 — 用户可在 Edge 窗口实时看到 +3. 完毕后整理回答呈现,等用户裁决 + +### 性能优化 + +| 优化 | 做法 | 效果 | +|------|------|------| +| **JS 注入文字** | `page.locator('#prompt-textarea').fill(text)` 替代 `keyboard.type()` | ~15s → ~0.1s | +| **复用标签页** | 首次导航后保持页面,后续 `?` 直接复用已加载的 SPA | 节省 ~3-5s | + +### 交互 API + +```javascript +// 填入文字(瞬间注入,比 keyboard.type() 快 100 倍) +await page.locator('div#prompt-textarea').fill(prompt); + +// 点击发送 +await page.locator('[data-testid="send-button"]').click(); + +// 等待回复(观察 DOM 变化或固定等待) +await page.waitForSelector('[data-message-author-role="assistant"]'); + +// 提取最后一条回复 +const response = await page.evaluate(() => { + const turns = document.querySelectorAll('[data-message-author-role="assistant"]'); + return turns[turns.length - 1]?.textContent; +}); +``` + +## 什么算"不确定" + +- 多个可行方案,各有取舍 +- 算法/API 细节记不清 +- 不知道某个库的用法 +- 架构/设计层面的选择 + +## 什么不算 + +- 语法拼写、简单 API 调用(直接写) +- 用户已明确指定做法 +- 纯粹的单行修改 + +## 原则 + +**宁可多搜一次,不要瞎写一段。用户拍板后再动手。**