@vibgrate/cli 2026.720.4 → 2026.721.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.
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { resolveDsn, resolveIngestHost, dashHostForIngestHost, resolveCliInvocation, availableRegionIds, createWorkspaceDsn, writeStoredCredentials, credentialsPath, findGitRoot, ensureGitignored, gitignoreEntryForCredentials, clearStoredCredentials, inventory, uploadScanArtifact, ingestHostForRegionId, dsnCommand, pushCommand, CliError, ExitCode, NPX_INVOCATION, refreshIfStale, driftCount, embeddingsCached, resolveEmbedModel, loadEmbedder, getNodeEmbeddings, queryGraphSemantic, queryGraph, unavailableMessage, recordCliCall, CLI_TOOL_ALIASES, countPending, resolveOne, indexFor, countTokens, shortestPath, renderReport, impactOf, testsToRun, detectRunner, defaultGraphPath, savingsLedgerPath, serveStdio, ASSISTANTS, detectAssistants, usageError, loadGraph, detectServeLaunch, installAssistant, writeNavigationConfig, uninstallAssistant, coveringTests, FREE_PACK, readScanArtifact, enrichOnline, ECOSYSTEMS, discoverModels, readSavings, readUsage, exportGraph, catalogPath, libDir, stableStringify, buildGraph, writeArtifacts, writeSnapshot, UsageError, ResourceLimitError, refreshInstalledInstructions, SMALL_REPO_FILES, epistemicBreakdown, cacheDir, probeFreshness, discover, vibgrateDir, modelCacheInfo, clearModelCache, GraphSource, createServer, assistantById, serializeGraph, resolveLimits, loadCatalog, driftFor, addLibrary, parseDsn as parseDsn$1, publishPrivateLibrary, resolveLib, libId, resolveVersion, readDoc, localPackageDocs, localApiSurface, assessDocQuality, symbolsFromApi, fetchHostedDocsCached, selectForBudget, formatForExt, hostedBase, verifyDeterminism, renderHtml, isModelReady, SAVINGS_TOOLS, sanitizeClient, readStoredCredentials, projectCredentialsPath, homeCredentialsPath, SKIP_DIRS, SKIP_FILES } from './chunk-AS7DIHZZ.js';
3
- import { resolvedGrammarFiles, grammarSetVersion, hashString, canonicalize, hashBytes } from './chunk-BHA7QIPD.js';
4
- import { loadAdvancedScanHook, baselineCommand } from './chunk-ULAYELSU.js';
5
- import { ensureDir, pathExists, writeDefaultConfig, parseDsn, detectVcs, computeRepoFingerprint, resolveRepositoryName, fetchScanPreflight, runCoreScan, VERSION, readJsonFile, writeTextFile, loadConfig, prepareCompressedUpload, computeDriftScore, titleBox, projectTypeToVulnEcosystem, driftBar, gitHistoryAvailable, buildVersionTimelines, findPackageAnyEcosystem, normalizeConstraint, findVersionCrossings, versionSatisfies, PROJECT_TYPE_TO_OSV_ECOSYSTEM, fetchRiskySymbols, brandProgressBar, resolveHead, workingTreeDirty } from './chunk-RAQBGOP5.js';
2
+ import { resolveDsn, resolveIngestHost, dashHostForIngestHost, resolveCliInvocation, availableRegionIds, createWorkspaceDsn, writeStoredCredentials, credentialsPath, findGitRoot, ensureGitignored, gitignoreEntryForCredentials, clearStoredCredentials, inventory, uploadScanArtifact, cacheDir, ingestHostForRegionId, dsnCommand, pushCommand, CliError, ExitCode, NPX_INVOCATION, refreshIfStale, driftCount, embeddingsCached, resolveEmbedModel, loadEmbedder, getNodeEmbeddings, queryGraphSemantic, queryGraph, unavailableMessage, recordCliCall, CLI_TOOL_ALIASES, countPending, resolveOne, indexFor, countTokens, shortestPath, renderReport, impactOf, testsToRun, detectRunner, defaultGraphPath, savingsLedgerPath, serveStdio, ASSISTANTS, detectAssistants, usageError, loadGraph, detectServeLaunch, installAssistant, writeNavigationConfig, uninstallAssistant, coveringTests, FREE_PACK, readScanArtifact, enrichOnline, ECOSYSTEMS, discoverModels, clearSavings, readSavings, readUsage, exportGraph, catalogPath, libDir, stableStringify, buildGraph, writeArtifacts, writeSnapshot, UsageError, ResourceLimitError, refreshInstalledInstructions, SMALL_REPO_FILES, epistemicBreakdown, probeFreshness, discover, vibgrateDir, modelCacheInfo, clearModelCache, GraphSource, createServer, assistantById, serializeGraph, resolveLimits, loadCatalog, driftFor, addLibrary, parseDsn as parseDsn$1, publishPrivateLibrary, resolveLib, libId, resolveVersion, readDoc, localPackageDocs, localApiSurface, assessDocQuality, symbolsFromApi, fetchHostedDocsCached, selectForBudget, formatForExt, hostedBase, verifyDeterminism, renderHtml, isModelReady, SAVINGS_TOOLS, sanitizeClient, readStoredCredentials, projectCredentialsPath, homeCredentialsPath, SKIP_DIRS, SKIP_FILES } from './chunk-3DPZQS2Q.js';
3
+ import { resolvedGrammarFiles, grammarSetVersion, hashString, canonicalize, hashBytes } from './chunk-JWBS5GS6.js';
4
+ import { loadAdvancedScanHook, baselineCommand } from './chunk-MUMBLIDO.js';
5
+ import { ensureDir, pathExists, writeDefaultConfig, parseDsn, detectVcs, computeRepoFingerprint, resolveRepositoryName, fetchScanPreflight, runCoreScan, VERSION, readJsonFile, writeTextFile, loadConfig, prepareCompressedUpload, computeDriftScore, titleBox, projectTypeToVulnEcosystem, driftBar, gitHistoryAvailable, buildVersionTimelines, findPackageAnyEcosystem, normalizeConstraint, findVersionCrossings, versionSatisfies, PROJECT_TYPE_TO_OSV_ECOSYSTEM, fetchRiskySymbols, brandProgressBar, resolveHead, workingTreeDirty } from './chunk-NHLSAZ6N.js';
6
6
  import './chunk-RXP66R2E.js';
