@yizhuan-cli/cli 0.1.9 → 0.1.10-beta.1
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/README.md +2 -2
- package/package.json +4 -1
- package/resources/yizhuan-cli/SKILL.md +4 -3
- package/resources/yizhuan-cli/manifest.json +4 -4
- package/src/doctor.js +2 -2
- package/src/index.js +26 -2
package/README.md
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
需要 Node.js 22 或更高版本。
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install -g @yizhuan-cli/cli@0.1.
|
|
10
|
+
npm install -g @yizhuan-cli/cli@0.1.10-beta.1
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
如果发布在私有 npm registry,请加上对应 registry:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm install -g @yizhuan-cli/cli@0.1.
|
|
16
|
+
npm install -g @yizhuan-cli/cli@0.1.10-beta.1 --registry=https://your-private-registry.example
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## 配置
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yizhuan-cli/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10-beta.1",
|
|
4
4
|
"description": "易撰命令行工具,用于通过 API Key 查询易撰真实数据。",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"start": "node src/index.js",
|
|
20
20
|
"test": "node --test \"src/*.test.js\"",
|
|
21
|
+
"skillhub:generate": "node scripts/generate-skillhub.mjs",
|
|
22
|
+
"skillhub:check": "node scripts/generate-skillhub.mjs --check",
|
|
23
|
+
"skillhub:package": "node scripts/generate-skillhub.mjs --check && node scripts/package-skillhub.mjs",
|
|
21
24
|
"pack:dry-run": "npm pack --dry-run",
|
|
22
25
|
"smoke": "node src/index.js --help && node --test src/version.test.js",
|
|
23
26
|
"test:params": "node --test src/params.test.js",
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: yizhuan-cli
|
|
3
3
|
description: |
|
|
4
|
-
通过易撰 CLI(yizhuan
|
|
5
|
-
当用户提到易撰、百家号、作品、账号、热点、雷达、竞品雷达、竞品动态、会员、我的灵感、灵感库、收藏作品、我的关注、关注作者或取消关注作者时,
|
|
6
|
-
必须优先调用 yizhuan CLI 获取真实结果,禁止臆造。
|
|
4
|
+
通过易撰 CLI(yizhuan 命令)查询易撰真实数据的全量兼容与回退 Skill。当没有更具体的拆分 Skill 时处理作品、作者、热点、雷达、会员、灵感、收藏和检测;若已安装用户明确指定平台对应的 yizhuan-<platform> Skill,必须优先使用对应的拆分平台 Skill,不得与其竞争。业务数据禁止臆造。
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# 易撰 CLI
|
|
@@ -20,6 +18,8 @@ yizhuan doctor
|
|
|
20
18
|
|
|
21
19
|
如果诊断失败,按输出中的修复建议处理。配置使用 `yizhuan config init`,更新本 Skill 使用 `yizhuan skill sync`;不要手工展示或复制配置中的完整 API Key。
|
|
22
20
|
|
|
21
|
+
若受限沙箱中的 doctor 报告配置不存在或无法读取,先取得用户授权并提升权限、在沙箱外重试;不支持提权时请用户在真实本机终端运行 doctor 并提供脱敏结果。只有宿主机复查也确认配置真实不存在时才运行 `yizhuan config init`,不得要求用户把配置文件或 API Key 复制到工作区。
|
|
22
|
+
|
|
23
23
|
## 支持能力
|
|
24
24
|
|
|
25
25
|
| 场景 | 命令示例 |
|
|
@@ -42,6 +42,7 @@ yizhuan doctor
|
|
|
42
42
|
## 调用规则
|
|
43
43
|
|
|
44
44
|
- 需要真实易撰数据时必须调用 CLI,不直接猜测结果。
|
|
45
|
+
- 一键检测的原创度检测当前只有百度引擎。展示检测结果时使用 `data.originalScore` 和 `data.originalEngine`;不得把历史兼容字段 `_360`、`sogou`、`zonghe` 展示为检测引擎或额外得分。
|
|
45
46
|
- PowerShell 使用单引号包裹 JSON。终端可能改写引号时,将不含密钥的请求对象写入文件,再使用 `--json-file`。
|
|
46
47
|
- `execute --json-file` 是完整参数对象的唯一输入源,不与 `--params`、`--query` 或独立参数混用。
|
|
47
48
|
- 热点查询使用 `query` 统一协议并明确 `platform`;缺少平台时先澄清,不默认猜测。
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "yizhuan-cli",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"compatibleCliVersion": "0.1.
|
|
6
|
-
"source": "npm:@yizhuan-cli/cli@0.1.
|
|
4
|
+
"version": "0.1.10-beta.1",
|
|
5
|
+
"compatibleCliVersion": "0.1.10-beta.1",
|
|
6
|
+
"source": "npm:@yizhuan-cli/cli@0.1.10-beta.1",
|
|
7
7
|
"digestAlgorithm": "sha256",
|
|
8
8
|
"files": [
|
|
9
9
|
{
|
|
10
10
|
"path": "SKILL.md",
|
|
11
|
-
"sha256": "
|
|
11
|
+
"sha256": "fa478305d464ef41379022ce936ca4a1ccceedfeb77e4c2a249069fdeefd588c"
|
|
12
12
|
}
|
|
13
13
|
]
|
|
14
14
|
}
|
package/src/doctor.js
CHANGED
|
@@ -52,9 +52,9 @@ export function inspectLocalEnvironment(
|
|
|
52
52
|
? check('pass', 'node', `Node.js ${nodeVersion} 满足 >=${minimumNode}`)
|
|
53
53
|
: check('fail', 'node', `Node.js ${nodeVersion} 不满足 ${packageJson.engines?.node || '版本要求'}`, `安装 Node.js ${minimumNode || 22} 或更高版本。`))
|
|
54
54
|
|
|
55
|
-
checks.push(packageJson.version === '0.1.
|
|
55
|
+
checks.push(packageJson.version === '0.1.10-beta.1'
|
|
56
56
|
? check('pass', 'cli_version', `CLI ${packageJson.version}`)
|
|
57
|
-
: check('fail', 'cli_version', `CLI 版本为 ${packageJson.version},预期 0.1.
|
|
57
|
+
: check('fail', 'cli_version', `CLI 版本为 ${packageJson.version},预期 0.1.10-beta.1`, '安装 @yizhuan-cli/cli@0.1.10-beta.1。'))
|
|
58
58
|
|
|
59
59
|
if (!exists(configPath)) {
|
|
60
60
|
checks.push(check('fail', 'config', `配置不存在:${configPath}`, '运行 yizhuan config init。'))
|
package/src/index.js
CHANGED
|
@@ -25,6 +25,7 @@ const ABILITIES = new Set([
|
|
|
25
25
|
'work_query',
|
|
26
26
|
'membership_info',
|
|
27
27
|
'favorites_query'
|
|
28
|
+
,'detection'
|
|
28
29
|
])
|
|
29
30
|
|
|
30
31
|
const PARAM_FLAG_KEYS = [
|
|
@@ -67,6 +68,7 @@ Examples:
|
|
|
67
68
|
yizhuan execute --ability accounts --params '{"mode":"public_search","platform":"toutiao","keyword":"张三"}'
|
|
68
69
|
yizhuan execute --ability radar --params '{"mode":"following"}'
|
|
69
70
|
yizhuan execute --ability radar --mode timeline --timeRange 7d
|
|
71
|
+
yizhuan execute --ability detection --json-file detection.json
|
|
70
72
|
yizhuan execute --ability radar --params '{"mode":"unfollow","articleId":"205169870"}'
|
|
71
73
|
|
|
72
74
|
Notes:
|
|
@@ -84,6 +86,7 @@ Abilities:
|
|
|
84
86
|
membership 会员查询
|
|
85
87
|
favorites 收藏查询
|
|
86
88
|
public_author_search 作者全网搜索,兼容低层能力
|
|
89
|
+
detection 一键检测(原创/风险)
|
|
87
90
|
|
|
88
91
|
Config:
|
|
89
92
|
${CONFIG_PATH}
|
|
@@ -366,8 +369,29 @@ async function execute(args) {
|
|
|
366
369
|
throw new Error(`请求失败 HTTP ${response.status}:${text}`)
|
|
367
370
|
}
|
|
368
371
|
|
|
369
|
-
|
|
370
|
-
|
|
372
|
+
let result = payloadResult(JSON.parse(text))
|
|
373
|
+
const requestParams = buildExecuteParams(args)
|
|
374
|
+
if (ability === 'detection' && requestParams?.wait === true && result?.status === 'pending' && result?.data?.id) {
|
|
375
|
+
const timeoutSeconds = Number(requestParams.timeoutSeconds) > 0 ? Number(requestParams.timeoutSeconds) : 120
|
|
376
|
+
const deadline = Date.now() + timeoutSeconds * 1000
|
|
377
|
+
while (Date.now() < deadline && result.status === 'pending') {
|
|
378
|
+
await new Promise((resolve) => setTimeout(resolve, Math.max(500, Number(result.data.pollAfterSeconds || 3) * 1000)))
|
|
379
|
+
if (Date.now() >= deadline) break
|
|
380
|
+
const poll = await fetch(`${config.apiBaseUrl}/api/cli.execute`, {
|
|
381
|
+
method: 'POST',
|
|
382
|
+
headers: { authorization: config.apiKey, 'content-type': 'application/json', 'x-device-type': 'pc' },
|
|
383
|
+
body: JSON.stringify({ json: { ability: 'detection', params: { mode: 'get', id: result.data.id } } })
|
|
384
|
+
})
|
|
385
|
+
const pollText = await poll.text()
|
|
386
|
+
if (!poll.ok) throw new Error(`请求失败 HTTP ${poll.status}:${pollText}`)
|
|
387
|
+
result = payloadResult(JSON.parse(pollText))
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
console.log(JSON.stringify(result, null, 2))
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function payloadResult(payload) {
|
|
394
|
+
return payload.result?.data?.json ?? payload
|
|
371
395
|
}
|
|
372
396
|
|
|
373
397
|
function renderQuery(payload, format) {
|