ai-metrics-mcp-server 1.0.9

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/src/test.js ADDED
@@ -0,0 +1,220 @@
1
+ /**
2
+ * MCP Server测试脚本
3
+ */
4
+
5
+ import CodeStatsCollector from './collector.js';
6
+
7
+ // 打印方法,打印hell git-hook
8
+ function printHellGitHook() {
9
+ console.log('hell git-hook');
10
+ console.log('hell git-hook');
11
+ console.log('hell git-hook');
12
+ }
13
+
14
+ // 打印方法,打印delete sessions
15
+ function printDeleteSessions() {
16
+ console.log('delete sessions');
17
+ console.log('delete sessions');
18
+ console.log('delete sessions');
19
+ console.log('delete sessions');
20
+ console.log('delete sessions');
21
+ }
22
+
23
+ // 打印方法,打印hook-version
24
+ function printHookVersion() {
25
+ console.log('hook-version');
26
+ }
27
+
28
+ // 打印方法,打印hook-version-1
29
+ function printHookVersion1() {
30
+ console.log('hook-version-1');
31
+ }
32
+
33
+ // 打印方法,打印完美。。。。
34
+ function printPerfect() {
35
+ console.log('完美。。。。');
36
+ }
37
+
38
+ // 打印方法,打印hello night
39
+ function printHelloNight() {
40
+ console.log('hello night');
41
+ }
42
+
43
+ // 打印方法,打印我叫刘文胜
44
+ function printLiuWensheng() {
45
+ console.log('我叫刘文胜');
46
+ console.log('我叫刘文胜1');
47
+ console.log('我叫刘文胜2');
48
+ console.log('我叫刘文胜3');
49
+ }
50
+
51
+ // 打印方法,打印新功能
52
+ function printNewFeature() {
53
+ console.log('新功能已添加');
54
+ console.log('打印功能正常工作了');
55
+ }
56
+
57
+ // 打印方法,打印git-hook触发信息
58
+ function printGitHookTrigger() {
59
+ console.log('Git Hook 已触发');
60
+ console.log('Git Hook 触发成功');
61
+ console.log('Git Hook 触发完成');
62
+ }
63
+
64
+ // 打印方法,打印验证失败的上传任务
65
+ function printFailedUploadTask() {
66
+ console.log('上传任务验证失败');
67
+ console.log('请检查上传内容');
68
+ console.log('验证失败原因:参数不完整');
69
+ }
70
+
71
+ // 打印方法,打印验证git-commit数据的正确性
72
+ function printGitCommitValidation() {
73
+ console.log('正在验证git-commit数据');
74
+ console.log('验证结果:数据正确');
75
+ console.log('git-commit数据验证通过');
76
+ }
77
+
78
+ // 打印方法,打印在验证cursor数据上报
79
+ function printValidateCursorData() {
80
+ console.log('在验证cursor数据上报');
81
+ }
82
+
83
+ // 打印方法,打印验证cursor的mcp是否生效
84
+ function printValidateCursorMcp() {
85
+ console.log('正在验证cursor的mcp是否生效');
86
+ console.log('检查beforeEditFile工具');
87
+ console.log('检查afterEditFile工具');
88
+ console.log('检查recordSession工具');
89
+ console.log('mcp工具验证完成');
90
+ }
91
+
92
+ // 打印方法,打印IDE-TYPE
93
+ function printIdeType() {
94
+ console.log('IDE-TYPE');
95
+ }
96
+
97
+ // 打印方法,打印我是熊
98
+ function printXiong() {
99
+ console.log('我是熊');
100
+ }
101
+
102
+ // 打印方法,打印今天周五了
103
+ function printFriday() {
104
+ console.log('今天周五了');
105
+ }
106
+
107
+ async function test() {
108
+ console.log('=== MCP Server Test ===\n');
109
+
110
+ // 调用打印方法
111
+ printHellGitHook();
112
+
113
+ // 调用新的打印方法
114
+ printDeleteSessions();
115
+
116
+ // 调用打印我是rowans的方法
117
+ printRowans();
118
+
119
+ // 调用打印我是rowans-1的方法
120
+ printRowans1();
121
+
122
+ // 调用打印hook-version的方法
123
+ printHookVersion();
124
+
125
+ // 调用打印hook-version-1的方法
126
+ printHookVersion1();
127
+
128
+ // 调用打印完美。。。。的方法
129
+ printPerfect();
130
+
131
+ // 调用打印hello night的方法
132
+ printHelloNight();
133
+
134
+ // 调用打印我叫刘文胜的方法
135
+ printLiuWensheng();
136
+
137
+ // 调用打印新功能的方法
138
+ printNewFeature();
139
+
140
+ // 调用打印git-hook触发的方法
141
+ printGitHookTrigger();
142
+
143
+ // 调用打印验证失败的上传任务的方法
144
+ printFailedUploadTask();
145
+
146
+ // 调用打印验证git-commit数据正确性的方法
147
+ printGitCommitValidation();
148
+
149
+ // 调用打印验证cursor的mcp是否生效的方法
150
+ printValidateCursorMcp();
151
+
152
+ // 调用打印IDE-TYPE的方法
153
+ printIdeType();
154
+
155
+ // 调用打印我是熊的方法
156
+ printXiong();
157
+
158
+ // 调用打印今天周五了的方法
159
+ printFriday();
160
+
161
+ const collector = new CodeStatsCollector();
162
+
163
+ // 测试1: beforeEditFile
164
+ console.log('Test 1: beforeEditFile');
165
+ const result1 = await collector.handleToolCall('beforeEditFile', {
166
+ sessionId: 'test-session-001',
167
+ filePaths: ['/Users/yanghongfeng1/jdcode/ai-extension-code-stats/test-file.js'],
168
+ operation: 'create'
169
+ });
170
+ console.log('Result:', JSON.parse(result1.content[0].text));
171
+ console.log('');
172
+
173
+ // 测试2: afterEditFile
174
+ console.log('Test 2: afterEditFile');
175
+ const result2 = await collector.handleToolCall('afterEditFile', {
176
+ sessionId: 'test-session-001',
177
+ filePaths: ['/Users/yanghongfeng1/jdcode/ai-extension-code-stats/test-file.js'],
178
+ changes: [
179
+ {
180
+ filePath: '/Users/yanghongfeng1/jdcode/ai-extension-code-stats/test-file.js',
181
+ generatedLines: [
182
+ { lineNumber: 1, content: 'function hello() {' },
183
+ { lineNumber: 2, content: ' console.log("Hello");' },
184
+ { lineNumber: 3, content: '}' }
185
+ ],
186
+ totalLines: 3
187
+ }
188
+ ]
189
+ });
190
+ console.log('Result:', JSON.parse(result2.content[0].text));
191
+ console.log('');
192
+
193
+ // 测试3: recordSession
194
+ console.log('Test 3: recordSession');
195
+ const result3 = await collector.handleToolCall('recordSession', {
196
+ sessionId: 'test-session-001',
197
+ prompt: 'Create a hello function',
198
+ aiModel: 'test-model',
199
+ conversationRounds: 1,
200
+ isAdopted: true
201
+ });
202
+ console.log('Result:', JSON.parse(result3.content[0].text));
203
+ console.log('');
204
+
205
+ // 测试4: 非Git项目
206
+ console.log('Test 4: Non-Git Project Handling');
207
+ const result4 = await collector.handleToolCall('recordSession', {
208
+ sessionId: 'non-git-test-001',
209
+ prompt: 'Test non-git',
210
+ aiModel: 'test-model',
211
+ conversationRounds: 1,
212
+ isAdopted: false
213
+ });
214
+ console.log('Result:', JSON.parse(result4.content[0].text));
215
+ console.log('');
216
+
217
+ console.log('=== Test Completed ===');
218
+ }
219
+
220
+ test().catch(console.error);