@iasiv5/dsh-skills 1.0.4 → 1.0.6
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/package.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
name: brainstorming
|
|
3
3
|
description: "在开始实现前,把需求澄清成设计文档。适用于新增功能、修改行为、组件设计、接口设计、流程改造、架构取舍和多方案比较。只要改动跨文件、改行为或涉及多方案取舍,就值得先做设计,无论体量大小;单点直改不必走本 skill。用户说'先想一下''先给方案''先规划一下''先比较两种做法'时优先使用这个 skill。"
|
|
4
4
|
argument-hint: 描述要做的功能、约束、背景或已有想法;可留空
|
|
5
|
+
disable-model-invocation: true
|
|
5
6
|
---
|
|
6
7
|
|
|
7
8
|
# Brainstorming Skill
|
|
@@ -14,7 +14,7 @@ npm 没有预留/停放机制:**名字只有在第一次成功 publish 之后
|
|
|
14
14
|
用户报来一个或多个包名时,按序调用:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
scripts/claim.sh check <name> [<name>...] #
|
|
17
|
+
scripts/claim.sh check <name> [<name>...] # 批量逐行输出;短名自动 typosquat RISK 预筛;本地死刑名单命中报 DEAD
|
|
18
18
|
scripts/claim.sh scaffold <name> --dir BASE --desc ... --repo ... --homepage ... --author ...
|
|
19
19
|
scripts/claim.sh weblogin <pkgdir> # 已有可用 token 时跳过
|
|
20
20
|
scripts/claim.sh publish <pkgdir> # 用后台任务方式运行,见第 4 步
|
|
@@ -25,11 +25,13 @@ scripts/claim.sh trust <pkgdir> --repo OWNER/REPO --file <wf.yml> # 可选:
|
|
|
25
25
|
|
|
26
26
|
## 1. 查名
|
|
27
27
|
|
|
28
|
-
`claim.sh check`
|
|
28
|
+
`claim.sh check` 返回判定:AVAILABLE / TAKEN / RISK / DEAD / INVALID / UNKNOWN。多名批量逐行输出;RISK 预筛批量照跑,近似名全列表仅单名输出。
|
|
29
29
|
|
|
30
|
-
- 完成标准:向用户逐名明确「可抢 /
|
|
31
|
-
- **AVAILABLE 只保证「未注册」**:npm 在 publish 时还有一层 typosquat 相似度拦截(详见第 4 步症状表),短名(≤4
|
|
32
|
-
-
|
|
30
|
+
- 完成标准:向用户逐名明确「可抢 / 已占 / 高危 / 死刑」,RISK 名附近似对象。
|
|
31
|
+
- **AVAILABLE 只保证「未注册」**:npm 在 publish 时还有一层 typosquat 相似度拦截(详见第 4 步症状表),短名(≤4 字母)和常见词即使未注册也可能被拒。
|
|
32
|
+
- **RISK 是保守预警,不是判决**:check 自动把名字压成紧缩串(去连字符,如 `dsh-k`→`dshk`)做近似搜索,与已注册包编辑距离 ≤2 即报 RISK。存在假阳性——`dsh-a`≈`sha`(距离 1)实际发得出去。RISK 的价值是把「拼接心算」机械化,逼出第 4 步授权前的用户确认。
|
|
33
|
+
- **DEAD 是确定性信号**:typosquat 403 意味着永久关闭,验过的死刑名记入本地名单 `~/.config/npm-claim/dead-names.txt`(一行一个包名,`#` 后备注;路径可用环境变量 `NPM_CLAIM_DEADLIST` 覆盖)。名单属个人维护数据,不随 skill 分发;check 命中即报 DEAD,连 registry 都不必查。
|
|
34
|
+
- 实战教训:`dsh-ip`≈dship、`dsh-op`≈dshop(2026-10-09,连读成词);`dsh-k`≈sshpk、`dsh-x`≈shx、`dsh-y`≈tshy(2026-11-06,压缩串近似非词)。两批 check 均 AVAILABLE,publish 全部 403 永久关闭——单字母/短名是重灾区,早期能过属窗口宽松,不可复制。
|
|
33
35
|
- 近似名一眼扫过即可:占自己的品牌名属于正常占位;蹭知名项目的近似名属于 typosquat,会被 npm 处理,拒绝协助。
|
|
34
36
|
- 提醒用户抓紧:查完到 publish 之间随时可能被人截胡。
|
|
35
37
|
|
|
@@ -72,13 +74,15 @@ cd <pkgdir> && npm whoami --registry https://registry.npmjs.org --cache ../.npm-
|
|
|
72
74
|
| `EOTP: This operation requires a one-time password` | 账号 2FA 设为 auth-and-writes,写操作要二次验证 | 见下 |
|
|
73
75
|
| `npm trust` 任意子命令(**连 `list` 读操作**)报 `EOTP`,错误通道里授权链接是打码的 `***` | trust 属账号级敏感操作,auth-and-writes 账号一律二次验证,且 npm 把它走错误通道输出 | 与 publish 同一套伪 TTY + `--browser=false`(`claim.sh trust` 已内置);`--browser` 这个 flag 传不进去就改用环境变量 `npm_config_browser=false` |
|
|
74
76
|
| `npm trust ... --cache/--logs-dir <dir>` 报 `Unknown positional argument: <dir>` | `npm trust` 的子命令用严格 flag 解析器,不认这些全局 flag 的空格分隔形式,值被当成了多余位置参数 | 相关配置全部改走 `npm_config_*` 环境变量(`npm_config_cache` / `npm_config_logs_dir` / `npm_config_browser`) |
|
|
75
|
-
| PUT `403 Package name too similar to existing packages ...` | npm typosquat 防护在发布时做相似度拦截(check 阶段看不到) |
|
|
77
|
+
| PUT `403 Package name too similar to existing packages ...` | npm typosquat 防护在发布时做相似度拦截(check 阶段看不到) | 该名对所有账号永久关闭,重试无意义;记入本地死刑名单(见第 1 步 DEAD);向用户说明并给替代:`@scope/name`(属自己账号,无抢注意义)或换名。实战例:dsh-ip≈dship、dsh-op≈dshop(连读成词);dsh-k≈sshpk、dsh-x≈shx、dsh-y≈tshy(压缩串近似同样中招) |
|
|
76
78
|
|
|
77
79
|
**EOTP 核心技巧:伪造 TTY + 关闭浏览器。** 具体命令在 `claim.sh` 的 publish 子命令里(`script -qec` 包一层伪终端,npm 加 `--browser=false`),这里写清楚它为什么有效——排障时据此推理:
|
|
78
80
|
|
|
79
81
|
- 非 TTY 环境下,npm 收到 EOTP 直接抛错退出;伪 TTY 让它改走 web-OTP 流程:打开 authUrl、轮询 doneUrl、拿到 OTP 票据后**自动重试发布**,全程无需手动输验证码。
|
|
80
82
|
- `--browser=false` 让 opener 把真实授权链接打印到输出后立即返回——npm 打印 URL 的通道关闭了脱敏(错误通道里的 URL 是打码的 `***`),并且弹浏览器、等回车两个动作都被跳过,适合 headless 环境。
|
|
81
83
|
|
|
84
|
+
**授权前置确认**:typosquat 403 只能在真 PUT 时暴露,无法免费预试,而 auth-and-writes 账号每次 publish 都要先过 OTP。带 RISK 标记的名字发起 weblogin / publish 授权前,先向用户确认「publish 可能 403 永久关闭,这次授权可能白点」,点头再发起(2026-11-06 实录:k/x/y 三连 403,用户为注定失败的批次点了两次授权)。
|
|
85
|
+
|
|
82
86
|
交互协议:
|
|
83
87
|
|
|
84
88
|
1. **以后台任务运行** `claim.sh publish`(bash 工具 `run_in_background: true`)——它会阻塞等待用户授权。
|
|
@@ -24,7 +24,30 @@ case "$cmd" in
|
|
|
24
24
|
|
|
25
25
|
check)
|
|
26
26
|
[ $# -ge 1 ] || die "$USAGE"
|
|
27
|
-
batch=0 ; [ $# -gt 1 ] && batch=1 #
|
|
27
|
+
batch=0 ; [ $# -gt 1 ] && batch=1 # 多名批量:逐行输出;RISK 预筛批量照跑,近似名全列表仅单名输出
|
|
28
|
+
deadlist="${NPM_CLAIM_DEADLIST:-$HOME/.config/npm-claim/dead-names.txt}"
|
|
29
|
+
# typosquat 预筛:npm 的相似度拦截发生在 publish 的 PUT 时,无法免费预试,403 即对所有账号永久关闭。
|
|
30
|
+
# 这里对短名做「压缩串(去连字符)编辑距离 ≤2」的保守预警:dsh-k→dshk≈sshpk、dsh-x→dshx≈shx、dsh-y→dshy≈tshy。
|
|
31
|
+
# RISK 是提示不是判决(存在假阳性:dsh-a≈sha 距离 1 却发得出去);DEAD 名单才是确定性信号。
|
|
32
|
+
risk_scan() {
|
|
33
|
+
node -e '
|
|
34
|
+
const [name, json] = process.argv.slice(1);
|
|
35
|
+
const comp = s => s.toLowerCase().replace(/-/g, "");
|
|
36
|
+
const lv = (a, b) => { const m = a.length, n = b.length;
|
|
37
|
+
const row = Array.from({ length: m + 1 }, (_, i) => i);
|
|
38
|
+
for (let j = 1; j <= n; j++) { let prev = row[0]; row[0] = j;
|
|
39
|
+
for (let i = 1; i <= m; i++) { const tmp = row[i];
|
|
40
|
+
row[i] = Math.min(row[i] + 1, row[i - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1)); prev = tmp; } }
|
|
41
|
+
return row[m]; };
|
|
42
|
+
const cn = comp(name);
|
|
43
|
+
for (const c of JSON.parse(json)) {
|
|
44
|
+
const cc = comp(c);
|
|
45
|
+
if (cc === cn) continue;
|
|
46
|
+
const d = lv(cn, cc);
|
|
47
|
+
if (d <= 2) console.log("RISK: " + name + " ≈ " + c + " (压缩串编辑距离 " + d + ",publish 可能 403 永久关闭)");
|
|
48
|
+
}
|
|
49
|
+
' "$1" "$2"
|
|
50
|
+
}
|
|
28
51
|
for name in "$@"; do
|
|
29
52
|
# 名字合规(新包规则:小写字母数字连字符,可带 scope,不以点/下划线开头,≤214)
|
|
30
53
|
if [[ "$name" =~ ^@ ]]; then
|
|
@@ -33,14 +56,26 @@ check)
|
|
|
33
56
|
[[ "$name" =~ ^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$ ]] || { echo "INVALID: 包名不合规(需小写字母/数字/连字符,且不以连字符开头结尾): $name"; continue; }
|
|
34
57
|
fi
|
|
35
58
|
[ ${#name} -le 214 ] || { echo "INVALID: 包名超过 214 字符: $name"; continue; }
|
|
59
|
+
# 死刑名单(确定性):本地文件一行一个包名、# 后备注;数据属个人维护,不随 skill 分发
|
|
60
|
+
if [ -f "$deadlist" ] && grep -v '^#' "$deadlist" | awk '{print $1}' | grep -qx -- "$name"; then
|
|
61
|
+
echo "DEAD: $name 在本地死刑名单(typosquat 永久关闭,勿再尝试;名单: $deadlist)"
|
|
62
|
+
continue
|
|
63
|
+
fi
|
|
36
64
|
code=$(curl -s -o /dev/null -w '%{http_code}' "$REGISTRY/$name")
|
|
37
65
|
case "$code" in
|
|
38
66
|
404) echo "AVAILABLE: $name 未注册,可抢注" ;;
|
|
39
67
|
200) echo "TAKEN: $name 已被注册" ;;
|
|
40
68
|
*) echo "UNKNOWN: $name -> registry HTTP $code,请人工确认" ;;
|
|
41
69
|
esac
|
|
70
|
+
# 压缩串近似搜索:原名 + 去连字符各查一次,合并去重后按编辑距离过滤
|
|
71
|
+
comp=${name//-/}
|
|
72
|
+
enc=${name//@/%40} ; enc=${enc//\//%2F}
|
|
73
|
+
enc2=${comp//@/%40} ; enc2=${enc2//\//%2F}
|
|
74
|
+
cands=$({ curl -s "$REGISTRY/-/v1/search?text=$enc&size=25"; echo; \
|
|
75
|
+
curl -s "$REGISTRY/-/v1/search?text=$enc2&size=25"; } \
|
|
76
|
+
| node -e 'let s="";process.stdin.on("data",c=>s+=c).on("end",()=>{const names=new Set();for(const line of s.split("\n")){if(!line.trim())continue;try{const d=JSON.parse(line);for(const o of d.objects||[])names.add(o.package.name)}catch(e){}}console.log(JSON.stringify([...names]))})')
|
|
77
|
+
risk_scan "$name" "$cands"
|
|
42
78
|
if [ "$batch" -eq 0 ]; then
|
|
43
|
-
enc=${name//@/%40} ; enc=${enc//\//%2F}
|
|
44
79
|
echo "--- 近似名(评估混淆/typosquat 争议风险)---"
|
|
45
80
|
curl -s "$REGISTRY/-/v1/search?text=$enc&size=5" \
|
|
46
81
|
| node -e "let s='';process.stdin.on('data',c=>s+=c).on('end',()=>{const d=JSON.parse(s);for(const o of d.objects)console.log(' ', o.package.name, '|', o.package.version, '|', (o.package.description||'').slice(0,70))})"
|
package/skills-manifest.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"name": "brainstorming",
|
|
24
24
|
"description": "在开始实现前,把需求澄清成设计文档。适用于新增功能、修改行为、组件设计、接口设计、流程改造、架构取舍和多方案比较。只要改动跨文件、改行为或涉及多方案取舍,就值得先做设计,无论体量大小;单点直改不必走本 skill。用户说'先想一下''先给方案''先规划一下''先比较两种做法'时优先使用这个 skill。",
|
|
25
25
|
"invocation": {
|
|
26
|
-
"modelInvocable":
|
|
26
|
+
"modelInvocable": false,
|
|
27
27
|
"userInvocable": true
|
|
28
28
|
}
|
|
29
29
|
},
|