Skip to content

Commit d69dde7

Browse files
JusterZhuclaude
andauthored
sync(agent-skills): update website docs to match codegen v10.5.0-beta.4 (#125)
* sync(agent-skills): update website docs to match codegen v10.5.0-beta.4 - Bump version from 0.0.1-beta.1 to 0.0.2-beta.1 - Configinfo → UpdateRequest API across all pages - Add AppType enum, SetSource(), AddListenerProgress() coverage - Add 2 new skills: generalupdate-migration, generalupdate-security-audit - Add developer integration roadmap and unified verification checklist - Update Bowl section: BowlContext + LaunchAsync (v10.5.0-beta.4) - Update DiffPipelineBuilder differential engine section - Add detailed strategy decision tree with 19 combinations - Add anti-pattern checklists to all skill pages - Update English i18n to match Chinese docs - Register new pages in sidebars.js Co-Authored-By: Claude <noreply@anthropic.com> * fix(agent-skills): address Copilot review comments - Fix namespace: GeneralUpdate.Differential.Matchers → GeneralUpdate.Core.Differential - Fix log glob: generalupdate-trace *.log → generalupdate-trace-*.log - Fix skill path: skills/ → .claude/skills/ in search commands - Fix event count: 6 → 7 events (missing AddListenerProgress) Co-Authored-By: Claude <noreply@anthropic.com> * fix: escape <T> in overview.md to fix MDX compilation <T> outside backticks was parsed as JSX tag by Docusaurus MDX, causing CI build failure. Added backticks around Hooks<T>() and Strategy<T>(). Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent edfe7e5 commit d69dde7

17 files changed

Lines changed: 2107 additions & 359 deletions

website/docs/agent-skills/generalupdate-advanced.md

Lines changed: 168 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,55 @@ title: 🔧 generalupdate-advanced — 高级定制参考
88

99
涵盖扩展点架构、Pipeline 管道、差分引擎、Bowl 崩溃守护、事件系统、文件系统工具等。
1010

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 策略接口
11+
> ⚠️ **API 版本说明**:本指南基于 **NuGet v10.5.0-beta.4**
12+
> 以下功能在 v10.5.0-beta.4 中全部**可用**
13+
> -`IUpdateHooks` 生命周期钩子(`Hooks<T>()`
14+
> -`IStrategy` 自定义策略注入(`Strategy<T>()`
15+
> -`SilentPollOrchestrator` 静默轮询器(`Option.Silent`
16+
> -`Option` 可编程配置系统
17+
> -`ISslValidationPolicy` SSL 策略接口
18+
> -`IHttpAuthProvider` HTTP 认证提供者
19+
> -`DiffPipelineBuilder` 差分管道配置
1920
>
20-
> 各功能的可用性在文中已标注
21+
> 各功能的命名空间和用法在文中已标注
2122
2223
---
2324

24-
## 1. Pipeline 管道系统(v10.4.6 可用)
25+
## 📋 用户需求提取
26+
27+
```
28+
### 定制目标(必需)
29+
- 需要什么定制: ______(Bowl 崩溃守护 / IPC 替换 / Pipeline 定制 / 自定义策略 / AOT / Drivelution / 黑名单 / 认证提供者 / 差分引擎)
30+
- 使用的 GeneralUpdate 版本: ______(v10.4.6 稳定版 / v10.5.0+ 开发分支)
31+
- .NET 版本: ______(.NET 6/8/9/10)
32+
33+
### Bowl(如果选择)
34+
- 被监控进程名: ______
35+
- 工作模式: ______(Normal / Upgrade)
36+
- 是否需要崩溃 Dump: ______(是/否)
37+
- 备份目录路径: ______
38+
39+
### IPC 替换(如果选择)
40+
- 替换方式: ______(NamedPipe / SharedMemory / 自定义)
41+
- 目标平台: ______(Windows / Linux / macOS / 跨平台)
42+
- 安全要求: ______(加密 / 签名 / 无额外安全)
43+
44+
### AOT(如果选择)
45+
- 当前剪裁警告: ______(有/无)
46+
- 是否使用反射: ______(是/否)
47+
- JSON 序列化需求: ______(有/无)
48+
```
49+
50+
---
51+
52+
## 1. Pipeline 管道系统(v10.5.0-beta.4 可用)
2553

2654
GeneralUpdate 使用 Pipeline 管道模式处理更新包的校验、解压、补丁应用。
2755

2856
### PipelineBuilder API
2957

3058
```csharp
31-
using GeneralUpdate.Common.Internal.Pipeline;
32-
using GeneralUpdate.Common.Internal.Strategy;
59+
using GeneralUpdate.Core.Pipeline;
3360

3461
// 创建管道上下文
3562
var context = new PipelineContext();
@@ -44,7 +71,7 @@ context.Add("PatchEnabled", true);
4471
await new PipelineBuilder(context)
4572
.UseMiddleware<HashMiddleware>() // 哈希校验
4673
.UseMiddleware<CompressMiddleware>() // 解压
47-
.UseMiddleware<PatchMiddleware>() // 差分补丁(需安装 Differential 包)
74+
.UseMiddleware<PatchMiddleware>() // 差分补丁
4875
.Build();
4976
```
5077

@@ -57,35 +84,29 @@ await new PipelineBuilder(context)
5784

5885
---
5986

60-
## 2. 策略系统(v10.4.6 可用)
87+
## 2. 策略系统(v10.5.0-beta.4 可用)
6188

62-
GeneralUpdate 内置三种平台策略,通过 `AbstractStrategy` 模板方法模式实现
89+
GeneralUpdate 内置三种平台策略,通过 `IStrategy` 接口实现
6390

6491
| 策略 | 类名 | 平台 |
6592
|------|------|------|
6693
| Windows | `WindowsStrategy` | Windows |
6794
| Linux | `LinuxStrategy` | Linux |
6895
| OSS | `OSSStrategy` | 跨平台(对象存储) |
6996

70-
> ⚠️ 稳定版**不支持**通过 `bootstrap.Strategy<T>()` 注入自定义策略。
71-
> 自定义策略需要继承 `AbstractStrategy` 并直接调用
97+
> ✅ 支持通过 `bootstrap.Strategy<T>()` 注入自定义策略。
98+
> 自定义策略需要实现 `IStrategy` 接口
7299
73100
---
74101

75-
## 3. Bowl 崩溃守护(v10.4.6 存在但功能有限)
76-
77-
Bowl 是一个崩溃监控组件,通过 `MonitorParameter` 配置。
102+
## 3. Bowl 崩溃守护(v10.5.0-beta.4)
78103

79-
> ⚠️ **注意**:v10.4.6 的 Bowl 仅提供基础类型定义,`Bowl` 类没有公开的 `LaunchAsync` 方法。
80-
> 完整功能在开发分支(v10.5.0-beta.2)中。
81-
82-
### MonitorParameter 配置
104+
Bowl 是一个崩溃监控组件,通过 `BowlContext` 配置。
83105

84106
```csharp
85107
using GeneralUpdate.Bowl;
86-
using GeneralUpdate.Bowl.Strategys;
87108

88-
var param = new MonitorParameter
109+
var context = new BowlContext
89110
{
90111
ProcessNameOrId = "MyApp.exe",
91112
DumpFileName = "v1.0.0.0_fail.dmp",
@@ -94,26 +115,40 @@ var param = new MonitorParameter
94115
FailDirectory = @"C:\Program Files\MyApp\fail",
95116
BackupDirectory = @"C:\Program Files\MyApp\backup",
96117
WorkModel = "Upgrade",
118+
TimeoutMs = 30_000,
119+
AutoRestore = true,
120+
OnCrash = async (info, ct) => Console.WriteLine($"Crash: {info.DumpFilePath}"),
97121
};
98122

99-
// Bowl 实例(v10.4.6 无公开 LaunchAsync,此为占位)
100123
var bowl = new Bowl();
124+
var result = await bowl.LaunchAsync(context);
125+
Console.WriteLine($"Result: Success={result.Success}, Restored={result.Restored}");
101126
```
102127

103-
完整 Bowl 崩溃守护功能请关注 GeneralUpdate 后续版本。
104-
105-
### Bowl 引用规则
106-
107-
Bowl 引用规则:只用 `GeneralUpdate.Bowl`(传递依赖 Core,两者不能同时引用)。
128+
| 属性 | 类型 | 说明 |
129+
|------|------|------|
130+
| `ProcessNameOrId` | string | 被监控的进程名或 PID(必填) |
131+
| `TargetPath` | string | 应用安装根目录(必填) |
132+
| `DumpFileName` | string | Dump 文件名(必填) |
133+
| `FailFileName` | string | 故障报告文件名(必填) |
134+
| `FailDirectory` | string | 崩溃报告输出目录(必填) |
135+
| `BackupDirectory` | string | 备份目录(必填) |
136+
| `WorkModel` | string | "Upgrade" 或 "Normal" |
137+
| `TimeoutMs` | int | 监控超时(毫秒),默认 30000 |
138+
| `AutoRestore` | bool | 崩溃后自动回滚 |
139+
| `DumpType` | DumpType | Mini / Full |
140+
| `OnCrash` | delegate | 崩溃回调 |
141+
142+
> ⚠️ NuGet v10.5.0-beta.4 中 Bowl 和 Core **无类型冲突**,可以同时引用。
108143
109144
---
110145

111-
## 4. EventManager 事件系统(v10.4.6 可用)
146+
## 4. EventManager 事件系统(v10.5.0-beta.4 可用)
112147

113148
EventManager 是一个全局单例,提供事件的发布和订阅:
114149

115150
```csharp
116-
using GeneralUpdate.Common.Internal.Event;
151+
using GeneralUpdate.Core.Event;
117152

118153
// 添加监听
119154
EventManager.Instance.AddListener((object? sender, UpdateInfoEventArgs e) =>
@@ -131,57 +166,82 @@ EventManager.Instance.Clear();
131166
EventManager.Instance.Dispose();
132167
```
133168

134-
> ⚠️ EventManager 是全局单例,`Dispose()``Instance` 仍然可访问(代码审计发现)
169+
> ⚠️ EventManager 是全局单例,`Dispose()``Instance` 仍然可访问。
135170
136171
---
137172

138-
## 5. 文件系统工具(v10.4.6 可用)
173+
## 5. 文件系统工具(v10.5.0-beta.4 可用)
139174

140175
### BlackList(黑名单)
141176

142-
`Configinfo` 支持通过以下属性排除文件:
177+
`UpdateRequest` 支持通过以下属性排除文件:
143178

144179
```csharp
145-
var config = new Configinfo
180+
var config = new UpdateRequest
146181
{
147182
// ...
148-
BlackFiles = new List<string> { "*.log", "*.tmp" },
149-
BlackFormats = new List<string> { ".pdb", ".vshost.exe" },
150-
SkipDirectorys = new List<string> { "logs", "cache", "temp" },
183+
Files = new List<string> { "*.log", "*.tmp" },
184+
Formats = new List<string> { ".pdb", ".vshost.exe" },
185+
Directories = new List<string> { "logs", "cache", "temp" },
151186
};
152187
```
153188

189+
黑名单内部通过 `ToBlackPolicy()` 转换为 `BlackPolicy` 记录。
190+
154191
### FileTree(文件树对比)
155192

156193
```csharp
157-
using GeneralUpdate.Common.FileBasic;
194+
using GeneralUpdate.Core.FileSystem;
158195

159196
var tree = new FileTree();
160197
var snapshot = tree.CreateSnapshot(@"C:\Program Files\MyApp");
161-
// 或从 StorageManager 获取比较结果
162198
```
163199

164200
---
165201

166-
## 6. 差分引擎(v10.4.6 可用,需安装 Differential 包)
202+
## 6. 差分引擎(v10.5.0-beta.4 可用,无需额外安装包)
203+
204+
差分类型已内嵌在 `GeneralUpdate.Core` 中,**无需额外**安装 `GeneralUpdate.Differential` 包。
167205

168-
安装 `GeneralUpdate.Differential` 包后可用:
206+
### DiffPipelineBuilder 方式(推荐)
169207

170208
```csharp
171-
// DifferentialCore 提供核心差分能力
172-
using GeneralUpdate.Differential;
209+
using GeneralUpdate.Core.Pipeline;
210+
211+
var pipeline = new DiffPipelineBuilder()
212+
.UseDiffer(new StreamingHdiffDiffer()) // 差分算法
213+
.UseCleanMatcher(new DefaultCleanMatcher()) // 文件匹配器(服务端)
214+
.UseDirtyMatcher(new DefaultDirtyMatcher()) // 文件匹配器(客户端)
215+
.WithParallelism(4)
216+
.WithStopOnFirstError(true)
217+
.WithProgress(new Progress<DiffProgress>(p =>
218+
Console.WriteLine($"[{p.Completed}/{p.Total}] {p.FileName}")))
219+
.Build();
173220

174-
// 清理模式(服务端):对比新旧版本生成补丁
175-
await DifferentialCore.CleanAsync(srcDir, tgtDir, patchDir);
221+
// 服务端:生成补丁
222+
await pipeline.CleanAsync(oldDir, newDir, patchDir);
176223

177-
// 脏模式(客户端:应用补丁
178-
await DifferentialCore.DirtyAsync(installDir, patchDir);
224+
// 客户端:应用补丁
225+
await pipeline.DirtyAsync(appDir, patchDir);
179226
```
180227

181-
自定义匹配器(v10.4.6 可用):
228+
### Bootstrap 集成方式
182229

183230
```csharp
184-
using GeneralUpdate.Differential.Matchers;
231+
new GeneralUpdateBootstrap()
232+
.SetConfig(config)
233+
.UseDiffPipeline(pipeline =>
234+
{
235+
pipeline.WithParallelism(2)
236+
.WithStopOnFirstError(true);
237+
})
238+
.LaunchAsync();
239+
```
240+
241+
### 自定义匹配器
242+
243+
```csharp
244+
using GeneralUpdate.Core.Differential;
185245

186246
// 自定义清理匹配器
187247
var cleanMatcher = new DefaultCleanMatcher(); // 或实现 ICleanMatcher
@@ -192,7 +252,7 @@ var dirtyMatcher = new DefaultDirtyMatcher(); // 或实现 IDirtyMatcher
192252

193253
## 7. AOT / NativeAOT 兼容性
194254

195-
GeneralUpdate.Core v10.4.6 支持 .NET Native AOT:
255+
GeneralUpdate.Core v10.5.0-beta.4 支持 .NET Native AOT`net8.0``net10.0`
196256

197257
```xml
198258
<PropertyGroup>
@@ -204,10 +264,10 @@ GeneralUpdate.Core v10.4.6 支持 .NET Native AOT:
204264
JSON 序列化上下文(减少 AOT 大小):
205265

206266
```csharp
207-
using GeneralUpdate.Common.Internal.JsonContext;
267+
using GeneralUpdate.Core.JsonContext;
208268

209269
// 使用内置的 JsonSerializerContext
210-
// VersionRespJsonContext, PacketJsonContext, ProcessInfoJsonContext
270+
// VersionRespJsonContext, ProcessContractJsonContext, HttpParameterJsonContext
211271
```
212272

213273
---
@@ -235,24 +295,60 @@ var result = GeneralDrivelution.InstallDriver(driverPath);
235295

236296
| 主题 | 可用性 | 参考 |
237297
|------|--------|------|
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 属性 |
298+
| Pipeline 管道 | ✅ v10.5.0-beta.4 | `GeneralUpdate.Core.Pipeline` |
299+
| 策略系统 | ✅ v10.5.0-beta.4 | `GeneralUpdate.Core.Strategy` |
300+
| FileTree | ✅ v10.5.0-beta.4 | `GeneralUpdate.Core.FileSystem` |
301+
| BlackList | ✅ v10.5.0-beta.4 | `UpdateRequest.Files/Formats/Directories``ToBlackPolicy()` |
302+
| 差分引擎 | ✅ 内嵌 Core | `DiffPipelineBuilder` / `DiffPipeline` |
303+
| AOT | ✅ v10.5.0-beta.4 | `JsonSerializerContext` 子类 |
304+
| EventManager | ✅ v10.5.0-beta.4 | `GeneralUpdate.Core.Event` |
305+
| Bowl 崩溃守护 | ✅ v10.5.0-beta.4 | `GeneralUpdate.Bowl.Bowl` |
306+
| IUpdateHooks | ✅ v10.5.0-beta.4 | `GeneralUpdate.Core.Hooks``Hooks<T>()` |
307+
| 自定义 Strategy 注入 | ✅ v10.5.0-beta.4 | `Strategy<T>()` |
308+
| IPC 替换接口 | ❌ 暂不支持 | 使用 NamedPipe 替代方案 |
309+
| SilentPollOrchestrator | ✅ v10.5.0-beta.4 | `Option.Silent` + `SetOption()` |
310+
| Option 系统 | ✅ v10.5.0-beta.4 | `SetOption<T>(Option<T>, T)` |
311+
312+
---
313+
314+
## ✅ 高级定制验证清单
315+
316+
### Bowl 崩溃守护
317+
- [ ] 如果用 Bowl:项目中同时引用 `GeneralUpdate.Core``GeneralUpdate.Bowl`(v10.5.0-beta.4 无冲突)
318+
- [ ] `BowlContext``ProcessNameOrId` 与实际进程名匹配
319+
- [ ] `TargetPath` 设置为应用安装根目录,非子目录
320+
- [ ] `WorkModel` 根据场景选择 Correct(Normal/Upgrade)
321+
- [ ] `FailDirectory` 有写入权限
322+
- [ ] Linux/macOS 无此功能(Bowl 仅 Windows)
323+
324+
### Pipeline 定制
325+
- [ ] `PipelineContext` 中的 Key 名称使用字符串常量拼写正确
326+
- [ ] 中间件注册顺序正确:Hash → Compress → Patch → Drivelution
327+
- [ ] `Encoding` 设置为 `Encoding.UTF8`
328+
329+
### AOT/NativeAOT
330+
- [ ] 启用了 `<IsAotCompatible>true</IsAotCompatible>`
331+
- [ ] 对反射路径添加了 `[DynamicDependency]``[RequiresUnreferencedCode]`
332+
- [ ] 使用了内置的 `JsonSerializerContext` 子类(减少裁剪)
333+
334+
---
335+
336+
## ⚠️ 反模式清单
337+
338+
| # | 反模式 | 后果 | 正确做法 |
339+
|---|--------|------|---------|
340+
| 1 | **在 v10.4.6 稳定版上使用开发分支 API(IUpdateHooks 等)** | 编译失败 / 运行时 MissingMethodException | 检查 API 可用性表 |
341+
| 2 | **PipelineContext Key 拼写错误** | Pipeline 运行异常,值未传递 | 使用类库公开的常量或文档中的 Key 名 |
342+
| 3 | **Bowl 的 WorkModel 设为 Upgrade 但进程是主程序** | 监控逻辑错误 | Normal=主线进程,Upgrade=升级进程 |
343+
| 4 | **Windows 上 IPC 使用默认加密密钥** | 加密可被破解 | 使用强密钥(≥ 32 字符) |
344+
| 5 | **差分包生成时使用不同版本的源文件结构** | 补丁应用失败 | 源和目标版本的文件结构必须一致 |
345+
| 6 | **AOT 项目中使用了大量反射且未标记 DynamicDependency** | 运行时 TypeLoadException | 使用源代码生成器或显式标记保留 |
346+
| 7 | **Pipeline 中 PatchMiddleware 排在 CompressMiddleware 前面** | 未解压就试图打补丁 | 顺序必须是 Compress→Patch |
251347

252348
---
253349

254350
## 相关技能
255351

256-
- [🚀 generalupdate-init — Bootstrap 配置](./generalupdate-init.md)
257-
- [⚙️ generalupdate-strategy — 更新策略选择](./generalupdate-strategy.md)
258-
- [🩺 generalupdate-troubleshoot — 问题诊断](./generalupdate-troubleshoot.md)
352+
- `/generalupdate-init` — Bootstrap 配置
353+
- `/generalupdate-strategy` — 更新策略选择
354+
- `/generalupdate-troubleshoot` — 问题诊断

0 commit comments

Comments
 (0)