@vibgrate/cli 1.0.90 → 2026.4.10
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.
- package/dist/cli.js +86 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -596,6 +596,90 @@ function validateFactLine(line) {
|
|
|
596
596
|
}
|
|
597
597
|
return { valid: true, fact: envelope };
|
|
598
598
|
}
|
|
599
|
+
function decompressHcsLines(lines) {
|
|
600
|
+
if (lines.length === 0) return lines;
|
|
601
|
+
let modelsLine = null;
|
|
602
|
+
let refsLine = null;
|
|
603
|
+
const contentLines = [];
|
|
604
|
+
for (const line of lines) {
|
|
605
|
+
let parsed;
|
|
606
|
+
try {
|
|
607
|
+
parsed = JSON.parse(line);
|
|
608
|
+
} catch {
|
|
609
|
+
contentLines.push(line);
|
|
610
|
+
continue;
|
|
611
|
+
}
|
|
612
|
+
const obj = parsed;
|
|
613
|
+
if (obj.factType === "Models" && !modelsLine) {
|
|
614
|
+
modelsLine = obj;
|
|
615
|
+
} else if (obj.factType === "References" && !refsLine) {
|
|
616
|
+
refsLine = obj;
|
|
617
|
+
} else {
|
|
618
|
+
contentLines.push(line);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
if (!modelsLine) return lines;
|
|
622
|
+
const emittedAt = typeof modelsLine.emittedAt === "string" ? modelsLine.emittedAt : (/* @__PURE__ */ new Date()).toISOString();
|
|
623
|
+
const modelsPayload = modelsLine.payload;
|
|
624
|
+
const modelMap = /* @__PURE__ */ new Map();
|
|
625
|
+
for (const m of modelsPayload?.models ?? []) {
|
|
626
|
+
if (m.id) modelMap.set(m.id, m);
|
|
627
|
+
}
|
|
628
|
+
const refsPayload = refsLine?.payload;
|
|
629
|
+
const refMap = /* @__PURE__ */ new Map();
|
|
630
|
+
for (const r of refsPayload?.references ?? []) {
|
|
631
|
+
if (r.id && r.value) refMap.set(r.id, r.value);
|
|
632
|
+
}
|
|
633
|
+
const sortedRefs = [...refMap.entries()].sort((a, b) => b[0].length - a[0].length);
|
|
634
|
+
function expandRefs(text) {
|
|
635
|
+
for (const [token, value] of sortedRefs) {
|
|
636
|
+
text = text.split(token).join(value);
|
|
637
|
+
}
|
|
638
|
+
return text;
|
|
639
|
+
}
|
|
640
|
+
const expanded = [];
|
|
641
|
+
for (const line of contentLines) {
|
|
642
|
+
let parsed;
|
|
643
|
+
try {
|
|
644
|
+
parsed = JSON.parse(line);
|
|
645
|
+
} catch {
|
|
646
|
+
expanded.push(line);
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
const obj = parsed;
|
|
650
|
+
if (typeof obj.factType === "string") {
|
|
651
|
+
expanded.push(line);
|
|
652
|
+
continue;
|
|
653
|
+
}
|
|
654
|
+
if (typeof obj.factId !== "string" || typeof obj.m !== "string") {
|
|
655
|
+
expanded.push(line);
|
|
656
|
+
continue;
|
|
657
|
+
}
|
|
658
|
+
const model = modelMap.get(obj.m);
|
|
659
|
+
if (!model) {
|
|
660
|
+
expanded.push(line);
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
const payloadJson = expandRefs(JSON.stringify(obj.payload));
|
|
664
|
+
let payload;
|
|
665
|
+
try {
|
|
666
|
+
payload = JSON.parse(payloadJson);
|
|
667
|
+
} catch {
|
|
668
|
+
payload = obj.payload;
|
|
669
|
+
}
|
|
670
|
+
const fullEnvelope = {
|
|
671
|
+
factId: obj.factId,
|
|
672
|
+
factType: model.factType ?? "",
|
|
673
|
+
language: model.language ?? "",
|
|
674
|
+
scanner: model.scanner ?? "",
|
|
675
|
+
scannerVersion: model.scannerVersion ?? "",
|
|
676
|
+
emittedAt: model.emittedAt ?? emittedAt,
|
|
677
|
+
payload
|
|
678
|
+
};
|
|
679
|
+
expanded.push(JSON.stringify(fullEnvelope));
|
|
680
|
+
}
|
|
681
|
+
return expanded;
|
|
682
|
+
}
|
|
599
683
|
function resolveHcsWorkerBin() {
|
|
600
684
|
const base = import.meta.dirname ?? path6.dirname(new URL(import.meta.url).pathname);
|
|
601
685
|
const bundledPath = path6.resolve(base, "..", "dist", "hcs-worker.js");
|
|
@@ -1237,8 +1321,9 @@ var extractCommand = new Command5("extract").description("Analyze source code an
|
|
|
1237
1321
|
if (result.exitCode === EXIT_TIMEOUT) {
|
|
1238
1322
|
hasTimeout = true;
|
|
1239
1323
|
}
|
|
1324
|
+
const decompressedFacts = decompressHcsLines(result.facts);
|
|
1240
1325
|
let langFactCount = 0;
|
|
1241
|
-
for (const line of
|
|
1326
|
+
for (const line of decompressedFacts) {
|
|
1242
1327
|
const validation = validateFactLine(line);
|
|
1243
1328
|
if (validation.valid) {
|
|
1244
1329
|
allFacts.push(line);
|