@justmpm/ai-tool 0.7.5 → 0.7.6
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,7 +3572,8 @@ 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
|
+
const triggerName = extractFirebaseTriggerName(init, filePath, name, importMap);
|
|
3554
3577
|
if (DEBUG_FUNCTIONS && filePath.includes("functions/src/")) {
|
|
3555
3578
|
const initText = init.getText().slice(0, 80).replace(/\s+/g, " ");
|
|
3556
3579
|
debugFunctions(`Analisando: ${filePath}:${varDecl.getStartLineNumber()} - ${name} = ${initText}...`);
|
|
@@ -3763,9 +3786,44 @@ function inferSymbolKind(name, context2) {
|
|
|
3763
3786
|
}
|
|
3764
3787
|
return context2 === "function" ? "function" : "const";
|
|
3765
3788
|
}
|
|
3766
|
-
function extractFirebaseTriggerName(init, filePath, varName) {
|
|
3789
|
+
function extractFirebaseTriggerName(init, filePath, varName, importMap) {
|
|
3767
3790
|
const text = init.getText().trim();
|
|
3768
3791
|
const shouldDebug = DEBUG_FUNCTIONS && filePath && filePath.includes("functions/src/");
|
|
3792
|
+
if (importMap && Node2.isCallExpression(init)) {
|
|
3793
|
+
const expr = init.getExpression();
|
|
3794
|
+
if (Node2.isIdentifier(expr)) {
|
|
3795
|
+
const name = expr.getText();
|
|
3796
|
+
const importInfo = importMap.get(name);
|
|
3797
|
+
if (importInfo && importInfo.module.includes("firebase-functions")) {
|
|
3798
|
+
if (FIREBASE_V2_TRIGGERS.has(importInfo.name)) {
|
|
3799
|
+
if (shouldDebug) debugFunctions(` [AST] Import detectado: ${name} -> ${importInfo.name} from ${importInfo.module}`);
|
|
3800
|
+
return importInfo.name;
|
|
3801
|
+
}
|
|
3802
|
+
}
|
|
3803
|
+
if (FIREBASE_V2_TRIGGERS.has(name)) {
|
|
3804
|
+
return name;
|
|
3805
|
+
}
|
|
3806
|
+
} else if (Node2.isPropertyAccessExpression(expr)) {
|
|
3807
|
+
const lastPart = expr.getName();
|
|
3808
|
+
if (FIREBASE_V2_TRIGGERS.has(lastPart)) {
|
|
3809
|
+
let root = expr.getExpression();
|
|
3810
|
+
while (Node2.isPropertyAccessExpression(root)) {
|
|
3811
|
+
root = root.getExpression();
|
|
3812
|
+
}
|
|
3813
|
+
if (Node2.isIdentifier(root)) {
|
|
3814
|
+
const rootName = root.getText();
|
|
3815
|
+
const importInfo = importMap.get(rootName);
|
|
3816
|
+
if (importInfo && importInfo.module.includes("firebase-functions")) {
|
|
3817
|
+
if (shouldDebug) debugFunctions(` [AST] Chain detectada: ${rootName}...${lastPart} from ${importInfo.module}`);
|
|
3818
|
+
return lastPart;
|
|
3819
|
+
}
|
|
3820
|
+
if (["v2", "functions", "firebase", "admin"].includes(rootName)) {
|
|
3821
|
+
return lastPart;
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3769
3827
|
if (shouldDebug && varName) {
|
|
3770
3828
|
debugFunctions(` [regex] Analisando texto: "${text.slice(0, 60)}..."`);
|
|
3771
3829
|
}
|
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-V625LOQR.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-OEYAIVEP.js");
|
|
112
112
|
await startMcpServer();
|
|
113
113
|
return;
|
|
114
114
|
}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED