chaimi-keep-mcp 3.1.40-beta.2 → 3.1.40-beta.4

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 +37 -6
  2. package/package.json +1 -1
  3. package/server.js +176 -21
package/SKILL.md CHANGED
@@ -205,7 +205,15 @@ get_statistics period="this_week"
205
205
 
206
206
  Agent **直接使用当前时间**作为消费时间,无需进行时间语义解析。
207
207
 
208
- **最终传入的 `date` 参数格式:**毫秒级时间戳(13位数字)⚠️ **重要:**必须根据实际年月日时分秒计算时间戳,示例格式:`YYYY-MM-DD HH:mm:ss` `[毫秒时间戳]`(北京时间),禁止使用示例中的具体数字,必须根据当前实际时间重新计算
208
+ **最终传入的 `date` 参数格式:**毫秒级时间戳(13位数字)⚠️ **⚠️ ⚠️ 重要 ⚠️ ⚠️ ⚠️**:
209
+
210
+ - **必须使用 date 命令计算时间戳,禁止手动填写或猜测**
211
+ - **强制使用以下命令:**
212
+ ```bash
213
+ date -j -f "%Y-%m-%d %H:%M:%S" "YYYY-MM-DD HH:MM:SS" +%s000
214
+ ```
215
+ - 如果未使用 date 命令计算,服务端将拒绝保存
216
+ - 示例格式:`2026-04-20 18:30:00` → `1776604200000`(北京时间),禁止使用示例中的具体数字,必须根据实际时间计算
209
217
 
210
218
  **必填字段:** `name`、`amount`、`category`、`date`
211
219
 
@@ -238,7 +246,15 @@ Agent **直接使用当前时间**作为收入时间,无需进行时间语义
238
246
 
239
247
  **必填字段:**
240
248
  - `store`:商家名称
241
- - `date`:毫秒时间戳(13位数字,格式:`[毫秒时间戳]`),小票上的真实消费时间,禁止使用示例中的具体数字,必须根据小票上的实际时间重新计算
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
+ - 禁止使用示例中的具体数字,必须根据小票上的实际时间重新计算
242
258
  - `totalAmount`:商品原价总和
243
259
  - `actualAmount`:实付金额(优惠后)
244
260
  - `originalAmount`:原价(优惠前)
@@ -277,21 +293,36 @@ Agent **直接使用当前时间**作为收入时间,无需进行时间语义
277
293
  ```
278
294
  ✅ 【商品名/店名】¥【金额】 已录入柴米AI记账。
279
295
 
280
- [自定义其他内容]
281
-
282
296
  【友好结束语】
283
- ------------
284
- chaimi-keep-mcp: v【版本号】
285
297
 
298
+ 消费洞察:【洞察内容】(可选)
299
+ -------------
300
+ chaimi-keep-mcp: v【版本号】
286
301
  ```
287
302
 
288
303
  **友好结束语参考:**
289
304
  - 餐饮类:用餐愉快!🍚 / 好好吃饭哦~
305
+ - 食品类:吃好喝好!🍎
290
306
  - 交通类:出行顺利!🚗
291
307
  - 购物类:买得开心!🛍️
292
308
  - 收入类:入账顺利!💰
293
309
  - 通用:记账完成!继续保持~ ✨
294
310
 
311
+ **消费洞察(可选):**
312
+ - 由云函数自动生成,返回记账后的即时洞察
313
+ - 示例:这是你本周第19次餐饮消费,要不要看看本周餐饮花了多少钱?
314
+
315
+ **真实示例:**
316
+ ```
317
+ ✅ 【肌肉】¥24 已录入柴米AI记账。
318
+
319
+ 好好吃饭哦~
320
+
321
+ 消费洞察:这是你本周第19次餐饮消费,要不要看看本周餐饮花了多少钱?
322
+ -------------
323
+ chaimi-keep-mcp: v3.1.40-beta.3
324
+ ```
325
+
295
326
  ---
296
327
 
297
328
  ## 错误处理
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chaimi-keep-mcp",
3
- "version": "3.1.40-beta.2",
3
+ "version": "3.1.40-beta.4",
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"';
@@ -958,9 +994,39 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
958
994
  const toolName = toolMapping[name];
959
995
  const mcpParams = convertParams(name, processedArgs);
960
996
  result = await callMcpHub(toolName, mcpParams, token);
