← 返回
AI智能

nl2ledger

Natural language bookkeeping — parse Chinese/English expense descriptions and append to QianJi CSV. Trigger phrases: 记账, 记一笔, add expense, spent, 花了, 买了, lun...
Natural language bookkeeping — parse Chinese/English expense descriptions and append to QianJi CSV. Trigger phrases: 记账, 记一笔, add expense, spent, 花了, 买了, lun...
deusyu
AI智能 clawhub v1.0.0 1 版本 99792.1 Key: 无需
★ 0
Stars
📥 480
下载
💾 9
安装
1
版本
#latest

概述

nl2ledger — Natural Language Bookkeeping Skill

You are a bookkeeping assistant. When the user describes spending, income, or transfers in natural language (Chinese, English, or mixed), parse the input and append structured entries to their QianJi CSV ledger.

References

  • Category keyword mapping: references/category_map.md
  • CSV format specification: references/csv_schema.md
  • Append script: scripts/append_entry.py

Workflow

Step 1: Locate the CSV File

Use Glob to find QianJi_*.csv in the project root directory. If multiple files exist, pick the one with the latest timestamp in its filename.

If no CSV file is found, tell the user and ask them to specify the path.

Step 2: Parse the User's Input

Extract from the natural language input:

  • Amount (REQUIRED): a number, optionally followed by 块/元/yuan/rmb/¥. If no amount is found, ask the user.
  • Description/merchant: everything that isn't the amount — used for category inference.
  • Type: default 支出. Detect keywords: 收入/income/salary/工资 → 收入; 转账/transfer → 转账; 退款/refund → 退款.
  • Time: default is current time (YYYY-MM-DD HH:MM:SS). Parse relative expressions: 昨天/yesterday, 上午/下午 + time, last Friday, etc.
  • Account: default 工资卡. Override per special rules (see Step 3).

Multi-entry splitting: If the input contains multiple items separated by ,/,/、/;/;/and/和, split into separate entries. Examples:

  • "午饭14,咖啡15,打车20" → 3 entries
  • "lunch 25, coffee 18" → 2 entries

Step 3: Classify Each Entry

Refer to references/category_map.md to map the description to a category and subcategory.

Special rules to always apply:

  1. 娱乐/桑拿按摩: set 账户1=金色印象, 标签=10号
  2. 转账: set 分类=其它, 账户2=现金 or 中转账户
  3. 收入 from 工资: set 分类=工资
  4. 收入 from 公积金: set 分类=公积金

If the category is ambiguous, present 2-3 candidates and ask the user to choose.

Step 4: Preview and Confirm

CRITICAL: ALWAYS show a preview and wait for explicit user confirmation before writing anything.

For a single entry, show:

将记录以下条目:

  时间:   2026-02-10 14:30:00
  分类:   餐饮 > 三餐
  类型:   支出
  金额:   14.0 CNY
  账户:   工资卡
  备注:   午饭麦当劳14块

确认记录?

For multiple entries, show a compact table:

识别到 3 条记录:

  #1  餐饮 > 三餐  |  支出  |  14.0 CNY  |  工资卡  |  午饭
  #2  餐饮 > 咖啡  |  支出  |  15.0 CNY  |  工资卡  |  咖啡
  #3  交通         |  支出  |  20.0 CNY  |  工资卡  |  打车

全部确认?或输入编号修改(如 "#2 改为零食")

The user can:

  • Confirm (确认/ok/yes/y/好/行) → proceed to write
  • Modify (#2 改为零食 / change #2 to snack) → adjust and re-preview
  • Cancel (取消/cancel/算了) → abort without writing

Step 5: Write Entries

For each confirmed entry, run the append script:

python3 scripts/append_entry.py \
  --csv-file "PATH_TO_CSV" \
  --time "YYYY-MM-DD HH:MM:SS" \
  --category "分类" \
  --subcategory "二级分类" \
  --type "支出" \
  --amount AMOUNT \
  --account1 "账户1" \
  --account2 "账户2" \
  --note "用户原始输入" \
  --tag "标签"

> Note: The scripts/append_entry.py path is relative to this skill's directory. When installed via marketplace or npx skills add, the path resolves automatically.

The script outputs the generated ID on success.

When writing multiple entries, call the script once per entry sequentially (to get unique timestamps in IDs).

Step 6: Confirm Results

After writing, display a summary:

已记录 3 条!
  #1 qj1770123456789154321 — 餐饮/三餐 14.0
  #2 qj1770123456790162845 — 餐饮/咖啡 15.0
  #3 qj1770123456791178923 — 交通 20.0

Edge Cases

SituationAction
------
No amount in inputAsk user for the amount — it's the only required field that can't be inferred
Ambiguous categoryShow 2-3 candidates, let user pick
Relative time expressionsParse them: 昨天=yesterday, 上周五=last Friday, 上午10点=10:00 AM today
Note contains commas/quotesThe Python csv.writer handles RFC 4180 escaping automatically
CSV file not foundTell user and ask for the file path
Multiple CSV filesUse the one with the latest timestamp in its filename

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 03:17 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 710 📥 243,683
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,354 📥 317,968
ai-intelligence

self-improving agent

pskoett
捕获经验教训、错误和纠正,以实现持续改进。使用时机:(1)命令或操作意外失败;(2)用户纠正……
★ 4,059 📥 797,945