chaimi-keep-mcp 3.1.40-beta.3 → 3.1.40

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 (3) hide show
  1. package/SKILL.md +42 -30
  2. package/package.json +1 -1
  3. package/server.js +49 -11
package/SKILL.md CHANGED
@@ -213,9 +213,7 @@ Agent **直接使用当前时间**作为消费时间,无需进行时间语义
213
213
  date -j -f "%Y-%m-%d %H:%M:%S" "YYYY-MM-DD HH:MM:SS" +%s000
214
214
  ```
215
215
  - 如果未使用 date 命令计算,服务端将拒绝保存
216
- - 示例格式:`2026-04-20 18:30:00` → `1776604200000`(北京时间),禁止使用示例中的具体数字,必须根据实际时间计算
217
-
218
- **必填字段:** `name`、`amount`、`category`、`date`
216
+ - 示例格式:`YYYY-MM-DD HH:mm:ss` → `[毫秒时间戳]`(北京时间),禁止使用示例中的具体数字,必须根据当前实际时间重新计算
219
217
 
220
218
  ---
221
219
 
@@ -228,11 +226,17 @@ Agent **直接使用当前时间**作为消费时间,无需进行时间语义
228
226
 
229
227
  **时间处理规则:**
230
228
 
231
- Agent **直接使用当前时间**作为收入时间,无需进行时间语义解析。
229
+ Agent **直接使用当前时间**作为消费时间,无需进行时间语义解析。
232
230
 
233
- **最终传入的 `date` 参数格式:**毫秒级时间戳(13位数字)⚠️ **重要:**必须根据实际年月日时分秒计算时间戳,示例格式:`YYYY-MM-DD HH:mm:ss` `[毫秒时间戳]`(北京时间),禁止使用示例中的具体数字,必须根据当前实际时间重新计算
231
+ **最终传入的 `date` 参数格式:**毫秒级时间戳(13位数字)⚠️ **⚠️ ⚠️ 重要 ⚠️ ⚠️ ⚠️**:
234
232
 
235
- **必填字段:** `name`、`amount`、`category`、`date`
233
+ - **必须使用 date 命令计算时间戳,禁止手动填写或猜测**
234
+ - **强制使用以下命令:**
235
+ ```bash
236
+ date -j -f "%Y-%m-%d %H:%M:%S" "YYYY-MM-DD HH:MM:SS" +%s000
237
+ ```
238
+ - 如果未使用 date 命令计算,服务端将拒绝保存
239
+ - 示例格式:`YYYY-MM-DD HH:mm:ss` → `[毫秒时间戳]`(北京时间),禁止使用示例中的具体数字,必须根据当前实际时间重新计算
236
240
 
237
241
  ---
238
242
 
@@ -244,26 +248,19 @@ Agent **直接使用当前时间**作为收入时间,无需进行时间语义
244
248
  3. **字段核对**:确保所有解析结果字段都传给 `save_receipt`
245
249
  4. 调用 `save_receipt` 保存
246
250
 
247
- **必填字段:**
248
- - `store`:商家名称
249
- - `date`:毫秒时间戳(13位数字,格式:`[毫秒时间戳]`),小票上的真实消费时间,⚠️ **⚠️ ⚠️ 重要 ⚠️ ⚠️ ⚠️**:
250
-
251
- - **必须使用 date 命令计算时间戳,禁止手动填写或猜测**
252
- - **强制使用以下命令:**
253
- ```bash
254
- date -j -f "%Y-%m-%d %H:%M:%S" "YYYY-MM-DD HH:MM:SS" +%s000
255
- ```
256
- - 如果未使用 date 命令计算,服务端将拒绝保存
257
- - 禁止使用示例中的具体数字,必须根据小票上的实际时间重新计算
258
- - `totalAmount`:商品原价总和
259
- - `actualAmount`:实付金额(优惠后)
260
- - `originalAmount`:原价(优惠前)
261
- - `discountAmount`:优惠金额
262
- - `items`:商品数组,每个商品必须有 `name`、`amount`、`price`、`quantity`、`category`
263
- - `category`:主分类(如:蔬菜、肉类、水果、水产,常见超市购物分类)
264
- - `subCategory`:子分类(如:叶菜类、根茎类、猪肉类,超市细分类目),推荐填写
265
- - `unit`:计价单位(如:元/500g、元/个、元/盒、元/袋)
266
- - `marketPrice`:单价,根据 unit 计算,如 unit=元/500g,则 marketPrice=金额÷重量(g)×500
251
+ **时间处理规则:**
252
+
253
+ Agent **直接使用当前时间**作为消费时间,无需进行时间语义解析。
254
+
255
+ **最终传入的 `date` 参数格式:**毫秒级时间戳(13位数字)⚠️ **⚠️ ⚠️ 重要 ⚠️ ⚠️ ⚠️**:
256
+
257
+ - **必须使用 date 命令计算时间戳,禁止手动填写或猜测**
258
+ - **强制使用以下命令:**
259
+ ```bash
260
+ date -j -f "%Y-%m-%d %H:%M:%S" "YYYY-MM-DD HH:MM:SS" +%s000
261
+ ```
262
+ - 如果未使用 date 命令计算,服务端将拒绝保存
263
+ - 示例格式:`YYYY-MM-DD HH:mm:ss` → `[毫秒时间戳]`(北京时间),禁止使用示例中的具体数字,必须根据当前实际时间重新计算
267
264
 
268
265
  ---
269
266
 
@@ -293,21 +290,36 @@ Agent **直接使用当前时间**作为收入时间,无需进行时间语义
293
290
  ```
