@justmpm/ai-tool 0.7.6 → 0.7.8
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)
|
|
@@ -3573,10 +3578,19 @@ function indexProject(cwd) {
|
|
|
3573
3578
|
}
|
|
3574
3579
|
} else if (initKind === SyntaxKind2.CallExpression) {
|
|
3575
3580
|
const importMap = buildImportMap(sourceFile);
|
|
3581
|
+
if (DEBUG_FUNCTIONS && filePath.includes("functions/src/")) {
|
|
3582
|
+
const initText = init.getText().slice(0, 100).replace(/\s+/g, " ");
|
|
3583
|
+
debugFunctions(`
|
|
3584
|
+
[CallExpression] ${filePath}:${varDecl.getStartLineNumber()}`);
|
|
3585
|
+
debugFunctions(` Vari\xE1vel: ${name}`);
|
|
3586
|
+
debugFunctions(` C\xF3digo: ${initText}...`);
|
|
3587
|
+
debugFunctions(` Imports encontrados: ${importMap.size}`);
|
|
3588
|
+
importMap.forEach((info, key) => {
|
|
3589
|
+
debugFunctions(` - ${key} -> ${info.name} from ${info.module}`);
|
|
3590
|
+
});
|
|
3591
|
+
}
|
|
3576
3592
|
const triggerName = extractFirebaseTriggerName(init, filePath, name, importMap);
|
|
3577
3593
|
if (DEBUG_FUNCTIONS && filePath.includes("functions/src/")) {
|
|
3578
|
-
const initText = init.getText().slice(0, 80).replace(/\s+/g, " ");
|
|
3579
|
-
debugFunctions(`Analisando: ${filePath}:${varDecl.getStartLineNumber()} - ${name} = ${initText}...`);
|
|
3580
3594
|
if (triggerName) {
|
|
3581
3595
|
debugFunctions(` \u2713\u2713\u2713 Trigger FINAL detectado: ${triggerName}`);
|
|
3582
3596
|
} else {
|
|
@@ -3789,35 +3803,62 @@ function inferSymbolKind(name, context2) {
|
|
|
3789
3803
|
function extractFirebaseTriggerName(init, filePath, varName, importMap) {
|
|
3790
3804
|
const text = init.getText().trim();
|
|
3791
3805
|
const shouldDebug = DEBUG_FUNCTIONS && filePath && filePath.includes("functions/src/");
|
|
3806
|
+
if (shouldDebug) {
|
|
3807
|
+
debugFunctions(`[extractFirebaseTriggerName] Iniciando an\xE1lise`);
|
|
3808
|
+
debugFunctions(` VarName: ${varName}`);
|
|
3809
|
+
debugFunctions(` Node Kind: ${init.getKindName()} (${init.getKind()})`);
|
|
3810
|
+
debugFunctions(` \xC9 CallExpression: ${Node2.isCallExpression(init)}`);
|
|
3811
|
+
debugFunctions(` ImportMap dispon\xEDvel: ${importMap ? "SIM" : "N\xC3O"}`);
|
|
3812
|
+
}
|
|
3792
3813
|
if (importMap && Node2.isCallExpression(init)) {
|
|
3793
3814
|
const expr = init.getExpression();
|
|
3815
|
+
if (shouldDebug) {
|
|
3816
|
+
debugFunctions(` Expression Kind: ${expr.getKindName()} (${expr.getKind()})`);
|
|
3817
|
+
debugFunctions(` \xC9 Identifier: ${Node2.isIdentifier(expr)}`);
|
|
3818
|
+
debugFunctions(` \xC9 PropertyAccess: ${Node2.isPropertyAccessExpression(expr)}`);
|
|
3819
|
+
}
|
|
3794
3820
|
if (Node2.isIdentifier(expr)) {
|
|
3795
3821
|
const name = expr.getText();
|
|
3796
3822
|
const importInfo = importMap.get(name);
|
|
3823
|
+
if (shouldDebug) {
|
|
3824
|
+
debugFunctions(` [Caso 1: Identifier] Nome: ${name}`);
|
|
3825
|
+
debugFunctions(` ImportInfo: ${importInfo ? JSON.stringify(importInfo) : "n\xE3o encontrado"}`);
|
|
3826
|
+
}
|
|
3797
3827
|
if (importInfo && importInfo.module.includes("firebase-functions")) {
|
|
3798
3828
|
if (FIREBASE_V2_TRIGGERS.has(importInfo.name)) {
|
|
3799
|
-
if (shouldDebug) debugFunctions(`
|
|
3829
|
+
if (shouldDebug) debugFunctions(` \u2713 Import detectado: ${name} -> ${importInfo.name} from ${importInfo.module}`);
|
|
3800
3830
|
return importInfo.name;
|
|
3801
3831
|
}
|
|
3802
3832
|
}
|
|
3803
3833
|
if (FIREBASE_V2_TRIGGERS.has(name)) {
|
|
3834
|
+
if (shouldDebug) debugFunctions(` \u2713 Trigger conhecido detectado: ${name}`);
|
|
3804
3835
|
return name;
|
|
3805
3836
|
}
|
|
3806
3837
|
} else if (Node2.isPropertyAccessExpression(expr)) {
|
|
3807
3838
|
const lastPart = expr.getName();
|
|
3839
|
+
if (shouldDebug) {
|
|
3840
|
+
debugFunctions(` [Caso 2: PropertyAccess] \xDAltima parte: ${lastPart}`);
|
|
3841
|
+
}
|
|
3808
3842
|
if (FIREBASE_V2_TRIGGERS.has(lastPart)) {
|
|
3809
3843
|
let root = expr.getExpression();
|
|
3810
|
-
|
|
3844
|
+
let depth = 0;
|
|
3845
|
+
while (Node2.isPropertyAccessExpression(root) && depth < 10) {
|
|
3811
3846
|
root = root.getExpression();
|
|
3847
|
+
depth++;
|
|
3812
3848
|
}
|
|
3813
3849
|
if (Node2.isIdentifier(root)) {
|
|
3814
3850
|
const rootName = root.getText();
|
|
3815
3851
|
const importInfo = importMap.get(rootName);
|
|
3852
|
+
if (shouldDebug) {
|
|
3853
|
+
debugFunctions(` Raiz: ${rootName} (profundidade: ${depth})`);
|
|
3854
|
+
debugFunctions(` ImportInfo da raiz: ${importInfo ? JSON.stringify(importInfo) : "n\xE3o encontrado"}`);
|
|
3855
|
+
}
|
|
3816
3856
|
if (importInfo && importInfo.module.includes("firebase-functions")) {
|
|
3817
|
-
if (shouldDebug) debugFunctions(`
|
|
3857
|
+
if (shouldDebug) debugFunctions(` \u2713 Chain detectada: ${rootName}...${lastPart} from ${importInfo.module}`);
|
|
3818
3858
|
return lastPart;
|
|
3819
3859
|
}
|
|
3820
3860
|
if (["v2", "functions", "firebase", "admin"].includes(rootName)) {
|
|
3861
|
+
if (shouldDebug) debugFunctions(` \u2713 Heur\xEDstica: raiz "${rootName}" \xE9 conhecida do Firebase`);
|
|
3821
3862
|
return lastPart;
|
|
3822
3863
|
}
|
|
3823
3864
|
}
|
|
@@ -4737,13 +4778,9 @@ async function functions(options = {}) {
|
|
|
4737
4778
|
}
|
|
4738
4779
|
const functionFiles = Object.values(index.files).filter((f) => f.path.includes("functions/src/"));
|
|
4739
4780
|
const funcs = [];
|
|
4740
|
-
let totalSymbolsInFunctions = 0;
|
|
4741
|
-
let triggerSymbolsFound = 0;
|
|
4742
4781
|
for (const fileData of functionFiles) {
|
|
4743
|
-
totalSymbolsInFunctions += fileData.symbols.length;
|
|
4744
4782
|
for (const symbol of fileData.symbols) {
|
|
4745
4783
|
if (symbol.kind === "trigger") {
|
|
4746
|
-
triggerSymbolsFound++;
|
|
4747
4784
|
funcs.push({
|
|
4748
4785
|
name: symbol.name,
|
|
4749
4786
|
file: symbol.file,
|
|
@@ -4756,18 +4793,6 @@ async function functions(options = {}) {
|
|
|
4756
4793
|
}
|
|
4757
4794
|
}
|
|
4758
4795
|
}
|
|
4759
|
-
if (funcs.length === 0 && (process.env.DEBUG_FUNCTIONS === "true" || process.env.DEBUG_ANALYZE === "true")) {
|
|
4760
|
-
console.error(`[functions:debug] Total de arquivos indexados: ${Object.keys(index.files).length}`);
|
|
4761
|
-
console.error(`[functions:debug] Arquivos em functions/src/: ${functionFiles.length}`);
|
|
4762
|
-
console.error(`[functions:debug] Total de s\xEDmbolos em functions/src/: ${totalSymbolsInFunctions}`);
|
|
4763
|
-
console.error(`[functions:debug] S\xEDmbolos do tipo 'trigger': ${triggerSymbolsFound}`);
|
|
4764
|
-
functionFiles.forEach((f) => {
|
|
4765
|
-
console.error(`[functions:debug] ${f.path}: ${f.symbols.length} s\xEDmbolos`);
|
|
4766
|
-
f.symbols.forEach((s) => {
|
|
4767
|
-
console.error(`[functions:debug] - ${s.name} (${s.kind})${s.isExported ? " [exported]" : ""}`);
|
|
4768
|
-
});
|
|
4769
|
-
});
|
|
4770
|
-
}
|
|
4771
4796
|
const filtered = filterTrigger ? funcs.filter(
|
|
4772
4797
|
(f) => f.triggerType.toLowerCase().includes(filterTrigger.toLowerCase())
|
|
4773
4798
|
) : funcs;
|
|
@@ -4844,9 +4869,9 @@ function formatFunctionsText(result) {
|
|
|
4844
4869
|
`;
|
|
4845
4870
|
out += ` 3. Os triggers n\xE3o usam padr\xF5es v2 (onCall, onDocumentCreated, etc)
|
|
4846
4871
|
`;
|
|
4847
|
-
out += ` 4. O cache est\xE1 desatualizado
|
|
4872
|
+
out += ` 4. O cache est\xE1 desatualizado (ex: atualizou o ai-tool recentemente)
|
|
4848
4873
|
`;
|
|
4849
|
-
out += `
|
|
4874
|
+
out += ` \u2192 Tente: ai-tool functions --no-cache
|
|
4850
4875
|
|
|
4851
4876
|
`;
|
|
4852
4877
|
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-
|
|
16
|
+
} from "./chunk-DUFJBSFC.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-TQLA6OF6.js");
|
|
112
112
|
await startMcpServer();
|
|
113
113
|
return;
|
|
114
114
|
}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED