clawshire-cli 0.1.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.
Files changed (30) hide show
  1. clawshire_cli-0.1.0/PKG-INFO +564 -0
  2. clawshire_cli-0.1.0/README.md +554 -0
  3. clawshire_cli-0.1.0/clawshire_cli/__init__.py +1 -0
  4. clawshire_cli-0.1.0/clawshire_cli/commands/__init__.py +1 -0
  5. clawshire_cli-0.1.0/clawshire_cli/commands/annual_analysis.py +132 -0
  6. clawshire_cli-0.1.0/clawshire_cli/commands/annual_report.py +43 -0
  7. clawshire_cli-0.1.0/clawshire_cli/commands/auth.py +121 -0
  8. clawshire_cli-0.1.0/clawshire_cli/commands/notice.py +77 -0
  9. clawshire_cli-0.1.0/clawshire_cli/commands/update.py +171 -0
  10. clawshire_cli-0.1.0/clawshire_cli/commands/user.py +21 -0
  11. clawshire_cli-0.1.0/clawshire_cli/config.py +61 -0
  12. clawshire_cli-0.1.0/clawshire_cli/context.py +19 -0
  13. clawshire_cli-0.1.0/clawshire_cli/main.py +140 -0
  14. clawshire_cli-0.1.0/clawshire_cli/output.py +127 -0
  15. clawshire_cli-0.1.0/clawshire_cli.egg-info/PKG-INFO +564 -0
  16. clawshire_cli-0.1.0/clawshire_cli.egg-info/SOURCES.txt +28 -0
  17. clawshire_cli-0.1.0/clawshire_cli.egg-info/dependency_links.txt +1 -0
  18. clawshire_cli-0.1.0/clawshire_cli.egg-info/entry_points.txt +3 -0
  19. clawshire_cli-0.1.0/clawshire_cli.egg-info/requires.txt +3 -0
  20. clawshire_cli-0.1.0/clawshire_cli.egg-info/top_level.txt +2 -0
  21. clawshire_cli-0.1.0/clawshire_sdk/__init__.py +15 -0
  22. clawshire_cli-0.1.0/clawshire_sdk/client.py +153 -0
  23. clawshire_cli-0.1.0/clawshire_sdk/domains/__init__.py +4 -0
  24. clawshire_cli-0.1.0/clawshire_sdk/domains/annual_reports.py +145 -0
  25. clawshire_cli-0.1.0/clawshire_sdk/domains/filings.py +64 -0
  26. clawshire_cli-0.1.0/clawshire_sdk/errors.py +22 -0
  27. clawshire_cli-0.1.0/pyproject.toml +41 -0
  28. clawshire_cli-0.1.0/setup.cfg +4 -0
  29. clawshire_cli-0.1.0/tests/test_clawshire_cli.py +206 -0
  30. clawshire_cli-0.1.0/tests/test_skills.py +179 -0
@@ -0,0 +1,564 @@
1
+ Metadata-Version: 2.4
2
+ Name: clawshire-cli
3
+ Version: 0.1.0
4
+ Summary: ClawShire CLI for notice query, annual report query, and annual analysis
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: httpx>=0.28.1
8
+ Requires-Dist: packaging>=24.0
9
+ Requires-Dist: tomli-w>=1.2.0
10
+
11
+ # ClawShire CLI
12
+
13
+ 独立可安装的 ClawShire 命令行客户端。
14
+
15
+ ## Hello World
16
+
17
+ 要求:`Python >= 3.12`
18
+
19
+ 推荐先用 `uv` 创建一个独立环境,避免污染本地其他 Python 环境:
20
+
21
+ ```bash
22
+ mkdir clawshire-demo && cd clawshire-demo
23
+ uv venv .venv --python 3.12
24
+ source .venv/bin/activate
25
+ uv pip install clawshire-cli
26
+ ```
27
+
28
+ 然后:
29
+
30
+ 1. 访问 [https://clawshire.cn](https://clawshire.cn) 注册/登录
31
+ 2. 在控制台创建 API Key
32
+ 3. 执行下面几条命令
33
+
34
+ ```bash
35
+ clawshire auth set-key <your_api_key>
36
+ clawshire auth status
37
+ clawshire user info
38
+ clawshire notice search --start-date 2026-04-19 --end-date 2026-04-20 --keyword 603402
39
+ ```
40
+
41
+ 如果想马上试一个需要认证的能力:
42
+
43
+ ```bash
44
+ clawshire annual-report latest --year 2025 --keyword 平安银行
45
+ ```
46
+
47
+ ## 安装与升级
48
+
49
+ 推荐使用 `Python 3.12` 或 `Python 3.13`。
50
+
51
+ ```bash
52
+ pip install clawshire-cli
53
+ ```
54
+
55
+ 或使用 uv(推荐):
56
+
57
+ ```bash
58
+ uv tool install clawshire-cli
59
+ ```
60
+
61
+ 本地开发从源码安装:
62
+
63
+ ```bash
64
+ uv tool install ./clawshire-cli
65
+ ```
66
+
67
+ 安装后可使用两个命令入口:
68
+
69
+ ```bash
70
+ clawshire --help
71
+ cs --help
72
+ ```
73
+
74
+ 升级到最新版本:
75
+
76
+ ```bash
77
+ clawshire update
78
+ clawshire upgrade
79
+ ```
80
+
81
+ 如果想先看将执行什么命令:
82
+
83
+ ```bash
84
+ clawshire update --dry-run
85
+ clawshire --output json update --dry-run
86
+ ```
87
+
88
+ 如果想跳过确认提示:
89
+
90
+ ```bash
91
+ clawshire update -y
92
+ ```
93
+
94
+ 说明:
95
+
96
+ - `update` 会优先检查 PyPI 上的最新版本,再决定是否执行升级
97
+ - `update` 适合通过 `uv tool`、`pipx`、`pip` 安装的场景
98
+ - `upgrade` 是 `update` 的等价别名
99
+ - 如果你当前是在源码目录里开发,优先继续使用你原来的开发安装方式
100
+
101
+ ## SDK Quick Start
102
+
103
+ `clawshire-cli` 同时包含 Python SDK,安装 CLI 后即可直接在代码中使用:
104
+
105
+ ```python
106
+ from clawshire_sdk import ClawShireClient
107
+
108
+ client = ClawShireClient(
109
+ base_url="https://api.clawshire.cn",
110
+ api_key="your_api_key",
111
+ )
112
+
113
+ reports = client.annual.latest(
114
+ year=2025,
115
+ keyword="平安银行",
116
+ page_size=1,
117
+ )
118
+
119
+ print(reports["items"][0]["pdf_url"])
120
+ ```
121
+
122
+ 完整 SDK 用法见:
123
+
124
+ ```text
125
+ docs/sdk-usage.md
126
+ ```
127
+
128
+ ## Skills
129
+
130
+ `clawshire-cli` 仓库同时维护配套 Skills,目录位于:
131
+
132
+ ```text
133
+ skills/
134
+ ```
135
+
136
+ 当前已提供:
137
+
138
+ 1. `clawshire-shared`
139
+ 2. `clawshire-data-query`
140
+ 3. `clawshire-annual-report`
141
+ 4. `clawshire-annual-analysis`
142
+
143
+ 这些 Skills 的定位不是重复实现底层请求,而是复用 `clawshire` CLI,把公告查询、年报定位、年报分析等能力组织成更适合 Agent 调用的工作流。
144
+
145
+ 推荐按**整个仓库**安装 skills bundle,而不是单独安装某个 skill 子目录。
146
+
147
+ 示意安装方式:
148
+
149
+ ```bash
150
+ npx skills add <owner>/clawshire-cli -y -g
151
+ ```
152
+
153
+ 这意味着:
154
+
155
+ - `skills/` 下的多个 Skill 会一起分发
156
+ - `clawshire-shared` 可以作为共享规则层存在
157
+ - 不需要假设用户只安装单个 skill 子目录
158
+
159
+ ## Testing
160
+
161
+ 本地完整用户流程测试说明见:
162
+
163
+ ```text
164
+ docs/local-e2e.md
165
+ ```
166
+
167
+ Python SDK 使用说明见:
168
+
169
+ ```text
170
+ docs/sdk-usage.md
171
+ ```
172
+
173
+ 一键检查脚本:
174
+
175
+ ```bash
176
+ ./scripts/e2e_local_check.sh
177
+ ```
178
+
179
+ 该脚本默认执行:
180
+
181
+ 1. 测试集
182
+ 2. CLI 基础命令检查
183
+ 3. skills 目录结构检查
184
+
185
+ 若环境中存在 `CLAWSHIRE_API_KEY`,还会继续执行真实线上链路验证,包括 `auth check`、`user info`、`notice stock`、`annual-report latest`、`annual-analysis company`。
186
+
187
+ 如果你只想快速确认安装成功,先跑:
188
+
189
+ ```bash
190
+ clawshire --help
191
+ clawshire auth --help
192
+ clawshire update --dry-run
193
+ clawshire user info --api-key <your_api_key>
194
+ ```
195
+
196
+ ## 3 分钟上手
197
+
198
+ 把下面几条命令直接复制执行即可:
199
+
200
+ ```bash
201
+ pip install clawshire-cli
202
+ clawshire auth set-key <your_api_key>
203
+ clawshire user info
204
+ clawshire annual-analysis pdf-url https://static.cninfo.com.cn/finalpage/2026-04-20/1225116956.PDF
205
+ ```
206
+
207
+ 如果你要查公告或年报,再继续:
208
+
209
+ ```bash
210
+ clawshire notice search --start-date 2026-04-19 --end-date 2026-04-20
211
+ clawshire annual-report latest --year 2025 --keyword 平安银行
212
+ ```
213
+
214
+ ## 如何获取 API Key
215
+
216
+ 1. 访问 [https://clawshire.cn](https://clawshire.cn) 并注册/登录你的 ClawShire 账号
217
+ 2. 进入平台控制台中的 API Key 页面创建一个新 Key
218
+ 3. 复制创建后的 Key,并立即保存到安全位置
219
+ 4. 回到终端执行:
220
+
221
+ ```bash
222
+ clawshire auth set-key <your_api_key>
223
+ ```
224
+
225
+ 如果你只想临时使用,也可以不落盘,直接通过环境变量传入:
226
+
227
+ ```bash
228
+ export CLAWSHIRE_API_KEY="<your_api_key>"
229
+ ```
230
+
231
+ ## 先配置 API Key
232
+
233
+ 建议先把 API Key 保存到本地,这样后续不用每次手动加 `--api-key`。
234
+
235
+ ```bash
236
+ clawshire auth set-key <your_api_key>
237
+ clawshire auth show
238
+ clawshire auth status
239
+ clawshire auth check
240
+ clawshire user info
241
+ ```
242
+
243
+ 如果想临时覆盖本地配置,也可以直接传:
244
+
245
+ ```bash
246
+ clawshire --api-key <your_api_key> user info
247
+ ```
248
+
249
+ 清除本地保存的 Key:
250
+
251
+ ```bash
252
+ clawshire auth clear-key
253
+ clawshire auth logout
254
+ ```
255
+
256
+ ## 命令
257
+
258
+ 主命令分组:
259
+
260
+ 1. `notice`
261
+ 2. `annual-report`
262
+ 3. `annual-analysis`
263
+
264
+ 高频简写:
265
+
266
+ 1. `gg` -> `notice`
267
+ 2. `ar` -> `annual-report`
268
+ 3. `aa` -> `annual-analysis`
269
+
270
+ ## 全部命令能力
271
+
272
+ | 能力 | 命令 | 是否需要 API Key | 说明 |
273
+ |------|------|------------------|------|
274
+ | 保存 Key | `clawshire auth set-key <key>` | 否 | 保存本地 API Key |
275
+ | 查看认证配置 | `clawshire auth show` | 否 | 查看当前 base_url、key 掩码、输出格式、超时 |
276
+ | 查看认证状态 | `clawshire auth status` | 否/建议有 | 查看当前 key 来源、是否已配置、是否认证可用 |
277
+ | 检查认证可用性 | `clawshire auth check` | 是 | 用退出码检查当前认证是否可用,`0=ok` |
278
+ | 清除 Key | `clawshire auth clear-key` | 否 | 清除本地保存的 API Key |
279
+ | 退出登录 | `clawshire auth logout` | 否 | `clear-key` 的用户友好别名 |
280
+ | 检查当前 Key | `clawshire auth whoami` | 是 | 校验当前 API Key 是否有效 |
281
+ | 用户信息 | `clawshire user info` | 是 | 查询余额、免费次数、配额等用户信息 |
282
+ | 公告按日期查询 | `clawshire notice search --start-date <d> --end-date <d> --keyword 603402` | 否/建议有 | 按日期范围查询公告,示例默认限定证券代码避免结果过大 |
283
+ | 公告按证券代码查询 | `clawshire notice stock <sec_code> --start-date <d> --end-date <d>` | 否/建议有 | 查询某证券代码公告 |
284
+ | 公告按链接查询 | `clawshire notice link --met-link <pdf_link>` | 否/建议有 | 按公告 PDF 链接查询 |
285
+ | 年报列表 | `clawshire annual-report latest --year <YYYY> --keyword <kw>` | 是 | 查询指定年份年报列表 |
286
+ | 年报结构化数据 | `clawshire annual-report data <met_uuid>` | 是 | 查询指定年报的结构化数据 |
287
+ | 年报分析: 本地文件 | `clawshire annual-analysis pdf-file <path>` | 是 | 上传本地 PDF 分析 |
288
+ | 年报分析: PDF 链接 | `clawshire annual-analysis pdf-url <url>` | 是 | 下载 PDF 链接后分析 |
289
+ | 年报分析: 公司 | `clawshire annual-analysis company <代码或简称> --year <YYYY>` | 是 | 先查询指定年份年报,再自动发起分析 |
290
+ | 查询分析任务 | `clawshire annual-analysis get <task_id_or_job_id>` | 是 | 查询分析任务状态或结果 |
291
+
292
+ 简写命令:
293
+
294
+ | 简写 | 全称 | 示例 |
295
+ |------|------|------|
296
+ | `gg` | `notice` | `cs gg search --start-date 2026-04-19 --end-date 2026-04-20 --keyword 603402` |
297
+ | `ar` | `annual-report` | `cs ar latest --year 2025 --keyword 平安银行` |
298
+ | `aa` | `annual-analysis` | `cs aa company 000001 --year 2025` |
299
+
300
+ 按命令分组查看帮助:
301
+
302
+ ```bash
303
+ clawshire auth --help
304
+ clawshire update --help
305
+ clawshire user --help
306
+ clawshire notice --help
307
+ clawshire annual-report --help
308
+ clawshire annual-analysis --help
309
+ ```
310
+
311
+ ## 示例
312
+
313
+ ```bash
314
+ clawshire user info
315
+ clawshire notice search --start-date 2026-04-01 --end-date 2026-04-20 --keyword 603402
316
+ clawshire annual-report latest --year 2025 --keyword 平安银行
317
+ clawshire annual-analysis pdf-file ./report.pdf
318
+ clawshire annual-analysis pdf-url https://example.com/report.pdf
319
+ clawshire annual-analysis company 000001 --year 2025
320
+ ```
321
+
322
+ 年报分析测试 PDF 示例:
323
+
324
+ ```text
325
+ https://static.cninfo.com.cn/finalpage/2026-04-20/1225116956.PDF
326
+ ```
327
+
328
+ 推荐直接试:
329
+
330
+ ```bash
331
+ clawshire annual-analysis pdf-url https://static.cninfo.com.cn/finalpage/2026-04-20/1225116956.PDF
332
+ ```
333
+
334
+ ## 配置
335
+
336
+ 支持环境变量:
337
+
338
+ 1. `CLAWSHIRE_API_KEY`
339
+ 2. `CLAWSHIRE_BASE_URL`
340
+ 3. `CLAWSHIRE_OUTPUT`
341
+ 4. `CLAWSHIRE_TIMEOUT`
342
+
343
+ 如果你更习惯环境变量,可直接这样配置:
344
+
345
+ ```bash
346
+ export CLAWSHIRE_API_KEY=<your_api_key>
347
+ clawshire user info
348
+ ```
349
+
350
+ ## 最常用命令
351
+
352
+ 查询用户信息:
353
+
354
+ ```bash
355
+ clawshire user info
356
+ ```
357
+
358
+ 查询公告:
359
+
360
+ ```bash
361
+ clawshire notice search --start-date 2026-04-19 --end-date 2026-04-20 --keyword 603402
362
+ clawshire notice stock 000001 --start-date 2026-04-01 --end-date 2026-04-20
363
+ clawshire notice link --met-link <pdf_link>
364
+ ```
365
+
366
+ 查询年报:
367
+
368
+ ```bash
369
+ clawshire annual-report latest --year 2025 --keyword 平安银行
370
+ clawshire annual-report data <met_uuid>
371
+ ```
372
+
373
+ 发起年报分析:
374
+
375
+ ```bash
376
+ clawshire annual-analysis pdf-file ./report.pdf
377
+ clawshire annual-analysis pdf-url https://static.cninfo.com.cn/finalpage/2026-04-20/1225116956.PDF
378
+ clawshire annual-analysis company 000001 --year 2025
379
+ ```
380
+
381
+ 查询分析任务:
382
+
383
+ ```bash
384
+ clawshire annual-analysis get <task_id_or_job_id>
385
+ ```
386
+
387
+ ## 必要提示
388
+
389
+ 1. 全局参数要放在子命令前面,例如:`clawshire --output json user info`
390
+ 2. `notice` 查询通常不需要 API Key,但如果本地配置了错误的 Key,可能会带上错误认证头
391
+ 3. `annual-report`、`annual-analysis`、`user info` 都需要有效 API Key
392
+ 4. CLI 不单独实现计费,仍然走服务端原有配额和计费逻辑
393
+
394
+ ## 常见报错与处理
395
+
396
+ ### 1. `认证失败: Authorization 格式错误,应为 Bearer <api_key>`
397
+
398
+ 原因:
399
+
400
+ 1. 本地保存了错误的 API Key
401
+ 2. 环境变量里有错误的 `CLAWSHIRE_API_KEY`
402
+ 3. 你传入的不是完整 API Key
403
+
404
+ 处理:
405
+
406
+ ```bash
407
+ clawshire auth show
408
+ clawshire auth status
409
+ clawshire auth clear-key
410
+ clawshire auth set-key <your_api_key>
411
+ clawshire user info
412
+ ```
413
+
414
+ 如果你使用环境变量,也检查:
415
+
416
+ ```bash
417
+ echo $CLAWSHIRE_API_KEY
418
+ ```
419
+
420
+ ### 2. `配置错误: 该命令需要 API Key`
421
+
422
+ 原因:
423
+
424
+ 1. 你在调用需要认证的命令,但还没有配置 Key
425
+
426
+ 处理:
427
+
428
+ ```bash
429
+ clawshire auth set-key <your_api_key>
430
+ clawshire auth status
431
+ clawshire user info
432
+ ```
433
+
434
+ 或者临时传参:
435
+
436
+ ```bash
437
+ clawshire --api-key <your_api_key> user info
438
+ ```
439
+
440
+ ### 3. `unrecognized arguments: --output json`
441
+
442
+ 原因:
443
+
444
+ 1. 把全局参数写在了子命令后面
445
+
446
+ 错误示例:
447
+
448
+ ```bash
449
+ clawshire notice search --start-date 2026-04-19 --end-date 2026-04-20 --keyword 603402 --output json
450
+ ```
451
+
452
+ 正确写法:
453
+
454
+ ```bash
455
+ clawshire --output json notice search --start-date 2026-04-19 --end-date 2026-04-20 --keyword 603402
456
+ ```
457
+
458
+ ### 4. `未找到与 XXX 匹配的年报`
459
+
460
+ 原因:
461
+
462
+ 1. 公司代码或简称不匹配
463
+ 2. 指定年份没有收录对应年报
464
+ 3. 交易所筛选过窄
465
+
466
+ 处理:
467
+
468
+ ```bash
469
+ clawshire annual-report latest --year 2025 --keyword 平安银行
470
+ clawshire annual-report latest --year 2025 --keyword 000001
471
+ clawshire annual-analysis company 000001 --year 2025
472
+ ```
473
+
474
+ 如果仍然找不到,先去掉 `--exchange` 再试。
475
+
476
+ ### 5. `查询分析任务` 没返回结果
477
+
478
+ 原因:
479
+
480
+ 1. `annual-analysis get` 传错了 ID
481
+ 2. `pdf-file/pdf-url` 用的是 `job_id`
482
+ 3. `company` 用的是平台异步分析 `task_id`
483
+
484
+ 处理:
485
+
486
+ 1. `pdf-file` / `pdf-url` 后续查询传 `job_id`
487
+ 2. `company` 后续查询优先传 `task_id`
488
+
489
+ 示例:
490
+
491
+ ```bash
492
+ clawshire annual-analysis get 123
493
+ clawshire annual-analysis get job_xxx
494
+ ```
495
+
496
+ ## 发布流程
497
+
498
+ ### 版本更新
499
+
500
+ 1. 修改 [pyproject.toml](/Users/memect/work/code/sz_extract/hermeshub/clawshire-cli/pyproject.toml) 中的 `version`
501
+ 2. 如有命令变化,同步更新本 README 与根目录 [README.md](/Users/memect/work/code/sz_extract/hermeshub/README.md)
502
+
503
+ ### 本地构建
504
+
505
+ ```bash
506
+ cd clawshire-cli
507
+ uv build
508
+ ```
509
+
510
+ 构建产物位于:
511
+
512
+ ```text
513
+ clawshire-cli/dist/
514
+ ```
515
+
516
+ ### 本地安装验证
517
+
518
+ ```bash
519
+ cd clawshire-cli
520
+ uv tool install .
521
+ clawshire --help
522
+ cs --help
523
+ clawshire notice search --start-date 2026-04-19 --end-date 2026-04-20 --keyword 603402
524
+ ```
525
+
526
+ 如果本机已安装 `pipx`,再补一轮:
527
+
528
+ ```bash
529
+ cd clawshire-cli
530
+ pipx install .
531
+ clawshire --help
532
+ ```
533
+
534
+ ### 发布测试版
535
+
536
+ 建议先发测试版,再发正式版,例如:
537
+
538
+ 1. `0.1.0a1`
539
+ 2. `0.1.0b1`
540
+ 3. `0.1.0rc1`
541
+
542
+ 发布命令示例:
543
+
544
+ ```bash
545
+ cd clawshire-cli
546
+ uv build
547
+ uv publish
548
+ ```
549
+
550
+ 如果要发到 TestPyPI:
551
+
552
+ ```bash
553
+ cd clawshire-cli
554
+ uv build
555
+ uv publish --publish-url https://test.pypi.org/legacy/
556
+ ```
557
+
558
+ 安装验证:
559
+
560
+ ```bash
561
+ pip install clawshire-cli
562
+ clawshire --help
563
+ cs --help
564
+ ```