@vibgrate/cli 1.0.90 → 2026.4.10-2

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.
Files changed (2) hide show
  1. package/dist/cli.js +56 -17
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -572,29 +572,61 @@ function validateFactLine(line) {
572
572
  } catch {
573
573
  return { valid: false, error: `Invalid JSON: ${line.substring(0, 80)}...` };
574
574
  }
575
- const envelope = parsed;
576
- if (typeof envelope.factId !== "string" || !envelope.factId) {
575
+ const obj = parsed;
576
+ if (obj.factType === "Models" || obj.factType === "References") {
577
+ if (obj.payload === void 0 || obj.payload === null) {
578
+ return { valid: false, error: `Preamble ${obj.factType} missing payload` };
579
+ }
580
+ return { valid: true };
581
+ }
582
+ if (typeof obj.factId !== "string" || !obj.factId) {
577
583
  return { valid: false, error: "Missing or invalid factId" };
578
584
  }
579
- if (typeof envelope.factType !== "string" || !envelope.factType) {
585
+ if (typeof obj.m === "string") {
586
+ if (obj.payload === void 0 || obj.payload === null) {
587
+ return { valid: false, error: "Compressed fact missing payload" };
588
+ }
589
+ return { valid: true };
590
+ }
591
+ if (typeof obj.factType !== "string" || !obj.factType) {
580
592
  return { valid: false, error: "Missing or invalid factType" };
581
593
  }
582
- if (typeof envelope.language !== "string") {
594
+ if (typeof obj.language !== "string") {
583
595
  return { valid: false, error: "Missing or invalid language" };
584
596
  }
585
- if (typeof envelope.scanner !== "string") {
597
+ if (typeof obj.scanner !== "string") {
586
598
  return { valid: false, error: "Missing or invalid scanner" };
587
599
  }
588
- if (typeof envelope.scannerVersion !== "string") {
600
+ if (typeof obj.scannerVersion !== "string") {
589
601
  return { valid: false, error: "Missing or invalid scannerVersion" };
590
602
  }
591
- if (typeof envelope.emittedAt !== "string") {
603
+ if (typeof obj.emittedAt !== "string") {
592
604
  return { valid: false, error: "Missing or invalid emittedAt" };
593
605
  }
594
- if (envelope.payload === void 0 || envelope.payload === null) {
606
+ if (obj.payload === void 0 || obj.payload === null) {
595
607
  return { valid: false, error: "Missing payload" };
596
608
  }
597
- return { valid: true, fact: envelope };
609
+ return { valid: true };
610
+ }
611
+ function splitHcsOutput(lines) {
612
+ const preamble = [];
613
+ const facts = [];
614
+ for (const line of lines) {
615
+ let parsed;
616
+ try {
617
+ parsed = JSON.parse(line);
618
+ } catch {
619
+ facts.push(line);
620
+ continue;
621
+ }
622
+ const obj = parsed;
623
+ if (obj.factType === "Models" || obj.factType === "References") {
624
+ preamble.push(line);
625
+ } else {
626
+ facts.push(line);
627
+ }
628
+ }
629
+ return { preamble, facts };
598
630
  }
599
631
  function resolveHcsWorkerBin() {
600
632
  const base = import.meta.dirname ?? path6.dirname(new URL(import.meta.url).pathname);
@@ -1212,6 +1244,7 @@ var extractCommand = new Command5("extract").description("Analyze source code an
1212
1244
  );
1213
1245
  const progress = new ProgressTracker(runnableLanguages);
1214
1246
  const sem = new Semaphore(concurrency);
1247
+ const allPreamble = [];
1215
1248
  const allFacts = [];
1216
1249
  const allErrors = [];
1217
1250
  let hasSchemaFailure = false;
@@ -1237,14 +1270,12 @@ var extractCommand = new Command5("extract").description("Analyze source code an
1237
1270
  if (result.exitCode === EXIT_TIMEOUT) {
1238
1271
  hasTimeout = true;
1239
1272
  }
1273
+ const { preamble, facts } = splitHcsOutput(result.facts);
1274
+ allPreamble.push(...preamble);
1240
1275
  let langFactCount = 0;
1241
- for (const line of result.facts) {
1276
+ for (const line of [...preamble, ...facts]) {
1242
1277
  const validation = validateFactLine(line);
1243
- if (validation.valid) {
1244
- allFacts.push(line);
1245
- langFactCount++;
1246
- progress.onFact();
1247
- } else {
1278
+ if (!validation.valid) {
1248
1279
  hasSchemaFailure = true;
1249
1280
  allErrors.push(`[${language}] Schema validation: ${validation.error}`);
1250
1281
  if (opts.verbose) {
@@ -1253,6 +1284,13 @@ var extractCommand = new Command5("extract").description("Analyze source code an
1253
1284
  }
1254
1285
  }
1255
1286
  }
1287
+ for (const line of facts) {
1288
+ if (validateFactLine(line).valid) {
1289
+ allFacts.push(line);
1290
+ langFactCount++;
1291
+ progress.onFact();
1292
+ }
1293
+ }
1256
1294
  progress.setLanguageFactCount(language, langFactCount);
1257
1295
  if (result.errors.length > 0) {
1258
1296
  allErrors.push(...result.errors.map((e) => `[${language}] ${e}`));
@@ -1266,7 +1304,8 @@ var extractCommand = new Command5("extract").description("Analyze source code an
1266
1304
  const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
1267
1305
  progress.finish(elapsed);
1268
1306
  allFacts.sort();
1269
- const ndjsonOutput = allFacts.map((f) => f).join("\n") + (allFacts.length > 0 ? "\n" : "");
1307
+ const allLines = [...allPreamble, ...allFacts];
1308
+ const ndjsonOutput = allLines.join("\n") + (allLines.length > 0 ? "\n" : "");
1270
1309
  if (opts.out) {
1271
1310
  const outPath = path6.resolve(opts.out);
1272
1311
  await fs2.writeFile(outPath, ndjsonOutput, "utf-8");
@@ -1276,7 +1315,7 @@ var extractCommand = new Command5("extract").description("Analyze source code an
1276
1315
  process.stdout.write(ndjsonOutput);
1277
1316
  }
1278
1317
  if (opts.push && dsn && allFacts.length > 0) {
1279
- const pushOk = await pushFacts(allFacts, dsn, opts.verbose ?? false);
1318
+ const pushOk = await pushFacts(allLines, dsn, opts.verbose ?? false);
1280
1319
  if (!pushOk) {
1281
1320
  process.exit(EXIT_PUSH_FAILURE);
1282
1321
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibgrate/cli",
3
- "version": "1.0.90",
3
+ "version": "2026.4.10-2",
4
4
  "description": "CLI for measuring upgrade drift across Node, .NET, Python & Java projects",
5
5
  "type": "module",
6
6
  "bin": {