Skip to content

Commit edfe7e5

Browse files
JusterZhuclaude
andauthored
docs: add Agent Skills documentation pages with standalone sidebar (#124)
- Add 6 Agent Skills doc pages (overview, init, ui, strategy, advanced, troubleshoot) - Create independent agentSkillsSidebar separate from doc sidebar - Add Agent Skills navbar item alongside Doc - Add Chinese (zh-Hans) and English (en) i18n versions - Include installation guide for Claude Code skills - Include feedback section with GitHub Issues links Co-authored-by: Claude <noreply@anthropic.com>
1 parent 21131f9 commit edfe7e5

16 files changed

Lines changed: 1974 additions & 0 deletions
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "Agent Skills",
3+
"position": 4,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "Claude Code Agent Skills 使用教程 — 帮助 .NET 开发者在 5 分钟内将 GeneralUpdate 自动更新系统集成到任意 .NET 应用中。覆盖 50+ 真实 Issue 发现的已知问题,提供即用型代码生成 + 深度故障排查。"
7+
}
8+
}
Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
---
2+
sidebar_position: 5
3+
sidebar_label: 🔧 高级定制
4+
title: 🔧 generalupdate-advanced — 高级定制参考
5+
---
6+
7+
# 🔧 GeneralUpdate 高级定制参考
8+
9+
涵盖扩展点架构、Pipeline 管道、差分引擎、Bowl 崩溃守护、事件系统、文件系统工具等。
10+
11+
> ⚠️ **API 版本说明**:本指南基于 **NuGet v10.4.6 稳定版**
12+
>
13+
> 以下功能在稳定版中**不存在**(但在开发分支 v10.5.0-beta.2 中已有):
14+
> - `IUpdateHooks` 生命周期钩子
15+
> - `IProcessInfoProvider` IPC 替换接口
16+
> - `SilentPollOrchestrator` 静默轮询器
17+
> - `Option` 可编程配置系统(v10.4.6 仅使用 `Configinfo` 属性)
18+
> - `ISslValidationPolicy` SSL 策略接口
19+
>
20+
> 各功能的可用性在文中已标注。
21+
22+
---
23+
24+
## 1. Pipeline 管道系统(v10.4.6 可用)
25+
26+
GeneralUpdate 使用 Pipeline 管道模式处理更新包的校验、解压、补丁应用。
27+
28+
### PipelineBuilder API
29+
30+
```csharp
31+
using GeneralUpdate.Common.Internal.Pipeline;
32+
using GeneralUpdate.Common.Internal.Strategy;
33+
34+
// 创建管道上下文
35+
var context = new PipelineContext();
36+
context.Add("ZipFilePath", @"C:\temp\update.zip");
37+
context.Add("Hash", "sha256-hex-value");
38+
context.Add("Format", 0); // 0=Zip
39+
context.Add("Encoding", System.Text.Encoding.UTF8);
40+
context.Add("SourcePath", @"C:\Program Files\MyApp");
41+
context.Add("PatchEnabled", true);
42+
43+
// 构建并执行管道
44+
await new PipelineBuilder(context)
45+
.UseMiddleware<HashMiddleware>() // 哈希校验
46+
.UseMiddleware<CompressMiddleware>() // 解压
47+
.UseMiddleware<PatchMiddleware>() // 差分补丁(需安装 Differential 包)
48+
.Build();
49+
```
50+
51+
| 中间件 | 类名 | 命名空间 | 功能 |
52+
|--------|------|---------|------|
53+
| 哈希校验 | `HashMiddleware` | `GeneralUpdate.Core.Pipeline` | SHA256 完整性校验 |
54+
| 解压 | `CompressMiddleware` | `GeneralUpdate.Core.Pipeline` | 解压 ZIP 包 |
55+
| 差分补丁 | `PatchMiddleware` | `GeneralUpdate.Core.Pipeline` | 应用 BSDIFF/HDiffPatch 补丁 |
56+
| 驱动更新 | `DrivelutionMiddleware` | `GeneralUpdate.Core.Pipeline` | Windows 驱动安装 |
57+
58+
---
59+
60+
## 2. 策略系统(v10.4.6 可用)
61+
62+
GeneralUpdate 内置三种平台策略,通过 `AbstractStrategy` 模板方法模式实现:
63+
64+
| 策略 | 类名 | 平台 |
65+
|------|------|------|
66+
| Windows | `WindowsStrategy` | Windows |
67+
| Linux | `LinuxStrategy` | Linux |
68+
| OSS | `OSSStrategy` | 跨平台(对象存储) |
69+
70+
> ⚠️ 稳定版**不支持**通过 `bootstrap.Strategy<T>()` 注入自定义策略。
71+
> 自定义策略需要继承 `AbstractStrategy` 并直接调用。
72+
73+
---
74+
75+
## 3. Bowl 崩溃守护(v10.4.6 存在但功能有限)
76+
77+
Bowl 是一个崩溃监控组件,通过 `MonitorParameter` 配置。
78+
79+
> ⚠️ **注意**:v10.4.6 的 Bowl 仅提供基础类型定义,`Bowl` 类没有公开的 `LaunchAsync` 方法。
80+
> 完整功能在开发分支(v10.5.0-beta.2)中。
81+
82+
### MonitorParameter 配置
83+
84+
```csharp
85+
using GeneralUpdate.Bowl;
86+
using GeneralUpdate.Bowl.Strategys;
87+
88+
var param = new MonitorParameter
89+
{
90+
ProcessNameOrId = "MyApp.exe",
91+
DumpFileName = "v1.0.0.0_fail.dmp",
92+
FailFileName = "v1.0.0.0_fail.json",
93+
TargetPath = @"C:\Program Files\MyApp",
94+
FailDirectory = @"C:\Program Files\MyApp\fail",
95+
BackupDirectory = @"C:\Program Files\MyApp\backup",
96+
WorkModel = "Upgrade",
97+
};
98+
99+
// Bowl 实例(v10.4.6 无公开 LaunchAsync,此为占位)
100+
var bowl = new Bowl();
101+
```
102+
103+
完整 Bowl 崩溃守护功能请关注 GeneralUpdate 后续版本。
104+
105+
### Bowl 引用规则
106+
107+
Bowl 引用规则:只用 `GeneralUpdate.Bowl`(传递依赖 Core,两者不能同时引用)。
108+
109+
---
110+
111+
## 4. EventManager 事件系统(v10.4.6 可用)
112+
113+
EventManager 是一个全局单例,提供事件的发布和订阅:
114+
115+
```csharp
116+
using GeneralUpdate.Common.Internal.Event;
117+
118+
// 添加监听
119+
EventManager.Instance.AddListener((object? sender, UpdateInfoEventArgs e) =>
120+
{
121+
// 处理版本发现事件
122+
});
123+
124+
// 手动分发事件
125+
EventManager.Instance.Dispatch(this, new ExceptionEventArgs(ex, "自定义错误"));
126+
127+
// 清空所有监听
128+
EventManager.Instance.Clear();
129+
130+
// 释放
131+
EventManager.Instance.Dispose();
132+
```
133+
134+
> ⚠️ EventManager 是全局单例,`Dispose()``Instance` 仍然可访问(代码审计发现)。
135+
136+
---
137+
138+
## 5. 文件系统工具(v10.4.6 可用)
139+
140+
### BlackList(黑名单)
141+
142+
`Configinfo` 支持通过以下属性排除文件:
143+
144+
```csharp
145+
var config = new Configinfo
146+
{
147+
// ...
148+
BlackFiles = new List<string> { "*.log", "*.tmp" },
149+
BlackFormats = new List<string> { ".pdb", ".vshost.exe" },
150+
SkipDirectorys = new List<string> { "logs", "cache", "temp" },
151+
};
152+
```
153+
154+
### FileTree(文件树对比)
155+
156+
```csharp
157+
using GeneralUpdate.Common.FileBasic;
158+
159+
var tree = new FileTree();
160+
var snapshot = tree.CreateSnapshot(@"C:\Program Files\MyApp");
161+
// 或从 StorageManager 获取比较结果
162+
```
163+
164+
---
165+
166+
## 6. 差分引擎(v10.4.6 可用,需安装 Differential 包)
167+
168+
安装 `GeneralUpdate.Differential` 包后可用:
169+
170+
```csharp
171+
// DifferentialCore 提供核心差分能力
172+
using GeneralUpdate.Differential;
173+
174+
// 清理模式(服务端):对比新旧版本生成补丁
175+
await DifferentialCore.CleanAsync(srcDir, tgtDir, patchDir);
176+
177+
// 脏模式(客户端):应用补丁
178+
await DifferentialCore.DirtyAsync(installDir, patchDir);
179+
```
180+
181+
自定义匹配器(v10.4.6 可用):
182+
183+
```csharp
184+
using GeneralUpdate.Differential.Matchers;
185+
186+
// 自定义清理匹配器
187+
var cleanMatcher = new DefaultCleanMatcher(); // 或实现 ICleanMatcher
188+
var dirtyMatcher = new DefaultDirtyMatcher(); // 或实现 IDirtyMatcher
189+
```
190+
191+
---
192+
193+
## 7. AOT / NativeAOT 兼容性
194+
195+
GeneralUpdate.Core v10.4.6 支持 .NET Native AOT:
196+
197+
```xml
198+
<PropertyGroup>
199+
<IsAotCompatible>true</IsAotCompatible>
200+
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
201+
</PropertyGroup>
202+
```
203+
204+
JSON 序列化上下文(减少 AOT 大小):
205+
206+
```csharp
207+
using GeneralUpdate.Common.Internal.JsonContext;
208+
209+
// 使用内置的 JsonSerializerContext
210+
// VersionRespJsonContext, PacketJsonContext, ProcessInfoJsonContext 等
211+
```
212+
213+
---
214+
215+
## 8. Drivelution(Windows 驱动更新)
216+
217+
`GeneralUpdate.Drivelution` 包提供 Windows 驱动管理:
218+
219+
```csharp
220+
using GeneralUpdate.Drivelution;
221+
222+
// 扫描驱动目录
223+
var allDrivers = GeneralDrivelution.ScanDirectory(driverDir);
224+
225+
// 验证驱动
226+
var isValid = GeneralDrivelution.ValidateDriver(driverPath);
227+
228+
// 安装驱动(DIFx → SetupAPI → PnPUtil 级联)
229+
var result = GeneralDrivelution.InstallDriver(driverPath);
230+
```
231+
232+
---
233+
234+
## 内容索引
235+
236+
| 主题 | 可用性 | 参考 |
237+
|------|--------|------|
238+
| Pipeline 管道 | ✅ v10.4.6 | `GeneralUpdate.Common.Internal.Pipeline` |
239+
| 策略系统 | ✅ v10.4.6 | `GeneralUpdate.Common.Internal.Strategy` |
240+
| FileTree | ✅ v10.4.6 | `GeneralUpdate.Common.FileBasic` |
241+
| BlackList | ✅ v10.4.6 | `Configinfo.BlackFiles` 等属性 |
242+
| 差分引擎 | ✅ 需 `GeneralUpdate.Differential` | `DifferentialCore` |
243+
| AOT | ✅ v10.4.6 | `JsonSerializerContext` 子类 |
244+
| EventManager | ✅ v10.4.6 | `GeneralUpdate.Common.Internal.Event` |
245+
| Bowl 崩溃守护 | ⚠️ 基础类型 | `GeneralUpdate.Bowl.Bowl` |
246+
| IUpdateHooks | ❌ v10.4.6 不支持 | 开发分支 v10.5.0-beta.2 中 |
247+
| 自定义 Strategy 注入 | ❌ v10.4.6 不支持 | 开发分支 v10.5.0-beta.2 中 |
248+
| IPC 替换接口 | ❌ v10.4.6 不支持 | 开发分支 v10.5.0-beta.2 中 |
249+
| SilentPollOrchestrator | ❌ v10.4.6 不支持 | 开发分支 v10.5.0-beta.2 中 |
250+
| Option 系统 | ❌ v10.4.6 不支持 | 仅 Configinfo 属性 |
251+
252+
---
253+
254+
## 相关技能
255+
256+
- [🚀 generalupdate-init — Bootstrap 配置](./generalupdate-init.md)
257+
- [⚙️ generalupdate-strategy — 更新策略选择](./generalupdate-strategy.md)
258+
- [🩺 generalupdate-troubleshoot — 问题诊断](./generalupdate-troubleshoot.md)

0 commit comments

Comments
 (0)