@zhizai/cli 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 iswalle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,304 @@
1
+ # 智在记录 CLI
2
+
3
+ 智在记录的命令行工具,让你在终端和 AI Agent 里直接管理笔记、笔记集、场景与团队。
4
+
5
+ 查笔记、写总结、管知识库——一条命令搞定,支持脚本和 AI Agent 调用。
6
+
7
+ > **当前版本:v0.0.1**
8
+ > 已实现:`auth` / `doctor` / `capabilities` / `version` / `notes` / `note get` / `setup`。
9
+ > 其余业务命令(`note create` / `ask` / `team` 等)已挂载子命令树,实现中。
10
+
11
+ ---
12
+
13
+ ## 安装
14
+
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 后可用)
36
+
37
+ ```bash
38
+ npm install -g @zhizai/cli@latest
39
+ zhizai auth login --api-key <your-api-key>
40
+ zhizai doctor -o json
41
+ ```
42
+
43
+ `postinstall` 会下载对应平台的二进制;发布 Release 前请优先用源码构建。
44
+
45
+ ### 维护者发版
46
+
47
+ 仓库已配置 tag 触发:构建多平台二进制 → GitHub Release → `npm publish`。
48
+
49
+ 前置:GitHub Actions Secret 配置 `NPM_TOKEN`;本地 `.npmrc` 仅用于本机 npm,**不要提交**(见 `.npmrc.example`)。
50
+
51
+ ```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
60
+ ```
61
+
62
+ ---
63
+
64
+ ## 使用要求
65
+
66
+ - 需要有效的智在记录 **API Key**
67
+ - 获取入口:[智在记录开发者](https://www.zzjilu.com/pc/developer)
68
+ - OpenAPI 基址:`https://openapi.zzjilu.com/api/v1`
69
+ - 请求头:`Authorization: <api-key>`(**不要**加 `Bearer`)
70
+ - 限流:最高约 **2 次/秒**
71
+
72
+ ---
73
+
74
+ ## 开始使用
75
+
76
+ ### 登录
77
+
78
+ ```bash
79
+ # 直接传入 API Key(推荐脚本/CI)
80
+ zhizai auth login --api-key <your-api-key>
81
+
82
+ # 或交互粘贴
83
+ zhizai auth login
84
+ ```
85
+
86
+ 登录成功后会写入 `~/.zhizai/config.json`,并调用 `queryNoteList` 做一次探活。
87
+
88
+ 也可用环境变量(优先级高于配置文件):
89
+
90
+ ```bash
91
+ export ZHIZAI_REC_API_KEY=<your-api-key>
92
+ ```
93
+
94
+ ### 检查状态
95
+
96
+ ```bash
97
+ zhizai auth status
98
+ zhizai doctor
99
+ zhizai doctor -o json
100
+ zhizai capabilities -o json
101
+ ```
102
+
103
+ `doctor` 返回 `ready=true,status=ready` 表示可正常调用业务接口。
104
+
105
+ ### 查看笔记
106
+
107
+ ```bash
108
+ zhizai notes
109
+ zhizai notes --limit 10 -o json
110
+ zhizai notes --all
111
+ zhizai note get <id>
112
+ zhizai note get <id> --field summary
113
+ ```
114
+
115
+ ### 接入本机 AI
116
+
117
+ ```bash
118
+ # 预览将执行的操作
119
+ zhizai setup --dry-run -o json
120
+
121
+ # 正式安装(本地验收可跳过 npm 全局安装)
122
+ zhizai setup --skill-source . --skip-cli-install
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 命令一览
128
+
129
+ ### 已可用
130
+
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/` 为准。
157
+
158
+ ---
159
+
160
+ ## 全局参数
161
+
162
+ | 参数 | 说明 |
163
+ |------|------|
164
+ | `--api-key <key>` | 临时覆盖 API Key |
165
+ | `-o, --output table\|json` | 输出格式(默认 `table`) |
166
+
167
+ 机器 / AI Agent 调用时请加 `-o json`,统一读取:
168
+
169
+ ```json
170
+ {
171
+ "success": true,
172
+ "data": {},
173
+ "error": null
174
+ }
175
+ ```
176
+
177
+ 失败时 `success=false`,读取 `error.code` / `error.message` / `error.reason` / `error.retryable`。
178
+
179
+ ---
180
+
181
+ ## 配置
182
+
183
+ 凭证保存在 `~/.zhizai/config.json`:
184
+
185
+ ```json
186
+ {
187
+ "api_key": "xxxx",
188
+ "expires_at": "2027-12-31 23:59:59",
189
+ "team_id": ""
190
+ }
191
+ ```
192
+
193
+ 凭证优先级:
194
+
195
+ ```text
196
+ --api-key > 环境变量 ZHIZAI_REC_API_KEY > ~/.zhizai/config.json
197
+ ```
198
+
199
+ | 环境变量 | 说明 |
200
+ |----------|------|
201
+ | `ZHIZAI_REC_API_KEY` | API Key |
202
+ | `ZHIZAI_API_URL` | 覆盖 API 基址(默认 `https://openapi.zzjilu.com/api/v1`) |
203
+ | `GOPROXY` | 构建时 Go 模块代理,国内可用 `https://goproxy.cn,direct` |
204
+
205
+ ---
206
+
207
+ ## 鉴权说明
208
+
209
+ v0.1 仅支持 **API Key**:
210
+
211
+ 1. 在开发者页获取 Key,或由管理员下发后自行配置
212
+ 2. `zhizai auth login --api-key ...` 保存并探活
213
+ 3. 后续请求自动带 `Authorization: <api-key>`
214
+
215
+ OAuth 浏览器授权计划在后续版本补齐,不影响当前 API Key 流程。
216
+
217
+ ---
218
+
219
+ ## AI Agent 使用
220
+
221
+ 所有命令支持 `-o json`。内置原子 Skill 源在 `skills/`:
222
+
223
+ | Skill | 职责 |
224
+ |-------|------|
225
+ | `zhizai-auth` | 安装、登录、诊断、升级 |
226
+ | `zhizai-note` | 笔记 CRUD、上传、问答 |
227
+ | `zhizai-knowledge` | 笔记集 |
228
+ | `zhizai-scene` | 场景与知识卡 |
229
+ | `zhizai-team` | 团队与成员 |
230
+ | `zhizai-msg` | 消息与录音卡 |
231
+
232
+ 另保留聚合 Skill `zhiji-open-platform`(含完整 OpenAPI 参考文档)。
233
+ `zhizai setup` 就绪后,会把原子 Skill 安装到 Cursor、Claude Code、Codex 等本机 AI。
234
+
235
+ 原则:**Skill 只做意图路由,真实请求一律走 `zhizai` CLI**,不自行拼 OpenAPI。
236
+
237
+ ---
238
+
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
+ ## 相关链接
297
+
298
+ - [智在记录官网](https://www.zzjilu.com)
299
+ - [开发者中心](https://www.zzjilu.com/pc/developer)
300
+ - [问题反馈](https://github.com/BoteAI/zhizai-cli/issues)
301
+
302
+ ## License
303
+
304
+ [MIT](./LICENSE)
package/bin/zhizai.js ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ // Platform-agnostic launcher for zhizai binary
3
+
4
+ 'use strict';
5
+
6
+ const { spawn } = require('child_process');
7
+ const path = require('path');
8
+ const os = require('os');
9
+
10
+ const platform = os.platform();
11
+ const binaryName = platform === 'win32' ? 'zhizai.exe' : 'zhizai';
12
+ const binaryPath = path.join(__dirname, binaryName);
13
+
14
+ const child = spawn(binaryPath, process.argv.slice(2), {
15
+ stdio: 'inherit',
16
+ windowsHide: true
17
+ });
18
+
19
+ child.on('exit', (code, signal) => {
20
+ if (signal) {
21
+ process.kill(process.pid, signal);
22
+ } else {
23
+ process.exit(code);
24
+ }
25
+ });
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@zhizai/cli",
3
+ "version": "0.0.1",
4
+ "description": "CLI tool for 智在记录 — manage notes and knowledge from the terminal and AI agents",
5
+ "keywords": [
6
+ "zhizai",
7
+ "zhiji",
8
+ "cli",
9
+ "notes"
10
+ ],
11
+ "homepage": "https://github.com/BoteAI/zhizai-cli",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/BoteAI/zhizai-cli.git"
15
+ },
16
+ "license": "MIT",
17
+ "bin": {
18
+ "zhizai": "./bin/zhizai.js",
19
+ "zz": "./bin/zhizai.js"
20
+ },
21
+ "scripts": {
22
+ "postinstall": "node scripts/postinstall.js",
23
+ "release": "bash scripts/release.sh"
24
+ },
25
+ "files": [
26
+ "bin/zhizai.js",
27
+ "scripts/postinstall.js",
28
+ "skills/",
29
+ "README.md"
30
+ ]
31
+ }
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env node
2
+ // postinstall.js — downloads the zhizai binary for the current platform.
3
+
4
+ 'use strict';
5
+
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+ const os = require('os');
9
+ const https = require('https');
10
+ const crypto = require('crypto');
11
+ const { spawnSync } = require('child_process');
12
+
13
+ const pkg = require('../package.json');
14
+ const VERSION = pkg.version;
15
+ const REPO = 'BoteAI/zhizai-cli';
16
+
17
+ function getPlatform() {
18
+ const platform = os.platform();
19
+ const arch = os.arch();
20
+
21
+ const platformMap = { darwin: 'darwin', linux: 'linux', win32: 'windows' };
22
+ const archMap = { x64: 'amd64', arm64: 'arm64' };
23
+
24
+ const p = platformMap[platform];
25
+ const a = archMap[arch];
26
+ if (!p || !a) throw new Error(`Unsupported platform: ${platform}/${arch}`);
27
+ return { platform: p, arch: a };
28
+ }
29
+
30
+ function getBinaryName(platform) {
31
+ return platform.platform === 'windows' ? 'zhizai.exe' : 'zhizai';
32
+ }
33
+
34
+ function getDownloadURL(platform) {
35
+ const ext = platform.platform === 'windows' ? '.zip' : '.tar.gz';
36
+ const asset = `zhizai-cli_${VERSION}_${platform.platform}_${platform.arch}${ext}`;
37
+ return `https://github.com/${REPO}/releases/download/v${VERSION}/${asset}`;
38
+ }
39
+
40
+ function getWindowsExtractArgs(archivePath, destinationPath) {
41
+ return [
42
+ '-NoProfile',
43
+ '-Command',
44
+ '& { Expand-Archive -LiteralPath $args[0] -DestinationPath $args[1] -Force }',
45
+ archivePath,
46
+ destinationPath,
47
+ ];
48
+ }
49
+
50
+ async function installArchive({ platform, binDir, binaryName, binaryPath, url, tmpFile }) {
51
+ try {
52
+ await download(url, tmpFile);
53
+ await verifyChecksum(url, path.basename(url), tmpFile);
54
+ if (platform.platform === 'windows') {
55
+ run('powershell', getWindowsExtractArgs(tmpFile, binDir));
56
+ } else {
57
+ run('tar', ['-xzf', tmpFile, '-C', binDir, binaryName]);
58
+ }
59
+
60
+ fs.chmodSync(binaryPath, 0o755);
61
+ console.log(`zhizai installed at ${binaryPath}`);
62
+ } finally {
63
+ try { fs.unlinkSync(tmpFile); } catch (_) {}
64
+ }
65
+ }
66
+
67
+ async function main() {
68
+ const platform = getPlatform();
69
+ const binDir = path.join(__dirname, '..', 'bin');
70
+ const binaryName = getBinaryName(platform);
71
+ const binaryPath = path.join(binDir, binaryName);
72
+ const url = getDownloadURL(platform);
73
+ const tmpFile = path.join(os.tmpdir(), `zhizai-download-${Date.now()}`);
74
+
75
+ if (fs.existsSync(binaryPath)) {
76
+ try {
77
+ const result = spawnSync(binaryPath, ['version'], { encoding: 'utf8' });
78
+ const out = (result.stdout || '').trim();
79
+ if (result.status === 0 && out.includes(VERSION)) {
80
+ console.log(`zhizai v${VERSION} already installed, skipping download.`);
81
+ return;
82
+ }
83
+ } catch (_) {}
84
+ }
85
+
86
+ console.log(`Downloading zhizai v${VERSION} for ${platform.platform}/${platform.arch}...`);
87
+ console.log(`URL: ${url}`);
88
+
89
+ fs.mkdirSync(binDir, { recursive: true });
90
+ await installArchive({ platform, binDir, binaryName, binaryPath, url, tmpFile });
91
+ }
92
+
93
+ function run(command, args) {
94
+ const result = spawnSync(command, args, { stdio: 'inherit' });
95
+ if (result.error) throw result.error;
96
+ if (result.status !== 0) throw new Error(`${command} exited with status ${result.status}`);
97
+ }
98
+
99
+ function download(url, destination, redirects = 0) {
100
+ if (redirects > 5) return Promise.reject(new Error('Too many redirects'));
101
+ return new Promise((resolve, reject) => {
102
+ const request = https.get(url, { headers: { 'User-Agent': '@zhizai/cli installer' } }, response => {
103
+ if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
104
+ response.resume();
105
+ return resolve(download(new URL(response.headers.location, url).toString(), destination, redirects + 1));
106
+ }
107
+ if (response.statusCode !== 200) {
108
+ response.resume();
109
+ return reject(new Error(`HTTP ${response.statusCode}: ${url}`));
110
+ }
111
+ const output = fs.createWriteStream(destination, { mode: 0o600 });
112
+ response.pipe(output);
113
+ output.on('finish', () => output.close(resolve));
114
+ output.on('error', reject);
115
+ });
116
+ request.on('error', reject);
117
+ });
118
+ }
119
+
120
+ async function verifyChecksum(assetURL, assetName, archivePath) {
121
+ const checksumPath = `${archivePath}.checksums`;
122
+ try {
123
+ await download(new URL('checksums.txt', assetURL).toString(), checksumPath);
124
+ const line = fs.readFileSync(checksumPath, 'utf8').split(/\r?\n/).find(value => {
125
+ const fields = value.trim().split(/\s+/);
126
+ return fields.length === 2 && fields[1].replace(/^\*/, '') === assetName;
127
+ });
128
+ if (!line) throw new Error(`Checksum for ${assetName} is missing`);
129
+ const expected = line.trim().split(/\s+/)[0].toLowerCase();
130
+ if (!/^[a-f0-9]{64}$/.test(expected)) throw new Error(`Checksum for ${assetName} is invalid`);
131
+ const actual = crypto.createHash('sha256').update(fs.readFileSync(archivePath)).digest('hex');
132
+ if (actual !== expected) throw new Error(`Checksum mismatch for ${assetName}`);
133
+ } finally {
134
+ try { fs.unlinkSync(checksumPath); } catch (_) {}
135
+ }
136
+ }
137
+
138
+ if (require.main === module) {
139
+ main().catch(err => {
140
+ console.error('Failed to install zhizai:', err.message);
141
+ process.exitCode = 1;
142
+ });
143
+ }
@@ -0,0 +1,103 @@
1
+ ---
2
+ name: zhiji-open-platform
3
+ version: 1.0.0
4
+ description: |
5
+ 通过智在记录开放 API 连接笔记数据:鉴权、检索/问答/总结(动态模版路由)、笔记 CRUD、场景与知识卡、笔记集、团队、消息与录音卡。
6
+ 用户要查笔记、写周报/复盘、新建编辑删除笔记、管团队/笔记集/录音卡,或配置 ZHIZAI_REC_API_KEY 时使用。
7
+ 基准地址为常量 ZHIZAI_BASE_URL;鉴权 Header 直接传 Key(无 Bearer)。
8
+ metadata:
9
+ openclaw:
10
+ emoji: "📒"
11
+ requires: {}
12
+ optionalEnv:
13
+ - ZHIZAI_REC_API_KEY
14
+ ---
15
+
16
+ # 智在记录 · 开放平台
17
+
18
+ 让用户在当前 AI 中用自然语言访问智在记录:检索与总结、维护笔记、管理场景/笔记集/团队与录音卡。本 Skill 理解意图、加载对应领域参考,再按官方 REST API 执行真实操作。
19
+
20
+ ## 能力与外部影响
21
+
22
+ - 按用户请求调用 `https://openapi.zzjilu.com/api/v1` 下的开放接口,读取或修改当前 API Key 对应账号的数据。
23
+ - 鉴权依赖环境变量 `ZHIZAI_REC_API_KEY`(请求头 `Authorization` 直接传 Key,**不要**加 `Bearer`)。
24
+ - 新建/编辑/删除笔记、加人删团队、发消息等会修改远端数据,须遵守下方确认规则。
25
+ - 限流最高 **2 次/秒**;连续调用宜间隔 ≥500ms。
26
+ - 不会自行安装其他软件、下载覆盖本 Skill,或在回复中泄露完整 Key。
27
+
28
+ ## 能力概览
29
+
30
+ | 用户想做什么 | 典型说法 | 完成后应返回什么 |
31
+ | --- | --- | --- |
32
+ | 基于笔记问答/总结 | “本周会议总结一下”“帮我写周报” | 按模版或语义结构整理的真实结论;无笔记时诚实说明 |
33
+ | 查找笔记 | “最近有哪些录音”“找一下报销相关” | 真实 `id`、标题、中文类型、时间、摘要/总结 |
34
+ | 新建/上传笔记 | “存这篇文档”“记一条文本” | 真实笔记 ID、标题、`note_state`;未完成时说明进度 |
35
+ | 改删与进度 | “改标题”“删掉这条”“处理完了吗” | 最终状态;删除/覆盖先确认;进度≠正文 |
36
+ | 场景与知识卡 | “有哪些总结场景”“看知识卡” | 真实场景/卡片列表,可用 ID |
37
+ | 笔记集 | “我创建的笔记集”“打开某某集” | 真实知识库名称、ID、集内条目 |
38
+ | 团队 | “建个团队”“加个成员” | 真实团队/成员 ID;危险操作先确认 |
39
+ | 录音卡 / 发消息 | “查一下这张卡”“给某某发消息” | 用量/连接状态或发送结果;敏感字段脱敏 |
40
+ | 连接与鉴权 | “配置 Key”“用口令换 Key” | Key 是否可用;口令换 Key 不展示完整密钥 |
41
+
42
+ 不要要求用户记接口路径。用户用自然语言表达目标即可。
43
+
44
+ ## 首次连接
45
+
46
+ 1. 检查 `ZHIZAI_REC_API_KEY` 是否已配置且非空。未配置:只提示配置该变量,并推荐 [智在记录开发者](https://www.zzjilu.com/pc/developer);不继续调业务接口。
47
+ 2. 用无写入验收:`POST /note/queryNoteList`,`pageNum=1`、`pageSize=1`。`resultCode=="0"` 才可说已连接。
48
+ 3. 只有用户同意时才创建测试笔记;必须返回真实 `id`、标题与 `note_state`。
49
+ 4. 本会话已成功调用过任一接口后,可不再重复强调 Key 检查。
50
+
51
+ 常量(非环境变量):`ZHIZAI_BASE_URL` = `https://openapi.zzjilu.com/api/v1`。下文路径均接在该基准之后。
52
+
53
+ ## 每次任务的执行闭环
54
+
55
+ 1. **理解目标**:对象、动作、时间范围与输出版式;指代不清时先澄清。
56
+ 2. **加载领域参考**:只读取本次任务涉及的 `references/*.md`,不要凭印象猜路径、参数或返回字段。
57
+ 3. **确认真实 ID**:笔记、场景、笔记集、团队、成员等一律使用接口返回的真实 ID;重名时让用户选择。
58
+ 4. **按官方 API 调用**:JSON 用 `content-type: application/json`;上传用 `multipart/form-data`;遵守限流。
59
+ 5. **判断结果**:先看 HTTP(400/401/406=无权限),再看 `resultCode=="0"`;异步创建用 `queryNoteStatus` 轮询,不能把“已提交”说成“已完成”。
60
+ 6. **必要时复读**:更新、删除、归档类操作后按需再查列表/详情确认最终状态。
61
+ 7. **回复用户**:先结论,再给必要字段;失败说明原因与下一步,不泄露 Key/`stack`。
62
+
63
+ ## 路由
64
+
65
+ 匹配用户意图后,**必须读取并遵循**对应领域参考:
66
+
67
+ - 鉴权、口令换 Key、解析 token:[`references/auth.md`](references/auth.md)
68
+ - 笔记检索/问答/总结(含动态模版)、CRUD、上传下载:[`references/note.md`](references/note.md)
69
+ - 场景与知识卡:[`references/scene.md`](references/scene.md)
70
+ - 笔记集(我创建/我收到/详情):[`references/knowledge.md`](references/knowledge.md)
71
+ - 团队与成员:[`references/team.md`](references/team.md)
72
+ - 消息与录音卡:[`references/msg-device.md`](references/msg-device.md)
73
+
74
+ 多领域任务按步骤依次读取。例如“按场景总结本周会议笔记”先读 `note`(模版管线),需要 `sceneId` 时再读 `scene`。
75
+
76
+ 边界模糊且答案依赖笔记内容时:**默认走 `note` 中的动态模版管线**。
77
+
78
+ ## 结果呈现标准
79
+
80
+ - **总结/问答**:按最终选用模版填充真实笔记;缺失标「未提及」;不默认整段贴出模版原文。
81
+ - **笔记列表**:`id`、`title`、中文类型、`create_time`;有 `summary` 用总结否则 `abstract`。`note_type` 必须转中文(见 `note.md`)。
82
+ - **新建成功**:返回真实 ID、标题、`note_state`;`pending` 等说明处理中并可查进度。
83
+ - **进度查询**:只报告系统处理阶段,不当作正文内容。
84
+ - **空结果**:柔和说明未找到及相关检索范围,可建议换词/调时间,禁止编造。
85
+ - **失败**:用户能理解的短句 + 可执行下一步;禁止展示完整 Key、`stack`、未脱敏 `errorInfos`。
86
+
87
+ ## 统一规则
88
+
89
+ - 真实操作只走开放 API;字段与 curl 以对应 `references/*.md` 的「接口协议」为准。
90
+ - `resultCode != "0"` 一律失败;优先用 `resultMsg` 短句说明。
91
+ - ID、fileId 始终按返回原样传递,禁止臆造。
92
+ - 修改笔记路径为 **`POST /note/updateNoteInfo`**(不是 `updateNote`);摘要请求字段为 `abstractContent`。
93
+ - 删除笔记、删团队/成员、发消息、覆盖性修改须先确认。
94
+ - 群聊或共享会话中不主动展开私密全文与手机号。
95
+ - 口令换 Key:口令与返回的 Key **禁止**在对话中完整展示。
96
+
97
+ ## 常见恢复方式
98
+
99
+ - HTTP 400/401/406 或鉴权失败:读 `references/auth.md`,检查 `ZHIZAI_REC_API_KEY`,引导开发者页,不回显 Header。
100
+ - 限流:等待后重试,不高频循环。
101
+ - 笔记不存在 / 非录音却下音频:说明真实原因,改用正确 ID 或接口。
102
+ - 创建后长期 `pending`:用 `queryNoteStatus` 查询,提示稍后查看,不伪造已完成总结。
103
+ - 网络中断或结果不确定:只做查询核验,不自动重复写入。