cubox-cli 1.0.0
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 +21 -0
- package/README.md +280 -0
- package/README.zh.md +288 -0
- package/package.json +32 -0
- package/scripts/install.js +92 -0
- package/scripts/run.js +12 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cubox
|
|
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,280 @@
|
|
|
1
|
+
# cubox-cli
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://go.dev/)
|
|
5
|
+
[](https://www.npmjs.com/package/cubox-cli)
|
|
6
|
+
|
|
7
|
+
[English](./README.md) | [中文版](./README.zh.md)
|
|
8
|
+
|
|
9
|
+
The official [Cubox](https://cubox.pro) CLI tool — built for humans and AI Agents. Manage your bookmarks, browse collections, and read saved content from the terminal.
|
|
10
|
+
|
|
11
|
+
[Install](#installation) · [Auth](#authentication) · [Commands](#commands) · [AI Agent](#quick-start-ai-agent) · [Examples](#examples) · [Development](#development)
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
| Category | Capabilities |
|
|
16
|
+
|----------|-------------|
|
|
17
|
+
| Groups | List and browse bookmark folders |
|
|
18
|
+
| Tags | List and browse tag hierarchy |
|
|
19
|
+
| Cards | Filter cards by group, type, tag, starred/read/annotated status; cursor-based pagination |
|
|
20
|
+
| Content | Read full article content in markdown format |
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
### Requirements
|
|
25
|
+
|
|
26
|
+
- Node.js 16+ (for `npm`/`npx`)
|
|
27
|
+
- Go 1.23+ (only for building from source)
|
|
28
|
+
|
|
29
|
+
### Quick Start (Human Users)
|
|
30
|
+
|
|
31
|
+
> **For AI Agents:** jump to [Quick Start (AI Agent)](#quick-start-ai-agent) below.
|
|
32
|
+
|
|
33
|
+
#### Install
|
|
34
|
+
|
|
35
|
+
**Option 1 — From npm (recommended):**
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Install CLI
|
|
39
|
+
npm install -g cubox-cli
|
|
40
|
+
|
|
41
|
+
# Install CLI Skill (required for AI Agents)
|
|
42
|
+
npx skills add OLCUBO/cubox-cli -g -y
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Option 2 — From source:**
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/OLCUBO/cubox-cli.git
|
|
49
|
+
cd cubox-cli
|
|
50
|
+
make install
|
|
51
|
+
|
|
52
|
+
# Install CLI Skill (required for AI Agents)
|
|
53
|
+
npx skills add OLCUBO/cubox-cli -g -y
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### Log in
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
cubox-cli auth login
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The CLI will guide you through:
|
|
63
|
+
|
|
64
|
+
1. **Select your server** — `cubox.pro` (China) or `cubox.cc` (international)
|
|
65
|
+
2. **Get your API key** — the CLI shows the URL to open:
|
|
66
|
+
- China: https://cubox.pro/web/settings/extensions
|
|
67
|
+
- International: https://cubox.cc/web/settings/extensions
|
|
68
|
+
3. **Paste the API link** — copy the full link (e.g. `https://cubox.pro/c/api/save/abcdefg`) and paste it. The CLI extracts the token automatically.
|
|
69
|
+
|
|
70
|
+
#### Start using
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# List your folders
|
|
74
|
+
cubox-cli group list
|
|
75
|
+
|
|
76
|
+
# List your tags
|
|
77
|
+
cubox-cli tag list
|
|
78
|
+
|
|
79
|
+
# Browse recent cards
|
|
80
|
+
cubox-cli card list --limit 5 -o pretty
|
|
81
|
+
|
|
82
|
+
# Read an article
|
|
83
|
+
cubox-cli card content --id CARD_ID
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Quick Start (AI Agent)
|
|
87
|
+
|
|
88
|
+
> These steps are for AI Agents helping users set up cubox-cli.
|
|
89
|
+
|
|
90
|
+
**Step 1 — Install**
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Install CLI
|
|
94
|
+
npm install -g cubox-cli
|
|
95
|
+
|
|
96
|
+
# Install CLI Skill (required)
|
|
97
|
+
npx skills add OLCUBO/cubox-cli -g -y
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Step 2 — Authenticate**
|
|
101
|
+
|
|
102
|
+
Ask the user which server they use (`cubox.pro` or `cubox.cc`), then instruct them to open the extensions settings page and copy their API link:
|
|
103
|
+
|
|
104
|
+
- China: `https://cubox.pro/web/settings/extensions`
|
|
105
|
+
- International: `https://cubox.cc/web/settings/extensions`
|
|
106
|
+
|
|
107
|
+
Once the user provides the API link or token, run:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
cubox-cli auth login --server cubox.pro --token TOKEN
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The `--token` flag accepts either the full API link URL or just the token string.
|
|
114
|
+
|
|
115
|
+
**Step 3 — Verify**
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
cubox-cli auth status
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Step 4 — Use**
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
cubox-cli group list
|
|
125
|
+
cubox-cli card list --limit 10
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Authentication
|
|
129
|
+
|
|
130
|
+
| Command | Description |
|
|
131
|
+
|---------|-------------|
|
|
132
|
+
| `cubox-cli auth login` | Interactive login (server selection + token input) |
|
|
133
|
+
| `cubox-cli auth login --server cubox.pro --token TOKEN` | Non-interactive login (for agents) |
|
|
134
|
+
| `cubox-cli auth status` | Show current server, masked token, connection test |
|
|
135
|
+
| `cubox-cli auth logout` | Remove saved credentials |
|
|
136
|
+
|
|
137
|
+
Credentials are stored at `~/.config/cubox-cli/config.json`.
|
|
138
|
+
|
|
139
|
+
## Commands
|
|
140
|
+
|
|
141
|
+
### Output Formats
|
|
142
|
+
|
|
143
|
+
All commands support the `-o` / `--output` flag:
|
|
144
|
+
|
|
145
|
+
| Flag | Description |
|
|
146
|
+
|------|-------------|
|
|
147
|
+
| `-o json` | Compact JSON (default, agent-friendly) |
|
|
148
|
+
| `-o pretty` | Indented JSON |
|
|
149
|
+
| `-o text` | Human-readable text/tree output |
|
|
150
|
+
|
|
151
|
+
### `cubox-cli group list`
|
|
152
|
+
|
|
153
|
+
List all bookmark groups (folders).
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
cubox-cli group list
|
|
157
|
+
cubox-cli group list -o text
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**JSON output fields:** `id`, `nested_name`, `name`, `parent_id`, `uncategorized`
|
|
161
|
+
|
|
162
|
+
### `cubox-cli tag list`
|
|
163
|
+
|
|
164
|
+
List all tags.
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
cubox-cli tag list
|
|
168
|
+
cubox-cli tag list -o text
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**JSON output fields:** `id`, `nested_name`, `name`, `parent_id`
|
|
172
|
+
|
|
173
|
+
### `cubox-cli card list`
|
|
174
|
+
|
|
175
|
+
Filter and list bookmark cards.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
cubox-cli card list [flags]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
| Flag | Description |
|
|
182
|
+
|------|-------------|
|
|
183
|
+
| `--group ID,...` | Filter by group/folder IDs |
|
|
184
|
+
| `--type TYPE,...` | Filter by type: `Article`, `Snippet`, `Memo`, `Image`, `Audio`, `Video`, `File` |
|
|
185
|
+
| `--tag ID,...` | Filter by tag IDs |
|
|
186
|
+
| `--starred` | Only starred cards |
|
|
187
|
+
| `--read` | Only read cards |
|
|
188
|
+
| `--unread` | Only unread cards |
|
|
189
|
+
| `--annotated` | Only cards with highlights |
|
|
190
|
+
| `--limit N` | Page size (default 50) |
|
|
191
|
+
| `--cursor ID,TIME` | Resume from last card for pagination |
|
|
192
|
+
| `--all` | Auto-paginate to fetch all results |
|
|
193
|
+
|
|
194
|
+
**JSON output fields:** `id`, `title`, `description`, `article_title`, `domain`, `type`, `tags`, `url`, `cubox_url`, `words_count`, `create_time`, `update_time`, `highlights`
|
|
195
|
+
|
|
196
|
+
### `cubox-cli card content --id ID`
|
|
197
|
+
|
|
198
|
+
Get the full article content in markdown format.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
cubox-cli card content --id 7247925101516031380
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
By default outputs raw markdown. Use `-o pretty` for a JSON envelope.
|
|
205
|
+
|
|
206
|
+
## Examples
|
|
207
|
+
|
|
208
|
+
### List all starred articles
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
cubox-cli card list --starred --type Article -o pretty
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Browse cards in a specific folder
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# Find the folder ID
|
|
218
|
+
cubox-cli group list -o text
|
|
219
|
+
|
|
220
|
+
# List cards in that folder
|
|
221
|
+
cubox-cli card list --group 7230156249357091393 --limit 10
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Read a saved article
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
cubox-cli card content --id 7247925101516031380
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Fetch all annotated cards with highlights
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
cubox-cli card list --annotated --all -o pretty
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Pagination
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# First page
|
|
240
|
+
cubox-cli card list --limit 5
|
|
241
|
+
|
|
242
|
+
# Use the last card's ID and update_time for the next page
|
|
243
|
+
cubox-cli card list --limit 5 --cursor "7247925102807877551,2024-12-04T16:23:01:347+08:00"
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Development
|
|
247
|
+
|
|
248
|
+
### Build from source
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
git clone https://github.com/OLCUBO/cubox-cli.git
|
|
252
|
+
cd cubox-cli
|
|
253
|
+
make build # build for current platform
|
|
254
|
+
make build-all # cross-compile for all platforms
|
|
255
|
+
make release # create release archives
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Project structure
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
cubox-cli/
|
|
262
|
+
main.go # entry point
|
|
263
|
+
cmd/ # cobra commands
|
|
264
|
+
root.go # root command, --output flag
|
|
265
|
+
auth.go # auth login/status/logout
|
|
266
|
+
group.go # group list
|
|
267
|
+
tag.go # tag list
|
|
268
|
+
card.go # card list, card content
|
|
269
|
+
version.go # version
|
|
270
|
+
internal/
|
|
271
|
+
client/ # HTTP client + API types
|
|
272
|
+
config/ # config file management
|
|
273
|
+
scripts/ # npm distribution wrapper
|
|
274
|
+
skills/cubox/ # AI Agent skill
|
|
275
|
+
.github/workflows/ # CI/CD
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## License
|
|
279
|
+
|
|
280
|
+
[MIT](LICENSE)
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# cubox-cli
|
|
2
|
+
|
|
3
|
+
[License: MIT](https://opensource.org/licenses/MIT)
|
|
4
|
+
[Go Version](https://go.dev/)
|
|
5
|
+
[npm version](https://www.npmjs.com/package/cubox-cli)
|
|
6
|
+
|
|
7
|
+
[English](./README.md) | [中文版](./README.zh.md)
|
|
8
|
+
|
|
9
|
+
[Cubox](https://cubox.pro) 官方命令行工具 — 为人类用户和 AI Agent 而设计。在终端中管理书签、浏览收藏夹、阅读保存的内容。
|
|
10
|
+
|
|
11
|
+
[安装](#安装) · [认证](#认证) · [命令](#命令) · [AI Agent](#ai-agent-快速开始) · [示例](#示例) · [开发](#开发)
|
|
12
|
+
|
|
13
|
+
## 功能
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
| 类别 | 能力 |
|
|
17
|
+
| --- | ------------------------------ |
|
|
18
|
+
| 收藏夹 | 列出和浏览书签文件夹 |
|
|
19
|
+
| 标签 | 列出和浏览标签层级 |
|
|
20
|
+
| 卡片 | 按收藏夹、类型、标签、星标/已读/标注状态过滤卡片;游标分页 |
|
|
21
|
+
| 内容 | 以 Markdown 格式阅读文章全文 |
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## 安装
|
|
25
|
+
|
|
26
|
+
### 前置要求
|
|
27
|
+
|
|
28
|
+
- Node.js 16+(用于 `npm`/`npx`)
|
|
29
|
+
- Go 1.23+(仅从源码构建时需要)
|
|
30
|
+
|
|
31
|
+
### 快速开始(人类用户)
|
|
32
|
+
|
|
33
|
+
> **AI Agent 请跳转:** [AI Agent 快速开始](#ai-agent-快速开始)
|
|
34
|
+
|
|
35
|
+
#### 安装
|
|
36
|
+
|
|
37
|
+
**方式一 — 通过 npm(推荐):**
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# 安装 CLI
|
|
41
|
+
npm install -g cubox-cli
|
|
42
|
+
|
|
43
|
+
# 安装 CLI Skill(AI Agent 必需)
|
|
44
|
+
npx skills add OLCUBO/cubox-cli -g -y
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**方式二 — 从源码构建:**
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
git clone https://github.com/OLCUBO/cubox-cli.git
|
|
51
|
+
cd cubox-cli
|
|
52
|
+
make install
|
|
53
|
+
|
|
54
|
+
# 安装 CLI Skill(AI Agent 必需)
|
|
55
|
+
npx skills add OLCUBO/cubox-cli -g -y
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### 登录
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
cubox-cli auth login
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
CLI 会引导你完成以下步骤:
|
|
65
|
+
|
|
66
|
+
1. **选择服务器** — `cubox.pro`(中国)或 `cubox.cc`(国际版)
|
|
67
|
+
2. **获取 API Key** — CLI 会提示打开对应网址:
|
|
68
|
+
- 中国版:[https://cubox.pro/web/settings/extensions](https://cubox.pro/web/settings/extensions)
|
|
69
|
+
- 国际版:[https://cubox.cc/web/settings/extensions](https://cubox.cc/web/settings/extensions)
|
|
70
|
+
3. **粘贴 API 链接** — 复制完整链接(如 `https://cubox.pro/c/api/save/abcdefg`)并粘贴。CLI 会自动提取 token。
|
|
71
|
+
|
|
72
|
+
#### 开始使用
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# 列出收藏夹
|
|
76
|
+
cubox-cli group list
|
|
77
|
+
|
|
78
|
+
# 列出标签
|
|
79
|
+
cubox-cli tag list
|
|
80
|
+
|
|
81
|
+
# 浏览最近的卡片
|
|
82
|
+
cubox-cli card list --limit 5 -o pretty
|
|
83
|
+
|
|
84
|
+
# 阅读一篇文章
|
|
85
|
+
cubox-cli card content --id CARD_ID
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### AI Agent 快速开始
|
|
89
|
+
|
|
90
|
+
> 以下步骤适用于 AI Agent 帮助用户设置 cubox-cli。
|
|
91
|
+
|
|
92
|
+
**步骤 1 — 安装**
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# 安装 CLI
|
|
96
|
+
npm install -g cubox-cli
|
|
97
|
+
|
|
98
|
+
# 安装 CLI Skill(必需)
|
|
99
|
+
npx skills add OLCUBO/cubox-cli -g -y
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**步骤 2 — 认证**
|
|
103
|
+
|
|
104
|
+
询问用户使用哪个服务器(`cubox.pro` 或 `cubox.cc`),然后引导用户打开扩展设置页面并复制 API 链接:
|
|
105
|
+
|
|
106
|
+
- 中国版:`https://cubox.pro/web/settings/extensions`
|
|
107
|
+
- 国际版:`https://cubox.cc/web/settings/extensions`
|
|
108
|
+
|
|
109
|
+
用户提供 API 链接或 token 后执行:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
cubox-cli auth login --server cubox.pro --token TOKEN
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`--token` 参数接受完整的 API 链接 URL 或纯 token 字符串。
|
|
116
|
+
|
|
117
|
+
**步骤 3 — 验证**
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
cubox-cli auth status
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**步骤 4 — 使用**
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
cubox-cli group list
|
|
127
|
+
cubox-cli card list --limit 10
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## 认证
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
| 命令 | 说明 |
|
|
134
|
+
| ------------------------------------------------------- | ----------------------- |
|
|
135
|
+
| `cubox-cli auth login` | 交互式登录(选择服务器 + 输入 token) |
|
|
136
|
+
| `cubox-cli auth login --server cubox.pro --token TOKEN` | 非交互式登录(适用于 Agent) |
|
|
137
|
+
| `cubox-cli auth status` | 显示当前服务器、脱敏 token、连接测试 |
|
|
138
|
+
| `cubox-cli auth logout` | 删除已保存的凭证 |
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
凭证保存在 `~/.config/cubox-cli/config.json`。
|
|
142
|
+
|
|
143
|
+
## 命令
|
|
144
|
+
|
|
145
|
+
### 输出格式
|
|
146
|
+
|
|
147
|
+
所有命令支持 `-o` / `--output` 参数:
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
| 参数 | 说明 |
|
|
151
|
+
| ----------- | -------------------- |
|
|
152
|
+
| `-o json` | 紧凑 JSON(默认,适合 Agent) |
|
|
153
|
+
| `-o pretty` | 格式化 JSON |
|
|
154
|
+
| `-o text` | 人类可读的文本/树形输出 |
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
### `cubox-cli group list`
|
|
158
|
+
|
|
159
|
+
列出所有收藏夹(文件夹)。
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
cubox-cli group list
|
|
163
|
+
cubox-cli group list -o text
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**JSON 输出字段:** `id`, `nested_name`, `name`, `parent_id`, `uncategorized`
|
|
167
|
+
|
|
168
|
+
### `cubox-cli tag list`
|
|
169
|
+
|
|
170
|
+
列出所有标签。
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
cubox-cli tag list
|
|
174
|
+
cubox-cli tag list -o text
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**JSON 输出字段:** `id`, `nested_name`, `name`, `parent_id`
|
|
178
|
+
|
|
179
|
+
### `cubox-cli card list`
|
|
180
|
+
|
|
181
|
+
过滤和列出收藏卡片。
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
cubox-cli card list [flags]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
| 参数 | 说明 |
|
|
189
|
+
| ------------------ | --------------------------------------------------------------------- |
|
|
190
|
+
| `--group ID,...` | 按收藏夹 ID 过滤 |
|
|
191
|
+
| `--type TYPE,...` | 按类型过滤:`Article`, `Snippet`, `Memo`, `Image`, `Audio`, `Video`, `File` |
|
|
192
|
+
| `--tag ID,...` | 按标签 ID 过滤 |
|
|
193
|
+
| `--starred` | 仅星标卡片 |
|
|
194
|
+
| `--read` | 仅已读卡片 |
|
|
195
|
+
| `--unread` | 仅未读卡片 |
|
|
196
|
+
| `--annotated` | 仅有标注的卡片 |
|
|
197
|
+
| `--limit N` | 每页数量(默认 50) |
|
|
198
|
+
| `--cursor ID,TIME` | 分页游标,从上一张卡片继续 |
|
|
199
|
+
| `--all` | 自动翻页获取全部结果 |
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
**JSON 输出字段:** `id`, `title`, `description`, `article_title`, `domain`, `type`, `tags`, `url`, `cubox_url`, `words_count`, `create_time`, `update_time`, `highlights`
|
|
203
|
+
|
|
204
|
+
### `cubox-cli card content --id ID`
|
|
205
|
+
|
|
206
|
+
获取文章全文(Markdown 格式)。
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
cubox-cli card content --id 7247925101516031380
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
默认输出原始 Markdown。使用 `-o pretty` 获取 JSON 包装格式。
|
|
213
|
+
|
|
214
|
+
## 示例
|
|
215
|
+
|
|
216
|
+
### 列出所有星标文章
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
cubox-cli card list --starred --type Article -o pretty
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### 浏览特定收藏夹的卡片
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# 查找收藏夹 ID
|
|
226
|
+
cubox-cli group list -o text
|
|
227
|
+
|
|
228
|
+
# 列出该收藏夹的卡片
|
|
229
|
+
cubox-cli card list --group 7230156249357091393 --limit 10
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### 阅读保存的文章
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
cubox-cli card content --id 7247925101516031380
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### 获取所有带标注的卡片
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
cubox-cli card list --annotated --all -o pretty
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### 分页
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# 第一页
|
|
248
|
+
cubox-cli card list --limit 5
|
|
249
|
+
|
|
250
|
+
# 使用最后一张卡片的 ID 和 update_time 获取下一页
|
|
251
|
+
cubox-cli card list --limit 5 --cursor "7247925102807877551,2024-12-04T16:23:01:347+08:00"
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## 开发
|
|
255
|
+
|
|
256
|
+
### 从源码构建
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
git clone https://github.com/OLCUBO/cubox-cli.git
|
|
260
|
+
cd cubox-cli
|
|
261
|
+
make build # 为当前平台构建
|
|
262
|
+
make build-all # 交叉编译所有平台
|
|
263
|
+
make release # 创建发布包
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### 项目结构
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
cubox-cli/
|
|
270
|
+
main.go # 入口
|
|
271
|
+
cmd/ # cobra 命令
|
|
272
|
+
root.go # 根命令,--output 参数
|
|
273
|
+
auth.go # auth login/status/logout
|
|
274
|
+
group.go # group list
|
|
275
|
+
tag.go # tag list
|
|
276
|
+
card.go # card list, card content
|
|
277
|
+
version.go # version
|
|
278
|
+
internal/
|
|
279
|
+
client/ # HTTP 客户端 + API 类型
|
|
280
|
+
config/ # 配置文件管理
|
|
281
|
+
scripts/ # npm 分发包装
|
|
282
|
+
skills/cubox/ # AI Agent Skill
|
|
283
|
+
.github/workflows/ # CI/CD
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## 许可证
|
|
287
|
+
|
|
288
|
+
[MIT](LICENSE)
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cubox-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The official Cubox CLI tool, built for humans and AI Agents",
|
|
5
|
+
"bin": {
|
|
6
|
+
"cubox-cli": "scripts/run.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node scripts/install.js"
|
|
10
|
+
},
|
|
11
|
+
"os": [
|
|
12
|
+
"darwin",
|
|
13
|
+
"linux",
|
|
14
|
+
"win32"
|
|
15
|
+
],
|
|
16
|
+
"cpu": [
|
|
17
|
+
"x64",
|
|
18
|
+
"arm64"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=16"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/OLCUBO/cubox-cli.git"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"files": [
|
|
29
|
+
"scripts/install.js",
|
|
30
|
+
"scripts/run.js"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const { execSync } = require("child_process");
|
|
4
|
+
const os = require("os");
|
|
5
|
+
|
|
6
|
+
const VERSION = require("../package.json").version;
|
|
7
|
+
const REPO = "OLCUBO/cubox-cli";
|
|
8
|
+
const NAME = "cubox-cli";
|
|
9
|
+
|
|
10
|
+
const PLATFORM_MAP = {
|
|
11
|
+
darwin: "darwin",
|
|
12
|
+
linux: "linux",
|
|
13
|
+
win32: "windows",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const ARCH_MAP = {
|
|
17
|
+
x64: "amd64",
|
|
18
|
+
arm64: "arm64",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const platform = PLATFORM_MAP[process.platform];
|
|
22
|
+
const arch = ARCH_MAP[process.arch];
|
|
23
|
+
|
|
24
|
+
if (!platform || !arch) {
|
|
25
|
+
console.error(
|
|
26
|
+
`Unsupported platform: ${process.platform}-${process.arch}`
|
|
27
|
+
);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const isWindows = process.platform === "win32";
|
|
32
|
+
const ext = isWindows ? ".zip" : ".tar.gz";
|
|
33
|
+
const archiveName = `${NAME}-${VERSION}-${platform}-${arch}${ext}`;
|
|
34
|
+
const GITHUB_URL = `https://github.com/${REPO}/releases/download/v${VERSION}/${archiveName}`;
|
|
35
|
+
|
|
36
|
+
const binDir = path.join(__dirname, "..", "bin");
|
|
37
|
+
const dest = path.join(binDir, NAME + (isWindows ? ".exe" : ""));
|
|
38
|
+
|
|
39
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
40
|
+
|
|
41
|
+
function download(url, destPath) {
|
|
42
|
+
const sslFlag = isWindows ? "--ssl-revoke-best-effort " : "";
|
|
43
|
+
execSync(
|
|
44
|
+
`curl ${sslFlag}--fail --location --silent --show-error --connect-timeout 10 --max-time 120 --output "${destPath}" "${url}"`,
|
|
45
|
+
{ stdio: ["ignore", "ignore", "pipe"] }
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function install() {
|
|
50
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "cubox-cli-"));
|
|
51
|
+
const archivePath = path.join(tmpDir, archiveName);
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
download(GITHUB_URL, archivePath);
|
|
55
|
+
|
|
56
|
+
if (isWindows) {
|
|
57
|
+
execSync(
|
|
58
|
+
`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${tmpDir}'"`,
|
|
59
|
+
{ stdio: "ignore" }
|
|
60
|
+
);
|
|
61
|
+
} else {
|
|
62
|
+
execSync(`tar -xzf "${archivePath}" -C "${tmpDir}"`, {
|
|
63
|
+
stdio: "ignore",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const binaryName = NAME + (isWindows ? ".exe" : "");
|
|
68
|
+
const extractedBinary = path.join(tmpDir, binaryName);
|
|
69
|
+
|
|
70
|
+
fs.copyFileSync(extractedBinary, dest);
|
|
71
|
+
fs.chmodSync(dest, 0o755);
|
|
72
|
+
console.log(`${NAME} v${VERSION} installed successfully`);
|
|
73
|
+
} finally {
|
|
74
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
install();
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.error(`Failed to install ${NAME}:`, err.message);
|
|
82
|
+
console.error(
|
|
83
|
+
`\nYou can also build from source:\n` +
|
|
84
|
+
` git clone https://github.com/${REPO}.git\n` +
|
|
85
|
+
` cd cubox-cli\n` +
|
|
86
|
+
` make install\n` +
|
|
87
|
+
`\nIf behind a firewall, try setting a proxy:\n` +
|
|
88
|
+
` export https_proxy=http://your-proxy:port\n` +
|
|
89
|
+
` npm install -g cubox-cli`
|
|
90
|
+
);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
package/scripts/run.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execFileSync } = require("child_process");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
6
|
+
const bin = path.join(__dirname, "..", "bin", "cubox-cli" + ext);
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
execFileSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
10
|
+
} catch (e) {
|
|
11
|
+
process.exit(e.status || 1);
|
|
12
|
+
}
|