artdam-cli 0.4.2__tar.gz → 0.5.0__tar.gz
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.
- {artdam_cli-0.4.2/artdam_cli.egg-info → artdam_cli-0.5.0}/PKG-INFO +31 -7
- artdam_cli-0.4.2/PKG-INFO → artdam_cli-0.5.0/README.md +258 -246
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/client.py +15 -8
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/engine.py +2 -2
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/get.py +4 -2
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/login.py +74 -13
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/update.py +12 -4
- artdam_cli-0.5.0/artdam_cli/config.py +143 -0
- artdam_cli-0.4.2/README.md → artdam_cli-0.5.0/artdam_cli.egg-info/PKG-INFO +270 -234
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli.egg-info/SOURCES.txt +1 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/pyproject.toml +1 -1
- artdam_cli-0.5.0/tests/test_login.py +279 -0
- artdam_cli-0.4.2/artdam_cli/config.py +0 -39
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/__init__.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/__init__.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/comment.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/delete_cmd.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/download.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/favorite.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/folder_cmd.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/folders.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/project.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/projects.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/rate.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/restore.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/search.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/tag_cmd.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/tags.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/commands/upload.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/main.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/update_check.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli/uploader.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli.egg-info/dependency_links.txt +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli.egg-info/entry_points.txt +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli.egg-info/requires.txt +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/artdam_cli.egg-info/top_level.txt +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/setup.cfg +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/tests/test_search_pagination.py +0 -0
- {artdam_cli-0.4.2 → artdam_cli-0.5.0}/tests/test_uploader.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: artdam-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: ArtDAM 数字资产管理平台命令行工具
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -32,6 +32,9 @@ uv tool install artdam-cli@latest
|
|
|
32
32
|
# 登录(首次使用,浏览器 SSO 授权)
|
|
33
33
|
artdam login
|
|
34
34
|
|
|
35
|
+
# 个人 API Key 登录(隐藏输入,适合本机长期使用)
|
|
36
|
+
artdam login --api-key
|
|
37
|
+
|
|
35
38
|
# 搜索资产
|
|
36
39
|
artdam search "关键词" --project 1
|
|
37
40
|
|
|
@@ -48,12 +51,29 @@ artdam download 123 --out ./downloads
|
|
|
48
51
|
|
|
49
52
|
#### `artdam login`
|
|
50
53
|
|
|
51
|
-
登录 ArtDAM
|
|
54
|
+
登录 ArtDAM。默认使用浏览器 SSO,也可使用个人 API Key 或账号密码。
|
|
52
55
|
|
|
53
56
|
```bash
|
|
54
|
-
artdam login
|
|
57
|
+
artdam login # 浏览器 SSO
|
|
58
|
+
artdam login --api-key # 隐藏输入个人 ab_ API Key
|
|
59
|
+
artdam login --password # 账号密码(仅 admin / 服务账号)
|
|
55
60
|
```
|
|
56
61
|
|
|
62
|
+
`--api-key` 会通过只读的 `GET /api/auth/me` 验证密钥,再保存到
|
|
63
|
+
`~/.artdam/config.json`(Linux/macOS 为 `0600`,Windows 收紧为仅当前用户 ACL)。
|
|
64
|
+
命令行参数和输出都不会显示密钥。
|
|
65
|
+
|
|
66
|
+
无人值守脚本和 Agent 可直接使用环境变量,无需执行登录,也不会把密钥写入配置文件:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
export ARTDAM_API_KEY='ab_...'
|
|
70
|
+
export ARTDAM_BASE_URL='https://artdam.xindong.com' # 可选
|
|
71
|
+
artdam search "头盔" --project 1 --json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
个人 API Key 代表创建它的用户,最终能力始终是**用户在项目中的角色权限 ∩ Key 的权限范围
|
|
75
|
+
(scope)**。例如 viewer 用户即使 Key 含 `write` 也不能上传;只有 `read` 的 Key 不能执行写操作。
|
|
76
|
+
|
|
57
77
|
#### `artdam search`
|
|
58
78
|
|
|
59
79
|
搜索资产,返回匹配列表。默认只取首页(`--limit` 条);加 `--all` 自动翻页取全部结果
|
|
@@ -209,8 +229,8 @@ artdam folders --project 1 --json
|
|
|
209
229
|
### 典型 Agent 工作流
|
|
210
230
|
|
|
211
231
|
```bash
|
|
212
|
-
# 1.
|
|
213
|
-
|
|
232
|
+
# 1. 登录(本机可用 SSO;无人值守 Agent 推荐 ARTDAM_API_KEY)
|
|
233
|
+
export ARTDAM_API_KEY='ab_...'
|
|
214
234
|
|
|
215
235
|
# 2. 搜索 → 确认 → 下载
|
|
216
236
|
artdam search "头盔" --project 1 --json
|
|
@@ -231,7 +251,9 @@ artdam update <asset_id> --description "AI 生成的场景描述"
|
|
|
231
251
|
|
|
232
252
|
- `--project` 参数为**数字 ID**,不是项目名称
|
|
233
253
|
- `--json` 返回原始 JSON,适合程序解析
|
|
234
|
-
-
|
|
254
|
+
- SSO/JWT 或手动输入的 API Key 保存在 `~/.artdam/config.json`,仅当前用户可读写
|
|
255
|
+
- `ARTDAM_API_KEY` 优先于配置文件中的登录凭据,且不会被写入配置或输出
|
|
256
|
+
- API Key 能力受用户项目角色和 Key scope 双重限制
|
|
235
257
|
- `artdam delete` 是软删除,可用 `artdam restore` 恢复
|
|
236
258
|
|
|
237
259
|
## 配置文件
|
|
@@ -241,6 +263,8 @@ artdam update <asset_id> --description "AI 生成的场景描述"
|
|
|
241
263
|
```json
|
|
242
264
|
{
|
|
243
265
|
"base_url": "https://artdam.xindong.com",
|
|
244
|
-
"
|
|
266
|
+
"api_key": "ab_..."
|
|
245
267
|
}
|
|
246
268
|
```
|
|
269
|
+
|
|
270
|
+
SSO 或密码登录时凭据字段为 `"token": "eyJ..."`。请勿提交此配置文件或在日志中打印其内容。
|
|
@@ -1,246 +1,258 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
#
|
|
33
|
-
artdam
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
artdam search
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
artdam
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
artdam
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
artdam
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
artdam upload
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
artdam
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
artdam
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
#### `artdam
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
```bash
|
|
157
|
-
artdam
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
artdam
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
artdam
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
artdam
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
#
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
artdam
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
1
|
+
# artdam-cli
|
|
2
|
+
|
|
3
|
+
ArtDAM 数字资产管理平台命令行工具,支持所有主流 AI Agent工具接入
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv tool install artdam-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 更新
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
uv tool install artdam-cli@latest
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 快速开始
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# 登录(首次使用,浏览器 SSO 授权)
|
|
21
|
+
artdam login
|
|
22
|
+
|
|
23
|
+
# 个人 API Key 登录(隐藏输入,适合本机长期使用)
|
|
24
|
+
artdam login --api-key
|
|
25
|
+
|
|
26
|
+
# 搜索资产
|
|
27
|
+
artdam search "关键词" --project 1
|
|
28
|
+
|
|
29
|
+
# 查看资产详情
|
|
30
|
+
artdam get 123
|
|
31
|
+
|
|
32
|
+
# 下载资产
|
|
33
|
+
artdam download 123 --out ./downloads
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 命令说明
|
|
37
|
+
|
|
38
|
+
### 查询命令(viewer 及以上)
|
|
39
|
+
|
|
40
|
+
#### `artdam login`
|
|
41
|
+
|
|
42
|
+
登录 ArtDAM。默认使用浏览器 SSO,也可使用个人 API Key 或账号密码。
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
artdam login # 浏览器 SSO
|
|
46
|
+
artdam login --api-key # 隐藏输入个人 ab_ API Key
|
|
47
|
+
artdam login --password # 账号密码(仅 admin / 服务账号)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`--api-key` 会通过只读的 `GET /api/auth/me` 验证密钥,再保存到
|
|
51
|
+
`~/.artdam/config.json`(Linux/macOS 为 `0600`,Windows 收紧为仅当前用户 ACL)。
|
|
52
|
+
命令行参数和输出都不会显示密钥。
|
|
53
|
+
|
|
54
|
+
无人值守脚本和 Agent 可直接使用环境变量,无需执行登录,也不会把密钥写入配置文件:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
export ARTDAM_API_KEY='ab_...'
|
|
58
|
+
export ARTDAM_BASE_URL='https://artdam.xindong.com' # 可选
|
|
59
|
+
artdam search "头盔" --project 1 --json
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
个人 API Key 代表创建它的用户,最终能力始终是**用户在项目中的角色权限 ∩ Key 的权限范围
|
|
63
|
+
(scope)**。例如 viewer 用户即使 Key 含 `write` 也不能上传;只有 `read` 的 Key 不能执行写操作。
|
|
64
|
+
|
|
65
|
+
#### `artdam search`
|
|
66
|
+
|
|
67
|
+
搜索资产,返回匹配列表。默认只取首页(`--limit` 条);加 `--all` 自动翻页取全部结果
|
|
68
|
+
(Agent 场景推荐,避免结果被截断)。`--all` 最多返回 1000 条,超出会提示用更精确的关键词或
|
|
69
|
+
`--ext` / `--folder` 收窄,避免在几万条资产上卡死。
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
artdam search "头盔" --project 1
|
|
73
|
+
artdam search "头盔" --project 1 --limit 50
|
|
74
|
+
artdam search "头盔" --project 1 --all # 自动翻页,取全部匹配
|
|
75
|
+
artdam search "头盔" --project 1 --all --json # 全量 JSON 输出(AI Agent 用)
|
|
76
|
+
artdam search "头盔" --project 1 --ext jpg # 按扩展名过滤
|
|
77
|
+
artdam search "头盔" --project 1 --ext jpg,png # 多个扩展名
|
|
78
|
+
artdam search "头盔" --project 1 --folder 10
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
| 参数 | 说明 |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `KEYWORD` | 搜索关键词 |
|
|
84
|
+
| `-p, --project` | 项目 ID(必填) |
|
|
85
|
+
| `-n, --limit` | 返回数量上限,默认 20(不与 `--all` 共用) |
|
|
86
|
+
| `--all` | 自动翻页取全部匹配结果(最多 1000 条) |
|
|
87
|
+
| `-e, --ext` | 按文件扩展名过滤,逗号分隔,如 `jpg,png` |
|
|
88
|
+
| `--folder` | 限定文件夹 ID |
|
|
89
|
+
| `--json` | 输出原始 JSON |
|
|
90
|
+
|
|
91
|
+
#### `artdam get`
|
|
92
|
+
|
|
93
|
+
查看单个资产详情(含预览链接)。
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
artdam get 123
|
|
97
|
+
artdam get 123 --json # 输出原始 JSON(AI Agent 用)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### `artdam download`
|
|
101
|
+
|
|
102
|
+
下载资产文件到本地。
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
artdam download 123
|
|
106
|
+
artdam download 123 --out ./downloads
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### `artdam tags`
|
|
110
|
+
|
|
111
|
+
列出项目标签。
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
artdam tags --project 1
|
|
115
|
+
artdam tags --project 1 --search "角色"
|
|
116
|
+
artdam tags --project 1 --json
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### `artdam folders`
|
|
120
|
+
|
|
121
|
+
查看文件夹结构。
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
artdam folders --project 1
|
|
125
|
+
artdam folders --project 1 --json
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 资产管理(member 及以上)
|
|
129
|
+
|
|
130
|
+
#### `artdam upload`
|
|
131
|
+
|
|
132
|
+
上传文件到指定项目和文件夹。采用分块上传,支持大文件(最大 10GB),带进度条;
|
|
133
|
+
上传前按内容计算 SHA-256,库中已有相同文件则**秒传**(直接复用,不重复传输)。
|
|
134
|
+
单个分块遇到网络抖动(超时 / 5xx)会自动重试,中断时清理服务端会话。
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
artdam upload ./image.jpg --project 1
|
|
138
|
+
artdam upload ./image.jpg --project 1 --folder 10
|
|
139
|
+
artdam upload ./big_scene.zip --project 1 # 大文件分块 + 进度条
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### `artdam update`
|
|
143
|
+
|
|
144
|
+
更新资产信息(可同时传多个选项)。
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
artdam update 123 --name "新文件名"
|
|
148
|
+
artdam update 123 --description "新描述"
|
|
149
|
+
artdam update 123 --folder 10
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### `artdam delete`
|
|
153
|
+
|
|
154
|
+
软删除资产(可通过 `restore` 恢复)。
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
artdam delete 123
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### `artdam restore`
|
|
161
|
+
|
|
162
|
+
恢复已删除的资产。
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
artdam restore 123
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 标签管理(member 及以上)
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# 给资产添加标签
|
|
172
|
+
artdam tag add 123 5
|
|
173
|
+
|
|
174
|
+
# 从资产移除标签
|
|
175
|
+
artdam tag remove 123 5
|
|
176
|
+
|
|
177
|
+
# 创建新标签
|
|
178
|
+
artdam tag create "标签名" --project 1
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 文件夹管理(member 及以上)
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# 创建文件夹
|
|
185
|
+
artdam folder create "文件夹名" --project 1
|
|
186
|
+
artdam folder create "子文件夹" --project 1 --parent 10
|
|
187
|
+
|
|
188
|
+
# 删除文件夹
|
|
189
|
+
artdam folder delete 10
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 互动操作(member 及以上)
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# 评论
|
|
196
|
+
artdam comment 123 "评论内容"
|
|
197
|
+
|
|
198
|
+
# 评分(1-5 星)
|
|
199
|
+
artdam rate 123 4
|
|
200
|
+
|
|
201
|
+
# 收藏 / 取消收藏
|
|
202
|
+
artdam favorite 123
|
|
203
|
+
artdam favorite 123 --remove
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## AI Agent 使用指南
|
|
207
|
+
|
|
208
|
+
所有查询命令支持 `--json` 输出原始 JSON,适合 Agent 解析:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
artdam search "安妮" --project 1 --json
|
|
212
|
+
artdam get 123 --json
|
|
213
|
+
artdam tags --project 1 --json
|
|
214
|
+
artdam folders --project 1 --json
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### 典型 Agent 工作流
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# 1. 登录(本机可用 SSO;无人值守 Agent 推荐 ARTDAM_API_KEY)
|
|
221
|
+
export ARTDAM_API_KEY='ab_...'
|
|
222
|
+
|
|
223
|
+
# 2. 搜索 → 确认 → 下载
|
|
224
|
+
artdam search "头盔" --project 1 --json
|
|
225
|
+
artdam get 50707 --json
|
|
226
|
+
artdam download 50707 --out ./assets
|
|
227
|
+
|
|
228
|
+
# 3. 搜索 → 批量打标签
|
|
229
|
+
artdam search "安妮" --project 1 --json
|
|
230
|
+
artdam tag add 50707 5
|
|
231
|
+
artdam tag add 50708 5
|
|
232
|
+
|
|
233
|
+
# 4. 上传并更新描述
|
|
234
|
+
artdam upload ./new_asset.jpg --project 1 --folder 10
|
|
235
|
+
artdam update <asset_id> --description "AI 生成的场景描述"
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## 注意事项
|
|
239
|
+
|
|
240
|
+
- `--project` 参数为**数字 ID**,不是项目名称
|
|
241
|
+
- `--json` 返回原始 JSON,适合程序解析
|
|
242
|
+
- SSO/JWT 或手动输入的 API Key 保存在 `~/.artdam/config.json`,仅当前用户可读写
|
|
243
|
+
- `ARTDAM_API_KEY` 优先于配置文件中的登录凭据,且不会被写入配置或输出
|
|
244
|
+
- API Key 能力受用户项目角色和 Key scope 双重限制
|
|
245
|
+
- `artdam delete` 是软删除,可用 `artdam restore` 恢复
|
|
246
|
+
|
|
247
|
+
## 配置文件
|
|
248
|
+
|
|
249
|
+
登录信息保存在 `~/.artdam/config.json`:
|
|
250
|
+
|
|
251
|
+
```json
|
|
252
|
+
{
|
|
253
|
+
"base_url": "https://artdam.xindong.com",
|
|
254
|
+
"api_key": "ab_..."
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
SSO 或密码登录时凭据字段为 `"token": "eyJ..."`。请勿提交此配置文件或在日志中打印其内容。
|
|
@@ -12,11 +12,11 @@ _RETRY_BACKOFF = (1, 2, 4)
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def _make_client(timeout: float = 30) -> httpx.Client:
|
|
15
|
-
base_url = config.
|
|
16
|
-
|
|
15
|
+
base_url = config.get_base_url()
|
|
16
|
+
credential = config.get_auth_credential()
|
|
17
17
|
return httpx.Client(
|
|
18
18
|
base_url=base_url,
|
|
19
|
-
headers={"Authorization": f"Bearer {
|
|
19
|
+
headers={"Authorization": f"Bearer {credential}"},
|
|
20
20
|
timeout=timeout,
|
|
21
21
|
)
|
|
22
22
|
|
|
@@ -39,7 +39,9 @@ def _send_with_retry(do_request: Callable[[], httpx.Response]) -> httpx.Response
|
|
|
39
39
|
return r
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
def get(
|
|
42
|
+
def get(
|
|
43
|
+
path: str, params: dict | None = None, not_found_msg: str = "资源不存在"
|
|
44
|
+
) -> dict:
|
|
43
45
|
with _make_client() as c:
|
|
44
46
|
r = c.get(path, params=params)
|
|
45
47
|
_raise(r, not_found_msg=not_found_msg)
|
|
@@ -47,12 +49,12 @@ def get(path: str, params: dict | None = None, not_found_msg: str = "资源不
|
|
|
47
49
|
|
|
48
50
|
|
|
49
51
|
def download_file(path: str, dest: str, not_found_msg: str = "资源不存在") -> int:
|
|
50
|
-
base_url = config.
|
|
51
|
-
|
|
52
|
+
base_url = config.get_base_url()
|
|
53
|
+
credential = config.get_auth_credential()
|
|
52
54
|
with httpx.stream(
|
|
53
55
|
"GET",
|
|
54
56
|
f"{base_url}{path}",
|
|
55
|
-
headers={"Authorization": f"Bearer {
|
|
57
|
+
headers={"Authorization": f"Bearer {credential}"},
|
|
56
58
|
timeout=120,
|
|
57
59
|
follow_redirects=True,
|
|
58
60
|
) as r:
|
|
@@ -165,7 +167,12 @@ def cancel_upload(upload_id: str) -> None:
|
|
|
165
167
|
|
|
166
168
|
def _raise(r: httpx.Response, not_found_msg: str = "资源不存在") -> None:
|
|
167
169
|
if r.status_code == 401:
|
|
168
|
-
raise SystemExit("
|
|
170
|
+
raise SystemExit("登录凭据无效或已过期,请重新运行 artdam login")
|
|
171
|
+
if r.status_code == 403:
|
|
172
|
+
raise SystemExit(
|
|
173
|
+
"权限不足:请检查当前用户的项目角色;"
|
|
174
|
+
"使用个人 API Key 时还需检查密钥的权限范围"
|
|
175
|
+
)
|
|
169
176
|
if r.status_code == 404:
|
|
170
177
|
raise SystemExit(not_found_msg)
|
|
171
178
|
if r.is_error:
|
|
@@ -113,7 +113,7 @@ def _stop_running_agent() -> None:
|
|
|
113
113
|
|
|
114
114
|
def _write_autostart(install_dir: Path, venv_py: Path, webserver: Path) -> Path:
|
|
115
115
|
"""写 run-agent.ps1 + 开机自启 .vbs(启动文件夹,免管理员),返回 .vbs 路径。"""
|
|
116
|
-
base_url = config.
|
|
116
|
+
base_url = config.get_base_url()
|
|
117
117
|
run_script = install_dir / "run-agent.ps1"
|
|
118
118
|
lines = [
|
|
119
119
|
f'$env:ARTDAM_AGENT_WEBSERVER_EXE = "{webserver}"',
|
|
@@ -273,7 +273,7 @@ def install(project: str) -> None:
|
|
|
273
273
|
f"暂不支持的项目代号:{project}。"
|
|
274
274
|
f"目前支持:{', '.join(sorted(_SUPPORTED_PROJECTS))}。"
|
|
275
275
|
)
|
|
276
|
-
base_url = config.
|
|
276
|
+
base_url = config.get_base_url()
|
|
277
277
|
install_dir = _install_dir()
|
|
278
278
|
uv = _find_uv()
|
|
279
279
|
console.print(f"[cyan]→[/cyan] 安装目录:{install_dir}")
|