cn-coding-mirrors 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/MIRRORS-STATUS.md +47 -0
- package/README.md +345 -2
- package/SECURITY.md +55 -0
- package/package.json +43 -4
- package/scripts/check-mirrors.sh +158 -0
- package/scripts/install.sh +39 -0
- package/skills/cn-coding-mirrors/SKILL.md +58 -0
- package/skills/cn-coding-mirrors/references/ai.md +65 -0
- package/skills/cn-coding-mirrors/references/docker.md +48 -0
- package/skills/cn-coding-mirrors/references/go.md +34 -0
- package/skills/cn-coding-mirrors/references/java.md +69 -0
- package/skills/cn-coding-mirrors/references/misc.md +52 -0
- package/skills/cn-coding-mirrors/references/node.md +54 -0
- package/skills/cn-coding-mirrors/references/python.md +87 -0
- package/skills/cn-coding-mirrors/references/rust.md +38 -0
- package/skills/cn-coding-mirrors/references/system.md +51 -0
- package/skills/cn-coding-mirrors/references/vcs.md +58 -0
- package/skills/docker-pull/SKILL.md +74 -0
- package/skills/docker-pull/scripts/dpull +656 -0
- package/skills/gh-download/SKILL.md +62 -0
- package/skills/gh-download/scripts/ghdl +267 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本遵循 [SemVer](https://semver.org/lang/zh-CN/)。
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2025-11-29
|
|
6
|
+
|
|
7
|
+
首个版本。
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- 技能 `cn-coding-mirrors`:pip/uv、npm/yarn/pnpm、maven/gradle、GOPROXY、cargo/rustup、
|
|
11
|
+
apt/apk/dnf/brew、conda、hf-mirror/ModelScope/PyTorch、Flutter/Composer/NuGet/CRAN/RubyGems/Helm、
|
|
12
|
+
docker registry、git/hg/svn 的国内镜像配置速查(`references/` 10 篇)。
|
|
13
|
+
- 技能 `gh-download`:`scripts/ghdl`,GitHub release 资产分片下载,镜像轮转 + sha256 校验 + 断点续传。
|
|
14
|
+
- 技能 `docker-pull`:`scripts/dpull`,按 registry v2 协议走国内镜像源分片拉取 OCI 镜像并 `docker load`。
|
|
15
|
+
- `scripts/check-mirrors.sh`:38 个镜像端点实时可用性探测(表格/Markdown/JSON/`--strict`)。
|
|
16
|
+
- `scripts/install.sh`:安装到任意 Agent Skills 兼容目录(`~/.agents/skills` 等)。
|
|
17
|
+
- `MIRRORS-STATUS.md`:最近一次探测快照(脚本生成)。
|
|
18
|
+
|
|
19
|
+
### Known limitations
|
|
20
|
+
- `dpull` 仅支持匿名公开镜像。
|
|
21
|
+
- `dpull` 生成 tar 需 Docker 25+ 才能 `load`。
|
|
22
|
+
- 镜像站可用性无长期保证,以 `MIRRORS-STATUS.md` 为准。
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 cn-mirrors contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# 镜像源实时可用性
|
|
2
|
+
|
|
3
|
+
> 由 `scripts/check-mirrors.sh --write` 生成,勿手改。上次探测:**2026-11-29 04:26 UTC**
|
|
4
|
+
> 共 38 项:**OK 33** · 降级(SLOW/AUTH) 5 · 不可用 0
|
|
5
|
+
|
|
6
|
+
| 生态 | 源 | 状态 | HTTP | 耗时(s) |
|
|
7
|
+
|---|---|---|---|---|
|
|
8
|
+
| Python | **tuna pypi** | OK | 206 | 0.417647 |
|
|
9
|
+
| Python | aliyun pypi | OK | 206 | 0.538033 |
|
|
10
|
+
| Python | tencent pypi | OK | 206 | 2.237381 |
|
|
11
|
+
| Python | ustc pypi | OK | 206 | 0.436254 |
|
|
12
|
+
| Python | huawei pypi | OK | 200 | 0.519546 |
|
|
13
|
+
| Node | **npmmirror registry** | OK | 206 | 0.743991 |
|
|
14
|
+
| Node | npmmirror node bin | OK | 206 | 0.860223 |
|
|
15
|
+
| Node | npmmirror electron | OK | 206 | 0.773016 |
|
|
16
|
+
| Java | **aliyun maven** | OK | 206 | 0.803807 |
|
|
17
|
+
| Java | huawei maven | OK | 206 | 1.203039 |
|
|
18
|
+
| Java | tencent maven | OK | 206 | 2.066494 |
|
|
19
|
+
| Go | **goproxy.cn** | OK | 206 | 2.194386 |
|
|
20
|
+
| Go | aliyun goproxy | OK | 206 | 0.491386 |
|
|
21
|
+
| Rust | **rsproxy sparse** | OK | 206 | 0.626017 |
|
|
22
|
+
| Rust | tuna crates | OK | 206 | 0.354671 |
|
|
23
|
+
| AI | **hf-mirror** | SLOW | 200 | 4.129000 |
|
|
24
|
+
| AI | modelscope | OK | 200 | 0.554881 |
|
|
25
|
+
| AI | aliyun pytorch | OK | 206 | 0.438552 |
|
|
26
|
+
| Docker | **ghcr nju** | OK | 200 | 0.430624 |
|
|
27
|
+
| Docker | ghcr daocloud | AUTH | 401 | 0.424917 |
|
|
28
|
+
| Docker | docker daocloud | AUTH | 401 | 0.432920 |
|
|
29
|
+
| Docker | docker 1panel | OK | 200 | 1.481966 |
|
|
30
|
+
| Docker | k8s daocloud | AUTH | 401 | 0.425796 |
|
|
31
|
+
| GitHub | **ghproxy.net** | SLOW | 206 | 9.125757 |
|
|
32
|
+
| GitHub | ghfast.top | OK | 206 | 1.459341 |
|
|
33
|
+
| GitHub | gh-proxy.com | OK | 206 | 0.642703 |
|
|
34
|
+
| GitHub | api.github.com | OK | 206 | 0.742955 |
|
|
35
|
+
| 系统 | tuna ubuntu | OK | 206 | 0.213700 |
|
|
36
|
+
| 系统 | aliyun ubuntu | OK | 206 | 0.350875 |
|
|
37
|
+
| 系统 | ustc ubuntu | OK | 206 | 0.426507 |
|
|
38
|
+
| 系统 | huawei ubuntu | OK | 206 | 0.217102 |
|
|
39
|
+
| Conda | tuna anaconda | OK | 206 | 0.207686 |
|
|
40
|
+
| 其他 | flutter pub | OK | 206 | 0.567191 |
|
|
41
|
+
| 其他 | aliyun composer | OK | 206 | 0.382021 |
|
|
42
|
+
| 其他 | huawei nuget | OK | 200 | 0.443568 |
|
|
43
|
+
| 其他 | tuna cran | OK | 206 | 0.259675 |
|
|
44
|
+
| 其他 | tuna rubygems | OK | 206 | 0.217530 |
|
|
45
|
+
| 其他 | huawei helm | OK | 200 | 0.438285 |
|
|
46
|
+
|
|
47
|
+
图例:`OK` 正常 · `SLOW` >3s · `AUTH` 401/403(可达但需鉴权)· `404` 路径变更 · `FAIL` 超时/连不上。加粗为关键源。
|
package/README.md
CHANGED
|
@@ -1,3 +1,346 @@
|
|
|
1
|
-
#
|
|
1
|
+
# cn-coding-mirrors
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://gitee.com/zxh126/cn-coding-mirrors/stargazers)
|
|
4
|
+
[](https://gitee.com/zxh126/cn-coding-mirrors/members)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
[](./skills)
|
|
7
|
+
[](./MIRRORS-STATUS.md)
|
|
8
|
+
|
|
9
|
+
> **让编程智能体在中国大陆网络下也能顺畅装包、下文件、拉镜像。**
|
|
10
|
+
> 以 [Agent Skills](https://agentskills.io/specification) 规范发布,一个包内含 3 个技能,
|
|
11
|
+
> Pi / Pi-Bolt、Claude Code、Codex 以及任何兼容该规范的 agent 都能直接使用。
|
|
12
|
+
|
|
13
|
+
**不需要智能体"猜"镜像地址,也不需要它自己发明下载逻辑** —— 镜像怎么配、下不动怎么切源、校验怎么做,全部写成可审计的文档和脚本。
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 目录
|
|
18
|
+
|
|
19
|
+
- [30 秒上手](#30-秒上手)
|
|
20
|
+
- [它解决什么问题](#它解决什么问题)
|
|
21
|
+
- [三个技能](#三个技能)
|
|
22
|
+
- [常用配方](#常用配方)
|
|
23
|
+
- [镜像可用性自检](#镜像可用性自检)
|
|
24
|
+
- [兼容性](#兼容性)
|
|
25
|
+
- [安全与信任边界](#安全与信任边界)
|
|
26
|
+
- [目录结构](#目录结构)
|
|
27
|
+
- [设计取舍](#设计取舍)
|
|
28
|
+
- [FAQ](#faq)
|
|
29
|
+
- [贡献](#贡献)
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 30 秒上手
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git clone https://gitee.com/zxh126/cn-coding-mirrors.git
|
|
37
|
+
cd cn-coding-mirrors
|
|
38
|
+
|
|
39
|
+
# 方式 A:任意 Agent Skills 兼容工具(通用位置)
|
|
40
|
+
./scripts/install.sh # -> ~/.agents/skills
|
|
41
|
+
./scripts/install.sh ~/.claude/skills # Claude Code
|
|
42
|
+
|
|
43
|
+
# 方式 B:Pi / Pi-Bolt 作为 package 安装(推荐,可随仓库更新)
|
|
44
|
+
pi install git:gitee.com/zxh126/cn-coding-mirrors
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
装完重启 / `/reload`,技能即可被自动路由;也可强制调用:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
/skill:cn-coding-mirrors pip 装包超时了帮我换源
|
|
51
|
+
/skill:docker-pull ghcr.io/owner/app:1.2.3
|
|
52
|
+
/skill:gh-download owner/repo@v1.2.3
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 它解决什么问题
|
|
58
|
+
|
|
59
|
+
国内网络下这些操作会卡死在**同一个地方**:拿不到 manifest 或第一个字节。
|
|
60
|
+
|
|
61
|
+
| 场景 | 直连实测 | 走本项目的路径 |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| `docker pull ghcr.io/...` | **0.07 MB/s**(1.38 GB 需 5 小时+) | `dpull` 分片 + `ghcr.nju.edu.cn`:**15 MB/s,155 秒** |
|
|
64
|
+
| GitHub release 下载 | 连接重置 / 超时 | `ghdl` 三镜像轮转 + 8 分片 + sha256 |
|
|
65
|
+
| `pip install` | 单包几十秒到超时 | 一行 `pip.conf` 换 tuna/aliyun,+ 验证命令 |
|
|
66
|
+
| `npm install` | registry 卡 + 二进制 99% 卡死 | registry 与 electron/sass/puppeteer 等二进制镜像一次配齐 |
|
|
67
|
+
| 下载 HF 模型 | 连接被重置 | `HF_ENDPOINT=https://hf-mirror.com` |
|
|
68
|
+
| 智能体自己瞎猜 | 猜错地址、死循环重试、把 `curl \| sh` 塞进用户机器 | 技能给出**确定性步骤 + 验证命令 + 止损条件** |
|
|
69
|
+
|
|
70
|
+
最后一行是重点:**这类技能真正的价值不是"知道几个镜像域名",而是给智能体一套不会乱来的行为约束**(详见 [FAQ](#faq))。
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 三个技能
|
|
75
|
+
|
|
76
|
+
技能分离、包合一体:模型只载入当下需要的那份上下文。
|
|
77
|
+
|
|
78
|
+
### 1. `cn-coding-mirrors` —— 各生态镜像配置速查
|
|
79
|
+
|
|
80
|
+
触发:装包慢/超时/被重置、要换国内源、要配代理。
|
|
81
|
+
|
|
82
|
+
按生态拆成 10 篇 reference,**按需加载**,不会一次性塞进上下文:
|
|
83
|
+
|
|
84
|
+
| reference | 覆盖 | 典型内容 |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `python.md` | pip、uv、poetry/pdm、conda | `pip.conf`、`UV_DEFAULT_INDEX`、`UV_PYTHON_INSTALL_MIRROR` |
|
|
87
|
+
| `node.md` | npm/yarn/pnpm | `registry.npmmirror.com` + electron/sass/puppeteer/playwright/cypress 二进制镜像 |
|
|
88
|
+
| `java.md` | maven、gradle、sbt | `settings.xml` 镜像、`init.gradle` |
|
|
89
|
+
| `go.md` | GOPROXY | `goproxy.cn` + `GOPRIVATE` 私有模块共存 |
|
|
90
|
+
| `rust.md` | cargo、rustup | sparse index(`rsproxy.cn`)、`RUSTUP_DIST_SERVER` |
|
|
91
|
+
| `system.md` | apt/apk/dnf/brew | 含 Ubuntu 24.04 deb822 (`ubuntu.sources`) 注意事项 |
|
|
92
|
+
| `ai.md` | **hf-mirror**、ModelScope、PyTorch wheels | `HF_ENDPOINT`、`hf download --resume`、`TIKTOKEN_CACHE_DIR` |
|
|
93
|
+
| `misc.md` | Flutter、Composer、NuGet、CRAN、RubyGems、Helm | — |
|
|
94
|
+
| `docker.md` | registry 镜像表 | 何时该用 `dpull`、何时改 `daemon.json` |
|
|
95
|
+
| `vcs.md` | GitHub 代理、git/hg/svn | `insteadOf` 精确改写、hg bundle 建议 |
|
|
96
|
+
|
|
97
|
+
### 2. `gh-download` —— GitHub 文件下载
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
bash scripts/ghdl owner/repo@v1.2.3 -a linux-amd64 -a tar.gz -o /tmp/pkg.tgz -n 8
|
|
101
|
+
bash scripts/ghdl https://github.com/owner/repo/releases/download/v1/x.tgz
|
|
102
|
+
OUT=$(bash scripts/ghdl owner/repo@latest -a linux-amd64 -q) # 脚本化:stdout 只有路径
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- 镜像链 `ghproxy.net → ghfast.top → gh-proxy.com`,失败自动轮转(含分片级重试);实测 `ghproxy.net` 常慢于另两家(曾 7–9 s 才返回 1 KB),轮转机制正好派上用场
|
|
106
|
+
- 自动从 `checksums.txt` / `*.sha256` 取校验值并比对,不匹配**删文件报错**
|
|
107
|
+
- 服务端不支持 Range → 降级 `curl -C -` 续传
|
|
108
|
+
- `-q` 时日志全走 stderr,stdout 只有最终路径(给 agent 解析用)
|
|
109
|
+
|
|
110
|
+
### 3. `docker-pull` —— 容器镜像
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
python3 scripts/dpull ghcr.io/owner/app:1.2.3 # 下载 + docker load
|
|
114
|
+
python3 scripts/dpull alpine:3.20 -j 16 -c 8 # 16 分片 × 8 MiB
|
|
115
|
+
python3 scripts/dpull ghcr.io/o/a:tag --no-load -o /tmp/a.tar # 离线导出
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
原理:`GET /v2/<repo>/manifests/<ref>`(协商 OCI index / docker manifest list,按 `--platform` 选 digest)→ 每个 blob 探大小 → Range 分片并发 → **逐 blob sha256 校验** → 组装成 `docker save` 兼容 tar(`blobs/sha256/*` + `manifest.json` + OCI `index.json`)→ `docker load`。
|
|
119
|
+
|
|
120
|
+
内置源链:
|
|
121
|
+
|
|
122
|
+
| registry | 国内镜像 |
|
|
123
|
+
|---|---|
|
|
124
|
+
| `ghcr.io` | `ghcr.nju.edu.cn`、`ghcr.m.daocloud.io` |
|
|
125
|
+
| `docker.io` | `docker.m.daocloud.io`、`docker.1panel.live`、`hub.rat.dev` |
|
|
126
|
+
| `gcr.io` / `quay.io` / `registry.k8s.io` | `*.m.daocloud.io` |
|
|
127
|
+
|
|
128
|
+
启动时并发预探测,403/连不通的源被剔除并提示;缓存内容寻址(`~/.cache/dpull`),重复层直接命中。
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 常用配方
|
|
133
|
+
|
|
134
|
+
<details>
|
|
135
|
+
<summary><b>装一个 GitHub 上的 CLI 工具(国内直连必挂的那种)</b></summary>
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
cd cn-coding-mirrors/skills/gh-download
|
|
139
|
+
bash scripts/ghdl sharkdp/fd@latest -a x86_64-unknown-linux-gnu -a tar.gz -o /tmp/fd.tgz -q
|
|
140
|
+
mkdir -p ~/.local/bin && tar xzf /tmp/fd.tgz --wildcards '*/fd' -O > ~/.local/bin/fd
|
|
141
|
+
chmod +x ~/.local/bin/fd && fd --version
|
|
142
|
+
```
|
|
143
|
+
</details>
|
|
144
|
+
|
|
145
|
+
<details>
|
|
146
|
+
<summary><b>拉一个 ghcr.io 镜像(strix-sandbox 这类大镜像)</b></summary>
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
cd cn-coding-mirrors/skills/docker-pull
|
|
150
|
+
python3 scripts/dpull ghcr.io/usestrix/strix-sandbox:1.3.0
|
|
151
|
+
# 1.38 GB / 35 层 → 约 155 秒;跑完直接 docker run 可用
|
|
152
|
+
```
|
|
153
|
+
</details>
|
|
154
|
+
|
|
155
|
+
<details>
|
|
156
|
+
<summary><b>pip 装包超时</b></summary>
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
mkdir -p ~/.pip && cat > ~/.pip/pip.conf <<'EOF'
|
|
160
|
+
[global]
|
|
161
|
+
index-url = https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
|
|
162
|
+
extra-index-url = https://mirrors.aliyun.com/pypi/simple
|
|
163
|
+
timeout = 60
|
|
164
|
+
EOF
|
|
165
|
+
pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple <pkg> # 先单次验证
|
|
166
|
+
```
|
|
167
|
+
</details>
|
|
168
|
+
|
|
169
|
+
<details>
|
|
170
|
+
<summary><b>npm install 卡在 99%</b></summary>
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
npm config set registry https://registry.npmmirror.com
|
|
174
|
+
export ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/"
|
|
175
|
+
export SASS_BINARY_SITE="https://npmmirror.com/mirrors/node-sass"
|
|
176
|
+
export PUPPETEER_DOWNLOAD_BASE_URL="https://cdn.npmmirror.com/binaries/chrome-for-testing"
|
|
177
|
+
npm install
|
|
178
|
+
```
|
|
179
|
+
</details>
|
|
180
|
+
|
|
181
|
+
<details>
|
|
182
|
+
<summary><b>下载 HuggingFace 模型</b></summary>
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
export HF_ENDPOINT="https://hf-mirror.com"
|
|
186
|
+
hf download Qwen/Qwen2.5-7B-Instruct --repo-type model
|
|
187
|
+
# 断点续传用 --resume;gated 模型仍需 HF_TOKEN
|
|
188
|
+
```
|
|
189
|
+
</details>
|
|
190
|
+
|
|
191
|
+
<details>
|
|
192
|
+
<summary><b>在 CI 里守住"镜像别悄悄挂掉"</b></summary>
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
./scripts/check-mirrors.sh --strict || echo "::warning::关键镜像源不可用"
|
|
196
|
+
./scripts/check-mirrors.sh --write # 更新 MIRRORS-STATUS.md 并提交
|
|
197
|
+
```
|
|
198
|
+
</details>
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 镜像可用性自检
|
|
203
|
+
|
|
204
|
+
镜像站会挂(403 / 429 / 超时),文档里的"实测"结论会过期。技能自带探测脚本,一次跑完 **38 个关键端点**:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
./scripts/check-mirrors.sh # 终端表格,并发探测,约 8 秒
|
|
208
|
+
./scripts/check-mirrors.sh --md # Markdown 表格
|
|
209
|
+
./scripts/check-mirrors.sh --json # 机器可读
|
|
210
|
+
./scripts/check-mirrors.sh --write # 覆盖生成 MIRRORS-STATUS.md
|
|
211
|
+
./scripts/check-mirrors.sh --strict # 关键源不可用 → 退出码 1
|
|
212
|
+
./scripts/check-mirrors.sh -t 10 -j 16 # 超时 / 并发
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
- 探测的是**每个源上的 1 KB 真实资源**(`-r 0-1023`),不是 `HEAD /` —— 后者常返回 200 但其实拉不了包
|
|
216
|
+
- 状态口径:`OK` / `SLOW`(>3s) / `AUTH`(401-403,可达但需鉴权,**不算故障**) / `404`(路径变更) / `FAIL`(超时)
|
|
217
|
+
- 加粗项为 **8 个关键源**(tuna pypi、npmmirror registry、aliyun maven、goproxy.cn、rsproxy sparse、hf-mirror、ghcr.nju、ghproxy.net),`--strict` 只对它们报警
|
|
218
|
+
|
|
219
|
+
当前快照:[MIRRORS-STATUS.md](./MIRRORS-STATUS.md)。
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 兼容性
|
|
224
|
+
|
|
225
|
+
| 工具 | 安装方式 | 说明 |
|
|
226
|
+
|---|---|---|
|
|
227
|
+
| **Pi / Pi-Bolt** | `pi install git:gitee.com/zxh126/cn-coding-mirrors` | 已实测通过;`pi.skills` 清单自动发现 3 个技能 |
|
|
228
|
+
| **Claude Code** | `./scripts/install.sh ~/.claude/skills` | 遵循 agentskills.io 规范的标准目录结构 |
|
|
229
|
+
| **Codex / 其他兼容 agent** | `./scripts/install.sh`(→ `~/.agents/skills`) | 通用位置,无需配置 |
|
|
230
|
+
| **自研 agent** | 把 `skills/<name>/SKILL.md` 当提示词片段注入 | 只需要 markdown;脚本按相对路径调用 |
|
|
231
|
+
|
|
232
|
+
运行时依赖:
|
|
233
|
+
|
|
234
|
+
| 技能 | 依赖 |
|
|
235
|
+
|---|---|
|
|
236
|
+
| `cn-coding-mirrors` | `curl`(其余按生态:pip/npm/mvn/cargo…) |
|
|
237
|
+
| `gh-download` | `bash 4+`、`curl`;自动挑资产需 `python3`(无则用 URL 形式) |
|
|
238
|
+
| `docker-pull` | `python3 3.8+`(仅标准库)、`docker` CLI(`--no-load` 时不需要) |
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## 安全与信任边界
|
|
243
|
+
|
|
244
|
+
**这些技能会下载并落盘文件、会 `docker load` 镜像,属于高权限动作**,请按此标准审视:
|
|
245
|
+
|
|
246
|
+
| 项目 | 承诺 |
|
|
247
|
+
|---|---|
|
|
248
|
+
| 不执行远程代码 | 全程没有 `curl \| sh`、没有 `postinstall`、没有 `eval` |
|
|
249
|
+
| 不偷偷改系统 | 配置一律以"改哪个文件 + 片段 + 验证命令"呈现,系统级改动会明确标注需要 sudo |
|
|
250
|
+
| 可验证 | 下载全流程 sha256 校验(GitHub 走 checksums 资产,镜像走 layer digest) |
|
|
251
|
+
| 网络最小化 | 只访问镜像站与目标 registry,无遥测、无统计上报 |
|
|
252
|
+
| 可审计 | 脚本无压缩混淆,`ghdl` 267 行、`dpull` 656 行,直接读 |
|
|
253
|
+
|
|
254
|
+
详见 [SECURITY.md](./SECURITY.md)。
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 目录结构
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
cn-coding-mirrors/
|
|
262
|
+
├── package.json # Pi package 清单(pi.skills)
|
|
263
|
+
├── scripts/
|
|
264
|
+
│ ├── install.sh # 跨智能体安装脚本
|
|
265
|
+
│ └── check-mirrors.sh # 38 个镜像端点实时探测
|
|
266
|
+
├── MIRRORS-STATUS.md # 最近一次探测快照(脚本生成,勿手改)
|
|
267
|
+
├── CHANGELOG.md
|
|
268
|
+
└── skills/
|
|
269
|
+
├── cn-coding-mirrors/
|
|
270
|
+
│ ├── SKILL.md # 总入口 + 分流规则 + reference 索引
|
|
271
|
+
│ └── references/ # python node java go rust system ai misc docker vcs
|
|
272
|
+
├── gh-download/
|
|
273
|
+
│ ├── SKILL.md
|
|
274
|
+
│ └── scripts/ghdl
|
|
275
|
+
└── docker-pull/
|
|
276
|
+
├── SKILL.md
|
|
277
|
+
└── scripts/dpull
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 设计取舍
|
|
283
|
+
|
|
284
|
+
- **技能分开、包合一体**
|
|
285
|
+
三者触发条件正交(包管理器配置 / GitHub 文件 / 容器镜像)。分技能让模型只载入需要的上下文;
|
|
286
|
+
同一包分发保证版本一致、一次安装。合成的代价是 description 变成"或"串联,路由精度下降。
|
|
287
|
+
|
|
288
|
+
- **知识可审计**
|
|
289
|
+
不给"魔法脚本",给"改哪个文件 + 片段 + 验证命令"。用户能审、能回滚、能 diff。
|
|
290
|
+
|
|
291
|
+
- **脚本随技能走**
|
|
292
|
+
不假设用户预装 `ghdl` / `dpull`,技能里直接 `bash scripts/ghdl` / `python3 scripts/dpull`。
|
|
293
|
+
|
|
294
|
+
- **镜像源可覆盖**
|
|
295
|
+
`GHDL_MIRRORS`、`DPULL_MIRRORS` 环境变量或 `--mirror` 参数,便于企业内网 / 社区替换。
|
|
296
|
+
|
|
297
|
+
- **文档会过期,所以内置探测器**
|
|
298
|
+
与其承诺"地址永远有效",不如给一个 8 秒跑完的自检脚本 + CI 定时任务。
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## FAQ
|
|
303
|
+
|
|
304
|
+
**Q:装了会不会让 agent 在我机器上乱跑命令?**
|
|
305
|
+
技能本身只是 markdown 指令 + 三个可读脚本。真正执行的是 agent 的 bash 工具,受各自主机的审批策略约束
|
|
306
|
+
(例如 Pi 的 `approve.tools`)。脚本做的事有界且可读:下载到指定路径、校验、`docker load`。
|
|
307
|
+
|
|
308
|
+
**Q:`--strict` 适合放 CI 吗?**
|
|
309
|
+
适合。它只对"关键源"报警(tuna pypi / npmmirror / goproxy.cn / rsproxy / hf-mirror / ghcr.nju / ghproxy.net),
|
|
310
|
+
`AUTH`(401-403) 与 `SLOW` 不算失败,避免噪音。
|
|
311
|
+
|
|
312
|
+
**Q:能拉私有镜像吗?**
|
|
313
|
+
不能。`dpull` 只支持匿名公开镜像;私有 registry 请用 `docker login` + 官方 `docker pull`,或自行扩展 token 逻辑。
|
|
314
|
+
|
|
315
|
+
**Q:`dpull` 生成的 tar 能在任意 Docker 上 `load` 吗?**
|
|
316
|
+
需要 Docker 25+(使用 `blobs/sha256/*` + `manifest.json` 的现代 `docker save` 格式)。更老的版本请用 `--no-load` 自行转换。
|
|
317
|
+
|
|
318
|
+
**Q:为什么不直接配 `daemon.json` 的 `registry-mirrors`?**
|
|
319
|
+
多数公共加速器现在要求登录或已停服,且它是全局配置、需要重启 dockerd。`dpull` 是**按需、单次、可校验**的方案。
|
|
320
|
+
两者并不冲突,`references/docker.md` 都写了。
|
|
321
|
+
|
|
322
|
+
**Q:镜像站挂了怎么办?**
|
|
323
|
+
跑 `check-mirrors.sh` 换源;同一生态最多试两个源,仍不行就明确告知用户"当前国内镜像均不可用,建议配代理或稍后重试",
|
|
324
|
+
不要把重试循环留给用户等。
|
|
325
|
+
|
|
326
|
+
**Q:会不会收集使用数据?**
|
|
327
|
+
不会。没有任何遥测。
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## 贡献
|
|
332
|
+
|
|
333
|
+
欢迎提交新的镜像源、修正失效地址、补充生态:
|
|
334
|
+
|
|
335
|
+
1. 改对应 `skills/cn-coding-mirrors/references/*.md`,**必须附上验证命令**
|
|
336
|
+
2. 若是新增端点,同时加入 `scripts/check-mirrors.sh` 的 `CHECKS` 表(关键源标 `*`)
|
|
337
|
+
3. 跑 `./scripts/check-mirrors.sh --write` 更新快照,`./scripts/check-mirrors.sh --strict` 确认无回归
|
|
338
|
+
4. 提交 PR / Issue 到 [Gitee](https://gitee.com/zxh126/cn-coding-mirrors)
|
|
339
|
+
|
|
340
|
+
镜像地址变更属于 **patch** 版本(见 [CHANGELOG](./CHANGELOG.md));脚本参数/行为变更才是 minor。
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## 许可
|
|
345
|
+
|
|
346
|
+
[MIT](./LICENSE)
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# 安全说明
|
|
2
|
+
|
|
3
|
+
## 这套技能会做什么
|
|
4
|
+
|
|
5
|
+
`cn-coding-mirrors` 是一个**提示词 + 可读脚本**的集合,不是后台服务、不是守护进程、不常驻内存。
|
|
6
|
+
它只在 agent 主动调用时执行,动作范围有界:
|
|
7
|
+
|
|
8
|
+
| 技能 | 读取 | 写入 | 网络 |
|
|
9
|
+
|---|---|---|---|
|
|
10
|
+
| `cn-coding-mirrors` | 无(纯文档) | **无** —— 只给出配置片段,由 agent 决定是否写 `~/.pip/pip.conf` 等 | 无 |
|
|
11
|
+
| `gh-download`(`ghdl`) | 无 | 目标下载文件(`-o` 指定,默认当前目录)、`/tmp` 临时分片 | 镜像站 + `github.com` / `api.github.com` |
|
|
12
|
+
| `docker-pull`(`dpull`) | 无 | `~/.cache/dpull`(或 `--cache`)、指定 tar、通过 `docker load` 写入本地镜像库 | 镜像站 + 目标 registry |
|
|
13
|
+
| `scripts/check-mirrors.sh` | 无 | 仅在 `--write` 时覆写 `MIRRORS-STATUS.md` | 38 个镜像端点,各取 1 KB |
|
|
14
|
+
|
|
15
|
+
## 明确不做的事
|
|
16
|
+
|
|
17
|
+
- ❌ **不执行远程代码**:没有 `curl | sh`、没有 `postinstall` / `prepare`、没有下载后立即执行的逻辑
|
|
18
|
+
- ❌ **不落任何凭据**:脚本不读 `~/.npmrc`、`~/.docker/config.json`、SSH key、环境变量里的 token
|
|
19
|
+
- ❌ **不改系统配置**:不会自动写 `/etc/apt/sources.list`、`/etc/docker/daemon.json`;文档给出片段并标注是否需要 sudo
|
|
20
|
+
- ❌ **不收集数据**:无遥测、无统计上报、无"检查更新"回连
|
|
21
|
+
|
|
22
|
+
## 完整性保证
|
|
23
|
+
|
|
24
|
+
| 通道 | 保证方式 |
|
|
25
|
+
|---|---|
|
|
26
|
+
| GitHub release 资产 | 自动抓取 `checksums.txt` / `*.sha256` 并比对;不匹配则**删除文件并以非零码退出** |
|
|
27
|
+
| 容器镜像 | 每个 blob(config + 全部 layer)按 digest 逐一 `sha256` 校验,失败丢弃该 blob |
|
|
28
|
+
| 镜像源探测 | 仅做可用性度量,不涉及内容校验(校验由上传方负责) |
|
|
29
|
+
|
|
30
|
+
镜像站的**内容可信度不在本项目控制范围**:任何镜像站理论上都可以返回被篡改的包。本项目保证的是
|
|
31
|
+
"你拿到的字节与上游 manifest 声明的 digest 一致"。若需要更强的供应链保证,请对上游做签名验证
|
|
32
|
+
(如 cosign / sigstore),本项目未内置。
|
|
33
|
+
|
|
34
|
+
## 网络范围
|
|
35
|
+
|
|
36
|
+
`ghdl` 只访问:`ghproxy.net` / `ghfast.top` / `gh-proxy.com` / `github.com` / `api.github.com`。
|
|
37
|
+
`dpull` 只访问:目标 registry 及其配置的国内镜像站(见 `skills/docker-pull/SKILL.md`)。
|
|
38
|
+
`check-mirrors.sh` 访问 `CHECKS` 表中列出的 38 个端点 —— **全部可在脚本里直接看到**,可自行删改。
|
|
39
|
+
|
|
40
|
+
如需在隔离网络使用:把 `GHDL_MIRRORS` / `DPULL_MIRRORS` 指向内网镜像,或直接阅脚本删掉不需要的端点。
|
|
41
|
+
|
|
42
|
+
## 审计建议
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# 脚本总量:ghdl 267 行、dpull 656 行、check-mirrors 约 160 行 —— 全部可通读
|
|
46
|
+
wc -l skills/*/scripts/* scripts/*.sh
|
|
47
|
+
grep -rn "curl\|wget\|eval\|exec\|rm -rf" skills/*/scripts/* scripts/*.sh | less
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
重点确认三处:`ghdl` 的镜像前缀拼接、`dpull` 的 `docker load` 调用、`check-mirrors.sh` 的 `CHECKS` 表。
|
|
51
|
+
|
|
52
|
+
## 报告安全问题
|
|
53
|
+
|
|
54
|
+
Gitee Issues:<https://gitee.com/zxh126/cn-coding-mirrors/issues>
|
|
55
|
+
涉及凭据泄露或代码执行的,请**先私信作者**(Gitee 站内信 / 邮箱 `zxh_126@qq.com`),不要公开提交。
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cn-coding-mirrors",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "China-network download & mirror toolkit for coding agents: GitHub release downloader, OCI image puller, and per-ecosystem mirror configuration (pip/npm/maven/go/cargo/apt/conda/HF/docker).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pi-package",
|
|
8
|
+
"agent-skills",
|
|
9
|
+
"coding-agent",
|
|
10
|
+
"china",
|
|
11
|
+
"mirror",
|
|
12
|
+
"mirrors",
|
|
13
|
+
"ghproxy",
|
|
14
|
+
"ghcr",
|
|
15
|
+
"pip-mirror",
|
|
16
|
+
"npm-mirror",
|
|
17
|
+
"goproxy",
|
|
18
|
+
"docker"
|
|
19
|
+
],
|
|
20
|
+
"files": [
|
|
21
|
+
"skills",
|
|
22
|
+
"scripts",
|
|
23
|
+
"MIRRORS-STATUS.md",
|
|
24
|
+
"CHANGELOG.md",
|
|
25
|
+
"SECURITY.md",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"pi": {
|
|
30
|
+
"skills": [
|
|
31
|
+
"./skills"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://gitee.com/zxh126/cn-coding-mirrors.git"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://gitee.com/zxh126/cn-coding-mirrors",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://gitee.com/zxh126/cn-coding-mirrors/issues"
|
|
44
|
+
}
|
|
45
|
+
}
|