chaimi-keep-mcp 3.1.49-beta.0 → 3.1.49-beta.2

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/README.md +25 -0
  2. package/package.json +1 -1
  3. package/server.js +73 -4
package/README.md CHANGED
@@ -148,6 +148,31 @@ AI 会自动调用 `save_income` 工具记录收入。
148
148
 
149
149
  ## 更新日志
150
150
 
151
+ ### v3.1.49-beta.2 (2026-04-24)
152
+ - **新增** period 参数支持
153
+ - getStatistics: 支持 this_week/last_week/this_month/last_month 周期筛选
154
+ - getExpenses: 支持 this_week/last_week/this_month/last_month 周期筛选
155
+ - 自动将周期转换为开始/结束日期
156
+
157
+ ### v3.1.49-beta.0 (2026-04-24)
158
+ - **修复** category 未定义错误(三个记账函数)
159
+ - save_expense: `category` → `displayCategory`
160
+ - save_receipt: `storeCategory` → `category`
161
+ - save_income: `category` → `displayCategory`
162
+ - **优化** 回复格式排版
163
+ - Agent 名称用「」包裹:`「你的小可爱」`
164
+ - 分隔符从 emoji 换成实心点 `·`
165
+ - 更简洁清晰的视觉层次
166
+
167
+ ### v3.1.48 (2026-04-24)
168
+ - **优化** 回复格式模板
169
+ - 添加缩进层级,主次信息更清晰
170
+ - 所有记账工具回复添加 4 空格缩进
171
+ - 新增 Agent 名称说明,支持自定义名称显示
172
+ - **完善** SKILL.md 文档
173
+ - 扩充友好结束语参考,按分类给出更多正能量表达
174
+ - 详细说明未授权处理流程
175
+
151
176
  ### v3.1.46-beta.0 (2026-04-22)
152
177
  - **修复** 授权流程阻塞问题:恢复到 v3.1.37 之前的非阻塞模式
153
178
  - 移除 `startAuthFlowAndWait()` 和 `waitForAuthWithPolling()` 阻塞函数
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chaimi-keep-mcp",
3
- "version": "3.1.49-beta.0",
3
+ "version": "3.1.49-beta.2",
4
4
  "description": "柴米记账 MCP Server - 支持 Claude、Cursor、OpenClaw、WorkBuddy 等 AI 工具直接记账",
5
5
  "main": "server.js",
6
6
  "bin": {
package/server.js CHANGED
@@ -1909,18 +1909,29 @@ function convertParams(toolName, args) {
1909
1909
  };
1910
1910
  }
1911
1911
 
1912
- case 'get_expenses':
1912
+ case 'get_expenses': {
1913
+ // 【新增】支持 period 参数
1914
+ const periodDates = args.period ? parsePeriod(args.period) : {};
1913
1915
  return {
1916
+ startDate: periodDates.startDate || args.startDate,
1917
+ endDate: periodDates.endDate || args.endDate,
1914
1918
  limit: Math.min(parseInt(args.limit) || 10, 100),
1915
1919
  source: args.source,
1920
+ category: args.category,
1921
+ store: args.store,
1916
1922
  };
1923
+ }
1917
1924
 
1918
- case 'get_statistics':
1925
+ case 'get_statistics': {
1926
+ // 【新增】支持 period 参数
1927
+ const periodDates = args.period ? parsePeriod(args.period) : {};
1919
1928
  return {
1920
- startDate: args.yearMonth ? `${args.yearMonth}-01` : undefined,
1921
- endDate: args.yearMonth ? getMonthEndDate(args.yearMonth) : undefined,
1929
+ startDate: periodDates.startDate || (args.yearMonth ? `${args.yearMonth}-01` : undefined),
1930
+ endDate: periodDates.endDate || (args.yearMonth ? getMonthEndDate(args.yearMonth) : undefined),
1922
1931
  type: args.type,
1932
+ includeInsights: args.includeInsights,
1923
1933
  };
1934
+ }
1924
1935
 
1925
1936
  case 'save_income':
1926
1937
  return {
@@ -1949,6 +1960,64 @@ function getMonthEndDate(yearMonth) {
1949
1960
  return `${yearMonth}-${lastDay}`;
1950
1961
  }
1951
1962
 
1963
+ // 【新增】解析 period 参数为日期范围
1964
+ function parsePeriod(period) {
1965
+ const now = new Date();
1966
+ const year = now.getFullYear();
1967
+ const month = now.getMonth();
1968
+ const day = now.getDate();
1969
+ const weekDay = now.getDay(); // 0=周日, 1=周一...
1970
+
1971
+ let startDate, endDate;
1972
+
1973
+ switch (period) {
1974
+ case 'this_week': {
1975
+ // 本周一到今天
1976
+ const mondayOffset = weekDay === 0 ? 6 : weekDay - 1;
1977
+ const monday = new Date(year, month, day - mondayOffset);
1978
+ startDate = formatDateISO(monday);
1979
+ endDate = formatDateISO(now);
1980
+ break;
1981
+ }
1982
+ case 'last_week': {
1983
+ // 上周一到上周日
1984
+ const thisMondayOffset = weekDay === 0 ? 6 : weekDay - 1;
1985
+ const lastMonday = new Date(year, month, day - thisMondayOffset - 7);
1986
+ const lastSunday = new Date(year, month, day - thisMondayOffset - 1);
1987
+ startDate = formatDateISO(lastMonday);
1988
+ endDate = formatDateISO(lastSunday);
1989
+ break;
1990
+ }
1991
+ case 'this_month': {
1992
+ // 本月1号到今天
1993
+ const firstDay = new Date(year, month, 1);
1994
+ startDate = formatDateISO(firstDay);
1995
+ endDate = formatDateISO(now);
1996
+ break;
1997
+ }
1998
+ case 'last_month': {
1999
+ // 上月1号到上月最后一天
2000
+ const firstDayLastMonth = new Date(year, month - 1, 1);
2001
+ const lastDayLastMonth = new Date(year, month, 0);
2002
+ startDate = formatDateISO(firstDayLastMonth);
2003
+ endDate = formatDateISO(lastDayLastMonth);
2004
+ break;
2005
+ }
2006
+ default:
2007
+ return { startDate: undefined, endDate: undefined };
2008
+ }
2009
+
2010
+ return { startDate, endDate };
2011
+ }
2012
+
2013
+ // 格式化日期为 YYYY-MM-DD
2014
+ function formatDateISO(date) {
2015
+ const y = date.getFullYear();
2016
+ const m = String(date.getMonth() + 1).padStart(2, '0');
2017
+ const d = String(date.getDate()).padStart(2, '0');
2018
+ return `${y}-${m}-${d}`;
2019
+ }
2020
+
1952
2021
  // 授权状态管理
1953
2022
  let authState = {
1954
2023
  isAuthorized: false,