@zhizai/cli 0.0.1 → 0.0.3

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,68 +4,42 @@
4
4
 
5
5
  查笔记、写总结、管知识库——一条命令搞定,支持脚本和 AI Agent 调用。
6
6
 
7
- > **当前版本:v0.0.1**
8
- > 已实现:`auth` / `doctor` / `capabilities` / `version` / `notes` / `note get` / `setup`。
9
- > 其余业务命令(`note create` / `ask` / `team` 等)已挂载子命令树,实现中。
7
+ > **当前版本:v0.0.3**
8
+ > 已可用:`auth` / `doctor` / `capabilities` / `version` / `notes` / `note get` / `setup`。
9
+ > 其余业务命令(`note create` / `ask` / `team` 等)子命令已挂载,能力逐步完善中。
10
+
11
+ 参与开发、构建与发包请见 [docs/development.md](./docs/development.md)。
10
12
 
11
13
  ---
12
14
 
13
15
  ## 安装
14
16
 
15
- ### 从源码构建(推荐开发期)
16
-
17
- 需要 Go 1.21+:
18
-
19
- ```bash
20
- git clone https://github.com/BoteAI/zhizai-cli.git
21
- cd zhizai-cli
22
- make build
23
- make install
24
- ```
25
-
26
- 构建产物:
27
-
28
- | 文件 | 说明 |
29
- |------|------|
30
- | `zhizai-cli` | `make build` 直接产物 |
31
- | `bin/zhizai` | `make dev-link` 复制到 npm 启动器目录 |
32
-
33
- 安装后可用命令:`zhizai` 与短别名 `zz`(`make install` 会安装符号链接;npm 全局安装同样注册两个入口)。
34
-
35
- ### npm 全局安装(Release 后可用)
17
+ 推荐使用 npm 全局安装(会自动下载对应平台二进制):
36
18
 
37
19
  ```bash
38
20
  npm install -g @zhizai/cli@latest
39
- zhizai auth login --api-key <your-api-key>
40
- zhizai doctor -o json
41
21
  ```
42
22
 
43
- `postinstall` 会下载对应平台的二进制;发布 Release 前请优先用源码构建。
23
+ 安装后可用命令:
44
24
 
45
- ### 维护者发版
25
+ - `zhizai` — 主命令
26
+ - `zz` — 短别名
46
27
 
47
- 仓库已配置 tag 触发:构建多平台二进制 → GitHub Release → `npm publish`。
48
-
49
- 前置:GitHub Actions Secret 配置 `NPM_TOKEN`;本地 `.npmrc` 仅用于本机 npm,**不要提交**(见 `.npmrc.example`)。
28
+ 验证:
50
29
 
51
30
  ```bash
52
- # 使用 package.json 当前版本打 tag 并推送
53
- make release
54
- # 或
55
- npm run release
56
-
57
- # 升版本后再发(注意用 V=,不要用 VERSION=)
58
- make release V=patch
59
- make release V=0.0.2
31
+ zhizai version
32
+ zz version
60
33
  ```
61
34
 