294
291
  ✅ 【商品名/店名】¥【金额】 已录入柴米AI记账。
295
292
 
296
- [自定义其他内容]
297
-
298
293
  【友好结束语】
299
- ------------
300
- chaimi-keep-mcp: v【版本号】
301
294
 
295
+ 消费洞察:【洞察内容】(可选)
296
+ -------------
297
+ chaimi-keep-mcp: v【版本号】
302
298
  ```
303
299
 
304
300
  **友好结束语参考:**
305
301
  - 餐饮类:用餐愉快!🍚 / 好好吃饭哦~
302
+ - 食品类:吃好喝好!🍎
306
303
  - 交通类:出行顺利!🚗
307
304
  - 购物类:买得开心!🛍️
308
305
  - 收入类:入账顺利!💰
309
306
  - 通用:记账完成!继续保持~ ✨
310
307
 
308
+ **消费洞察(可选):**
309
+ - 由云函数自动生成,返回记账后的即时洞察
310
+ - 示例:这是你本周第19次餐饮消费,要不要看看本周餐饮花了多少钱?
311
+
312
+ **真实示例:**
313
+ ```
314
+ ✅ 【肌肉】¥24 已录入柴米AI记账。
315
+
316
+ 好好吃饭哦~
317
+
318
+ 消费洞察:这是你本周第19次餐饮消费,要不要看看本周餐饮花了多少钱?
319
+ -------------
320
+ chaimi-keep-mcp: v3.1.40-beta.3
321
+ ```
322
+
311
323
  ---
312
324
 
313
325
  ## 错误处理
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chaimi-keep-mcp",
3
- "version": "3.1.40-beta.3",
3
+ "version": "3.1.40",
4
4
  "description": "柴米记账 MCP Server - 支持 Claude、Cursor、OpenClaw、WorkBuddy 等 AI 工具直接记账",
5
5
  "main": "server.js",
6
6
  "bin": {
package/server.js CHANGED
@@ -702,8 +702,28 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
702
702
  const displayName = processedArgs.name || '未知商品';
703
703
  const displayAmount = processedArgs.amount || 0;
704
704
  const displayCategory = processedArgs.category || '其他';
705
- const displayStore = processedArgs.store || '-';
706
- userMessage = `✅ 记账成功\n\n| 商品 | 金额 | 分类 | 商家 |\n|------|------|------|------|\n| ${displayName} | ${displayAmount}元 | ${displayCategory} | ${displayStore} |\n\n已保存到你的柴米记账小程序数据库。`;
705
+ const displayStore = processedArgs.store || '';
706
+
707
+ // 友好结束语(根据分类)
708
+ const friendlyEndings = {
709
+ '餐饮': '用餐愉快!🍚 / 好好吃饭哦~',
710
+ '食品': '吃好喝好!🍎',
711
+ '交通': '出行顺利!🚗',
712
+ '购物': '买得开心!🛍️',
713
+ '收入': '入账顺利!💰',
714
+ '其他': '记账完成!继续保持~ ✨'
715
+ };
716
+ const friendlyEnding = friendlyEndings[displayCategory] || '记账完成!继续保持~ ✨';
717
+
718
+ // 消费洞察(如果有)
719
+ let insightsText = '';
720
+ if (result.insights && result.insights.length > 0) {
721
+ insightsText = '\n\n消费洞察:' + result.insights.map(ins => ins.message || ins.title).join(';');
722
+ }
723
+
724
+ // 按 SKILL 规范格式:记账成功 + 友好结束语 + 消费洞察 + 版本号
725
+ const displayStoreText = displayStore ? `【${displayStore}】` : '';
726
+ userMessage = `✅ ${displayName}${displayStoreText} ¥${displayAmount} 已录入柴米AI记账。\n\n${friendlyEnding}${insightsText}\n-------------\nchaimi-keep-mcp: v${MCP_VERSION}`;
707
727
 
708
728
  if (!processedArgs.agentType || !processedArgs.apiProvider) {
709
729
  userMessage += '\n\n💡 提示:传递agentType和apiProvider参数可解锁小程序记录来源统计功能,示例:agentType="openclaw", apiProvider="doubao"';
@@ -941,10 +961,26 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
941
961
 
942
962
  if (result.success) {
943
963
  const totalAmount = processedArgs.totalAmount || processedArgs.items?.reduce((sum, item) => sum + (item.amount || 0), 0) || 0;
944
- const itemsList = processedArgs.items?.map(item => `• ${item.name || '未知商品'} - ${item.amount || 0}元`).join('\n') || '暂无商品明细';
945
- const storeName = processedArgs.store || '-';
946
- const category = processedArgs.items?.[0]?.category || '其他';
947
- userMessage = `✅ 小票记录成功\n\n| 项目 | 内容 |\n|------|------|\n| 商家 | ${storeName} |\n| 金额 | ${totalAmount}元 |\n| 分类 | ${category} |\n\n商品明细:\n${itemsList}\n\n已保存到你的柴米记账小程序数据库。`;
964
+ const storeName = processedArgs.store || '';
965
+ const category = processedArgs.items?.[0]?.category || '购物';
966
+ const itemCount = processedArgs.items?.length || 0;
967
+
968
+ // 友好结束语(根据分类)
969
+ const friendlyEndings = {
970
+ '餐饮': '用餐愉快!🍚',
971
+ '食品': '吃好喝好!🍎',
972
+ '购物': '买得开心!🛍️',
973
+ '其他': '记账完成!继续保持~ ✨'
974
+ };
975
+ const friendlyEnding = friendlyEndings[category] || '买得开心!🛍️';
976
+
977
+ // 消费洞察(如果有)
978
+ let insightsText = '';
979
+ if (result.insights && result.insights.length > 0) {
980
+ insightsText = '\n\n消费洞察:' + result.insights.map(ins => ins.message || ins.title).join(';');
981
+ }
982
+
983
+ userMessage = `✅ ${storeName} ¥${totalAmount} 已录入柴米AI记账(${itemCount}件商品)。\n\n${friendlyEnding}${insightsText}\n-------------\nchaimi-keep-mcp: v${MCP_VERSION}`;
948
984
 
949
985
  if (!processedArgs.agentType || !processedArgs.apiProvider) {
950
986
  userMessage += '\n\n💡 提示:传递agentType和apiProvider参数可解锁小程序记录来源统计功能,示例:agentType="openclaw", apiProvider="doubao"';
@@ -1149,11 +1185,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1149
1185
  result = await callMcpHub('addIncome', mcpParams, token);
1150
1186
 
1151
1187
  if (result.success) {
1152
- const displayName = processedArgs.name;
1153
- const displayAmount = processedArgs.amount;
1154
- const displayCategory = processedArgs.category;
1155
- const displayStore = processedArgs.store || '-';
1156
- userMessage = `✅ 收入记录成功\n\n| 来源 | 金额 | 分类 | 付款方 |\n|------|------|------|--------|\n| ${displayName} | ${displayAmount}元 | ${displayCategory} | ${displayStore} |`;
1188
+ const displayName = processedArgs.name || '未知收入';
1189
+ const displayAmount = processedArgs.amount || 0;
1190
+ const displayCategory = processedArgs.category || '其他';
1191
+ const displayStore = processedArgs.store || '';
1192
+ const displayStoreText = displayStore ? `【${displayStore}】` : '';
1193
+
1194
+ userMessage = `✅ ${displayName}${displayStoreText} ¥${displayAmount} 已录入柴米AI记账。\n\n入账顺利!💰\n-------------\nchaimi-keep-mcp: v${MCP_VERSION}`;
1157
1195
  }
1158
1196
  break;
1159
1197
  }