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

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 +56 -13
  2. package/package.json +1 -1
  3. package/server.js +127 -10
package/SKILL.md CHANGED
@@ -84,15 +84,9 @@ Agent 必须输出:
84
84
  为数据安全起见,我已暂停记账操作。
85
85
 
86
86
  请开启新会话后重新触发记账。
87
- ```
88
87
 
89
- Agent 根据当前环境,向用户说明开启新会话的具体操作方式:
90
- - **Cursor**: 按 `Cmd+N` (Mac) / `Ctrl+N` (Windows)
91
- - **Claude Desktop**: 点击 `+ New Chat`
92
- - **OpenClaw**: 输入 `/new`
93
- - **WorkBuddy**: 输入 `/clear`
94
- - **Trae**: 按 `Cmd/Ctrl + N` 或点击 `+` 按钮
95
- - **其他**: 输入 `/new` 或菜单"新建会话"
88
+ (操作方式见上方「遇到问题时-方案1」)
89
+ ```
96
90
 
97
91
  ---
98
92
 
@@ -157,14 +151,45 @@ Agent 根据当前环境,向用户说明开启新会话的具体操作方式
157
151
  - **save_income** - 文字记账(收入)
158
152
  - **save_receipt** - 小票记账(需先调用 get_parse_prompt)
159
153
 
154
+ ### 智能查询工具(新功能)
155
+ - **get_insights** - 【推荐使用】获取消费洞察(零AI成本!)
156
+ - 返回消费趋势、模式、优化建议
157
+ - 让 Agent 结合用户的大模型分析
158
+ - **export_data** - 【深度分析用】导出完整消费数据
159
+ - 用于 Agent 深度分析
160
+ - **get_statistics** - 获取消费统计(支持周/月周期!)
161
+ - 新增 `period` 参数:支持 `this_week`、`last_week`、`this_month`、`last_month`
162
+
160
163
  ### 辅助工具
161
164
  - **get_skill** - 【记账前必须调用】获取 Skill 文档
162
165
  - **get_parse_prompt** - 获取小票解析模板
163
- - **get_expenses** - 查询支出记录
166
+ - **get_expenses** - 查询支出记录(支持周/月周期!)
167
+ - 新增 `period` 参数:支持 `this_week`、`last_week`、`this_month`、`last_month`
164
168
  - **get_receipt_list** - 查询小票列表
165
- - **get_statistics** - 获取统计信息
166
169
  - **submit_feedback** - 提交反馈
167
170
 
171
+ ---
172
+
173
+ ## 📊 场景说明(智能分析)
174
+
175
+ ### 场景 1:用户问「帮我看看这周花了多少钱」
176
+ **推荐工具:`get_statistics` 搭配 `period: this_week`**
177
+ 参数示例:
178
+ ```
179
+ get_statistics period="this_week"
180
+ ```
181
+
182
+ ### 场景 2:用户问「分析一下消费习惯」
183
+ **推荐工具:`get_insights` + `export_data`**
184
+ 1. 先用 `get_insights` 获取洞察
185
+ 2. 再用 `export_data` 获取完整数据
186
+ 3. 用用户的大模型进行深度分析
187
+
188
+ ### 场景 3:用户问「最近的消费记录」
189
+ **推荐工具:`get_expenses`**
190
+ - 也可以搭配 `period: this_week` 使用
191
+
192
+
168
193
  ---
169
194
 
170
195
  ## 工具详细说明
@@ -180,7 +205,15 @@ Agent 根据当前环境,向用户说明开启新会话的具体操作方式
180
205
 
181
206
  Agent **直接使用当前时间**作为消费时间,无需进行时间语义解析。
182
207
 
183
- **最终传入的 `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`(北京时间),禁止使用示例中的具体数字,必须根据实际时间计算
184
217
 
185
218
  **必填字段:** `name`、`amount`、`category`、`date`
186
219
 
@@ -213,7 +246,15 @@ Agent **直接使用当前时间**作为收入时间,无需进行时间语义
213
246
 
214
247
  **必填字段:**
215
248
  - `store`:商家名称
216
- - `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
+ - 禁止使用示例中的具体数字,必须根据小票上的实际时间重新计算
217
258
  - `totalAmount`:商品原价总和
218
259
  - `actualAmount`:实付金额(优惠后)
219
260
  - `originalAmount`:原价(优惠前)
@@ -254,8 +295,10 @@ Agent **直接使用当前时间**作为收入时间,无需进行时间语义
254
295
 
255
296
  [自定义其他内容]
256
297
 
257
- MCP Server: v【版本号】
258
298
  【友好结束语】
299
+ ------------
300
+ chaimi-keep-mcp: v【版本号】
301
+
259
302
  ```
260
303
 
261
304
  **友好结束语参考:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chaimi-keep-mcp",
3
- "version": "3.1.40-beta.1",
3
+ "version": "3.1.40-beta.3",
4
4
  "description": "柴米记账 MCP Server - 支持 Claude、Cursor、OpenClaw、WorkBuddy 等 AI 工具直接记账",
5
5
  "main": "server.js",
6
6
  "bin": {
package/server.js CHANGED
@@ -958,9 +958,39 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
958
958
  const toolName = toolMapping[name];
959
959
  const mcpParams = convertParams(name, processedArgs);
960
960
  result = await callMcpHub(toolName, mcpParams, token);
961
-
961
+
962
962
  if (result.success) {
963
- userMessage = `📊 消费记录查询成功\n共找到 ${result.data?.length || 0} 条记录`;
963
+ const total = result.data?.total || 0;
964
+ const items = result.data?.items || [];
965
+ const patterns = result.data?.patterns || {};
966
+
967
+ // 构建友好的摘要信息
968
+ let summary = `📊 消费记录查询成功\n\n`;
969
+ summary += `📋 共找到 ${total} 条记录\n`;
970
+
971
+ // 高频商家
972
+ if (patterns.highFrequencyStores && patterns.highFrequencyStores.length > 0) {
973
+ const topStore = patterns.highFrequencyStores[0];
974
+ summary += `🏪 高频商家:${topStore.store}(${topStore.count}次,均价¥${topStore.avgAmount})\n`;
975
+ }
976
+
977
+ // 消费时间模式
978
+ if (patterns.timePattern) {
979
+ summary += `⏰ 消费高峰:${patterns.timePattern.peakTime}\n`;
980
+ if (patterns.timePattern.lateNightCount > 0) {
981
+ summary += `🌙 深夜消费:${patterns.timePattern.lateNightCount}次\n`;
982
+ }
983
+ }
984
+
985
+ // 异常消费
986
+ if (patterns.unusualItems && patterns.unusualItems.length > 0) {
987
+ const topUnusual = patterns.unusualItems[0];
988
+ summary += `💡 大额消费:${topUnusual.name} ¥${topUnusual.amount}\n`;
989
+ }
990
+
991
+ summary += `\n💡 提示:完整数据(含每笔明细、flags标记)请查看下方 JSON 数据`;
992
+
993
+ userMessage = summary;
964
994
  }
965
995
  break;
966
996
  }
@@ -971,7 +1001,44 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
971
1001
  result = await callMcpHub(toolName, mcpParams, token);
972
1002
 
973
1003
  if (result.success) {
974
- userMessage = `📈 统计查询成功`;
1004
+ const data = result.data || {};
1005
+
1006
+ // 构建友好的统计摘要
1007
+ let summary = `📈 统计查询成功\n\n`;
1008
+ summary += `📅 周期:${data.periodDisplay || data.period || '未知'}\n`;
1009
+ summary += `💰 总支出:¥${data.totalAmount || 0}(${data.totalCount || 0}笔)\n`;
1010
+
1011
+ // 环比对比
1012
+ if (data.compare && data.compare.vsLastPeriod !== undefined) {
1013
+ const change = data.compare.vsLastPeriod;
1014
+ const emoji = change > 0 ? '📈' : change < 0 ? '📉' : '➡️';
1015
+ summary += `${emoji} 环比:${change > 0 ? '+' : ''}${change}%\n`;
1016
+ }
1017
+
1018
+ // 预算进度
1019
+ if (data.budget) {
1020
+ summary += `🎯 预算:已用¥${data.budget.used}/¥${data.budget.total}(${data.budget.progress}%)\n`;
1021
+ }
1022
+
1023
+ // Top 3 分类
1024
+ if (data.categories && data.categories.length > 0) {
1025
+ summary += `\n📂 消费分类 Top3:\n`;
1026
+ data.categories.slice(0, 3).forEach((cat, idx) => {
1027
+ summary += ` ${idx + 1}. ${cat.category}:¥${cat.amount}(${cat.percentage}%)\n`;
1028
+ });
1029
+ }
1030
+
1031
+ // 洞察摘要
1032
+ if (data.insights && data.insights.length > 0) {
1033
+ summary += `\n💡 洞察线索(${data.insights.length}条):\n`;
1034
+ data.insights.slice(0, 3).forEach(insight => {
1035
+ summary += ` ${insight.emoji || '•'} ${insight.title}:${insight.message}\n`;
1036
+ });
1037
+ }
1038
+
1039
+ summary += `\n💡 提示:完整数据(含每日统计、所有洞察)请查看下方 JSON 数据`;
1040
+
1041
+ userMessage = summary;
975
1042
  }
