@zhizai/cli 0.0.3 → 0.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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  查笔记、写总结、管知识库——一条命令搞定,支持脚本和 AI Agent 调用。
6
6
 
7
- > **当前版本:v0.0.3**
7
+ > **当前版本:v0.0.4**
8
8
  > 已可用:`auth` / `doctor` / `capabilities` / `version` / `notes` / `note get` / `setup`。
9
9
  > 其余业务命令(`note create` / `ask` / `team` 等)子命令已挂载,能力逐步完善中。
10
10
 
@@ -38,9 +38,7 @@ zz version
38
38
 
39
39
  ## 使用要求
40
40
 
41
- - 需要有效的智在记录 **API Key**
42
- - 获取入口:[智在记录开发者](https://www.zzjilu.com/pc/developer)
43
- - 请求头:`Authorization: <api-key>`(**不要**加 `Bearer`)
41
+ - 通过 `zhizai auth login` 完成**网页授权登录**
44
42
  - 限流:最高约 **2 次/秒**
45
43
 
46
44
  ---
@@ -50,19 +48,15 @@ zz version
50
48
  ### 1. 登录
51
49
 
52
50
  ```bash
53
- # 直接传入 API Key(推荐脚本 / CI)
54
- zhizai auth login --api-key <your-api-key>
55
-
56
- # 或交互粘贴
57
51
  zhizai auth login
58
52
  ```
59
53
 
60
- 登录成功后会写入 `~/.zhizai/config.json`,并做一次接口探活。
54
+ 按提示在浏览器确认授权即可。登录成功后写入 `~/.zhizai/config.json`。
61
55
 
62
- 也可用环境变量(优先级高于配置文件):
56
+ 刷新 OAuth access_token(业务请求也会在过期时自动刷新):
63
57
 
64
58
  ```bash
65
- export ZHIZAI_REC_API_KEY=<your-api-key>
59
+ zhizai auth refresh
66
60
  ```
67
61
 
68
62
  ### 2. 检查状态
@@ -106,8 +100,9 @@ zhizai setup
106
100
 
107
101
  | 命令 | 说明 |
108
102
  |------|------|
109
- | `zhizai auth login [--api-key <key>]` | 保存 API Key 并验证连接 |
110
- | `zhizai auth status` | 查看认证状态(Key 掩码显示) |
103
+ | `zhizai auth login` | 网页设备授权登录 |
104
+ | `zhizai auth refresh` | 刷新 OAuth access_token |
105
+ | `zhizai auth status` | 查看认证状态(凭证掩码) |
111
106
  | `zhizai auth logout` | 清除本机凭证 |
112
107
  | `zhizai doctor` | 检查安装、登录与 API 连通性 |
113
108
  | `zhizai capabilities` | 查看当前版本的稳定能力契约 |
@@ -135,7 +130,6 @@ zhizai setup
135
130
 
136
131
  | 参数 | 说明 |
137
132
  |------|------|
138
- | `--api-key <key>` | 临时覆盖 API Key |
139
133
  | `-o, --output table\|json` | 输出格式(默认 `table`) |
140
134
 
141
135
  机器 / AI Agent 调用时请加 `-o json`,统一读取:
@@ -154,36 +148,15 @@ zhizai setup
154
148
 
155
149
  ## 配置
156
150
 
157
- 凭证保存在 `~/.zhizai/config.json`:
158
-
159
- ```json
160
- {
161
- "api_key": "xxxx",
162
- "expires_at": "2027-12-31 23:59:59",
163
- "team_id": ""
164
- }
165
- ```
166
-
167
- 凭证优先级:
168
-
169
- ```text
170
- --api-key > 环境变量 ZHIZAI_REC_API_KEY > ~/.zhizai/config.json
171
- ```
172
-
173
- | 环境变量 | 说明 |
174
- |----------|------|
175
- | `ZHIZAI_REC_API_KEY` | API Key |
176
- | `ZHIZAI_API_URL` | 覆盖 API 基址(默认 `https://openapi.zzjilu.com/api/v1`) |
151
+ 凭证保存在 `~/.zhizai/config.json`(含 OAuth `access_token` / `refresh_token` 等字段)。
177
152
 
178
153
  ### 鉴权说明
179
154
 
180
- 当前仅支持 **API Key**:
155
+ 默认使用 **OAuth 设备授权**:`zhizai auth login` → 浏览器确认 → 业务请求头 `X-OAuth2-Access-Token: Bearer …`。
181
156
 
182
- 1. 在[开发者中心](https://www.zzjilu.com/pc/developer)获取 Key,或由管理员下发
183
- 2. `zhizai auth login --api-key ...` 保存并探活
184
- 3. 后续请求自动带 `Authorization: <api-key>`
157
+ OAuth 过期时 CLI 会自动用 `refresh_token` 刷新;也可手动 `zhizai auth refresh`。
185
158
 
186
- OAuth 浏览器授权计划在后续版本补齐,不影响当前 API Key 流程。
159
+ 仅当网页授权失败时,CLI 会提示可改用 API Key 备用登录。
187
160
 
188
161
  ---
189
162
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhizai/cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "CLI tool for 智在记录 — manage notes and knowledge from the terminal and AI agents",
5
5
  "keywords": [
6
6
  "zhizai",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: zhizai-auth
3
- description: 安装和连接智在记录,完成 API Key 配置、环境诊断与 CLI 升级。用户说安装、连接、登录、检查为什么不能用时使用。
3
+ description: 安装和连接智在记录,完成网页授权登录、环境诊断与 CLI 升级。用户说安装、连接、登录、检查为什么不能用时使用。
4
4
  ---
5
5
 
6
6
  # 智在记录连接与诊断
@@ -11,9 +11,11 @@ description: 安装和连接智在记录,完成 API Key 配置、环境诊断
11
11
 
12
12
  | 意图 | 命令 |
13
13
  |---|---|
14
- | 登录 | `zhizai auth login --api-key <key>` |
14
+ | 登录 | `zhizai auth login` |
15
15
  | 查看状态 | `zhizai auth status` |
16
16
  | 退出 | `zhizai auth logout` |
17
17
  | 诊断 | `zhizai doctor -o json` |
18
18
  | 能力契约 | `zhizai capabilities -o json` |
19
19
  | 安装 Skill | `zhizai setup` |
20
+
21
+ 默认使用网页设备授权。仅当网页授权失败时,再提示用户使用 `zhizai auth login --api-key <key>`。