@justmpm/ai-tool 0.7.2 → 0.7.4
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.
|
@@ -3330,11 +3330,17 @@ import { join as join4, extname as extname2, resolve } from "path";
|
|
|
3330
3330
|
import { Project as Project2, SyntaxKind as SyntaxKind2 } from "ts-morph";
|
|
3331
3331
|
var CODE_EXTENSIONS2 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]);
|
|
3332
3332
|
var DEBUG = process.env.DEBUG_ANALYZE === "true";
|
|
3333
|
+
var DEBUG_FUNCTIONS = process.env.DEBUG_FUNCTIONS === "true" || DEBUG;
|
|
3333
3334
|
function debugLog(...args) {
|
|
3334
3335
|
if (DEBUG) {
|
|
3335
3336
|
console.error("[analyze:debug]", ...args);
|
|
3336
3337
|
}
|
|
3337
3338
|
}
|
|
3339
|
+
function debugFunctions(...args) {
|
|
3340
|
+
if (DEBUG_FUNCTIONS) {
|
|
3341
|
+
console.error("[functions:debug]", ...args);
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3338
3344
|
var IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
3339
3345
|
"node_modules",
|
|
3340
3346
|
"dist",
|
|
@@ -3419,6 +3425,8 @@ function indexProject(cwd) {
|
|
|
3419
3425
|
const functionFiles = allFiles.filter((f) => f.includes("functions/src/"));
|
|
3420
3426
|
if (functionFiles.length > 0) {
|
|
3421
3427
|
debugLog(`Encontrados ${functionFiles.length} arquivos em functions/src/:`, functionFiles);
|
|
3428
|
+
debugFunctions(`Arquivos em functions/src/:`);
|
|
3429
|
+
functionFiles.forEach((f) => debugFunctions(` - ${f}`));
|
|
3422
3430
|
}
|
|
3423
3431
|
const project = createProject2(cwd);
|
|
3424
3432
|
for (const file of allFiles) {
|
|
@@ -3495,6 +3503,10 @@ function indexProject(cwd) {
|
|
|
3495
3503
|
const init = varDecl.getInitializer();
|
|
3496
3504
|
if (!init) continue;
|
|
3497
3505
|
const initKind = init.getKind();
|
|
3506
|
+
const initKindName = init.getKindName();
|
|
3507
|
+
if (DEBUG_FUNCTIONS && filePath.includes("functions/src/")) {
|
|
3508
|
+
debugFunctions(`[kind] ${name}: ${initKindName} (kind=${initKind})`);
|
|
3509
|
+
}
|
|
3498
3510
|
if (initKind === SyntaxKind2.ArrowFunction || initKind === SyntaxKind2.FunctionExpression) {
|
|
3499
3511
|
const funcLike = init.asKind(SyntaxKind2.ArrowFunction) || init.asKind(SyntaxKind2.FunctionExpression);
|
|
3500
3512
|
if (!funcLike) continue;
|
|
@@ -3520,12 +3532,14 @@ function indexProject(cwd) {
|
|
|
3520
3532
|
exports.push(name);
|
|
3521
3533
|
}
|
|
3522
3534
|
} else if (initKind === SyntaxKind2.CallExpression) {
|
|
3523
|
-
const triggerName = extractFirebaseTriggerName(init);
|
|
3524
|
-
if (
|
|
3525
|
-
const initText = init.getText().slice(0,
|
|
3526
|
-
|
|
3535
|
+
const triggerName = extractFirebaseTriggerName(init, filePath, name);
|
|
3536
|
+
if (DEBUG_FUNCTIONS && filePath.includes("functions/src/")) {
|
|
3537
|
+
const initText = init.getText().slice(0, 80).replace(/\s+/g, " ");
|
|
3538
|
+
debugFunctions(`Analisando: ${filePath}:${varDecl.getStartLineNumber()} - ${name} = ${initText}...`);
|
|
3527
3539
|
if (triggerName) {
|
|
3528
|
-
|
|
3540
|
+
debugFunctions(` \u2713\u2713\u2713 Trigger FINAL detectado: ${triggerName}`);
|
|
3541
|
+
} else {
|
|
3542
|
+
debugFunctions(` \u2717\u2717\u2717 Nenhum trigger detectado para: ${name}`);
|
|
3529
3543
|
}
|
|
3530
3544
|
}
|
|
3531
3545
|
if (triggerName && FIREBASE_V2_TRIGGERS.has(triggerName)) {
|
|
@@ -3722,11 +3736,22 @@ function inferSymbolKind(name, context2) {
|
|
|
3722
3736
|
}
|
|
3723
3737
|
return context2 === "function" ? "function" : "const";
|
|
3724
3738
|
}
|
|
3725
|
-
function extractFirebaseTriggerName(init) {
|
|
3726
|
-
const text = init.getText();
|
|
3739
|
+
function extractFirebaseTriggerName(init, filePath, varName) {
|
|
3740
|
+
const text = init.getText().trim();
|
|
3741
|
+
const shouldDebug = DEBUG_FUNCTIONS && filePath && filePath.includes("functions/src/");
|
|
3742
|
+
if (shouldDebug && varName) {
|
|
3743
|
+
debugFunctions(` [regex] Analisando texto: "${text.slice(0, 60)}..."`);
|
|
3744
|
+
}
|
|
3727
3745
|
for (const trigger of FIREBASE_V2_TRIGGERS) {
|
|
3728
|
-
const pattern = new RegExp(`(?:^|\\.|\\s)${trigger}(?:<[
|
|
3746
|
+
const pattern = new RegExp(`(?:^|\\.|\\s|\\()${trigger}(?:<[\\s\\S]*?>)?\\s*\\(`);
|
|
3747
|
+
if (shouldDebug && varName) {
|
|
3748
|
+
const testResult = pattern.test(text);
|
|
3749
|
+
debugFunctions(` [regex] Testando ${trigger}: ${testResult ? "\u2713 MATCH" : "\u2717 no match"}`);
|
|
3750
|
+
}
|
|
3729
3751
|
if (pattern.test(text)) {
|
|
3752
|
+
if (shouldDebug && varName) {
|
|
3753
|
+
debugFunctions(` [regex] \u2713\u2713\u2713 TRIGGER ENCONTRADO: ${trigger}`);
|
|
3754
|
+
}
|
|
3730
3755
|
return trigger;
|
|
3731
3756
|
}
|
|
3732
3757
|
}
|
|
@@ -4625,11 +4650,15 @@ async function functions(options = {}) {
|
|
|
4625
4650
|
updateCacheMeta(cwd);
|
|
4626
4651
|
}
|
|
4627
4652
|
}
|
|
4653
|
+
const functionFiles = Object.values(index.files).filter((f) => f.path.includes("functions/src/"));
|
|
4628
4654
|
const funcs = [];
|
|
4629
|
-
|
|
4630
|
-
|
|
4655
|
+
let totalSymbolsInFunctions = 0;
|
|
4656
|
+
let triggerSymbolsFound = 0;
|
|
4657
|
+
for (const fileData of functionFiles) {
|
|
4658
|
+
totalSymbolsInFunctions += fileData.symbols.length;
|
|
4631
4659
|
for (const symbol of fileData.symbols) {
|
|
4632
4660
|
if (symbol.kind === "trigger") {
|
|
4661
|
+
triggerSymbolsFound++;
|
|
4633
4662
|
funcs.push({
|
|
4634
4663
|
name: symbol.name,
|
|
4635
4664
|
file: symbol.file,
|
|
@@ -4642,6 +4671,18 @@ async function functions(options = {}) {
|
|
|
4642
4671
|
}
|
|
4643
4672
|
}
|
|
4644
4673
|
}
|
|
4674
|
+
if (funcs.length === 0 && (process.env.DEBUG_FUNCTIONS === "true" || process.env.DEBUG_ANALYZE === "true")) {
|
|
4675
|
+
console.error(`[functions:debug] Total de arquivos indexados: ${Object.keys(index.files).length}`);
|
|
4676
|
+
console.error(`[functions:debug] Arquivos em functions/src/: ${functionFiles.length}`);
|
|
4677
|
+
console.error(`[functions:debug] Total de s\xEDmbolos em functions/src/: ${totalSymbolsInFunctions}`);
|
|
4678
|
+
console.error(`[functions:debug] S\xEDmbolos do tipo 'trigger': ${triggerSymbolsFound}`);
|
|
4679
|
+
functionFiles.forEach((f) => {
|
|
4680
|
+
console.error(`[functions:debug] ${f.path}: ${f.symbols.length} s\xEDmbolos`);
|
|
4681
|
+
f.symbols.forEach((s) => {
|
|
4682
|
+
console.error(`[functions:debug] - ${s.name} (${s.kind})${s.isExported ? " [exported]" : ""}`);
|
|
4683
|
+
});
|
|
4684
|
+
});
|
|
4685
|
+
}
|
|
4645
4686
|
const filtered = filterTrigger ? funcs.filter(
|
|
4646
4687
|
(f) => f.triggerType.toLowerCase().includes(filterTrigger.toLowerCase())
|
|
4647
4688
|
) : funcs;
|
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-JUKU4SGB.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-52VHXRUA.js");
|
|
112
112
|
await startMcpServer();
|
|
113
113
|
return;
|
|
114
114
|
}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED