chaimi-keep-mcp 3.1.49-beta.1 → 3.1.49
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 +8 -2
- package/SKILL.md +4 -1
- package/bin/get-auth-code.js +2 -2
- package/package.json +1 -1
- package/server.js +78 -6
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ MCP Server 会显示:
|
|
|
61
61
|
║ 请在"柴米AI记账"小程序中完成授权: ║
|
|
62
62
|
║ ║
|
|
63
63
|
║ 1. 打开"柴米AI记账"小程序 ║
|
|
64
|
-
║ 2. 点击"我的" → "
|
|
64
|
+
║ 2. 点击"我的" → "Agent 授权" ║
|
|
65
65
|
║ 3. 输入验证码:ABCD-EFGH ║
|
|
66
66
|
║ ║
|
|
67
67
|
╚════════════════════════════════════════════════════════╝
|
|
@@ -69,7 +69,7 @@ MCP Server 会显示:
|
|
|
69
69
|
|
|
70
70
|
### 3. 小程序授权
|
|
71
71
|
|
|
72
|
-
打开"柴米AI记账"小程序 → 点击"我的" → "
|
|
72
|
+
打开"柴米AI记账"小程序 → 点击"我的" → "Agent 授权" → 输入上述验证码
|
|
73
73
|
|
|
74
74
|
### 4. 完成
|
|
75
75
|
|
|
@@ -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/SKILL.md
CHANGED
package/bin/get-auth-code.js
CHANGED
|
@@ -54,7 +54,7 @@ async function getAuthCode() {
|
|
|
54
54
|
message: `请在"柴米AI记账"小程序中完成授权`,
|
|
55
55
|
steps: [
|
|
56
56
|
'打开"柴米AI记账"小程序',
|
|
57
|
-
'点击"我的" → "
|
|
57
|
+
'点击"我的" → "Agent 授权"',
|
|
58
58
|
`输入验证码:${qrData.userCode}`
|
|
59
59
|
]
|
|
60
60
|
}));
|
|
@@ -79,7 +79,7 @@ async function getAuthCode() {
|
|
|
79
79
|
message: `授权进行中,请使用验证码 ${authState.userCode} 完成授权`,
|
|
80
80
|
steps: [
|
|
81
81
|
'打开"柴米AI记账"小程序',
|
|
82
|
-
'点击"我的" → "
|
|
82
|
+
'点击"我的" → "Agent 授权"',
|
|
83
83
|
`输入验证码:${authState.userCode}`
|
|
84
84
|
]
|
|
85
85
|
}));
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -180,7 +180,7 @@ async function initOAuthManager() {
|
|
|
180
180
|
console.error(' 请在"柴米AI记账"小程序中完成授权:');
|
|
181
181
|
console.error('');
|
|
182
182
|
console.error(' 1. 打开"柴米AI记账"小程序');
|
|
183
|
-
console.error(' 2. 点击"我的" → "
|
|
183
|
+
console.error(' 2. 点击"我的" → "Agent 授权"');
|
|
184
184
|
console.error(` 3. 输入验证码:${qrData.userCode}`);
|
|
185
185
|
console.error('');
|
|
186
186
|
console.error('='.repeat(60) + '\n');
|
|
@@ -1584,8 +1584,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1584
1584
|
请在"柴米AI记账"小程序中完成授权:
|
|
1585
1585
|
|
|
1586
1586
|
1️⃣ 打开微信小程序"柴米AI记账"
|
|
1587
|
-
|
|
1587
|
+
|
|
1588
|
+
2️⃣ 点击"我的" → "Agent 授权"
|
|
1589
|
+
|
|
1588
1590
|
3️⃣ 输入验证码:**${userCode}**
|
|
1591
|
+
|
|
1589
1592
|
4️⃣ 点击确认授权
|
|
1590
1593
|
|
|
1591
1594
|
⚠️ 重要提示:
|
|
@@ -1909,18 +1912,29 @@ function convertParams(toolName, args) {
|
|
|
1909
1912
|
};
|
|
1910
1913
|
}
|
|
1911
1914
|
|
|
1912
|
-
case 'get_expenses':
|
|
1915
|
+
case 'get_expenses': {
|
|
1916
|
+
// 【新增】支持 period 参数
|
|
1917
|
+
const periodDates = args.period ? parsePeriod(args.period) : {};
|
|
1913
1918
|
return {
|
|
1919
|
+
startDate: periodDates.startDate || args.startDate,
|
|
1920
|
+
endDate: periodDates.endDate || args.endDate,
|
|
1914
1921
|
limit: Math.min(parseInt(args.limit) || 10, 100),
|
|
1915
1922
|
source: args.source,
|
|
1923
|
+
category: args.category,
|
|
1924
|
+
store: args.store,
|
|
1916
1925
|
};
|
|
1926
|
+
}
|
|
1917
1927
|
|
|
1918
|
-
case 'get_statistics':
|
|
1928
|
+
case 'get_statistics': {
|
|
1929
|
+
// 【新增】支持 period 参数
|
|
1930
|
+
const periodDates = args.period ? parsePeriod(args.period) : {};
|
|
1919
1931
|
return {
|
|
1920
|
-
startDate: args.yearMonth ? `${args.yearMonth}-01` : undefined,
|
|
1921
|
-
endDate: args.yearMonth ? getMonthEndDate(args.yearMonth) : undefined,
|
|
1932
|
+
startDate: periodDates.startDate || (args.yearMonth ? `${args.yearMonth}-01` : undefined),
|
|
1933
|
+
endDate: periodDates.endDate || (args.yearMonth ? getMonthEndDate(args.yearMonth) : undefined),
|
|
1922
1934
|
type: args.type,
|
|
1935
|
+
includeInsights: args.includeInsights,
|
|
1923
1936
|
};
|
|
1937
|
+
}
|
|
1924
1938
|
|
|
1925
1939
|
case 'save_income':
|
|
1926
1940
|
return {
|
|
@@ -1949,6 +1963,64 @@ function getMonthEndDate(yearMonth) {
|
|
|
1949
1963
|
return `${yearMonth}-${lastDay}`;
|
|
1950
1964
|
}
|
|
1951
1965
|
|
|
1966
|
+
// 【新增】解析 period 参数为日期范围
|
|
1967
|
+
function parsePeriod(period) {
|
|
1968
|
+
const now = new Date();
|
|
1969
|
+
const year = now.getFullYear();
|
|
1970
|
+
const month = now.getMonth();
|
|
1971
|
+
const day = now.getDate();
|
|
1972
|
+
const weekDay = now.getDay(); // 0=周日, 1=周一...
|
|
1973
|
+
|
|
1974
|
+
let startDate, endDate;
|
|
1975
|
+
|
|
1976
|
+
switch (period) {
|
|
1977
|
+
case 'this_week': {
|
|
1978
|
+
// 本周一到今天
|
|
1979
|
+
const mondayOffset = weekDay === 0 ? 6 : weekDay - 1;
|
|
1980
|
+
const monday = new Date(year, month, day - mondayOffset);
|
|
1981
|
+
startDate = formatDateISO(monday);
|
|
1982
|
+
endDate = formatDateISO(now);
|
|
1983
|
+
break;
|
|
1984
|
+
}
|
|
1985
|
+
case 'last_week': {
|
|
1986
|
+
// 上周一到上周日
|
|
1987
|
+
const thisMondayOffset = weekDay === 0 ? 6 : weekDay - 1;
|
|
1988
|
+
const lastMonday = new Date(year, month, day - thisMondayOffset - 7);
|
|
1989
|
+
const lastSunday = new Date(year, month, day - thisMondayOffset - 1);
|
|
1990
|
+
startDate = formatDateISO(lastMonday);
|
|
1991
|
+
endDate = formatDateISO(lastSunday);
|
|
1992
|
+
break;
|
|
1993
|
+
}
|
|
1994
|
+
case 'this_month': {
|
|
1995
|
+
// 本月1号到今天
|
|
1996
|
+
const firstDay = new Date(year, month, 1);
|
|
1997
|
+
startDate = formatDateISO(firstDay);
|
|
1998
|
+
endDate = formatDateISO(now);
|
|
1999
|
+
break;
|
|
2000
|
+
}
|
|
2001
|
+
case 'last_month': {
|
|
2002
|
+
// 上月1号到上月最后一天
|
|
2003
|
+
const firstDayLastMonth = new Date(year, month - 1, 1);
|
|
2004
|
+
const lastDayLastMonth = new Date(year, month, 0);
|
|
2005
|
+
startDate = formatDateISO(firstDayLastMonth);
|
|
2006
|
+
endDate = formatDateISO(lastDayLastMonth);
|
|
2007
|
+
break;
|
|
2008
|
+
}
|
|
2009
|
+
default:
|
|
2010
|
+
return { startDate: undefined, endDate: undefined };
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
return { startDate, endDate };
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
// 格式化日期为 YYYY-MM-DD
|
|
2017
|
+
function formatDateISO(date) {
|
|
2018
|
+
const y = date.getFullYear();
|
|
2019
|
+
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
2020
|
+
const d = String(date.getDate()).padStart(2, '0');
|
|
2021
|
+
return `${y}-${m}-${d}`;
|
|
2022
|
+
}
|
|
2023
|
+
|
|
1952
2024
|
// 授权状态管理
|
|
1953
2025
|
let authState = {
|
|
1954
2026
|
isAuthorized: false,
|