artdam-cli 0.6.0__tar.gz → 0.6.1__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.
Files changed (48) hide show
  1. {artdam_cli-0.6.0/artdam_cli.egg-info → artdam_cli-0.6.1}/PKG-INFO +12 -1
  2. artdam_cli-0.6.0/PKG-INFO → artdam_cli-0.6.1/README.md +278 -279
  3. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/client.py +10 -1
  4. artdam_cli-0.6.1/artdam_cli/commands/ai_model.py +18 -0
  5. artdam_cli-0.6.1/artdam_cli/commands/search.py +230 -0
  6. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/main.py +2 -0
  7. artdam_cli-0.6.1/artdam_cli/search_query.py +61 -0
  8. artdam_cli-0.6.0/README.md → artdam_cli-0.6.1/artdam_cli.egg-info/PKG-INFO +290 -267
  9. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli.egg-info/SOURCES.txt +5 -0
  10. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/pyproject.toml +1 -1
  11. artdam_cli-0.6.1/tests/test_ai_model.py +19 -0
  12. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/tests/test_display_policy.py +1 -1
  13. artdam_cli-0.6.1/tests/test_search_notices.py +73 -0
  14. artdam_cli-0.6.1/tests/test_search_pagination.py +202 -0
  15. artdam_cli-0.6.1/tests/test_search_scope_contract.py +143 -0
  16. artdam_cli-0.6.0/artdam_cli/commands/search.py +0 -121
  17. artdam_cli-0.6.0/tests/test_search_pagination.py +0 -78
  18. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/__init__.py +0 -0
  19. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/__init__.py +0 -0
  20. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/comment.py +0 -0
  21. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/delete_cmd.py +0 -0
  22. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/download.py +0 -0
  23. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/engine.py +0 -0
  24. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/favorite.py +0 -0
  25. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/folder_cmd.py +0 -0
  26. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/folders.py +0 -0
  27. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/get.py +0 -0
  28. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/login.py +0 -0
  29. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/project.py +0 -0
  30. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/projects.py +0 -0
  31. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/rate.py +0 -0
  32. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/restore.py +0 -0
  33. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/tag_cmd.py +0 -0
  34. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/tags.py +0 -0
  35. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/update.py +0 -0
  36. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/commands/upload.py +0 -0
  37. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/config.py +0 -0
  38. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/display.py +0 -0
  39. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/update_check.py +0 -0
  40. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli/uploader.py +0 -0
  41. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli.egg-info/dependency_links.txt +0 -0
  42. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli.egg-info/entry_points.txt +0 -0
  43. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli.egg-info/requires.txt +0 -0
  44. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/artdam_cli.egg-info/top_level.txt +0 -0
  45. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/setup.cfg +0 -0
  46. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/tests/test_login.py +0 -0
  47. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/tests/test_main_entry.py +0 -0
  48. {artdam_cli-0.6.0 → artdam_cli-0.6.1}/tests/test_uploader.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: artdam-cli
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: ArtDAM 数字资产管理平台命令行工具
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -277,3 +277,14 @@ artdam update <asset_id> --description "AI 生成的场景描述"
277
277
  ```
278
278
 
279
279
  SSO 或密码登录时凭据字段为 `"token": "eyJ..."`。请勿提交此配置文件或在日志中打印其内容。
280
+
281
+
282
+ ### 搜索范围与分页契约
283
+
284
+ artdam search 默认 --scope project,与网页项目工作区相同,包含自有素材与引用。仅查自有请显式使用 --scope owned;--scope global 查当前凭证可见全库;--scope published 查发布空间(可用 --project 显式筛选)。
285
+
286
+ artdam search "游戏特效" --project 1 --page 2 --limit 50 --json
287
+ artdam search "鞋子" --scope global --json
288
+ artdam search "特效设计" --scope published --project 1 --json
289
+
290
+ --json 现在返回分页对象,素材数组在 items,并保留 total、page、page_size、truncated。已有把 JSON 顶层当数组的脚本需改读 items。truncated=true 表示服务端召回不完整;--all 的 1000 条本地上限另用 fetch_capped 表达,不修改服务端截断语义。CLI 不再本地匹配、排序或去重。
@@ -1,279 +1,278 @@
1
- Metadata-Version: 2.4
2
- Name: artdam-cli
3
- Version: 0.6.0
4
- Summary: ArtDAM 数字资产管理平台命令行工具
5
- Requires-Python: >=3.10
6
- Description-Content-Type: text/markdown
7
- Requires-Dist: click>=8.1
8
- Requires-Dist: httpx>=0.27
9
- Requires-Dist: rich>=13.0
10
- Provides-Extra: dev
11
- Requires-Dist: pytest>=8.0; extra == "dev"
12
-
13
- # artdam-cli
14
-
15
- ArtDAM 数字资产管理平台命令行工具,支持所有主流 AI Agent工具接入
16
-
17
- ## 安装
18
-
19
- ```bash
20
- uv tool install artdam-cli
21
- ```
22
-
23
- ## 更新
24
-
25
- ```bash
26
- uv tool install artdam-cli@latest
27
- ```
28
-
29
- ## 快速开始
30
-
31
- ```bash
32
- # 登录(首次使用,浏览器 SSO 授权)
33
- artdam login
34
-
35
- # 个人 API Key 登录(隐藏输入,适合本机长期使用)
36
- artdam login --api-key
37
-
38
- # 搜索资产
39
- artdam search "关键词" --project 1
40
-
41
- # 查看资产详情
42
- artdam get 123
43
-
44
- # 下载资产
45
- artdam download 123 --out ./downloads
46
- ```
47
-
48
- ## 命令说明
49
-
50
- ### 素材名的显示口径
51
-
52
- 开了「只显示 public_id」的项目,`search` 的「素材名」列、`get` 的「素材名」行、`delete` 的
53
- 确认文案都显示 `public_id`(规则同网页端)。
54
-
55
- `download` 落盘名、`get` 的「路径」行、`--json` 原始响应**照旧给真实文件名**——脱敏只在对外面
56
- (发布空间 / 分享链接 / ZIP)由后端做,内部下载不变,见 PR #1036。写脚本时按
57
- `display_asset_public_id_only` 字段自己判断,别拿显示名当文件名用。
58
-
59
- ### 查询命令(viewer 及以上)
60
-
61
- #### `artdam login`
62
-
63
- 登录 ArtDAM。默认使用浏览器 SSO,也可使用个人 API Key 或账号密码。
64
-
65
- ```bash
66
- artdam login # 浏览器 SSO
67
- artdam login --api-key # 隐藏输入个人 ab_ API Key
68
- artdam login --password # 账号密码(仅 admin / 服务账号)
69
- ```
70
-
71
- `--api-key` 会通过只读的 `GET /api/auth/me` 验证密钥,再保存到
72
- `~/.artdam/config.json`(Linux/macOS 为 `0600`,Windows 收紧为仅当前用户 ACL)。
73
- 命令行参数和输出都不会显示密钥。
74
-
75
- 无人值守脚本和 Agent 可直接使用环境变量,无需执行登录,也不会把密钥写入配置文件:
76
-
77
- ```bash
78
- export ARTDAM_API_KEY='ab_...'
79
- export ARTDAM_BASE_URL='https://artdam.xindong.com' # 可选
80
- artdam search "头盔" --project 1 --json
81
- ```
82
-
83
- 个人 API Key 代表创建它的用户,最终能力始终是**用户在项目中的角色权限 ∩ Key 的权限范围
84
- (scope)**。例如 viewer 用户即使 Key 含 `write` 也不能上传;只有 `read` 的 Key 不能执行写操作。
85
-
86
- #### `artdam search`
87
-
88
- 搜索资产,返回匹配列表。默认只取首页(`--limit` 条);加 `--all` 自动翻页取全部结果
89
- (Agent 场景推荐,避免结果被截断)。`--all` 最多返回 1000 条,超出会提示用更精确的关键词或
90
- `--ext` / `--folder` 收窄,避免在几万条资产上卡死。
91
-
92
- ```bash
93
- artdam search "头盔" --project 1
94
- artdam search "头盔" --project 1 --limit 50
95
- artdam search "头盔" --project 1 --all # 自动翻页,取全部匹配
96
- artdam search "头盔" --project 1 --all --json # 全量 JSON 输出(AI Agent 用)
97
- artdam search "头盔" --project 1 --ext jpg # 按扩展名过滤
98
- artdam search "头盔" --project 1 --ext jpg,png # 多个扩展名
99
- artdam search "头盔" --project 1 --folder 10
100
- ```
101
-
102
- | 参数 | 说明 |
103
- |---|---|
104
- | `KEYWORD` | 搜索关键词 |
105
- | `-p, --project` | 项目 ID(必填) |
106
- | `-n, --limit` | 返回数量上限,默认 20(不与 `--all` 共用) |
107
- | `--all` | 自动翻页取全部匹配结果(最多 1000 条) |
108
- | `-e, --ext` | 按文件扩展名过滤,逗号分隔,如 `jpg,png` |
109
- | `--folder` | 限定文件夹 ID |
110
- | `--json` | 输出原始 JSON |
111
-
112
- #### `artdam get`
113
-
114
- 查看单个资产详情(含预览链接)。
115
-
116
- ```bash
117
- artdam get 123
118
- artdam get 123 --json # 输出原始 JSON(AI Agent 用)
119
- ```
120
-
121
- #### `artdam download`
122
-
123
- 下载资产文件到本地。
124
-
125
- ```bash
126
- artdam download 123
127
- artdam download 123 --out ./downloads
128
- ```
129
-
130
- #### `artdam tags`
131
-
132
- 列出项目标签。
133
-
134
- ```bash
135
- artdam tags --project 1
136
- artdam tags --project 1 --search "角色"
137
- artdam tags --project 1 --json
138
- ```
139
-
140
- #### `artdam folders`
141
-
142
- 查看文件夹结构。
143
-
144
- ```bash
145
- artdam folders --project 1
146
- artdam folders --project 1 --json
147
- ```
148
-
149
- ### 资产管理(member 及以上)
150
-
151
- #### `artdam upload`
152
-
153
- 上传文件到指定项目和文件夹。采用分块上传,支持大文件(最大 10GB),带进度条;
154
- 上传前按内容计算 SHA-256,库中已有相同文件则**秒传**(直接复用,不重复传输)。
155
- 单个分块遇到网络抖动(超时 / 5xx)会自动重试,中断时清理服务端会话。
156
-
157
- ```bash
158
- artdam upload ./image.jpg --project 1
159
- artdam upload ./image.jpg --project 1 --folder 10
160
- artdam upload ./big_scene.zip --project 1 # 大文件分块 + 进度条
161
- ```
162
-
163
- #### `artdam update`
164
-
165
- 更新资产信息(可同时传多个选项)。
166
-
167
- ```bash
168
- artdam update 123 --name "新文件名"
169
- artdam update 123 --description "新描述"
170
- artdam update 123 --folder 10
171
- ```
172
-
173
- #### `artdam delete`
174
-
175
- 软删除资产(可通过 `restore` 恢复)。
176
-
177
- ```bash
178
- artdam delete 123
179
- ```
180
-
181
- #### `artdam restore`
182
-
183
- 恢复已删除的资产。
184
-
185
- ```bash
186
- artdam restore 123
187
- ```
188
-
189
- ### 标签管理(member 及以上)
190
-
191
- ```bash
192
- # 给资产添加标签
193
- artdam tag add 123 5
194
-
195
- # 从资产移除标签
196
- artdam tag remove 123 5
197
-
198
- # 创建新标签
199
- artdam tag create "标签名" --project 1
200
- ```
201
-
202
- ### 文件夹管理(member 及以上)
203
-
204
- ```bash
205
- # 创建文件夹
206
- artdam folder create "文件夹名" --project 1
207
- artdam folder create "子文件夹" --project 1 --parent 10
208
-
209
- # 删除文件夹
210
- artdam folder delete 10
211
- ```
212
-
213
- ### 互动操作(member 及以上)
214
-
215
- ```bash
216
- # 评论
217
- artdam comment 123 "评论内容"
218
-
219
- # 评分(1-5 星)
220
- artdam rate 123 4
221
-
222
- # 收藏 / 取消收藏
223
- artdam favorite 123
224
- artdam favorite 123 --remove
225
- ```
226
-
227
- ## AI Agent 使用指南
228
-
229
- 所有查询命令支持 `--json` 输出原始 JSON,适合 Agent 解析:
230
-
231
- ```bash
232
- artdam search "安妮" --project 1 --json
233
- artdam get 123 --json
234
- artdam tags --project 1 --json
235
- artdam folders --project 1 --json
236
- ```
237
-
238
- ### 典型 Agent 工作流
239
-
240
- ```bash
241
- # 1. 登录(本机可用 SSO;无人值守 Agent 推荐 ARTDAM_API_KEY)
242
- export ARTDAM_API_KEY='ab_...'
243
-
244
- # 2. 搜索 → 确认 → 下载
245
- artdam search "头盔" --project 1 --json
246
- artdam get 50707 --json
247
- artdam download 50707 --out ./assets
248
-
249
- # 3. 搜索 → 批量打标签
250
- artdam search "安妮" --project 1 --json
251
- artdam tag add 50707 5
252
- artdam tag add 50708 5
253
-
254
- # 4. 上传并更新描述
255
- artdam upload ./new_asset.jpg --project 1 --folder 10
256
- artdam update <asset_id> --description "AI 生成的场景描述"
257
- ```
258
-
259
- ## 注意事项
260
-
261
- - `--project` 参数为**数字 ID**,不是项目名称
262
- - `--json` 返回原始 JSON,适合程序解析
263
- - SSO/JWT 或手动输入的 API Key 保存在 `~/.artdam/config.json`,仅当前用户可读写
264
- - `ARTDAM_API_KEY` 优先于配置文件中的登录凭据,且不会被写入配置或输出
265
- - API Key 能力受用户项目角色和 Key scope 双重限制
266
- - `artdam delete` 是软删除,可用 `artdam restore` 恢复
267
-
268
- ## 配置文件
269
-
270
- 登录信息保存在 `~/.artdam/config.json`:
271
-
272
- ```json
273
- {
274
- "base_url": "https://artdam.xindong.com",
275
- "api_key": "ab_..."
276
- }
277
- ```
278
-
279
- SSO 或密码登录时凭据字段为 `"token": "eyJ..."`。请勿提交此配置文件或在日志中打印其内容。
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
+ ### 素材名的显示口径
39
+
40
+ 开了「只显示 public_id」的项目,`search` 的「素材名」列、`get` 的「素材名」行、`delete` 的
41
+ 确认文案都显示 `public_id`(规则同网页端)。
42
+
43
+ `download` 落盘名、`get` 的「路径」行、`--json` 原始响应**照旧给真实文件名**——脱敏只在对外面
44
+ (发布空间 / 分享链接 / ZIP)由后端做,内部下载不变,见 PR #1036。写脚本时按
45
+ `display_asset_public_id_only` 字段自己判断,别拿显示名当文件名用。
46
+
47
+ ### 查询命令(viewer 及以上)
48
+
49
+ #### `artdam login`
50
+
51
+ 登录 ArtDAM。默认使用浏览器 SSO,也可使用个人 API Key 或账号密码。
52
+
53
+ ```bash
54
+ artdam login # 浏览器 SSO
55
+ artdam login --api-key # 隐藏输入个人 ab_ API Key
56
+ artdam login --password # 账号密码(仅 admin / 服务账号)
57
+ ```
58
+
59
+ `--api-key` 会通过只读的 `GET /api/auth/me` 验证密钥,再保存到
60
+ `~/.artdam/config.json`(Linux/macOS 为 `0600`,Windows 收紧为仅当前用户 ACL)。
61
+ 命令行参数和输出都不会显示密钥。
62
+
63
+ 无人值守脚本和 Agent 可直接使用环境变量,无需执行登录,也不会把密钥写入配置文件:
64
+
65
+ ```bash
66
+ export ARTDAM_API_KEY='ab_...'
67
+ export ARTDAM_BASE_URL='https://artdam.xindong.com' # 可选
68
+ artdam search "头盔" --project 1 --json
69
+ ```
70
+
71
+ 个人 API Key 代表创建它的用户,最终能力始终是**用户在项目中的角色权限 ∩ Key 的权限范围
72
+ (scope)**。例如 viewer 用户即使 Key 含 `write` 也不能上传;只有 `read` 的 Key 不能执行写操作。
73
+
74
+ #### `artdam search`
75
+
76
+ 搜索资产,返回匹配列表。默认只取首页(`--limit` 条);加 `--all` 自动翻页取全部结果
77
+ (Agent 场景推荐,避免结果被截断)。`--all` 最多返回 1000 条,超出会提示用更精确的关键词或
78
+ `--ext` / `--folder` 收窄,避免在几万条资产上卡死。
79
+
80
+ ```bash
81
+ artdam search "头盔" --project 1
82
+ artdam search "头盔" --project 1 --limit 50
83
+ artdam search "头盔" --project 1 --all # 自动翻页,取全部匹配
84
+ artdam search "头盔" --project 1 --all --json # 全量 JSON 输出(AI Agent 用)
85
+ artdam search "头盔" --project 1 --ext jpg # 按扩展名过滤
86
+ artdam search "头盔" --project 1 --ext jpg,png # 多个扩展名
87
+ artdam search "头盔" --project 1 --folder 10
88
+ ```
89
+
90
+ | 参数 | 说明 |
91
+ |---|---|
92
+ | `KEYWORD` | 搜索关键词 |
93
+ | `-p, --project` | 项目 ID(必填) |
94
+ | `-n, --limit` | 返回数量上限,默认 20(不与 `--all` 共用) |
95
+ | `--all` | 自动翻页取全部匹配结果(最多 1000 条) |
96
+ | `-e, --ext` | 按文件扩展名过滤,逗号分隔,如 `jpg,png` |
97
+ | `--folder` | 限定文件夹 ID |
98
+ | `--json` | 输出原始 JSON |
99
+
100
+ #### `artdam get`
101
+
102
+ 查看单个资产详情(含预览链接)。
103
+
104
+ ```bash
105
+ artdam get 123
106
+ artdam get 123 --json # 输出原始 JSON(AI Agent 用)
107
+ ```
108
+
109
+ #### `artdam download`
110
+
111
+ 下载资产文件到本地。
112
+
113
+ ```bash
114
+ artdam download 123
115
+ artdam download 123 --out ./downloads
116
+ ```
117
+
118
+ #### `artdam tags`
119
+
120
+ 列出项目标签。
121
+
122
+ ```bash
123
+ artdam tags --project 1
124
+ artdam tags --project 1 --search "角色"
125
+ artdam tags --project 1 --json
126
+ ```
127
+
128
+ #### `artdam folders`
129
+
130
+ 查看文件夹结构。
131
+
132
+ ```bash
133
+ artdam folders --project 1
134
+ artdam folders --project 1 --json
135
+ ```
136
+
137
+ ### 资产管理(member 及以上)
138
+
139
+ #### `artdam upload`
140
+
141
+ 上传文件到指定项目和文件夹。采用分块上传,支持大文件(最大 10GB),带进度条;
142
+ 上传前按内容计算 SHA-256,库中已有相同文件则**秒传**(直接复用,不重复传输)。
143
+ 单个分块遇到网络抖动(超时 / 5xx)会自动重试,中断时清理服务端会话。
144
+
145
+ ```bash
146
+ artdam upload ./image.jpg --project 1
147
+ artdam upload ./image.jpg --project 1 --folder 10
148
+ artdam upload ./big_scene.zip --project 1 # 大文件分块 + 进度条
149
+ ```
150
+
151
+ #### `artdam update`
152
+
153
+ 更新资产信息(可同时传多个选项)。
154
+
155
+ ```bash
156
+ artdam update 123 --name "新文件名"
157
+ artdam update 123 --description "新描述"
158
+ artdam update 123 --folder 10
159
+ ```
160
+
161
+ #### `artdam delete`
162
+
163
+ 软删除资产(可通过 `restore` 恢复)。
164
+
165
+ ```bash
166
+ artdam delete 123
167
+ ```
168
+
169
+ #### `artdam restore`
170
+
171
+ 恢复已删除的资产。
172
+
173
+ ```bash
174
+ artdam restore 123
175
+ ```
176
+
177
+ ### 标签管理(member 及以上)
178
+
179
+ ```bash
180
+ # 给资产添加标签
181
+ artdam tag add 123 5
182
+
183
+ # 从资产移除标签
184
+ artdam tag remove 123 5
185
+
186
+ # 创建新标签
187
+ artdam tag create "标签名" --project 1
188
+ ```
189
+
190
+ ### 文件夹管理(member 及以上)
191
+
192
+ ```bash
193
+ # 创建文件夹
194
+ artdam folder create "文件夹名" --project 1
195
+ artdam folder create "子文件夹" --project 1 --parent 10
196
+
197
+ # 删除文件夹
198
+ artdam folder delete 10
199
+ ```
200
+
201
+ ### 互动操作(member 及以上)
202
+
203
+ ```bash
204
+ # 评论
205
+ artdam comment 123 "评论内容"
206
+
207
+ # 评分(1-5 星)
208
+ artdam rate 123 4
209
+
210
+ # 收藏 / 取消收藏
211
+ artdam favorite 123
212
+ artdam favorite 123 --remove
213
+ ```
214
+
215
+ ## AI Agent 使用指南
216
+
217
+ 所有查询命令支持 `--json` 输出原始 JSON,适合 Agent 解析:
218
+
219
+ ```bash
220
+ artdam search "安妮" --project 1 --json
221
+ artdam get 123 --json
222
+ artdam tags --project 1 --json
223
+ artdam folders --project 1 --json
224
+ ```
225
+
226
+ ### 典型 Agent 工作流
227
+
228
+ ```bash
229
+ # 1. 登录(本机可用 SSO;无人值守 Agent 推荐 ARTDAM_API_KEY)
230
+ export ARTDAM_API_KEY='ab_...'
231
+
232
+ # 2. 搜索 → 确认 → 下载
233
+ artdam search "头盔" --project 1 --json
234
+ artdam get 50707 --json
235
+ artdam download 50707 --out ./assets
236
+
237
+ # 3. 搜索 → 批量打标签
238
+ artdam search "安妮" --project 1 --json
239
+ artdam tag add 50707 5
240
+ artdam tag add 50708 5
241
+
242
+ # 4. 上传并更新描述
243
+ artdam upload ./new_asset.jpg --project 1 --folder 10
244
+ artdam update <asset_id> --description "AI 生成的场景描述"
245
+ ```
246
+
247
+ ## 注意事项
248
+
249
+ - `--project` 参数为**数字 ID**,不是项目名称
250
+ - `--json` 返回原始 JSON,适合程序解析
251
+ - SSO/JWT 或手动输入的 API Key 保存在 `~/.artdam/config.json`,仅当前用户可读写
252
+ - `ARTDAM_API_KEY` 优先于配置文件中的登录凭据,且不会被写入配置或输出
253
+ - API Key 能力受用户项目角色和 Key scope 双重限制
254
+ - `artdam delete` 是软删除,可用 `artdam restore` 恢复
255
+
256
+ ## 配置文件
257
+
258
+ 登录信息保存在 `~/.artdam/config.json`:
259
+
260
+ ```json
261
+ {
262
+ "base_url": "https://artdam.xindong.com",
263
+ "api_key": "ab_..."
264
+ }
265
+ ```
266
+
267
+ SSO 或密码登录时凭据字段为 `"token": "eyJ..."`。请勿提交此配置文件或在日志中打印其内容。
268
+
269
+
270
+ ### 搜索范围与分页契约
271
+
272
+ artdam search 默认 --scope project,与网页项目工作区相同,包含自有素材与引用。仅查自有请显式使用 --scope owned;--scope global 查当前凭证可见全库;--scope published 查发布空间(可用 --project 显式筛选)。
273
+
274
+ artdam search "游戏特效" --project 1 --page 2 --limit 50 --json
275
+ artdam search "鞋子" --scope global --json
276
+ artdam search "特效设计" --scope published --project 1 --json
277
+
278
+ --json 现在返回分页对象,素材数组在 items,并保留 total、page、page_size、truncated。已有把 JSON 顶层当数组的脚本需改读 items。truncated=true 表示服务端召回不完整;--all 的 1000 条本地上限另用 fetch_capped 表达,不修改服务端截断语义。CLI 不再本地匹配、排序或去重。
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import time
4
+ import re
4
5
  from collections.abc import Callable
5
6
 
6
7
  import httpx
@@ -45,7 +46,15 @@ def get(
45
46
  with _make_client() as c:
46
47
  r = c.get(path, params=params)
47
48
  _raise(r, not_found_msg=not_found_msg)
48
- return r.json()
49
+ data = r.json()
50
+ search_id = r.headers.get("X-ArtDAM-Search-Id")
51
+ if (
52
+ isinstance(data, dict)
53
+ and isinstance(search_id, str)
54
+ and re.fullmatch(r"[A-Za-z0-9_-]{32}", search_id)
55
+ ):
56
+ data["search_id"] = search_id
57
+ return data
49
58
 
50
59
 
51
60
  def download_file(path: str, dest: str, not_found_msg: str = "资源不存在") -> int:
@@ -0,0 +1,18 @@
1
+ """Read central model selection for independently deployed admin tools."""
2
+
3
+ import json
4
+
5
+ import click
6
+ from urllib.parse import quote
7
+
8
+ from artdam_cli import client
9
+
10
+
11
+ @click.command("ai-model")
12
+ @click.argument("purpose")
13
+ @click.option("--json", "as_json", is_flag=True)
14
+ def ai_model(purpose: str, as_json: bool) -> None:
15
+ """只读分发:系统管理员 JWT,或含 read 权限的 API Key / OAuth。"""
16
+ item = client.get("/api/ai-models/selections/" + quote(purpose, safe=""))
17
+ result = {key: item[key] for key in ("key", "model", "override", "source")}
18
+ click.echo(json.dumps(result, ensure_ascii=False) if as_json else item["model"])