semantic-complexity 0.0.7-741984fb → 0.0.15-29c6b296
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/dist/__tests__/analyzers.test.d.ts +5 -0
- package/dist/__tests__/analyzers.test.d.ts.map +1 -0
- package/dist/__tests__/analyzers.test.js +357 -0
- package/dist/__tests__/analyzers.test.js.map +1 -0
- package/dist/__tests__/gate.test.d.ts +5 -0
- package/dist/__tests__/gate.test.d.ts.map +1 -0
- package/dist/__tests__/gate.test.js +140 -0
- package/dist/__tests__/gate.test.js.map +1 -0
- package/dist/analyzers/bread.d.ts +63 -0
- package/dist/analyzers/bread.d.ts.map +1 -0
- package/dist/analyzers/bread.js +415 -0
- package/dist/analyzers/bread.js.map +1 -0
- package/dist/analyzers/cheese.d.ts +111 -0
- package/dist/analyzers/cheese.d.ts.map +1 -0
- package/dist/analyzers/cheese.js +881 -0
- package/dist/analyzers/cheese.js.map +1 -0
- package/dist/analyzers/ham.d.ts +33 -0
- package/dist/analyzers/ham.d.ts.map +1 -0
- package/dist/analyzers/ham.js +264 -0
- package/dist/analyzers/ham.js.map +1 -0
- package/dist/analyzers/index.d.ts +7 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +7 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/budget/index.d.ts +50 -0
- package/dist/budget/index.d.ts.map +1 -0
- package/dist/budget/index.js +138 -0
- package/dist/budget/index.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +103 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/gate/index.d.ts +31 -0
- package/dist/gate/index.d.ts.map +1 -0
- package/dist/gate/index.js +117 -0
- package/dist/gate/index.js.map +1 -0
- package/dist/gate/waiver.d.ts +83 -0
- package/dist/gate/waiver.d.ts.map +1 -0
- package/dist/gate/waiver.js +425 -0
- package/dist/gate/waiver.js.map +1 -0
- package/dist/index.d.ts +8 -34
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -49
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +351 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/recommend/index.d.ts +32 -0
- package/dist/recommend/index.d.ts.map +1 -0
- package/dist/recommend/index.js +169 -0
- package/dist/recommend/index.js.map +1 -0
- package/dist/simplex/index.d.ts +26 -0
- package/dist/simplex/index.d.ts.map +1 -0
- package/dist/simplex/index.js +100 -0
- package/dist/simplex/index.js.map +1 -0
- package/dist/types/index.d.ts +39 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +27 -52
- package/LICENSE +0 -21
- package/README.md +0 -72
- package/dist/ast/index.d.ts +0 -2
- package/dist/ast/index.d.ts.map +0 -1
- package/dist/ast/index.js +0 -2
- package/dist/ast/index.js.map +0 -1
- package/dist/ast/parser.d.ts +0 -27
- package/dist/ast/parser.d.ts.map +0 -1
- package/dist/ast/parser.js +0 -273
- package/dist/ast/parser.js.map +0 -1
- package/dist/canonical/convergence.d.ts +0 -56
- package/dist/canonical/convergence.d.ts.map +0 -1
- package/dist/canonical/convergence.js +0 -149
- package/dist/canonical/convergence.js.map +0 -1
- package/dist/canonical/index.d.ts +0 -11
- package/dist/canonical/index.d.ts.map +0 -1
- package/dist/canonical/index.js +0 -11
- package/dist/canonical/index.js.map +0 -1
- package/dist/canonical/profiles.d.ts +0 -40
- package/dist/canonical/profiles.d.ts.map +0 -1
- package/dist/canonical/profiles.js +0 -182
- package/dist/canonical/profiles.js.map +0 -1
- package/dist/canonical/types.d.ts +0 -124
- package/dist/canonical/types.d.ts.map +0 -1
- package/dist/canonical/types.js +0 -46
- package/dist/canonical/types.js.map +0 -1
- package/dist/compare.d.ts +0 -31
- package/dist/compare.d.ts.map +0 -1
- package/dist/compare.js +0 -354
- package/dist/compare.js.map +0 -1
- package/dist/context/index.d.ts +0 -41
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js +0 -253
- package/dist/context/index.js.map +0 -1
- package/dist/gates/delta.d.ts +0 -45
- package/dist/gates/delta.d.ts.map +0 -1
- package/dist/gates/delta.js +0 -260
- package/dist/gates/delta.js.map +0 -1
- package/dist/gates/index.d.ts +0 -9
- package/dist/gates/index.d.ts.map +0 -1
- package/dist/gates/index.js +0 -9
- package/dist/gates/index.js.map +0 -1
- package/dist/gates/types.d.ts +0 -96
- package/dist/gates/types.d.ts.map +0 -1
- package/dist/gates/types.js +0 -59
- package/dist/gates/types.js.map +0 -1
- package/dist/graph/call.d.ts +0 -63
- package/dist/graph/call.d.ts.map +0 -1
- package/dist/graph/call.js +0 -240
- package/dist/graph/call.js.map +0 -1
- package/dist/graph/dependency.d.ts +0 -52
- package/dist/graph/dependency.d.ts.map +0 -1
- package/dist/graph/dependency.js +0 -296
- package/dist/graph/dependency.js.map +0 -1
- package/dist/graph/index.d.ts +0 -3
- package/dist/graph/index.d.ts.map +0 -1
- package/dist/graph/index.js +0 -3
- package/dist/graph/index.js.map +0 -1
- package/dist/metrics/cognitive.d.ts +0 -42
- package/dist/metrics/cognitive.d.ts.map +0 -1
- package/dist/metrics/cognitive.js +0 -204
- package/dist/metrics/cognitive.js.map +0 -1
- package/dist/metrics/cyclomatic.d.ts +0 -31
- package/dist/metrics/cyclomatic.d.ts.map +0 -1
- package/dist/metrics/cyclomatic.js +0 -121
- package/dist/metrics/cyclomatic.js.map +0 -1
- package/dist/metrics/dimensional.d.ts +0 -32
- package/dist/metrics/dimensional.d.ts.map +0 -1
- package/dist/metrics/dimensional.js +0 -560
- package/dist/metrics/dimensional.js.map +0 -1
- package/dist/metrics/index.d.ts +0 -26
- package/dist/metrics/index.d.ts.map +0 -1
- package/dist/metrics/index.js +0 -120
- package/dist/metrics/index.js.map +0 -1
- package/dist/metrics/meta.d.ts +0 -90
- package/dist/metrics/meta.d.ts.map +0 -1
- package/dist/metrics/meta.js +0 -144
- package/dist/metrics/meta.js.map +0 -1
- package/dist/tensor/canonical.d.ts +0 -53
- package/dist/tensor/canonical.d.ts.map +0 -1
- package/dist/tensor/canonical.js +0 -192
- package/dist/tensor/canonical.js.map +0 -1
- package/dist/tensor/index.d.ts +0 -22
- package/dist/tensor/index.d.ts.map +0 -1
- package/dist/tensor/index.js +0 -22
- package/dist/tensor/index.js.map +0 -1
- package/dist/tensor/matrix.d.ts +0 -62
- package/dist/tensor/matrix.d.ts.map +0 -1
- package/dist/tensor/matrix.js +0 -187
- package/dist/tensor/matrix.js.map +0 -1
- package/dist/tensor/scoring.d.ts +0 -82
- package/dist/tensor/scoring.d.ts.map +0 -1
- package/dist/tensor/scoring.js +0 -233
- package/dist/tensor/scoring.js.map +0 -1
- package/dist/tensor/types.d.ts +0 -186
- package/dist/tensor/types.d.ts.map +0 -1
- package/dist/tensor/types.js +0 -15
- package/dist/tensor/types.js.map +0 -1
- package/dist/types.d.ts +0 -341
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -22
- package/dist/types.js.map +0 -1
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* semantic-complexity MCP Server
|
|
3
|
+
*/
|
|
4
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
5
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
import { readFileSync } from 'fs';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
import { dirname, join } from 'path';
|
|
10
|
+
import { analyzeBread } from '../analyzers/bread.js';
|
|
11
|
+
import { analyzeCheese } from '../analyzers/cheese.js';
|
|
12
|
+
import { analyzeHam } from '../analyzers/ham.js';
|
|
13
|
+
import { normalize, calculateEquilibrium, getLabel } from '../simplex/index.js';
|
|
14
|
+
import { checkGate } from '../gate/index.js';
|
|
15
|
+
import { checkBudget, calculateDelta } from '../budget/index.js';
|
|
16
|
+
import { suggestRefactor, checkDegradation } from '../recommend/index.js';
|
|
17
|
+
// Canonical profile (ideal simplex coordinates by module type)
|
|
18
|
+
const CANONICAL_PROFILES = {
|
|
19
|
+
'api/external': { bread: 0.5, cheese: 0.3, ham: 0.2 },
|
|
20
|
+
'api/internal': { bread: 0.4, cheese: 0.35, ham: 0.25 },
|
|
21
|
+
'lib/domain': { bread: 0.2, cheese: 0.5, ham: 0.3 },
|
|
22
|
+
'lib/util': { bread: 0.1, cheese: 0.5, ham: 0.4 },
|
|
23
|
+
'app': { bread: 0.33, cheese: 0.34, ham: 0.33 },
|
|
24
|
+
'default': { bread: 1 / 3, cheese: 1 / 3, ham: 1 / 3 },
|
|
25
|
+
};
|
|
26
|
+
function calculateDeviation(current, canonical) {
|
|
27
|
+
return {
|
|
28
|
+
bread: current.bread - canonical.bread,
|
|
29
|
+
cheese: current.cheese - canonical.cheese,
|
|
30
|
+
ham: current.ham - canonical.ham,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// package.json에서 버전 동적으로 읽기
|
|
34
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
35
|
+
const __dirname = dirname(__filename);
|
|
36
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, '../../package.json'), 'utf-8'));
|
|
37
|
+
const server = new Server({
|
|
38
|
+
name: 'semantic-complexity',
|
|
39
|
+
version: packageJson.version,
|
|
40
|
+
}, {
|
|
41
|
+
capabilities: {
|
|
42
|
+
tools: {},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
// List available tools
|
|
46
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
47
|
+
tools: [
|
|
48
|
+
{
|
|
49
|
+
name: 'analyze_sandwich',
|
|
50
|
+
description: 'Analyze code complexity using Bread-Cheese-Ham model',
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
source: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
description: 'Source code to analyze',
|
|
57
|
+
},
|
|
58
|
+
file_path: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: 'Optional file path for context',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
required: ['source'],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'check_gate',
|
|
68
|
+
description: 'Check if code passes PoC/MVP/Production gate',
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: {
|
|
72
|
+
source: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
description: 'Source code to check',
|
|
75
|
+
},
|
|
76
|
+
gate_type: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
enum: ['poc', 'mvp', 'production'],
|
|
79
|
+
description: 'Gate type (default: mvp)',
|
|
80
|
+
},
|
|
81
|
+
file_path: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
description: 'File path for waiver check',
|
|
84
|
+
},
|
|
85
|
+
project_root: {
|
|
86
|
+
type: 'string',
|
|
87
|
+
description: 'Project root for waiver discovery',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
required: ['source'],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'analyze_cheese',
|
|
95
|
+
description: 'Analyze cognitive accessibility (Cheese axis)',
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
properties: {
|
|
99
|
+
source: {
|
|
100
|
+
type: 'string',
|
|
101
|
+
description: 'Source code to analyze',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
required: ['source'],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'suggest_refactor',
|
|
109
|
+
description: 'Suggest refactoring actions based on complexity analysis',
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: 'object',
|
|
112
|
+
properties: {
|
|
113
|
+
source: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
description: 'Source code to analyze',
|
|
116
|
+
},
|
|
117
|
+
module_type: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
enum: ['api/external', 'api/internal', 'lib/domain', 'lib/util', 'app'],
|
|
120
|
+
description: 'Module type for context-aware recommendations',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
required: ['source'],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'check_budget',
|
|
128
|
+
description: 'Check if code changes stay within allowed complexity budget',
|
|
129
|
+
inputSchema: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
properties: {
|
|
132
|
+
before_source: {
|
|
133
|
+
type: 'string',
|
|
134
|
+
description: 'Source code before changes',
|
|
135
|
+
},
|
|
136
|
+
after_source: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
description: 'Source code after changes',
|
|
139
|
+
},
|
|
140
|
+
module_type: {
|
|
141
|
+
type: 'string',
|
|
142
|
+
enum: ['api/external', 'api/internal', 'lib/domain', 'lib/util', 'app'],
|
|
143
|
+
description: 'Module type for budget limits',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
required: ['before_source', 'after_source'],
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'get_label',
|
|
151
|
+
description: 'Get dominant axis label (bread/cheese/ham/balanced)',
|
|
152
|
+
inputSchema: {
|
|
153
|
+
type: 'object',
|
|
154
|
+
properties: {
|
|
155
|
+
source: {
|
|
156
|
+
type: 'string',
|
|
157
|
+
description: 'Source code to analyze',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
required: ['source'],
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: 'check_degradation',
|
|
165
|
+
description: 'Detect cognitive degradation between code versions',
|
|
166
|
+
inputSchema: {
|
|
167
|
+
type: 'object',
|
|
168
|
+
properties: {
|
|
169
|
+
before_source: {
|
|
170
|
+
type: 'string',
|
|
171
|
+
description: 'Source code before changes',
|
|
172
|
+
},
|
|
173
|
+
after_source: {
|
|
174
|
+
type: 'string',
|
|
175
|
+
description: 'Source code after changes',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
required: ['before_source', 'after_source'],
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
}));
|
|
183
|
+
// Handle tool calls
|
|
184
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
185
|
+
const { name, arguments: args } = request.params;
|
|
186
|
+
switch (name) {
|
|
187
|
+
case 'analyze_sandwich': {
|
|
188
|
+
const source = args?.source;
|
|
189
|
+
const filePath = args?.file_path;
|
|
190
|
+
const bread = analyzeBread(source);
|
|
191
|
+
const cheese = analyzeCheese(source);
|
|
192
|
+
const ham = analyzeHam(source, filePath);
|
|
193
|
+
const simplex = normalize(bread, cheese, ham);
|
|
194
|
+
const equilibrium = calculateEquilibrium(simplex);
|
|
195
|
+
const label = getLabel(simplex);
|
|
196
|
+
const recommendations = suggestRefactor(simplex, equilibrium, cheese);
|
|
197
|
+
// Determine module type from file path or use default
|
|
198
|
+
let moduleType = 'default';
|
|
199
|
+
if (filePath) {
|
|
200
|
+
if (filePath.includes('/api/') || filePath.includes('\\api\\')) {
|
|
201
|
+
moduleType = filePath.includes('external') ? 'api/external' : 'api/internal';
|
|
202
|
+
}
|
|
203
|
+
else if (filePath.includes('/lib/') || filePath.includes('\\lib\\')) {
|
|
204
|
+
moduleType = filePath.includes('domain') ? 'lib/domain' : 'lib/util';
|
|
205
|
+
}
|
|
206
|
+
else if (filePath.includes('/app/') || filePath.includes('\\app\\')) {
|
|
207
|
+
moduleType = 'app';
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const canonical = CANONICAL_PROFILES[moduleType] || CANONICAL_PROFILES['default'];
|
|
211
|
+
const deviation = calculateDeviation(simplex, canonical);
|
|
212
|
+
return {
|
|
213
|
+
content: [
|
|
214
|
+
{
|
|
215
|
+
type: 'text',
|
|
216
|
+
text: JSON.stringify({
|
|
217
|
+
bread,
|
|
218
|
+
cheese,
|
|
219
|
+
ham,
|
|
220
|
+
simplex,
|
|
221
|
+
equilibrium,
|
|
222
|
+
label: label.label,
|
|
223
|
+
confidence: label.confidence,
|
|
224
|
+
canonical,
|
|
225
|
+
deviation,
|
|
226
|
+
recommendations,
|
|
227
|
+
}, null, 2),
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
case 'check_gate': {
|
|
233
|
+
const source = args?.source;
|
|
234
|
+
const gateType = args?.gate_type || 'mvp';
|
|
235
|
+
const filePath = args?.file_path;
|
|
236
|
+
const projectRoot = args?.project_root;
|
|
237
|
+
const cheese = analyzeCheese(source);
|
|
238
|
+
const ham = analyzeHam(source);
|
|
239
|
+
const result = checkGate(gateType, cheese, ham, {
|
|
240
|
+
source,
|
|
241
|
+
filePath,
|
|
242
|
+
projectRoot,
|
|
243
|
+
});
|
|
244
|
+
return {
|
|
245
|
+
content: [
|
|
246
|
+
{
|
|
247
|
+
type: 'text',
|
|
248
|
+
text: JSON.stringify(result, null, 2),
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
case 'analyze_cheese': {
|
|
254
|
+
const source = args?.source;
|
|
255
|
+
const cheese = analyzeCheese(source);
|
|
256
|
+
return {
|
|
257
|
+
content: [
|
|
258
|
+
{
|
|
259
|
+
type: 'text',
|
|
260
|
+
text: JSON.stringify(cheese, null, 2),
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
case 'suggest_refactor': {
|
|
266
|
+
const source = args?.source;
|
|
267
|
+
const bread = analyzeBread(source);
|
|
268
|
+
const cheese = analyzeCheese(source);
|
|
269
|
+
const ham = analyzeHam(source);
|
|
270
|
+
const simplex = normalize(bread, cheese, ham);
|
|
271
|
+
const equilibrium = calculateEquilibrium(simplex);
|
|
272
|
+
const recommendations = suggestRefactor(simplex, equilibrium, cheese);
|
|
273
|
+
return {
|
|
274
|
+
content: [
|
|
275
|
+
{
|
|
276
|
+
type: 'text',
|
|
277
|
+
text: JSON.stringify(recommendations, null, 2),
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
case 'check_budget': {
|
|
283
|
+
const beforeSource = args?.before_source;
|
|
284
|
+
const afterSource = args?.after_source;
|
|
285
|
+
const moduleType = args?.module_type || 'app';
|
|
286
|
+
const before = analyzeCheese(beforeSource);
|
|
287
|
+
const after = analyzeCheese(afterSource);
|
|
288
|
+
const delta = calculateDelta(before, after);
|
|
289
|
+
const result = checkBudget(moduleType, delta);
|
|
290
|
+
return {
|
|
291
|
+
content: [
|
|
292
|
+
{
|
|
293
|
+
type: 'text',
|
|
294
|
+
text: JSON.stringify(result, null, 2),
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
case 'get_label': {
|
|
300
|
+
const source = args?.source;
|
|
301
|
+
const bread = analyzeBread(source);
|
|
302
|
+
const cheese = analyzeCheese(source);
|
|
303
|
+
const ham = analyzeHam(source);
|
|
304
|
+
const simplex = normalize(bread, cheese, ham);
|
|
305
|
+
const label = getLabel(simplex);
|
|
306
|
+
return {
|
|
307
|
+
content: [
|
|
308
|
+
{
|
|
309
|
+
type: 'text',
|
|
310
|
+
text: JSON.stringify({ ...label, simplex }, null, 2),
|
|
311
|
+
},
|
|
312
|
+
],
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
case 'check_degradation': {
|
|
316
|
+
const beforeSource = args?.before_source;
|
|
317
|
+
const afterSource = args?.after_source;
|
|
318
|
+
const before = analyzeCheese(beforeSource);
|
|
319
|
+
const after = analyzeCheese(afterSource);
|
|
320
|
+
const result = checkDegradation(before, after);
|
|
321
|
+
return {
|
|
322
|
+
content: [
|
|
323
|
+
{
|
|
324
|
+
type: 'text',
|
|
325
|
+
text: JSON.stringify({
|
|
326
|
+
degraded: result.degraded,
|
|
327
|
+
severity: result.severity,
|
|
328
|
+
indicators: result.indicators,
|
|
329
|
+
beforeAccessible: result.beforeAccessible,
|
|
330
|
+
afterAccessible: result.afterAccessible,
|
|
331
|
+
delta: {
|
|
332
|
+
nesting: result.deltaNesting,
|
|
333
|
+
hiddenDeps: result.deltaHiddenDeps,
|
|
334
|
+
violations: result.deltaViolations,
|
|
335
|
+
},
|
|
336
|
+
}, null, 2),
|
|
337
|
+
},
|
|
338
|
+
],
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
default:
|
|
342
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
// Start server
|
|
346
|
+
export async function main() {
|
|
347
|
+
const transport = new StdioServerTransport();
|
|
348
|
+
await server.connect(transport);
|
|
349
|
+
}
|
|
350
|
+
main().catch(console.error);
|
|
351
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,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,gBAAgB;4BACzC,eAAe,EAAE,MAAM,CAAC,eAAe;4BACvC,KAAK,EAAE;gCACL,OAAO,EAAE,MAAM,CAAC,YAAY;gCAC5B,UAAU,EAAE,MAAM,CAAC,eAAe;gCAClC,UAAU,EAAE,MAAM,CAAC,eAAe;6BACnC;yBACF,EAAE,IAAI,EAAE,CAAC,CAAC;qBACZ;iBACF;aACF,CAAC;QACJ,CAAC;QAED;YACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe;AACf,MAAM,CAAC,KAAK,UAAU,IAAI;IACxB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gradient-based Recommender
|
|
3
|
+
*
|
|
4
|
+
* 균형점으로 향하는 리팩토링 권장사항 생성
|
|
5
|
+
*/
|
|
6
|
+
import type { CheeseResult } from '../analyzers/cheese.js';
|
|
7
|
+
import type { SimplexCoordinates, EquilibriumResult } from '../types/index.js';
|
|
8
|
+
export type Axis = 'bread' | 'cheese' | 'ham';
|
|
9
|
+
export interface Recommendation {
|
|
10
|
+
axis: Axis;
|
|
11
|
+
priority: number;
|
|
12
|
+
action: string;
|
|
13
|
+
reason: string;
|
|
14
|
+
expectedImpact: Record<string, number>;
|
|
15
|
+
targetEquilibrium: boolean;
|
|
16
|
+
}
|
|
17
|
+
export type Severity = 'none' | 'mild' | 'moderate' | 'severe';
|
|
18
|
+
export interface DegradationResult {
|
|
19
|
+
degraded: boolean;
|
|
20
|
+
severity: Severity;
|
|
21
|
+
indicators: string[];
|
|
22
|
+
beforeAccessible: boolean;
|
|
23
|
+
afterAccessible: boolean;
|
|
24
|
+
deltaNesting: number;
|
|
25
|
+
deltaHiddenDeps: number;
|
|
26
|
+
deltaViolations: number;
|
|
27
|
+
}
|
|
28
|
+
export declare const CHEESE_ANTI_PATTERNS: string[][];
|
|
29
|
+
export declare function suggestRefactor(simplex: SimplexCoordinates, equilibrium: EquilibriumResult, cheeseResult?: CheeseResult, maxRecommendations?: number): Recommendation[];
|
|
30
|
+
export declare function getPriorityAction(simplex: SimplexCoordinates, equilibrium: EquilibriumResult, cheeseResult?: CheeseResult): Recommendation | null;
|
|
31
|
+
export declare function checkDegradation(before: CheeseResult, after: CheeseResult): DegradationResult;
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/recommend/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAM/E,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE9C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE/D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB;AAgCD,eAAO,MAAM,oBAAoB,YAKhC,CAAC;AAuBF,wBAAgB,eAAe,CAC7B,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,iBAAiB,EAC9B,YAAY,CAAC,EAAE,YAAY,EAC3B,kBAAkB,SAAI,GACrB,cAAc,EAAE,CAsDlB;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,iBAAiB,EAC9B,YAAY,CAAC,EAAE,YAAY,GAC1B,cAAc,GAAG,IAAI,CAGvB;AAMD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,YAAY,GAClB,iBAAiB,CA0DnB"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gradient-based Recommender
|
|
3
|
+
*
|
|
4
|
+
* 균형점으로 향하는 리팩토링 권장사항 생성
|
|
5
|
+
*/
|
|
6
|
+
// =============================================================
|
|
7
|
+
// Refactoring Actions by Axis
|
|
8
|
+
// =============================================================
|
|
9
|
+
const BREAD_ACTIONS = {
|
|
10
|
+
increase: [
|
|
11
|
+
['Add explicit trust boundary', 'Define trust boundary in code explicitly'],
|
|
12
|
+
['Apply auth decorators', 'Add @Auth, @Protected decorators to endpoints'],
|
|
13
|
+
['Add input validation', 'Add validation for external inputs'],
|
|
14
|
+
],
|
|
15
|
+
decrease: [
|
|
16
|
+
['Separate security logic', 'Extract security logic from business logic'],
|
|
17
|
+
['Extract common security middleware', 'Move repeated security patterns to middleware'],
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
const CHEESE_ACTIONS = {
|
|
21
|
+
increase: [
|
|
22
|
+
['Add proper error handling', 'Add exception handling for edge cases'],
|
|
23
|
+
],
|
|
24
|
+
decrease: [
|
|
25
|
+
['Flatten nesting (early return)', 'Use early return to reduce nesting depth'],
|
|
26
|
+
['Extract function', 'Extract complex blocks to separate functions (no param bundling)'],
|
|
27
|
+
['Simplify conditions', 'Extract complex conditions to named variables'],
|
|
28
|
+
['Separate state logic', 'Split state×async×retry into separate concerns'],
|
|
29
|
+
['Switch → polymorphism', 'Replace switch with Strategy pattern'],
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
// 🚫 Anti-patterns (LLM should not use these)
|
|
33
|
+
export const CHEESE_ANTI_PATTERNS = [
|
|
34
|
+
['No rest parameters abuse', '...args to hide parameter count is a complexity evasion trick'],
|
|
35
|
+
['No config object bundling', 'Do not bundle unrelated params into config objects'],
|
|
36
|
+
['No tuple/dict params', 'params: any[] or options: object hides meaning'],
|
|
37
|
+
['No inline substitution', 'Do not replace named variables with inline expressions'],
|
|
38
|
+
];
|
|
39
|
+
const HAM_ACTIONS = {
|
|
40
|
+
increase: [
|
|
41
|
+
['Add golden tests', 'Write golden tests for critical paths'],
|
|
42
|
+
['Add contract tests', 'Write API contract tests'],
|
|
43
|
+
['Organize test fixtures', 'Structure test code better'],
|
|
44
|
+
],
|
|
45
|
+
decrease: [
|
|
46
|
+
['Remove duplicate tests', 'Clean up unnecessary test duplication'],
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
const AXIS_ACTIONS = {
|
|
50
|
+
bread: BREAD_ACTIONS,
|
|
51
|
+
cheese: CHEESE_ACTIONS,
|
|
52
|
+
ham: HAM_ACTIONS,
|
|
53
|
+
};
|
|
54
|
+
// =============================================================
|
|
55
|
+
// Recommender
|
|
56
|
+
// =============================================================
|
|
57
|
+
export function suggestRefactor(simplex, equilibrium, cheeseResult, maxRecommendations = 3) {
|
|
58
|
+
const recommendations = [];
|
|
59
|
+
// If in equilibrium, no recommendations needed
|
|
60
|
+
if (equilibrium.inEquilibrium) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
// state×async×retry violation is highest priority
|
|
64
|
+
if (cheeseResult?.stateAsyncRetry.violated) {
|
|
65
|
+
recommendations.push({
|
|
66
|
+
axis: 'cheese',
|
|
67
|
+
priority: 0,
|
|
68
|
+
action: 'Separate state×async×retry',
|
|
69
|
+
reason: `Cognitive invariant violation - ${cheeseResult.stateAsyncRetry.axes.join('×')} must be separated`,
|
|
70
|
+
expectedImpact: { cheese: -20 },
|
|
71
|
+
targetEquilibrium: true,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Generate recommendations based on dominant axis
|
|
75
|
+
const { bread, cheese, ham } = simplex;
|
|
76
|
+
const ideal = 1 / 3;
|
|
77
|
+
const deviations = [
|
|
78
|
+
{ axis: 'bread', deviation: bread - ideal, direction: bread > ideal ? 'decrease' : 'increase' },
|
|
79
|
+
{ axis: 'cheese', deviation: cheese - ideal, direction: cheese > ideal ? 'decrease' : 'increase' },
|
|
80
|
+
{ axis: 'ham', deviation: ham - ideal, direction: ham > ideal ? 'decrease' : 'increase' },
|
|
81
|
+
];
|
|
82
|
+
// Sort by absolute deviation (largest first)
|
|
83
|
+
deviations.sort((a, b) => Math.abs(b.deviation) - Math.abs(a.deviation));
|
|
84
|
+
let priority = recommendations.length + 1;
|
|
85
|
+
for (const { axis, deviation, direction } of deviations) {
|
|
86
|
+
if (recommendations.length >= maxRecommendations)
|
|
87
|
+
break;
|
|
88
|
+
if (Math.abs(deviation) < 0.1)
|
|
89
|
+
continue; // Skip small deviations
|
|
90
|
+
const actions = AXIS_ACTIONS[axis][direction];
|
|
91
|
+
if (actions && actions.length > 0) {
|
|
92
|
+
const [action, reason] = actions[0];
|
|
93
|
+
recommendations.push({
|
|
94
|
+
axis,
|
|
95
|
+
priority,
|
|
96
|
+
action,
|
|
97
|
+
reason,
|
|
98
|
+
expectedImpact: { [axis]: direction === 'decrease' ? -Math.abs(deviation) * 100 : Math.abs(deviation) * 100 },
|
|
99
|
+
targetEquilibrium: true,
|
|
100
|
+
});
|
|
101
|
+
priority++;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return recommendations;
|
|
105
|
+
}
|
|
106
|
+
export function getPriorityAction(simplex, equilibrium, cheeseResult) {
|
|
107
|
+
const recommendations = suggestRefactor(simplex, equilibrium, cheeseResult, 1);
|
|
108
|
+
return recommendations[0] || null;
|
|
109
|
+
}
|
|
110
|
+
// =============================================================
|
|
111
|
+
// Degradation Detection
|
|
112
|
+
// =============================================================
|
|
113
|
+
export function checkDegradation(before, after) {
|
|
114
|
+
const indicators = [];
|
|
115
|
+
// 1. Accessibility state transition
|
|
116
|
+
const accessibilityLost = before.accessible && !after.accessible;
|
|
117
|
+
if (accessibilityLost) {
|
|
118
|
+
indicators.push('Accessibility lost (accessible: true → false)');
|
|
119
|
+
}
|
|
120
|
+
// 2. Nesting depth increase
|
|
121
|
+
const deltaNesting = after.maxNesting - before.maxNesting;
|
|
122
|
+
if (deltaNesting > 0) {
|
|
123
|
+
indicators.push(`Nesting depth increased: +${deltaNesting} (${before.maxNesting} → ${after.maxNesting})`);
|
|
124
|
+
}
|
|
125
|
+
// 3. Hidden dependencies increase
|
|
126
|
+
const deltaHiddenDeps = after.hiddenDependencies - before.hiddenDependencies;
|
|
127
|
+
if (deltaHiddenDeps > 0) {
|
|
128
|
+
indicators.push(`Hidden dependencies increased: +${deltaHiddenDeps}`);
|
|
129
|
+
}
|
|
130
|
+
// 4. state×async×retry violation introduced
|
|
131
|
+
const sarBefore = before.stateAsyncRetry.violated;
|
|
132
|
+
const sarAfter = after.stateAsyncRetry.violated;
|
|
133
|
+
if (!sarBefore && sarAfter) {
|
|
134
|
+
indicators.push(`state×async×retry violation introduced: ${after.stateAsyncRetry.axes.join(' × ')}`);
|
|
135
|
+
}
|
|
136
|
+
// 5. Violations increase
|
|
137
|
+
const deltaViolations = after.violations.length - before.violations.length;
|
|
138
|
+
if (deltaViolations > 0) {
|
|
139
|
+
indicators.push(`Violations increased: +${deltaViolations}`);
|
|
140
|
+
}
|
|
141
|
+
// Severity determination
|
|
142
|
+
let severity;
|
|
143
|
+
if (indicators.length === 0) {
|
|
144
|
+
severity = 'none';
|
|
145
|
+
}
|
|
146
|
+
else if (accessibilityLost) {
|
|
147
|
+
severity = 'severe';
|
|
148
|
+
}
|
|
149
|
+
else if (indicators.length >= 3) {
|
|
150
|
+
severity = 'severe';
|
|
151
|
+
}
|
|
152
|
+
else if (indicators.length >= 2) {
|
|
153
|
+
severity = 'moderate';
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
severity = 'mild';
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
degraded: indicators.length > 0,
|
|
160
|
+
severity,
|
|
161
|
+
indicators,
|
|
162
|
+
beforeAccessible: before.accessible,
|
|
163
|
+
afterAccessible: after.accessible,
|
|
164
|
+
deltaNesting,
|
|
165
|
+
deltaHiddenDeps,
|
|
166
|
+
deltaViolations,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/recommend/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiCH,gEAAgE;AAChE,8BAA8B;AAC9B,gEAAgE;AAEhE,MAAM,aAAa,GAAG;IACpB,QAAQ,EAAE;QACR,CAAC,6BAA6B,EAAE,0CAA0C,CAAC;QAC3E,CAAC,uBAAuB,EAAE,+CAA+C,CAAC;QAC1E,CAAC,sBAAsB,EAAE,oCAAoC,CAAC;KAC/D;IACD,QAAQ,EAAE;QACR,CAAC,yBAAyB,EAAE,4CAA4C,CAAC;QACzE,CAAC,oCAAoC,EAAE,+CAA+C,CAAC;KACxF;CACF,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,QAAQ,EAAE;QACR,CAAC,2BAA2B,EAAE,uCAAuC,CAAC;KACvE;IACD,QAAQ,EAAE;QACR,CAAC,gCAAgC,EAAE,0CAA0C,CAAC;QAC9E,CAAC,kBAAkB,EAAE,kEAAkE,CAA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ACtB,CAAC;SAAM,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QAClC,QAAQ,GAAG,QAAQ,CAAC;IACtB,CAAC;SAAM,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QAClC,QAAQ,GAAG,UAAU,CAAC;IACxB,CAAC;SAAM,CAAC;QACN,QAAQ,GAAG,MAAM,CAAC;IACpB,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC;QAC/B,QAAQ;QACR,UAAU;QACV,gBAAgB,EAAE,MAAM,CAAC,UAAU;QACnC,eAAe,EAAE,KAAK,CAAC,UAAU;QACjC,YAAY;QACZ,eAAe;QACf,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplex - Normalization & Equilibrium
|
|
3
|
+
*
|
|
4
|
+
* Normalizes Bread, Cheese, Ham scores to simplex coordinates
|
|
5
|
+
* and calculates equilibrium state.
|
|
6
|
+
*/
|
|
7
|
+
import type { BreadResult } from '../analyzers/bread.js';
|
|
8
|
+
import type { CheeseResult } from '../analyzers/cheese.js';
|
|
9
|
+
import type { HamResult } from '../analyzers/ham.js';
|
|
10
|
+
import type { SimplexCoordinates, EquilibriumResult } from '../types/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Normalize scores to simplex coordinates (sum = 1)
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalize(bread: BreadResult, cheese: CheeseResult, ham: HamResult): SimplexCoordinates;
|
|
15
|
+
/**
|
|
16
|
+
* Calculate equilibrium state
|
|
17
|
+
*/
|
|
18
|
+
export declare function calculateEquilibrium(simplex: SimplexCoordinates): EquilibriumResult;
|
|
19
|
+
/**
|
|
20
|
+
* Get label based on dominant axis
|
|
21
|
+
*/
|
|
22
|
+
export declare function getLabel(simplex: SimplexCoordinates): {
|
|
23
|
+
label: 'bread' | 'cheese' | 'ham' | 'balanced';
|
|
24
|
+
confidence: number;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/simplex/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE/E;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,GACb,kBAAkB,CAiBpB;AA4CD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,kBAAkB,GAC1B,iBAAiB,CA0BnB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG;IACrD,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,UAAU,CAAC;IAC/C,UAAU,EAAE,MAAM,CAAC;CACpB,CAWA"}
|