@justmpm/ai-tool 0.7.7 → 0.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1395,6 +1395,7 @@ function calculateFilesHash(cwd) {
1395
1395
  function getCacheDir(cwd) {
1396
1396
  return join2(cwd, CACHE_DIR);
1397
1397
  }
1398
+ var MIN_SCHEMA_VERSION = "2.0.0";
1398
1399
  function isCacheValid(cwd) {
1399
1400
  const cacheDir = getCacheDir(cwd);
1400
1401
  const metaPath = join2(cacheDir, META_FILE);
@@ -1403,6 +1404,9 @@ function isCacheValid(cwd) {
1403
1404
  }
1404
1405
  try {
1405
1406
  const meta = JSON.parse(readFileSync2(metaPath, "utf-8"));
1407
+ if (!meta.schemaVersion || meta.schemaVersion < MIN_SCHEMA_VERSION) {
1408
+ return false;
1409
+ }
1406
1410
  const currentHash = calculateFilesHash(cwd);
1407
1411
  return meta.filesHash === currentHash;
1408
1412
  } catch {
@@ -1431,6 +1435,7 @@ function writeCache(cwd, file, data) {
1431
1435
  function updateCacheMeta(cwd) {
1432
1436
  const meta = {
1433
1437
  version: "1.0.0",
1438
+ schemaVersion: "2.0.0",
1434
1439
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1435
1440
  lastCheck: (/* @__PURE__ */ new Date()).toISOString(),
1436
1441
  filesHash: calculateFilesHash(cwd)
@@ -4610,6 +4615,9 @@ Ou edite manualmente o arquivo existente.
4610
4615
  }
4611
4616
  };
4612
4617
  writeConfig(cwd, newConfig);
4618
+ const unmappedCount = allFiles.filter(
4619
+ (f) => detectFileAreas(f, newConfig).length === 0
4620
+ ).length;
4613
4621
  const sortedAreas = [...areaCounts.entries()].sort((a, b) => b[1].size - a[1].size);
4614
4622
  let out = `
4615
4623
  \u2705 Arquivo criado: .analyze/areas.config.json
@@ -4631,9 +4639,6 @@ Ou edite manualmente o arquivo existente.
4631
4639
  out += ` ... e mais ${sortedAreas.length - 15}
4632
4640
  `;
4633
4641
  }
4634
- const unmappedCount = allFiles.filter(
4635
- (f) => detectFileAreas(f, currentConfig).length === 0
4636
- ).length;
4637
4642
  if (unmappedCount > 0) {
4638
4643
  out += `
4639
4644
  \u26A0\uFE0F ${unmappedCount} arquivos sem \xE1rea definida
@@ -4650,13 +4655,46 @@ Ou edite manualmente o arquivo existente.
4650
4655
  }
4651
4656
  }
4652
4657
  out += `
4653
- \u{1F4A1} Edite o arquivo para:
4654
- - Renomear \xE1reas (campo "name")
4655
- - Adicionar descri\xE7\xF5es (campo "description")
4656
- - Ajustar padr\xF5es (campo "patterns")
4657
- - Adicionar/remover \xE1reas
4658
- - Definir descri\xE7\xF5es espec\xEDficas de arquivos (campo "descriptions")
4659
- `;
4658
+ \u{1F4A1} Boas pr\xE1ticas:
4659
+ - Ideal: 5-15 \xE1reas (muitas \xE1reas \xE9 dif\xEDcil de navegar)
4660
+ - Use patterns para pastas, keywords para arquivos espalhados
4661
+ - Se uma \xE1rea tem <3 arquivos, considere mesclar com outra
4662
+ - Se tem >50 arquivos, considere dividir em sub-\xE1reas
4663
+
4664
+ \u{1F4DD} Como customizar:
4665
+ 1. Renomear \xE1reas: altere o campo "name"
4666
+ 2. Ajustar padr\xF5es: edite "patterns" (glob) ou "keywords"
4667
+ 3. Adicionar descri\xE7\xF5es: campo "description" explica o dom\xEDnio
4668
+ 4. Descri\xE7\xF5es de arquivos: use "descriptions" para documentos espec\xEDficos
4669
+
4670
+ \u{1F4A1} Exemplo de customiza\xE7\xE3o:
4671
+
4672
+ Antes (nome gen\xE9rico detectado):
4673
+ "user-profile": { "name": "User Profile", ... }
4674
+
4675
+ Depois (renomeado para dom\xEDnio de neg\xF3cio):
4676
+ "meu-perfil": { "name": "Meu Perfil", "description": "Edi\xE7\xE3o de perfil do usu\xE1rio" }
4677
+
4678
+ \u2699\uFE0F Quando usar autoDetect: false
4679
+ - Quando quer controle total das \xE1reas
4680
+ - Quando a detec\xE7\xE3o autom\xE1tica est\xE1 muito imprecisa
4681
+ - Quando o projeto tem dom\xEDnios muito espec\xEDficos
4682
+
4683
+ \u{1F4A1} Casos especiais:
4684
+ - Arquivos compartilhados: adicione a m\xFAltiplas \xE1reas
4685
+ - Utils globais: crie \xE1rea 'shared' ou use 'ignore'
4686
+ - Monorepo: use 'patterns' com caminhos relativos \xE0 raiz
4687
+
4688
+ \u{1F527} Manuten\xE7\xE3o:
4689
+ - Atualize o config ao criar/mover arquivos
4690
+ - Use 'ai-tool areas' para verificar arquivos sem \xE1rea
4691
+ - Use 'ai-tool area <nome>' para ver o que foi detectado
4692
+
4693
+ \u{1F4CB} Pr\xF3ximos passos:
4694
+ \u2192 Execute 'ai-tool areas' para ver o resultado
4695
+ \u2192 Use 'ai-tool area <nome>' para validar uma \xE1rea espec\xEDfica
4696
+ \u2192 Execute 'ai-tool map' para ver o resumo atualizado
4697
+ `;
4660
4698
  return out.trim();
4661
4699
  } catch (error) {
4662
4700
  const message = error instanceof Error ? error.message : String(error);
@@ -4728,7 +4766,9 @@ function getAllCodeFiles5(dir, files = [], baseDir = dir) {
4728
4766
  const ext = extname6(entry).toLowerCase();
4729
4767
  if (CODE_EXTENSIONS6.has(ext)) {
4730
4768
  const relativePath = fullPath.slice(baseDir.length + 1).replace(/\\/g, "/");
4731
- files.push(relativePath);
4769
+ if (relativePath && !relativePath.startsWith("..")) {
4770
+ files.push(relativePath);
4771
+ }
4732
4772
  }
4733
4773
  }
4734
4774
  } catch {
@@ -4772,41 +4812,10 @@ async function functions(options = {}) {
4772
4812
  }
4773
4813
  }
4774
4814
  const functionFiles = Object.values(index.files).filter((f) => f.path.includes("functions/src/"));
4775
- if (process.env.DEBUG_FUNCTIONS === "true" || process.env.DEBUG_ANALYZE === "true") {
4776
- console.error(`
4777
- [functions:debug] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);
4778
- console.error(`[functions:debug] ESTAT\xCDSTICAS DE INDEXA\xC7\xC3O`);
4779
- console.error(`[functions:debug] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);
4780
- console.error(`[functions:debug] Total de arquivos indexados: ${Object.keys(index.files).length}`);
4781
- console.error(`[functions:debug] Arquivos em functions/src/: ${functionFiles.length}`);
4782
- if (functionFiles.length === 0) {
4783
- console.error(`[functions:debug] \u26A0\uFE0F NENHUM arquivo em functions/src/ encontrado!`);
4784
- console.error(`[functions:debug] Listando todos os arquivos indexados:`);
4785
- Object.keys(index.files).slice(0, 20).forEach((f) => {
4786
- console.error(`[functions:debug] - ${f}`);
4787
- });
4788
- }
4789
- functionFiles.forEach((f) => {
4790
- console.error(`
4791
- [functions:debug] \u{1F4C4} ${f.path}`);
4792
- console.error(`[functions:debug] Categoria: ${f.category}`);
4793
- console.error(`[functions:debug] S\xEDmbolos: ${f.symbols.length}`);
4794
- f.symbols.forEach((s) => {
4795
- console.error(`[functions:debug] - ${s.name} [${s.kind}]${s.isExported ? " \u2713" : " \u2717"} (linha ${s.line})`);
4796
- });
4797
- console.error(`[functions:debug] Exports: ${f.exports.join(", ") || "(nenhum)"}`);
4798
- });
4799
- console.error(`[functions:debug] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
4800
- `);
4801
- }
4802
4815
  const funcs = [];
4803
- let totalSymbolsInFunctions = 0;
4804
- let triggerSymbolsFound = 0;
4805
4816
  for (const fileData of functionFiles) {
4806
- totalSymbolsInFunctions += fileData.symbols.length;
4807
4817
  for (const symbol of fileData.symbols) {
4808
4818
  if (symbol.kind === "trigger") {
4809
- triggerSymbolsFound++;
4810
4819
  funcs.push({
4811
4820
  name: symbol.name,
4812
4821
  file: symbol.file,
@@ -4819,18 +4828,6 @@ async function functions(options = {}) {
4819
4828
  }
4820
4829
  }
4821
4830
  }
4822
- if (funcs.length === 0 && (process.env.DEBUG_FUNCTIONS === "true" || process.env.DEBUG_ANALYZE === "true")) {
4823
- console.error(`[functions:debug] Total de arquivos indexados: ${Object.keys(index.files).length}`);
4824
- console.error(`[functions:debug] Arquivos em functions/src/: ${functionFiles.length}`);
4825
- console.error(`[functions:debug] Total de s\xEDmbolos em functions/src/: ${totalSymbolsInFunctions}`);
4826
- console.error(`[functions:debug] S\xEDmbolos do tipo 'trigger': ${triggerSymbolsFound}`);
4827
- functionFiles.forEach((f) => {
4828
- console.error(`[functions:debug] ${f.path}: ${f.symbols.length} s\xEDmbolos`);
4829
- f.symbols.forEach((s) => {
4830
- console.error(`[functions:debug] - ${s.name} (${s.kind})${s.isExported ? " [exported]" : ""}`);
4831
- });
4832
- });
4833
- }
4834
4831
  const filtered = filterTrigger ? funcs.filter(
4835
4832
  (f) => f.triggerType.toLowerCase().includes(filterTrigger.toLowerCase())
4836
4833
  ) : funcs;
@@ -4907,9 +4904,9 @@ function formatFunctionsText(result) {
4907
4904
  `;
4908
4905
  out += ` 3. Os triggers n\xE3o usam padr\xF5es v2 (onCall, onDocumentCreated, etc)
4909
4906
  `;
4910
- out += ` 4. O cache est\xE1 desatualizado \u2192 tente: ai-tool functions --no-cache
4907
+ out += ` 4. O cache est\xE1 desatualizado (ex: atualizou o ai-tool recentemente)
4911
4908
  `;
4912
- out += ` 5. Para debug: DEBUG_ANALYZE=true ai-tool functions
4909
+ out += ` \u2192 Tente: ai-tool functions --no-cache
4913
4910
 
4914
4911
  `;
4915
4912
  out += ` Padr\xF5es suportados:
package/dist/cli.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  impact,
14
14
  map,
15
15
  suggest
16
- } from "./chunk-KAP6AXYR.js";
16
+ } from "./chunk-PUA5CWMJ.js";
17
17
 
18
18
  // src/cli.ts
19
19
  import { resolve } from "path";
@@ -108,7 +108,7 @@ async function main() {
108
108
  }
109
109
  }
110
110
  if (flags.mcp) {
111
- const { startMcpServer } = await import("./server-URBWKWHH.js");
111
+ const { startMcpServer } = await import("./server-GII6BLXS.js");
112
112
  await startMcpServer();
113
113
  return;
114
114
  }
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ import {
47
47
  setFileDescription,
48
48
  suggest,
49
49
  writeConfig
50
- } from "./chunk-KAP6AXYR.js";
50
+ } from "./chunk-PUA5CWMJ.js";
51
51
  export {
52
52
  AREA_DESCRIPTIONS,
53
53
  AREA_NAMES,
@@ -11,7 +11,7 @@ import {
11
11
  impact,
12
12
  map,
13
13
  suggest
14
- } from "./chunk-KAP6AXYR.js";
14
+ } from "./chunk-PUA5CWMJ.js";
15
15
 
16
16
  // src/mcp/server.ts
17
17
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justmpm/ai-tool",
3
- "version": "0.7.7",
3
+ "version": "0.7.9",
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",