@justmpm/ai-tool 0.3.2 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -1
- package/dist/{chunk-EONUMGCN.js → chunk-WN7FTU6M.js} +1281 -10
- package/dist/cli.js +42 -8
- package/dist/index.d.ts +203 -2
- package/dist/index.js +39 -3
- package/dist/{server-K55EXKYX.js → server-SPVMWDEO.js} +246 -1
- package/package.json +2 -1
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
VERSION,
|
|
4
|
+
area,
|
|
5
|
+
areas,
|
|
6
|
+
areasInit,
|
|
4
7
|
context,
|
|
5
8
|
dead,
|
|
6
9
|
deadFix,
|
|
7
10
|
impact,
|
|
8
11
|
map,
|
|
9
12
|
suggest
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-WN7FTU6M.js";
|
|
11
14
|
|
|
12
15
|
// src/cli.ts
|
|
13
16
|
var HELP = `
|
|
@@ -21,6 +24,14 @@ COMANDOS:
|
|
|
21
24
|
suggest <arquivo> Sugere arquivos para ler antes de modificar
|
|
22
25
|
context <arquivo> Extrai assinaturas de um arquivo (funcoes, tipos)
|
|
23
26
|
|
|
27
|
+
AREAS (NOVO):
|
|
28
|
+
areas Lista todas as areas/dominios do projeto
|
|
29
|
+
areas init Gera arquivo de configuracao .analyze/areas.config.json
|
|
30
|
+
areas init --force Sobrescreve configuracao existente
|
|
31
|
+
area <nome> Mostra arquivos de uma area especifica
|
|
32
|
+
area <nome> --type=hook Filtra por categoria
|
|
33
|
+
area <nome> --full Mostra todos os arquivos
|
|
34
|
+
|
|
24
35
|
MODOS:
|
|
25
36
|
--mcp Inicia servidor MCP para integracao com Claude Desktop
|
|
26
37
|
|
|
@@ -29,6 +40,8 @@ OPCOES:
|
|
|
29
40
|
--cwd=<path> Diretorio do projeto (default: cwd)
|
|
30
41
|
--no-cache Ignora cache e forca regeneracao
|
|
31
42
|
--limit=<n> Limite de sugestoes (default: 10, apenas suggest)
|
|
43
|
+
--type=<categoria> Filtra por categoria (apenas area)
|
|
44
|
+
--full Mostra todos os arquivos (apenas area)
|
|
32
45
|
--help, -h Mostra esta ajuda
|
|
33
46
|
--version, -v Mostra versao
|
|
34
47
|
|
|
@@ -40,16 +53,16 @@ CACHE:
|
|
|
40
53
|
EXEMPLOS:
|
|
41
54
|
ai-tool map
|
|
42
55
|
ai-tool map --format=json
|
|
43
|
-
ai-tool map --no-cache
|
|
44
56
|
ai-tool dead
|
|
45
57
|
ai-tool dead --fix
|
|
46
58
|
ai-tool impact Button
|
|
47
|
-
ai-tool
|
|
48
|
-
ai-tool impact src/components/Header.tsx --format=json
|
|
49
|
-
ai-tool suggest Button
|
|
50
|
-
ai-tool suggest src/hooks/useAuth.ts --limit=5
|
|
59
|
+
ai-tool suggest Button --limit=5
|
|
51
60
|
ai-tool context Button
|
|
52
|
-
ai-tool
|
|
61
|
+
ai-tool areas
|
|
62
|
+
ai-tool areas init
|
|
63
|
+
ai-tool area meus-pets
|
|
64
|
+
ai-tool area meus-pets --type=hook
|
|
65
|
+
ai-tool area firebase --full
|
|
53
66
|
ai-tool --mcp
|
|
54
67
|
|
|
55
68
|
SOBRE:
|
|
@@ -72,7 +85,7 @@ async function main() {
|
|
|
72
85
|
}
|
|
73
86
|
}
|
|
74
87
|
if (flags.mcp) {
|
|
75
|
-
const { startMcpServer } = await import("./server-
|
|
88
|
+
const { startMcpServer } = await import("./server-SPVMWDEO.js");
|
|
76
89
|
await startMcpServer();
|
|
77
90
|
return;
|
|
78
91
|
}
|
|
@@ -134,6 +147,27 @@ async function main() {
|
|
|
134
147
|
}
|
|
135
148
|
result = await context(target, { format, cwd });
|
|
136
149
|
break;
|
|
150
|
+
case "areas":
|
|
151
|
+
if (target === "init") {
|
|
152
|
+
result = await areasInit({ cwd, force: !!flags.force });
|
|
153
|
+
} else {
|
|
154
|
+
result = await areas({ format, cwd });
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
case "area":
|
|
158
|
+
if (!target) {
|
|
159
|
+
console.error("\u274C Erro: nome da \xE1rea \xE9 obrigat\xF3rio para o comando area");
|
|
160
|
+
console.error(" Exemplo: ai-tool area meus-pets");
|
|
161
|
+
console.error(" Use 'ai-tool areas' para listar \xE1reas dispon\xEDveis");
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
164
|
+
result = await area(target, {
|
|
165
|
+
format,
|
|
166
|
+
cwd,
|
|
167
|
+
type: flags.type,
|
|
168
|
+
full: !!flags.full
|
|
169
|
+
});
|
|
170
|
+
break;
|
|
137
171
|
default:
|
|
138
172
|
console.error(`\u274C Comando desconhecido: ${command}`);
|
|
139
173
|
console.error(" Use 'ai-tool --help' para ver comandos dispon\xEDveis.");
|
package/dist/index.d.ts
CHANGED
|
@@ -158,6 +158,64 @@ interface ContextResult {
|
|
|
158
158
|
functions: FunctionInfo[];
|
|
159
159
|
types: TypeInfo[];
|
|
160
160
|
}
|
|
161
|
+
interface AreaConfig {
|
|
162
|
+
name: string;
|
|
163
|
+
description?: string;
|
|
164
|
+
patterns: string[];
|
|
165
|
+
keywords?: string[];
|
|
166
|
+
exclude?: string[];
|
|
167
|
+
}
|
|
168
|
+
interface AreasConfigFile {
|
|
169
|
+
$schema?: string;
|
|
170
|
+
version: string;
|
|
171
|
+
areas: Record<string, AreaConfig>;
|
|
172
|
+
descriptions?: Record<string, string>;
|
|
173
|
+
settings?: {
|
|
174
|
+
autoDetect?: boolean;
|
|
175
|
+
inferDescriptions?: boolean;
|
|
176
|
+
groupByCategory?: boolean;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
interface AreaFile {
|
|
180
|
+
path: string;
|
|
181
|
+
category: FileCategory;
|
|
182
|
+
description?: string;
|
|
183
|
+
}
|
|
184
|
+
interface DetectedArea {
|
|
185
|
+
id: string;
|
|
186
|
+
name: string;
|
|
187
|
+
description?: string;
|
|
188
|
+
files: AreaFile[];
|
|
189
|
+
fileCount: number;
|
|
190
|
+
categories: Partial<Record<FileCategory, number>>;
|
|
191
|
+
isAutoDetected: boolean;
|
|
192
|
+
}
|
|
193
|
+
interface AreasResult {
|
|
194
|
+
version: string;
|
|
195
|
+
timestamp: string;
|
|
196
|
+
cwd: string;
|
|
197
|
+
areas: DetectedArea[];
|
|
198
|
+
unmapped: AreaFile[];
|
|
199
|
+
summary: {
|
|
200
|
+
totalAreas: number;
|
|
201
|
+
totalFiles: number;
|
|
202
|
+
unmappedCount: number;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
interface AreaDetailResult {
|
|
206
|
+
version: string;
|
|
207
|
+
timestamp: string;
|
|
208
|
+
area: DetectedArea;
|
|
209
|
+
byCategory: Partial<Record<FileCategory, AreaFile[]>>;
|
|
210
|
+
}
|
|
211
|
+
interface AreasOptions extends CommandOptions {
|
|
212
|
+
full?: boolean;
|
|
213
|
+
type?: FileCategory;
|
|
214
|
+
}
|
|
215
|
+
interface AreaOptions extends CommandOptions {
|
|
216
|
+
full?: boolean;
|
|
217
|
+
type?: FileCategory;
|
|
218
|
+
}
|
|
161
219
|
|
|
162
220
|
/**
|
|
163
221
|
* Comando MAP - Mapa do projeto usando Skott
|
|
@@ -211,12 +269,51 @@ declare function suggest(target: string, options?: SuggestOptions): Promise<stri
|
|
|
211
269
|
*/
|
|
212
270
|
declare function context(target: string, options?: ContextOptions): Promise<string>;
|
|
213
271
|
|
|
272
|
+
/**
|
|
273
|
+
* Comando AREAS - Lista todas as áreas do projeto
|
|
274
|
+
*/
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Executa o comando AREAS
|
|
278
|
+
*/
|
|
279
|
+
declare function areas(options?: AreasOptions): Promise<string>;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Comando AREA - Mostra detalhes de uma área específica
|
|
283
|
+
*/
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Executa o comando AREA
|
|
287
|
+
*/
|
|
288
|
+
declare function area(target: string, options?: AreaOptions): Promise<string>;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Comando AREAS INIT - Gera configuração inicial de áreas
|
|
292
|
+
*/
|
|
293
|
+
interface InitOptions {
|
|
294
|
+
cwd?: string;
|
|
295
|
+
force?: boolean;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Executa o comando AREAS INIT
|
|
299
|
+
*/
|
|
300
|
+
declare function areasInit(options?: InitOptions): Promise<string>;
|
|
301
|
+
|
|
214
302
|
/**
|
|
215
303
|
* Utilitários para detecção e classificação de arquivos
|
|
216
304
|
*/
|
|
217
305
|
|
|
218
306
|
/**
|
|
219
307
|
* Detecta a categoria de um arquivo baseado no path
|
|
308
|
+
*
|
|
309
|
+
* Suporta múltiplos frameworks:
|
|
310
|
+
* - Next.js (App Router e Pages Router)
|
|
311
|
+
* - Vite (React, Vue, Svelte)
|
|
312
|
+
* - Create React App
|
|
313
|
+
* - Remix
|
|
314
|
+
* - Nuxt
|
|
315
|
+
* - SvelteKit
|
|
316
|
+
* - Astro
|
|
220
317
|
*/
|
|
221
318
|
declare function detectCategory(filePath: string): FileCategory;
|
|
222
319
|
/**
|
|
@@ -280,6 +377,110 @@ declare function isCacheValid(cwd: string): boolean;
|
|
|
280
377
|
*/
|
|
281
378
|
declare function invalidateCache(cwd: string): void;
|
|
282
379
|
|
|
380
|
+
/**
|
|
381
|
+
* Gerenciamento de configuração de áreas
|
|
382
|
+
*
|
|
383
|
+
* Lê e escreve o arquivo areas.config.json
|
|
384
|
+
*/
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Verifica se o arquivo de configuração existe
|
|
388
|
+
*/
|
|
389
|
+
declare function configExists(cwd: string): boolean;
|
|
390
|
+
/**
|
|
391
|
+
* Lê o arquivo de configuração
|
|
392
|
+
*/
|
|
393
|
+
declare function readConfig(cwd: string): AreasConfigFile;
|
|
394
|
+
/**
|
|
395
|
+
* Escreve o arquivo de configuração
|
|
396
|
+
*/
|
|
397
|
+
declare function writeConfig(cwd: string, config: AreasConfigFile): void;
|
|
398
|
+
/**
|
|
399
|
+
* Adiciona ou atualiza uma área na configuração
|
|
400
|
+
*/
|
|
401
|
+
declare function setArea(cwd: string, id: string, area: AreaConfig): void;
|
|
402
|
+
/**
|
|
403
|
+
* Remove uma área da configuração
|
|
404
|
+
*/
|
|
405
|
+
declare function removeArea(cwd: string, id: string): void;
|
|
406
|
+
/**
|
|
407
|
+
* Define descrição manual para um arquivo
|
|
408
|
+
*/
|
|
409
|
+
declare function setFileDescription(cwd: string, filePath: string, description: string): void;
|
|
410
|
+
/**
|
|
411
|
+
* Obtém descrição manual de um arquivo (se existir)
|
|
412
|
+
*/
|
|
413
|
+
declare function getFileDescription(cwd: string, filePath: string): string | undefined;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Detector de áreas
|
|
417
|
+
*
|
|
418
|
+
* Detecta automaticamente a área de cada arquivo baseado em:
|
|
419
|
+
* 1. Configuração manual (areas.config.json)
|
|
420
|
+
* 2. Padrões de pasta
|
|
421
|
+
* 3. Keywords no nome
|
|
422
|
+
*/
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Detecta a(s) área(s) de um arquivo
|
|
426
|
+
* Retorna array porque um arquivo pode pertencer a múltiplas áreas
|
|
427
|
+
*/
|
|
428
|
+
declare function detectFileAreas(filePath: string, config: AreasConfigFile): string[];
|
|
429
|
+
/**
|
|
430
|
+
* Obtém o nome amigável de uma área
|
|
431
|
+
*/
|
|
432
|
+
declare function getAreaName(areaId: string, config: AreasConfigFile): string;
|
|
433
|
+
/**
|
|
434
|
+
* Obtém a descrição de uma área
|
|
435
|
+
*/
|
|
436
|
+
declare function getAreaDescription(areaId: string, config: AreasConfigFile): string | undefined;
|
|
437
|
+
/**
|
|
438
|
+
* Infere descrição de um arquivo baseado em seu nome e categoria
|
|
439
|
+
*/
|
|
440
|
+
declare function inferFileDescription(filePath: string, category: FileCategory): string | undefined;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Padrões de detecção automática de áreas
|
|
444
|
+
*
|
|
445
|
+
* Define regras para detectar áreas baseado em:
|
|
446
|
+
* - Padrões de pasta (glob)
|
|
447
|
+
* - Keywords no nome do arquivo
|
|
448
|
+
*
|
|
449
|
+
* Suporta múltiplos frameworks:
|
|
450
|
+
* - Next.js (App Router e Pages Router)
|
|
451
|
+
* - Vite (React, Vue)
|
|
452
|
+
* - Create React App
|
|
453
|
+
* - Remix
|
|
454
|
+
* - Nuxt
|
|
455
|
+
* - SvelteKit
|
|
456
|
+
* - Astro
|
|
457
|
+
*/
|
|
458
|
+
/**
|
|
459
|
+
* Padrões de pasta → área
|
|
460
|
+
* Ordem importa: mais específico primeiro
|
|
461
|
+
*/
|
|
462
|
+
declare const FOLDER_PATTERNS: Array<{
|
|
463
|
+
pattern: RegExp;
|
|
464
|
+
area: string;
|
|
465
|
+
priority: number;
|
|
466
|
+
}>;
|
|
467
|
+
/**
|
|
468
|
+
* Keywords no nome do arquivo → área
|
|
469
|
+
*/
|
|
470
|
+
declare const KEYWORD_PATTERNS: Array<{
|
|
471
|
+
keyword: RegExp;
|
|
472
|
+
area: string;
|
|
473
|
+
priority: number;
|
|
474
|
+
}>;
|
|
475
|
+
/**
|
|
476
|
+
* Nomes amigáveis das áreas
|
|
477
|
+
*/
|
|
478
|
+
declare const AREA_NAMES: Record<string, string>;
|
|
479
|
+
/**
|
|
480
|
+
* Descrições padrão das áreas
|
|
481
|
+
*/
|
|
482
|
+
declare const AREA_DESCRIPTIONS: Record<string, string>;
|
|
483
|
+
|
|
283
484
|
/**
|
|
284
485
|
* ai-tool - Ferramenta de análise de dependências e impacto
|
|
285
486
|
*
|
|
@@ -300,6 +501,6 @@ declare function invalidateCache(cwd: string): void;
|
|
|
300
501
|
* ```
|
|
301
502
|
*/
|
|
302
503
|
|
|
303
|
-
declare const VERSION
|
|
504
|
+
declare const VERSION: string;
|
|
304
505
|
|
|
305
|
-
export { type CommandOptions, type ContextOptions, type ContextResult, type DeadFile, type DeadOptions, type DeadResult, type FileCategory, type FileInfo, type FolderStats, type FunctionInfo, type ImpactFile, type ImpactOptions, type ImpactResult, type ImportInfo, type MapOptions, type MapResult, type OutputFormat, type ParamInfo, type RiskInfo, type SuggestOptions, type SuggestResult, type Suggestion, type SuggestionPriority, type TypeInfo, type TypeKind, VERSION, categoryIcons, clearFirebaseCache, context, dead, deadFix, detectCategory, filterCloudFunctionsFalsePositives, getCacheDir, hasFirebaseFunctions, impact, invalidateCache, isCacheValid, isCodeFile, isEntryPoint, isExportedCloudFunction, isFirebaseProject, map, suggest };
|
|
506
|
+
export { AREA_DESCRIPTIONS, AREA_NAMES, type AreaConfig, type AreaDetailResult, type AreaFile, type AreaOptions, type AreasConfigFile, type AreasOptions, type AreasResult, type CommandOptions, type ContextOptions, type ContextResult, type DeadFile, type DeadOptions, type DeadResult, type DetectedArea, FOLDER_PATTERNS, type FileCategory, type FileInfo, type FolderStats, type FunctionInfo, type ImpactFile, type ImpactOptions, type ImpactResult, type ImportInfo, KEYWORD_PATTERNS, type MapOptions, type MapResult, type OutputFormat, type ParamInfo, type RiskInfo, type SuggestOptions, type SuggestResult, type Suggestion, type SuggestionPriority, type TypeInfo, type TypeKind, VERSION, area, areas, areasInit, categoryIcons, clearFirebaseCache, configExists, context, dead, deadFix, detectCategory, detectFileAreas, filterCloudFunctionsFalsePositives, getAreaDescription, getAreaName, getCacheDir, getFileDescription, hasFirebaseFunctions, impact, inferFileDescription, invalidateCache, isCacheValid, isCodeFile, isEntryPoint, isExportedCloudFunction, isFirebaseProject, map, readConfig, removeArea, setArea, setFileDescription, suggest, writeConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AREA_DESCRIPTIONS,
|
|
3
|
+
AREA_NAMES,
|
|
4
|
+
FOLDER_PATTERNS,
|
|
5
|
+
KEYWORD_PATTERNS,
|
|
2
6
|
VERSION,
|
|
7
|
+
area,
|
|
8
|
+
areas,
|
|
9
|
+
areasInit,
|
|
3
10
|
categoryIcons,
|
|
4
11
|
clearFirebaseCache,
|
|
12
|
+
configExists,
|
|
5
13
|
context,
|
|
6
14
|
dead,
|
|
7
15
|
deadFix,
|
|
8
16
|
detectCategory,
|
|
17
|
+
detectFileAreas,
|
|
9
18
|
filterCloudFunctionsFalsePositives,
|
|
19
|
+
getAreaDescription,
|
|
20
|
+
getAreaName,
|
|
10
21
|
getCacheDir,
|
|
22
|
+
getFileDescription,
|
|
11
23
|
hasFirebaseFunctions,
|
|
12
24
|
impact,
|
|
25
|
+
inferFileDescription,
|
|
13
26
|
invalidateCache,
|
|
14
27
|
isCacheValid,
|
|
15
28
|
isCodeFile,
|
|
@@ -17,20 +30,38 @@ import {
|
|
|
17
30
|
isExportedCloudFunction,
|
|
18
31
|
isFirebaseProject,
|
|
19
32
|
map,
|
|
20
|
-
|
|
21
|
-
|
|
33
|
+
readConfig,
|
|
34
|
+
removeArea,
|
|
35
|
+
setArea,
|
|
36
|
+
setFileDescription,
|
|
37
|
+
suggest,
|
|
38
|
+
writeConfig
|
|
39
|
+
} from "./chunk-WN7FTU6M.js";
|
|
22
40
|
export {
|
|
41
|
+
AREA_DESCRIPTIONS,
|
|
42
|
+
AREA_NAMES,
|
|
43
|
+
FOLDER_PATTERNS,
|
|
44
|
+
KEYWORD_PATTERNS,
|
|
23
45
|
VERSION,
|
|
46
|
+
area,
|
|
47
|
+
areas,
|
|
48
|
+
areasInit,
|
|
24
49
|
categoryIcons,
|
|
25
50
|
clearFirebaseCache,
|
|
51
|
+
configExists,
|
|
26
52
|
context,
|
|
27
53
|
dead,
|
|
28
54
|
deadFix,
|
|
29
55
|
detectCategory,
|
|
56
|
+
detectFileAreas,
|
|
30
57
|
filterCloudFunctionsFalsePositives,
|
|
58
|
+
getAreaDescription,
|
|
59
|
+
getAreaName,
|
|
31
60
|
getCacheDir,
|
|
61
|
+
getFileDescription,
|
|
32
62
|
hasFirebaseFunctions,
|
|
33
63
|
impact,
|
|
64
|
+
inferFileDescription,
|
|
34
65
|
invalidateCache,
|
|
35
66
|
isCacheValid,
|
|
36
67
|
isCodeFile,
|
|
@@ -38,5 +69,10 @@ export {
|
|
|
38
69
|
isExportedCloudFunction,
|
|
39
70
|
isFirebaseProject,
|
|
40
71
|
map,
|
|
41
|
-
|
|
72
|
+
readConfig,
|
|
73
|
+
removeArea,
|
|
74
|
+
setArea,
|
|
75
|
+
setFileDescription,
|
|
76
|
+
suggest,
|
|
77
|
+
writeConfig
|
|
42
78
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
VERSION,
|
|
3
|
+
area,
|
|
4
|
+
areas,
|
|
5
|
+
areasInit,
|
|
3
6
|
context,
|
|
4
7
|
dead,
|
|
5
8
|
impact,
|
|
6
9
|
map,
|
|
7
10
|
suggest
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-WN7FTU6M.js";
|
|
9
12
|
|
|
10
13
|
// src/mcp/server.ts
|
|
11
14
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -333,6 +336,248 @@ Eficiente: retorna apenas assinaturas, nao o codigo completo.`,
|
|
|
333
336
|
}
|
|
334
337
|
}
|
|
335
338
|
);
|
|
339
|
+
server.registerTool(
|
|
340
|
+
"aitool_list_areas",
|
|
341
|
+
{
|
|
342
|
+
title: "List Project Areas",
|
|
343
|
+
description: `Lista todas as areas/dominios funcionais do projeto.
|
|
344
|
+
|
|
345
|
+
IMPORTANTE - AREAS vs CATEGORIAS:
|
|
346
|
+
- CATEGORIA = tipo tecnico (hook, component, page, service...)
|
|
347
|
+
\u2192 Use aitool_project_map para ver categorias
|
|
348
|
+
- AREA = dominio funcional (auth, meus-pets, stripe, dashboard...)
|
|
349
|
+
\u2192 Use ESTA tool para ver areas
|
|
350
|
+
\u2192 Use aitool_area_detail para ver arquivos de uma area especifica
|
|
351
|
+
|
|
352
|
+
Um arquivo pode pertencer a MULTIPLAS areas!
|
|
353
|
+
|
|
354
|
+
FUNCIONALIDADES:
|
|
355
|
+
- Detecta areas automaticamente baseado em padroes de pasta e keywords
|
|
356
|
+
- Agrupa arquivos por dominio funcional
|
|
357
|
+
- Mostra distribuicao de categorias por area
|
|
358
|
+
- Identifica arquivos sem area definida
|
|
359
|
+
|
|
360
|
+
PARAMETROS:
|
|
361
|
+
- format: "text" (legivel) ou "json" (estruturado)
|
|
362
|
+
- cwd: Diretorio do projeto (default: diretorio atual)
|
|
363
|
+
|
|
364
|
+
RETORNA:
|
|
365
|
+
- Lista de areas com nome, descricao e contagem
|
|
366
|
+
- Distribuicao de categorias por area
|
|
367
|
+
- Lista de arquivos sem area (para configurar manualmente)
|
|
368
|
+
|
|
369
|
+
EXEMPLO DE USO:
|
|
370
|
+
Chamar no inicio da sessao para entender os dominios do projeto.
|
|
371
|
+
Usar antes de trabalhar em uma feature especifica.
|
|
372
|
+
|
|
373
|
+
CONFIGURACAO MANUAL:
|
|
374
|
+
Se houver arquivos sem area ou areas incorretas, use aitool_areas_init
|
|
375
|
+
para gerar .analyze/areas.config.json e edite manualmente.`,
|
|
376
|
+
inputSchema: {
|
|
377
|
+
format: z.enum(["text", "json"]).default("text").describe("Formato de saida: text (legivel) ou json (estruturado)"),
|
|
378
|
+
cwd: z.string().optional().describe("Diretorio do projeto a analisar")
|
|
379
|
+
},
|
|
380
|
+
annotations: {
|
|
381
|
+
title: "List Project Areas",
|
|
382
|
+
readOnlyHint: true,
|
|
383
|
+
destructiveHint: false,
|
|
384
|
+
idempotentHint: true,
|
|
385
|
+
openWorldHint: false
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
async (params) => {
|
|
389
|
+
try {
|
|
390
|
+
const result = await areas({
|
|
391
|
+
format: params.format,
|
|
392
|
+
cwd: params.cwd
|
|
393
|
+
});
|
|
394
|
+
return { content: [{ type: "text", text: result }] };
|
|
395
|
+
} catch (error) {
|
|
396
|
+
return {
|
|
397
|
+
content: [
|
|
398
|
+
{
|
|
399
|
+
type: "text",
|
|
400
|
+
text: `Erro ao executar areas: ${error instanceof Error ? error.message : String(error)}`
|
|
401
|
+
}
|
|
402
|
+
],
|
|
403
|
+
isError: true
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
server.registerTool(
|
|
409
|
+
"aitool_area_detail",
|
|
410
|
+
{
|
|
411
|
+
title: "Area Detail",
|
|
412
|
+
description: `Mostra todos os arquivos de uma area/dominio especifica.
|
|
413
|
+
|
|
414
|
+
USE ESTA TOOL QUANDO:
|
|
415
|
+
- Usuario pedir para trabalhar em uma feature (ex: "vou mexer em auth")
|
|
416
|
+
- Precisar listar todos os arquivos de um dominio
|
|
417
|
+
- Quiser ver apenas hooks, components, etc de uma area especifica
|
|
418
|
+
|
|
419
|
+
FUNCIONALIDADES:
|
|
420
|
+
- Lista arquivos agrupados por categoria (page, component, hook...)
|
|
421
|
+
- Mostra descricao de cada arquivo (inferida ou manual)
|
|
422
|
+
- Permite filtrar por categoria especifica (type="hook")
|
|
423
|
+
- Mostra resumo de distribuicao
|
|
424
|
+
|
|
425
|
+
PARAMETROS:
|
|
426
|
+
- target: Nome da area (OBRIGATORIO - ex: "meus-pets", "auth", "stripe")
|
|
427
|
+
- type: Filtrar por categoria (opcional - ex: "hook", "component")
|
|
428
|
+
- full: Mostrar todos os arquivos (default: false = resumido)
|
|
429
|
+
- cwd: Diretorio do projeto
|
|
430
|
+
|
|
431
|
+
RETORNA:
|
|
432
|
+
- Nome e descricao da area
|
|
433
|
+
- Lista de arquivos por categoria
|
|
434
|
+
- Descricao de cada arquivo
|
|
435
|
+
|
|
436
|
+
EXEMPLOS DE USO:
|
|
437
|
+
- Ver tudo de auth: target="auth"
|
|
438
|
+
- Ver apenas hooks de auth: target="auth", type="hook"
|
|
439
|
+
- Ver todos os arquivos de stripe: target="stripe", full=true
|
|
440
|
+
|
|
441
|
+
DICA: Use aitool_list_areas primeiro para ver quais areas existem.`,
|
|
442
|
+
inputSchema: {
|
|
443
|
+
target: z.string().min(1).describe("Nome da area: meus-pets, auth, stripe, etc"),
|
|
444
|
+
type: z.enum([
|
|
445
|
+
"page",
|
|
446
|
+
"layout",
|
|
447
|
+
"route",
|
|
448
|
+
"component",
|
|
449
|
+
"hook",
|
|
450
|
+
"service",
|
|
451
|
+
"store",
|
|
452
|
+
"util",
|
|
453
|
+
"type",
|
|
454
|
+
"config",
|
|
455
|
+
"test",
|
|
456
|
+
"other"
|
|
457
|
+
]).optional().describe("Filtrar por categoria especifica"),
|
|
458
|
+
full: z.boolean().default(false).describe("Mostrar todos os arquivos (default: resumido)"),
|
|
459
|
+
cwd: z.string().optional().describe("Diretorio do projeto a analisar")
|
|
460
|
+
},
|
|
461
|
+
annotations: {
|
|
462
|
+
title: "Area Detail",
|
|
463
|
+
readOnlyHint: true,
|
|
464
|
+
destructiveHint: false,
|
|
465
|
+
idempotentHint: true,
|
|
466
|
+
openWorldHint: false
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
async (params) => {
|
|
470
|
+
try {
|
|
471
|
+
const result = await area(params.target, {
|
|
472
|
+
type: params.type,
|
|
473
|
+
full: params.full,
|
|
474
|
+
cwd: params.cwd,
|
|
475
|
+
format: "text"
|
|
476
|
+
});
|
|
477
|
+
return { content: [{ type: "text", text: result }] };
|
|
478
|
+
} catch (error) {
|
|
479
|
+
return {
|
|
480
|
+
content: [
|
|
481
|
+
{
|
|
482
|
+
type: "text",
|
|
483
|
+
text: `Erro ao executar area: ${error instanceof Error ? error.message : String(error)}`
|
|
484
|
+
}
|
|
485
|
+
],
|
|
486
|
+
isError: true
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
);
|
|
491
|
+
server.registerTool(
|
|
492
|
+
"aitool_areas_init",
|
|
493
|
+
{
|
|
494
|
+
title: "Initialize Areas Config",
|
|
495
|
+
description: `Gera arquivo de configuracao de areas (.analyze/areas.config.json).
|
|
496
|
+
|
|
497
|
+
QUANDO USAR:
|
|
498
|
+
- Quando aitool_list_areas mostrar arquivos sem area definida
|
|
499
|
+
- Quando precisar personalizar deteccao de areas
|
|
500
|
+
- Quando quiser adicionar areas que nao sao detectadas automaticamente
|
|
501
|
+
|
|
502
|
+
O QUE FAZ:
|
|
503
|
+
- Escaneia o projeto e detecta areas automaticamente
|
|
504
|
+
- Infere patterns glob para cada area detectada
|
|
505
|
+
- Gera arquivo editavel em .analyze/areas.config.json
|
|
506
|
+
- NAO sobrescreve config existente (use force=true para sobrescrever)
|
|
507
|
+
|
|
508
|
+
PARAMETROS:
|
|
509
|
+
- force: Sobrescrever config existente (default: false)
|
|
510
|
+
- cwd: Diretorio do projeto (default: diretorio atual)
|
|
511
|
+
|
|
512
|
+
RETORNA:
|
|
513
|
+
- Confirmacao do arquivo criado
|
|
514
|
+
- Lista de areas detectadas com contagem
|
|
515
|
+
- Arquivos sem area (para configurar manualmente)
|
|
516
|
+
- Instrucoes de como editar o arquivo
|
|
517
|
+
|
|
518
|
+
ESTRUTURA DO ARQUIVO GERADO:
|
|
519
|
+
{
|
|
520
|
+
"areas": {
|
|
521
|
+
"auth": {
|
|
522
|
+
"name": "Autenticacao",
|
|
523
|
+
"description": "Sistema de login e sessao",
|
|
524
|
+
"patterns": ["components/auth/**", "hooks/useAuth.ts"],
|
|
525
|
+
"keywords": ["auth", "login", "session"]
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
"descriptions": {
|
|
529
|
+
"components/pets/PetForm.tsx": "Formulario multi-step de pets"
|
|
530
|
+
},
|
|
531
|
+
"settings": {
|
|
532
|
+
"autoDetect": true,
|
|
533
|
+
"inferDescriptions": true
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
COMO EDITAR MANUALMENTE:
|
|
538
|
+
1. Adicionar areas nao detectadas: adicione entrada em "areas"
|
|
539
|
+
2. Renomear areas: altere "name" da area
|
|
540
|
+
3. Ajustar deteccao: modifique "patterns" e "keywords"
|
|
541
|
+
4. Excluir arquivos: adicione "exclude" com patterns
|
|
542
|
+
5. Descrever arquivos: adicione entrada em "descriptions"
|
|
543
|
+
|
|
544
|
+
EXEMPLO DE USO:
|
|
545
|
+
1. Rode aitool_list_areas para ver areas atuais
|
|
546
|
+
2. Se houver arquivos sem area, rode aitool_areas_init
|
|
547
|
+
3. Edite .analyze/areas.config.json conforme necessario
|
|
548
|
+
4. Rode aitool_list_areas novamente para ver mudancas`,
|
|
549
|
+
inputSchema: {
|
|
550
|
+
force: z.boolean().default(false).describe("Sobrescrever config existente"),
|
|
551
|
+
cwd: z.string().optional().describe("Diretorio do projeto")
|
|
552
|
+
},
|
|
553
|
+
annotations: {
|
|
554
|
+
title: "Initialize Areas Config",
|
|
555
|
+
readOnlyHint: false,
|
|
556
|
+
destructiveHint: false,
|
|
557
|
+
idempotentHint: false,
|
|
558
|
+
openWorldHint: false
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
async (params) => {
|
|
562
|
+
try {
|
|
563
|
+
const result = await areasInit({
|
|
564
|
+
force: params.force,
|
|
565
|
+
cwd: params.cwd
|
|
566
|
+
});
|
|
567
|
+
return { content: [{ type: "text", text: result }] };
|
|
568
|
+
} catch (error) {
|
|
569
|
+
return {
|
|
570
|
+
content: [
|
|
571
|
+
{
|
|
572
|
+
type: "text",
|
|
573
|
+
text: `Erro ao executar areas init: ${error instanceof Error ? error.message : String(error)}`
|
|
574
|
+
}
|
|
575
|
+
],
|
|
576
|
+
isError: true
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
);
|
|
336
581
|
async function startMcpServer() {
|
|
337
582
|
const transport = new StdioServerTransport();
|
|
338
583
|
await server.connect(transport);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justmpm/ai-tool",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Ferramenta de análise de dependências e impacto para projetos TypeScript/JavaScript. Usa Skott + Knip internamente.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dependency-analysis",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@modelcontextprotocol/sdk": "^1.25.3",
|
|
47
47
|
"knip": "^5.44.0",
|
|
48
|
+
"minimatch": "^10.0.1",
|
|
48
49
|
"skott": "^0.35.2",
|
|
49
50
|
"ts-morph": "^27.0.2",
|
|
50
51
|
"zod": "^3.25.76"
|