@justmpm/ai-tool 0.7.5 → 0.7.7
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.
|
@@ -3327,7 +3327,7 @@ function extractExports(sourceFile) {
|
|
|
3327
3327
|
// src/ts/indexer.ts
|
|
3328
3328
|
import { readdirSync as readdirSync2, statSync as statSync2 } from "fs";
|
|
3329
3329
|
import { join as join4, extname as extname2, resolve } from "path";
|
|
3330
|
-
import { Project as Project2, SyntaxKind as SyntaxKind2 } from "ts-morph";
|
|
3330
|
+
import { Project as Project2, SyntaxKind as SyntaxKind2, Node as Node2 } 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
3333
|
var DEBUG_FUNCTIONS = process.env.DEBUG_FUNCTIONS === "true" || DEBUG;
|
|
@@ -3419,6 +3419,28 @@ var FIREBASE_V2_TRIGGERS = /* @__PURE__ */ new Set([
|
|
|
3419
3419
|
// Test Lab (firebase-functions/v2/testLab)
|
|
3420
3420
|
"onTestMatrixCompleted"
|
|
3421
3421
|
]);
|
|
3422
|
+
function buildImportMap(sourceFile) {
|
|
3423
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
3424
|
+
if (!sourceFile.getImportDeclarations) return map2;
|
|
3425
|
+
for (const decl of sourceFile.getImportDeclarations()) {
|
|
3426
|
+
const module = decl.getModuleSpecifierValue();
|
|
3427
|
+
const ns = decl.getNamespaceImport();
|
|
3428
|
+
if (ns) {
|
|
3429
|
+
map2.set(ns.getText(), { name: "*", module });
|
|
3430
|
+
}
|
|
3431
|
+
for (const named of decl.getNamedImports()) {
|
|
3432
|
+
const alias = named.getAliasNode();
|
|
3433
|
+
const name = named.getName();
|
|
3434
|
+
const localName = alias ? alias.getText() : name;
|
|
3435
|
+
map2.set(localName, { name, module });
|
|
3436
|
+
}
|
|
3437
|
+
const def = decl.getDefaultImport();
|
|
3438
|
+
if (def) {
|
|
3439
|
+
map2.set(def.getText(), { name: "default", module });
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
return map2;
|
|
3443
|
+
}
|
|
3422
3444
|
function indexProject(cwd) {
|
|
3423
3445
|
const allFiles = getAllCodeFiles(cwd);
|
|
3424
3446
|
debugLog(`Indexando ${allFiles.length} arquivos em ${cwd}`);
|
|
@@ -3550,10 +3572,20 @@ function indexProject(cwd) {
|
|
|
3550
3572
|
exports.push(name);
|
|
3551
3573
|
}
|
|
3552
3574
|
} else if (initKind === SyntaxKind2.CallExpression) {
|
|
3553
|
-
const
|
|
3575
|
+
const importMap = buildImportMap(sourceFile);
|
|
3576
|
+
if (DEBUG_FUNCTIONS && filePath.includes("functions/src/")) {
|
|
3577
|
+
const initText = init.getText().slice(0, 100).replace(/\s+/g, " ");
|
|
3578
|
+
debugFunctions(`
|
|
3579
|
+
[CallExpression] ${filePath}:${varDecl.getStartLineNumber()}`);
|
|
3580
|
+
debugFunctions(` Vari\xE1vel: ${name}`);
|
|
3581
|
+
debugFunctions(` C\xF3digo: ${initText}...`);
|
|
3582
|
+
debugFunctions(` Imports encontrados: ${importMap.size}`);
|
|
3583
|
+
importMap.forEach((info, key) => {
|
|
3584
|
+
debugFunctions(` - ${key} -> ${info.name} from ${info.module}`);
|
|
3585
|
+
});
|
|
3586
|
+
}
|
|
3587
|
+
const triggerName = extractFirebaseTriggerName(init, filePath, name, importMap);
|
|
3554
3588
|
if (DEBUG_FUNCTIONS && filePath.includes("functions/src/")) {
|
|
3555
|
-
const initText = init.getText().slice(0, 80).replace(/\s+/g, " ");
|
|
3556
|
-
debugFunctions(`Analisando: ${filePath}:${varDecl.getStartLineNumber()} - ${name} = ${initText}...`);
|
|
3557
3589
|
if (triggerName) {
|
|
3558
3590
|
debugFunctions(` \u2713\u2713\u2713 Trigger FINAL detectado: ${triggerName}`);
|
|
3559
3591
|
} else {
|
|
@@ -3763,9 +3795,71 @@ function inferSymbolKind(name, context2) {
|
|
|
3763
3795
|
}
|
|
3764
3796
|
return context2 === "function" ? "function" : "const";
|
|
3765
3797
|
}
|
|
3766
|
-
function extractFirebaseTriggerName(init, filePath, varName) {
|
|
3798
|
+
function extractFirebaseTriggerName(init, filePath, varName, importMap) {
|
|
3767
3799
|
const text = init.getText().trim();
|
|
3768
3800
|
const shouldDebug = DEBUG_FUNCTIONS && filePath && filePath.includes("functions/src/");
|
|
3801
|
+
if (shouldDebug) {
|
|
3802
|
+
debugFunctions(`[extractFirebaseTriggerName] Iniciando an\xE1lise`);
|
|
3803
|
+
debugFunctions(` VarName: ${varName}`);
|
|
3804
|
+
debugFunctions(` Node Kind: ${init.getKindName()} (${init.getKind()})`);
|
|
3805
|
+
debugFunctions(` \xC9 CallExpression: ${Node2.isCallExpression(init)}`);
|
|
3806
|
+
debugFunctions(` ImportMap dispon\xEDvel: ${importMap ? "SIM" : "N\xC3O"}`);
|
|
3807
|
+
}
|
|
3808
|
+
if (importMap && Node2.isCallExpression(init)) {
|
|
3809
|
+
const expr = init.getExpression();
|
|
3810
|
+
if (shouldDebug) {
|
|
3811
|
+
debugFunctions(` Expression Kind: ${expr.getKindName()} (${expr.getKind()})`);
|
|
3812
|
+
debugFunctions(` \xC9 Identifier: ${Node2.isIdentifier(expr)}`);
|
|
3813
|
+
debugFunctions(` \xC9 PropertyAccess: ${Node2.isPropertyAccessExpression(expr)}`);
|
|
3814
|
+
}
|
|
3815
|
+
if (Node2.isIdentifier(expr)) {
|
|
3816
|
+
const name = expr.getText();
|
|
3817
|
+
const importInfo = importMap.get(name);
|
|
3818
|
+
if (shouldDebug) {
|
|
3819
|
+
debugFunctions(` [Caso 1: Identifier] Nome: ${name}`);
|
|
3820
|
+
debugFunctions(` ImportInfo: ${importInfo ? JSON.stringify(importInfo) : "n\xE3o encontrado"}`);
|
|
3821
|
+
}
|
|
3822
|
+
if (importInfo && importInfo.module.includes("firebase-functions")) {
|
|
3823
|
+
if (FIREBASE_V2_TRIGGERS.has(importInfo.name)) {
|
|
3824
|
+
if (shouldDebug) debugFunctions(` \u2713 Import detectado: ${name} -> ${importInfo.name} from ${importInfo.module}`);
|
|
3825
|
+
return importInfo.name;
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
if (FIREBASE_V2_TRIGGERS.has(name)) {
|
|
3829
|
+
if (shouldDebug) debugFunctions(` \u2713 Trigger conhecido detectado: ${name}`);
|
|
3830
|
+
return name;
|
|
3831
|
+
}
|
|
3832
|
+
} else if (Node2.isPropertyAccessExpression(expr)) {
|
|
3833
|
+
const lastPart = expr.getName();
|
|
3834
|
+
if (shouldDebug) {
|
|
3835
|
+
debugFunctions(` [Caso 2: PropertyAccess] \xDAltima parte: ${lastPart}`);
|
|
3836
|
+
}
|
|
3837
|
+
if (FIREBASE_V2_TRIGGERS.has(lastPart)) {
|
|
3838
|
+
let root = expr.getExpression();
|
|
3839
|
+
let depth = 0;
|
|
3840
|
+
while (Node2.isPropertyAccessExpression(root) && depth < 10) {
|
|
3841
|
+
root = root.getExpression();
|
|
3842
|
+
depth++;
|
|
3843
|
+
}
|
|
3844
|
+
if (Node2.isIdentifier(root)) {
|
|
3845
|
+
const rootName = root.getText();
|
|
3846
|
+
const importInfo = importMap.get(rootName);
|
|
3847
|
+
if (shouldDebug) {
|
|
3848
|
+
debugFunctions(` Raiz: ${rootName} (profundidade: ${depth})`);
|
|
3849
|
+
debugFunctions(` ImportInfo da raiz: ${importInfo ? JSON.stringify(importInfo) : "n\xE3o encontrado"}`);
|
|
3850
|
+
}
|
|
3851
|
+
if (importInfo && importInfo.module.includes("firebase-functions")) {
|
|
3852
|
+
if (shouldDebug) debugFunctions(` \u2713 Chain detectada: ${rootName}...${lastPart} from ${importInfo.module}`);
|
|
3853
|
+
return lastPart;
|
|
3854
|
+
}
|
|
3855
|
+
if (["v2", "functions", "firebase", "admin"].includes(rootName)) {
|
|
3856
|
+
if (shouldDebug) debugFunctions(` \u2713 Heur\xEDstica: raiz "${rootName}" \xE9 conhecida do Firebase`);
|
|
3857
|
+
return lastPart;
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
}
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3769
3863
|
if (shouldDebug && varName) {
|
|
3770
3864
|
debugFunctions(` [regex] Analisando texto: "${text.slice(0, 60)}..."`);
|
|
3771
3865
|
}
|
|
@@ -4678,6 +4772,33 @@ async function functions(options = {}) {
|
|
|
4678
4772
|
}
|
|
4679
4773
|
}
|
|
4680
4774
|
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
|
+
}
|
|
4681
4802
|
const funcs = [];
|
|
4682
4803
|
let totalSymbolsInFunctions = 0;
|
|
4683
4804
|
let triggerSymbolsFound = 0;
|
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-KAP6AXYR.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-URBWKWHH.js");
|
|
112
112
|
await startMcpServer();
|
|
113
113
|
return;
|
|
114
114
|
}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED