coder-firefly-cli 1.0.0__tar.gz → 1.0.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 (43) hide show
  1. coder_firefly_cli-1.0.1/PKG-INFO +512 -0
  2. coder_firefly_cli-1.0.1/README.md +474 -0
  3. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/setup.py +2 -2
  4. coder_firefly_cli-1.0.1/src/coder_firefly_cli/__init__.py +0 -0
  5. coder_firefly_cli-1.0.1/src/coder_firefly_cli/api_client.py +308 -0
  6. coder_firefly_cli-1.0.1/src/coder_firefly_cli/cli.py +132 -0
  7. coder_firefly_cli-1.0.1/src/coder_firefly_cli/commands/accounts.py +113 -0
  8. coder_firefly_cli-1.0.1/src/coder_firefly_cli/commands/bills.py +99 -0
  9. coder_firefly_cli-1.0.1/src/coder_firefly_cli/commands/budgets.py +147 -0
  10. coder_firefly_cli-1.0.1/src/coder_firefly_cli/commands/categories.py +79 -0
  11. coder_firefly_cli-1.0.1/src/coder_firefly_cli/commands/info.py +36 -0
  12. coder_firefly_cli-1.0.1/src/coder_firefly_cli/commands/insights.py +87 -0
  13. coder_firefly_cli-1.0.1/src/coder_firefly_cli/commands/piggy_banks.py +99 -0
  14. coder_firefly_cli-1.0.1/src/coder_firefly_cli/commands/search.py +25 -0
  15. coder_firefly_cli-1.0.1/src/coder_firefly_cli/commands/tags.py +100 -0
  16. coder_firefly_cli-1.0.1/src/coder_firefly_cli/commands/transactions.py +151 -0
  17. coder_firefly_cli-1.0.1/src/coder_firefly_cli.egg-info/PKG-INFO +512 -0
  18. coder_firefly_cli-1.0.1/src/coder_firefly_cli.egg-info/SOURCES.txt +35 -0
  19. coder_firefly_cli-1.0.1/src/coder_firefly_cli.egg-info/entry_points.txt +2 -0
  20. coder_firefly_cli-1.0.1/src/coder_firefly_cli.egg-info/top_level.txt +2 -0
  21. coder_firefly_cli-1.0.1/src/commands/__init__.py +1 -0
  22. coder_firefly_cli-1.0.0/PKG-INFO +0 -239
  23. coder_firefly_cli-1.0.0/README.md +0 -201
  24. coder_firefly_cli-1.0.0/src/coder_firefly_cli.egg-info/PKG-INFO +0 -239
  25. coder_firefly_cli-1.0.0/src/coder_firefly_cli.egg-info/SOURCES.txt +0 -21
  26. coder_firefly_cli-1.0.0/src/coder_firefly_cli.egg-info/entry_points.txt +0 -2
  27. coder_firefly_cli-1.0.0/src/coder_firefly_cli.egg-info/top_level.txt +0 -1
  28. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/setup.cfg +0 -0
  29. {coder_firefly_cli-1.0.0/src → coder_firefly_cli-1.0.1/src/coder_firefly_cli}/commands/__init__.py +0 -0
  30. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/src/coder_firefly_cli.egg-info/dependency_links.txt +0 -0
  31. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/src/coder_firefly_cli.egg-info/requires.txt +0 -0
  32. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/src/commands/accounts.py +0 -0
  33. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/src/commands/bills.py +0 -0
  34. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/src/commands/budgets.py +0 -0
  35. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/src/commands/categories.py +0 -0
  36. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/src/commands/info.py +0 -0
  37. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/src/commands/insights.py +0 -0
  38. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/src/commands/piggy_banks.py +0 -0
  39. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/src/commands/search.py +0 -0
  40. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/src/commands/tags.py +0 -0
  41. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/src/commands/transactions.py +0 -0
  42. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/tests/test_api_client.py +0 -0
  43. {coder_firefly_cli-1.0.0 → coder_firefly_cli-1.0.1}/tests/test_commands.py +0 -0
@@ -0,0 +1,512 @@
1
+ Metadata-Version: 2.4
2
+ Name: coder-firefly-cli
3
+ Version: 1.0.1
4
+ Summary: Firefly III CLI - 个人财务管理命令行工具
5
+ Home-page: https://github.com/joyous-coder/coder-firefly-cli
6
+ Author: coder
7
+ Author-email: coder@example.com
8
+ License: MIT
9
+ Keywords: firefly-iii cli finance personal-finance
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: End Users/Desktop
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Office/Business :: Financial
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: click>=8.0
21
+ Requires-Dist: requests>=2.25
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7.0; extra == "dev"
24
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
25
+ Requires-Dist: responses>=0.25; extra == "dev"
26
+ Dynamic: author
27
+ Dynamic: author-email
28
+ Dynamic: classifier
29
+ Dynamic: description
30
+ Dynamic: description-content-type
31
+ Dynamic: home-page
32
+ Dynamic: keywords
33
+ Dynamic: license
34
+ Dynamic: provides-extra
35
+ Dynamic: requires-dist
36
+ Dynamic: requires-python
37
+ Dynamic: summary
38
+
39
+ # coder-firefly-cli
40
+
41
+ Firefly III CLI - 个人财务管理命令行工具
42
+
43
+ 通过命令行连接和管理 Firefly III 个人财务管理系统,支持账户、交易、预算、分类、标签、账单、储蓄罐等全面管理。
44
+
45
+ ## 安装
46
+
47
+ ### 方式一:通过 PyPI 安装(推荐)
48
+
49
+ ```bash
50
+ pip install coder-firefly-cli
51
+ ```
52
+
53
+ ### 方式二:通过 GitHub 安装
54
+
55
+ ```bash
56
+ pip install git+https://github.com/joyous-coder/coder-firefly-cli.git
57
+ ```
58
+
59
+ ### 方式三:本地开发安装
60
+
61
+ ```bash
62
+ git clone https://github.com/joyous-coder/coder-firefly-cli.git
63
+ cd coder-firefly-cli
64
+ pip install -e .
65
+ ```
66
+
67
+ ## 安装为 Skill(AI Agent 使用)
68
+
69
+ 如果你需要将本工具作为 AI Agent 的 Skill 使用,可以将 `SKILL.md` 文件配置到 AI 系统中。
70
+
71
+ ### OhMyOpenCode / CLI-Anything 环境
72
+
73
+ 将本仓库作为 Skill 添加到配置中:
74
+
75
+ ```bash
76
+ # 克隆仓库
77
+ git clone https://github.com/joyous-coder/coder-firefly-cli.git
78
+
79
+ # 在 skill 配置中引用 SKILL.md 文件路径
80
+ # 或直接复制 SKILL.md 内容到 skill 配置
81
+ ```
82
+
83
+ ### 通用 AI 工具集成
84
+
85
+ 1. 获取 `SKILL.md` 文件内容
86
+ 2. 在 AI 系统中配置为可用工具/Skill
87
+ 3. 配置环境变量 `FIREFLY_BASE_URL` 和 `FIREFLY_PAT`
88
+ 4. AI 将自动识别并使用 `coder-firefly-cli` 命令
89
+
90
+ ## 前提条件
91
+
92
+ - Python 3.10+
93
+ - 运行中的 Firefly III 实例
94
+ - Personal Access Token (PAT)
95
+
96
+ ## 配置
97
+
98
+ ### 环境变量(推荐)
99
+
100
+ ```bash
101
+ export FIREFLY_BASE_URL="https://firefly.yourdomain.com"
102
+ export FIREFLY_PAT="your-personal-access-token"
103
+ ```
104
+
105
+ ### 命令行参数
106
+
107
+ ```bash
108
+ coder-firefly-cli --base-url https://firefly.yourdomain.com --pat your-token accounts list
109
+ ```
110
+
111
+ ## 全局选项
112
+
113
+ | 选项 | 说明 |
114
+ |------|------|
115
+ | `--json` | 以 JSON 格式输出结构化数据 |
116
+ | `--base-url` | Firefly III 实例地址 |
117
+ | `--pat` | Personal Access Token |
118
+ | `--help` | 查看帮助信息 |
119
+
120
+ ## 命令组
121
+
122
+ | 命令组 | 说明 | 对应 API |
123
+ |--------|------|----------|
124
+ | `accounts` | 账户管理(资产、支出、收入、负债) | `/api/v1/accounts` |
125
+ | `transactions` | 交易管理(支出、收入、转账) | `/api/v1/transactions` |
126
+ | `budgets` | 预算管理(含预算限额) | `/api/v1/budgets` |
127
+ | `categories` | 分类管理 | `/api/v1/categories` |
128
+ | `tags` | 标签管理 | `/api/v1/tags` |
129
+ | `bills` | 账单管理 | `/api/v1/bills` |
130
+ | `piggy-banks` | 储蓄罐管理 | `/api/v1/piggy-banks` |
131
+ | `insights` | 财务洞察报告(支出/收入/转账分析) | `/api/v1/insight/*` |
132
+ | `search` | 搜索交易 | `/api/v1/search/*` |
133
+ | `info` | 系统信息 | `/api/v1/about` |
134
+
135
+ ## 详细命令参考
136
+
137
+ ### accounts - 账户管理
138
+
139
+ ```bash
140
+ # 列出所有账户
141
+ coder-firefly-cli accounts list
142
+
143
+ # 按类型筛选(asset/expense/revenue/liability)
144
+ coder-firefly-cli accounts list --type asset
145
+
146
+ # 分页查询
147
+ coder-firefly-cli accounts list --limit 10 --page 1
148
+
149
+ # 获取账户详情
150
+ coder-firefly-cli accounts get --id 123
151
+
152
+ # 创建资产账户
153
+ coder-firefly-cli accounts create --name "现金" --type asset --currency-code CNY --opening-balance 1000
154
+
155
+ # 创建支出账户
156
+ coder-firefly-cli accounts create --name "餐饮" --type expense
157
+
158
+ # 更新账户
159
+ coder-firefly-cli accounts update --id 123 --name "新名称"
160
+
161
+ # 删除账户(会提示确认)
162
+ coder-firefly-cli accounts delete --id 123
163
+ ```
164
+
165
+ ### transactions - 交易管理
166
+
167
+ ```bash
168
+ # 列出最近交易
169
+ coder-firefly-cli transactions list
170
+
171
+ # 分页和日期范围
172
+ coder-firefly-cli transactions list --limit 20 --start 2024-01-01 --end 2024-01-31
173
+
174
+ # 按类型筛选(withdrawal/deposit/transfer)
175
+ coder-firefly-cli transactions list --type withdrawal
176
+
177
+ # 按账户筛选
178
+ coder-firefly-cli transactions list --source-account 1
179
+
180
+ # 创建支出交易
181
+ coder-firefly-cli transactions create --description "超市购物" --amount 150.00 --source-account 1 --category "生活"
182
+
183
+ # 创建转账
184
+ coder-firefly-cli transactions create --description "转账到支付宝" --amount 500.00 --source-account 1 --destination-account 2 --type transfer
185
+
186
+ # 创建带标签的交易
187
+ coder-firefly-cli transactions create --description "午餐" --amount 35.00 --source-account 1 --tags "餐饮,工作日"
188
+
189
+ # 获取交易详情
190
+ coder-firefly-cli transactions get --id 456
191
+
192
+ # 更新交易
193
+ coder-firefly-cli transactions update --id 456 --description "更新后的描述" --amount 160.00
194
+
195
+ # 删除交易(会提示确认)
196
+ coder-firefly-cli transactions delete --id 456
197
+ ```
198
+
199
+ ### budgets - 预算管理
200
+
201
+ ```bash
202
+ # 列出所有预算
203
+ coder-firefly-cli budgets list
204
+
205
+ # 创建预算
206
+ coder-firefly-cli budgets create --name "餐饮预算" --notes "每月餐饮支出上限"
207
+
208
+ # 获取预算详情
209
+ coder-firefly-cli budgets get --id 1
210
+
211
+ # 更新预算
212
+ coder-firefly-cli budgets update --id 1 --name "新餐饮预算"
213
+
214
+ # 删除预算(会提示确认)
215
+ coder-firefly-cli budgets delete --id 1
216
+
217
+ # 查看预算限额
218
+ coder-firefly-cli budgets limits --budget-id 1
219
+
220
+ # 创建预算限额
221
+ coder-firefly-cli budgets limit-create --budget-id 1 --amount 2000 --start 2024-01-01 --end 2024-01-31 --currency-code CNY
222
+
223
+ # 更新预算限额
224
+ coder-firefly-cli budgets limit-update --id 10 --amount 2500
225
+
226
+ # 删除预算限额(会提示确认)
227
+ coder-firefly-cli budgets limit-delete --id 10
228
+ ```
229
+
230
+ ### categories - 分类管理
231
+
232
+ ```bash
233
+ # 列出所有分类
234
+ coder-firefly-cli categories list
235
+
236
+ # 创建分类
237
+ coder-firefly-cli categories create --name "餐饮" --notes "日常餐饮"
238
+
239
+ # 获取分类详情
240
+ coder-firefly-cli categories get --id 1
241
+
242
+ # 更新分类
243
+ coder-firefly-cli categories update --id 1 --name "日常餐饮"
244
+
245
+ # 删除分类(会提示确认)
246
+ coder-firefly-cli categories delete --id 1
247
+ ```
248
+
249
+ ### tags - 标签管理
250
+
251
+ ```bash
252
+ # 列出所有标签
253
+ coder-firefly-cli tags list
254
+
255
+ # 创建标签
256
+ coder-firefly-cli tags create --tag "重要" --description "重要支出标记"
257
+
258
+ # 获取标签详情
259
+ coder-firefly-cli tags get --id "重要"
260
+
261
+ # 更新标签
262
+ coder-firefly-cli tags update --id "重要" --description "更新后的描述"
263
+
264
+ # 删除标签(会提示确认)
265
+ coder-firefly-cli tags delete --id "重要"
266
+ ```
267
+
268
+ ### bills - 账单管理
269
+
270
+ ```bash
271
+ # 列出所有账单
272
+ coder-firefly-cli bills list
273
+
274
+ # 创建账单
275
+ coder-firefly-cli bills create --name "房租" --amount-min 3000 --amount-max 3000 --date 2024-01-01 --repeat-freq monthly
276
+
277
+ # 获取账单详情
278
+ coder-firefly-cli bills get --id 1
279
+
280
+ # 更新账单
281
+ coder-firefly-cli bills update --id 1 --amount-min 3200
282
+
283
+ # 删除账单(会提示确认)
284
+ coder-firefly-cli bills delete --id 1
285
+ ```
286
+
287
+ ### piggy-banks - 储蓄罐管理
288
+
289
+ ```bash
290
+ # 列出所有储蓄罐
291
+ coder-firefly-cli piggy-banks list
292
+
293
+ # 创建储蓄罐
294
+ coder-firefly-cli piggy-banks create --name "旅行基金" --account-id 1 --target-amount 10000 --current-amount 2000 --target-date 2024-12-31
295
+
296
+ # 获取储蓄罐详情
297
+ coder-firefly-cli piggy-banks get --id 1
298
+
299
+ # 更新储蓄罐
300
+ coder-firefly-cli piggy-banks update --id 1 --current-amount 2500
301
+
302
+ # 删除储蓄罐(会提示确认)
303
+ coder-firefly-cli piggy-banks delete --id 1
304
+ ```
305
+
306
+ ### insights - 财务洞察
307
+
308
+ ```bash
309
+ # 支出洞察
310
+ coder-firefly-cli insights expense --start 2024-01-01 --end 2024-01-31
311
+
312
+ # 收入洞察
313
+ coder-firefly-cli insights income --start 2024-01-01 --end 2024-01-31
314
+
315
+ # 转账洞察
316
+ coder-firefly-cli insights transfer --start 2024-01-01 --end 2024-01-31
317
+
318
+ # 按账户筛选洞察
319
+ coder-firefly-cli insights expense --start 2024-01-01 --end 2024-01-31 --accounts "1,2"
320
+
321
+ # 按分类筛选洞察
322
+ coder-firefly-cli insights expense --start 2024-01-01 --end 2024-01-31 --categories "3,4"
323
+ ```
324
+
325
+ ### search - 搜索
326
+
327
+ ```bash
328
+ # 搜索交易
329
+ coder-firefly-cli search transactions --query "超市"
330
+
331
+ # 分页搜索
332
+ coder-firefly-cli search transactions --query "餐饮" --limit 10 --page 2
333
+ ```
334
+
335
+ ### info - 系统信息
336
+
337
+ ```bash
338
+ # 获取系统信息
339
+ coder-firefly-cli info about
340
+
341
+ # 检查连接状态
342
+ coder-firefly-cli info status
343
+ ```
344
+
345
+ ## JSON 输出
346
+
347
+ 所有命令都支持 `--json` 参数以结构化格式输出:
348
+
349
+ ```bash
350
+ # 查看账户列表的 JSON 输出
351
+ coder-firefly-cli --json accounts list
352
+
353
+ # 查看交易详情的 JSON 输出
354
+ coder-firefly-cli --json transactions get --id 456
355
+
356
+ # 查看洞察报告的 JSON 输出
357
+ coder-firefly-cli --json insights expense --start 2024-01-01 --end 2024-01-31
358
+ ```
359
+
360
+ JSON 输出便于脚本处理和数据分析,所有字段都以标准 JSON 格式返回。
361
+
362
+ ## 常见工作流示例
363
+
364
+ ### 查看账户余额
365
+
366
+ ```bash
367
+ # 1. 检查连接
368
+ coder-firefly-cli info status
369
+
370
+ # 2. 列出资产账户
371
+ coder-firefly-cli accounts list --type asset
372
+
373
+ # 3. 查看账户详情(获取余额)
374
+ coder-firefly-cli accounts get --id <account_id>
375
+ ```
376
+
377
+ ### 记录日常支出
378
+
379
+ ```bash
380
+ # 1. 查找支出账户
381
+ coder-firefly-cli accounts list --type expense
382
+
383
+ # 2. 创建支出交易
384
+ coder-firefly-cli transactions create \
385
+ --description "午餐" \
386
+ --amount 35.00 \
387
+ --source-account <asset_account_id> \
388
+ --category "餐饮" \
389
+ --tags "工作日"
390
+ ```
391
+
392
+ ### 月度财务报告
393
+
394
+ ```bash
395
+ # 1. 支出报告
396
+ coder-firefly-cli --json insights expense --start 2024-01-01 --end 2024-01-31
397
+
398
+ # 2. 收入报告
399
+ coder-firefly-cli --json insights income --start 2024-01-01 --end 2024-01-31
400
+
401
+ # 3. 搜索特定交易
402
+ coder-firefly-cli --json search transactions --query "超市" --start 2024-01-01 --end 2024-01-31
403
+ ```
404
+
405
+ ### 预算管理
406
+
407
+ ```bash
408
+ # 1. 创建预算
409
+ coder-firefly-cli budgets create --name "餐饮预算"
410
+
411
+ # 2. 设置预算限额
412
+ coder-firefly-cli budgets limit-create \
413
+ --budget-id 1 \
414
+ --amount 2000 \
415
+ --start 2024-01-01 \
416
+ --end 2024-01-31
417
+
418
+ # 3. 查看预算使用情况
419
+ coder-firefly-cli budgets limits --budget-id 1
420
+ ```
421
+
422
+ ## 故障排除
423
+
424
+ ### 连接失败
425
+
426
+ ```
427
+ 错误: 无法连接到 Firefly III 实例
428
+ ```
429
+
430
+ 检查:
431
+ 1. Firefly III 实例是否正在运行
432
+ 2. 基础 URL 是否正确(注意结尾不要带斜杠)
433
+ 3. 网络连接是否正常
434
+
435
+ ### 认证失败
436
+
437
+ ```
438
+ 错误: 认证失败: Personal Access Token 无效
439
+ ```
440
+
441
+ 检查:
442
+ 1. PAT 是否正确
443
+ 2. PAT 是否已过期
444
+ 3. 在 Firefly III 的 选项 > 个人资料 > OAuth 中生成新的 PAT
445
+
446
+ ### 数据格式问题
447
+
448
+ ```
449
+ 错误: 请求参数错误
450
+ ```
451
+
452
+ 检查:
453
+ 1. 金额是否为字符串格式(如 "100.00")
454
+ 2. 日期格式是否为 YYYY-MM-DD
455
+ 3. 必需参数是否都已提供
456
+
457
+ ### 资源未找到
458
+
459
+ ```
460
+ 错误: 资源未找到
461
+ ```
462
+
463
+ 检查:
464
+ 1. ID 是否正确
465
+ 2. 资源是否存在(可能已被删除)
466
+
467
+ ## 开发
468
+
469
+ ```bash
470
+ # 安装开发依赖
471
+ pip install -e ".[dev]"
472
+
473
+ # 运行测试
474
+ pytest
475
+
476
+ # 带覆盖率报告
477
+ pytest --cov=src
478
+
479
+ # 代码格式化
480
+ black src/
481
+ ```
482
+
483
+ ## 项目结构
484
+
485
+ ```
486
+ coder-firefly-cli/
487
+ ├── setup.py # 包安装配置
488
+ ├── requirements.txt # 依赖列表
489
+ ├── README.md # 项目文档
490
+ ├── SKILL.md # AI Agent Skill 文档
491
+ ├── .github/
492
+ │ └── workflows/
493
+ │ └── publish.yml # GitHub Actions 自动发布
494
+ └── src/
495
+ ├── api_client.py # Firefly III API 客户端
496
+ ├── cli.py # CLI 主入口
497
+ └── commands/ # 命令模块
498
+ ├── accounts.py
499
+ ├── bills.py
500
+ ├── budgets.py
501
+ ├── categories.py
502
+ ├── info.py
503
+ ├── insights.py
504
+ ├── piggy_banks.py
505
+ ├── search.py
506
+ ├── tags.py
507
+ └── transactions.py
508
+ ```
509
+
510
+ ## 许可证
511
+
512
+ MIT License