@vibgrate/cli 2026.718.2 → 2026.720.1

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.
@@ -1,5 +1,5 @@
1
1
  import { hashString, langById, shortId, canonicalize, grammarSetVersion, hashBytes, langForExtension, setGrammarsOverride, parseSource } from './chunk-VFO5UDAT.js';
2
- import { writeTextFile, pathExists, readJsonFile, loadConfig, computeUpgradeImpact, getChangelogSignals, gitHistoryAvailable, buildVersionTimelines, findPackageTimeline, severityRank, projectTypeToVulnEcosystem, VERSION } from './chunk-RME7BFMU.js';
2
+ import { writeTextFile, pathExists, readJsonFile, loadConfig, computeUpgradeImpact, getChangelogSignals, gitHistoryAvailable, buildVersionTimelines, findPackageTimeline, severityRank, projectTypeToVulnEcosystem, VERSION } from './chunk-AJDUMRVI.js';
3
3
  import * as fs19 from 'fs';
4
4
  import { spawnSync, execFileSync } from 'child_process';
5
5
  import * as path19 from 'path';
@@ -3445,6 +3445,7 @@ function readUsage(root, days, now) {
3445
3445
  const byTool = /* @__PURE__ */ new Map();
3446
3446
  const bySource = /* @__PURE__ */ new Map();
3447
3447
  const byClient = /* @__PURE__ */ new Map();
3448
+ const msByTool = /* @__PURE__ */ new Map();
3448
3449
  const bump2 = (m, key, outcome) => {
3449
3450
  const row = m.get(key) ?? { complete: 0, partial: 0, miss: 0 };
3450
3451
  row[outcome]++;
@@ -3460,18 +3461,28 @@ function readUsage(root, days, now) {
3460
3461
  bump2(byTool, e.tool, outcome);
3461
3462
  bump2(bySource, e.source ?? "mcp", outcome);
3462
3463
  bump2(byClient, e.client ?? "unknown", outcome);
3464
+ if (typeof e.ms === "number" && e.ms >= 0) {
3465
+ const timing = msByTool.get(e.tool) ?? { sum: 0, n: 0 };
3466
+ timing.sum += e.ms;
3467
+ timing.n++;
3468
+ msByTool.set(e.tool, timing);
3469
+ }
3463
3470
  } catch {
3464
3471
  }
3465
3472
  }
3466
3473
  }
3467
- const commands = toDimensionStats(byTool).map((d) => ({
3468
- tool: d.key,
3469
- calls: d.calls,
3470
- complete: d.complete,
3471
- partial: d.partial,
3472
- miss: d.miss,
3473
- successPct: d.successPct
3474
- }));
3474
+ const commands = toDimensionStats(byTool).map((d) => {
3475
+ const timing = msByTool.get(d.key);
3476
+ return {
3477
+ tool: d.key,
3478
+ calls: d.calls,
3479
+ complete: d.complete,
3480
+ partial: d.partial,
3481
+ miss: d.miss,
3482
+ successPct: d.successPct,
3483
+ avgMs: timing && timing.n > 0 ? Math.round(timing.sum / timing.n) : null
3484
+ };
3485
+ });
3475
3486
  const totals = commands.reduce(
3476
3487
  (t, c) => ({
3477
3488
  calls: t.calls + c.calls,
@@ -6878,7 +6889,7 @@ var GraphSource = class {
6878
6889
  }
6879
6890
  };
6880
6891
  function createServer(source, opts = {}) {
6881
- const { savings = false, shareStats = false, local = false, dedup = false } = opts;
6892
+ const { savings = false, shareStats = false, local = false, dedup = false, stats } = opts;
6882
6893
  const record = savings || shareStats;
6883
6894
  const root = path19.dirname(path19.dirname(source.graphPath));
6884
6895
  const seen = /* @__PURE__ */ new Set();
@@ -6913,12 +6924,23 @@ function createServer(source, opts = {}) {
6913
6924
  "no code map found. Run `vg` in the project to build .vibgrate/graph.json, then retry."
6914
6925
  );
6915
6926
  }
6927
+ const startedAt = Date.now();
6916
6928
  try {
6917
6929
  const args = request.params.arguments ?? {};
6918
6930
  const result = await tool.handler(graph, args, { root, local, dedup, seen });
6919
- if (record) recordUsage(root, tool.name, result, detectClient(server));
6931
+ const ms = Date.now() - startedAt;
6932
+ stats?.record({ ...measureCall(tool.name, result), client: sanitizeClient(detectClient(server)), ms });
6933
+ if (record) recordUsage(root, tool.name, result, detectClient(server), ms);
6920
6934
  return renderToolResult(result);
6921
6935
  } catch (err) {
6936
+ stats?.record({
6937
+ tool: tool.name,
6938
+ client: sanitizeClient(detectClient(server)),
6939
+ outcome: "miss",
6940
+ ms: Date.now() - startedAt,
6941
+ vgTokens: 0,
6942
+ baselineTokens: 0
6943
+ });
6922
6944
  return errorResult(`tool "${tool.name}" failed: ${err.message}`);
6923
6945
  }
6924
6946
  });
