Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/README.skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ See [CONTRIBUTING.md](../CONTRIBUTING.md#adding-skills) for guidelines on how to
| [editorconfig](../skills/editorconfig/SKILL.md)<br />`gh skills install github/awesome-copilot editorconfig` | Generates a comprehensive and best-practice-oriented .editorconfig file based on project analysis and user preferences. | None |
| [ef-core](../skills/ef-core/SKILL.md)<br />`gh skills install github/awesome-copilot ef-core` | Get best practices for Entity Framework Core | None |
| [efcore-d2-db-diagram](../skills/efcore-d2-db-diagram/SKILL.md)<br />`gh skills install github/awesome-copilot efcore-d2-db-diagram` | Generate D2 database diagrams from Entity Framework Core models. USE FOR: EF Core database diagram, Entity Framework Core ERD, DbContext diagram, C# entity relationship diagram, PostgreSQL schema visualization, generate .d2 file from EF Core entities, Fluent API mapping diagram, migrations-based database diagram, table relationships, owned types, many-to-many join tables, indexes and constraints. DO NOT USE FOR: runtime debugging, database migration execution, schema deployment, SQL performance tuning, or draw.io diagrams. | `references/d2-erd-style.md`<br />`references/efcore-model-extraction.md`<br />`references/grouping-modes.md`<br />`references/quality-gate.md`<br />`references/relationship-rules.md` |
| [electron-debug](../skills/electron-debug/SKILL.md)<br />`gh skills install github/awesome-copilot electron-debug` | Use when validating Electron main-process, BrowserWindow, renderer, preload, or IPC changes, or investigating a blank window or runtime error in a running local Electron app. Collect Inspector/CDP status, targets, logs, and exceptions using the bundled attach-only MCP runtime for Agent-led verification. | `VERSION.md`<br />`references/mcp-setup.md`<br />`runtime/THIRD_PARTY_LICENSES.txt`<br />`runtime/launch.cjs`<br />`runtime/manifest.json`<br />`runtime/server.cjs` |
| [em-dash](../skills/em-dash/SKILL.md)<br />`gh skills install github/awesome-copilot em-dash` | Expert on the history, origin, and correct use of the em dash. Use when writing or reviewing code, comments, or data files to avoid em and en dashes, defaulting to never using them and replacing any found with a hyphen (-). Includes strong knowledge of punctuation marks and the proper usage of punctuation characters when writing comments. | None |
| [email-drafter](../skills/email-drafter/SKILL.md)<br />`gh skills install github/awesome-copilot email-drafter` | Draft and review professional emails that match your personal writing style. Analyzes your sent emails for tone, greeting, structure, and sign-off patterns via WorkIQ, then generates context-aware drafts for any recipient. USE FOR: draft email, write email, compose email, reply email, follow-up email, analyze email tone, email style. | None |
| [embedding-anisotropy-check](../skills/embedding-anisotropy-check/SKILL.md)<br />`gh skills install github/awesome-copilot embedding-anisotropy-check` | Use before reporting any cosine similarity computed over embeddings or transformer hidden states, whether the agent computed the vectors or loaded them. Measures the anisotropy of each side, centres by the population mean, and scores matched pairs against a permuted floor taken from the same comparison. Use when comparing one model's embeddings across precisions, runtimes or layers, when evaluating retrieval, probes or adapters, or before calling a similarity high, two conditions in agreement, or a small gap a null. | `scripts/anisotropy_check.py`<br />`scripts/example_scifact_halves.py` |
Expand Down
135 changes: 135 additions & 0 deletions skills/electron-debug/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
name: electron-debug
description: Use when validating Electron main-process, BrowserWindow, renderer, preload, or IPC changes, or investigating a blank window or runtime error in a running local Electron app. Collect Inspector/CDP status, targets, logs, and exceptions using the bundled attach-only MCP runtime for Agent-led verification.
license: MIT
---

# Electron Agent Debug

为编码 Agent 提供轻量、attach-only 的 Electron 诊断能力。MCP 返回运行时事实;Agent 准备应用、执行业务回归并自行判断结果。

## 触发条件

| 场景 | 行为与通道 |
| --- | --- |
| 主进程、BrowserWindow 或窗口生命周期修改后需要运行时验证 | 检查主进程 Inspector、日志及项目回归结果 |
| renderer 白屏、页面加载或前端异常 | 检查 renderer CDP、正确的 page target、日志及项目回归结果 |
| preload、contextBridge 或 IPC 修改 | 同时检查主进程和 renderer,双方各需证据,并执行覆盖调用链的项目回归 |
| 用户明确要求诊断已经运行的本地 Electron 应用 | 根据问题选择最小必要通道 |
| 纯类型或构建问题,无运行时观察需求 | 优先使用项目已有检查,不必 attach |
| 需要截图、DOM、evaluate、断点或交互操作 | 使用项目已有测试或其他工具;本 MCP 不提供这些能力 |

## 核心能力

| 工具 | 返回内容 |
| --- | --- |
| `electron_attach` | 两个通道各自的连接结果、target 和结构化错误 |
| `electron_status` | 当前在线状态、endpoint 来源、selected target 和事件数量 |
| `electron_targets` | renderer page targets 与明确选择结果 |
| `electron_logs` | 有界缓存中的日志、异常、连接和协议事件 |

MCP 不启动、停止、重启或操作 Electron,不执行页面代码,不修改用户项目。业务测试、视觉验证和最终验收由 Agent 使用项目已有工具完成。

## 使用方法

### 1. 准备随包 MCP

本 Skill 包含 `runtime/launch.cjs`、MCP JavaScript bundle、版本清单及依赖许可证。Agent 使用当前已安装 Skill 的实际绝对目录,运行环境需要 Node.js 22 或更高版本。

先确认安装渠道及版本符合当前任务要求,再执行本地完整性检查:

```text
node <absolute-skill-directory>/runtime/launch.cjs --verify
```

校验通过后,以同一个入口配置本地 MCP stdio Server:

```json
{
"mcpServers": {
"electron-agent-debug": {
"command": "node",
"args": ["<absolute-skill-directory>/runtime/launch.cjs"]
}
}
}
```

这只是配置概念示例。Agent 根据实际宿主查找配置入口,避免重复注册,按宿主规则刷新,并验证四个工具可见。Skill 安装不会自动注册 MCP。全局和项目级安装均使用对应 Skill 目录中的运行文件,不写死用户目录或配置路径。

运行文件缺失或校验失败时报告 `BLOCKED`,从已获准的安装渠道重新安装完整版本。正常使用不下载额外源码、不安装依赖、不在本机构建 MCP,也不以远程执行作为备用路径。

宿主配置、版本更新和校验边界见 [MCP 接入说明](references/mcp-setup.md)。当前包版本见 [VERSION.md](VERSION.md)。

### 2. 由 Agent 提供诊断前提

- Electron 项目目录、本次修改要证明的预期行为。
- 项目已有启动、停止或重启命令,以及测试或业务回归步骤。
- 已运行的 Electron 应用及本次实际使用的 Inspector 和/或 CDP discovery endpoint。
- 多窗口时的 target 选择条件。

Agent 可以通过项目已有启动命令支持的参数暴露所需 endpoint。端口由 Agent 或项目动态决定,不扫描端口、不猜测入口,也不为了接入 MCP 改写项目启动脚本。只允许本地回环 HTTP(S) discovery endpoint,其返回的 WebSocket 地址也必须是回环地址。

缺少必要前提且无法补齐时报告 `BLOCKED`,不要归因为用户代码失败。

## 工作流程

```text
┌──────────────────────────────────────────┐
│ 确认任务、包来源与诊断前提 │
└────────────────────┬─────────────────────┘
▼
┌──────────────────────────────────────────┐
│ 校验随包 MCP → 配置宿主 → 确认四工具可见 │
└────────────────────┬─────────────────────┘
▼
┌──────────────────────────────────────────┐
│ attach → status → 按需 targets → logs │
└────────────────────┬─────────────────────┘
▼
┌──────────────────────────────────────────┐
│ Agent 执行项目已有测试或业务回归 │
└────────────────────┬─────────────────────┘
▼
┌──────────────────────────────────────────┐
│ Agent 按需 reload / 重启 → 重新收集证据 │
└────────────────────┬─────────────────────┘
▼
┌──────────────────────────────────────────┐
│ Agent 根据预期行为与证据判断结果 │
│ PASS / FAIL / BLOCKED │
└──────────────────────────────────────────┘

任何阶段缺少必要前提或完整性检查失败
└─► BLOCKED:说明缺少什么
```

1. **收集基线**:向 `electron_attach` 传入本次实际的 `mainUrl` 和/或 `rendererUrl`;如使用环境变量,可以省略相应输入。分别记录两个通道的状态与错误。部分成功时保留可用通道证据。
2. **确认 target**:需要 renderer 时调用 `electron_targets`。一个可连接 page target 可自动选择;多个或同名窗口使用 `targetId`、完整 URL 或标题明确选择,歧义时不要静默选第一个。
3. **执行回归**:Agent 运行项目已有检查或业务操作。主进程、preload、BrowserWindow 或 IPC handler 修改后使用项目已有方式重启;renderer 修改后使用项目已有方式 reload。缺少必要操作时报告 `BLOCKED`。
4. **刷新证据**:Electron 重启或窗口重建后重新 attach。旧 target 失效时通过 `electron_targets` 的 `clearSelection=true` 清除旧条件,再选择当前窗口。读取 status、按需 targets 和 logs,比较回归前后结果。

日志只代表当前 MCP 观察到的事件,不保证包含 attach 前的历史。需要区分不同轮次时使用 `since` 或按范围清空缓存,并保留已经用于判断的证据。清空历史记录不等于错误已修复。

## 错误处理

| 情况 | Agent 的处理 |
| --- | --- |
| Node 不满足要求、运行文件缺失或完整性校验失败 | `BLOCKED`;说明缺少项,重新安装获准版本后再验证 |
| 找不到宿主配置入口、初始化失败或工具不可见 | 检查宿主配置和 stderr;不要归因于 Electron 业务代码 |
| 应用未运行、endpoint 不可用 | 核对本次启动结果和实际 endpoint;无法确定原因时报告 `BLOCKED` |
| 某一通道连接失败 | 保留另一通道的状态和证据,按本次修改范围判断是否足够 |
| target 歧义、断开或窗口已重建 | 重新发现并明确选择;不要沿用失效 target |
| 需要的业务、DOM 或视觉证据无法取得 | 使用项目其他工具补齐;无法补齐时说明验证限制 |

## 结论与输出

结论由 Agent 结合用户目标、项目回归和 MCP 事实自行生成:

- `PASS`:预期行为被实际回归或明确运行时观察证实,相关通道和 target 符合预期。
- `FAIL`:预期行为可执行但结果不符合要求,或有与本次修改相关的错误证据。区分已确认根因与推测。
- `BLOCKED`:缺少前提、可观察结果或必要回归,尚不能完成判断。

不能只凭 attach 成功、没有 console error 或存在日志输出 `PASS`。`electron_attach` 的 `ok` 只表示返回了结构化诊断结果。

报告包含:预期行为、诊断范围、本次修改、执行的回归、各通道关键证据、target、问题归属、根因确定程度、连接恢复操作和剩余限制。preload/IPC 需要主进程和 renderer 各至少一项证据,并有覆盖调用链的回归结果。
22 changes: 22 additions & 0 deletions skills/electron-debug/VERSION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 版本记录

## 1.0.4

- 在 description 中明确 Electron 代码变更验证、白屏和运行时错误等触发场景。
- 工作流程图增加框线及箭头,便于阅读与平台识别;诊断能力和 Agent 职责不变。

## 1.0.3

- MCP 0.1.1 与 Skill 一起交付,包含运行时 JavaScript 依赖;使用时无需额外下载、依赖安装或构建。
- 增加本地完整性启动器、构建输入摘要和第三方许可证。
- 增加触发条件表格、标准使用章节、ASCII 工作流程与错误处理。
- 旧宿主配置需切换到本版本的 `runtime/launch.cjs`。
- GitHub Release 来源证明绑定对应 tag 的源码提交;构建输入摘要见 `runtime/manifest.json`。平台包的发布版本与扫描结果由安装渠道提供。

## 1.0.2

补充独立 MCP 源码更新说明。本版本的独立下载和构建方式已由 1.0.3 的随包运行方式替代。

## 1.0.1

提供 Electron 双通道诊断流程、四个 MCP 工具接入说明与 Agent 自行验收边界。
77 changes: 77 additions & 0 deletions skills/electron-debug/references/mcp-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# MCP 接入说明

## 前提

Agent 宿主支持本地 MCP stdio Server;本机具备 Node.js 22 或更高版本;当前 Skill 已通过任务认可的安装渠道获取。应用运行、endpoint 和业务回归由 Agent 准备。

## 随包运行文件

MCP 与 Skill 一起交付,`runtime/server.cjs` 已包含运行时 JavaScript 依赖,不依赖源码目录、外部依赖安装目录或原生扩展。入口为 `runtime/launch.cjs`。正常安装后的使用流程不需要下载源码或执行安装、构建命令。

Agent 查找当前 Skill 的实际安装目录,不假设全局目录、项目目录或宿主配置文件路径。

```text
node <absolute-skill-directory>/runtime/launch.cjs --verify
```

成功结果包含 Skill 版本、MCP 版本和构建输入摘要。启动器在加载 MCP 前检查 manifest 和运行文件的 SHA-256,拒绝缺失、损坏或不匹配的文件;失败信息写入 stderr,且不启动 MCP。

## 来源与完整性边界

同包哈希可检测文件不一致,不能独立证明发布者身份,也不能证明代码没有漏洞。来源信任由用户或组织认可的安装渠道、平台扫描及发布证明建立,不能仅凭包自称可信。

GitHub Release 的 ZIP 可提供构建来源 attestation。需要核对来源时,在执行包内代码前,使用可信的 GitHub CLI 对原始 Release ZIP 验证预期仓库和工作流身份:

```text
gh attestation verify <absolute-release-zip> --repo longhun12346/electron-agent-debug --signer-workflow longhun12346/electron-agent-debug/.github/workflows/release.yml
```

该命令只验证产物来源,不下载或执行 MCP 代码。验证失败时停止;要求来源证明但没有相应证明时报告 `BLOCKED`,不要把本地哈希校验当成替代。OneTool 安装包使用平台的发布和扫描结果,不能用另一份 GitHub ZIP 的证明替它背书。

## 配置宿主

先确认包来源符合任务要求,再执行完整性检查。通过后,根据实际宿主注册以下本地入口:

```json
{
"mcpServers": {
"electron-agent-debug": {
"command": "node",
"args": ["<absolute-skill-directory>/runtime/launch.cjs"]
}
}
}
```

这是概念示例,字段与刷新方式以实际宿主为准。已存在相同 Server 时先核对其入口和版本,避免重复注册。刷新后确认 `electron_attach`、`electron_status`、`electron_targets`、`electron_logs` 可见。MCP 启动成功不代表 Electron 已启动或业务已通过。

## 更新与迁移

更新时从原获准渠道安装完整的新 Skill 版本,按宿主方式停止旧 MCP,把配置指向新版本的实际 `runtime/launch.cjs`,重新核对来源和完整性后刷新宿主。

旧版本如果指向独立源码目录下的入口,必须切换到随包启动器。不要继续复用旧进程或旧构建产物,不覆盖用户的源码修改。升级不需要修改待诊断 Electron 项目。

普通诊断复用当前获准版本,不在每次调用时自动联网升级。运行文件缺失、版本不符或校验失败时报告 `BLOCKED`,不自动回退到下载和执行外部代码。

## Endpoint 与保护参数

MCP 通过 stdio 通信,不监听诊断服务端口,也不启动 Electron。Agent 在调用 `electron_attach` 时传入实际回环 HTTP(S) discovery URL,或通过宿主提供环境变量:

```text
ELECTRON_DEBUG_MAIN_URL=<agent-provided-loopback-endpoint>
ELECTRON_DEBUG_CDP_URL=<agent-provided-loopback-endpoint>
```

可选保护参数沿用默认值,只有诊断确有需要时调整:

```text
ELECTRON_DEBUG_REQUEST_TIMEOUT_MS=<optional-request-timeout>
ELECTRON_DEBUG_DISCOVERY_TIMEOUT_MS=<optional-discovery-timeout>
ELECTRON_DEBUG_MAX_LOG_EVENTS=<optional-event-limit>
ELECTRON_DEBUG_MAX_LOG_BYTES=<optional-byte-limit>
ELECTRON_DEBUG_MAX_PROTOCOL_MESSAGE_BYTES=<optional-protocol-message-limit>
```

端口由 Agent 或项目启动方式动态确定;不扫描端口,不猜测 target。主进程问题使用 Inspector,renderer 问题使用 CDP,preload/IPC 使用双通道。Electron 重启后重新 attach;窗口重建后重新发现 target。

业务测试、DOM、视觉验证以及最终结论由 Agent 完成,MCP 只提供状态、target、日志和结构化错误。
Loading
Loading