961
-
997
+
962
998
  if (result.success) {
963
- userMessage = `📊 消费记录查询成功\n共找到 ${result.data?.length || 0} 条记录`;
999
+ const total = result.data?.total || 0;
1000
+ const items = result.data?.items || [];
1001
+ const patterns = result.data?.patterns || {};
1002
+
1003
+ // 构建友好的摘要信息
1004
+ let summary = `📊 消费记录查询成功\n\n`;
1005
+ summary += `📋 共找到 ${total} 条记录\n`;
1006
+
1007
+ // 高频商家
1008
+ if (patterns.highFrequencyStores && patterns.highFrequencyStores.length > 0) {
1009
+ const topStore = patterns.highFrequencyStores[0];
1010
+ summary += `🏪 高频商家:${topStore.store}(${topStore.count}次,均价¥${topStore.avgAmount})\n`;
1011
+ }
1012
+
1013
+ // 消费时间模式
1014
+ if (patterns.timePattern) {
1015
+ summary += `⏰ 消费高峰:${patterns.timePattern.peakTime}\n`;
1016
+ if (patterns.timePattern.lateNightCount > 0) {
1017
+ summary += `🌙 深夜消费:${patterns.timePattern.lateNightCount}次\n`;
1018
+ }
1019
+ }
1020
+
1021
+ // 异常消费
1022
+ if (patterns.unusualItems && patterns.unusualItems.length > 0) {
1023
+ const topUnusual = patterns.unusualItems[0];
1024
+ summary += `💡 大额消费:${topUnusual.name} ¥${topUnusual.amount}\n`;
1025
+ }
1026
+
1027
+ summary += `\n💡 提示:完整数据(含每笔明细、flags标记)请查看下方 JSON 数据`;
1028
+
1029
+ userMessage = summary;
964
1030
  }
965
1031
  break;
966
1032
  }
@@ -971,7 +1037,44 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
971
1037
  result = await callMcpHub(toolName, mcpParams, token);
972
1038
 
973
1039
  if (result.success) {
974
- userMessage = `📈 统计查询成功`;
1040
+ const data = result.data || {};
1041
+
1042
+ // 构建友好的统计摘要
1043
+ let summary = `📈 统计查询成功\n\n`;
1044
+ summary += `📅 周期:${data.periodDisplay || data.period || '未知'}\n`;
1045
+ summary += `💰 总支出:¥${data.totalAmount || 0}(${data.totalCount || 0}笔)\n`;
1046
+
1047
+ // 环比对比
1048
+ if (data.compare && data.compare.vsLastPeriod !== undefined) {
1049
+ const change = data.compare.vsLastPeriod;
1050
+ const emoji = change > 0 ? '📈' : change < 0 ? '📉' : '➡️';
1051
+ summary += `${emoji} 环比:${change > 0 ? '+' : ''}${change}%\n`;
1052
+ }
1053
+
1054
+ // 预算进度
1055
+ if (data.budget) {
1056
+ summary += `🎯 预算:已用¥${data.budget.used}/¥${data.budget.total}(${data.budget.progress}%)\n`;
1057
+ }
1058
+
1059
+ // Top 3 分类
1060
+ if (data.categories && data.categories.length > 0) {
1061
+ summary += `\n📂 消费分类 Top3:\n`;
1062
+ data.categories.slice(0, 3).forEach((cat, idx) => {
1063
+ summary += ` ${idx + 1}. ${cat.category}:¥${cat.amount}(${cat.percentage}%)\n`;
1064
+ });
1065
+ }
1066
+
1067
+ // 洞察摘要
1068
+ if (data.insights && data.insights.length > 0) {
1069
+ summary += `\n💡 洞察线索(${data.insights.length}条):\n`;
1070
+ data.insights.slice(0, 3).forEach(insight => {
1071
+ summary += ` ${insight.emoji || '•'} ${insight.title}:${insight.message}\n`;
1072
+ });
1073
+ }
1074
+
1075
+ summary += `\n💡 提示:完整数据(含每日统计、所有洞察)请查看下方 JSON 数据`;
1076
+
1077
+ userMessage = summary;
975
1078
  }
976
1079
  break;
977
1080
  }
@@ -982,8 +1085,42 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
982
1085
  result = await callMcpHub(toolName, mcpParams, token);
983
1086
 
984
1087
  if (result.success) {
985
- const insightsCount = result.data?.insights?.length || 0;
986
- userMessage = `🔍 消费洞察获取成功\n共找到 ${insightsCount} 条洞察线索,供你进行深度分析!`;
1088
+ const data = result.data || {};
1089
+ const insights = data.insights || [];
1090
+
1091
+ // 构建友好的洞察摘要
1092
+ let summary = `🔍 消费洞察获取成功\n\n`;
1093
+ summary += `📅 周期:${data.periodDisplay || data.period || '未知'}\n`;
1094
+ summary += `💡 共找到 ${insights.length} 条洞察线索\n`;
1095
+
1096
+ if (insights.length > 0) {
1097
+ // 按优先级分组
1098
+ const highPriority = insights.filter(i => i.priority === 'high');
1099
+ const mediumPriority = insights.filter(i => i.priority === 'medium');
1100
+ const lowPriority = insights.filter(i => i.priority === 'low');
1101
+
1102
+ if (highPriority.length > 0) {
1103
+ summary += `\n🔴 高优先级(${highPriority.length}条):\n`;
1104
+ highPriority.forEach(insight => {
1105
+ summary += ` ${insight.emoji || '•'} ${insight.title}:${insight.message}\n`;
1106
+ });
1107
+ }
1108
+
1109
+ if (mediumPriority.length > 0) {
1110
+ summary += `\n🟡 中优先级(${mediumPriority.length}条):\n`;
1111
+ mediumPriority.slice(0, 2).forEach(insight => {
1112
+ summary += ` ${insight.emoji || '•'} ${insight.title}:${insight.message}\n`;
1113
+ });
1114
+ }
1115
+
1116
+ if (lowPriority.length > 0) {
1117
+ summary += `\n🟢 低优先级(${lowPriority.length}条)\n`;
1118
+ }
1119
+ }
1120
+
1121
+ summary += `\n💡 提示:每条洞察都包含 suggestionForAgent 字段,可用于深度分析`;
1122
+
1123
+ userMessage = summary;
987
1124
  }
988
1125
  break;
989
1126
  }
@@ -994,9 +1131,20 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
994
1131
  result = await callMcpHub(toolName, mcpParams, token);
995
1132
 
996
1133
  if (result.success) {
997
- const totalRecords = result.data?.summary?.totalRecords || 0;
998
- const totalAmount = result.data?.summary?.totalAmount || 0;
999
- userMessage = `📦 数据导出成功\n共导出 ${totalRecords} 条记录,总金额 ${totalAmount} 元\n数据已准备好,你可以使用大模型进行深度分析了!`;
1134
+ const summary = result.data?.summary || {};
1135
+ const totalRecords = summary.totalRecords || 0;
1136
+ const totalAmount = summary.totalAmount || 0;
1137
+ const periodDisplay = result.data?.periodDisplay || '';
1138
+
1139
+ let summaryText = `📦 数据导出完成\n\n`;
1140
+ if (periodDisplay) {
1141
+ summaryText += `📅 周期:${periodDisplay}\n`;
1142
+ }
1143
+ summaryText += `📊 导出记录数:${totalRecords}条\n`;
1144
+ summaryText += `💰 总金额:¥${totalAmount.toFixed ? totalAmount.toFixed(2) : totalAmount}\n`;
1145
+ summaryText += `\n✅ 完整数据已准备好,你可以使用自己的大模型进行深度分析了!\n(完整数据在下方的完整数据JSON中)`;
1146
+
1147
+ userMessage = summaryText;
1000
1148
  }
1001
1149
  break;
1002
1150
  }
@@ -1037,11 +1185,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1037
1185
  result = await callMcpHub('addIncome', mcpParams, token);
1038
1186
 
1039
1187
  if (result.success) {
1040
- const displayName = processedArgs.name;
1041
- const displayAmount = processedArgs.amount;
1042
- const displayCategory = processedArgs.category;
1043
- const displayStore = processedArgs.store || '-';
1044
- 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}`;
1045
1195
  }
1046
1196
  break;
1047
1197
  }
@@ -1129,13 +1279,18 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1129
1279
  userMessage = `❌ 操作失败:${result.error || '未知错误'}`;
1130
1280
  }
1131
1281
 
1132
- userMessage += `\n\n---\n📦 柴米记账 MCP v${MCP_VERSION}`;
1282
+ // 构建完整的返回内容:userMessage + 完整的 result 数据
1283
+ const fullResponse = {
1284
+ userMessage: userMessage,
1285
+ result: result,
1286
+ mcp_version: MCP_VERSION
1287
+ };
1133
1288
 
1134
1289
  return {
1135
1290
  content: [
1136
1291
  {
1137
1292
  type: 'text',
1138
- text: userMessage,
1293
+ text: `${userMessage}\n\n---\n📦 柴米记账 MCP v${MCP_VERSION}\n\n## 完整数据\n\`\`\`json\n${JSON.stringify(result, null, 2)}\n\`\`\``,
1139
1294
  },
1140
1295
  ],
1141
1296
  };