@qcplay/cli 1.0.3 → 1.0.4
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
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qcplay-auth
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
description: "QCPlay 登录认证:Use when user mentions 登录、认证、auth、权限查询、检查登录状态、退出登录、浏览器登录、access_token、auth.json 等;use for QCPlay authentication workflow only."
|
|
5
|
+
metadata:
|
|
6
|
+
requires:
|
|
7
|
+
bins: ["qcplay", "qcplay-cli"]
|
|
8
|
+
native_bins: ["qcplay-auth.exe", "qcplay-auth-darwin-arm64"]
|
|
9
|
+
cliHelp: "qcplay auth --help"
|
|
10
|
+
authFile: "~/.qcplay/auth.json"
|
|
11
|
+
loginCommand: "qcplay auth"
|
|
12
|
+
statusCommand: "qcplay auth status"
|
|
13
|
+
logoutCommand: "qcplay auth logout"
|
|
14
|
+
permissionsCommand: "qcplay auth permissions"
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# qcplay auth
|
|
18
|
+
|
|
19
|
+
## CRITICAL — 认证工作流,必须遵循
|
|
20
|
+
|
|
21
|
+
本 Skill 用于通过 QCPlay CLI 完成登录认证、检查登录状态、退出登录和查询权限。
|
|
22
|
+
|
|
23
|
+
认证由本地原生程序 `qcplay-auth` 完成,CLI 只负责统一入口和状态检查。
|
|
24
|
+
|
|
25
|
+
用户常用命令:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
qcplay auth
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
或者:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
qcplay-cli auth
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 核心命令
|
|
38
|
+
|
|
39
|
+
### 1. 登录
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
qcplay auth
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
或:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
qcplay-cli auth
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
当前程序行为:
|
|
52
|
+
|
|
53
|
+
1. 打开浏览器登录窗口
|
|
54
|
+
2. 用户在浏览器中完成登录
|
|
55
|
+
3. 本地生成认证文件 `~/.qcplay/auth.json`
|
|
56
|
+
|
|
57
|
+
### 2. 检查登录状态
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
qcplay auth status
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
或:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
qcplay-cli auth status
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
如果已登录,当前 CLI 会输出:
|
|
70
|
+
|
|
71
|
+
```txt
|
|
72
|
+
已登录
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
如果未登录或登录无效,当前 CLI 会输出:
|
|
76
|
+
|
|
77
|
+
```txt
|
|
78
|
+
未登录或登录无效
|
|
79
|
+
原因: ...
|
|
80
|
+
|
|
81
|
+
请执行:
|
|
82
|
+
qcplay-cli auth
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 3. 退出登录
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
qcplay auth logout
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
或:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
qcplay-cli auth logout
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
该命令会删除本地认证文件,并输出:
|
|
98
|
+
|
|
99
|
+
```txt
|
|
100
|
+
已退出登录
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 4. 查询权限
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
qcplay auth permissions
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
支持参数:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
qcplay auth permissions --key <key>
|
|
113
|
+
qcplay auth permissions --json
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
如果未登录,不得伪造权限结果,必须先提示用户登录。
|
|
117
|
+
|
|
118
|
+
## 认证文件
|
|
119
|
+
|
|
120
|
+
认证文件固定读取:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
~/.qcplay/auth.json
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Windows 示例:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
C:\Users\Administrator\.qcplay\auth.json
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
macOS 示例:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
/Users/<your-name>/.qcplay/auth.json
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Linux 示例:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
/home/<your-name>/.qcplay/auth.json
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
认证文件中至少需要存在有效的 `access_token`。
|
|
145
|
+
|
|
146
|
+
当前 CLI 同时兼容这些字段命名:
|
|
147
|
+
|
|
148
|
+
- `access_token`
|
|
149
|
+
- `accessToken`
|
|
150
|
+
- `token`
|
|
151
|
+
- `data.access_token`
|
|
152
|
+
- `data.accessToken`
|
|
153
|
+
|
|
154
|
+
如果存在 `expires_at` / `expiresAt`,程序会同时兼容秒级和毫秒级时间戳。
|
|
155
|
+
|
|
156
|
+
## Agent 执行要求
|
|
157
|
+
|
|
158
|
+
当 AI Agent 帮用户处理认证时,必须遵守:
|
|
159
|
+
|
|
160
|
+
1. 不要要求用户手动复制 `access_token`。
|
|
161
|
+
2. 不要要求用户手动编辑 `auth.json`。
|
|
162
|
+
3. 不要在终端输出完整 `access_token` 或 `refresh_token`。
|
|
163
|
+
4. 如果浏览器登录尚未完成,不要谎报“已登录”。
|
|
164
|
+
5. 如果用户只是想验证登录状态,优先执行 `qcplay auth status`。
|
|
165
|
+
6. 如果用户只是想重新登录,优先执行 `qcplay auth`。
|
|
166
|
+
|
|
167
|
+
## 安装联动
|
|
168
|
+
|
|
169
|
+
执行下面命令时,也会自动触发登录:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
qcplay install
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
或:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
qcplay-cli install
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
因此,如果用户正在首次安装 QCPlay CLI,通常不需要再额外执行一次独立的 `auth` 命令。
|
|
182
|
+
|
|
183
|
+
## 常见失败场景
|
|
184
|
+
|
|
185
|
+
### 1. 认证文件不存在
|
|
186
|
+
|
|
187
|
+
当前 CLI 会提示类似:
|
|
188
|
+
|
|
189
|
+
```txt
|
|
190
|
+
未登录或登录无效
|
|
191
|
+
原因: 认证文件不存在: ~/.qcplay/auth.json
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
处理方式:
|
|
195
|
+
|
|
196
|
+
- 提示用户执行 `qcplay auth`
|
|
197
|
+
- 等待浏览器登录完成
|
|
198
|
+
|
|
199
|
+
### 2. 认证文件不是合法 JSON
|
|
200
|
+
|
|
201
|
+
当前 CLI 会提示类似:
|
|
202
|
+
|
|
203
|
+
```txt
|
|
204
|
+
原因: 认证文件不是合法 JSON: ...
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
处理方式:
|
|
208
|
+
|
|
209
|
+
- 不要手改文件内容
|
|
210
|
+
- 直接重新执行 `qcplay auth`
|
|
211
|
+
|
|
212
|
+
### 3. 认证文件里没有 access_token
|
|
213
|
+
|
|
214
|
+
当前 CLI 会提示类似:
|
|
215
|
+
|
|
216
|
+
```txt
|
|
217
|
+
原因: 认证文件中没有找到 access_token
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
处理方式:
|
|
221
|
+
|
|
222
|
+
- 直接重新执行 `qcplay auth`
|
|
223
|
+
|
|
224
|
+
### 4. 登录状态已过期
|
|
225
|
+
|
|
226
|
+
当前 CLI 会提示类似:
|
|
227
|
+
|
|
228
|
+
```txt
|
|
229
|
+
原因: 登录状态已过期: ...
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
处理方式:
|
|
233
|
+
|
|
234
|
+
- 重新执行 `qcplay auth`
|
|
235
|
+
|
|
236
|
+
### 5. 本地认证程序不存在
|
|
237
|
+
|
|
238
|
+
如果底层 `qcplay-auth` 原生程序不存在,CLI 会报错:
|
|
239
|
+
|
|
240
|
+
```txt
|
|
241
|
+
执行程序不存在: ...
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
这说明当前平台的原生文件未正确打包或未提供,不要伪造认证成功。
|
|
245
|
+
|
|
246
|
+
## 禁止行为
|
|
247
|
+
|
|
248
|
+
禁止:
|
|
249
|
+
|
|
250
|
+
1. 未完成浏览器登录就声称认证成功。
|
|
251
|
+
2. 让用户把 token 明文发到聊天里。
|
|
252
|
+
3. 在项目目录中另存一份 token。
|
|
253
|
+
4. 登录失败时伪造“已登录”状态。
|
|
254
|
+
5. 未登录时伪造权限查询结果。
|
|
255
|
+
|
|
256
|
+
## 最短操作建议
|
|
257
|
+
|
|
258
|
+
如果用户只说“帮我登录 QCPlay”,默认执行:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
qcplay-cli auth
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
如果用户只说“帮我看看现在有没有登录”,默认执行:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
qcplay-cli auth status
|
|
268
|
+
```
|