35
+ 也可从 [GitHub Releases](https://github.com/BoteAI/zhizai-cli/releases) 下载对应平台压缩包,解压后将 `zhizai` / `zhizai.exe` 放到 `PATH` 中。
36
+
62
37
  ---
63
38
 
64
39
  ## 使用要求
65
40
 
66
41
  - 需要有效的智在记录 **API Key**
67
42
  - 获取入口:[智在记录开发者](https://www.zzjilu.com/pc/developer)
68
- - OpenAPI 基址:`https://openapi.zzjilu.com/api/v1`
69
43
  - 请求头:`Authorization: <api-key>`(**不要**加 `Bearer`)
70
44
  - 限流:最高约 **2 次/秒**
71
45
 
@@ -73,17 +47,17 @@ make release V=0.0.2
73
47
 
74
48
  ## 开始使用
75
49
 
76
- ### 登录
50
+ ### 1. 登录
77
51
 
78
52
  ```bash
79
- # 直接传入 API Key(推荐脚本/CI)
53
+ # 直接传入 API Key(推荐脚本 / CI)
80
54
  zhizai auth login --api-key <your-api-key>
81
55
 
82
56
  # 或交互粘贴
83
57
  zhizai auth login
84
58
  ```
85
59
 
86
- 登录成功后会写入 `~/.zhizai/config.json`,并调用 `queryNoteList` 做一次探活。
60
+ 登录成功后会写入 `~/.zhizai/config.json`,并做一次接口探活。
87
61
 
88
62
  也可用环境变量(优先级高于配置文件):
89
63
 
@@ -91,7 +65,7 @@ zhizai auth login
91
65
  export ZHIZAI_REC_API_KEY=<your-api-key>
92
66
  ```
93
67
 
94
- ### 检查状态
68
+ ### 2. 检查状态
95
69
 
96
70
  ```bash
97
71
  zhizai auth status
@@ -102,7 +76,7 @@ zhizai capabilities -o json
102
76
 
103
77
  `doctor` 返回 `ready=true,status=ready` 表示可正常调用业务接口。
104
78
 
105
- ### 查看笔记
79
+ ### 3. 查看笔记
106
80
 
107
81
  ```bash
108
82
  zhizai notes
@@ -112,48 +86,48 @@ zhizai note get <id>
112
86
  zhizai note get <id> --field summary
113
87
  ```
114
88
 
115
- ### 接入本机 AI
89
+ ### 4. 接入本机 AI
116
90
 
117
91
  ```bash
118
92
  # 预览将执行的操作
119
93
  zhizai setup --dry-run -o json
120
94
 
121
- # 正式安装(本地验收可跳过 npm 全局安装)
122
- zhizai setup --skill-source . --skip-cli-install
95
+ # 正式安装 Skill
96
+ zhizai setup
123
97
  ```
124
98
 
99
+ `setup` 会把原子 Skill 安装到 Cursor、Claude Code、Codex 等本机 AI 环境,并引导完成授权。
100
+
125
101
  ---
126
102
 
127
- ## 命令一览
103
+ ## 功能一览
128
104
 
129
105
  ### 已可用
130
106
 
131
- ```
132
- zhizai auth login [--api-key <key>] 保存 API Key 并验证连接
133
- zhizai auth status 查看认证状态(Key 掩码显示)
134
- zhizai auth logout 清除本机凭证
135
- zhizai doctor 检查安装、登录与 API 连通性
136
- zhizai capabilities 查看当前版本的稳定能力契约
137
- zhizai version 显示版本
138
- zhizai notes [--limit|--page|--all] 笔记列表
139
- zhizai note get <id> [--field ...] 笔记详情
140
- zhizai setup [--dry-run] 为本机 AI 安装原子 Skill 并引导授权
141
- ```
142
-
143
- ### 规划中(子命令已挂载,业务逻辑待实现)
144
-
145
- ```
146
- zhizai note create|update|delete|status
147
- zhizai file upload 文件上传
148
- zhizai ask "<问题>" 基于笔记的动态模版问答/总结
149
- zhizai scene 场景与知识卡
150
- zhizai knowledge 笔记集
151
- zhizai team 团队与成员
152
- zhizai msg 消息与录音卡
153
- zhizai update 升级 CLI 并同步 Skill
154
- ```
155
-
156
- 字段与接口细节以 `skills/zhiji-open-platform/references/` 为准。
107
+ | 命令 | 说明 |
108
+ |------|------|
109
+ | `zhizai auth login [--api-key <key>]` | 保存 API Key 并验证连接 |
110
+ | `zhizai auth status` | 查看认证状态(Key 掩码显示) |
111
+ | `zhizai auth logout` | 清除本机凭证 |
112
+ | `zhizai doctor` | 检查安装、登录与 API 连通性 |
113
+ | `zhizai capabilities` | 查看当前版本的稳定能力契约 |
114
+ | `zhizai version` | 显示版本 |
115
+ | `zhizai notes [--limit\|--page\|--all]` | 笔记列表 |
116
+ | `zhizai note get <id> [--field ...]` | 笔记详情 |
117
+ | `zhizai setup [--dry-run]` | 为本机 AI 安装原子 Skill 并引导授权 |
118
+
119
+ ### 规划中
120
+
121
+ | 命令 | 说明 |
122
+ |------|------|
123
+ | `zhizai note create\|update\|delete\|status` | 笔记写入与状态 |
124
+ | `zhizai file upload` | 文件上传 |
125
+ | `zhizai ask "<问题>"` | 基于笔记的动态模版问答 / 总结 |
126
+ | `zhizai scene` | 场景与知识卡 |
127
+ | `zhizai knowledge` | 笔记集 |
128
+ | `zhizai team` | 团队与成员 |
129
+ | `zhizai msg` | 消息与录音卡 |
130
+ | `zhizai update` | 升级 CLI 并同步 Skill |
157
131
 
158
132
  ---
159
133
 
@@ -200,15 +174,12 @@ zhizai update 升级 CLI 并同步 Skill
200
174
  |----------|------|
201
175
  | `ZHIZAI_REC_API_KEY` | API Key |
202
176
  | `ZHIZAI_API_URL` | 覆盖 API 基址(默认 `https://openapi.zzjilu.com/api/v1`) |
203
- | `GOPROXY` | 构建时 Go 模块代理,国内可用 `https://goproxy.cn,direct` |
204
-
205
- ---
206
177
 
207
- ## 鉴权说明
178
+ ### 鉴权说明
208
179
 
209
- v0.1 仅支持 **API Key**:
180
+ 当前仅支持 **API Key**:
210
181
 
211
- 1. 在开发者页获取 Key,或由管理员下发后自行配置
182
+ 1. 在[开发者中心](https://www.zzjilu.com/pc/developer)获取 Key,或由管理员下发
212
183
  2. `zhizai auth login --api-key ...` 保存并探活
213
184
  3. 后续请求自动带 `Authorization: <api-key>`
214
185
 
@@ -218,7 +189,7 @@ OAuth 浏览器授权计划在后续版本补齐,不影响当前 API Key 流
218
189
 
219
190
  ## AI Agent 使用
220
191
 
221
- 所有命令支持 `-o json`。内置原子 Skill 源在 `skills/`:
192
+ 所有命令支持 `-o json`。内置原子 Skill:
222
193
 
223
194
  | Skill | 职责 |
224
195
  |-------|------|
@@ -229,74 +200,17 @@ OAuth 浏览器授权计划在后续版本补齐,不影响当前 API Key 流
229
200
  | `zhizai-team` | 团队与成员 |
230
201
  | `zhizai-msg` | 消息与录音卡 |
231
202
 
232
- 另保留聚合 Skill `zhiji-open-platform`(含完整 OpenAPI 参考文档)。
233
- `zhizai setup` 就绪后,会把原子 Skill 安装到 Cursor、Claude Code、Codex 等本机 AI。
203
+ 另保留聚合 Skill `zhiji-open-platform`(含完整 OpenAPI 参考文档)。
234
204
 
235
205
  原则:**Skill 只做意图路由,真实请求一律走 `zhizai` CLI**,不自行拼 OpenAPI。
236
206
 
237
207
  ---
238
208
 
239
- ## 从源码开发
240
-
241
- ```bash
242
- # 依赖
243
- go version # >= 1.21
244
-
245
- # 构建
246
- make build
247
-
248
- # 本地链接到 bin/zhizai(配合 npm 启动器调试)
249
- make dev-link
250
-
251
- # 安装到 PATH
252
- make install
253
-
254
- # 测试 / 静态检查
255
- make test
256
- make lint
257
-
258
- # 多平台交叉编译
259
- make build-all
260
- ```
261
-
262
- 目录结构:
263
-
264
- ```text
265
- zhizai-cli/
266
- ├── main.go
267
- ├── cmd/ # Cobra 子命令
268
- ├── internal/
269
- │ ├── client/ # OpenAPI HTTP 客户端(限流、resultCode 适配)
270
- │ ├── config/ # ~/.zhizai/config.json
271
- │ ├── output/ # 统一 JSON 输出
272
- │ ├── platform/ # 本机 AI 平台探测
273
- │ ├── ui/
274
- │ └── version/
275
- ├── skills/ # 原子 Skill + 开放平台参考
276
- ├── bin/zhizai.js # npm 启动器
277
- ├── scripts/postinstall.js
278
- └── .github/workflows/release.yml
279
- ```
280
-
281
- ---
282
-
283
- ## 路线图
284
-
285
- | 版本 | 内容 |
286
- |------|------|
287
- | **v0.1** | 脚手架、auth、doctor、capabilities(当前) |
288
- | **v0.2** | notes / note 详情与 CRUD、file upload |
289
- | **v0.3** | setup 安装 Skill、capabilities 完善 |
290
- | **v0.4** | scene / knowledge / team / msg |
291
- | **v0.5** | ask 动态模版总结管线 |
292
- | **v1.0** | update、Release CI、npm 发布 |
293
-
294
- ---
295
-
296
209
  ## 相关链接
297
210
 
298
211
  - [智在记录官网](https://www.zzjilu.com)
299
212
  - [开发者中心](https://www.zzjilu.com/pc/developer)
213
+ - [开发与发包说明](./docs/development.md)
300
214
  - [问题反馈](https://github.com/BoteAI/zhizai-cli/issues)
301
215
 
302
216
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhizai/cli",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "CLI tool for 智在记录 — manage notes and knowledge from the terminal and AI agents",
5
5
  "keywords": [
6
6
  "zhizai",
@@ -57,7 +57,13 @@ async function installArchive({ platform, binDir, binaryName, binaryPath, url, t
57
57
  run('tar', ['-xzf', tmpFile, '-C', binDir, binaryName]);
58
58
  }
59
59
 
60
- fs.chmodSync(binaryPath, 0o755);
60
+ if (!fs.existsSync(binaryPath)) {
61
+ throw new Error(`Binary missing after extract: ${binaryPath}`);
62
+ }
63
+ // chmod is meaningful on Unix; Windows may not need it.
64
+ if (platform.platform !== 'windows') {
65
+ fs.chmodSync(binaryPath, 0o755);
66
+ }
61
67
  console.log(`zhizai installed at ${binaryPath}`);
62
68
  } finally {
63
69
  try { fs.unlinkSync(tmpFile); } catch (_) {}
@@ -70,7 +76,9 @@ async function main() {
70
76
  const binaryName = getBinaryName(platform);
71
77
  const binaryPath = path.join(binDir, binaryName);
72
78
  const url = getDownloadURL(platform);
73
- const tmpFile = path.join(os.tmpdir(), `zhizai-download-${Date.now()}`);
79
+ // Expand-Archive on Windows requires a .zip extension; tar.gz similarly.
80
+ const archiveExt = platform.platform === 'windows' ? '.zip' : '.tar.gz';
81
+ const tmpFile = path.join(os.tmpdir(), `zhizai-download-${Date.now()}${archiveExt}`);
74
82
 
75
83
  if (fs.existsSync(binaryPath)) {
76
84
  try {