976
1043
  break;
977
1044
  }
@@ -982,8 +1049,42 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
982
1049
  result = await callMcpHub(toolName, mcpParams, token);
983
1050
 
984
1051
  if (result.success) {
985
- const insightsCount = result.data?.insights?.length || 0;
986
- userMessage = `🔍 消费洞察获取成功\n共找到 ${insightsCount} 条洞察线索,供你进行深度分析!`;
1052
+ const data = result.data || {};
1053
+ const insights = data.insights || [];
1054
+
1055
+ // 构建友好的洞察摘要
1056
+ let summary = `🔍 消费洞察获取成功\n\n`;
1057
+ summary += `📅 周期:${data.periodDisplay || data.period || '未知'}\n`;
1058
+ summary += `💡 共找到 ${insights.length} 条洞察线索\n`;
1059
+
1060
+ if (insights.length > 0) {
1061
+ // 按优先级分组
1062
+ const highPriority = insights.filter(i => i.priority === 'high');
1063
+ const mediumPriority = insights.filter(i => i.priority === 'medium');
1064
+ const lowPriority = insights.filter(i => i.priority === 'low');
1065
+
1066
+ if (highPriority.length > 0) {
1067
+ summary += `\n🔴 高优先级(${highPriority.length}条):\n`;
1068
+ highPriority.forEach(insight => {
1069
+ summary += ` ${insight.emoji || '•'} ${insight.title}:${insight.message}\n`;
1070
+ });
1071
+ }
1072
+
1073
+ if (mediumPriority.length > 0) {
1074
+ summary += `\n🟡 中优先级(${mediumPriority.length}条):\n`;
1075
+ mediumPriority.slice(0, 2).forEach(insight => {
1076
+ summary += ` ${insight.emoji || '•'} ${insight.title}:${insight.message}\n`;
1077
+ });
1078
+ }
1079
+
1080
+ if (lowPriority.length > 0) {
1081
+ summary += `\n🟢 低优先级(${lowPriority.length}条)\n`;
1082
+ }
1083
+ }
1084
+
1085
+ summary += `\n💡 提示:每条洞察都包含 suggestionForAgent 字段,可用于深度分析`;
1086
+
1087
+ userMessage = summary;
987
1088
  }
988
1089
  break;
989
1090
  }
@@ -994,9 +1095,20 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
994
1095
  result = await callMcpHub(toolName, mcpParams, token);
995
1096
 
996
1097
  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数据已准备好,你可以使用大模型进行深度分析了!`;
1098
+ const summary = result.data?.summary || {};
1099
+ const totalRecords = summary.totalRecords || 0;
1100
+ const totalAmount = summary.totalAmount || 0;
1101
+ const periodDisplay = result.data?.periodDisplay || '';
1102
+
1103
+ let summaryText = `📦 数据导出完成\n\n`;
1104
+ if (periodDisplay) {
1105
+ summaryText += `📅 周期:${periodDisplay}\n`;
1106
+ }
1107
+ summaryText += `📊 导出记录数:${totalRecords}条\n`;
1108
+ summaryText += `💰 总金额:¥${totalAmount.toFixed ? totalAmount.toFixed(2) : totalAmount}\n`;
1109
+ summaryText += `\n✅ 完整数据已准备好,你可以使用自己的大模型进行深度分析了!\n(完整数据在下方的完整数据JSON中)`;
1110
+
1111
+ userMessage = summaryText;
1000
1112
  }
1001
1113
  break;
1002
1114
  }
@@ -1129,13 +1241,18 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1129
1241
  userMessage = `❌ 操作失败:${result.error || '未知错误'}`;
1130
1242
  }
1131
1243
 
1132
- userMessage += `\n\n---\n📦 柴米记账 MCP v${MCP_VERSION}`;
1244
+ // 构建完整的返回内容:userMessage + 完整的 result 数据
1245
+ const fullResponse = {
1246
+ userMessage: userMessage,
1247
+ result: result,
1248
+ mcp_version: MCP_VERSION
1249
+ };
1133
1250
 
1134
1251
  return {
1135
1252
  content: [
1136
1253
  {
1137
1254
  type: 'text',
1138
- text: userMessage,
1255
+ text: `${userMessage}\n\n---\n📦 柴米记账 MCP v${MCP_VERSION}\n\n## 完整数据\n\`\`\`json\n${JSON.stringify(result, null, 2)}\n\`\`\``,
1139
1256
  },
1140
1257
  ],
1141
1258
  };