Skip to content

Commit 9b310cb

Browse files
committed
docs: 工作原理图改为 sequenceDiagram 时序图(同步线+使用线双泳道)
1 parent 7a942de commit 9b310cb

1 file changed

Lines changed: 32 additions & 9 deletions

File tree

‎README.md‎

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,38 @@
2020
## 工作原理
2121

2222
```mermaid
23-
flowchart LR
24-
A[command-code 官方 npm] -->|每 6h 检测新版本| B[catalog-sync CI]
25-
B -->|sync-models 提取| C[models.json / _version.txt / manifest.json]
26-
C -->|直推 main| D[本仓库 raw GitHub URL]
27-
D -->|启动时 fetch 8s 超时| E[插件 config hook]
28-
E -->|成功| F[写本地缓存]
29-
E -->|失败| G[回退 bundled → 缓存]
30-
F --> H[opencode 模型列表]
31-
G --> H
23+
sequenceDiagram
24+
autonumber
25+
participant NPM as command-code 官方 npm
26+
participant CI as catalog-sync CI
27+
participant REPO as 本仓库 main
28+
participant PLUGIN as 插件 config hook
29+
participant CACHE as 本地缓存
30+
participant OC as opencode 模型列表
31+
32+
rect rgb(235, 248, 255)
33+
Note over NPM,REPO: 同步线 · 每 6 小时(后台)
34+
NPM->>CI: 发布新版本 command-code@X
35+
CI->>CI: 比对 _version.txt,版本不一致
36+
CI->>CI: sync-models 提取模型
37+
alt 提取成功且模型数达标
38+
CI->>REPO: 直推 models.json(不经 PR)
39+
else 提取失败 / 跌破保护线
40+
CI->>REPO: 开 catalog-break issue,不推坏数据
41+
end
42+
end
43+
44+
rect rgb(255, 250, 235)
45+
Note over PLUGIN,OC: 使用线 · 每次启动(用户可见)
46+
PLUGIN->>REPO: fetch raw models.json(8s 超时)
47+
alt 拉取成功
48+
PLUGIN->>CACHE: 写入缓存
49+
else 拉取失败
50+
PLUGIN->>CACHE: 回退 bundled → 缓存
51+
end
52+
CACHE->>PLUGIN: 模型列表
53+
PLUGIN->>OC: 注入 provider.commandcode.models
54+
end
3255
```
3356

3457
三处关键设计:

0 commit comments

Comments
 (0)