@getnote/cli 0.1.3 → 0.1.5

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
@@ -1,133 +1,199 @@
1
- # getnote-cli
1
+ # Get笔记 CLI
2
2
 
3
- CLI tool for [Get笔记](https://biji.com) — manage notes and knowledge bases from the terminal.
3
+ Get笔记的命令行工具,让你在终端和 AI Agent 里直接管理笔记和知识库。
4
4
 
5
- Designed for both humans and AI agents.
5
+ 存链接、记文字、搜笔记、管知识库——一条命令搞定,支持脚本和 AI Agent 调用。
6
6
 
7
- ## Installation
7
+ ---
8
8
 
9
- ### npm (recommended)
9
+ ## 安装
10
10
 
11
11
  ```bash
12
12
  npm install -g @getnote/cli
13
13
  ```
14
14
 
15
- ### Manual
15
+ 或者从 [Releases](https://github.com/iswalle/getnote-cli/releases) 下载对应平台的二进制文件,放到 `$PATH` 里。
16
16
 
17
- Download the latest binary from [Releases](https://github.com/iswalle/getnote-cli/releases) and place it on your `$PATH`.
17
+ ---
18
18
 
19
- ### Build from source
19
+ ## 三步开始用
20
20
 
21
+ **第一步:安装**
21
22
  ```bash
22
- git clone https://github.com/iswalle/getnote-cli.git
23
- cd getnote-cli
24
- make install
23
+ npm install -g @getnote/cli
25
24
  ```
26
25
 
27
- ## Quick Start
28
-
26
+ **第二步:登录**
29
27
  ```bash
30
- # Authenticate (OAuth browser flow)
31
28
  getnote auth login
29
+ ```
30
+ 会自动打开浏览器完成授权。也可以直接用 API Key:
31
+ ```bash
32
+ getnote auth login --api-key gk_live_xxx
33
+ ```
32
34
 
33
- # Save a URL
34
- getnote save https://example.com/article --title "Great article"
35
+ **第三步:开始用**
36
+ ```bash
37
+ # 存一篇文章
38
+ getnote save https://example.com/article --tag 阅读
35
39
 
36
- # Save plain text
37
- getnote save "Remember to review the docs" --tag work
40
+ # 记一条文字
41
+ getnote save "周五前要回复王总的邮件" --tag 待办
38
42
 
39
- # List recent notes
43
+ # 看最近的笔记
40
44
  getnote notes
41
-
42
- # List all notes (auto-paginate)
43
- getnote notes --all
44
45
  ```
45
46
 
46
- ## Commands
47
+ ---
47
48
 
48
- ### Authentication
49
+ ## 典型使用场景
49
50
 
51
+ **场景 1:边看边存**
52
+ ```bash
53
+ # 存链接,自动抓取页面内容
54
+ getnote save https://simonwillison.net/2024/llms-reading-list/ --tag ai
55
+
56
+ # 存完自动展示笔记内容,不用再手动查
50
57
  ```
51
- getnote auth login Authenticate via OAuth (browser)
52
- getnote auth login --api-key <key> Authenticate with API key directly
53
- getnote auth status Show authentication status
54
- getnote auth logout Remove saved credentials
58
+
59
+ **场景 2:搜索笔记**
60
+ ```bash
61
+ # 全局搜索
62
+ getnote search "LLM 推荐阅读"
63
+
64
+ # 在某个知识库内搜索
65
+ getnote search "产品设计" --kb vnrOAaGY
55
66
  ```
56
67
 
57
- ### Save & Tasks
68
+ **场景 3:管理知识库**
69
+ ```bash
70
+ # 列出所有知识库
71
+ getnote kbs
72
+
73
+ # 查看某个知识库的笔记
74
+ getnote kb vnrOAaGY --all
58
75
 
76
+ # 把笔记加入知识库
77
+ getnote kb add vnrOAaGY 1234567890
59
78
  ```
60
- getnote save <url|text> Save a URL or text note
61
- --title <title> Optional title
62
- --tag <tag> Tag (repeatable)
63
79
 
64
- getnote task <task_id> Check the progress of an async save task
80
+ **场景 4:脚本批处理**
81
+ ```bash
82
+ # 导出所有笔记为 JSON
83
+ getnote notes --all -o json > all-notes.json
84
+
85
+ # 取出某条笔记的正文
86
+ getnote note 1234567890 --field content | pbcopy
65
87
  ```
66
88
 
67
- ### Notes
89
+ ---
68
90
 
91
+ ## AI Agent 使用
92
+
93
+ 所有命令支持 `-o json` 输出结构化数据,AI Agent 可以直接解析:
94
+
95
+ ```bash
96
+ getnote notes -o json
97
+ getnote note 1234567890 -o json
98
+ getnote search "关键词" -o json
99
+ getnote save https://example.com -o json # 自动轮询,返回最终笔记
69
100
  ```
70
- getnote notes List recent notes (default 20)
71
- --limit <n> Number of notes (default 20)
72
- --since-id <id> Pagination cursor
73
- --all Fetch all notes (auto-paginate)
74
101
 
75
- getnote note <id> Show note details
76
- --field <name> Output a single field as plain text
77
- (id, title, content, type,
78
- created_at, updated_at, url, excerpt)
102
+ `skills/` 目录下有 Claude Code 专用的 Skill 文件,加到项目上下文后,AI Agent 可以直接用自然语言操作笔记。
79
103
 
80
- getnote note update <id> Update a note
81
- --title <title>
82
- --content <content> plain_text notes only
83
- --tag <tags> Comma-separated, replaces existing tags
104
+ ---
84
105
 
85
- getnote note delete <id> Delete a note (moves to trash)
86
- -y, --yes Skip confirmation
106
+ ## 完整命令参考
107
+
108
+ ### 认证
109
+
110
+ ```
111
+ getnote auth login OAuth 登录(浏览器授权)
112
+ getnote auth login --api-key <key> 直接用 API Key 登录
113
+ getnote auth status 查看当前登录状态
114
+ getnote auth logout 退出登录
87
115
  ```
88
116
 
89
- ### Knowledge Bases
117
+ ### 保存笔记
90
118
 
91
119
  ```
92
- getnote kbs List all knowledge bases
120
+ getnote save <url|文字|图片路径> 保存链接/文字/图片笔记
121
+ --title <标题> 可选标题
122
+ --tag <标签> 标签(可重复)
93
123
 
94
- getnote kb <topic_id> List notes in a knowledge base
95
- --limit <n> Number of notes (default 20)
96
- --all Fetch all notes (auto-paginate)
124
+ getnote task <task_id> 查看异步任务进度
125
+ ```
126
+
127
+ 链接笔记是异步处理的,CLI 会自动轮询等待完成,完成后直接展示内容。`-o json` 模式下静默轮询,返回最终笔记 JSON。
97
128
 
98
- getnote kb create <name> Create a knowledge base
99
- --desc <description>
129
+ ### 查看和管理笔记
100
130
 
101
- getnote kb add <topic_id> <note_id> [note_id...] Add notes
102
- getnote kb remove <topic_id> <note_id> [note_id...] Remove notes
131
+ ```
132
+ getnote notes 最近 20 条笔记
133
+ --limit <n> 自定义数量
134
+ --all 获取全部(自动翻页)
135
+
136
+ getnote note <id> 笔记详情
137
+ --field <字段名> 只输出某个字段的值
138
+ (id/title/content/type/
139
+ created_at/url/excerpt)
140
+
141
+ getnote note update <id> 更新笔记
142
+ --title <标题>
143
+ --content <内容> 仅文字笔记可用
144
+ --tag <标签> 逗号分隔,会替换现有标签
145
+
146
+ getnote note delete <id> 删除笔记(移入回收站)
147
+ -y 跳过确认
103
148
  ```
104
149
 
105
- ## Global Flags
150
+ ### 搜索
106
151
 
107
- | Flag | Description |
108
- |------|-------------|
109
- | `--api-key <key>` | Override API key for this command |
110
- | `-o, --output json\|table` | Output format (default: `table`) |
111
- | `--env prod\|dev` | Target environment (default: `prod`) |
152
+ ```
153
+ getnote search <关键词> 全局语义搜索
154
+ --limit <n> 返回数量(默认 10)
155
+ --kb <topic_id> 限定在某个知识库内搜索
156
+ ```
112
157
 
113
- ## Field Output (Pipe-friendly)
158
+ ### 标签
114
159
 
115
- Use `--field` to extract a single value for use in scripts:
160
+ ```
161
+ getnote tag add <note_id> <标签> 给笔记加标签
162
+ getnote tag remove <note_id> <标签> 删除笔记标签
163
+ getnote tag list <note_id> 查看笔记的所有标签
164
+ ```
116
165
 
117
- ```bash
118
- # Get note content
119
- getnote note 1234567890 --field content
166
+ ### 知识库
120
167
 
121
- # Get source URL of a link note
122
- getnote note 1234567890 --field url
168
+ ```
169
+ getnote kbs 列出所有知识库
123
170
 
124
- # Pipe into another command
125
- getnote note 1234567890 --field content | pbcopy
171
+ getnote kb <topic_id> 知识库内的笔记
172
+ --limit <n>
173
+ --all 获取全部
174
+
175
+ getnote kb create <名称> 新建知识库
176
+ --desc <描述>
177
+
178
+ getnote kb add <topic_id> <note_id> [note_id...] 加入知识库
179
+ getnote kb remove <topic_id> <note_id> [note_id...] 移出知识库
126
180
  ```
127
181
 
128
- ## Configuration
182
+ ---
183
+
184
+ ## 全局参数
129
185
 
130
- Credentials are stored in `~/.getnote/config.json`:
186
+ | 参数 | 说明 |
187
+ |------|------|
188
+ | `--api-key <key>` | 临时覆盖 API Key |
189
+ | `-o, --output json\|table` | 输出格式(默认 table) |
190
+ | `--env prod\|dev` | 切换 API 环境 |
191
+
192
+ ---
193
+
194
+ ## 配置
195
+
196
+ 凭证保存在 `~/.getnote/config.json`:
131
197
 
132
198
  ```json
133
199
  {
@@ -136,18 +202,36 @@ Credentials are stored in `~/.getnote/config.json`:
136
202
  }
137
203
  ```
138
204
 
139
- Environment variables (higher priority than config file):
205
+ 也支持环境变量(优先级更高):
140
206
 
141
- | Variable | Description |
142
- |----------|-------------|
143
- | `GETNOTE_API_KEY` | API key |
207
+ | 变量 | 说明 |
208
+ |------|------|
209
+ | `GETNOTE_API_KEY` | API Key |
144
210
  | `GETNOTE_CLIENT_ID` | Client ID |
145
- | `GETNOTE_API_URL` | Override the API base URL |
211
+ | `GETNOTE_API_URL` | 覆盖 API 地址 |
212
+
213
+ ---
214
+
215
+ ## 从源码构建
216
+
217
+ 需要 Go 1.21+。
218
+
219
+ ```bash
220
+ git clone https://github.com/iswalle/getnote-cli.git
221
+ cd getnote-cli
222
+ make install
223
+ ```
224
+
225
+ ---
146
226
 
147
- ## AI Agent Usage
227
+ ## 相关链接
148
228
 
149
- All commands support `-o json` for machine-readable output. See the [skills/](./skills/) directory for agent skill documentation.
229
+ - [Get笔记官网](https://biji.com)
230
+ - [Get笔记 OpenClaw Skill](https://github.com/iswalle/getnote-openclaw) — 在飞书/Telegram 等消息渠道用自然语言操作笔记
231
+ - [Get笔记 MCP](https://github.com/iswalle/getnote-mcp) — MCP 协议接入,适配 Claude Desktop 等工具
232
+ - [开放平台文档](https://openapi.biji.com/docs)
233
+ - [问题反馈](https://github.com/iswalle/getnote-cli/issues)
150
234
 
151
235
  ## License
152
236
 
153
- MIT
237
+ [MIT](https://opensource.org/licenses/MIT)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getnote/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "CLI tool for Get笔记 — manage notes and knowledge bases from the terminal",
5
5
  "keywords": [
6
6
  "getnote",
@@ -3,7 +3,6 @@
3
3
 
4
4
  'use strict';
5
5
 
6
- const https = require('https');
7
6
  const fs = require('fs');
8
7
  const path = require('path');
9
8
  const os = require('os');
@@ -17,21 +16,12 @@ function getPlatform() {
17
16
  const platform = os.platform();
18
17
  const arch = os.arch();
19
18
 
20
- const platformMap = {
21
- darwin: 'darwin',
22
- linux: 'linux',
23
- win32: 'windows',
24
- };
25
- const archMap = {
26
- x64: 'amd64',
27
- arm64: 'arm64',
28
- };
19
+ const platformMap = { darwin: 'darwin', linux: 'linux', win32: 'windows' };
20
+ const archMap = { x64: 'amd64', arm64: 'arm64' };
29
21
 
30
22
  const p = platformMap[platform];
31
23
  const a = archMap[arch];
32
- if (!p || !a) {
33
- throw new Error(`Unsupported platform: ${platform}/${arch}`);
34
- }
24
+ if (!p || !a) throw new Error(`Unsupported platform: ${platform}/${arch}`);
35
25
  return { platform: p, arch: a };
36
26
  }
37
27
 
@@ -45,31 +35,6 @@ function getDownloadURL(platform) {
45
35
  return `https://github.com/${REPO}/releases/download/v${VERSION}/${asset}`;
46
36
  }
47
37
 
48
- async function download(url, dest) {
49
- return new Promise((resolve, reject) => {
50
- const file = fs.createWriteStream(dest);
51
- const get = (u) => {
52
- https.get(u, (res) => {
53
- if (res.statusCode === 301 || res.statusCode === 302) {
54
- file.close();
55
- get(res.headers.location);
56
- return;
57
- }
58
- if (res.statusCode !== 200) {
59
- reject(new Error(`Download failed: ${res.statusCode} ${u}`));
60
- return;
61
- }
62
- res.pipe(file);
63
- file.on('finish', () => file.close(resolve));
64
- }).on('error', (err) => {
65
- fs.unlink(dest, () => {});
66
- reject(err);
67
- });
68
- };
69
- get(url);
70
- });
71
- }
72
-
73
38
  async function main() {
74
39
  const platform = getPlatform();
75
40
  const binDir = path.join(__dirname, '..', 'bin');
@@ -84,22 +49,26 @@ async function main() {
84
49
  fs.mkdirSync(binDir, { recursive: true });
85
50
 
86
51
  try {
87
- await download(url, tmpFile);
88
-
52
+ // Use curl (available on macOS/Linux) or PowerShell (Windows) for reliable redirect handling
89
53
  if (platform.platform === 'windows') {
90
- execSync(`unzip -o "${tmpFile}" "${binaryName}" -d "${binDir}"`);
54
+ execSync(
55
+ `powershell -Command "Invoke-WebRequest -Uri '${url}' -OutFile '${tmpFile}'"`,
56
+ { stdio: 'inherit' }
57
+ );
58
+ execSync(`powershell -Command "Expand-Archive -Path '${tmpFile}' -DestinationPath '${binDir}' -Force"`, { stdio: 'inherit' });
91
59
  } else {
92
- execSync(`tar -xzf "${tmpFile}" -C "${binDir}" "${binaryName}"`);
60
+ execSync(`curl -fsSL "${url}" -o "${tmpFile}"`, { stdio: 'inherit' });
61
+ execSync(`tar -xzf "${tmpFile}" -C "${binDir}" "${binaryName}"`, { stdio: 'inherit' });
93
62
  }
94
63
 
95
64
  fs.chmodSync(binaryPath, 0o755);
96
65
  console.log(`getnote installed at ${binaryPath}`);
66
+ } catch (err) {
67
+ console.error('Failed to install getnote:', err.message);
68
+ process.exit(1);
97
69
  } finally {
98
70
  try { fs.unlinkSync(tmpFile); } catch (_) {}
99
71
  }
100
72
  }
101
73
 
102
- main().catch((err) => {
103
- console.error('Failed to install getnote:', err.message);
104
- process.exit(1);
105
- });
74
+ main();