skhaall-codeguard 0.1.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/LICENSE +21 -0
- package/README.md +125 -0
- package/dist/cli.d.ts +16 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +295 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/indexer.d.ts +21 -0
- package/dist/core/indexer.d.ts.map +1 -0
- package/dist/core/indexer.js +96 -0
- package/dist/core/indexer.js.map +1 -0
- package/dist/graph/dependency-graph.d.ts +37 -0
- package/dist/graph/dependency-graph.d.ts.map +1 -0
- package/dist/graph/dependency-graph.js +94 -0
- package/dist/graph/dependency-graph.js.map +1 -0
- package/dist/graph/impact-resolver.d.ts +40 -0
- package/dist/graph/impact-resolver.d.ts.map +1 -0
- package/dist/graph/impact-resolver.js +108 -0
- package/dist/graph/impact-resolver.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +299 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/base-parser.d.ts +111 -0
- package/dist/parsers/base-parser.d.ts.map +1 -0
- package/dist/parsers/base-parser.js +7 -0
- package/dist/parsers/base-parser.js.map +1 -0
- package/dist/parsers/detector.d.ts +10 -0
- package/dist/parsers/detector.d.ts.map +1 -0
- package/dist/parsers/detector.js +61 -0
- package/dist/parsers/detector.js.map +1 -0
- package/dist/parsers/extractors/api-calls.d.ts +10 -0
- package/dist/parsers/extractors/api-calls.d.ts.map +1 -0
- package/dist/parsers/extractors/api-calls.js +99 -0
- package/dist/parsers/extractors/api-calls.js.map +1 -0
- package/dist/parsers/extractors/auth-guards.d.ts +8 -0
- package/dist/parsers/extractors/auth-guards.d.ts.map +1 -0
- package/dist/parsers/extractors/auth-guards.js +23 -0
- package/dist/parsers/extractors/auth-guards.js.map +1 -0
- package/dist/parsers/prisma-parser.d.ts +45 -0
- package/dist/parsers/prisma-parser.d.ts.map +1 -0
- package/dist/parsers/prisma-parser.js +197 -0
- package/dist/parsers/prisma-parser.js.map +1 -0
- package/dist/parsers/typescript-parser.d.ts +28 -0
- package/dist/parsers/typescript-parser.d.ts.map +1 -0
- package/dist/parsers/typescript-parser.js +374 -0
- package/dist/parsers/typescript-parser.js.map +1 -0
- package/dist/setup.d.ts +10 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +135 -0
- package/dist/setup.js.map +1 -0
- package/dist/storage/index-store.d.ts +36 -0
- package/dist/storage/index-store.d.ts.map +1 -0
- package/dist/storage/index-store.js +108 -0
- package/dist/storage/index-store.js.map +1 -0
- package/dist/tools/changelog.d.ts +36 -0
- package/dist/tools/changelog.d.ts.map +1 -0
- package/dist/tools/changelog.js +212 -0
- package/dist/tools/changelog.js.map +1 -0
- package/dist/tools/check.d.ts +31 -0
- package/dist/tools/check.d.ts.map +1 -0
- package/dist/tools/check.js +180 -0
- package/dist/tools/check.js.map +1 -0
- package/dist/tools/graph.d.ts +20 -0
- package/dist/tools/graph.d.ts.map +1 -0
- package/dist/tools/graph.js +192 -0
- package/dist/tools/graph.js.map +1 -0
- package/dist/tools/guard.d.ts +30 -0
- package/dist/tools/guard.d.ts.map +1 -0
- package/dist/tools/guard.js +132 -0
- package/dist/tools/guard.js.map +1 -0
- package/dist/tools/health.d.ts +33 -0
- package/dist/tools/health.d.ts.map +1 -0
- package/dist/tools/health.js +241 -0
- package/dist/tools/health.js.map +1 -0
- package/dist/tools/impact.d.ts +10 -0
- package/dist/tools/impact.d.ts.map +1 -0
- package/dist/tools/impact.js +45 -0
- package/dist/tools/impact.js.map +1 -0
- package/dist/tools/regression.d.ts +29 -0
- package/dist/tools/regression.d.ts.map +1 -0
- package/dist/tools/regression.js +151 -0
- package/dist/tools/regression.js.map +1 -0
- package/dist/tools/routes.d.ts +40 -0
- package/dist/tools/routes.d.ts.map +1 -0
- package/dist/tools/routes.js +203 -0
- package/dist/tools/routes.js.map +1 -0
- package/dist/tools/schema.d.ts +37 -0
- package/dist/tools/schema.d.ts.map +1 -0
- package/dist/tools/schema.js +214 -0
- package/dist/tools/schema.js.map +1 -0
- package/dist/tools/search.d.ts +18 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +99 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/tool-definitions.d.ts +15 -0
- package/dist/tools/tool-definitions.d.ts.map +1 -0
- package/dist/tools/tool-definitions.js +157 -0
- package/dist/tools/tool-definitions.js.map +1 -0
- package/dist/utils/import-resolver.d.ts +33 -0
- package/dist/utils/import-resolver.d.ts.map +1 -0
- package/dist/utils/import-resolver.js +150 -0
- package/dist/utils/import-resolver.js.map +1 -0
- package/dist/utils/logger.d.ts +15 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +49 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/path.d.ts +6 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +12 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/scanner.d.ts +13 -0
- package/dist/utils/scanner.d.ts.map +1 -0
- package/dist/utils/scanner.js +55 -0
- package/dist/utils/scanner.js.map +1 -0
- package/dist/utils/validators.d.ts +45 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/utils/validators.js +54 -0
- package/dist/utils/validators.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outil MCP : schema_check
|
|
3
|
+
* Coherence Prisma ↔ DTOs backend ↔ types frontend.
|
|
4
|
+
* Detecte les champs manquants, types incompatibles, enums desynchronises.
|
|
5
|
+
*/
|
|
6
|
+
import { toShortPath } from '../utils/path.js';
|
|
7
|
+
export function runSchemaCheck(index) {
|
|
8
|
+
const issues = [];
|
|
9
|
+
const matches = [];
|
|
10
|
+
// 1. Trouver les types Prisma dans l'index (fichiers .prisma)
|
|
11
|
+
const prismaTypes = [];
|
|
12
|
+
let prismaFile = '';
|
|
13
|
+
let enumCount = 0;
|
|
14
|
+
for (const [filePath, node] of Object.entries(index.files)) {
|
|
15
|
+
if (node.language === 'prisma') {
|
|
16
|
+
prismaFile = filePath;
|
|
17
|
+
for (const type of node.types) {
|
|
18
|
+
if (type.kind === 'enum') {
|
|
19
|
+
enumCount++;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
prismaTypes.push(type);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (prismaTypes.length === 0) {
|
|
28
|
+
return { modelCount: 0, enumCount: 0, matches, issues, issueCount: 0 };
|
|
29
|
+
}
|
|
30
|
+
// 2. Pour chaque modele Prisma, chercher les DTOs/types correspondants
|
|
31
|
+
const nonPrismaTypes = collectNonPrismaTypes(index);
|
|
32
|
+
for (const prismaModel of prismaTypes) {
|
|
33
|
+
const prismaFields = prismaModel.properties.map((p) => p.name);
|
|
34
|
+
const matchCandidates = findMatchingTypes(prismaModel.name, nonPrismaTypes);
|
|
35
|
+
if (matchCandidates.length === 0) {
|
|
36
|
+
issues.push({
|
|
37
|
+
severity: 'info',
|
|
38
|
+
model: prismaModel.name,
|
|
39
|
+
message: `Aucun DTO/type correspondant trouve pour le modele "${prismaModel.name}"`,
|
|
40
|
+
prismaFile,
|
|
41
|
+
});
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
for (const candidate of matchCandidates) {
|
|
45
|
+
const candidateFields = candidate.type.properties.map((p) => p.name);
|
|
46
|
+
const missingFields = prismaFields.filter((f) => !candidateFields.includes(f));
|
|
47
|
+
const extraFields = candidateFields.filter((f) => !prismaFields.includes(f));
|
|
48
|
+
matches.push({
|
|
49
|
+
prismaModel: prismaModel.name,
|
|
50
|
+
matchedType: candidate.type.name,
|
|
51
|
+
matchedFile: candidate.filePath,
|
|
52
|
+
missingFields,
|
|
53
|
+
extraFields,
|
|
54
|
+
});
|
|
55
|
+
// Signaler les champs manquants importants (pas les relations, pas createdAt/updatedAt)
|
|
56
|
+
const significantMissing = missingFields.filter((f) => !['createdAt', 'updatedAt', 'deletedAt', 'id'].includes(f));
|
|
57
|
+
if (significantMissing.length > 0) {
|
|
58
|
+
issues.push({
|
|
59
|
+
severity: 'warning',
|
|
60
|
+
model: prismaModel.name,
|
|
61
|
+
message: `"${candidate.type.name}" manque ${significantMissing.length} champ(s) Prisma : ${significantMissing.join(', ')}`,
|
|
62
|
+
prismaFile,
|
|
63
|
+
matchFile: candidate.filePath,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// Signaler les champs extra (potentiellement des champs calcules — juste info)
|
|
67
|
+
if (extraFields.length > 0) {
|
|
68
|
+
issues.push({
|
|
69
|
+
severity: 'info',
|
|
70
|
+
model: prismaModel.name,
|
|
71
|
+
message: `"${candidate.type.name}" a ${extraFields.length} champ(s) supplementaire(s) : ${extraFields.join(', ')}`,
|
|
72
|
+
matchFile: candidate.filePath,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// 3. Verifier les enums
|
|
78
|
+
const prismaEnums = collectPrismaEnums(index);
|
|
79
|
+
const tsEnums = collectTsEnums(nonPrismaTypes);
|
|
80
|
+
for (const prismaEnum of prismaEnums) {
|
|
81
|
+
const tsMatch = tsEnums.find((e) => e.type.name === prismaEnum.name ||
|
|
82
|
+
e.type.name === prismaEnum.name + 'Type' ||
|
|
83
|
+
e.type.name === prismaEnum.name + 'Enum');
|
|
84
|
+
if (!tsMatch)
|
|
85
|
+
continue;
|
|
86
|
+
const prismaValues = new Set(prismaEnum.values);
|
|
87
|
+
const tsValues = new Set(tsMatch.type.properties.map((p) => p.name));
|
|
88
|
+
const missingInTs = [...prismaValues].filter((v) => !tsValues.has(v));
|
|
89
|
+
const extraInTs = [...tsValues].filter((v) => !prismaValues.has(v));
|
|
90
|
+
if (missingInTs.length > 0) {
|
|
91
|
+
issues.push({
|
|
92
|
+
severity: 'warning',
|
|
93
|
+
model: prismaEnum.name,
|
|
94
|
+
message: `Enum "${tsMatch.type.name}" manque ${missingInTs.length} valeur(s) Prisma : ${missingInTs.join(', ')}`,
|
|
95
|
+
matchFile: tsMatch.filePath,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (extraInTs.length > 0) {
|
|
99
|
+
issues.push({
|
|
100
|
+
severity: 'info',
|
|
101
|
+
model: prismaEnum.name,
|
|
102
|
+
message: `Enum "${tsMatch.type.name}" a ${extraInTs.length} valeur(s) supplementaire(s) : ${extraInTs.join(', ')}`,
|
|
103
|
+
matchFile: tsMatch.filePath,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
modelCount: prismaTypes.length,
|
|
109
|
+
enumCount,
|
|
110
|
+
matches,
|
|
111
|
+
issues,
|
|
112
|
+
issueCount: issues.filter((i) => i.severity === 'error' || i.severity === 'warning').length,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** Collecte tous les types/interfaces non-Prisma du projet */
|
|
116
|
+
function collectNonPrismaTypes(index) {
|
|
117
|
+
const result = [];
|
|
118
|
+
for (const [filePath, node] of Object.entries(index.files)) {
|
|
119
|
+
if (node.language === 'prisma')
|
|
120
|
+
continue;
|
|
121
|
+
for (const type of node.types) {
|
|
122
|
+
if (type.properties.length > 0) {
|
|
123
|
+
result.push({ type, filePath });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
/** Trouve les types qui correspondent a un modele Prisma (par nom) */
|
|
130
|
+
function findMatchingTypes(modelName, allTypes) {
|
|
131
|
+
const nameLower = modelName.toLowerCase();
|
|
132
|
+
return allTypes.filter(({ type }) => {
|
|
133
|
+
const typeLower = type.name.toLowerCase();
|
|
134
|
+
// Correspondances : User → UserDto, CreateUserDto, UserResponse, UserEntity, etc.
|
|
135
|
+
return typeLower === nameLower ||
|
|
136
|
+
typeLower === `${nameLower}dto` ||
|
|
137
|
+
typeLower === `create${nameLower}dto` ||
|
|
138
|
+
typeLower === `update${nameLower}dto` ||
|
|
139
|
+
typeLower === `${nameLower}response` ||
|
|
140
|
+
typeLower === `${nameLower}entity` ||
|
|
141
|
+
typeLower === `${nameLower}type` ||
|
|
142
|
+
typeLower === `${nameLower}props` ||
|
|
143
|
+
typeLower === `${nameLower}data`;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/** Collecte les enums du schema Prisma */
|
|
147
|
+
function collectPrismaEnums(index) {
|
|
148
|
+
const result = [];
|
|
149
|
+
for (const [, node] of Object.entries(index.files)) {
|
|
150
|
+
if (node.language !== 'prisma')
|
|
151
|
+
continue;
|
|
152
|
+
for (const type of node.types) {
|
|
153
|
+
if (type.kind === 'enum') {
|
|
154
|
+
result.push({ name: type.name, values: type.properties.map((p) => p.name) });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
/** Collecte les enums TypeScript */
|
|
161
|
+
function collectTsEnums(allTypes) {
|
|
162
|
+
return allTypes.filter(({ type }) => type.kind === 'enum');
|
|
163
|
+
}
|
|
164
|
+
/** Formate le resultat pour affichage MCP */
|
|
165
|
+
export function formatSchemaResult(result) {
|
|
166
|
+
const lines = [];
|
|
167
|
+
if (result.modelCount === 0) {
|
|
168
|
+
lines.push('## Schema Check : N/A');
|
|
169
|
+
lines.push('Aucun fichier Prisma trouve dans l\'index. Lancez "reindex" si le projet utilise Prisma.');
|
|
170
|
+
return lines.join('\n');
|
|
171
|
+
}
|
|
172
|
+
const icon = result.issueCount === 0 ? 'OK' : 'PROBLEMES';
|
|
173
|
+
lines.push(`## Schema Check : ${icon}`);
|
|
174
|
+
lines.push(`**Modeles Prisma** : ${result.modelCount} | **Enums** : ${result.enumCount}`);
|
|
175
|
+
lines.push(`**Correspondances trouvees** : ${result.matches.length}`);
|
|
176
|
+
if (result.matches.length > 0) {
|
|
177
|
+
lines.push('');
|
|
178
|
+
lines.push('### Correspondances Prisma ↔ TS');
|
|
179
|
+
for (const match of result.matches) {
|
|
180
|
+
const status = match.missingFields.length === 0 ? 'OK' : `${match.missingFields.length} champ(s) manquant(s)`;
|
|
181
|
+
lines.push(`- **${match.prismaModel}** ↔ ${match.matchedType} (${toShortPath(match.matchedFile)}) — ${status}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const errors = result.issues.filter((i) => i.severity === 'error');
|
|
185
|
+
const warnings = result.issues.filter((i) => i.severity === 'warning');
|
|
186
|
+
const infos = result.issues.filter((i) => i.severity === 'info');
|
|
187
|
+
if (errors.length > 0) {
|
|
188
|
+
lines.push('');
|
|
189
|
+
lines.push('### Erreurs');
|
|
190
|
+
for (const issue of errors) {
|
|
191
|
+
lines.push(`- [${issue.model}] ${issue.message}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (warnings.length > 0) {
|
|
195
|
+
lines.push('');
|
|
196
|
+
lines.push('### Avertissements');
|
|
197
|
+
for (const issue of warnings) {
|
|
198
|
+
lines.push(`- [${issue.model}] ${issue.message}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (infos.length > 0) {
|
|
202
|
+
lines.push('');
|
|
203
|
+
lines.push('### Info');
|
|
204
|
+
for (const issue of infos) {
|
|
205
|
+
lines.push(`- [${issue.model}] ${issue.message}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (result.issueCount === 0) {
|
|
209
|
+
lines.push('');
|
|
210
|
+
lines.push('> Schema coherent — les types correspondent aux modeles Prisma.');
|
|
211
|
+
}
|
|
212
|
+
return lines.join('\n');
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/tools/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA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1B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outil MCP : search
|
|
3
|
+
* "Qui utilise cette fonction / ce type / ce hook ?"
|
|
4
|
+
*/
|
|
5
|
+
import type { ProjectIndex } from '../storage/index-store.js';
|
|
6
|
+
export interface SearchResult {
|
|
7
|
+
query: string;
|
|
8
|
+
matches: SearchMatch[];
|
|
9
|
+
totalMatches: number;
|
|
10
|
+
}
|
|
11
|
+
export interface SearchMatch {
|
|
12
|
+
filePath: string;
|
|
13
|
+
context: string;
|
|
14
|
+
line: number | null;
|
|
15
|
+
}
|
|
16
|
+
export declare function searchIndex(index: ProjectIndex, query: string): SearchResult;
|
|
17
|
+
export declare function formatSearchResult(result: SearchResult): string;
|
|
18
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CA0F5E;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAc/D"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outil MCP : search
|
|
3
|
+
* "Qui utilise cette fonction / ce type / ce hook ?"
|
|
4
|
+
*/
|
|
5
|
+
export function searchIndex(index, query) {
|
|
6
|
+
const matches = [];
|
|
7
|
+
const queryLower = query.toLowerCase();
|
|
8
|
+
for (const [filePath, node] of Object.entries(index.files)) {
|
|
9
|
+
// Chercher dans les imports
|
|
10
|
+
for (const imp of node.imports) {
|
|
11
|
+
if (imp.name.toLowerCase().includes(queryLower)) {
|
|
12
|
+
matches.push({
|
|
13
|
+
filePath,
|
|
14
|
+
context: `imports "${imp.name}" from "${imp.source}"`,
|
|
15
|
+
line: null,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// Chercher dans les exports
|
|
20
|
+
for (const exp of node.exports) {
|
|
21
|
+
if (exp.name.toLowerCase().includes(queryLower)) {
|
|
22
|
+
matches.push({
|
|
23
|
+
filePath,
|
|
24
|
+
context: `exports ${exp.kind} "${exp.name}"`,
|
|
25
|
+
line: null,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Chercher dans les fonctions
|
|
30
|
+
for (const fn of node.functions) {
|
|
31
|
+
if (fn.name.toLowerCase().includes(queryLower)) {
|
|
32
|
+
matches.push({
|
|
33
|
+
filePath,
|
|
34
|
+
context: `function ${fn.name}(${fn.parameters.map((p) => p.name).join(', ')})`,
|
|
35
|
+
line: fn.line,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Chercher dans les classes
|
|
40
|
+
for (const cls of node.classes) {
|
|
41
|
+
if (cls.name.toLowerCase().includes(queryLower)) {
|
|
42
|
+
matches.push({
|
|
43
|
+
filePath,
|
|
44
|
+
context: `class ${cls.name}${cls.decorators.length ? ` @${cls.decorators.join(', @')}` : ''}`,
|
|
45
|
+
line: cls.line,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
// Aussi dans les methodes
|
|
49
|
+
for (const method of cls.methods) {
|
|
50
|
+
if (method.name.toLowerCase().includes(queryLower)) {
|
|
51
|
+
matches.push({
|
|
52
|
+
filePath,
|
|
53
|
+
context: `${cls.name}.${method.name}()`,
|
|
54
|
+
line: method.line,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Chercher dans les types/interfaces
|
|
60
|
+
for (const type of node.types) {
|
|
61
|
+
if (type.name.toLowerCase().includes(queryLower)) {
|
|
62
|
+
matches.push({
|
|
63
|
+
filePath,
|
|
64
|
+
context: `${type.kind} ${type.name}`,
|
|
65
|
+
line: type.line,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Chercher dans les routes
|
|
70
|
+
for (const route of node.routes) {
|
|
71
|
+
if (route.path.toLowerCase().includes(queryLower) ||
|
|
72
|
+
route.handler.toLowerCase().includes(queryLower)) {
|
|
73
|
+
matches.push({
|
|
74
|
+
filePath,
|
|
75
|
+
context: `${route.method} ${route.path} → ${route.handler}`,
|
|
76
|
+
line: route.line,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
query,
|
|
83
|
+
matches,
|
|
84
|
+
totalMatches: matches.length,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function formatSearchResult(result) {
|
|
88
|
+
if (result.totalMatches === 0) {
|
|
89
|
+
return `Aucun resultat pour "${result.query}"`;
|
|
90
|
+
}
|
|
91
|
+
const lines = [];
|
|
92
|
+
lines.push(`## Recherche : "${result.query}" — ${result.totalMatches} resultats`);
|
|
93
|
+
for (const match of result.matches) {
|
|
94
|
+
const lineRef = match.line ? `:${match.line}` : '';
|
|
95
|
+
lines.push(`- **${match.filePath}${lineRef}** — ${match.context}`);
|
|
96
|
+
}
|
|
97
|
+
return lines.join('\n');
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAg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AK,CAAC,QAAQ,GAAG,OAAO,QAAQ,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalogue des outils MCP exposes par CodeGuard.
|
|
3
|
+
* Separe de index.ts pour garder le serveur lisible.
|
|
4
|
+
*/
|
|
5
|
+
export interface ToolDefinition {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: 'object';
|
|
10
|
+
properties: Record<string, unknown>;
|
|
11
|
+
required?: string[];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare const TOOL_DEFINITIONS: ToolDefinition[];
|
|
15
|
+
//# sourceMappingURL=tool-definitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-definitions.d.ts","sourceRoot":"","sources":["../../src/tools/tool-definitions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH;AAED,eAAO,MAAM,gBAAgB,EAAE,cAAc,EAkK5C,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalogue des outils MCP exposes par CodeGuard.
|
|
3
|
+
* Separe de index.ts pour garder le serveur lisible.
|
|
4
|
+
*/
|
|
5
|
+
export const TOOL_DEFINITIONS = [
|
|
6
|
+
{
|
|
7
|
+
name: 'impact',
|
|
8
|
+
description: 'Analyse d\'impact — "je modifie ce fichier, qu\'est-ce qui casse ?" Retourne les fichiers impactes, les routes API affectees, et un score de risque.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
filePath: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'Chemin du fichier a analyser (absolu ou relatif au projet)',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
required: ['filePath'],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'search',
|
|
22
|
+
description: 'Recherche dans la carte — "qui utilise cette fonction/type/hook ?" Cherche dans les imports, exports, fonctions, classes, types et routes.',
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
query: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
description: 'Nom de la fonction, du type, du hook ou de la route a chercher',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: ['query'],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'reindex',
|
|
36
|
+
description: 'Re-indexe le projet. Par defaut complet, avec incremental=true ne re-parse que les fichiers modifies.',
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
incremental: {
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
description: 'Si true, ne re-parse que les fichiers modifies depuis le dernier indexage (plus rapide)',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'status',
|
|
49
|
+
description: 'Etat de l\'index : date, nombre de fichiers, fraicheur.',
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
properties: {},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'dependencies',
|
|
57
|
+
description: 'Graphe de dependances d\'un fichier — qui il importe et qui l\'importe.',
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: {
|
|
61
|
+
filePath: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: 'Chemin du fichier',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
required: ['filePath'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'guard',
|
|
71
|
+
description: 'Pre-change safety check — "est-ce safe de modifier ce fichier ?" Retourne les risques, les fichiers a verifier apres, et une recommandation go/no-go. A appeler AVANT toute modification.',
|
|
72
|
+
inputSchema: {
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: {
|
|
75
|
+
filePath: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
description: 'Chemin du fichier qui va etre modifie (absolu ou relatif)',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
required: ['filePath'],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'check',
|
|
85
|
+
description: 'Post-change coherence check — re-indexe le fichier modifie, compare avec l\'ancien etat, detecte les exports supprimes, imports casses et types incoherents. A appeler APRES chaque modification.',
|
|
86
|
+
inputSchema: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
filePath: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
description: 'Chemin du fichier qui vient d\'etre modifie (absolu ou relatif)',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
required: ['filePath'],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'health',
|
|
99
|
+
description: 'Score de sante global du projet — imports casses, fichiers orphelins, dependances circulaires, fichiers a haut risque. Note de A (excellent) a F (critique).',
|
|
100
|
+
inputSchema: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
properties: {},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'regression_map',
|
|
107
|
+
description: 'Regression map — "je modifie ce fichier, quelles pages/routes retester ?" Liste les pages, routes API et entry points impactes en cascade.',
|
|
108
|
+
inputSchema: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
properties: {
|
|
111
|
+
filePath: {
|
|
112
|
+
type: 'string',
|
|
113
|
+
description: 'Chemin du fichier modifie (absolu ou relatif)',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
required: ['filePath'],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'graph',
|
|
121
|
+
description: 'Genere un diagramme Mermaid du graphe de dependances. Sans filePath = graphe complet, avec filePath = graphe centre sur ce fichier (2 niveaux).',
|
|
122
|
+
inputSchema: {
|
|
123
|
+
type: 'object',
|
|
124
|
+
properties: {
|
|
125
|
+
filePath: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
description: 'Fichier sur lequel centrer le graphe (optionnel — sans = graphe complet)',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'schema_check',
|
|
134
|
+
description: 'Coherence Prisma ↔ DTOs backend ↔ types frontend. Detecte les champs manquants et les enums desynchronises. A lancer apres modification du schema Prisma ou des DTOs.',
|
|
135
|
+
inputSchema: {
|
|
136
|
+
type: 'object',
|
|
137
|
+
properties: {},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: 'route_guard',
|
|
142
|
+
description: 'Coherence routes frontend ↔ backend. Detecte les routes backend non appelees, les appels frontend vers des routes inexistantes, et les routes sensibles sans auth.',
|
|
143
|
+
inputSchema: {
|
|
144
|
+
type: 'object',
|
|
145
|
+
properties: {},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'changelog',
|
|
150
|
+
description: 'Diff lisible entre l\'ancien et le nouvel index. Montre les fichiers, exports, routes et types ajoutes/supprimes/modifies depuis le dernier reindex.',
|
|
151
|
+
inputSchema: {
|
|
152
|
+
type: 'object',
|
|
153
|
+
properties: {},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
];
|
|
157
|
+
//# sourceMappingURL=tool-definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-definitions.js","sourceRoot":"","sources":["../../src/tools/tool-definitions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,MAAM,CAAC,MAAM,gBAAgB,GAAqB;IAChD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,sJAAsJ;QACxJ,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,4DAA4D;iBAC1E;aACF;YACD,QAAQ,EAAE,CAAC,UAAU,CAAC;SACvB;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,4IAA4I;QAC9I,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,gEAAgE;iBAC9E;aACF;YACD,QAAQ,EAAE,CAAC,OAAO,CAAC;SACpB;KACF;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EACT,uGAAuG;QACzG,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,WAAW,EAAE;oBACX,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,yFAAyF;iBACvG;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,yDAAyD;QACtE,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;SACf;KACF;IACD;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,yEAAyE;QACtF,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gB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ACT,uKAAuK;QACzK,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;SACf;KACF;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EACT,oKAAoK;QACtK,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;SACf;KACF;IACD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EACT,sJAAsJ;QACxJ,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;SACf;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolution d'imports — source unique de verite.
|
|
3
|
+
* Utilise partout : dependency-graph, check, health.
|
|
4
|
+
* Gere :
|
|
5
|
+
* - Convention ESM (import from './foo.js' → fichier reel foo.ts)
|
|
6
|
+
* - Path aliases TypeScript (import from '@/lib/utils' → src/lib/utils.ts)
|
|
7
|
+
*/
|
|
8
|
+
/** Ensemble de chemins de fichiers connus (cles de l'index) */
|
|
9
|
+
export type FileSet = {
|
|
10
|
+
[filePath: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
/** Un alias : pattern → liste de remplacements */
|
|
13
|
+
export interface PathAlias {
|
|
14
|
+
prefix: string;
|
|
15
|
+
targets: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Charge les path aliases depuis les tsconfig.json du projet.
|
|
19
|
+
* Cherche dans la racine, dans backend/ et frontend/ (monorepo).
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadPathAliases(projectRoot: string): PathAlias[];
|
|
22
|
+
/** Vide le cache des aliases (pour les tests ou apres reindex) */
|
|
23
|
+
export declare function clearAliasCache(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Resout un chemin d'import vers un chemin absolu dans l'index.
|
|
26
|
+
* Supporte : chemins relatifs, convention ESM, path aliases TypeScript.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveImportPath(fromFile: string, importSource: string, fileSet: FileSet, projectRoot?: string): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Verifie si un import depuis fromFile pointe vers targetFile.
|
|
31
|
+
*/
|
|
32
|
+
export declare function importPointsTo(importSource: string, targetFile: string, fromFile: string, fileSet: FileSet, projectRoot?: string): boolean;
|
|
33
|
+
//# sourceMappingURL=import-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-resolver.d.ts","sourceRoot":"","sources":["../../src/utils/import-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,+DAA+D;AAC/D,MAAM,MAAM,OAAO,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAEtD,kDAAkD;AAClD,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAQD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,CAuDhE;AAED,kEAAkE;AAClE,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,OAAO,EAChB,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,GAAG,IAAI,CAuBf;AA6CD;;GAEG;AACH,wBAAgB,cAAc,CAC5B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAChB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAGT"}
|