@@ -6936,7 +6958,14 @@ function sleep(ms) {
6936
6958
  timer.unref?.();
6937
6959
  });
6938
6960
  }
6939
- function recordUsage(root, tool, result, client) {
6961
+ function recordUsage(root, tool, result, client, ms) {
6962
+ recordSaving(
6963
+ root,
6964
+ { ...measureCall(tool, result), source: "mcp", client: sanitizeClient(client), ...ms !== void 0 ? { ms } : {} },
6965
+ Date.now()
6966
+ );
6967
+ }
6968
+ function measureCall(tool, result) {
6940
6969
  const outcome = classifyOutcome(result);
6941
6970
  let vgTokens = 0;
6942
6971
  let baselineTokens = 0;
@@ -6944,11 +6973,7 @@ function recordUsage(root, tool, result, client) {
6944
6973
  vgTokens = countTokens(renderedText(renderToolResult(result)));
6945
6974
  baselineTokens = referencedFiles(result).size * PER_FILE_TOKENS;
6946
6975
  }
6947
- recordSaving(
6948
- root,
6949
- { tool, outcome, vgTokens, baselineTokens, source: "mcp", client: sanitizeClient(client) },
6950
- Date.now()
6951
- );
6976
+ return { tool, outcome, vgTokens, baselineTokens };
6952
6977
  }
6953
6978
  function detectClient(server) {
6954
6979
  try {
@@ -7564,6 +7589,6 @@ function spdx(ctx) {
7564
7589
  return JSON.stringify(doc, null, 2) + "\n";
7565
7590
  }
7566
7591
 
7567
- export { ASSISTANTS, CLI_TOOL_ALIASES, CliError, ECOSYSTEMS, ExitCode, FREE_PACK, GraphIndex, GraphSource, NPX_INVOCATION, ResourceLimitError, SCHEMA_VERSION, SKIP_DIRS, SKIP_FILES, TOOLS, UsageError, addLibrary, analyze, applyCoverage, applyStaticTestLinkage, assessDocQuality, assistantById, availableRegionIds, buildFacts, buildGraph, buildModuleResolver, cacheDir, catalogPath, clearModelCache, clearStoredCredentials, cosine, countPending, countTokens, coveringTests, createServer, createWorkspaceDsn, credentialsPath, dashHostForIngestHost, decodeScipIndex, defaultGraphPath, detectAssistants, detectRunner, detectServeLaunch, discover, discoverModels, driftCount, driftFor, dsnCommand, embeddingsCached, enrichOnline, ensureGitignored, epistemicBreakdown, exportGraph, fetchHostedDocsCached, findGitRoot, findNodes, formatForExt, getNodeEmbeddings, gitignoreEntryForCredentials, groundGraph, hasDrift, homeCredentialsPath, hostedBase, identifierParts, impactOf, indexFor, ingestHostForRegionId, installAssistant, inventory, isModelReady, isTestFile, libDir, libId, loadCatalog, loadCoverage, loadEmbedder, loadGraph, loadSnapshot, localApiSurface, localPackageDocs, modelCacheInfo, nodeById, nodeEmbedText, parseDsn, parseGraph, parseJsonc, probeFreshness, projectCredentialsPath, publishPrivateLibrary, pushCommand, queryGraph, queryGraphSemantic, readDoc, readSavings, readScanArtifact, readStoredCredentials, readUsage, recordCliCall, recordSaving, refreshIfStale, relativeResolver, renderHtml, renderReport, resolveCliInvocation, resolveDsn, resolveEmbedModel, resolveIngestHost, resolveLib, resolveLimits, resolveOne, resolveVersion, saveCatalog, savingsRecorded, scipEdges, selectForBudget, serializeGraph, serveStdio, shortestPath, stableStringify, symbolsFromApi, testsToRun, unavailableMessage, uninstallAssistant, uploadScanArtifact, usageError, verifyDeterminism, vibgrateDir, writeArtifacts, writeNavigationConfig, writeSnapshot, writeStoredCredentials };
7568
- //# sourceMappingURL=chunk-H5M7CXE6.js.map
7569
- //# sourceMappingURL=chunk-H5M7CXE6.js.map
7592
+ export { ASSISTANTS, CLI_TOOL_ALIASES, CliError, DEFAULT_RATE_LABEL, DEFAULT_RATE_PER_M, ECOSYSTEMS, ExitCode, FREE_PACK, GraphIndex, GraphSource, NPX_INVOCATION, ResourceLimitError, SAVINGS_TOOLS, SCHEMA_VERSION, SKIP_DIRS, SKIP_FILES, TOOLS, UsageError, addLibrary, analyze, applyCoverage, applyStaticTestLinkage, assessDocQuality, assistantById, availableRegionIds, buildFacts, buildGraph, buildModuleResolver, cacheDir, catalogPath, clearModelCache, clearStoredCredentials, cosine, countPending, countTokens, coveringTests, createServer, createWorkspaceDsn, credentialsPath, dashHostForIngestHost, decodeScipIndex, defaultGraphPath, detectAssistants, detectRunner, detectServeLaunch, discover, discoverModels, driftCount, driftFor, dsnCommand, embeddingsCached, enrichOnline, ensureGitignored, epistemicBreakdown, exportGraph, fetchHostedDocsCached, findGitRoot, findNodes, formatForExt, getNodeEmbeddings, gitignoreEntryForCredentials, groundGraph, hasDrift, homeCredentialsPath, hostedBase, identifierParts, impactOf, indexFor, ingestHostForRegionId, installAssistant, inventory, isModelReady, isTestFile, libDir, libId, loadCatalog, loadCoverage, loadEmbedder, loadGraph, loadSnapshot, localApiSurface, localPackageDocs, modelCacheInfo, nodeById, nodeEmbedText, parseDsn, parseGraph, parseJsonc, probeFreshness, projectCredentialsPath, publishPrivateLibrary, pushCommand, queryGraph, queryGraphSemantic, readDoc, readSavings, readScanArtifact, readStoredCredentials, readUsage, recordCliCall, recordSaving, refreshIfStale, relativeResolver, renderHtml, renderReport, resolveCliInvocation, resolveDsn, resolveEmbedModel, resolveIngestHost, resolveLib, resolveLimits, resolveOne, resolveVersion, saveCatalog, savingsRecorded, scipEdges, selectForBudget, serializeGraph, serveStdio, shortestPath, stableStringify, symbolsFromApi, testsToRun, unavailableMessage, uninstallAssistant, uploadScanArtifact, usageError, verifyDeterminism, vibgrateDir, writeArtifacts, writeNavigationConfig, writeSnapshot, writeStoredCredentials };
7593
+ //# sourceMappingURL=chunk-VQLOVQZP.js.map
7594
+ //# sourceMappingURL=chunk-VQLOVQZP.js.map