7
7
  import { pathExists as pathExists$1, parseExcludePatterns } from './chunk-GI6W53LM.js';
8
8
  import * as fs10 from 'fs';
@@ -1524,6 +1524,35 @@ var STALE_MS = 6e4;
1524
1524
  function liveStatsDir(root) {
1525
1525
  return path.join(cacheDir(root), "serve-live");
1526
1526
  }
1527
+ function reapOtherVersionServers(dir, keepVersion, now2 = Date.now(), kill = (pid, signal) => process.kill(pid, signal), selfPid = process.pid) {
1528
+ let entries;
1529
+ try {
1530
+ entries = fs10.readdirSync(dir);
1531
+ } catch {
1532
+ return [];
1533
+ }
1534
+ const reaped = [];
1535
+ for (const name of entries) {
1536
+ if (!/^serve-\d+\.json$/.test(name)) continue;
1537
+ let parsed;
1538
+ try {
1539
+ parsed = JSON.parse(fs10.readFileSync(path.join(dir, name), "utf8"));
1540
+ } catch {
1541
+ continue;
1542
+ }
1543
+ if (typeof parsed?.pid !== "number" || typeof parsed.updatedAt !== "number") continue;
1544
+ if (parsed.pid === selfPid) continue;
1545
+ if (now2 - parsed.updatedAt > STALE_MS) continue;
1546
+ const version = typeof parsed.version === "string" ? parsed.version : "unknown";
1547
+ if (version === keepVersion) continue;
1548
+ try {
1549
+ kill(parsed.pid, "SIGTERM");
1550
+ reaped.push({ pid: parsed.pid, version });
1551
+ } catch {
1552
+ }
1553
+ }
1554
+ return reaped;
1555
+ }
1527
1556
  var LiveStatsBus = class {
1528
1557
  constructor(dir, stats, pid = process.pid) {
1529
1558
  this.dir = dir;
@@ -1559,7 +1588,7 @@ var LiveStatsBus = class {
1559
1588
  if (snap.revision === this.lastRevision && now2 - this.lastWriteAt < KEEPALIVE_MS) return;
1560
1589
  this.lastRevision = snap.revision;
1561
1590
  this.lastWriteAt = now2;
1562
- const body = { pid: this.pid, updatedAt: now2, snapshot: snap };
1591
+ const body = { pid: this.pid, updatedAt: now2, version: VERSION, snapshot: snap };
1563
1592
  try {
1564
1593
  fs10.mkdirSync(this.dir, { recursive: true });
1565
1594
  const tmp = `${this.file}.tmp`;
@@ -3993,10 +4022,21 @@ function registerModels(program) {
3993
4022
 
3994
4023
  // src/commands/savings.ts
3995
4024
  function registerSavings(program) {
3996
- const cmd = program.command("savings").description("local, privacy-safe report of tokens/$ saved vs a grep baseline (estimates)").option("--days <n>", "window in days", "30").action(function() {
4025
+ const cmd = program.command("savings").description("local, privacy-safe report of tokens/$ saved vs a grep baseline (estimates)").option("--days <n>", "window in days", "30").option("--clear", "delete the recorded usage data for this repo").action(function() {
3997
4026
  const global = readGlobal(this);
3998
4027
  const days = Number(this.opts().days) || 30;
3999
4028
  const root = rootOf(global);
4029
+ if (this.opts().clear) {
4030
+ const existed = clearSavings(root);
4031
+ if (global.json) {
4032
+ json({ ok: true, cleared: existed });
4033
+ return;
4034
+ }
4035
+ info(
4036
+ existed ? `${c.cyan("vg savings")} ${c.dim("--clear")} \xB7 usage data deleted for this repo` : `${c.cyan("vg savings")} ${c.dim("--clear")} \xB7 nothing recorded here \u2014 nothing to delete`
4037
+ );
4038
+ return;
4039
+ }
4000
4040
  const now2 = Date.now();
4001
4041
  const report = readSavings(root, days, now2);
4002
4042
  const usage = readUsage(root, days, now2);
@@ -4469,7 +4509,7 @@ var initCommand = new Command("init").description("Initialize vibgrate in a proj
4469
4509
  console.log(chalk8.green("\u2714") + ` Created ${chalk8.bold("vibgrate.config.ts")}`);
4470
4510
  }
4471
4511
  if (opts.baseline) {
4472
- const { runBaseline } = await import('./baseline-YJT32DP2.js');
4512
+ const { runBaseline } = await import('./baseline-KK7ZLRZB.js');
4473
4513
  await runBaseline(rootDir);
4474
4514
  }
4475
4515
  console.log("");
@@ -5895,7 +5935,7 @@ async function confirmWorkspaceRoot(pm) {
5895
5935
  });
5896
5936
  });
5897
5937
  }
5898
- var updateCommand = new Command("update").description("Update vibgrate to the latest version").option("--check", "Only check for updates, do not install").option("--pm <manager>", "Package manager to use (npm, pnpm, yarn, bun)").option("--global", "Update global installation").option("-y, --yes", "Skip confirmation prompts (e.g. installing at a workspace root)").option("-w, --workspace-root", "Allow updating the pnpm workspace root (implies --yes for that prompt)").action(
5938
+ var updateCommand = new Command("update").description("Update vibgrate to the latest version").option("--check", "Only check for updates, do not install").option("--pm <manager>", "Package manager to use (npm, pnpm, yarn, bun)").option("--global", "Update global installation").option("-y, --yes", "Skip confirmation prompts (e.g. installing at a workspace root)").option("-w, --workspace-root", "Allow updating the pnpm workspace root (implies --yes for that prompt)").option("--no-reap", "Do not signal running vg serve processes on an older version to restart").action(
5899
5939
  async (opts) => {
5900
5940
  console.log(chalk8.dim(`Current version: ${VERSION}`));
5901
5941
  console.log(chalk8.dim("Checking npm registry..."));
@@ -5907,6 +5947,7 @@ var updateCommand = new Command("update").description("Update vibgrate to the la
5907
5947
  const semver2 = await import('semver');
5908
5948
  if (!semver2.gt(latest, VERSION)) {
5909
5949
  console.log(chalk8.green("\u2714") + ` You are on the latest version (${VERSION}).`);
5950
+ if (opts.reap !== false) reapAndReport(process.cwd(), VERSION);
5910
5951
  return;
5911
5952
  }
5912
5953
  console.log(chalk8.yellow(`Update available: ${VERSION} \u2192 ${latest}`));
@@ -5962,8 +6003,29 @@ var updateCommand = new Command("update").description("Update vibgrate to the la
5962
6003
  console.error(chalk8.red(`Update failed. Run manually: ${cmd}`));
5963
6004
  process.exit(1);
5964
6005
  }
6006
+ if (opts.reap !== false) reapAndReport(cwd, latest);
5965
6007
  }
5966
6008
  );
6009
+ function reapAndReport(cwd, keepVersion) {
6010
+ let reaped = [];
6011
+ try {
6012
+ reaped = reapOtherVersionServers(liveStatsDir(cwd), keepVersion);
6013
+ } catch {
6014
+ return;
6015
+ }
6016
+ if (reaped.length === 0) return;
6017
+ const list = reaped.map((r) => `pid ${r.pid} (v${r.version})`).join(", ");
6018
+ console.log(
6019
+ chalk8.dim(
6020
+ `Signalled ${reaped.length} running vg serve process${reaped.length === 1 ? "" : "es"} on an older version to restart: ${list}.`
6021
+ )
6022
+ );
6023
+ console.log(
6024
+ chalk8.dim(
6025
+ "Your editor/agent will respawn them on the new version. Restart your AI session if a server does not reconnect."
6026
+ )
6027
+ );
6028
+ }
5967
6029
 
5968
6030
  // src/reporting/commands/fix.ts
5969
6031
  var SEVERITY_RANK = { unknown: 0, low: 1, moderate: 2, high: 3, critical: 4 };