@justmpm/ai-tool 0.7.3 → 0.7.5
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.
|
@@ -3429,12 +3429,30 @@ function indexProject(cwd) {
|
|
|
3429
3429
|
functionFiles.forEach((f) => debugFunctions(` - ${f}`));
|
|
3430
3430
|
}
|
|
3431
3431
|
const project = createProject2(cwd);
|
|
3432
|
+
let addedCount = 0;
|
|
3433
|
+
let errorCount = 0;
|
|
3432
3434
|
for (const file of allFiles) {
|
|
3433
3435
|
try {
|
|
3434
3436
|
project.addSourceFileAtPath(resolve(cwd, file));
|
|
3437
|
+
addedCount++;
|
|
3435
3438
|
} catch {
|
|
3439
|
+
errorCount++;
|
|
3440
|
+
if (DEBUG && file.includes("functions/src/")) {
|
|
3441
|
+
debugLog(`[indexer] Erro ao adicionar: ${file}`);
|
|
3442
|
+
}
|
|
3436
3443
|
}
|
|
3437
3444
|
}
|
|
3445
|
+
debugLog(`[indexer] Total de arquivos encontrados: ${allFiles.length}`);
|
|
3446
|
+
debugLog(`[indexer] Arquivos adicionados ao projeto: ${addedCount}`);
|
|
3447
|
+
debugLog(`[indexer] Arquivos com erro: ${errorCount}`);
|
|
3448
|
+
debugLog(`[indexer] SourceFiles no projeto: ${project.getSourceFiles().length}`);
|
|
3449
|
+
const functionsInProject = project.getSourceFiles().filter(
|
|
3450
|
+
(sf) => sf.getFilePath().includes("functions/src/")
|
|
3451
|
+
);
|
|
3452
|
+
debugFunctions(`[indexer] Arquivos functions/src/ no projeto: ${functionsInProject.length}`);
|
|
3453
|
+
functionsInProject.forEach((sf) => {
|
|
3454
|
+
debugFunctions(` - ${sf.getFilePath()}`);
|
|
3455
|
+
});
|
|
3438
3456
|
const files = {};
|
|
3439
3457
|
const symbolsByName = {};
|
|
3440
3458
|
let symbolCount = 0;
|
|
@@ -3503,6 +3521,10 @@ function indexProject(cwd) {
|
|
|
3503
3521
|
const init = varDecl.getInitializer();
|
|
3504
3522
|
if (!init) continue;
|
|
3505
3523
|
const initKind = init.getKind();
|
|
3524
|
+
const initKindName = init.getKindName();
|
|
3525
|
+
if (DEBUG_FUNCTIONS && filePath.includes("functions/src/")) {
|
|
3526
|
+
debugFunctions(`[kind] ${name}: ${initKindName} (kind=${initKind})`);
|
|
3527
|
+
}
|
|
3506
3528
|
if (initKind === SyntaxKind2.ArrowFunction || initKind === SyntaxKind2.FunctionExpression) {
|
|
3507
3529
|
const funcLike = init.asKind(SyntaxKind2.ArrowFunction) || init.asKind(SyntaxKind2.FunctionExpression);
|
|
3508
3530
|
if (!funcLike) continue;
|
|
@@ -3528,15 +3550,14 @@ function indexProject(cwd) {
|
|
|
3528
3550
|
exports.push(name);
|
|
3529
3551
|
}
|
|
3530
3552
|
} else if (initKind === SyntaxKind2.CallExpression) {
|
|
3531
|
-
const triggerName = extractFirebaseTriggerName(init);
|
|
3532
|
-
if (filePath.includes("functions/src/")) {
|
|
3553
|
+
const triggerName = extractFirebaseTriggerName(init, filePath, name);
|
|
3554
|
+
if (DEBUG_FUNCTIONS && filePath.includes("functions/src/")) {
|
|
3533
3555
|
const initText = init.getText().slice(0, 80).replace(/\s+/g, " ");
|
|
3534
3556
|
debugFunctions(`Analisando: ${filePath}:${varDecl.getStartLineNumber()} - ${name} = ${initText}...`);
|
|
3535
3557
|
if (triggerName) {
|
|
3536
|
-
debugFunctions(` \u2713 Trigger detectado: ${triggerName}`);
|
|
3558
|
+
debugFunctions(` \u2713\u2713\u2713 Trigger FINAL detectado: ${triggerName}`);
|
|
3537
3559
|
} else {
|
|
3538
|
-
|
|
3539
|
-
debugFunctions(` \u2717 N\xE3o \xE9 trigger. Texto: ${allText}...`);
|
|
3560
|
+
debugFunctions(` \u2717\u2717\u2717 Nenhum trigger detectado para: ${name}`);
|
|
3540
3561
|
}
|
|
3541
3562
|
}
|
|
3542
3563
|
if (triggerName && FIREBASE_V2_TRIGGERS.has(triggerName)) {
|
|
@@ -3684,16 +3705,25 @@ function indexProject(cwd) {
|
|
|
3684
3705
|
}
|
|
3685
3706
|
function createProject2(cwd) {
|
|
3686
3707
|
try {
|
|
3687
|
-
|
|
3708
|
+
const project = new Project2({
|
|
3688
3709
|
tsConfigFilePath: `${cwd}/tsconfig.json`,
|
|
3689
3710
|
skipAddingFilesFromTsConfig: true
|
|
3690
3711
|
});
|
|
3712
|
+
debugLog(`Projeto ts-morph criado com tsconfig: ${cwd}/tsconfig.json`);
|
|
3713
|
+
return project;
|
|
3691
3714
|
} catch {
|
|
3715
|
+
debugLog(`Falha ao ler tsconfig, criando projeto b\xE1sico`);
|
|
3692
3716
|
return new Project2({
|
|
3693
3717
|
skipAddingFilesFromTsConfig: true,
|
|
3694
3718
|
compilerOptions: {
|
|
3695
3719
|
allowJs: true,
|
|
3696
|
-
checkJs: false
|
|
3720
|
+
checkJs: false,
|
|
3721
|
+
target: 2,
|
|
3722
|
+
// ES2020
|
|
3723
|
+
module: 200,
|
|
3724
|
+
// ESNext
|
|
3725
|
+
moduleResolution: 100
|
|
3726
|
+
// Bundler
|
|
3697
3727
|
}
|
|
3698
3728
|
});
|
|
3699
3729
|
}
|
|
@@ -3733,11 +3763,22 @@ function inferSymbolKind(name, context2) {
|
|
|
3733
3763
|
}
|
|
3734
3764
|
return context2 === "function" ? "function" : "const";
|
|
3735
3765
|
}
|
|
3736
|
-
function extractFirebaseTriggerName(init) {
|
|
3737
|
-
const text = init.getText();
|
|
3766
|
+
function extractFirebaseTriggerName(init, filePath, varName) {
|
|
3767
|
+
const text = init.getText().trim();
|
|
3768
|
+
const shouldDebug = DEBUG_FUNCTIONS && filePath && filePath.includes("functions/src/");
|
|
3769
|
+
if (shouldDebug && varName) {
|
|
3770
|
+
debugFunctions(` [regex] Analisando texto: "${text.slice(0, 60)}..."`);
|
|
3771
|
+
}
|
|
3738
3772
|
for (const trigger of FIREBASE_V2_TRIGGERS) {
|
|
3739
|
-
const pattern = new RegExp(`(?:^|\\.|\\s)${trigger}(?:<[
|
|
3773
|
+
const pattern = new RegExp(`(?:^|\\.|\\s|\\()${trigger}(?:<[\\s\\S]*?>)?\\s*\\(`);
|
|
3774
|
+
if (shouldDebug && varName) {
|
|
3775
|
+
const testResult = pattern.test(text);
|
|
3776
|
+
debugFunctions(` [regex] Testando ${trigger}: ${testResult ? "\u2713 MATCH" : "\u2717 no match"}`);
|
|
3777
|
+
}
|
|
3740
3778
|
if (pattern.test(text)) {
|
|
3779
|
+
if (shouldDebug && varName) {
|
|
3780
|
+
debugFunctions(` [regex] \u2713\u2713\u2713 TRIGGER ENCONTRADO: ${trigger}`);
|
|
3781
|
+
}
|
|
3741
3782
|
return trigger;
|
|
3742
3783
|
}
|
|
3743
3784
|
}
|
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
impact,
|
|
14
14
|
map,
|
|
15
15
|
suggest
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-IZ2UC65O.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-
|
|
111
|
+
const { startMcpServer } = await import("./server-H7ZERMME.js");
|
|
112
112
|
await startMcpServer();
|
|
113
113
|
return;
|
|
114
114
|
}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED