chaimi-keep-mcp 3.1.49-beta.1 → 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.
- package/README.md +6 -0
- package/package.json +1 -1
- package/server.js +73 -4
package/README.md
CHANGED
|
@@ -148,6 +148,12 @@ 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
|
+
|
|
151
157
|
### v3.1.49-beta.0 (2026-04-24)
|
|
152
158
|
- **修复** category 未定义错误(三个记账函数)
|
|
153
159
|
- save_expense: `category` → `displayCategory`
|
package/package.json
CHANGED
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,
|