shawnxixi-cli 0.1.0 → 0.3.0
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/.env.example +1 -1
- package/dist/commands/biz/calendar.d.ts.map +1 -1
- package/dist/commands/biz/calendar.js +2 -6
- package/dist/commands/biz/calendar.js.map +1 -1
- package/dist/commands/biz/item.d.ts.map +1 -1
- package/dist/commands/biz/item.js +2 -7
- package/dist/commands/biz/item.js.map +1 -1
- package/dist/index.js +132 -184
- package/dist/index.js.map +1 -1
- package/dist/services/api.d.ts.map +1 -1
- package/dist/services/api.js +25 -8
- package/dist/services/api.js.map +1 -1
- package/package.json +3 -2
- package/src/commands/biz/calendar.ts +2 -6
- package/src/commands/biz/item.ts +2 -7
- package/src/index.ts +142 -178
- package/src/services/api.ts +23 -8
package/.env.example
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
SHAWNXIXI_API_URL=http://
|
|
1
|
+
SHAWNXIXI_API_URL=http://server.shawnxixi.icu
|
|
2
2
|
SHAWNXIXI_API_TOKEN=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../src/commands/biz/calendar.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;oBACL,MAAM,YAAW;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../src/commands/biz/calendar.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;oBACL,MAAM,YAAW;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;qBAchE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE;CASrD,CAAC"}
|
|
@@ -9,9 +9,7 @@ exports.calendarCommands = {
|
|
|
9
9
|
process.exit(1);
|
|
10
10
|
}
|
|
11
11
|
try {
|
|
12
|
-
const result = await api_1.apiService.createCalendarEvent
|
|
13
|
-
? api_1.apiService.createCalendarEvent(title, options.start, options.end, options.desc)
|
|
14
|
-
: { error: 'Calendar API not yet implemented in service' };
|
|
12
|
+
const result = await api_1.apiService.createCalendarEvent(title, options.start, options.end, options.desc);
|
|
15
13
|
console.log(JSON.stringify(result, null, 2));
|
|
16
14
|
}
|
|
17
15
|
catch (error) {
|
|
@@ -21,9 +19,7 @@ exports.calendarCommands = {
|
|
|
21
19
|
},
|
|
22
20
|
list: async (options = {}) => {
|
|
23
21
|
try {
|
|
24
|
-
const result = await api_1.apiService.listCalendarEvents
|
|
25
|
-
? api_1.apiService.listCalendarEvents(options)
|
|
26
|
-
: { error: 'Calendar API not yet implemented in service' };
|
|
22
|
+
const result = await api_1.apiService.listCalendarEvents(options.from, options.to);
|
|
27
23
|
console.log(JSON.stringify(result, null, 2));
|
|
28
24
|
}
|
|
29
25
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../../src/commands/biz/calendar.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEnC,QAAA,gBAAgB,GAAG;IAC9B,MAAM,EAAE,KAAK,EAAE,KAAa,EAAE,UAA2D,EAAE,EAAE,EAAE;QAC7F,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YACnC,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../../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,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../src/commands/biz/item.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;mBACF,MAAM,YAAW;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../src/commands/biz/item.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;mBACF,MAAM,YAAW;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;qBAUzE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE;CAShE,CAAC"}
|
|
@@ -5,10 +5,7 @@ const api_1 = require("../../services/api");
|
|
|
5
5
|
exports.itemCommands = {
|
|
6
6
|
create: async (name, options = {}) => {
|
|
7
7
|
try {
|
|
8
|
-
|
|
9
|
-
const result = await api_1.apiService.createItem
|
|
10
|
-
? api_1.apiService.createItem(name, options)
|
|
11
|
-
: { error: 'Item API not yet implemented in service' };
|
|
8
|
+
const result = await api_1.apiService.createItem(name, options.category, options.location, options.expire);
|
|
12
9
|
console.log(JSON.stringify(result, null, 2));
|
|
13
10
|
}
|
|
14
11
|
catch (error) {
|
|
@@ -18,9 +15,7 @@ exports.itemCommands = {
|
|
|
18
15
|
},
|
|
19
16
|
list: async (options = {}) => {
|
|
20
17
|
try {
|
|
21
|
-
const result = await api_1.apiService.listItems
|
|
22
|
-
? api_1.apiService.listItems(options)
|
|
23
|
-
: { error: 'Item API not yet implemented in service' };
|
|
18
|
+
const result = await api_1.apiService.listItems(options.category);
|
|
24
19
|
console.log(JSON.stringify(result, null, 2));
|
|
25
20
|
}
|
|
26
21
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sourceRoot":"","sources":["../../../src/commands/biz/item.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEnC,QAAA,YAAY,GAAG;IAC1B,MAAM,EAAE,KAAK,EAAE,IAAY,EAAE,UAAqE,EAAE,EAAE,EAAE;QACtG,IAAI,CAAC;YACH,
|
|
1
|
+
{"version":3,"file":"item.js","sourceRoot":"","sources":["../../../src/commands/biz/item.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEnC,QAAA,YAAY,GAAG;IAC1B,MAAM,EAAE,KAAK,EAAE,IAAY,EAAE,UAAqE,EAAE,EAAE,EAAE;QACtG,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,gBAAU,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YACrG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,IAAI,EAAE,KAAK,EAAE,UAAqD,EAAE,EAAE,EAAE;QACtE,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,gBAAU,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,194 +6,142 @@
|
|
|
6
6
|
* 命令命名空间:biz:*(日常业务)、sys:*(系统操作)
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const commander_1 = require("commander");
|
|
9
10
|
const todo_1 = require("./commands/biz/todo");
|
|
10
11
|
const record_1 = require("./commands/biz/record");
|
|
11
12
|
const finance_1 = require("./commands/biz/finance");
|
|
12
13
|
const item_1 = require("./commands/biz/item");
|
|
13
14
|
const calendar_1 = require("./commands/biz/calendar");
|
|
14
15
|
const health_1 = require("./commands/sys/health");
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
'
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
'
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
'
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
'
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
'
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
console.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
Usage: shawnxixi <command> [args...]
|
|
147
|
-
|
|
148
|
-
Business Commands (biz:*):
|
|
149
|
-
biz todo create <title> [--due YYYY-MM-DD] [--priority low|medium|high]
|
|
150
|
-
biz todo list
|
|
151
|
-
biz todo done <id>
|
|
152
|
-
biz todo delete <id>
|
|
153
|
-
biz record create <title> [--content TEXT] [--type diary|pet|note|idea] [--tags TAG1,TAG2]
|
|
154
|
-
biz record list
|
|
155
|
-
biz finance create <amount> [--type income|expense] [--category CAT] [--desc TEXT]
|
|
156
|
-
biz finance list [--type income|expense] [--category CAT]
|
|
157
|
-
biz item create <name> [--location LOC] [--expire YYYY-MM-DD] [--category CAT]
|
|
158
|
-
biz item list
|
|
159
|
-
biz calendar create <title> --start DATETIME --end DATETIME [--desc TEXT]
|
|
160
|
-
biz calendar list
|
|
161
|
-
|
|
162
|
-
System Commands (sys:*):
|
|
163
|
-
sys health sync [--from YYYY-MM-DD] [--to YYYY-MM-DD]
|
|
164
|
-
sys health query <dataType> [--from YYYY-MM-DD] [--to YYYY-MM-DD]
|
|
165
|
-
|
|
166
|
-
Examples:
|
|
167
|
-
shawnxixi biz todo create "开会" --due 2026-04-12 --priority high
|
|
168
|
-
shawnxixi biz finance create 50 --category food --desc "午饭"
|
|
169
|
-
shawnxixi biz calendar create "面试" --start "2026-04-15 14:00" --end "2026-04-15 15:00"
|
|
170
|
-
`);
|
|
171
|
-
}
|
|
172
|
-
function main() {
|
|
173
|
-
const args = process.argv.slice(2);
|
|
174
|
-
if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
|
|
175
|
-
printUsage();
|
|
176
|
-
process.exit(0);
|
|
177
|
-
}
|
|
178
|
-
// Handle special case: "biz todo list" -> "biz:todo:list"
|
|
179
|
-
let commandKey;
|
|
180
|
-
if (args[0] === 'biz' || args[0] === 'sys') {
|
|
181
|
-
commandKey = args.join(':');
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
commandKey = args[0];
|
|
185
|
-
}
|
|
186
|
-
const handler = commands[commandKey];
|
|
187
|
-
if (!handler) {
|
|
188
|
-
console.error(`Unknown command: ${commandKey}`);
|
|
189
|
-
printUsage();
|
|
190
|
-
process.exit(1);
|
|
191
|
-
}
|
|
192
|
-
const handlerArgs = args.slice(1);
|
|
193
|
-
handler(...handlerArgs).catch((error) => {
|
|
194
|
-
console.error('Command failed:', error);
|
|
195
|
-
process.exit(1);
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
main();
|
|
16
|
+
const program = new commander_1.Command();
|
|
17
|
+
program
|
|
18
|
+
.name('shawnxixi')
|
|
19
|
+
.description('肖嘻 CLI 工具')
|
|
20
|
+
.version('0.2.0');
|
|
21
|
+
// ============ biz ============
|
|
22
|
+
const biz = program.command('biz').description('日常业务命令');
|
|
23
|
+
// biz todo
|
|
24
|
+
const todo = biz.command('todo').description('待办管理');
|
|
25
|
+
todo
|
|
26
|
+
.command('create <title>')
|
|
27
|
+
.description('创建待办')
|
|
28
|
+
.option('--due <date>', '截止日期 YYYY-MM-DD')
|
|
29
|
+
.option('--priority <level>', '优先级 low|medium|high', 'medium')
|
|
30
|
+
.action(async (title, options) => {
|
|
31
|
+
await todo_1.todoCommands.create(title, options);
|
|
32
|
+
});
|
|
33
|
+
todo
|
|
34
|
+
.command('list')
|
|
35
|
+
.description('列出待办')
|
|
36
|
+
.option('--status <status>', '状态过滤')
|
|
37
|
+
.action(async (options) => {
|
|
38
|
+
await todo_1.todoCommands.list(options);
|
|
39
|
+
});
|
|
40
|
+
todo
|
|
41
|
+
.command('done <id>')
|
|
42
|
+
.description('标记待办完成')
|
|
43
|
+
.action(async (id) => {
|
|
44
|
+
await todo_1.todoCommands.done(parseInt(id, 10));
|
|
45
|
+
});
|
|
46
|
+
todo
|
|
47
|
+
.command('delete <id>')
|
|
48
|
+
.description('删除待办')
|
|
49
|
+
.action(async (id) => {
|
|
50
|
+
await todo_1.todoCommands.delete(parseInt(id, 10));
|
|
51
|
+
});
|
|
52
|
+
// biz record
|
|
53
|
+
const record = biz.command('record').description('记录管理');
|
|
54
|
+
record
|
|
55
|
+
.command('create <title>')
|
|
56
|
+
.description('创建记录')
|
|
57
|
+
.option('--content <text>', '内容')
|
|
58
|
+
.option('--type <type>', '类型 diary|pet|note|idea', 'diary')
|
|
59
|
+
.option('--tags <tags>', '标签,逗号分隔')
|
|
60
|
+
.action(async (title, options) => {
|
|
61
|
+
await record_1.recordCommands.create(title, options.content || '', options);
|
|
62
|
+
});
|
|
63
|
+
record
|
|
64
|
+
.command('list')
|
|
65
|
+
.description('列出记录')
|
|
66
|
+
.option('--type <type>', '类型过滤')
|
|
67
|
+
.action(async (options) => {
|
|
68
|
+
await record_1.recordCommands.list(options);
|
|
69
|
+
});
|
|
70
|
+
// biz finance
|
|
71
|
+
const finance = biz.command('finance').description('财务管理');
|
|
72
|
+
finance
|
|
73
|
+
.command('create <amount>')
|
|
74
|
+
.description('记一笔账')
|
|
75
|
+
.option('--type <type>', '类型 income|expense', 'expense')
|
|
76
|
+
.option('--category <cat>', '分类', 'other')
|
|
77
|
+
.option('--desc <text>', '备注')
|
|
78
|
+
.action(async (amount, options) => {
|
|
79
|
+
await finance_1.financeCommands.create(amount, options);
|
|
80
|
+
});
|
|
81
|
+
finance
|
|
82
|
+
.command('list')
|
|
83
|
+
.description('列出账单')
|
|
84
|
+
.option('--type <type>', '类型过滤 income|expense')
|
|
85
|
+
.option('--category <cat>', '分类过滤')
|
|
86
|
+
.action(async (options) => {
|
|
87
|
+
await finance_1.financeCommands.list(options);
|
|
88
|
+
});
|
|
89
|
+
// biz item
|
|
90
|
+
const item = biz.command('item').description('物品管理');
|
|
91
|
+
item
|
|
92
|
+
.command('create <name>')
|
|
93
|
+
.description('添加物品')
|
|
94
|
+
.option('--location <loc>', '存放位置')
|
|
95
|
+
.option('--expire <date>', '过期日期 YYYY-MM-DD')
|
|
96
|
+
.option('--category <cat>', '分类')
|
|
97
|
+
.action(async (name, options) => {
|
|
98
|
+
await item_1.itemCommands.create(name, options);
|
|
99
|
+
});
|
|
100
|
+
item
|
|
101
|
+
.command('list')
|
|
102
|
+
.description('列出物品')
|
|
103
|
+
.option('--category <cat>', '分类过滤')
|
|
104
|
+
.action(async (options) => {
|
|
105
|
+
await item_1.itemCommands.list(options);
|
|
106
|
+
});
|
|
107
|
+
// biz calendar
|
|
108
|
+
const calendar = biz.command('calendar').description('日程管理');
|
|
109
|
+
calendar
|
|
110
|
+
.command('create <title>')
|
|
111
|
+
.description('创建日程')
|
|
112
|
+
.requiredOption('--start <datetime>', '开始时间')
|
|
113
|
+
.requiredOption('--end <datetime>', '结束时间')
|
|
114
|
+
.option('--desc <text>', '描述')
|
|
115
|
+
.action(async (title, options) => {
|
|
116
|
+
await calendar_1.calendarCommands.create(title, options);
|
|
117
|
+
});
|
|
118
|
+
calendar
|
|
119
|
+
.command('list')
|
|
120
|
+
.description('列出日程')
|
|
121
|
+
.option('--from <datetime>', '开始时间')
|
|
122
|
+
.option('--to <datetime>', '结束时间')
|
|
123
|
+
.action(async (options) => {
|
|
124
|
+
await calendar_1.calendarCommands.list(options);
|
|
125
|
+
});
|
|
126
|
+
// ============ sys ============
|
|
127
|
+
const sys = program.command('sys').description('系统命令');
|
|
128
|
+
const health = sys.command('health').description('健康数据');
|
|
129
|
+
health
|
|
130
|
+
.command('sync')
|
|
131
|
+
.description('同步健康数据')
|
|
132
|
+
.action(async () => {
|
|
133
|
+
await (0, health_1.syncHealth)();
|
|
134
|
+
});
|
|
135
|
+
health
|
|
136
|
+
.command('query [dataType]')
|
|
137
|
+
.description('查询健康数据')
|
|
138
|
+
.option('--from <date>', '开始日期 YYYY-MM-DD')
|
|
139
|
+
.option('--to <date>', '结束日期 YYYY-MM-DD')
|
|
140
|
+
.action(async (dataType, options) => {
|
|
141
|
+
await (0, health_1.syncHealth)(dataType, { startDate: options.from, endDate: options.to });
|
|
142
|
+
});
|
|
143
|
+
program.parseAsync(process.argv).catch((error) => {
|
|
144
|
+
console.error('Command failed:', error);
|
|
145
|
+
process.exit(1);
|
|
146
|
+
});
|
|
199
147
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAEA;;;;GAIG;;AAEH,8CAAmD;AACnD,kDAAuD;AACvD,oDAAyD;AACzD,8CAAmD;AACnD,sDAA2D;AAC3D,kDAAmD;
|
|
1
|
+
{"version":3,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AI,EAAE;IACjB,MAAM,IAAA,mBAAU,GAAE,CAAC;AACrB,CAAC,CAAC,CAAC;AAEL,MAAM;KACH,OAAO,CAAC,kBAAkB,CAAC;KAC3B,WAAW,CAAC,QAAQ,CAAC;KACrB,MAAM,CAAC,eAAe,EAAE,iBAAiB,CAAC;KAC1C,MAAM,CAAC,aAAa,EAAE,iBAAiB,CAAC;KACxC,MAAM,CAAC,KAAK,EAAE,QAA4B,EAAE,OAAuC,EAAE,EAAE;IACtF,MAAM,IAAA,mBAAU,EAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC/C,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;IACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/services/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/services/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,cAAM,UAAU;IACd,OAAO,CAAC,MAAM,CAAgB;;YA0ChB,QAAQ;YAKR,YAAY;IAKpB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAU7D,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM;IAMzB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE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,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAUxE,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAWlF,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM;CAMhC;AAED,eAAO,MAAM,UAAU,YAAmB,CAAC"}
|
package/dist/services/api.js
CHANGED
|
@@ -9,12 +9,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.apiService = void 0;
|
|
11
11
|
const axios_1 = __importDefault(require("axios"));
|
|
12
|
-
const API_BASE = process.env.SHAWNXIXI_API_URL || 'http://
|
|
12
|
+
const API_BASE = process.env.SHAWNXIXI_API_URL || 'http://server.shawnxixi.icu';
|
|
13
|
+
/** Normalize date/datetime strings to LocalDateTime format (ISO 8601 without timezone) */
|
|
14
|
+
function toLocalDateTime(value) {
|
|
15
|
+
if (!value)
|
|
16
|
+
return undefined;
|
|
17
|
+
// "YYYY-MM-DD" → "YYYY-MM-DDT00:00:00"
|
|
18
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value))
|
|
19
|
+
return `${value}T00:00:00`;
|
|
20
|
+
// "YYYY-MM-DD HH:MM" → "YYYY-MM-DDTHH:MM:00"
|
|
21
|
+
if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(value))
|
|
22
|
+
return value.replace(' ', 'T') + ':00';
|
|
23
|
+
// Already ISO format, pass through
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
13
26
|
class ApiService {
|
|
14
27
|
constructor() {
|
|
15
28
|
this.client = axios_1.default.create({
|
|
16
29
|
baseURL: API_BASE,
|
|
17
|
-
timeout:
|
|
30
|
+
timeout: 30000,
|
|
18
31
|
headers: {
|
|
19
32
|
'Content-Type': 'application/json',
|
|
20
33
|
},
|
|
@@ -25,6 +38,10 @@ class ApiService {
|
|
|
25
38
|
if (token) {
|
|
26
39
|
config.headers.Authorization = `Bearer ${token}`;
|
|
27
40
|
}
|
|
41
|
+
// 请求体长度防护
|
|
42
|
+
if (config.data && JSON.stringify(config.data).length > 100000) {
|
|
43
|
+
throw new Error('Request payload too large (max 100KB)');
|
|
44
|
+
}
|
|
28
45
|
return config;
|
|
29
46
|
});
|
|
30
47
|
// 响应拦截器:处理 401 刷新 token
|
|
@@ -52,7 +69,7 @@ class ApiService {
|
|
|
52
69
|
async createTodo(title, dueDate, priority) {
|
|
53
70
|
const { data } = await this.client.post('/api/v1/todos', {
|
|
54
71
|
title,
|
|
55
|
-
dueDate,
|
|
72
|
+
dueDate: toLocalDateTime(dueDate),
|
|
56
73
|
priority: priority || 'medium',
|
|
57
74
|
status: 'pending',
|
|
58
75
|
});
|
|
@@ -64,7 +81,7 @@ class ApiService {
|
|
|
64
81
|
return data;
|
|
65
82
|
}
|
|
66
83
|
async updateTodo(id, updates) {
|
|
67
|
-
const { data } = await this.client.
|
|
84
|
+
const { data } = await this.client.patch(`/api/v1/todos/${id}`, updates);
|
|
68
85
|
return data;
|
|
69
86
|
}
|
|
70
87
|
async deleteTodo(id) {
|
|
@@ -131,7 +148,7 @@ class ApiService {
|
|
|
131
148
|
name,
|
|
132
149
|
category,
|
|
133
150
|
location,
|
|
134
|
-
expireDate,
|
|
151
|
+
expireDate: toLocalDateTime(expireDate),
|
|
135
152
|
});
|
|
136
153
|
return data;
|
|
137
154
|
}
|
|
@@ -148,8 +165,8 @@ class ApiService {
|
|
|
148
165
|
async createCalendarEvent(title, startTime, endTime, description, location) {
|
|
149
166
|
const { data } = await this.client.post('/api/v1/calendar-events', {
|
|
150
167
|
title,
|
|
151
|
-
startTime,
|
|
152
|
-
endTime,
|
|
168
|
+
startTime: toLocalDateTime(startTime),
|
|
169
|
+
endTime: toLocalDateTime(endTime),
|
|
153
170
|
description,
|
|
154
171
|
location,
|
|
155
172
|
});
|
|
@@ -168,7 +185,7 @@ class ApiService {
|
|
|
168
185
|
async createReminder(title, triggerTime, type = 'once') {
|
|
169
186
|
const { data } = await this.client.post('/api/v1/reminders', {
|
|
170
187
|
title,
|
|
171
|
-
triggerTime,
|
|
188
|
+
triggerTime: toLocalDateTime(triggerTime),
|
|
172
189
|
type,
|
|
173
190
|
status: 'active',
|
|
174
191
|
});
|
package/dist/services/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/services/api.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,kDAA6C;AAE7C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/services/api.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,kDAA6C;AAE7C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,6BAA6B,CAAC;AAEhF,0FAA0F;AAC1F,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,uCAAuC;IACvC,IAAI,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,KAAK,WAAW,CAAC;IAClE,6CAA6C;IAC7C,IAAI,iCAAiC,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;IAC1F,mCAAmC;IACnC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU;IAGd;QACE,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,QAAQ;YACjB,OAAO,EAAE,KAAK;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACn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,GAAG,CAAC,eAAe,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAEY,QAAA,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shawnxixi-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "肖嘻 CLI 工具 - OpenClaw 执行肢",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"typescript": "^5.3.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"axios": "^1.15.0"
|
|
38
|
+
"axios": "^1.15.0",
|
|
39
|
+
"commander": "^14.0.3"
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -7,9 +7,7 @@ export const calendarCommands = {
|
|
|
7
7
|
process.exit(1);
|
|
8
8
|
}
|
|
9
9
|
try {
|
|
10
|
-
const result = await (
|
|
11
|
-
? (apiService as any).createCalendarEvent(title, options.start, options.end, options.desc)
|
|
12
|
-
: { error: 'Calendar API not yet implemented in service' };
|
|
10
|
+
const result = await apiService.createCalendarEvent(title, options.start!, options.end!, options.desc);
|
|
13
11
|
console.log(JSON.stringify(result, null, 2));
|
|
14
12
|
} catch (error: any) {
|
|
15
13
|
console.error('创建日程失败:', error.message);
|
|
@@ -19,9 +17,7 @@ export const calendarCommands = {
|
|
|
19
17
|
|
|
20
18
|
list: async (options: { from?: string; to?: string } = {}) => {
|
|
21
19
|
try {
|
|
22
|
-
const result = await (
|
|
23
|
-
? (apiService as any).listCalendarEvents(options)
|
|
24
|
-
: { error: 'Calendar API not yet implemented in service' };
|
|
20
|
+
const result = await apiService.listCalendarEvents(options.from, options.to);
|
|
25
21
|
console.log(JSON.stringify(result, null, 2));
|
|
26
22
|
} catch (error: any) {
|
|
27
23
|
console.error('查询日程失败:', error.message);
|
package/src/commands/biz/item.ts
CHANGED
|
@@ -3,10 +3,7 @@ import { apiService } from '../../services/api';
|
|
|
3
3
|
export const itemCommands = {
|
|
4
4
|
create: async (name: string, options: { location?: string; expire?: string; category?: string } = {}) => {
|
|
5
5
|
try {
|
|
6
|
-
|
|
7
|
-
const result = await (apiService as any).createItem
|
|
8
|
-
? (apiService as any).createItem(name, options)
|
|
9
|
-
: { error: 'Item API not yet implemented in service' };
|
|
6
|
+
const result = await apiService.createItem(name, options.category, options.location, options.expire);
|
|
10
7
|
console.log(JSON.stringify(result, null, 2));
|
|
11
8
|
} catch (error: any) {
|
|
12
9
|
console.error('创建物品失败:', error.message);
|
|
@@ -16,9 +13,7 @@ export const itemCommands = {
|
|
|
16
13
|
|
|
17
14
|
list: async (options: { category?: string; expiring?: boolean } = {}) => {
|
|
18
15
|
try {
|
|
19
|
-
const result = await
|
|
20
|
-
? (apiService as any).listItems(options)
|
|
21
|
-
: { error: 'Item API not yet implemented in service' };
|
|
16
|
+
const result = await apiService.listItems(options.category);
|
|
22
17
|
console.log(JSON.stringify(result, null, 2));
|
|
23
18
|
} catch (error: any) {
|
|
24
19
|
console.error('查询物品失败:', error.message);
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* 命令命名空间:biz:*(日常业务)、sys:*(系统操作)
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { Command } from 'commander';
|
|
9
10
|
import { todoCommands } from './commands/biz/todo';
|
|
10
11
|
import { recordCommands } from './commands/biz/record';
|
|
11
12
|
import { financeCommands } from './commands/biz/finance';
|
|
@@ -13,197 +14,160 @@ import { itemCommands } from './commands/biz/item';
|
|
|
13
14
|
import { calendarCommands } from './commands/biz/calendar';
|
|
14
15
|
import { syncHealth } from './commands/sys/health';
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
const program = new Command();
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
program
|
|
20
|
+
.name('shawnxixi')
|
|
21
|
+
.description('肖嘻 CLI 工具')
|
|
22
|
+
.version('0.2.0');
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// ============ biz ============
|
|
25
|
+
|
|
26
|
+
const biz = program.command('biz').description('日常业务命令');
|
|
27
|
+
|
|
28
|
+
// biz todo
|
|
29
|
+
const todo = biz.command('todo').description('待办管理');
|
|
30
|
+
|
|
31
|
+
todo
|
|
32
|
+
.command('create <title>')
|
|
33
|
+
.description('创建待办')
|
|
34
|
+
.option('--due <date>', '截止日期 YYYY-MM-DD')
|
|
35
|
+
.option('--priority <level>', '优先级 low|medium|high', 'medium')
|
|
36
|
+
.action(async (title: string, options: { due?: string; priority?: string }) => {
|
|
26
37
|
await todoCommands.create(title, options);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
'
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
todo
|
|
41
|
+
.command('list')
|
|
42
|
+
.description('列出待办')
|
|
43
|
+
.option('--status <status>', '状态过滤')
|
|
44
|
+
.action(async (options: { status?: string }) => {
|
|
45
|
+
await todoCommands.list(options);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
todo
|
|
49
|
+
.command('done <id>')
|
|
50
|
+
.description('标记待办完成')
|
|
51
|
+
.action(async (id: string) => {
|
|
32
52
|
await todoCommands.done(parseInt(id, 10));
|
|
33
|
-
}
|
|
34
|
-
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
todo
|
|
56
|
+
.command('delete <id>')
|
|
57
|
+
.description('删除待办')
|
|
58
|
+
.action(async (id: string) => {
|
|
35
59
|
await todoCommands.delete(parseInt(id, 10));
|
|
36
|
-
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// biz record
|
|
63
|
+
const record = biz.command('record').description('记录管理');
|
|
37
64
|
|
|
38
|
-
|
|
39
|
-
'
|
|
40
|
-
|
|
65
|
+
record
|
|
66
|
+
.command('create <title>')
|
|
67
|
+
.description('创建记录')
|
|
68
|
+
.option('--content <text>', '内容')
|
|
69
|
+
.option('--type <type>', '类型 diary|pet|note|idea', 'diary')
|
|
70
|
+
.option('--tags <tags>', '标签,逗号分隔')
|
|
71
|
+
.action(async (title: string, options: { content?: string; type?: string; tags?: string }) => {
|
|
41
72
|
await recordCommands.create(title, options.content || '', options);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
record
|
|
76
|
+
.command('list')
|
|
77
|
+
.description('列出记录')
|
|
78
|
+
.option('--type <type>', '类型过滤')
|
|
79
|
+
.action(async (options: { type?: string }) => {
|
|
80
|
+
await recordCommands.list(options);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// biz finance
|
|
84
|
+
const finance = biz.command('finance').description('财务管理');
|
|
85
|
+
|
|
86
|
+
finance
|
|
87
|
+
.command('create <amount>')
|
|
88
|
+
.description('记一笔账')
|
|
89
|
+
.option('--type <type>', '类型 income|expense', 'expense')
|
|
90
|
+
.option('--category <cat>', '分类', 'other')
|
|
91
|
+
.option('--desc <text>', '备注')
|
|
92
|
+
.action(async (amount: string, options: { type?: string; category?: string; desc?: string }) => {
|
|
50
93
|
await financeCommands.create(amount, options);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
finance
|
|
97
|
+
.command('list')
|
|
98
|
+
.description('列出账单')
|
|
99
|
+
.option('--type <type>', '类型过滤 income|expense')
|
|
100
|
+
.option('--category <cat>', '分类过滤')
|
|
101
|
+
.action(async (options: { type?: string; category?: string }) => {
|
|
54
102
|
await financeCommands.list(options);
|
|
55
|
-
}
|
|
103
|
+
});
|
|
56
104
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
105
|
+
// biz item
|
|
106
|
+
const item = biz.command('item').description('物品管理');
|
|
107
|
+
|
|
108
|
+
item
|
|
109
|
+
.command('create <name>')
|
|
110
|
+
.description('添加物品')
|
|
111
|
+
.option('--location <loc>', '存放位置')
|
|
112
|
+
.option('--expire <date>', '过期日期 YYYY-MM-DD')
|
|
113
|
+
.option('--category <cat>', '分类')
|
|
114
|
+
.action(async (name: string, options: { location?: string; expire?: string; category?: string }) => {
|
|
60
115
|
await itemCommands.create(name, options);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
item
|
|
119
|
+
.command('list')
|
|
120
|
+
.description('列出物品')
|
|
121
|
+
.option('--category <cat>', '分类过滤')
|
|
122
|
+
.action(async (options: { category?: string }) => {
|
|
123
|
+
await itemCommands.list(options);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// biz calendar
|
|
127
|
+
const calendar = biz.command('calendar').description('日程管理');
|
|
128
|
+
|
|
129
|
+
calendar
|
|
130
|
+
.command('create <title>')
|
|
131
|
+
.description('创建日程')
|
|
132
|
+
.requiredOption('--start <datetime>', '开始时间')
|
|
133
|
+
.requiredOption('--end <datetime>', '结束时间')
|
|
134
|
+
.option('--desc <text>', '描述')
|
|
135
|
+
.action(async (title: string, options: { start: string; end: string; desc?: string }) => {
|
|
69
136
|
await calendarCommands.create(title, options);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
calendar
|
|
140
|
+
.command('list')
|
|
141
|
+
.description('列出日程')
|
|
142
|
+
.option('--from <datetime>', '开始时间')
|
|
143
|
+
.option('--to <datetime>', '结束时间')
|
|
144
|
+
.action(async (options: { from?: string; to?: string }) => {
|
|
145
|
+
await calendarCommands.list(options);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// ============ sys ============
|
|
74
149
|
|
|
75
|
-
|
|
76
|
-
|
|
150
|
+
const sys = program.command('sys').description('系统命令');
|
|
151
|
+
|
|
152
|
+
const health = sys.command('health').description('健康数据');
|
|
153
|
+
|
|
154
|
+
health
|
|
155
|
+
.command('sync')
|
|
156
|
+
.description('同步健康数据')
|
|
157
|
+
.action(async () => {
|
|
77
158
|
await syncHealth();
|
|
78
|
-
},
|
|
79
|
-
'sys:health:query': async (dataType: string, args: string[]) => {
|
|
80
|
-
const options = parseHealthOptions(args);
|
|
81
|
-
await syncHealth(dataType, options);
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// ============ Option Parsers ============
|
|
86
|
-
|
|
87
|
-
function parseTodoOptions(args: string[]): { due?: string; priority?: string } {
|
|
88
|
-
const options: { due?: string; priority?: string } = {};
|
|
89
|
-
for (let i = 0; i < args.length; i++) {
|
|
90
|
-
if (args[i] === '--due' && args[i + 1]) options.due = args[++i];
|
|
91
|
-
if (args[i] === '--priority' && args[i + 1]) options.priority = args[++i];
|
|
92
|
-
}
|
|
93
|
-
return options;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function parseRecordOptions(args: string[]): { content?: string; type?: string; tags?: string } {
|
|
97
|
-
const options: { content?: string; type?: string; tags?: string } = {};
|
|
98
|
-
for (let i = 0; i < args.length; i++) {
|
|
99
|
-
if (args[i] === '--content' && args[i + 1]) options.content = args[++i];
|
|
100
|
-
if (args[i] === '--type' && args[i + 1]) options.type = args[++i];
|
|
101
|
-
if (args[i] === '--tags' && args[i + 1]) options.tags = args[++i];
|
|
102
|
-
}
|
|
103
|
-
return options;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function parseFinanceOptions(args: string[]): { type?: string; category?: string; desc?: string } {
|
|
107
|
-
const options: { type?: string; category?: string; desc?: string } = {};
|
|
108
|
-
for (let i = 0; i < args.length; i++) {
|
|
109
|
-
if (args[i] === '--type' && args[i + 1]) options.type = args[++i];
|
|
110
|
-
if (args[i] === '--category' && args[i + 1]) options.category = args[++i];
|
|
111
|
-
if (args[i] === '--desc' && args[i + 1]) options.desc = args[++i];
|
|
112
|
-
}
|
|
113
|
-
return options;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function parseItemOptions(args: string[]): { location?: string; expire?: string; category?: string } {
|
|
117
|
-
const options: { location?: string; expire?: string; category?: string } = {};
|
|
118
|
-
for (let i = 0; i < args.length; i++) {
|
|
119
|
-
if (args[i] === '--location' && args[i + 1]) options.location = args[++i];
|
|
120
|
-
if (args[i] === '--expire' && args[i + 1]) options.expire = args[++i];
|
|
121
|
-
if (args[i] === '--category' && args[i + 1]) options.category = args[++i];
|
|
122
|
-
}
|
|
123
|
-
return options;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function parseCalendarOptions(args: string[]): { start?: string; end?: string; desc?: string } {
|
|
127
|
-
const options: { start?: string; end?: string; desc?: string } = {};
|
|
128
|
-
for (let i = 0; i < args.length; i++) {
|
|
129
|
-
if (args[i] === '--start' && args[i + 1]) options.start = args[++i];
|
|
130
|
-
if (args[i] === '--end' && args[i + 1]) options.end = args[++i];
|
|
131
|
-
if (args[i] === '--desc' && args[i + 1]) options.desc = args[++i];
|
|
132
|
-
}
|
|
133
|
-
return options;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function parseHealthOptions(args: string[]): { startDate?: string; endDate?: string } {
|
|
137
|
-
const options: { startDate?: string; endDate?: string } = {};
|
|
138
|
-
for (let i = 0; i < args.length; i++) {
|
|
139
|
-
if (args[i] === '--from' && args[i + 1]) options.startDate = args[++i];
|
|
140
|
-
if (args[i] === '--to' && args[i + 1]) options.endDate = args[++i];
|
|
141
|
-
}
|
|
142
|
-
return options;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// ============ CLI Entry ============
|
|
146
|
-
|
|
147
|
-
function printUsage(): void {
|
|
148
|
-
console.log(`
|
|
149
|
-
shawnxixi CLI - 肖嘻 CLI 工具
|
|
150
|
-
|
|
151
|
-
Usage: shawnxixi <command> [args...]
|
|
152
|
-
|
|
153
|
-
Business Commands (biz:*):
|
|
154
|
-
biz todo create <title> [--due YYYY-MM-DD] [--priority low|medium|high]
|
|
155
|
-
biz todo list
|
|
156
|
-
biz todo done <id>
|
|
157
|
-
biz todo delete <id>
|
|
158
|
-
biz record create <title> [--content TEXT] [--type diary|pet|note|idea] [--tags TAG1,TAG2]
|
|
159
|
-
biz record list
|
|
160
|
-
biz finance create <amount> [--type income|expense] [--category CAT] [--desc TEXT]
|
|
161
|
-
biz finance list [--type income|expense] [--category CAT]
|
|
162
|
-
biz item create <name> [--location LOC] [--expire YYYY-MM-DD] [--category CAT]
|
|
163
|
-
biz item list
|
|
164
|
-
biz calendar create <title> --start DATETIME --end DATETIME [--desc TEXT]
|
|
165
|
-
biz calendar list
|
|
166
|
-
|
|
167
|
-
System Commands (sys:*):
|
|
168
|
-
sys health sync [--from YYYY-MM-DD] [--to YYYY-MM-DD]
|
|
169
|
-
sys health query <dataType> [--from YYYY-MM-DD] [--to YYYY-MM-DD]
|
|
170
|
-
|
|
171
|
-
Examples:
|
|
172
|
-
shawnxixi biz todo create "开会" --due 2026-04-12 --priority high
|
|
173
|
-
shawnxixi biz finance create 50 --category food --desc "午饭"
|
|
174
|
-
shawnxixi biz calendar create "面试" --start "2026-04-15 14:00" --end "2026-04-15 15:00"
|
|
175
|
-
`);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function main(): void {
|
|
179
|
-
const args = process.argv.slice(2);
|
|
180
|
-
|
|
181
|
-
if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
|
|
182
|
-
printUsage();
|
|
183
|
-
process.exit(0);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Handle special case: "biz todo list" -> "biz:todo:list"
|
|
187
|
-
let commandKey: string;
|
|
188
|
-
if (args[0] === 'biz' || args[0] === 'sys') {
|
|
189
|
-
commandKey = args.join(':');
|
|
190
|
-
} else {
|
|
191
|
-
commandKey = args[0];
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const handler = commands[commandKey];
|
|
195
|
-
|
|
196
|
-
if (!handler) {
|
|
197
|
-
console.error(`Unknown command: ${commandKey}`);
|
|
198
|
-
printUsage();
|
|
199
|
-
process.exit(1);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const handlerArgs = args.slice(1);
|
|
203
|
-
handler(...handlerArgs).catch((error) => {
|
|
204
|
-
console.error('Command failed:', error);
|
|
205
|
-
process.exit(1);
|
|
206
159
|
});
|
|
207
|
-
}
|
|
208
160
|
|
|
209
|
-
|
|
161
|
+
health
|
|
162
|
+
.command('query [dataType]')
|
|
163
|
+
.description('查询健康数据')
|
|
164
|
+
.option('--from <date>', '开始日期 YYYY-MM-DD')
|
|
165
|
+
.option('--to <date>', '结束日期 YYYY-MM-DD')
|
|
166
|
+
.action(async (dataType: string | undefined, options: { from?: string; to?: string }) => {
|
|
167
|
+
await syncHealth(dataType, { startDate: options.from, endDate: options.to });
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
program.parseAsync(process.argv).catch((error) => {
|
|
171
|
+
console.error('Command failed:', error);
|
|
172
|
+
process.exit(1);
|
|
173
|
+
});
|
package/src/services/api.ts
CHANGED
|
@@ -5,7 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
import axios, { AxiosInstance } from 'axios';
|
|
7
7
|
|
|
8
|
-
const API_BASE = process.env.SHAWNXIXI_API_URL || 'http://
|
|
8
|
+
const API_BASE = process.env.SHAWNXIXI_API_URL || 'http://server.shawnxixi.icu';
|
|
9
|
+
|
|
10
|
+
/** Normalize date/datetime strings to LocalDateTime format (ISO 8601 without timezone) */
|
|
11
|
+
function toLocalDateTime(value?: string): string | undefined {
|
|
12
|
+
if (!value) return undefined;
|
|
13
|
+
// "YYYY-MM-DD" → "YYYY-MM-DDT00:00:00"
|
|
14
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) return `${value}T00:00:00`;
|
|
15
|
+
// "YYYY-MM-DD HH:MM" → "YYYY-MM-DDTHH:MM:00"
|
|
16
|
+
if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(value)) return value.replace(' ', 'T') + ':00';
|
|
17
|
+
// Already ISO format, pass through
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
9
20
|
|
|
10
21
|
class ApiService {
|
|
11
22
|
private client: AxiosInstance;
|
|
@@ -13,7 +24,7 @@ class ApiService {
|
|
|
13
24
|
constructor() {
|
|
14
25
|
this.client = axios.create({
|
|
15
26
|
baseURL: API_BASE,
|
|
16
|
-
timeout:
|
|
27
|
+
timeout: 30000,
|
|
17
28
|
headers: {
|
|
18
29
|
'Content-Type': 'application/json',
|
|
19
30
|
},
|
|
@@ -25,6 +36,10 @@ class ApiService {
|
|
|
25
36
|
if (token) {
|
|
26
37
|
config.headers.Authorization = `Bearer ${token}`;
|
|
27
38
|
}
|
|
39
|
+
// 请求体长度防护
|
|
40
|
+
if (config.data && JSON.stringify(config.data).length > 100_000) {
|
|
41
|
+
throw new Error('Request payload too large (max 100KB)');
|
|
42
|
+
}
|
|
28
43
|
return config;
|
|
29
44
|
});
|
|
30
45
|
|
|
@@ -59,7 +74,7 @@ class ApiService {
|
|
|
59
74
|
async createTodo(title: string, dueDate?: string, priority?: string) {
|
|
60
75
|
const { data } = await this.client.post('/api/v1/todos', {
|
|
61
76
|
title,
|
|
62
|
-
dueDate,
|
|
77
|
+
dueDate: toLocalDateTime(dueDate),
|
|
63
78
|
priority: priority || 'medium',
|
|
64
79
|
status: 'pending',
|
|
65
80
|
});
|
|
@@ -73,7 +88,7 @@ class ApiService {
|
|
|
73
88
|
}
|
|
74
89
|
|
|
75
90
|
async updateTodo(id: number, updates: Partial<{title: string; status: string; priority: string; dueDate: string}>) {
|
|
76
|
-
const { data } = await this.client.
|
|
91
|
+
const { data } = await this.client.patch(`/api/v1/todos/${id}`, updates);
|
|
77
92
|
return data;
|
|
78
93
|
}
|
|
79
94
|
|
|
@@ -141,7 +156,7 @@ class ApiService {
|
|
|
141
156
|
name,
|
|
142
157
|
category,
|
|
143
158
|
location,
|
|
144
|
-
expireDate,
|
|
159
|
+
expireDate: toLocalDateTime(expireDate),
|
|
145
160
|
});
|
|
146
161
|
return data;
|
|
147
162
|
}
|
|
@@ -158,8 +173,8 @@ class ApiService {
|
|
|
158
173
|
async createCalendarEvent(title: string, startTime: string, endTime: string, description?: string, location?: string) {
|
|
159
174
|
const { data } = await this.client.post('/api/v1/calendar-events', {
|
|
160
175
|
title,
|
|
161
|
-
startTime,
|
|
162
|
-
endTime,
|
|
176
|
+
startTime: toLocalDateTime(startTime),
|
|
177
|
+
endTime: toLocalDateTime(endTime),
|
|
163
178
|
description,
|
|
164
179
|
location,
|
|
165
180
|
});
|
|
@@ -178,7 +193,7 @@ class ApiService {
|
|
|
178
193
|
async createReminder(title: string, triggerTime: string, type: string = 'once') {
|
|
179
194
|
const { data } = await this.client.post('/api/v1/reminders', {
|
|
180
195
|
title,
|
|
181
|
-
triggerTime,
|
|
196
|
+
triggerTime: toLocalDateTime(triggerTime),
|
|
182
197
|
type,
|
|
183
198
|
status: 'active',
|
|
184
199
|
});
|